更新前端文件
This commit is contained in:
32
public/static/libs/requirejs-plugins/.bower.json
Normal file
32
public/static/libs/requirejs-plugins/.bower.json
Normal file
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "requirejs-plugins",
|
||||
"version": "1.0.3",
|
||||
"main": [
|
||||
"src/async.js",
|
||||
"src/depend.js",
|
||||
"src/font.js",
|
||||
"src/goog.js",
|
||||
"src/image.js",
|
||||
"src/json.js",
|
||||
"src/mdown.js",
|
||||
"src/noext.js",
|
||||
"src/propertyParser.js",
|
||||
"lib/Markdown.Converter.js",
|
||||
"lib/text.js"
|
||||
],
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"components"
|
||||
],
|
||||
"homepage": "https://github.com/millermedeiros/requirejs-plugins",
|
||||
"_release": "1.0.3",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v1.0.3",
|
||||
"commit": "ac9de4bfae70b0630754a9faf93c42db362cb9a2"
|
||||
},
|
||||
"_source": "https://github.com/millermedeiros/requirejs-plugins.git",
|
||||
"_target": "~1.0.3",
|
||||
"_originalSource": "requirejs-plugins"
|
||||
}
|
||||
148
public/static/libs/requirejs-plugins/README.mdown
Normal file
148
public/static/libs/requirejs-plugins/README.mdown
Normal file
@@ -0,0 +1,148 @@
|
||||
# RequireJS plugins
|
||||
|
||||
Small set of plugins for [RequireJS](http://requirejs.org). Some plugins may
|
||||
also work on other AMD loaders (never tested it).
|
||||
|
||||
For more plugins check [RequireJS Wiki](https://github.com/jrburke/requirejs/wiki/Plugins).
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
You can use [bower](http://bower.io/) to install it easily:
|
||||
|
||||
```
|
||||
bower install --save requirejs-plugins
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Plugins
|
||||
|
||||
- **async** : Useful for JSONP and asynchronous dependencies (e.g. Google Maps).
|
||||
- **font** : Load web fonts using the [WebFont Loader API](https://code.google.com/apis/webfonts/docs/webfont_loader.html)
|
||||
(requires `propertyParser`)
|
||||
- **goog** : Load [Google APIs](http://code.google.com/apis/loader/)
|
||||
asynchronously (requires `async!` plugin and `propertyParser`).
|
||||
- **image** : Load image files as dependencies. Option to "cache bust".
|
||||
- **json** : Load JSON files and parses the result. (Requires `text!` plugin).
|
||||
- **mdown** : Load Markdown files and parses into HTML. (Requires `text!`
|
||||
plugin and a markdown converter).
|
||||
- **noext** : Load scripts without appending ".js" extension, useful for
|
||||
dynamic scripts.
|
||||
|
||||
### Other
|
||||
|
||||
- **propertyParser** : Just a helper used by some plugins to parse
|
||||
arguments (not a real plugin).
|
||||
|
||||
|
||||
|
||||
## Documentation
|
||||
|
||||
check the `examples` folder. All the info you probably need will be inside
|
||||
comments or on the example code itself.
|
||||
|
||||
|
||||
|
||||
## Basic usage
|
||||
|
||||
Put the plugins inside the `baseUrl` folder (usually same folder as the main.js
|
||||
file) or create an alias to the plugin location:
|
||||
|
||||
```js
|
||||
require.config({
|
||||
paths : {
|
||||
//create alias to plugins (not needed if plugins are on the baseUrl)
|
||||
async: 'lib/require/async',
|
||||
font: 'lib/require/font',
|
||||
goog: 'lib/require/goog',
|
||||
image: 'lib/require/image',
|
||||
json: 'lib/require/json',
|
||||
noext: 'lib/require/noext',
|
||||
mdown: 'lib/require/mdown',
|
||||
propertyParser : 'lib/require/propertyParser',
|
||||
markdownConverter : 'lib/Markdown.Converter'
|
||||
}
|
||||
});
|
||||
|
||||
//use plugins as if they were at baseUrl
|
||||
define([
|
||||
'image!awsum.jpg',
|
||||
'json!data/foo.json',
|
||||
'noext!js/bar.php',
|
||||
'mdown!data/lorem_ipsum.md',
|
||||
'async!http://maps.google.com/maps/api/js?sensor=false',
|
||||
'goog!visualization,1,packages:[corechart,geochart]',
|
||||
'goog!search,1',
|
||||
'font!google,families:[Tangerine,Cantarell]'
|
||||
], function(awsum, foo, bar, loremIpsum){
|
||||
//all dependencies are loaded (including gmaps and other google apis)
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
## Removing plugin code after build
|
||||
|
||||
[r.js](https://github.com/jrburke/r.js/blob/master/build/example.build.js)
|
||||
nowadays have the `stubModules` setting which can be used to remove the whole
|
||||
plugin code:
|
||||
|
||||
```js
|
||||
({
|
||||
// will remove whole source code of "json" and "text" plugins during build
|
||||
// JSON/text files that are bundled during build will still work fine but
|
||||
// you won't be able to load JSON/text files dynamically after build
|
||||
stubModules : ['json', 'text']
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
## Notes about the Markdown plugin
|
||||
|
||||
The Markdown plugin was created mainly to be used to compile the markdown files
|
||||
into HTML during the build step, if you set `pragmasOnSave.excludeMdown=true`
|
||||
it will remove the `Markdown.Converter.js` and `mdown.js` files from the build.
|
||||
Example build settings:
|
||||
|
||||
```js
|
||||
({
|
||||
baseUrl : './',
|
||||
pragmasOnSave : {
|
||||
excludeMdown : true
|
||||
},
|
||||
paths : {
|
||||
mdown : 'lib/requirejs/mdown',
|
||||
text : 'lib/requirejs/text',
|
||||
markdownConverter : 'lib/Markdown.Converter'
|
||||
},
|
||||
modules : {
|
||||
name : 'main'
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
If `excludeMdown=true` you won't be able to load markdown files dynamically
|
||||
after the build.
|
||||
|
||||
|
||||
|
||||
## Writing your own plugins
|
||||
|
||||
Check [RequireJS documentation](http://requirejs.org/docs/plugins.html) for
|
||||
a basic reference and use other plugins as reference. RequireJS official
|
||||
plugins are a good source for learning.
|
||||
|
||||
Also be sure to check [RequireJS Wiki](https://github.com/jrburke/requirejs/wiki/Plugins).
|
||||
|
||||
|
||||
|
||||
## Author
|
||||
|
||||
[Miller Medeiros](http://blog.millermedeiros.com/)
|
||||
|
||||
|
||||
|
||||
## License
|
||||
|
||||
All the plugins are released under the MIT license.
|
||||
22
public/static/libs/requirejs-plugins/bower.json
Normal file
22
public/static/libs/requirejs-plugins/bower.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "requirejs-plugins",
|
||||
"version": "1.0.3",
|
||||
"main": [
|
||||
"src/async.js",
|
||||
"src/depend.js",
|
||||
"src/font.js",
|
||||
"src/goog.js",
|
||||
"src/image.js",
|
||||
"src/json.js",
|
||||
"src/mdown.js",
|
||||
"src/noext.js",
|
||||
"src/propertyParser.js",
|
||||
"lib/Markdown.Converter.js",
|
||||
"lib/text.js"
|
||||
],
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"components"
|
||||
]
|
||||
}
|
||||
90
public/static/libs/requirejs-plugins/examples/async.html
Normal file
90
public/static/libs/requirejs-plugins/examples/async.html
Normal file
@@ -0,0 +1,90 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>RequireJS Async plugin</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style>
|
||||
.info{background-color:#cfc; border:2px solid #ada; padding:10px 20px; margin:2em 0}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<h1>RequireJS async plugin</h1>
|
||||
<div class="info">
|
||||
<p>
|
||||
Google Maps loads many JS files asynchronously, so listening just to the first script load
|
||||
isn't enough to check if it is ready to be used, another problem is that the regular gmaps script
|
||||
uses document.write, so we need to pass a `callback` parameter to make it not use `document.write`
|
||||
and wait for the callback call.
|
||||
<br>
|
||||
[<a href="http://code.google.com/apis/maps/documentation/javascript/basics.html#Async">More info</a>]
|
||||
</p>
|
||||
</div>
|
||||
<div id="map-canvas" style="width:400px; height:300px; border:1px solid #ccc; background-color:#f5f5f5"></div>
|
||||
<h2>JSONP</h2>
|
||||
<div class="info">
|
||||
<p>
|
||||
Note that the async! plugin isn't really required for JSONP calls if the response is an <strong>Object</strong>.
|
||||
If the response is an Array or String you will need the async! plugin. [<a href="http://requirejs.org/docs/api.html#jsonp">reference</a>]
|
||||
</p>
|
||||
<p>
|
||||
The default parameter used to set the callback name is <code>callback</code>, you can set a different name
|
||||
by passing it at the end of the dependency URL preceded by a exclamation mark (<code>!</code>), e.g.: <code>async!http://example.com/?foo=bar!jsoncallback</code>
|
||||
</p>
|
||||
</div>
|
||||
<h3>Flickr feed</h3>
|
||||
<div id="flickr-feed"></div>
|
||||
</div>
|
||||
<script src="../lib/require.js"></script>
|
||||
<script>
|
||||
require({
|
||||
waitSeconds : 120, //make sure it is enough to load all gmaps scripts
|
||||
paths : {
|
||||
async : '../src/async' //alias to plugin
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// you can use a "!callbackName" at the end of the URL
|
||||
// to specify name of parameter that expects callback function name
|
||||
// the default value is "!callback" if not present.
|
||||
// Notice that flickr uses "!jsoncallback".
|
||||
require(
|
||||
[
|
||||
'async!http://api.flickr.com/services/feeds/photos_public.gne?id=27041612@N06&format=json!jsoncallback',
|
||||
'async!http://maps.google.com/maps/api/js?sensor=false'
|
||||
],
|
||||
function(photos){
|
||||
|
||||
|
||||
|
||||
//flickr
|
||||
|
||||
var flickrDiv = document.getElementById('flickr-feed'),
|
||||
idx = Math.round((photos.items.length - 1) * Math.random());
|
||||
|
||||
flickrDiv.innerHTML += photos.items[idx].description;
|
||||
|
||||
|
||||
|
||||
//Google maps is available and all components are ready to use.
|
||||
|
||||
var mapDiv = document.getElementById('map-canvas');
|
||||
|
||||
var map = new google.maps.Map(mapDiv, {
|
||||
center: new google.maps.LatLng(37.4419, -122.1419),
|
||||
zoom: 13,
|
||||
mapTypeId: google.maps.MapTypeId.ROADMAP,
|
||||
navigationControl: true,
|
||||
navigationControlOptions: {
|
||||
style: google.maps.NavigationControlStyle.SMALL
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"text" : "Awesome"
|
||||
}
|
||||
13
public/static/libs/requirejs-plugins/examples/data/bar.md
Normal file
13
public/static/libs/requirejs-plugins/examples/data/bar.md
Normal file
@@ -0,0 +1,13 @@
|
||||
## Another markdown file
|
||||
|
||||
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
||||
|
||||
> this is a quote.
|
||||
|
||||
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
||||
|
||||
function doSomethingAwesome(){
|
||||
console.log('fuck yeahh!!');
|
||||
}
|
||||
|
||||
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"lorem" : "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
||||
"bar" : 1234567890
|
||||
}
|
||||
20
public/static/libs/requirejs-plugins/examples/data/foo.md
Normal file
20
public/static/libs/requirejs-plugins/examples/data/foo.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# This content was loaded from a markdown file!
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||
|
||||
## It is very useful for content-heavy sites
|
||||
|
||||
Ut enim ad minim veniam, quis nostrud *exercitation* ullamco laboris nisi ut
|
||||
aliquip ex ea commodo consequat. Duis aute irure **dolor in reprehenderit** in
|
||||
voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
|
||||
occaecat cupidatat non proident, sunt in culpa qui officia `deserunt` mollit
|
||||
anim id est laborum.
|
||||
|
||||
### You can change the markdownConverter if needed
|
||||
|
||||
- the markdownConverter is kept as a separate file:
|
||||
- if you project already uses one you can simply reuse it.
|
||||
- so plugin is more flexible.
|
||||
- this plugin is not targeted to dynamic loading after build:
|
||||
- check plugin source code for more info.
|
||||
|
||||
83
public/static/libs/requirejs-plugins/examples/font.html
Normal file
83
public/static/libs/requirejs-plugins/examples/font.html
Normal file
@@ -0,0 +1,83 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>RequireJS + WebFont Loader</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style>
|
||||
body{font-family:sans-serif}
|
||||
.h3{font-size:1.2em}
|
||||
.info{background-color:#cfc; border:2px solid #ada; padding:10px 20px; margin:2em 0}
|
||||
.wf-loading .f-1,
|
||||
.wf-loading .f-2,
|
||||
.wf-loading .f-3 {
|
||||
/* avoid FOUC */
|
||||
visibility:hidden;
|
||||
}
|
||||
.f-1{font-family:"Tangerine"}
|
||||
.f-2{font-family:"Cantarell"}
|
||||
.f-3{font-family:"Yanone Kaffeesatz"}
|
||||
</style>
|
||||
</head>
|
||||
<script>
|
||||
// add .wf-loading class to avoid FOUC
|
||||
// use JS to add class to avoid hidding content if JS isn't available
|
||||
document.documentElement.className += ' wf-loading';
|
||||
</script>
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<h1>RequireJS + WebFont Loader</h1>
|
||||
<div class="info">
|
||||
<p>
|
||||
Example of how to load webfonts using the <a href="https://code.google.com/apis/webfonts/docs/webfont_loader.html">Google WebFont Loader API</a>.
|
||||
</p>
|
||||
<h2 class="h3">Syntax</h2>
|
||||
<p>
|
||||
<code>font!google,families:[Tangerine,Cantarell]</code>
|
||||
</p>
|
||||
<p>
|
||||
You can load fonts from multiple vendors by splitting them with "|".
|
||||
</p>
|
||||
<p>
|
||||
<code>font!google,families:[Tangerine,Cantarell,Yanone Kaffeesatz:700]|typekit,id:123|monotype,projectId:555</code>
|
||||
</p>
|
||||
<p>
|
||||
Check the <a href="https://code.google.com/apis/webfonts/docs/webfont_loader.html">WebFont Loader API documentation</a> for available options.
|
||||
</p>
|
||||
</div>
|
||||
<div id="sample">
|
||||
<h2 class="f-1">Lorem Ipsum dolor</h2>
|
||||
<p class="f-2">
|
||||
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
||||
</p>
|
||||
<p class="f-3">
|
||||
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../lib/require.js"></script>
|
||||
<script>
|
||||
require({
|
||||
waitSeconds : 15, //make sure it is enough to load all scripts
|
||||
paths : {
|
||||
//alias to plugins
|
||||
async : '../src/async',
|
||||
goog : '../src/goog',
|
||||
font : '../src/font',
|
||||
propertyParser : '../src/propertyParser'
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
require(['font!google,families:[Tangerine,Cantarell,Yanone Kaffeesatz:700]'], function(){
|
||||
//fonts are loaded
|
||||
var ready = document.createElement('div');
|
||||
ready.className = 'f-1';
|
||||
ready.innerHTML = 'All fonts loaded!';
|
||||
ready.style.fontSize = '34px';
|
||||
document.getElementById('sample').appendChild(ready);
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
127
public/static/libs/requirejs-plugins/examples/goog.html
Normal file
127
public/static/libs/requirejs-plugins/examples/goog.html
Normal file
@@ -0,0 +1,127 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>RequireJS Google Ajax API plugin</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style>
|
||||
.info{background-color:#cfc; border:2px solid #ada; padding:10px 20px; margin:2em 0}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<h1>RequireJS + Google Ajax API plugin</h1>
|
||||
<div class="info">
|
||||
<p>
|
||||
This plugin depends on the Async plugin and loads files using the <code>google.load</code> method from the <a href="http://code.google.com/apis/loader/">Google Loader</a>.
|
||||
</p>
|
||||
<p>
|
||||
Notice that it can only load the libraries listed on the <a href="http://code.google.com/apis/loader/#AvailableAPIs">Available APIs section</a>.
|
||||
</p>
|
||||
</div>
|
||||
<h2>Google Charts - corechart</h2>
|
||||
<div id="chart_div"></div>
|
||||
<h2>Google Charts - geochart</h2>
|
||||
<div id="map_canvas" style="width:500px"></div>
|
||||
<h2>Google Search API</h2>
|
||||
<div id="branding"></div>
|
||||
<div id="search_results"> </div>
|
||||
</div>
|
||||
<script src="../lib/require.js"></script>
|
||||
<script>
|
||||
require({
|
||||
waitSeconds : 15, //make sure it is enough to load all scripts
|
||||
paths : {
|
||||
//alias to plugins
|
||||
async : '../src/async',
|
||||
goog : '../src/goog',
|
||||
propertyParser : '../src/propertyParser'
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//To load google libraries you should follow the format "goog!moduleName,version,packages:[packages],language:en,anotherOption:value"
|
||||
require(['goog!visualization,1,packages:[corechart,geochart]', 'goog!search,1'], function(){
|
||||
|
||||
// visualization + corechart + geochart + search are loaded
|
||||
|
||||
|
||||
// code copied from google charts docs:
|
||||
// http://code.google.com/apis/chart/interactive/docs/gallery/piechart.html
|
||||
var data = new google.visualization.DataTable();
|
||||
data.addColumn('string', 'Task');
|
||||
data.addColumn('number', 'Hours per Day');
|
||||
data.addRows(5);
|
||||
data.setValue(0, 0, 'Work');
|
||||
data.setValue(0, 1, 11);
|
||||
data.setValue(1, 0, 'Eat');
|
||||
data.setValue(1, 1, 2);
|
||||
data.setValue(2, 0, 'Commute');
|
||||
data.setValue(2, 1, 2);
|
||||
data.setValue(3, 0, 'Watch TV');
|
||||
data.setValue(3, 1, 2);
|
||||
data.setValue(4, 0, 'Sleep');
|
||||
data.setValue(4, 1, 7);
|
||||
|
||||
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
|
||||
chart.draw(data, {width: 450, height: 300, title: 'My Daily Activities'});
|
||||
|
||||
|
||||
// code copied from google charts docs:
|
||||
// http://code.google.com/apis/chart/interactive/docs/gallery/geochart.html
|
||||
var data = new google.visualization.DataTable();
|
||||
data.addRows(6);
|
||||
data.addColumn('string', 'Country');
|
||||
data.addColumn('number', 'Popularity');
|
||||
data.setValue(0, 0, 'Germany');
|
||||
data.setValue(0, 1, 200);
|
||||
data.setValue(1, 0, 'United States');
|
||||
data.setValue(1, 1, 300);
|
||||
data.setValue(2, 0, 'Brazil');
|
||||
data.setValue(2, 1, 400);
|
||||
data.setValue(3, 0, 'Canada');
|
||||
data.setValue(3, 1, 500);
|
||||
data.setValue(4, 0, 'France');
|
||||
data.setValue(4, 1, 600);
|
||||
data.setValue(5, 0, 'RU');
|
||||
data.setValue(5, 1, 700);
|
||||
|
||||
var options = {};
|
||||
|
||||
var container = document.getElementById('map_canvas');
|
||||
var geochart = new google.visualization.GeoChart(container);
|
||||
geochart.draw(data, options);
|
||||
|
||||
|
||||
|
||||
//code copied from http://code.google.com/apis/ajax/playground/?exp=libraries#the_hello_world_of_news_search
|
||||
//and slightly modified
|
||||
|
||||
var newsSearch = new google.search.WebSearch(),
|
||||
resultHolder = document.getElementById('search_results');
|
||||
|
||||
function searchComplete() {
|
||||
resultHolder.innerHTML = '';
|
||||
if (newsSearch.results && newsSearch.results.length > 0) {
|
||||
for (var i = 0; i < newsSearch.results.length; i++) {
|
||||
var p = document.createElement('p');
|
||||
var a = document.createElement('a');
|
||||
a.href = newsSearch.results[i].url;
|
||||
a.innerHTML = newsSearch.results[i].title;
|
||||
p.appendChild(a);
|
||||
resultHolder.appendChild(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newsSearch.setSearchCompleteCallback(this, searchComplete, null);
|
||||
newsSearch.execute('RequireJS plugins');
|
||||
|
||||
// Include the required Google branding
|
||||
google.search.Search.getBranding('branding');
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
70
public/static/libs/requirejs-plugins/examples/image.html
Normal file
70
public/static/libs/requirejs-plugins/examples/image.html
Normal file
@@ -0,0 +1,70 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>RequireJS image plugin</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<h1>RequireJS image plugin</h1>
|
||||
<p>Note that <code>waitSeconds</code> should be large enough to load all the images, otherwise module may timeout.</p>
|
||||
<p>Use this plugin only on specific cases and make sure you set a large <a href="http://requirejs.org/docs/api.html#config">waitSeconds</a> (default is 7 seconds).</p>
|
||||
<h2>Notes:</h2>
|
||||
<ul>
|
||||
<li>Image paths are relative to the HTML file by default.</li>
|
||||
<li>Support absolute paths as well.</li>
|
||||
<li>Appending <code>!bust</code> to the file name will avoid caching the image.</li>
|
||||
<li>Appending <code>!rel</code> to the file name will load image realtive to baseUrl or module path.</li>
|
||||
<li>It will always return the same image object unless you use the <code>!bust</code> flag, so you may need to clone the image element before inserting it multiple times into the same document.</li>
|
||||
</ul>
|
||||
<hr />
|
||||
</div>
|
||||
<script src="../lib/require.js"></script>
|
||||
<script>
|
||||
require.config({
|
||||
waitSeconds : 45, //should be enough to load images
|
||||
paths : {
|
||||
image : '../src/image' //alias to plugin
|
||||
}
|
||||
});
|
||||
|
||||
require([
|
||||
'image!img/lol_cat.jpg',
|
||||
'image!http://30.media.tumblr.com/tumblr_lgd1neNYSL1qbwkzvo1_500.jpg',
|
||||
'image!img/bike.jpg!bust',
|
||||
'image!img/bike.jpg!bust',
|
||||
'image!img/lol_cat.jpg',
|
||||
'img/relativePath.js'
|
||||
], function(cat, awesome, bike1, bike2, sameCat, relative){
|
||||
var wrapper = document.getElementById('wrapper');
|
||||
|
||||
//add loaded images to the document!
|
||||
//returns an Image object..
|
||||
wrapper.appendChild(awesome);
|
||||
wrapper.appendChild(cat);
|
||||
|
||||
//requireJS will return same image object unless you use `!bust`
|
||||
|
||||
var sameBike = document.createElement('div');
|
||||
sameBike.innerHTML = 'Is same bike cat? : '+ (bike1 === bike2);
|
||||
wrapper.appendChild(sameBike);
|
||||
|
||||
wrapper.appendChild(bike1);
|
||||
wrapper.appendChild(bike2);
|
||||
|
||||
var sameLol = document.createElement('div');
|
||||
sameLol.innerHTML = 'Is same lol cat? : '+ (cat === sameCat);
|
||||
wrapper.appendChild(sameLol);
|
||||
|
||||
//so we need to "deep-clone" the Element to be able
|
||||
//to insert it multiple times into the same document
|
||||
|
||||
//wrapper.appendChild(sameCat.cloneNode(true)); //insert a clone of the image
|
||||
wrapper.appendChild(sameCat);//swap image position
|
||||
|
||||
relative.init(wrapper);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
BIN
public/static/libs/requirejs-plugins/examples/img/bike.jpg
Normal file
BIN
public/static/libs/requirejs-plugins/examples/img/bike.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 93 KiB |
BIN
public/static/libs/requirejs-plugins/examples/img/lol_cat.jpg
Normal file
BIN
public/static/libs/requirejs-plugins/examples/img/lol_cat.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
@@ -0,0 +1,11 @@
|
||||
//use the !rel flag to load file relative to this module or to baseUrl
|
||||
define(['image!./software_engineer.png!rel'], function(engineer){
|
||||
|
||||
return {
|
||||
init : function(wrapper){
|
||||
engineer.style.display = 'block';
|
||||
wrapper.appendChild(engineer);
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 156 KiB |
5
public/static/libs/requirejs-plugins/examples/js/foo
Normal file
5
public/static/libs/requirejs-plugins/examples/js/foo
Normal file
@@ -0,0 +1,5 @@
|
||||
define(function(){
|
||||
return {
|
||||
msg : 'foo loaded!'
|
||||
};
|
||||
});
|
||||
5
public/static/libs/requirejs-plugins/examples/js/foo.bar
Normal file
5
public/static/libs/requirejs-plugins/examples/js/foo.bar
Normal file
@@ -0,0 +1,5 @@
|
||||
define(function(){
|
||||
return {
|
||||
msg : 'foo.bar loaded !'
|
||||
};
|
||||
});
|
||||
37
public/static/libs/requirejs-plugins/examples/json.html
Normal file
37
public/static/libs/requirejs-plugins/examples/json.html
Normal file
@@ -0,0 +1,37 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>RequireJS JSON plugin</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<h1>RequireJS JSON plugin</h1>
|
||||
<p>Helper for loading JSON files, it will also work during optimization (wrapping JSON files into a `define` call).</p>
|
||||
<p>If you want to load JSONP data use the `async` plugin instead.</p>
|
||||
<p>You can set the flag <code>`!bust`</code> to prevent caching the JSON response, it will append a query argument <code>"bust=RANDOM_INTEGER"</code> to the URI.</p>
|
||||
<h2>Output:</h2>
|
||||
<div id="output" style="border:1px solid #ccc; background:#f5f5f5; padding:10px 20px"></div>
|
||||
</div>
|
||||
<script src="../lib/require.js"></script>
|
||||
<script>
|
||||
require.config({
|
||||
waitSeconds : 2,
|
||||
paths : {
|
||||
text : '../lib/text', //text is required
|
||||
json : '../src/json' //alias to plugin
|
||||
}
|
||||
});
|
||||
|
||||
// adding the flag `!bust` to the end of dependency name will avoid caching
|
||||
require(['json!data/foo.json', 'json!data/bar.json!bust'], function(foo, bar){
|
||||
var out = document.getElementById('output');
|
||||
//data is parsed into an object
|
||||
out.innerHTML += '<p><b>lorem:<\/b> '+ foo.lorem +'<\/p>';
|
||||
out.innerHTML += '<p><b>bar:<\/b> '+ foo.bar +'<\/p>';
|
||||
out.innerHTML += '<p><b>message:<\/b> '+ bar.text +'<\/p>';
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
38
public/static/libs/requirejs-plugins/examples/mdown.html
Normal file
38
public/static/libs/requirejs-plugins/examples/mdown.html
Normal file
@@ -0,0 +1,38 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>RequireJS Markdown plugin</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<h1>RequireJS Markdown plugin</h1>
|
||||
<p>Helper for loading Markdown files, it will precompile Markdown files into HTML during optimization and wrap them into <code>define()</code> calls.</p>
|
||||
<p>
|
||||
If you set <code>pragmasOnSave.excludeMdown=true</code> the plugin code will be removed during the build, so it won't affect filesize.
|
||||
</p>
|
||||
<h2>Output:</h2>
|
||||
<div id="output" style="border:1px solid #ccc; background:#f5f5f5; padding:10px 20px"></div>
|
||||
</div>
|
||||
<script src="../lib/require.js"></script>
|
||||
<script>
|
||||
require.config({
|
||||
waitSeconds : 2,
|
||||
paths : {
|
||||
text : '../lib/text', //text is required
|
||||
markdownConverter : '../lib/Markdown.Converter', //used by plugin
|
||||
mdown : '../src/mdown' //alias to plugin
|
||||
}
|
||||
});
|
||||
|
||||
require(['mdown!data/foo.md', 'mdown!data/bar.md'], function(foo, bar){
|
||||
var out = document.getElementById('output');
|
||||
// data will be compiled into HTML
|
||||
out.innerHTML += foo;
|
||||
out.innerHTML += bar;
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
34
public/static/libs/requirejs-plugins/examples/noext.html
Normal file
34
public/static/libs/requirejs-plugins/examples/noext.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>RequireJS noext! plugin</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
</head>
|
||||
<body>
|
||||
<div id="wrapper">
|
||||
<h1>RequireJS noext! plugin</h1>
|
||||
<p>Helper for loading files without appending the ".js" extension.</p>
|
||||
<p>
|
||||
Note that it will append a query string "noext=1" to the URL to avoid inserting the JS extension.
|
||||
</p>
|
||||
<h2>Output:</h2>
|
||||
<div id="output" style="border:1px solid #ccc; background:#f5f5f5; padding:10px 20px"></div>
|
||||
</div>
|
||||
<script src="../lib/require.js"></script>
|
||||
<script>
|
||||
require.config({
|
||||
paths : {
|
||||
noext : '../src/noext' //alias to plugin
|
||||
}
|
||||
});
|
||||
|
||||
require(['noext!js/foo.bar', 'noext!js/foo'], function(foo1, foo2){
|
||||
var out = document.getElementById('output');
|
||||
//data is parsed into an object
|
||||
out.innerHTML += '<p><b>foo.bar:<\/b> '+ foo1.msg +'<\/p>';
|
||||
out.innerHTML += '<p><b>foo:<\/b> '+ foo2.msg +'<\/p>';
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
1353
public/static/libs/requirejs-plugins/lib/Markdown.Converter.js
Normal file
1353
public/static/libs/requirejs-plugins/lib/Markdown.Converter.js
Normal file
File diff suppressed because it is too large
Load Diff
2019
public/static/libs/requirejs-plugins/lib/require.js
Normal file
2019
public/static/libs/requirejs-plugins/lib/require.js
Normal file
File diff suppressed because it is too large
Load Diff
332
public/static/libs/requirejs-plugins/lib/text.js
Normal file
332
public/static/libs/requirejs-plugins/lib/text.js
Normal file
@@ -0,0 +1,332 @@
|
||||
/**
|
||||
* @license RequireJS text 2.0.5 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
|
||||
* Available via the MIT or new BSD license.
|
||||
* see: http://github.com/requirejs/text for details
|
||||
*/
|
||||
/*jslint regexp: true */
|
||||
/*global require: false, XMLHttpRequest: false, ActiveXObject: false,
|
||||
define: false, window: false, process: false, Packages: false,
|
||||
java: false, location: false */
|
||||
|
||||
define(['module'], function (module) {
|
||||
'use strict';
|
||||
|
||||
var text, fs,
|
||||
progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'],
|
||||
xmlRegExp = /^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,
|
||||
bodyRegExp = /<body[^>]*>\s*([\s\S]+)\s*<\/body>/im,
|
||||
hasLocation = typeof location !== 'undefined' && location.href,
|
||||
defaultProtocol = hasLocation && location.protocol && location.protocol.replace(/\:/, ''),
|
||||
defaultHostName = hasLocation && location.hostname,
|
||||
defaultPort = hasLocation && (location.port || undefined),
|
||||
buildMap = [],
|
||||
masterConfig = (module.config && module.config()) || {};
|
||||
|
||||
text = {
|
||||
version: '2.0.5',
|
||||
|
||||
strip: function (content) {
|
||||
//Strips <?xml ...?> declarations so that external SVG and XML
|
||||
//documents can be added to a document without worry. Also, if the string
|
||||
//is an HTML document, only the part inside the body tag is returned.
|
||||
if (content) {
|
||||
content = content.replace(xmlRegExp, "");
|
||||
var matches = content.match(bodyRegExp);
|
||||
if (matches) {
|
||||
content = matches[1];
|
||||
}
|
||||
} else {
|
||||
content = "";
|
||||
}
|
||||
return content;
|
||||
},
|
||||
|
||||
jsEscape: function (content) {
|
||||
return content.replace(/(['\\])/g, '\\$1')
|
||||
.replace(/[\f]/g, "\\f")
|
||||
.replace(/[\b]/g, "\\b")
|
||||
.replace(/[\n]/g, "\\n")
|
||||
.replace(/[\t]/g, "\\t")
|
||||
.replace(/[\r]/g, "\\r")
|
||||
.replace(/[\u2028]/g, "\\u2028")
|
||||
.replace(/[\u2029]/g, "\\u2029");
|
||||
},
|
||||
|
||||
createXhr: masterConfig.createXhr || function () {
|
||||
//Would love to dump the ActiveX crap in here. Need IE 6 to die first.
|
||||
var xhr, i, progId;
|
||||
if (typeof XMLHttpRequest !== "undefined") {
|
||||
return new XMLHttpRequest();
|
||||
} else if (typeof ActiveXObject !== "undefined") {
|
||||
for (i = 0; i < 3; i += 1) {
|
||||
progId = progIds[i];
|
||||
try {
|
||||
xhr = new ActiveXObject(progId);
|
||||
} catch (e) {}
|
||||
|
||||
if (xhr) {
|
||||
progIds = [progId]; // so faster next time
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return xhr;
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses a resource name into its component parts. Resource names
|
||||
* look like: module/name.ext!strip, where the !strip part is
|
||||
* optional.
|
||||
* @param {String} name the resource name
|
||||
* @returns {Object} with properties "moduleName", "ext" and "strip"
|
||||
* where strip is a boolean.
|
||||
*/
|
||||
parseName: function (name) {
|
||||
var modName, ext, temp,
|
||||
strip = false,
|
||||
index = name.indexOf("."),
|
||||
isRelative = name.indexOf('./') === 0 ||
|
||||
name.indexOf('../') === 0;
|
||||
|
||||
if (index !== -1 && (!isRelative || index > 1)) {
|
||||
modName = name.substring(0, index);
|
||||
ext = name.substring(index + 1, name.length);
|
||||
} else {
|
||||
modName = name;
|
||||
}
|
||||
|
||||
temp = ext || modName;
|
||||
index = temp.indexOf("!");
|
||||
if (index !== -1) {
|
||||
//Pull off the strip arg.
|
||||
strip = temp.substring(index + 1) === "strip";
|
||||
temp = temp.substring(0, index);
|
||||
if (ext) {
|
||||
ext = temp;
|
||||
} else {
|
||||
modName = temp;
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
moduleName: modName,
|
||||
ext: ext,
|
||||
strip: strip
|
||||
};
|
||||
},
|
||||
|
||||
xdRegExp: /^((\w+)\:)?\/\/([^\/\\]+)/,
|
||||
|
||||
/**
|
||||
* Is an URL on another domain. Only works for browser use, returns
|
||||
* false in non-browser environments. Only used to know if an
|
||||
* optimized .js version of a text resource should be loaded
|
||||
* instead.
|
||||
* @param {String} url
|
||||
* @returns Boolean
|
||||
*/
|
||||
useXhr: function (url, protocol, hostname, port) {
|
||||
var uProtocol, uHostName, uPort,
|
||||
match = text.xdRegExp.exec(url);
|
||||
if (!match) {
|
||||
return true;
|
||||
}
|
||||
uProtocol = match[2];
|
||||
uHostName = match[3];
|
||||
|
||||
uHostName = uHostName.split(':');
|
||||
uPort = uHostName[1];
|
||||
uHostName = uHostName[0];
|
||||
|
||||
return (!uProtocol || uProtocol === protocol) &&
|
||||
(!uHostName || uHostName.toLowerCase() === hostname.toLowerCase()) &&
|
||||
((!uPort && !uHostName) || uPort === port);
|
||||
},
|
||||
|
||||
finishLoad: function (name, strip, content, onLoad) {
|
||||
content = strip ? text.strip(content) : content;
|
||||
if (masterConfig.isBuild) {
|
||||
buildMap[name] = content;
|
||||
}
|
||||
onLoad(content);
|
||||
},
|
||||
|
||||
load: function (name, req, onLoad, config) {
|
||||
//Name has format: some.module.filext!strip
|
||||
//The strip part is optional.
|
||||
//if strip is present, then that means only get the string contents
|
||||
//inside a body tag in an HTML string. For XML/SVG content it means
|
||||
//removing the <?xml ...?> declarations so the content can be inserted
|
||||
//into the current doc without problems.
|
||||
|
||||
// Do not bother with the work if a build and text will
|
||||
// not be inlined.
|
||||
if (config.isBuild && !config.inlineText) {
|
||||
onLoad();
|
||||
return;
|
||||
}
|
||||
|
||||
masterConfig.isBuild = config.isBuild;
|
||||
|
||||
var parsed = text.parseName(name),
|
||||
nonStripName = parsed.moduleName +
|
||||
(parsed.ext ? '.' + parsed.ext : ''),
|
||||
url = req.toUrl(nonStripName),
|
||||
useXhr = (masterConfig.useXhr) ||
|
||||
text.useXhr;
|
||||
|
||||
//Load the text. Use XHR if possible and in a browser.
|
||||
if (!hasLocation || useXhr(url, defaultProtocol, defaultHostName, defaultPort)) {
|
||||
text.get(url, function (content) {
|
||||
text.finishLoad(name, parsed.strip, content, onLoad);
|
||||
}, function (err) {
|
||||
if (onLoad.error) {
|
||||
onLoad.error(err);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
//Need to fetch the resource across domains. Assume
|
||||
//the resource has been optimized into a JS module. Fetch
|
||||
//by the module name + extension, but do not include the
|
||||
//!strip part to avoid file system issues.
|
||||
req([nonStripName], function (content) {
|
||||
text.finishLoad(parsed.moduleName + '.' + parsed.ext,
|
||||
parsed.strip, content, onLoad);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
write: function (pluginName, moduleName, write, config) {
|
||||
if (buildMap.hasOwnProperty(moduleName)) {
|
||||
var content = text.jsEscape(buildMap[moduleName]);
|
||||
write.asModule(pluginName + "!" + moduleName,
|
||||
"define(function () { return '" +
|
||||
content +
|
||||
"';});\n");
|
||||
}
|
||||
},
|
||||
|
||||
writeFile: function (pluginName, moduleName, req, write, config) {
|
||||
var parsed = text.parseName(moduleName),
|
||||
extPart = parsed.ext ? '.' + parsed.ext : '',
|
||||
nonStripName = parsed.moduleName + extPart,
|
||||
//Use a '.js' file name so that it indicates it is a
|
||||
//script that can be loaded across domains.
|
||||
fileName = req.toUrl(parsed.moduleName + extPart) + '.js';
|
||||
|
||||
//Leverage own load() method to load plugin value, but only
|
||||
//write out values that do not have the strip argument,
|
||||
//to avoid any potential issues with ! in file names.
|
||||
text.load(nonStripName, req, function (value) {
|
||||
//Use own write() method to construct full module value.
|
||||
//But need to create shell that translates writeFile's
|
||||
//write() to the right interface.
|
||||
var textWrite = function (contents) {
|
||||
return write(fileName, contents);
|
||||
};
|
||||
textWrite.asModule = function (moduleName, contents) {
|
||||
return write.asModule(moduleName, fileName, contents);
|
||||
};
|
||||
|
||||
text.write(pluginName, nonStripName, textWrite, config);
|
||||
}, config);
|
||||
}
|
||||
};
|
||||
|
||||
if (masterConfig.env === 'node' || (!masterConfig.env &&
|
||||
typeof process !== "undefined" &&
|
||||
process.versions &&
|
||||
!!process.versions.node)) {
|
||||
//Using special require.nodeRequire, something added by r.js.
|
||||
fs = require.nodeRequire('fs');
|
||||
|
||||
text.get = function (url, callback) {
|
||||
var file = fs.readFileSync(url, 'utf8');
|
||||
//Remove BOM (Byte Mark Order) from utf8 files if it is there.
|
||||
if (file.indexOf('\uFEFF') === 0) {
|
||||
file = file.substring(1);
|
||||
}
|
||||
callback(file);
|
||||
};
|
||||
} else if (masterConfig.env === 'xhr' || (!masterConfig.env &&
|
||||
text.createXhr())) {
|
||||
text.get = function (url, callback, errback, headers) {
|
||||
var xhr = text.createXhr(), header;
|
||||
xhr.open('GET', url, true);
|
||||
|
||||
//Allow plugins direct access to xhr headers
|
||||
if (headers) {
|
||||
for (header in headers) {
|
||||
if (headers.hasOwnProperty(header)) {
|
||||
xhr.setRequestHeader(header.toLowerCase(), headers[header]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Allow overrides specified in config
|
||||
if (masterConfig.onXhr) {
|
||||
masterConfig.onXhr(xhr, url);
|
||||
}
|
||||
|
||||
xhr.onreadystatechange = function (evt) {
|
||||
var status, err;
|
||||
//Do not explicitly handle errors, those should be
|
||||
//visible via console output in the browser.
|
||||
if (xhr.readyState === 4) {
|
||||
status = xhr.status;
|
||||
if (status > 399 && status < 600) {
|
||||
//An http 4xx or 5xx error. Signal an error.
|
||||
err = new Error(url + ' HTTP status: ' + status);
|
||||
err.xhr = xhr;
|
||||
errback(err);
|
||||
} else {
|
||||
callback(xhr.responseText);
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.send(null);
|
||||
};
|
||||
} else if (masterConfig.env === 'rhino' || (!masterConfig.env &&
|
||||
typeof Packages !== 'undefined' && typeof java !== 'undefined')) {
|
||||
//Why Java, why is this so awkward?
|
||||
text.get = function (url, callback) {
|
||||
var stringBuffer, line,
|
||||
encoding = "utf-8",
|
||||
file = new java.io.File(url),
|
||||
lineSeparator = java.lang.System.getProperty("line.separator"),
|
||||
input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file), encoding)),
|
||||
content = '';
|
||||
try {
|
||||
stringBuffer = new java.lang.StringBuffer();
|
||||
line = input.readLine();
|
||||
|
||||
// Byte Order Mark (BOM) - The Unicode Standard, version 3.0, page 324
|
||||
// http://www.unicode.org/faq/utf_bom.html
|
||||
|
||||
// Note that when we use utf-8, the BOM should appear as "EF BB BF", but it doesn't due to this bug in the JDK:
|
||||
// http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058
|
||||
if (line && line.length() && line.charAt(0) === 0xfeff) {
|
||||
// Eat the BOM, since we've already found the encoding on this file,
|
||||
// and we plan to concatenating this buffer with others; the BOM should
|
||||
// only appear at the top of a file.
|
||||
line = line.substring(1);
|
||||
}
|
||||
|
||||
stringBuffer.append(line);
|
||||
|
||||
while ((line = input.readLine()) !== null) {
|
||||
stringBuffer.append(lineSeparator);
|
||||
stringBuffer.append(line);
|
||||
}
|
||||
//Make sure we return a JavaScript string and not a Java string.
|
||||
content = String(stringBuffer.toString()); //String
|
||||
} finally {
|
||||
input.close();
|
||||
}
|
||||
callback(content);
|
||||
};
|
||||
}
|
||||
|
||||
return text;
|
||||
});
|
||||
44
public/static/libs/requirejs-plugins/src/async.js
Normal file
44
public/static/libs/requirejs-plugins/src/async.js
Normal file
@@ -0,0 +1,44 @@
|
||||
/** @license
|
||||
* RequireJS plugin for async dependency load like JSONP and Google Maps
|
||||
* Author: Miller Medeiros
|
||||
* Version: 0.1.2 (2014/02/24)
|
||||
* Released under the MIT license
|
||||
*/
|
||||
define(function(){
|
||||
|
||||
var DEFAULT_PARAM_NAME = 'callback',
|
||||
_uid = 0;
|
||||
|
||||
function injectScript(src){
|
||||
var s, t;
|
||||
s = document.createElement('script'); s.type = 'text/javascript'; s.async = true; s.src = src;
|
||||
t = document.getElementsByTagName('script')[0]; t.parentNode.insertBefore(s,t);
|
||||
}
|
||||
|
||||
function formatUrl(name, id){
|
||||
var paramRegex = /!(.+)/,
|
||||
url = name.replace(paramRegex, ''),
|
||||
param = (paramRegex.test(name))? name.replace(/.+!/, '') : DEFAULT_PARAM_NAME;
|
||||
url += (url.indexOf('?') < 0)? '?' : '&';
|
||||
return url + param +'='+ id;
|
||||
}
|
||||
|
||||
function uid() {
|
||||
_uid += 1;
|
||||
return '__async_req_'+ _uid +'__';
|
||||
}
|
||||
|
||||
return{
|
||||
load : function(name, req, onLoad, config){
|
||||
if(config.isBuild){
|
||||
onLoad(null); //avoid errors on the optimizer
|
||||
}else{
|
||||
var id = uid();
|
||||
//create a global variable that stores onLoad so callback
|
||||
//function can define new module after async load
|
||||
window[id] = onLoad;
|
||||
injectScript(formatUrl(req.toUrl(name), id));
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
27
public/static/libs/requirejs-plugins/src/depend.js
Normal file
27
public/static/libs/requirejs-plugins/src/depend.js
Normal file
@@ -0,0 +1,27 @@
|
||||
/** @license
|
||||
* Plugin to load JS files that have dependencies but aren't wrapped into
|
||||
* `define` calls.
|
||||
* Author: Miller Medeiros
|
||||
* Version: 0.1.0 (2011/12/13)
|
||||
* Released under the MIT license
|
||||
*/
|
||||
define(function () {
|
||||
|
||||
var rParts = /^(.*)\[([^\]]*)\]$/;
|
||||
|
||||
return {
|
||||
|
||||
//example: depend!bar[jquery,lib/foo]
|
||||
load : function(name, req, onLoad, config){
|
||||
var parts = rParts.exec(name);
|
||||
|
||||
req(parts[2].split(','), function(){
|
||||
req([parts[1]], function(mod){
|
||||
onLoad(mod);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
45
public/static/libs/requirejs-plugins/src/font.js
Normal file
45
public/static/libs/requirejs-plugins/src/font.js
Normal file
@@ -0,0 +1,45 @@
|
||||
/** @license
|
||||
* RequireJS plugin for loading web fonts using the WebFont Loader
|
||||
* Author: Miller Medeiros
|
||||
* Version: 0.2.0 (2011/12/06)
|
||||
* Released under the MIT license
|
||||
*/
|
||||
define(['propertyParser'], function (propertyParser) {
|
||||
|
||||
var rParts = /^([^,]+),([^\|]+)\|?/;
|
||||
|
||||
function parseName(name) {
|
||||
var data = {},
|
||||
vendors = name.split('|'),
|
||||
n = vendors.length,
|
||||
match;
|
||||
|
||||
while (n--) {
|
||||
match = rParts.exec(vendors[n]);
|
||||
data[ match[1] ] = propertyParser.parseProperties(match[2]);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
// API
|
||||
return {
|
||||
|
||||
//example: font!google,families:[Tangerine,Cantarell,Yanone Kaffeesatz:700]
|
||||
load : function(name, req, onLoad, config){
|
||||
if (config.isBuild) {
|
||||
onLoad(null); //avoid errors on the optimizer
|
||||
} else {
|
||||
var data = parseName(name);
|
||||
data.active = onLoad;
|
||||
data.inactive = function(){
|
||||
onLoad(false);
|
||||
};
|
||||
req([(document.location.protocol === 'https:'? 'https' : 'http') +'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js'], function(){
|
||||
WebFont.load(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
});
|
||||
38
public/static/libs/requirejs-plugins/src/goog.js
Normal file
38
public/static/libs/requirejs-plugins/src/goog.js
Normal file
@@ -0,0 +1,38 @@
|
||||
/** @license
|
||||
* RequireJS plugin for loading Google Ajax API modules thru `google.load`
|
||||
* Author: Miller Medeiros
|
||||
* Version: 0.2.0 (2011/12/06)
|
||||
* Released under the MIT license
|
||||
*/
|
||||
define(['async', 'propertyParser'], function (async, propertyParser) {
|
||||
|
||||
var rParts = /^([^,]+)(?:,([^,]+))?(?:,(.+))?/;
|
||||
|
||||
function parseName(name){
|
||||
var match = rParts.exec(name),
|
||||
data = {
|
||||
moduleName : match[1],
|
||||
version : match[2] || '1'
|
||||
};
|
||||
data.settings = propertyParser.parseProperties(match[3]);
|
||||
return data;
|
||||
}
|
||||
|
||||
return {
|
||||
load : function(name, req, onLoad, config){
|
||||
if (config.isBuild) {
|
||||
onLoad(null); //avoid errors on the optimizer
|
||||
} else {
|
||||
var data = parseName(name),
|
||||
settings = data.settings;
|
||||
|
||||
settings.callback = onLoad;
|
||||
|
||||
req(['async!'+ (document.location.protocol === 'https:'? 'https' : 'http') +'://www.google.com/jsapi'], function(){
|
||||
google.load(data.moduleName, data.version, settings);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
53
public/static/libs/requirejs-plugins/src/image.js
Normal file
53
public/static/libs/requirejs-plugins/src/image.js
Normal file
@@ -0,0 +1,53 @@
|
||||
/** @license
|
||||
* RequireJS Image Plugin
|
||||
* Author: Miller Medeiros
|
||||
* Version: 0.2.2 (2013/02/08)
|
||||
* Released under the MIT license
|
||||
*/
|
||||
define(function(){
|
||||
|
||||
var CACHE_BUST_QUERY_PARAM = 'bust',
|
||||
CACHE_BUST_FLAG = '!bust',
|
||||
RELATIVE_FLAG = '!rel';
|
||||
|
||||
function noop(){}
|
||||
|
||||
function cacheBust(url){
|
||||
url = url.replace(CACHE_BUST_FLAG, '');
|
||||
url += (url.indexOf('?') < 0)? '?' : '&';
|
||||
return url + CACHE_BUST_QUERY_PARAM +'='+ Math.round(2147483647 * Math.random());
|
||||
}
|
||||
|
||||
return {
|
||||
load : function(name, req, onLoad, config){
|
||||
var img;
|
||||
if(config.isBuild){
|
||||
onLoad(null); //avoid errors on the optimizer since it can't inline image files
|
||||
}else{
|
||||
img = new Image();
|
||||
img.onerror = function (err) {
|
||||
onLoad.error(err);
|
||||
};
|
||||
img.onload = function(evt){
|
||||
onLoad(img);
|
||||
try {
|
||||
delete img.onload; //release memory - suggested by John Hann
|
||||
} catch(err) {
|
||||
img.onload = noop; // IE7 :(
|
||||
}
|
||||
};
|
||||
if (name.indexOf(RELATIVE_FLAG) !== -1) {
|
||||
//load image relative to module path / baseUrl
|
||||
img.src = req.toUrl( name.replace(RELATIVE_FLAG, '') );
|
||||
} else {
|
||||
img.src = name;
|
||||
}
|
||||
}
|
||||
},
|
||||
normalize : function (name, normalize) {
|
||||
//used normalize to avoid caching references to a "cache busted" request
|
||||
return (name.indexOf(CACHE_BUST_FLAG) === -1)? name : cacheBust(name);
|
||||
}
|
||||
};
|
||||
|
||||
});
|
||||
66
public/static/libs/requirejs-plugins/src/json.js
Normal file
66
public/static/libs/requirejs-plugins/src/json.js
Normal file
@@ -0,0 +1,66 @@
|
||||
/** @license
|
||||
* RequireJS plugin for loading JSON files
|
||||
* - depends on Text plugin and it was HEAVILY "inspired" by it as well.
|
||||
* Author: Miller Medeiros
|
||||
* Version: 0.4.0 (2014/04/10)
|
||||
* Released under the MIT license
|
||||
*/
|
||||
define(['text'], function(text){
|
||||
|
||||
var CACHE_BUST_QUERY_PARAM = 'bust',
|
||||
CACHE_BUST_FLAG = '!bust',
|
||||
jsonParse = (typeof JSON !== 'undefined' && typeof JSON.parse === 'function')? JSON.parse : function(val){
|
||||
return eval('('+ val +')'); //quick and dirty
|
||||
},
|
||||
buildMap = {};
|
||||
|
||||
function cacheBust(url){
|
||||
url = url.replace(CACHE_BUST_FLAG, '');
|
||||
url += (url.indexOf('?') < 0)? '?' : '&';
|
||||
return url + CACHE_BUST_QUERY_PARAM +'='+ Math.round(2147483647 * Math.random());
|
||||
}
|
||||
|
||||
//API
|
||||
return {
|
||||
|
||||
load : function(name, req, onLoad, config) {
|
||||
if (( config.isBuild && (config.inlineJSON === false || name.indexOf(CACHE_BUST_QUERY_PARAM +'=') !== -1)) || (req.toUrl(name).indexOf('empty:') === 0)) {
|
||||
//avoid inlining cache busted JSON or if inlineJSON:false
|
||||
//and don't inline files marked as empty!
|
||||
onLoad(null);
|
||||
} else {
|
||||
text.get(req.toUrl(name), function(data){
|
||||
if (config.isBuild) {
|
||||
buildMap[name] = data;
|
||||
onLoad(data);
|
||||
} else {
|
||||
onLoad(jsonParse(data));
|
||||
}
|
||||
},
|
||||
onLoad.error, {
|
||||
accept: 'application/json'
|
||||
}
|
||||
);
|
||||
}
|
||||
},
|
||||
|
||||
normalize : function (name, normalize) {
|
||||
// used normalize to avoid caching references to a "cache busted" request
|
||||
if (name.indexOf(CACHE_BUST_FLAG) !== -1) {
|
||||
name = cacheBust(name);
|
||||
}
|
||||
// resolve any relative paths
|
||||
return normalize(name);
|
||||
},
|
||||
|
||||
//write method based on RequireJS official text plugin by James Burke
|
||||
//https://github.com/jrburke/requirejs/blob/master/text.js
|
||||
write : function(pluginName, moduleName, write){
|
||||
if(moduleName in buildMap){
|
||||
var content = buildMap[moduleName];
|
||||
write('define("'+ pluginName +'!'+ moduleName +'", function(){ return '+ content +';});\n');
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
});
|
||||
59
public/static/libs/requirejs-plugins/src/mdown.js
Normal file
59
public/static/libs/requirejs-plugins/src/mdown.js
Normal file
@@ -0,0 +1,59 @@
|
||||
/** @license
|
||||
* RequireJS plugin for loading Markdown files and converting them into HTML.
|
||||
* Author: Miller Medeiros
|
||||
* Version: 0.1.1 (2012/02/17)
|
||||
* Released under the MIT license
|
||||
*/
|
||||
|
||||
// NOTE :: if you don't need to load markdown files in production outside of
|
||||
// the build, precompile them into modules and set
|
||||
// `pragmasOnSave.excludeMdown=true`
|
||||
|
||||
define(
|
||||
[
|
||||
//>>excludeStart('excludeMdown', pragmas.excludeMdown)
|
||||
'text',
|
||||
'markdownConverter'
|
||||
//>>excludeEnd('excludeMdown')
|
||||
],
|
||||
function (
|
||||
//>>excludeStart('excludeMdown', pragmas.excludeMdown)
|
||||
text, markdownConverter
|
||||
//>>excludeEnd('excludeMdown')
|
||||
) {
|
||||
|
||||
//>>excludeStart('excludeMdown', pragmas.excludeMdown)
|
||||
var buildMap = {};
|
||||
//>>excludeEnd('excludeMdown')
|
||||
|
||||
//API
|
||||
return {
|
||||
|
||||
load : function(name, req, onLoad, config) {
|
||||
//>>excludeStart('excludeMdown', pragmas.excludeMdown)
|
||||
text.get(req.toUrl(name), function(data){
|
||||
data = markdownConverter.makeHtml(data);
|
||||
if (config.isBuild) {
|
||||
buildMap[name] = data;
|
||||
onLoad(data);
|
||||
} else {
|
||||
onLoad(data);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
//write method based on RequireJS official text plugin by James Burke
|
||||
//https://github.com/jrburke/requirejs/blob/master/text.js
|
||||
write : function(pluginName, moduleName, write){
|
||||
if(moduleName in buildMap){
|
||||
var content = text.jsEscape(buildMap[moduleName]);
|
||||
write.asModule(pluginName + "!" + moduleName,
|
||||
"define(function () { return '" +
|
||||
content +
|
||||
"';});\n");
|
||||
}
|
||||
//>>excludeEnd('excludeMdown')
|
||||
}
|
||||
|
||||
};
|
||||
});
|
||||
28
public/static/libs/requirejs-plugins/src/noext.js
Normal file
28
public/static/libs/requirejs-plugins/src/noext.js
Normal file
@@ -0,0 +1,28 @@
|
||||
/** @license
|
||||
* RequireJS plugin for loading files without adding the JS extension, useful for
|
||||
* JSONP services and any other kind of resource that already contain a file
|
||||
* extension or that shouldn't have one (like dynamic scripts).
|
||||
* Author: Miller Medeiros
|
||||
* Version: 0.3.1 (2011/12/07)
|
||||
* Released under the MIT license
|
||||
*/
|
||||
define(function(){
|
||||
|
||||
var QUERY_PARAM = 'noext';
|
||||
|
||||
//API
|
||||
return {
|
||||
load : function(name, req, onLoad, config){
|
||||
req([req.toUrl(name)], function(mod){
|
||||
onLoad(mod);
|
||||
});
|
||||
},
|
||||
normalize : function(name, norm){
|
||||
//append query string to avoid adding .js extension
|
||||
//needs to be on normalize otherwise it won't work after build
|
||||
name += (name.indexOf('?') < 0)? '?' : '&';
|
||||
return name + QUERY_PARAM +'=1';
|
||||
}
|
||||
|
||||
};
|
||||
});
|
||||
43
public/static/libs/requirejs-plugins/src/propertyParser.js
Normal file
43
public/static/libs/requirejs-plugins/src/propertyParser.js
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Basic parser for URL properties
|
||||
* @author Miller Medeiros
|
||||
* @version 0.1.0 (2011/12/06)
|
||||
* MIT license
|
||||
*/
|
||||
define(function(){
|
||||
|
||||
var rProps = /([\w-]+)\s*:\s*(?:(\[[^\]]+\])|([^,]+)),?/g, //match "foo:bar" and "lorem:[ipsum,dolor]" capturing name as $1 and val as $2 or $3
|
||||
rArr = /^\[([^\]]+)\]$/; //match "[foo,bar]" capturing "foo,bar"
|
||||
|
||||
function parseProperties(str){
|
||||
var match, obj = {};
|
||||
while (match = rProps.exec(str)) {
|
||||
obj[ match[1] ] = typecastVal(match[2] || match[3]);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
function typecastVal(val){
|
||||
if (rArr.test(val)){
|
||||
val = val.replace(rArr, '$1').split(',');
|
||||
} else if (val === 'null'){
|
||||
val = null;
|
||||
} else if (val === 'false'){
|
||||
val = false;
|
||||
} else if (val === 'true'){
|
||||
val = true;
|
||||
} else if (val === '' || val === "''" || val === '""'){
|
||||
val = '';
|
||||
} else if (! isNaN(val)) {
|
||||
//isNaN('') == false
|
||||
val = +val;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
//API
|
||||
return {
|
||||
parseProperties : parseProperties,
|
||||
typecastVal : typecastVal
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user