updated to v2
This commit is contained in:
115
Cakefile
Normal file
115
Cakefile
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
fs = require 'fs'
|
||||||
|
path = require 'path'
|
||||||
|
{exec} = require 'child_process'
|
||||||
|
handlebars = require 'handlebars'
|
||||||
|
|
||||||
|
hb = "node_modules/handlebars/bin/handlebars"
|
||||||
|
|
||||||
|
sourceFiles = [
|
||||||
|
'SwaggerUi'
|
||||||
|
'view/HeaderView'
|
||||||
|
'view/MainView'
|
||||||
|
'view/ResourceView'
|
||||||
|
'view/OperationView'
|
||||||
|
'view/ParameterView'
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
task 'clean', 'Removes distribution', ->
|
||||||
|
console.log 'Clearing dist...'
|
||||||
|
exec 'rm -rf dist'
|
||||||
|
|
||||||
|
task 'dist', 'Build a distribution', ->
|
||||||
|
console.log "Build distribution in ./dist"
|
||||||
|
fs.mkdirSync('dist') if not path.existsSync('dist')
|
||||||
|
fs.mkdirSync('dist/lib') if not path.existsSync('dist/lib')
|
||||||
|
|
||||||
|
appContents = new Array remaining = sourceFiles.length
|
||||||
|
for file, index in sourceFiles then do (file, index) ->
|
||||||
|
console.log " : Reading src/main/coffeescript/#{file}.coffee"
|
||||||
|
fs.readFile "src/main/coffeescript/#{file}.coffee", 'utf8', (err, fileContents) ->
|
||||||
|
throw err if err
|
||||||
|
appContents[index] = fileContents
|
||||||
|
precompileTemplates() if --remaining is 0
|
||||||
|
|
||||||
|
precompileTemplates= ->
|
||||||
|
console.log ' : Precompiling templates...'
|
||||||
|
templateFiles = fs.readdirSync('src/main/template')
|
||||||
|
templateContents = new Array remaining = templateFiles.length
|
||||||
|
for file, index in templateFiles then do (file, index) ->
|
||||||
|
console.log " : Compiling src/main/template/#{file}"
|
||||||
|
exec hb + " src/main/template/#{file} -f dist/_#{file}.js", (err, stdout, stderr) ->
|
||||||
|
throw err if err
|
||||||
|
fs.readFile 'dist/_' + file + '.js', 'utf8', (err, fileContents) ->
|
||||||
|
throw err if err
|
||||||
|
templateContents[index] = fileContents
|
||||||
|
fs.unlink 'dist/_' + file + '.js'
|
||||||
|
if --remaining is 0
|
||||||
|
templateContents.push '\n\n'
|
||||||
|
fs.writeFile 'dist/_swagger-ui-templates.js', templateContents.join('\n\n'), 'utf8', (err) ->
|
||||||
|
throw err if err
|
||||||
|
build()
|
||||||
|
|
||||||
|
|
||||||
|
build = ->
|
||||||
|
console.log ' : Collecting Coffeescript source...'
|
||||||
|
|
||||||
|
appContents.push '\n\n'
|
||||||
|
fs.writeFile 'dist/_swagger-ui.coffee', appContents.join('\n\n'), 'utf8', (err) ->
|
||||||
|
throw err if err
|
||||||
|
console.log ' : Compiling...'
|
||||||
|
exec 'coffee --compile dist/_swagger-ui.coffee', (err, stdout, stderr) ->
|
||||||
|
throw err if err
|
||||||
|
fs.unlink 'dist/_swagger-ui.coffee'
|
||||||
|
console.log ' : Combining with javascript...'
|
||||||
|
exec 'cat src/main/javascript/doc.js dist/_swagger-ui-templates.js dist/_swagger-ui.js > dist/swagger-ui.js', (err, stdout, stderr) ->
|
||||||
|
throw err if err
|
||||||
|
fs.unlink 'dist/_swagger-ui.js'
|
||||||
|
fs.unlink 'dist/_swagger-ui-templates.js'
|
||||||
|
console.log ' : Minifying all...'
|
||||||
|
exec 'java -jar "./bin/yuicompressor-2.4.7.jar" --type js -o ' + 'dist/swagger-ui.min.js ' + 'dist/swagger-ui.js', (err, stdout, stderr) ->
|
||||||
|
throw err if err
|
||||||
|
pack()
|
||||||
|
|
||||||
|
pack = ->
|
||||||
|
console.log ' : Packaging...'
|
||||||
|
exec 'cp -r lib dist'
|
||||||
|
exec 'cp -r src/main/html/ dist'
|
||||||
|
console.log ' !'
|
||||||
|
|
||||||
|
task 'spec', "Run the test suite", ->
|
||||||
|
exec "open spec.html", (err, stdout, stderr) ->
|
||||||
|
throw err if err
|
||||||
|
|
||||||
|
task 'watch', 'Watch source files for changes and autocompile', ->
|
||||||
|
# Function which watches all files in the passed directory
|
||||||
|
watchFiles = (dir) ->
|
||||||
|
files = fs.readdirSync(dir)
|
||||||
|
for file, index in files then do (file, index) ->
|
||||||
|
console.log " : " + dir + "/#{file}"
|
||||||
|
fs.watchFile dir + "/#{file}", (curr, prev) ->
|
||||||
|
if +curr.mtime isnt +prev.mtime
|
||||||
|
invoke 'dist'
|
||||||
|
|
||||||
|
notify "Watching source files for changes..."
|
||||||
|
|
||||||
|
# Watch specific source files
|
||||||
|
for file, index in sourceFiles then do (file, index) ->
|
||||||
|
console.log " : " + "src/main/coffeescript/#{file}.coffee"
|
||||||
|
fs.watchFile "src/main/coffeescript/#{file}.coffee", (curr, prev) ->
|
||||||
|
if +curr.mtime isnt +prev.mtime
|
||||||
|
invoke 'dist'
|
||||||
|
|
||||||
|
# watch all files in these folders
|
||||||
|
watchFiles("src/main/template")
|
||||||
|
watchFiles("src/main/javascript")
|
||||||
|
watchFiles("src/main/html")
|
||||||
|
watchFiles("src/test")
|
||||||
|
|
||||||
|
notify = (message) ->
|
||||||
|
return unless message?
|
||||||
|
console.log message
|
||||||
|
# options =
|
||||||
|
# title: 'CoffeeScript'
|
||||||
|
# image: 'bin/CoffeeScript.png'
|
||||||
|
# try require('growl') message, options
|
||||||
53
README.md
53
README.md
@@ -1,44 +1,53 @@
|
|||||||
Swagger UI
|
Swagger UI
|
||||||
==========
|
==========
|
||||||
|
|
||||||
|
Swagger UI is part of [Swagger](http://swagger.wordnik.com/) project.
|
||||||
|
|
||||||
Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically
|
Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically
|
||||||
generate beautiful documentation from a Swagger-compliant API. Because Swagger UI has no
|
generate beautiful documentation and sandbox from a [Swagger-compliant](https://github.com/wordnik/swagger-core/wiki) API. Because Swagger UI has no
|
||||||
dependencies, you can host it in any server environment, or on your local machine.
|
dependencies, you can host it in any server environment, or on your local machine.
|
||||||
|
|
||||||
How to Use It
|
How to Use It
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
```bash
|
### Build
|
||||||
wget https://github.com/downloads/wordnik/swagger-ui/swagger-ui-1.0.zip
|
1. Install [CoffeeScript](http://coffeescript.org/#installation) which will give you [cake](http://coffeescript.org/#cake)
|
||||||
unzip swagger-ui-1.0.zip
|
2. Run cake dist
|
||||||
open swagger-ui-1.0/index.html
|
3. You should see the distribution under the dist folder. Open ./dist/index.html to launch Swagger UI in a browser
|
||||||
```
|
|
||||||
|
### Use
|
||||||
|
Once you open the Swagger UI, it will load the [Swagger Petstore](http://petstore.swagger.wordnik.com/api/resources.json) service and show its APIs.
|
||||||
|
You can enter your own server url and click explore to view the API.
|
||||||
|
|
||||||
|
### Customize
|
||||||
|
You may choose to customize Swagger UI for your organization. Here is an overview of what the various directories contain
|
||||||
|
|
||||||
|
- dist: Contains a distribution which you can deploy on a server or load from your local machine.
|
||||||
|
- bin: Contains files used by swagger-ui for its build/test. These are not required by the distribution.
|
||||||
|
- lib: Contains javascript dependencies which swagger-ui depends on
|
||||||
|
- node_modules: Contains node modules which swagger-ui uses for its development.
|
||||||
|
- src
|
||||||
|
- src/main/coffeescript: main code in CoffeeScript
|
||||||
|
- src/main/templates: [handlebars](http://handlebarsjs.com/) templates used to render swagger-ui
|
||||||
|
- src/main/html: the html files, some images and css
|
||||||
|
- src/main/javascript: some legacy javascript referenced by CofffeeScript code
|
||||||
|
|
||||||
|
### Header Parameters
|
||||||
|
Because of [Cross-Origin Resource Sharing](http://www.w3.org/TR/cors/) restrictions, swagger-ui, by default, does not send header parameters. This can be enabled by [setting the supportHeaderParams to false when creating SwaggerUI instance](https://github.com/wordnik/swagger-ui/blob/overhaul/src/main/html/index.html#L45).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
How to Improve It
|
How to Improve It
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
First, create your own fork of [wordnik/swagger-ui](https://github.com/wordnik/swagger-ui)
|
Create your own fork of [wordnik/swagger-ui](https://github.com/wordnik/swagger-ui)
|
||||||
|
|
||||||
To hack on swagger-ui, you'll need ruby. Then..
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Install the middleman gem:
|
|
||||||
gem install middleman
|
|
||||||
|
|
||||||
# Start up a development server on http://localhost:4567
|
|
||||||
middleman
|
|
||||||
|
|
||||||
# Edit the files in `/source`
|
|
||||||
# Then when you're ready to build, run:
|
|
||||||
middleman build
|
|
||||||
```
|
|
||||||
|
|
||||||
To share your changes, [submit a pull request](https://github.com/wordnik/swagger-ui/pull/new/master).
|
To share your changes, [submit a pull request](https://github.com/wordnik/swagger-ui/pull/new/master).
|
||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Copyright 2011 Wordnik, Inc.
|
Copyright 2011-2012 Wordnik, Inc.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
|||||||
169
build/index.html
169
build/index.html
@@ -1,169 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset='utf-8' />
|
|
||||||
<!-- Always force latest IE rendering engine (even in intranet) and Chrome Frame -->
|
|
||||||
<meta content='IE=edge,chrome=1' http-equiv='X-UA-Compatible' />
|
|
||||||
<title>Swagger API Explorer</title>
|
|
||||||
<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet' type='text/css' />
|
|
||||||
<link href='http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/smoothness/jquery-ui.css' media='screen' rel='stylesheet' type='text/css' />
|
|
||||||
<link href='stylesheets/screen.css' media='screen' rel='stylesheet' type='text/css' />
|
|
||||||
<script src='javascripts/app.js' type='text/javascript'></script>
|
|
||||||
<script src='javascripts/swagger-service.js' type='text/javascript'></script>
|
|
||||||
<script src='javascripts/swagger-ui.js' type='text/javascript'></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id='header'>
|
|
||||||
<a href="http://swagger.wordnik.com" id="logo">swagger</a>
|
|
||||||
<form id='api_selector'>
|
|
||||||
<div class='input'><input type="text" placeholder="http://example.com/api" name="baseUrl" id="input_baseUrl" /></div>
|
|
||||||
<div class='input'><input type="text" placeholder="api_key" name="apiKey" id="input_apiKey" /></div>
|
|
||||||
<div class='input'><a href="#" id="explore">Explore</a></div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<div class='container' id='resources_container'>
|
|
||||||
<ul id='resources'></ul>
|
|
||||||
</div>
|
|
||||||
<script type="text/x-jquery-tmpl" id="resourceTemplate"><li class='resource' id='resource_${name}'>
|
|
||||||
<div class='heading'>
|
|
||||||
<h2>
|
|
||||||
<a href='#!/${name}' onclick="Docs.toggleEndpointListForResource('${name}');">${path}</a>
|
|
||||||
</h2>
|
|
||||||
<ul class='options'>
|
|
||||||
<li>
|
|
||||||
<a href='#!/${name}' id='endpointListTogger_${name}' onclick="Docs.toggleEndpointListForResource('${name}');">Show/Hide</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href='#' onclick="Docs.collapseOperationsForResource('${name}'); return false;">
|
|
||||||
List Operations
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href='#' onclick="Docs.expandOperationsForResource('${name}'); return false;">
|
|
||||||
Expand Operations
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href='${baseUrl}${path_json}'>Raw</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<ul class='endpoints' id='${name}_endpoint_list' style='display:none'></ul>
|
|
||||||
</li>
|
|
||||||
</script>
|
|
||||||
<script type="text/x-jquery-tmpl" id="apiTemplate"><li class='endpoint'>
|
|
||||||
<ul class='operations' id='${name}_endpoint_operations'></ul>
|
|
||||||
</li>
|
|
||||||
</script>
|
|
||||||
<script type="text/x-jquery-tmpl" id="operationTemplate"><li class='${httpMethodLowercase} operation' id='${apiName}_${nickname}_${httpMethod}'>
|
|
||||||
<div class='heading'>
|
|
||||||
<h3>
|
|
||||||
<span class='http_method'>
|
|
||||||
<a href='#!/${apiName}/${nickname}_${httpMethod}' onclick="Docs.toggleOperationContent('${apiName}_${nickname}_${httpMethod}_content');">${httpMethod}</a>
|
|
||||||
</span>
|
|
||||||
<span class='path'>
|
|
||||||
<a href='#!/${apiName}/${nickname}_${httpMethod}' onclick="Docs.toggleOperationContent('${apiName}_${nickname}_${httpMethod}_content');">${path_json}</a>
|
|
||||||
</span>
|
|
||||||
</h3>
|
|
||||||
<ul class='options'>
|
|
||||||
<li>
|
|
||||||
<a href='#!/${apiName}/${nickname}_${httpMethod}' onclick="Docs.toggleOperationContent('${apiName}_${nickname}_${httpMethod}_content');">${summary}</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class='content' id='${apiName}_${nickname}_${httpMethod}_content' style='display:none'>
|
|
||||||
{{if notes}}
|
|
||||||
<h4>Implementation Notes</h4>
|
|
||||||
<p>${notes}</p>
|
|
||||||
{{/if}}
|
|
||||||
<form accept-charset='UTF-8' action='#' class='sandbox' id='${apiName}_${nickname}_${httpMethod}_form' method='post'>
|
|
||||||
<div style='margin:0;padding:0;display:inline'></div>
|
|
||||||
<h4>Parameters</h4>
|
|
||||||
<table class='fullwidth'>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Parameter</th>
|
|
||||||
<th id='${apiName}_${nickname}_${httpMethod}_value_header'>Value</th>
|
|
||||||
<th>Description</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody id='${apiName}_${nickname}_${httpMethod}_params'></tbody>
|
|
||||||
</table>
|
|
||||||
<div class='sandbox_header' id='${apiName}_${nickname}_${httpMethod}_content_sandbox_response_header'>
|
|
||||||
<input class='submit' id='${apiName}_${nickname}_${httpMethod}_content_sandbox_response_button' name='commit' type='button' value='Try it out!' />
|
|
||||||
<a href='#' id='${apiName}_${nickname}_${httpMethod}_content_sandbox_response_hider' onclick="$('#${apiName}_${nickname}_${httpMethod}_content_sandbox_response').slideUp();$(this).fadeOut(); return false;" style='display:none'>Hide Response</a>
|
|
||||||
<img alt='Throbber' id='${apiName}_${nickname}_${httpMethod}_content_sandbox_response_throbber' src='http://swagger.wordnik.com/images/throbber.gif' style='display:none' />
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
<div class='response' id='${apiName}_${nickname}_${httpMethod}_content_sandbox_response' style='display:none'>
|
|
||||||
<h4>Request URL</h4>
|
|
||||||
<div class='block request_url'></div>
|
|
||||||
<h4>Response Body</h4>
|
|
||||||
<div class='block response_body'></div>
|
|
||||||
<h4>Response Code</h4>
|
|
||||||
<div class='block response_code'></div>
|
|
||||||
<h4>Response Headers</h4>
|
|
||||||
<div class='block response_headers'></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
</script>
|
|
||||||
<script type="text/x-jquery-tmpl" id="paramTemplate"><tr>
|
|
||||||
<td class='code'>${name}</td>
|
|
||||||
<td>
|
|
||||||
<input minlength='0' name='${name}' placeholder='' type='text' value='' />
|
|
||||||
</td>
|
|
||||||
<td width='500'>${description}</td>
|
|
||||||
</tr>
|
|
||||||
</script>
|
|
||||||
<script type="text/x-jquery-tmpl" id="paramTemplateSelect"><tr>
|
|
||||||
<td class='code'>${name}</td>
|
|
||||||
<td>
|
|
||||||
<select name='${name}'>
|
|
||||||
{{if required == false }}
|
|
||||||
<option selected='selected' value=''></option>
|
|
||||||
{{/if}}
|
|
||||||
{{each allowableValues.values}}
|
|
||||||
{{if $value == defaultValue && required == true }}
|
|
||||||
<option selected='selected' value='${$value}'>${$value}</option>
|
|
||||||
{{else}}
|
|
||||||
<option value='${$value}'>${$value}</option>
|
|
||||||
{{/if}}
|
|
||||||
{{/each}}
|
|
||||||
</select>
|
|
||||||
</td>
|
|
||||||
<td width='500'>${description}</td>
|
|
||||||
</tr>
|
|
||||||
</script>
|
|
||||||
<script type="text/x-jquery-tmpl" id="paramTemplateRequired"><tr>
|
|
||||||
<td class='code required'>${name}</td>
|
|
||||||
<td>
|
|
||||||
<input class='required' minlength='1' name='${name}' placeholder='(required)' type='text' value='' />
|
|
||||||
</td>
|
|
||||||
<td width='500'>
|
|
||||||
<strong>${description}</strong>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</script>
|
|
||||||
<script type="text/x-jquery-tmpl" id="paramTemplateRequiredReadOnly"><tr>
|
|
||||||
<td class='code required'>${name}</td>
|
|
||||||
<td>-</td>
|
|
||||||
<td width='500'>${description}</td>
|
|
||||||
</tr>
|
|
||||||
</script>
|
|
||||||
<script type="text/x-jquery-tmpl" id="paramTemplateReadOnly"><tr>
|
|
||||||
<td class='code'>${name}</td>
|
|
||||||
<td>-</td>
|
|
||||||
<td width='500'>${description}</td>
|
|
||||||
</tr>
|
|
||||||
</script>
|
|
||||||
<div id='content_message'>
|
|
||||||
Enter the base URL of the API that you wish to explore, or try
|
|
||||||
<a onclick="$('#input_baseUrl').val('http://petstore.swagger.wordnik.com/api/resources.json'); apiSelectionController.showApi(); return false;" href="#">petstore.swagger.wordnik.com/api/resources.json</a>
|
|
||||||
</div>
|
|
||||||
<p id='colophon' style='display:none'>
|
|
||||||
Sexy API documentation from
|
|
||||||
<a href="http://swagger.wordnik.com">Swagger</a>.
|
|
||||||
</p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,776 +0,0 @@
|
|||||||
(function() {
|
|
||||||
/*
|
|
||||||
Chosen, a Select Box Enhancer for jQuery and Protoype
|
|
||||||
by Patrick Filler for Harvest, http://getharvest.com
|
|
||||||
|
|
||||||
Available for use under the MIT License, http://en.wikipedia.org/wiki/MIT_License
|
|
||||||
|
|
||||||
Copyright (c) 2011 by Harvest
|
|
||||||
*/ var $, Chosen, SelectParser, get_side_border_padding, root;
|
|
||||||
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
|
||||||
root = typeof exports !== "undefined" && exports !== null ? exports : this;
|
|
||||||
$ = jQuery;
|
|
||||||
$.fn.extend({
|
|
||||||
chosen: function(data, options) {
|
|
||||||
return $(this).each(function(input_field) {
|
|
||||||
if (!($(this)).hasClass("chzn-done")) {
|
|
||||||
return new Chosen(this, data, options);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Chosen = (function() {
|
|
||||||
function Chosen(elmn) {
|
|
||||||
this.set_default_values();
|
|
||||||
this.form_field = elmn;
|
|
||||||
this.form_field_jq = $(this.form_field);
|
|
||||||
this.is_multiple = this.form_field.multiple;
|
|
||||||
this.default_text_default = this.form_field.multiple ? "Select Some Options" : "Select an Option";
|
|
||||||
this.set_up_html();
|
|
||||||
this.register_observers();
|
|
||||||
this.form_field_jq.addClass("chzn-done");
|
|
||||||
}
|
|
||||||
Chosen.prototype.set_default_values = function() {
|
|
||||||
this.click_test_action = __bind(function(evt) {
|
|
||||||
return this.test_active_click(evt);
|
|
||||||
}, this);
|
|
||||||
this.active_field = false;
|
|
||||||
this.mouse_on_container = false;
|
|
||||||
this.results_showing = false;
|
|
||||||
this.result_highlighted = null;
|
|
||||||
this.result_single_selected = null;
|
|
||||||
return this.choices = 0;
|
|
||||||
};
|
|
||||||
Chosen.prototype.set_up_html = function() {
|
|
||||||
var container_div, dd_top, dd_width, sf_width;
|
|
||||||
this.container_id = this.form_field.id.length ? this.form_field.id.replace('.', '_') : this.generate_field_id();
|
|
||||||
this.container_id += "_chzn";
|
|
||||||
this.f_width = this.form_field_jq.width();
|
|
||||||
this.default_text = this.form_field_jq.attr('title') ? this.form_field_jq.attr('title') : this.default_text_default;
|
|
||||||
container_div = $("<div />", {
|
|
||||||
id: this.container_id,
|
|
||||||
"class": 'chzn-container',
|
|
||||||
style: 'width: ' + this.f_width + 'px;'
|
|
||||||
});
|
|
||||||
if (this.is_multiple) {
|
|
||||||
container_div.html('<ul class="chzn-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" style="width:25px;" /></li></ul><div class="chzn-drop" style="left:-9000px;"><ul class="chzn-results"></ul></div>');
|
|
||||||
} else {
|
|
||||||
container_div.html('<a href="javascript:void(0)" class="chzn-single"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chzn-drop" style="left:-9000px;"><div class="chzn-search"><input type="text" /></div><ul class="chzn-results"></ul></div>');
|
|
||||||
}
|
|
||||||
this.form_field_jq.hide().after(container_div);
|
|
||||||
this.container = $('#' + this.container_id);
|
|
||||||
this.container.addClass("chzn-container-" + (this.is_multiple ? "multi" : "single"));
|
|
||||||
this.dropdown = this.container.find('div.chzn-drop').first();
|
|
||||||
dd_top = this.container.height();
|
|
||||||
dd_width = this.f_width - get_side_border_padding(this.dropdown);
|
|
||||||
this.dropdown.css({
|
|
||||||
"width": dd_width + "px",
|
|
||||||
"top": dd_top + "px"
|
|
||||||
});
|
|
||||||
this.search_field = this.container.find('input').first();
|
|
||||||
this.search_results = this.container.find('ul.chzn-results').first();
|
|
||||||
this.search_field_scale();
|
|
||||||
this.search_no_results = this.container.find('li.no-results').first();
|
|
||||||
if (this.is_multiple) {
|
|
||||||
this.search_choices = this.container.find('ul.chzn-choices').first();
|
|
||||||
this.search_container = this.container.find('li.search-field').first();
|
|
||||||
} else {
|
|
||||||
this.search_container = this.container.find('div.chzn-search').first();
|
|
||||||
this.selected_item = this.container.find('.chzn-single').first();
|
|
||||||
sf_width = dd_width - get_side_border_padding(this.search_container) - get_side_border_padding(this.search_field);
|
|
||||||
this.search_field.css({
|
|
||||||
"width": sf_width + "px"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.results_build();
|
|
||||||
return this.set_tab_index();
|
|
||||||
};
|
|
||||||
Chosen.prototype.register_observers = function() {
|
|
||||||
this.container.click(__bind(function(evt) {
|
|
||||||
return this.container_click(evt);
|
|
||||||
}, this));
|
|
||||||
this.container.mouseenter(__bind(function(evt) {
|
|
||||||
return this.mouse_enter(evt);
|
|
||||||
}, this));
|
|
||||||
this.container.mouseleave(__bind(function(evt) {
|
|
||||||
return this.mouse_leave(evt);
|
|
||||||
}, this));
|
|
||||||
this.search_results.click(__bind(function(evt) {
|
|
||||||
return this.search_results_click(evt);
|
|
||||||
}, this));
|
|
||||||
this.search_results.mouseover(__bind(function(evt) {
|
|
||||||
return this.search_results_mouseover(evt);
|
|
||||||
}, this));
|
|
||||||
this.search_results.mouseout(__bind(function(evt) {
|
|
||||||
return this.search_results_mouseout(evt);
|
|
||||||
}, this));
|
|
||||||
this.form_field_jq.bind("liszt:updated", __bind(function(evt) {
|
|
||||||
return this.results_update_field(evt);
|
|
||||||
}, this));
|
|
||||||
this.search_field.blur(__bind(function(evt) {
|
|
||||||
return this.input_blur(evt);
|
|
||||||
}, this));
|
|
||||||
this.search_field.keyup(__bind(function(evt) {
|
|
||||||
return this.keyup_checker(evt);
|
|
||||||
}, this));
|
|
||||||
this.search_field.keydown(__bind(function(evt) {
|
|
||||||
return this.keydown_checker(evt);
|
|
||||||
}, this));
|
|
||||||
if (this.is_multiple) {
|
|
||||||
this.search_choices.click(__bind(function(evt) {
|
|
||||||
return this.choices_click(evt);
|
|
||||||
}, this));
|
|
||||||
return this.search_field.focus(__bind(function(evt) {
|
|
||||||
return this.input_focus(evt);
|
|
||||||
}, this));
|
|
||||||
} else {
|
|
||||||
return this.selected_item.focus(__bind(function(evt) {
|
|
||||||
return this.activate_field(evt);
|
|
||||||
}, this));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.container_click = function(evt) {
|
|
||||||
if (evt && evt.type === "click") {
|
|
||||||
evt.stopPropagation();
|
|
||||||
}
|
|
||||||
if (!this.pending_destroy_click) {
|
|
||||||
if (!this.active_field) {
|
|
||||||
if (this.is_multiple) {
|
|
||||||
this.search_field.val("");
|
|
||||||
}
|
|
||||||
$(document).click(this.click_test_action);
|
|
||||||
this.results_show();
|
|
||||||
} else if (!this.is_multiple && evt && ($(evt.target) === this.selected_item || $(evt.target).parents("a.chzn-single").length)) {
|
|
||||||
evt.preventDefault();
|
|
||||||
this.results_toggle();
|
|
||||||
}
|
|
||||||
return this.activate_field();
|
|
||||||
} else {
|
|
||||||
return this.pending_destroy_click = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.mouse_enter = function() {
|
|
||||||
return this.mouse_on_container = true;
|
|
||||||
};
|
|
||||||
Chosen.prototype.mouse_leave = function() {
|
|
||||||
return this.mouse_on_container = false;
|
|
||||||
};
|
|
||||||
Chosen.prototype.input_focus = function(evt) {
|
|
||||||
if (!this.active_field) {
|
|
||||||
return setTimeout((__bind(function() {
|
|
||||||
return this.container_click();
|
|
||||||
}, this)), 50);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.input_blur = function(evt) {
|
|
||||||
if (!this.mouse_on_container) {
|
|
||||||
this.active_field = false;
|
|
||||||
return setTimeout((__bind(function() {
|
|
||||||
return this.blur_test();
|
|
||||||
}, this)), 100);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.blur_test = function(evt) {
|
|
||||||
if (!this.active_field && this.container.hasClass("chzn-container-active")) {
|
|
||||||
return this.close_field();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.close_field = function() {
|
|
||||||
$(document).unbind("click", this.click_test_action);
|
|
||||||
if (!this.is_multiple) {
|
|
||||||
this.selected_item.attr("tabindex", this.search_field.attr("tabindex"));
|
|
||||||
this.search_field.attr("tabindex", -1);
|
|
||||||
}
|
|
||||||
this.active_field = false;
|
|
||||||
this.results_hide();
|
|
||||||
this.container.removeClass("chzn-container-active");
|
|
||||||
this.winnow_results_clear();
|
|
||||||
this.clear_backstroke();
|
|
||||||
this.show_search_field_default();
|
|
||||||
return this.search_field_scale();
|
|
||||||
};
|
|
||||||
Chosen.prototype.activate_field = function() {
|
|
||||||
if (!this.is_multiple && !this.active_field) {
|
|
||||||
this.search_field.attr("tabindex", this.selected_item.attr("tabindex"));
|
|
||||||
this.selected_item.attr("tabindex", -1);
|
|
||||||
}
|
|
||||||
this.container.addClass("chzn-container-active");
|
|
||||||
this.active_field = true;
|
|
||||||
this.search_field.val(this.search_field.val());
|
|
||||||
return this.search_field.focus();
|
|
||||||
};
|
|
||||||
Chosen.prototype.test_active_click = function(evt) {
|
|
||||||
if ($(evt.target).parents('#' + this.container_id).length) {
|
|
||||||
return this.active_field = true;
|
|
||||||
} else {
|
|
||||||
return this.close_field();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.results_build = function() {
|
|
||||||
var content, data, startTime, _i, _len, _ref;
|
|
||||||
startTime = new Date();
|
|
||||||
this.parsing = true;
|
|
||||||
this.results_data = SelectParser.select_to_array(this.form_field);
|
|
||||||
if (this.is_multiple && this.choices > 0) {
|
|
||||||
this.search_choices.find("li.search-choice").remove();
|
|
||||||
this.choices = 0;
|
|
||||||
} else if (!this.is_multiple) {
|
|
||||||
this.selected_item.find("span").text(this.default_text);
|
|
||||||
}
|
|
||||||
content = '';
|
|
||||||
_ref = this.results_data;
|
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
||||||
data = _ref[_i];
|
|
||||||
if (data.group) {
|
|
||||||
content += this.result_add_group(data);
|
|
||||||
} else if (!data.empty) {
|
|
||||||
content += this.result_add_option(data);
|
|
||||||
if (data.selected && this.is_multiple) {
|
|
||||||
this.choice_build(data);
|
|
||||||
} else if (data.selected && !this.is_multiple) {
|
|
||||||
this.selected_item.find("span").text(data.text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.show_search_field_default();
|
|
||||||
this.search_field_scale();
|
|
||||||
this.search_results.html(content);
|
|
||||||
return this.parsing = false;
|
|
||||||
};
|
|
||||||
Chosen.prototype.result_add_group = function(group) {
|
|
||||||
if (!group.disabled) {
|
|
||||||
group.dom_id = this.container_id + "_g_" + group.array_index;
|
|
||||||
return '<li id="' + group.dom_id + '" class="group-result">' + $("<div />").text(group.label).html() + '</li>';
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.result_add_option = function(option) {
|
|
||||||
var classes;
|
|
||||||
if (!option.disabled) {
|
|
||||||
option.dom_id = this.container_id + "_o_" + option.array_index;
|
|
||||||
classes = option.selected && this.is_multiple ? [] : ["active-result"];
|
|
||||||
if (option.selected) {
|
|
||||||
classes.push("result-selected");
|
|
||||||
}
|
|
||||||
if (option.group_array_index != null) {
|
|
||||||
classes.push("group-option");
|
|
||||||
}
|
|
||||||
return '<li id="' + option.dom_id + '" class="' + classes.join(' ') + '">' + $("<div />").text(option.text).html() + '</li>';
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.results_update_field = function() {
|
|
||||||
this.result_clear_highlight();
|
|
||||||
this.result_single_selected = null;
|
|
||||||
return this.results_build();
|
|
||||||
};
|
|
||||||
Chosen.prototype.result_do_highlight = function(el) {
|
|
||||||
var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
|
|
||||||
if (el.length) {
|
|
||||||
this.result_clear_highlight();
|
|
||||||
this.result_highlight = el;
|
|
||||||
this.result_highlight.addClass("highlighted");
|
|
||||||
maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
|
|
||||||
visible_top = this.search_results.scrollTop();
|
|
||||||
visible_bottom = maxHeight + visible_top;
|
|
||||||
high_top = this.result_highlight.position().top + this.search_results.scrollTop();
|
|
||||||
high_bottom = high_top + this.result_highlight.outerHeight();
|
|
||||||
if (high_bottom >= visible_bottom) {
|
|
||||||
return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
|
|
||||||
} else if (high_top < visible_top) {
|
|
||||||
return this.search_results.scrollTop(high_top);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.result_clear_highlight = function() {
|
|
||||||
if (this.result_highlight) {
|
|
||||||
this.result_highlight.removeClass("highlighted");
|
|
||||||
}
|
|
||||||
return this.result_highlight = null;
|
|
||||||
};
|
|
||||||
Chosen.prototype.results_toggle = function() {
|
|
||||||
if (this.results_showing) {
|
|
||||||
return this.results_hide();
|
|
||||||
} else {
|
|
||||||
return this.results_show();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.results_show = function() {
|
|
||||||
var dd_top;
|
|
||||||
if (!this.is_multiple) {
|
|
||||||
this.selected_item.addClass("chzn-single-with-drop");
|
|
||||||
if (this.result_single_selected) {
|
|
||||||
this.result_do_highlight(this.result_single_selected);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dd_top = this.is_multiple ? this.container.height() : this.container.height() - 1;
|
|
||||||
this.dropdown.css({
|
|
||||||
"top": dd_top + "px",
|
|
||||||
"left": 0
|
|
||||||
});
|
|
||||||
this.results_showing = true;
|
|
||||||
this.search_field.focus();
|
|
||||||
this.search_field.val(this.search_field.val());
|
|
||||||
return this.winnow_results();
|
|
||||||
};
|
|
||||||
Chosen.prototype.results_hide = function() {
|
|
||||||
if (!this.is_multiple) {
|
|
||||||
this.selected_item.removeClass("chzn-single-with-drop");
|
|
||||||
}
|
|
||||||
this.result_clear_highlight();
|
|
||||||
this.dropdown.css({
|
|
||||||
"left": "-9000px"
|
|
||||||
});
|
|
||||||
return this.results_showing = false;
|
|
||||||
};
|
|
||||||
Chosen.prototype.set_tab_index = function(el) {
|
|
||||||
var ti;
|
|
||||||
if (this.form_field_jq.attr("tabindex")) {
|
|
||||||
ti = this.form_field_jq.attr("tabindex");
|
|
||||||
this.form_field_jq.attr("tabindex", -1);
|
|
||||||
if (this.is_multiple) {
|
|
||||||
return this.search_field.attr("tabindex", ti);
|
|
||||||
} else {
|
|
||||||
this.selected_item.attr("tabindex", ti);
|
|
||||||
return this.search_field.attr("tabindex", -1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.show_search_field_default = function() {
|
|
||||||
if (this.is_multiple && this.choices < 1 && !this.active_field) {
|
|
||||||
this.search_field.val(this.default_text);
|
|
||||||
return this.search_field.addClass("default");
|
|
||||||
} else {
|
|
||||||
this.search_field.val("");
|
|
||||||
return this.search_field.removeClass("default");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.search_results_click = function(evt) {
|
|
||||||
var target;
|
|
||||||
target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
|
|
||||||
if (target.length) {
|
|
||||||
this.result_highlight = target;
|
|
||||||
return this.result_select();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.search_results_mouseover = function(evt) {
|
|
||||||
var target;
|
|
||||||
target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
|
|
||||||
if (target) {
|
|
||||||
return this.result_do_highlight(target);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.search_results_mouseout = function(evt) {
|
|
||||||
if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
|
|
||||||
return this.result_clear_highlight();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.choices_click = function(evt) {
|
|
||||||
evt.preventDefault();
|
|
||||||
if (this.active_field && !($(evt.target).hasClass("search-choice" || $(evt.target).parents('.search-choice').first)) && !this.results_showing) {
|
|
||||||
return this.results_show();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.choice_build = function(item) {
|
|
||||||
var choice_id, link;
|
|
||||||
choice_id = this.container_id + "_c_" + item.array_index;
|
|
||||||
this.choices += 1;
|
|
||||||
this.search_container.before('<li class="search-choice" id="' + choice_id + '"><span>' + item.text + '</span><a href="javascript:void(0)" class="search-choice-close" rel="' + item.array_index + '"></a></li>');
|
|
||||||
link = $('#' + choice_id).find("a").first();
|
|
||||||
return link.click(__bind(function(evt) {
|
|
||||||
return this.choice_destroy_link_click(evt);
|
|
||||||
}, this));
|
|
||||||
};
|
|
||||||
Chosen.prototype.choice_destroy_link_click = function(evt) {
|
|
||||||
evt.preventDefault();
|
|
||||||
this.pending_destroy_click = true;
|
|
||||||
return this.choice_destroy($(evt.target));
|
|
||||||
};
|
|
||||||
Chosen.prototype.choice_destroy = function(link) {
|
|
||||||
this.choices -= 1;
|
|
||||||
this.show_search_field_default();
|
|
||||||
if (this.is_multiple && this.choices > 0 && this.search_field.val().length < 1) {
|
|
||||||
this.results_hide();
|
|
||||||
}
|
|
||||||
this.result_deselect(link.attr("rel"));
|
|
||||||
return link.parents('li').first().remove();
|
|
||||||
};
|
|
||||||
Chosen.prototype.result_select = function() {
|
|
||||||
var high, high_id, item, position;
|
|
||||||
if (this.result_highlight) {
|
|
||||||
high = this.result_highlight;
|
|
||||||
high_id = high.attr("id");
|
|
||||||
this.result_clear_highlight();
|
|
||||||
high.addClass("result-selected");
|
|
||||||
if (this.is_multiple) {
|
|
||||||
this.result_deactivate(high);
|
|
||||||
} else {
|
|
||||||
this.result_single_selected = high;
|
|
||||||
}
|
|
||||||
position = high_id.substr(high_id.lastIndexOf("_") + 1);
|
|
||||||
item = this.results_data[position];
|
|
||||||
item.selected = true;
|
|
||||||
this.form_field.options[item.options_index].selected = true;
|
|
||||||
if (this.is_multiple) {
|
|
||||||
this.choice_build(item);
|
|
||||||
} else {
|
|
||||||
this.selected_item.find("span").first().text(item.text);
|
|
||||||
}
|
|
||||||
this.results_hide();
|
|
||||||
this.search_field.val("");
|
|
||||||
this.form_field_jq.trigger("change");
|
|
||||||
return this.search_field_scale();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.result_activate = function(el) {
|
|
||||||
return el.addClass("active-result").show();
|
|
||||||
};
|
|
||||||
Chosen.prototype.result_deactivate = function(el) {
|
|
||||||
return el.removeClass("active-result").hide();
|
|
||||||
};
|
|
||||||
Chosen.prototype.result_deselect = function(pos) {
|
|
||||||
var result, result_data;
|
|
||||||
result_data = this.results_data[pos];
|
|
||||||
result_data.selected = false;
|
|
||||||
this.form_field.options[result_data.options_index].selected = false;
|
|
||||||
result = $("#" + this.container_id + "_o_" + pos);
|
|
||||||
result.removeClass("result-selected").addClass("active-result").show();
|
|
||||||
this.result_clear_highlight();
|
|
||||||
this.winnow_results();
|
|
||||||
this.form_field_jq.trigger("change");
|
|
||||||
return this.search_field_scale();
|
|
||||||
};
|
|
||||||
Chosen.prototype.results_search = function(evt) {
|
|
||||||
if (this.results_showing) {
|
|
||||||
return this.winnow_results();
|
|
||||||
} else {
|
|
||||||
return this.results_show();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.winnow_results = function() {
|
|
||||||
var found, option, part, parts, regex, result_id, results, searchText, startTime, startpos, text, zregex, _i, _j, _len, _len2, _ref;
|
|
||||||
startTime = new Date();
|
|
||||||
this.no_results_clear();
|
|
||||||
results = 0;
|
|
||||||
searchText = this.search_field.val() === this.default_text ? "" : $.trim(this.search_field.val());
|
|
||||||
regex = new RegExp('^' + searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
|
|
||||||
zregex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"), 'i');
|
|
||||||
_ref = this.results_data;
|
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
||||||
option = _ref[_i];
|
|
||||||
if (!option.disabled && !option.empty) {
|
|
||||||
if (option.group) {
|
|
||||||
$('#' + option.dom_id).hide();
|
|
||||||
} else if (!(this.is_multiple && option.selected)) {
|
|
||||||
found = false;
|
|
||||||
result_id = option.dom_id;
|
|
||||||
if (regex.test(option.text)) {
|
|
||||||
found = true;
|
|
||||||
results += 1;
|
|
||||||
} else if (option.text.indexOf(" ") >= 0 || option.text.indexOf("[") === 0) {
|
|
||||||
parts = option.text.replace(/\[|\]/g, "").split(" ");
|
|
||||||
if (parts.length) {
|
|
||||||
for (_j = 0, _len2 = parts.length; _j < _len2; _j++) {
|
|
||||||
part = parts[_j];
|
|
||||||
if (regex.test(part)) {
|
|
||||||
found = true;
|
|
||||||
results += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (found) {
|
|
||||||
if (searchText.length) {
|
|
||||||
startpos = option.text.search(zregex);
|
|
||||||
text = option.text.substr(0, startpos + searchText.length) + '</em>' + option.text.substr(startpos + searchText.length);
|
|
||||||
text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
|
|
||||||
} else {
|
|
||||||
text = option.text;
|
|
||||||
}
|
|
||||||
if ($("#" + result_id).html !== text) {
|
|
||||||
$("#" + result_id).html(text);
|
|
||||||
}
|
|
||||||
this.result_activate($("#" + result_id));
|
|
||||||
if (option.group_array_index != null) {
|
|
||||||
$("#" + this.results_data[option.group_array_index].dom_id).show();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (this.result_highlight && result_id === this.result_highlight.attr('id')) {
|
|
||||||
this.result_clear_highlight();
|
|
||||||
}
|
|
||||||
this.result_deactivate($("#" + result_id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (results < 1 && searchText.length) {
|
|
||||||
return this.no_results(searchText);
|
|
||||||
} else {
|
|
||||||
return this.winnow_results_set_highlight();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.winnow_results_clear = function() {
|
|
||||||
var li, lis, _i, _len, _results;
|
|
||||||
this.search_field.val("");
|
|
||||||
lis = this.search_results.find("li");
|
|
||||||
_results = [];
|
|
||||||
for (_i = 0, _len = lis.length; _i < _len; _i++) {
|
|
||||||
li = lis[_i];
|
|
||||||
li = $(li);
|
|
||||||
_results.push(li.hasClass("group-result") ? li.show() : !this.is_multiple || !li.hasClass("result-selected") ? this.result_activate(li) : void 0);
|
|
||||||
}
|
|
||||||
return _results;
|
|
||||||
};
|
|
||||||
Chosen.prototype.winnow_results_set_highlight = function() {
|
|
||||||
var do_high;
|
|
||||||
if (!this.result_highlight) {
|
|
||||||
do_high = this.search_results.find(".active-result").first();
|
|
||||||
if (do_high) {
|
|
||||||
return this.result_do_highlight(do_high);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.no_results = function(terms) {
|
|
||||||
var no_results_html;
|
|
||||||
no_results_html = $('<li class="no-results">No results match "<span></span>"</li>');
|
|
||||||
no_results_html.find("span").first().text(terms);
|
|
||||||
return this.search_results.append(no_results_html);
|
|
||||||
};
|
|
||||||
Chosen.prototype.no_results_clear = function() {
|
|
||||||
return this.search_results.find(".no-results").remove();
|
|
||||||
};
|
|
||||||
Chosen.prototype.keydown_arrow = function() {
|
|
||||||
var first_active, next_sib;
|
|
||||||
if (!this.result_highlight) {
|
|
||||||
first_active = this.search_results.find("li.active-result").first();
|
|
||||||
if (first_active) {
|
|
||||||
this.result_do_highlight($(first_active));
|
|
||||||
}
|
|
||||||
} else if (this.results_showing) {
|
|
||||||
next_sib = this.result_highlight.nextAll("li.active-result").first();
|
|
||||||
if (next_sib) {
|
|
||||||
this.result_do_highlight(next_sib);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!this.results_showing) {
|
|
||||||
return this.results_show();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.keyup_arrow = function() {
|
|
||||||
var prev_sibs;
|
|
||||||
if (!this.results_showing && !this.is_multiple) {
|
|
||||||
return this.results_show();
|
|
||||||
} else if (this.result_highlight) {
|
|
||||||
prev_sibs = this.result_highlight.prevAll("li.active-result");
|
|
||||||
if (prev_sibs.length) {
|
|
||||||
return this.result_do_highlight(prev_sibs.first());
|
|
||||||
} else {
|
|
||||||
if (this.choices > 0) {
|
|
||||||
this.results_hide();
|
|
||||||
}
|
|
||||||
return this.result_clear_highlight();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.keydown_backstroke = function() {
|
|
||||||
if (this.pending_backstroke) {
|
|
||||||
this.choice_destroy(this.pending_backstroke.find("a").first());
|
|
||||||
return this.clear_backstroke();
|
|
||||||
} else {
|
|
||||||
this.pending_backstroke = this.search_container.siblings("li.search-choice").last();
|
|
||||||
return this.pending_backstroke.addClass("search-choice-focus");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.clear_backstroke = function() {
|
|
||||||
if (this.pending_backstroke) {
|
|
||||||
this.pending_backstroke.removeClass("search-choice-focus");
|
|
||||||
}
|
|
||||||
return this.pending_backstroke = null;
|
|
||||||
};
|
|
||||||
Chosen.prototype.keyup_checker = function(evt) {
|
|
||||||
var stroke, _ref;
|
|
||||||
stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
|
|
||||||
this.search_field_scale();
|
|
||||||
switch (stroke) {
|
|
||||||
case 8:
|
|
||||||
if (this.is_multiple && this.backstroke_length < 1 && this.choices > 0) {
|
|
||||||
return this.keydown_backstroke();
|
|
||||||
} else if (!this.pending_backstroke) {
|
|
||||||
this.result_clear_highlight();
|
|
||||||
return this.results_search();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 13:
|
|
||||||
evt.preventDefault();
|
|
||||||
if (this.results_showing) {
|
|
||||||
return this.result_select();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 27:
|
|
||||||
if (this.results_showing) {
|
|
||||||
return this.results_hide();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
case 38:
|
|
||||||
case 40:
|
|
||||||
case 16:
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return this.results_search();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.keydown_checker = function(evt) {
|
|
||||||
var stroke, _ref;
|
|
||||||
stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
|
|
||||||
this.search_field_scale();
|
|
||||||
if (stroke !== 8 && this.pending_backstroke) {
|
|
||||||
this.clear_backstroke();
|
|
||||||
}
|
|
||||||
switch (stroke) {
|
|
||||||
case 8:
|
|
||||||
this.backstroke_length = this.search_field.val().length;
|
|
||||||
break;
|
|
||||||
case 9:
|
|
||||||
this.mouse_on_container = false;
|
|
||||||
break;
|
|
||||||
case 13:
|
|
||||||
evt.preventDefault();
|
|
||||||
break;
|
|
||||||
case 38:
|
|
||||||
evt.preventDefault();
|
|
||||||
this.keyup_arrow();
|
|
||||||
break;
|
|
||||||
case 40:
|
|
||||||
this.keydown_arrow();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.search_field_scale = function() {
|
|
||||||
var dd_top, div, h, style, style_block, styles, w, _i, _len;
|
|
||||||
if (this.is_multiple) {
|
|
||||||
h = 0;
|
|
||||||
w = 0;
|
|
||||||
style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
|
|
||||||
styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
|
|
||||||
for (_i = 0, _len = styles.length; _i < _len; _i++) {
|
|
||||||
style = styles[_i];
|
|
||||||
style_block += style + ":" + this.search_field.css(style) + ";";
|
|
||||||
}
|
|
||||||
div = $('<div />', {
|
|
||||||
'style': style_block
|
|
||||||
});
|
|
||||||
div.text(this.search_field.val());
|
|
||||||
$('body').append(div);
|
|
||||||
w = div.width() + 25;
|
|
||||||
div.remove();
|
|
||||||
if (w > this.f_width - 10) {
|
|
||||||
w = this.f_width - 10;
|
|
||||||
}
|
|
||||||
this.search_field.css({
|
|
||||||
'width': w + 'px'
|
|
||||||
});
|
|
||||||
dd_top = this.container.height();
|
|
||||||
return this.dropdown.css({
|
|
||||||
"top": dd_top + "px"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
Chosen.prototype.generate_field_id = function() {
|
|
||||||
var new_id;
|
|
||||||
new_id = this.generate_random_id();
|
|
||||||
this.form_field.id = new_id;
|
|
||||||
return new_id;
|
|
||||||
};
|
|
||||||
Chosen.prototype.generate_random_id = function() {
|
|
||||||
var string;
|
|
||||||
string = "sel" + this.generate_random_char() + this.generate_random_char() + this.generate_random_char();
|
|
||||||
while ($("#" + string).length > 0) {
|
|
||||||
string += this.generate_random_char();
|
|
||||||
}
|
|
||||||
return string;
|
|
||||||
};
|
|
||||||
Chosen.prototype.generate_random_char = function() {
|
|
||||||
var chars, newchar, rand;
|
|
||||||
chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZ";
|
|
||||||
rand = Math.floor(Math.random() * chars.length);
|
|
||||||
return newchar = chars.substring(rand, rand + 1);
|
|
||||||
};
|
|
||||||
return Chosen;
|
|
||||||
})();
|
|
||||||
get_side_border_padding = function(elmt) {
|
|
||||||
var side_border_padding;
|
|
||||||
return side_border_padding = elmt.outerWidth() - elmt.width();
|
|
||||||
};
|
|
||||||
root.get_side_border_padding = get_side_border_padding;
|
|
||||||
SelectParser = (function() {
|
|
||||||
function SelectParser() {
|
|
||||||
this.options_index = 0;
|
|
||||||
this.parsed = [];
|
|
||||||
}
|
|
||||||
SelectParser.prototype.add_node = function(child) {
|
|
||||||
if (child.nodeName === "OPTGROUP") {
|
|
||||||
return this.add_group(child);
|
|
||||||
} else {
|
|
||||||
return this.add_option(child);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
SelectParser.prototype.add_group = function(group) {
|
|
||||||
var group_position, option, _i, _len, _ref, _results;
|
|
||||||
group_position = this.parsed.length;
|
|
||||||
this.parsed.push({
|
|
||||||
array_index: group_position,
|
|
||||||
group: true,
|
|
||||||
label: group.label,
|
|
||||||
children: 0,
|
|
||||||
disabled: group.disabled
|
|
||||||
});
|
|
||||||
_ref = group.childNodes;
|
|
||||||
_results = [];
|
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
||||||
option = _ref[_i];
|
|
||||||
_results.push(this.add_option(option, group_position, group.disabled));
|
|
||||||
}
|
|
||||||
return _results;
|
|
||||||
};
|
|
||||||
SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
|
|
||||||
if (option.nodeName === "OPTION") {
|
|
||||||
if (option.text !== "") {
|
|
||||||
if (group_position != null) {
|
|
||||||
this.parsed[group_position].children += 1;
|
|
||||||
}
|
|
||||||
this.parsed.push({
|
|
||||||
array_index: this.parsed.length,
|
|
||||||
options_index: this.options_index,
|
|
||||||
value: option.value,
|
|
||||||
text: option.text,
|
|
||||||
selected: option.selected,
|
|
||||||
disabled: group_disabled === true ? group_disabled : option.disabled,
|
|
||||||
group_array_index: group_position
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.parsed.push({
|
|
||||||
array_index: this.parsed.length,
|
|
||||||
options_index: this.options_index,
|
|
||||||
empty: true
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return this.options_index += 1;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return SelectParser;
|
|
||||||
})();
|
|
||||||
SelectParser.select_to_array = function(select) {
|
|
||||||
var child, parser, _i, _len, _ref;
|
|
||||||
parser = new SelectParser();
|
|
||||||
_ref = select.childNodes;
|
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
||||||
child = _ref[_i];
|
|
||||||
parser.add_node(child);
|
|
||||||
}
|
|
||||||
return parser.parsed;
|
|
||||||
};
|
|
||||||
root.SelectParser = SelectParser;
|
|
||||||
}).call(this);
|
|
||||||
@@ -1,163 +0,0 @@
|
|||||||
$(function() {
|
|
||||||
|
|
||||||
// Helper function for vertically aligning DOM elements
|
|
||||||
// http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/
|
|
||||||
$.fn.vAlign = function() {
|
|
||||||
return this.each(function(i){
|
|
||||||
var ah = $(this).height();
|
|
||||||
var ph = $(this).parent().height();
|
|
||||||
var mh = (ph - ah) / 2;
|
|
||||||
$(this).css('margin-top', mh);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$.fn.stretchFormtasticInputWidthToParent = function() {
|
|
||||||
return this.each(function(i){
|
|
||||||
var p_width = $(this).closest("form").innerWidth();
|
|
||||||
var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest("form").css('padding-right'), 10);
|
|
||||||
var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10);
|
|
||||||
$(this).css('width', p_width - p_padding - this_padding);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
$('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent();
|
|
||||||
|
|
||||||
// Vertically center these paragraphs
|
|
||||||
// Parent may need a min-height for this to work..
|
|
||||||
$('ul.downplayed li div.content p').vAlign();
|
|
||||||
|
|
||||||
// When a sandbox form is submitted..
|
|
||||||
$("form.sandbox").submit(function(){
|
|
||||||
|
|
||||||
var error_free = true;
|
|
||||||
|
|
||||||
// Cycle through the forms required inputs
|
|
||||||
$(this).find("input.required").each(function() {
|
|
||||||
|
|
||||||
// Remove any existing error styles from the input
|
|
||||||
$(this).removeClass('error');
|
|
||||||
|
|
||||||
// Tack the error style on if the input is empty..
|
|
||||||
if ($(this).val() == '') {
|
|
||||||
$(this).addClass('error');
|
|
||||||
$(this).wiggle();
|
|
||||||
error_free = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
return error_free;
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
function clippyCopiedCallback(a) {
|
|
||||||
$('#api_key_copied').fadeIn().delay(1000).fadeOut();
|
|
||||||
|
|
||||||
// var b = $("#clippy_tooltip_" + a);
|
|
||||||
// b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() {
|
|
||||||
// b.attr("title", "copy to clipboard")
|
|
||||||
// },
|
|
||||||
// 500))
|
|
||||||
}
|
|
||||||
|
|
||||||
// Logging function that accounts for browsers that don't have window.console
|
|
||||||
function log() {
|
|
||||||
if (window.console) console.log.apply(console,arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
var Docs = {
|
|
||||||
|
|
||||||
shebang: function() {
|
|
||||||
|
|
||||||
// If shebang has an operation nickname in it..
|
|
||||||
// e.g. /docs/#!/words/get_search
|
|
||||||
var fragments = $.param.fragment().split('/');
|
|
||||||
fragments.shift(); // get rid of the bang
|
|
||||||
|
|
||||||
switch (fragments.length) {
|
|
||||||
case 1:
|
|
||||||
// Expand all operations for the resource and scroll to it
|
|
||||||
log('shebang resource:' + fragments[0]);
|
|
||||||
var dom_id = 'resource_' + fragments[0];
|
|
||||||
|
|
||||||
Docs.expandEndpointListForResource(fragments[0]);
|
|
||||||
$("#"+dom_id).slideto({highlight: false});
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
// Refer to the endpoint DOM element, e.g. #words_get_search
|
|
||||||
log('shebang endpoint: ' + fragments.join('_'));
|
|
||||||
|
|
||||||
// Expand Resource
|
|
||||||
Docs.expandEndpointListForResource(fragments[0]);
|
|
||||||
$("#"+dom_id).slideto({highlight: false});
|
|
||||||
|
|
||||||
// Expand operation
|
|
||||||
var li_dom_id = fragments.join('_');
|
|
||||||
var li_content_dom_id = li_dom_id + "_content";
|
|
||||||
|
|
||||||
log("li_dom_id " + li_dom_id);
|
|
||||||
log("li_content_dom_id " + li_content_dom_id);
|
|
||||||
|
|
||||||
Docs.expandOperation($('#'+li_content_dom_id));
|
|
||||||
$('#'+li_dom_id).slideto({highlight: false});
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
toggleEndpointListForResource: function(resource) {
|
|
||||||
var elem = $('li#resource_' + resource + ' ul.endpoints');
|
|
||||||
if (elem.is(':visible')) {
|
|
||||||
Docs.collapseEndpointListForResource(resource);
|
|
||||||
} else {
|
|
||||||
Docs.expandEndpointListForResource(resource);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Expand resource
|
|
||||||
expandEndpointListForResource: function(resource) {
|
|
||||||
$('#resource_' + resource).addClass('active');
|
|
||||||
|
|
||||||
var elem = $('li#resource_' + resource + ' ul.endpoints');
|
|
||||||
elem.slideDown();
|
|
||||||
},
|
|
||||||
|
|
||||||
// Collapse resource and mark as explicitly closed
|
|
||||||
collapseEndpointListForResource: function(resource) {
|
|
||||||
$('#resource_' + resource).removeClass('active');
|
|
||||||
|
|
||||||
var elem = $('li#resource_' + resource + ' ul.endpoints');
|
|
||||||
elem.slideUp();
|
|
||||||
},
|
|
||||||
|
|
||||||
expandOperationsForResource: function(resource) {
|
|
||||||
// Make sure the resource container is open..
|
|
||||||
Docs.expandEndpointListForResource(resource);
|
|
||||||
$('li#resource_' + resource + ' li.operation div.content').each(function() {
|
|
||||||
Docs.expandOperation($(this));
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
collapseOperationsForResource: function(resource) {
|
|
||||||
// Make sure the resource container is open..
|
|
||||||
Docs.expandEndpointListForResource(resource);
|
|
||||||
$('li#resource_' + resource + ' li.operation div.content').each(function() {
|
|
||||||
Docs.collapseOperation($(this));
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
expandOperation: function(elem) {
|
|
||||||
elem.slideDown();
|
|
||||||
},
|
|
||||||
|
|
||||||
collapseOperation: function(elem) {
|
|
||||||
elem.slideUp();
|
|
||||||
},
|
|
||||||
|
|
||||||
toggleOperationContent: function(dom_id) {
|
|
||||||
var elem = $('#' + dom_id);
|
|
||||||
(elem.is(':visible')) ? Docs.collapseOperation(elem) : Docs.expandOperation(elem);
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
19
build/javascripts/jquery-1.6.2.min.js
vendored
19
build/javascripts/jquery-1.6.2.min.js
vendored
File diff suppressed because one or more lines are too long
790
build/javascripts/jquery-ui-1.8.14.custom.min.js
vendored
790
build/javascripts/jquery-ui-1.8.14.custom.min.js
vendored
@@ -1,790 +0,0 @@
|
|||||||
/*!
|
|
||||||
* jQuery UI 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function(c,j){function k(a,b){var d=a.nodeName.toLowerCase();if("area"===d){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&l(a)}return(/input|select|textarea|button|object/.test(d)?!a.disabled:"a"==d?a.href||b:b)&&l(a)}function l(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.14",
|
|
||||||
keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=this;setTimeout(function(){c(d).focus();
|
|
||||||
b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this,"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,
|
|
||||||
"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position");if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",
|
|
||||||
function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,m,n){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(m)g-=parseFloat(c.curCSS(f,"border"+this+"Width",true))||0;if(n)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,outerWidth:c.fn.outerWidth,
|
|
||||||
outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h,d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){return k(a,!isNaN(c.attr(a,"tabindex")))},tabbable:function(a){var b=c.attr(a,"tabindex"),d=isNaN(b);
|
|
||||||
return(d||b>=0)&&k(a,!d)}});c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode)for(var e=
|
|
||||||
0;e<b.length;e++)a.options[b[e][0]]&&b[e][1].apply(a.element,d)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(a,b){if(c(a).css("overflow")==="hidden")return false;b=b&&b==="left"?"scrollLeft":"scrollTop";var d=false;if(a[b]>0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a<b+d},isOver:function(a,b,d,e,h,i){return c.ui.isOverAxis(a,d,h)&&c.ui.isOverAxis(b,e,i)}})}})(jQuery);
|
|
||||||
;/*!
|
|
||||||
* jQuery UI Widget 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Widget
|
|
||||||
*/
|
|
||||||
(function(b,j){if(b.cleanData){var k=b.cleanData;b.cleanData=function(a){for(var c=0,d;(d=a[c])!=null;c++)b(d).triggerHandler("remove");k(a)}}else{var l=b.fn.remove;b.fn.remove=function(a,c){return this.each(function(){if(!c)if(!a||b.filter(a,[this]).length)b("*",this).add([this]).each(function(){b(this).triggerHandler("remove")});return l.call(b(this),a,c)})}}b.widget=function(a,c,d){var e=a.split(".")[0],f;a=a.split(".")[1];f=e+"-"+a;if(!d){d=c;c=b.Widget}b.expr[":"][f]=function(h){return!!b.data(h,
|
|
||||||
a)};b[e]=b[e]||{};b[e][a]=function(h,g){arguments.length&&this._createWidget(h,g)};c=new c;c.options=b.extend(true,{},c.options);b[e][a].prototype=b.extend(true,c,{namespace:e,widgetName:a,widgetEventPrefix:b[e][a].prototype.widgetEventPrefix||a,widgetBaseClass:f},d);b.widget.bridge(a,b[e][a])};b.widget.bridge=function(a,c){b.fn[a]=function(d){var e=typeof d==="string",f=Array.prototype.slice.call(arguments,1),h=this;d=!e&&f.length?b.extend.apply(null,[true,d].concat(f)):d;if(e&&d.charAt(0)==="_")return h;
|
|
||||||
e?this.each(function(){var g=b.data(this,a),i=g&&b.isFunction(g[d])?g[d].apply(g,f):g;if(i!==g&&i!==j){h=i;return false}}):this.each(function(){var g=b.data(this,a);g?g.option(d||{})._init():b.data(this,a,new c(d,this))});return h}};b.Widget=function(a,c){arguments.length&&this._createWidget(a,c)};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(a,c){b.data(c,this.widgetName,this);this.element=b(c);this.options=b.extend(true,{},this.options,
|
|
||||||
this._getCreateOptions(),a);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return b.metadata&&b.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},
|
|
||||||
widget:function(){return this.element},option:function(a,c){var d=a;if(arguments.length===0)return b.extend({},this.options);if(typeof a==="string"){if(c===j)return this.options[a];d={};d[a]=c}this._setOptions(d);return this},_setOptions:function(a){var c=this;b.each(a,function(d,e){c._setOption(d,e)});return this},_setOption:function(a,c){this.options[a]=c;if(a==="disabled")this.widget()[c?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",c);return this},
|
|
||||||
enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(a,c,d){var e=this.options[a];c=b.Event(c);c.type=(a===this.widgetEventPrefix?a:this.widgetEventPrefix+a).toLowerCase();d=d||{};if(c.originalEvent){a=b.event.props.length;for(var f;a;){f=b.event.props[--a];c[f]=c.originalEvent[f]}}this.element.trigger(c,d);return!(b.isFunction(e)&&e.call(this.element[0],c,d)===false||c.isDefaultPrevented())}}})(jQuery);
|
|
||||||
;/*!
|
|
||||||
* jQuery UI Mouse 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Mouse
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.ui.widget.js
|
|
||||||
*/
|
|
||||||
(function(b){var d=false;b(document).mousedown(function(){d=false});b.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var a=this;this.element.bind("mousedown."+this.widgetName,function(c){return a._mouseDown(c)}).bind("click."+this.widgetName,function(c){if(true===b.data(c.target,a.widgetName+".preventClickEvent")){b.removeData(c.target,a.widgetName+".preventClickEvent");c.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+
|
|
||||||
this.widgetName)},_mouseDown:function(a){if(!d){this._mouseStarted&&this._mouseUp(a);this._mouseDownEvent=a;var c=this,f=a.which==1,g=typeof this.options.cancel=="string"?b(a.target).closest(this.options.cancel).length:false;if(!f||g||!this._mouseCapture(a))return true;this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet)this._mouseDelayTimer=setTimeout(function(){c.mouseDelayMet=true},this.options.delay);if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a)){this._mouseStarted=this._mouseStart(a)!==
|
|
||||||
false;if(!this._mouseStarted){a.preventDefault();return true}}true===b.data(a.target,this.widgetName+".preventClickEvent")&&b.removeData(a.target,this.widgetName+".preventClickEvent");this._mouseMoveDelegate=function(e){return c._mouseMove(e)};this._mouseUpDelegate=function(e){return c._mouseUp(e)};b(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);a.preventDefault();return d=true}},_mouseMove:function(a){if(b.browser.msie&&
|
|
||||||
!(document.documentMode>=9)&&!a.button)return this._mouseUp(a);if(this._mouseStarted){this._mouseDrag(a);return a.preventDefault()}if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a))(this._mouseStarted=this._mouseStart(this._mouseDownEvent,a)!==false)?this._mouseDrag(a):this._mouseUp(a);return!this._mouseStarted},_mouseUp:function(a){b(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=
|
|
||||||
false;a.target==this._mouseDownEvent.target&&b.data(a.target,this.widgetName+".preventClickEvent",true);this._mouseStop(a)}return false},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Position 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Position
|
|
||||||
*/
|
|
||||||
(function(c){c.ui=c.ui||{};var n=/left|center|right/,o=/top|center|bottom/,t=c.fn.position,u=c.fn.offset;c.fn.position=function(b){if(!b||!b.of)return t.apply(this,arguments);b=c.extend({},b);var a=c(b.of),d=a[0],g=(b.collision||"flip").split(" "),e=b.offset?b.offset.split(" "):[0,0],h,k,j;if(d.nodeType===9){h=a.width();k=a.height();j={top:0,left:0}}else if(d.setTimeout){h=a.width();k=a.height();j={top:a.scrollTop(),left:a.scrollLeft()}}else if(d.preventDefault){b.at="left top";h=k=0;j={top:b.of.pageY,
|
|
||||||
left:b.of.pageX}}else{h=a.outerWidth();k=a.outerHeight();j=a.offset()}c.each(["my","at"],function(){var f=(b[this]||"").split(" ");if(f.length===1)f=n.test(f[0])?f.concat(["center"]):o.test(f[0])?["center"].concat(f):["center","center"];f[0]=n.test(f[0])?f[0]:"center";f[1]=o.test(f[1])?f[1]:"center";b[this]=f});if(g.length===1)g[1]=g[0];e[0]=parseInt(e[0],10)||0;if(e.length===1)e[1]=e[0];e[1]=parseInt(e[1],10)||0;if(b.at[0]==="right")j.left+=h;else if(b.at[0]==="center")j.left+=h/2;if(b.at[1]==="bottom")j.top+=
|
|
||||||
k;else if(b.at[1]==="center")j.top+=k/2;j.left+=e[0];j.top+=e[1];return this.each(function(){var f=c(this),l=f.outerWidth(),m=f.outerHeight(),p=parseInt(c.curCSS(this,"marginLeft",true))||0,q=parseInt(c.curCSS(this,"marginTop",true))||0,v=l+p+(parseInt(c.curCSS(this,"marginRight",true))||0),w=m+q+(parseInt(c.curCSS(this,"marginBottom",true))||0),i=c.extend({},j),r;if(b.my[0]==="right")i.left-=l;else if(b.my[0]==="center")i.left-=l/2;if(b.my[1]==="bottom")i.top-=m;else if(b.my[1]==="center")i.top-=
|
|
||||||
m/2;i.left=Math.round(i.left);i.top=Math.round(i.top);r={left:i.left-p,top:i.top-q};c.each(["left","top"],function(s,x){c.ui.position[g[s]]&&c.ui.position[g[s]][x](i,{targetWidth:h,targetHeight:k,elemWidth:l,elemHeight:m,collisionPosition:r,collisionWidth:v,collisionHeight:w,offset:e,my:b.my,at:b.at})});c.fn.bgiframe&&f.bgiframe();f.offset(c.extend(i,{using:b.using}))})};c.ui.position={fit:{left:function(b,a){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();b.left=
|
|
||||||
d>0?b.left-d:Math.max(b.left-a.collisionPosition.left,b.left)},top:function(b,a){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();b.top=d>0?b.top-d:Math.max(b.top-a.collisionPosition.top,b.top)}},flip:{left:function(b,a){if(a.at[0]!=="center"){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();var g=a.my[0]==="left"?-a.elemWidth:a.my[0]==="right"?a.elemWidth:0,e=a.at[0]==="left"?a.targetWidth:-a.targetWidth,h=-2*a.offset[0];b.left+=
|
|
||||||
a.collisionPosition.left<0?g+e+h:d>0?g+e+h:0}},top:function(b,a){if(a.at[1]!=="center"){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();var g=a.my[1]==="top"?-a.elemHeight:a.my[1]==="bottom"?a.elemHeight:0,e=a.at[1]==="top"?a.targetHeight:-a.targetHeight,h=-2*a.offset[1];b.top+=a.collisionPosition.top<0?g+e+h:d>0?g+e+h:0}}}};if(!c.offset.setOffset){c.offset.setOffset=function(b,a){if(/static/.test(c.curCSS(b,"position")))b.style.position="relative";var d=c(b),
|
|
||||||
g=d.offset(),e=parseInt(c.curCSS(b,"top",true),10)||0,h=parseInt(c.curCSS(b,"left",true),10)||0;g={top:a.top-g.top+e,left:a.left-g.left+h};"using"in a?a.using.call(b,g):d.css(g)};c.fn.offset=function(b){var a=this[0];if(!a||!a.ownerDocument)return null;if(b)return this.each(function(){c.offset.setOffset(this,b)});return u.call(this)}}})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Draggable 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Draggables
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.ui.core.js
|
|
||||||
* jquery.ui.mouse.js
|
|
||||||
* jquery.ui.widget.js
|
|
||||||
*/
|
|
||||||
(function(d){d.widget("ui.draggable",d.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){if(this.options.helper==
|
|
||||||
"original"&&!/^(?:r|a|f)/.test(this.element.css("position")))this.element[0].style.position="relative";this.options.addClasses&&this.element.addClass("ui-draggable");this.options.disabled&&this.element.addClass("ui-draggable-disabled");this._mouseInit()},destroy:function(){if(this.element.data("draggable")){this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this}},_mouseCapture:function(a){var b=
|
|
||||||
this.options;if(this.helper||b.disabled||d(a.target).is(".ui-resizable-handle"))return false;this.handle=this._getHandle(a);if(!this.handle)return false;d(b.iframeFix===true?"iframe":b.iframeFix).each(function(){d('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1E3}).css(d(this).offset()).appendTo("body")});return true},_mouseStart:function(a){var b=this.options;this.helper=
|
|
||||||
this._createHelper(a);this._cacheHelperProportions();if(d.ui.ddmanager)d.ui.ddmanager.current=this;this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};d.extend(this.offset,{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});
|
|
||||||
this.originalPosition=this.position=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY=a.pageY;b.cursorAt&&this._adjustOffsetFromHelper(b.cursorAt);b.containment&&this._setContainment();if(this._trigger("start",a)===false){this._clear();return false}this._cacheHelperProportions();d.ui.ddmanager&&!b.dropBehaviour&&d.ui.ddmanager.prepareOffsets(this,a);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(a,true);d.ui.ddmanager&&d.ui.ddmanager.dragStart(this,a);return true},
|
|
||||||
_mouseDrag:function(a,b){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute");if(!b){b=this._uiHash();if(this._trigger("drag",a,b)===false){this._mouseUp({});return false}this.position=b.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";d.ui.ddmanager&&d.ui.ddmanager.drag(this,a);return false},_mouseStop:function(a){var b=
|
|
||||||
false;if(d.ui.ddmanager&&!this.options.dropBehaviour)b=d.ui.ddmanager.drop(this,a);if(this.dropped){b=this.dropped;this.dropped=false}if((!this.element[0]||!this.element[0].parentNode)&&this.options.helper=="original")return false;if(this.options.revert=="invalid"&&!b||this.options.revert=="valid"&&b||this.options.revert===true||d.isFunction(this.options.revert)&&this.options.revert.call(this.element,b)){var c=this;d(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,
|
|
||||||
10),function(){c._trigger("stop",a)!==false&&c._clear()})}else this._trigger("stop",a)!==false&&this._clear();return false},_mouseUp:function(a){this.options.iframeFix===true&&d("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)});d.ui.ddmanager&&d.ui.ddmanager.dragStop(this,a);return d.ui.mouse.prototype._mouseUp.call(this,a)},cancel:function(){this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear();return this},_getHandle:function(a){var b=!this.options.handle||
|
|
||||||
!d(this.options.handle,this.element).length?true:false;d(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==a.target)b=true});return b},_createHelper:function(a){var b=this.options;a=d.isFunction(b.helper)?d(b.helper.apply(this.element[0],[a])):b.helper=="clone"?this.element.clone().removeAttr("id"):this.element;a.parents("body").length||a.appendTo(b.appendTo=="parent"?this.element[0].parentNode:b.appendTo);a[0]!=this.element[0]&&!/(fixed|absolute)/.test(a.css("position"))&&
|
|
||||||
a.css("position","absolute");return a},_adjustOffsetFromHelper:function(a){if(typeof a=="string")a=a.split(" ");if(d.isArray(a))a={left:+a[0],top:+a[1]||0};if("left"in a)this.offset.click.left=a.left+this.margins.left;if("right"in a)this.offset.click.left=this.helperProportions.width-a.right+this.margins.left;if("top"in a)this.offset.click.top=a.top+this.margins.top;if("bottom"in a)this.offset.click.top=this.helperProportions.height-a.bottom+this.margins.top},_getParentOffset:function(){this.offsetParent=
|
|
||||||
this.helper.offsetParent();var a=this.offsetParent.offset();if(this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0])){a.left+=this.scrollParent.scrollLeft();a.top+=this.scrollParent.scrollTop()}if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&d.browser.msie)a={top:0,left:0};return{top:a.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:a.left+(parseInt(this.offsetParent.css("borderLeftWidth"),
|
|
||||||
10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var a=this.element.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"),
|
|
||||||
10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var a=this.options;if(a.containment=="parent")a.containment=this.helper[0].parentNode;if(a.containment=="document"||a.containment=="window")this.containment=[a.containment=="document"?0:d(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,a.containment=="document"?0:d(window).scrollTop()-this.offset.relative.top-this.offset.parent.top,
|
|
||||||
(a.containment=="document"?0:d(window).scrollLeft())+d(a.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(a.containment=="document"?0:d(window).scrollTop())+(d(a.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(a.containment)&&a.containment.constructor!=Array){a=d(a.containment);var b=a[0];if(b){a.offset();var c=d(b).css("overflow")!=
|
|
||||||
"hidden";this.containment=[(parseInt(d(b).css("borderLeftWidth"),10)||0)+(parseInt(d(b).css("paddingLeft"),10)||0),(parseInt(d(b).css("borderTopWidth"),10)||0)+(parseInt(d(b).css("paddingTop"),10)||0),(c?Math.max(b.scrollWidth,b.offsetWidth):b.offsetWidth)-(parseInt(d(b).css("borderLeftWidth"),10)||0)-(parseInt(d(b).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(c?Math.max(b.scrollHeight,b.offsetHeight):b.offsetHeight)-(parseInt(d(b).css("borderTopWidth"),
|
|
||||||
10)||0)-(parseInt(d(b).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom];this.relative_container=a}}else if(a.containment.constructor==Array)this.containment=a.containment},_convertPositionTo:function(a,b){if(!b)b=this.position;a=a=="absolute"?1:-1;var c=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName);return{top:b.top+
|
|
||||||
this.offset.relative.top*a+this.offset.parent.top*a-(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():f?0:c.scrollTop())*a),left:b.left+this.offset.relative.left*a+this.offset.parent.left*a-(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():f?0:c.scrollLeft())*a)}},_generatePosition:function(a){var b=this.options,c=this.cssPosition=="absolute"&&
|
|
||||||
!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName),e=a.pageX,h=a.pageY;if(this.originalPosition){var g;if(this.containment){if(this.relative_container){g=this.relative_container.offset();g=[this.containment[0]+g.left,this.containment[1]+g.top,this.containment[2]+g.left,this.containment[3]+g.top]}else g=this.containment;if(a.pageX-this.offset.click.left<g[0])e=g[0]+this.offset.click.left;
|
|
||||||
if(a.pageY-this.offset.click.top<g[1])h=g[1]+this.offset.click.top;if(a.pageX-this.offset.click.left>g[2])e=g[2]+this.offset.click.left;if(a.pageY-this.offset.click.top>g[3])h=g[3]+this.offset.click.top}if(b.grid){h=b.grid[1]?this.originalPageY+Math.round((h-this.originalPageY)/b.grid[1])*b.grid[1]:this.originalPageY;h=g?!(h-this.offset.click.top<g[1]||h-this.offset.click.top>g[3])?h:!(h-this.offset.click.top<g[1])?h-b.grid[1]:h+b.grid[1]:h;e=b.grid[0]?this.originalPageX+Math.round((e-this.originalPageX)/
|
|
||||||
b.grid[0])*b.grid[0]:this.originalPageX;e=g?!(e-this.offset.click.left<g[0]||e-this.offset.click.left>g[2])?e:!(e-this.offset.click.left<g[0])?e-b.grid[0]:e+b.grid[0]:e}}return{top:h-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():f?0:c.scrollTop()),left:e-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(d.browser.safari&&d.browser.version<
|
|
||||||
526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():f?0:c.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging");this.helper[0]!=this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove();this.helper=null;this.cancelHelperRemoval=false},_trigger:function(a,b,c){c=c||this._uiHash();d.ui.plugin.call(this,a,[b,c]);if(a=="drag")this.positionAbs=this._convertPositionTo("absolute");return d.Widget.prototype._trigger.call(this,a,b,
|
|
||||||
c)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}});d.extend(d.ui.draggable,{version:"1.8.14"});d.ui.plugin.add("draggable","connectToSortable",{start:function(a,b){var c=d(this).data("draggable"),f=c.options,e=d.extend({},b,{item:c.element});c.sortables=[];d(f.connectToSortable).each(function(){var h=d.data(this,"sortable");if(h&&!h.options.disabled){c.sortables.push({instance:h,shouldRevert:h.options.revert});
|
|
||||||
h.refreshPositions();h._trigger("activate",a,e)}})},stop:function(a,b){var c=d(this).data("draggable"),f=d.extend({},b,{item:c.element});d.each(c.sortables,function(){if(this.instance.isOver){this.instance.isOver=0;c.cancelHelperRemoval=true;this.instance.cancelHelperRemoval=false;if(this.shouldRevert)this.instance.options.revert=true;this.instance._mouseStop(a);this.instance.options.helper=this.instance.options._helper;c.options.helper=="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})}else{this.instance.cancelHelperRemoval=
|
|
||||||
false;this.instance._trigger("deactivate",a,f)}})},drag:function(a,b){var c=d(this).data("draggable"),f=this;d.each(c.sortables,function(){this.instance.positionAbs=c.positionAbs;this.instance.helperProportions=c.helperProportions;this.instance.offset.click=c.offset.click;if(this.instance._intersectsWith(this.instance.containerCache)){if(!this.instance.isOver){this.instance.isOver=1;this.instance.currentItem=d(f).clone().removeAttr("id").appendTo(this.instance.element).data("sortable-item",true);
|
|
||||||
this.instance.options._helper=this.instance.options.helper;this.instance.options.helper=function(){return b.helper[0]};a.target=this.instance.currentItem[0];this.instance._mouseCapture(a,true);this.instance._mouseStart(a,true,true);this.instance.offset.click.top=c.offset.click.top;this.instance.offset.click.left=c.offset.click.left;this.instance.offset.parent.left-=c.offset.parent.left-this.instance.offset.parent.left;this.instance.offset.parent.top-=c.offset.parent.top-this.instance.offset.parent.top;
|
|
||||||
c._trigger("toSortable",a);c.dropped=this.instance.element;c.currentItem=c.element;this.instance.fromOutside=c}this.instance.currentItem&&this.instance._mouseDrag(a)}else if(this.instance.isOver){this.instance.isOver=0;this.instance.cancelHelperRemoval=true;this.instance.options.revert=false;this.instance._trigger("out",a,this.instance._uiHash(this.instance));this.instance._mouseStop(a,true);this.instance.options.helper=this.instance.options._helper;this.instance.currentItem.remove();this.instance.placeholder&&
|
|
||||||
this.instance.placeholder.remove();c._trigger("fromSortable",a);c.dropped=false}})}});d.ui.plugin.add("draggable","cursor",{start:function(){var a=d("body"),b=d(this).data("draggable").options;if(a.css("cursor"))b._cursor=a.css("cursor");a.css("cursor",b.cursor)},stop:function(){var a=d(this).data("draggable").options;a._cursor&&d("body").css("cursor",a._cursor)}});d.ui.plugin.add("draggable","opacity",{start:function(a,b){a=d(b.helper);b=d(this).data("draggable").options;if(a.css("opacity"))b._opacity=
|
|
||||||
a.css("opacity");a.css("opacity",b.opacity)},stop:function(a,b){a=d(this).data("draggable").options;a._opacity&&d(b.helper).css("opacity",a._opacity)}});d.ui.plugin.add("draggable","scroll",{start:function(){var a=d(this).data("draggable");if(a.scrollParent[0]!=document&&a.scrollParent[0].tagName!="HTML")a.overflowOffset=a.scrollParent.offset()},drag:function(a){var b=d(this).data("draggable"),c=b.options,f=false;if(b.scrollParent[0]!=document&&b.scrollParent[0].tagName!="HTML"){if(!c.axis||c.axis!=
|
|
||||||
"x")if(b.overflowOffset.top+b.scrollParent[0].offsetHeight-a.pageY<c.scrollSensitivity)b.scrollParent[0].scrollTop=f=b.scrollParent[0].scrollTop+c.scrollSpeed;else if(a.pageY-b.overflowOffset.top<c.scrollSensitivity)b.scrollParent[0].scrollTop=f=b.scrollParent[0].scrollTop-c.scrollSpeed;if(!c.axis||c.axis!="y")if(b.overflowOffset.left+b.scrollParent[0].offsetWidth-a.pageX<c.scrollSensitivity)b.scrollParent[0].scrollLeft=f=b.scrollParent[0].scrollLeft+c.scrollSpeed;else if(a.pageX-b.overflowOffset.left<
|
|
||||||
c.scrollSensitivity)b.scrollParent[0].scrollLeft=f=b.scrollParent[0].scrollLeft-c.scrollSpeed}else{if(!c.axis||c.axis!="x")if(a.pageY-d(document).scrollTop()<c.scrollSensitivity)f=d(document).scrollTop(d(document).scrollTop()-c.scrollSpeed);else if(d(window).height()-(a.pageY-d(document).scrollTop())<c.scrollSensitivity)f=d(document).scrollTop(d(document).scrollTop()+c.scrollSpeed);if(!c.axis||c.axis!="y")if(a.pageX-d(document).scrollLeft()<c.scrollSensitivity)f=d(document).scrollLeft(d(document).scrollLeft()-
|
|
||||||
c.scrollSpeed);else if(d(window).width()-(a.pageX-d(document).scrollLeft())<c.scrollSensitivity)f=d(document).scrollLeft(d(document).scrollLeft()+c.scrollSpeed)}f!==false&&d.ui.ddmanager&&!c.dropBehaviour&&d.ui.ddmanager.prepareOffsets(b,a)}});d.ui.plugin.add("draggable","snap",{start:function(){var a=d(this).data("draggable"),b=a.options;a.snapElements=[];d(b.snap.constructor!=String?b.snap.items||":data(draggable)":b.snap).each(function(){var c=d(this),f=c.offset();this!=a.element[0]&&a.snapElements.push({item:this,
|
|
||||||
width:c.outerWidth(),height:c.outerHeight(),top:f.top,left:f.left})})},drag:function(a,b){for(var c=d(this).data("draggable"),f=c.options,e=f.snapTolerance,h=b.offset.left,g=h+c.helperProportions.width,n=b.offset.top,o=n+c.helperProportions.height,i=c.snapElements.length-1;i>=0;i--){var j=c.snapElements[i].left,l=j+c.snapElements[i].width,k=c.snapElements[i].top,m=k+c.snapElements[i].height;if(j-e<h&&h<l+e&&k-e<n&&n<m+e||j-e<h&&h<l+e&&k-e<o&&o<m+e||j-e<g&&g<l+e&&k-e<n&&n<m+e||j-e<g&&g<l+e&&k-e<o&&
|
|
||||||
o<m+e){if(f.snapMode!="inner"){var p=Math.abs(k-o)<=e,q=Math.abs(m-n)<=e,r=Math.abs(j-g)<=e,s=Math.abs(l-h)<=e;if(p)b.position.top=c._convertPositionTo("relative",{top:k-c.helperProportions.height,left:0}).top-c.margins.top;if(q)b.position.top=c._convertPositionTo("relative",{top:m,left:0}).top-c.margins.top;if(r)b.position.left=c._convertPositionTo("relative",{top:0,left:j-c.helperProportions.width}).left-c.margins.left;if(s)b.position.left=c._convertPositionTo("relative",{top:0,left:l}).left-c.margins.left}var t=
|
|
||||||
p||q||r||s;if(f.snapMode!="outer"){p=Math.abs(k-n)<=e;q=Math.abs(m-o)<=e;r=Math.abs(j-h)<=e;s=Math.abs(l-g)<=e;if(p)b.position.top=c._convertPositionTo("relative",{top:k,left:0}).top-c.margins.top;if(q)b.position.top=c._convertPositionTo("relative",{top:m-c.helperProportions.height,left:0}).top-c.margins.top;if(r)b.position.left=c._convertPositionTo("relative",{top:0,left:j}).left-c.margins.left;if(s)b.position.left=c._convertPositionTo("relative",{top:0,left:l-c.helperProportions.width}).left-c.margins.left}if(!c.snapElements[i].snapping&&
|
|
||||||
(p||q||r||s||t))c.options.snap.snap&&c.options.snap.snap.call(c.element,a,d.extend(c._uiHash(),{snapItem:c.snapElements[i].item}));c.snapElements[i].snapping=p||q||r||s||t}else{c.snapElements[i].snapping&&c.options.snap.release&&c.options.snap.release.call(c.element,a,d.extend(c._uiHash(),{snapItem:c.snapElements[i].item}));c.snapElements[i].snapping=false}}}});d.ui.plugin.add("draggable","stack",{start:function(){var a=d(this).data("draggable").options;a=d.makeArray(d(a.stack)).sort(function(c,f){return(parseInt(d(c).css("zIndex"),
|
|
||||||
10)||0)-(parseInt(d(f).css("zIndex"),10)||0)});if(a.length){var b=parseInt(a[0].style.zIndex)||0;d(a).each(function(c){this.style.zIndex=b+c});this[0].style.zIndex=b+a.length}}});d.ui.plugin.add("draggable","zIndex",{start:function(a,b){a=d(b.helper);b=d(this).data("draggable").options;if(a.css("zIndex"))b._zIndex=a.css("zIndex");a.css("zIndex",b.zIndex)},stop:function(a,b){a=d(this).data("draggable").options;a._zIndex&&d(b.helper).css("zIndex",a._zIndex)}})})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Droppable 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Droppables
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.ui.core.js
|
|
||||||
* jquery.ui.widget.js
|
|
||||||
* jquery.ui.mouse.js
|
|
||||||
* jquery.ui.draggable.js
|
|
||||||
*/
|
|
||||||
(function(d){d.widget("ui.droppable",{widgetEventPrefix:"drop",options:{accept:"*",activeClass:false,addClasses:true,greedy:false,hoverClass:false,scope:"default",tolerance:"intersect"},_create:function(){var a=this.options,b=a.accept;this.isover=0;this.isout=1;this.accept=d.isFunction(b)?b:function(c){return c.is(b)};this.proportions={width:this.element[0].offsetWidth,height:this.element[0].offsetHeight};d.ui.ddmanager.droppables[a.scope]=d.ui.ddmanager.droppables[a.scope]||[];d.ui.ddmanager.droppables[a.scope].push(this);
|
|
||||||
a.addClasses&&this.element.addClass("ui-droppable")},destroy:function(){for(var a=d.ui.ddmanager.droppables[this.options.scope],b=0;b<a.length;b++)a[b]==this&&a.splice(b,1);this.element.removeClass("ui-droppable ui-droppable-disabled").removeData("droppable").unbind(".droppable");return this},_setOption:function(a,b){if(a=="accept")this.accept=d.isFunction(b)?b:function(c){return c.is(b)};d.Widget.prototype._setOption.apply(this,arguments)},_activate:function(a){var b=d.ui.ddmanager.current;this.options.activeClass&&
|
|
||||||
this.element.addClass(this.options.activeClass);b&&this._trigger("activate",a,this.ui(b))},_deactivate:function(a){var b=d.ui.ddmanager.current;this.options.activeClass&&this.element.removeClass(this.options.activeClass);b&&this._trigger("deactivate",a,this.ui(b))},_over:function(a){var b=d.ui.ddmanager.current;if(!(!b||(b.currentItem||b.element)[0]==this.element[0]))if(this.accept.call(this.element[0],b.currentItem||b.element)){this.options.hoverClass&&this.element.addClass(this.options.hoverClass);
|
|
||||||
this._trigger("over",a,this.ui(b))}},_out:function(a){var b=d.ui.ddmanager.current;if(!(!b||(b.currentItem||b.element)[0]==this.element[0]))if(this.accept.call(this.element[0],b.currentItem||b.element)){this.options.hoverClass&&this.element.removeClass(this.options.hoverClass);this._trigger("out",a,this.ui(b))}},_drop:function(a,b){var c=b||d.ui.ddmanager.current;if(!c||(c.currentItem||c.element)[0]==this.element[0])return false;var e=false;this.element.find(":data(droppable)").not(".ui-draggable-dragging").each(function(){var g=
|
|
||||||
d.data(this,"droppable");if(g.options.greedy&&!g.options.disabled&&g.options.scope==c.options.scope&&g.accept.call(g.element[0],c.currentItem||c.element)&&d.ui.intersect(c,d.extend(g,{offset:g.element.offset()}),g.options.tolerance)){e=true;return false}});if(e)return false;if(this.accept.call(this.element[0],c.currentItem||c.element)){this.options.activeClass&&this.element.removeClass(this.options.activeClass);this.options.hoverClass&&this.element.removeClass(this.options.hoverClass);this._trigger("drop",
|
|
||||||
a,this.ui(c));return this.element}return false},ui:function(a){return{draggable:a.currentItem||a.element,helper:a.helper,position:a.position,offset:a.positionAbs}}});d.extend(d.ui.droppable,{version:"1.8.14"});d.ui.intersect=function(a,b,c){if(!b.offset)return false;var e=(a.positionAbs||a.position.absolute).left,g=e+a.helperProportions.width,f=(a.positionAbs||a.position.absolute).top,h=f+a.helperProportions.height,i=b.offset.left,k=i+b.proportions.width,j=b.offset.top,l=j+b.proportions.height;
|
|
||||||
switch(c){case "fit":return i<=e&&g<=k&&j<=f&&h<=l;case "intersect":return i<e+a.helperProportions.width/2&&g-a.helperProportions.width/2<k&&j<f+a.helperProportions.height/2&&h-a.helperProportions.height/2<l;case "pointer":return d.ui.isOver((a.positionAbs||a.position.absolute).top+(a.clickOffset||a.offset.click).top,(a.positionAbs||a.position.absolute).left+(a.clickOffset||a.offset.click).left,j,i,b.proportions.height,b.proportions.width);case "touch":return(f>=j&&f<=l||h>=j&&h<=l||f<j&&h>l)&&(e>=
|
|
||||||
i&&e<=k||g>=i&&g<=k||e<i&&g>k);default:return false}};d.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(a,b){var c=d.ui.ddmanager.droppables[a.options.scope]||[],e=b?b.type:null,g=(a.currentItem||a.element).find(":data(droppable)").andSelf(),f=0;a:for(;f<c.length;f++)if(!(c[f].options.disabled||a&&!c[f].accept.call(c[f].element[0],a.currentItem||a.element))){for(var h=0;h<g.length;h++)if(g[h]==c[f].element[0]){c[f].proportions.height=0;continue a}c[f].visible=c[f].element.css("display")!=
|
|
||||||
"none";if(c[f].visible){e=="mousedown"&&c[f]._activate.call(c[f],b);c[f].offset=c[f].element.offset();c[f].proportions={width:c[f].element[0].offsetWidth,height:c[f].element[0].offsetHeight}}}},drop:function(a,b){var c=false;d.each(d.ui.ddmanager.droppables[a.options.scope]||[],function(){if(this.options){if(!this.options.disabled&&this.visible&&d.ui.intersect(a,this,this.options.tolerance))c=c||this._drop.call(this,b);if(!this.options.disabled&&this.visible&&this.accept.call(this.element[0],a.currentItem||
|
|
||||||
a.element)){this.isout=1;this.isover=0;this._deactivate.call(this,b)}}});return c},dragStart:function(a,b){a.element.parentsUntil("body").bind("scroll.droppable",function(){a.options.refreshPositions||d.ui.ddmanager.prepareOffsets(a,b)})},drag:function(a,b){a.options.refreshPositions&&d.ui.ddmanager.prepareOffsets(a,b);d.each(d.ui.ddmanager.droppables[a.options.scope]||[],function(){if(!(this.options.disabled||this.greedyChild||!this.visible)){var c=d.ui.intersect(a,this,this.options.tolerance);if(c=
|
|
||||||
!c&&this.isover==1?"isout":c&&this.isover==0?"isover":null){var e;if(this.options.greedy){var g=this.element.parents(":data(droppable):eq(0)");if(g.length){e=d.data(g[0],"droppable");e.greedyChild=c=="isover"?1:0}}if(e&&c=="isover"){e.isover=0;e.isout=1;e._out.call(e,b)}this[c]=1;this[c=="isout"?"isover":"isout"]=0;this[c=="isover"?"_over":"_out"].call(this,b);if(e&&c=="isout"){e.isout=0;e.isover=1;e._over.call(e,b)}}}})},dragStop:function(a,b){a.element.parentsUntil("body").unbind("scroll.droppable");
|
|
||||||
a.options.refreshPositions||d.ui.ddmanager.prepareOffsets(a,b)}}})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Resizable 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Resizables
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.ui.core.js
|
|
||||||
* jquery.ui.mouse.js
|
|
||||||
* jquery.ui.widget.js
|
|
||||||
*/
|
|
||||||
(function(e){e.widget("ui.resizable",e.ui.mouse,{widgetEventPrefix:"resize",options:{alsoResize:false,animate:false,animateDuration:"slow",animateEasing:"swing",aspectRatio:false,autoHide:false,containment:false,ghost:false,grid:false,handles:"e,s,se",helper:false,maxHeight:null,maxWidth:null,minHeight:10,minWidth:10,zIndex:1E3},_create:function(){var b=this,a=this.options;this.element.addClass("ui-resizable");e.extend(this,{_aspectRatio:!!a.aspectRatio,aspectRatio:a.aspectRatio,originalElement:this.element,
|
|
||||||
_proportionallyResizeElements:[],_helper:a.helper||a.ghost||a.animate?a.helper||"ui-resizable-helper":null});if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)){/relative/.test(this.element.css("position"))&&e.browser.opera&&this.element.css({position:"relative",top:"auto",left:"auto"});this.element.wrap(e('<div class="ui-wrapper" style="overflow: hidden;"></div>').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(),
|
|
||||||
top:this.element.css("top"),left:this.element.css("left")}));this.element=this.element.parent().data("resizable",this.element.data("resizable"));this.elementIsWrapper=true;this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")});this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});this.originalResizeStyle=
|
|
||||||
this.originalElement.css("resize");this.originalElement.css("resize","none");this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"}));this.originalElement.css({margin:this.originalElement.css("margin")});this._proportionallyResize()}this.handles=a.handles||(!e(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne",
|
|
||||||
nw:".ui-resizable-nw"});if(this.handles.constructor==String){if(this.handles=="all")this.handles="n,e,s,w,se,sw,ne,nw";var c=this.handles.split(",");this.handles={};for(var d=0;d<c.length;d++){var f=e.trim(c[d]),g=e('<div class="ui-resizable-handle '+("ui-resizable-"+f)+'"></div>');/sw|se|ne|nw/.test(f)&&g.css({zIndex:++a.zIndex});"se"==f&&g.addClass("ui-icon ui-icon-gripsmall-diagonal-se");this.handles[f]=".ui-resizable-"+f;this.element.append(g)}}this._renderAxis=function(h){h=h||this.element;for(var i in this.handles){if(this.handles[i].constructor==
|
|
||||||
String)this.handles[i]=e(this.handles[i],this.element).show();if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var j=e(this.handles[i],this.element),l=0;l=/sw|ne|nw|se|n|s/.test(i)?j.outerHeight():j.outerWidth();j=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join("");h.css(j,l);this._proportionallyResize()}e(this.handles[i])}};this._renderAxis(this.element);this._handles=e(".ui-resizable-handle",this.element).disableSelection();
|
|
||||||
this._handles.mouseover(function(){if(!b.resizing){if(this.className)var h=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);b.axis=h&&h[1]?h[1]:"se"}});if(a.autoHide){this._handles.hide();e(this.element).addClass("ui-resizable-autohide").hover(function(){if(!a.disabled){e(this).removeClass("ui-resizable-autohide");b._handles.show()}},function(){if(!a.disabled)if(!b.resizing){e(this).addClass("ui-resizable-autohide");b._handles.hide()}})}this._mouseInit()},destroy:function(){this._mouseDestroy();
|
|
||||||
var b=function(c){e(c).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){b(this.element);var a=this.element;a.after(this.originalElement.css({position:a.css("position"),width:a.outerWidth(),height:a.outerHeight(),top:a.css("top"),left:a.css("left")})).remove()}this.originalElement.css("resize",this.originalResizeStyle);b(this.originalElement);return this},_mouseCapture:function(b){var a=
|
|
||||||
false;for(var c in this.handles)if(e(this.handles[c])[0]==b.target)a=true;return!this.options.disabled&&a},_mouseStart:function(b){var a=this.options,c=this.element.position(),d=this.element;this.resizing=true;this.documentScroll={top:e(document).scrollTop(),left:e(document).scrollLeft()};if(d.is(".ui-draggable")||/absolute/.test(d.css("position")))d.css({position:"absolute",top:c.top,left:c.left});e.browser.opera&&/relative/.test(d.css("position"))&&d.css({position:"relative",top:"auto",left:"auto"});
|
|
||||||
this._renderProxy();c=m(this.helper.css("left"));var f=m(this.helper.css("top"));if(a.containment){c+=e(a.containment).scrollLeft()||0;f+=e(a.containment).scrollTop()||0}this.offset=this.helper.offset();this.position={left:c,top:f};this.size=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalSize=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalPosition={left:c,top:f};this.sizeDiff=
|
|
||||||
{width:d.outerWidth()-d.width(),height:d.outerHeight()-d.height()};this.originalMousePosition={left:b.pageX,top:b.pageY};this.aspectRatio=typeof a.aspectRatio=="number"?a.aspectRatio:this.originalSize.width/this.originalSize.height||1;a=e(".ui-resizable-"+this.axis).css("cursor");e("body").css("cursor",a=="auto"?this.axis+"-resize":a);d.addClass("ui-resizable-resizing");this._propagate("start",b);return true},_mouseDrag:function(b){var a=this.helper,c=this.originalMousePosition,d=this._change[this.axis];
|
|
||||||
if(!d)return false;c=d.apply(this,[b,b.pageX-c.left||0,b.pageY-c.top||0]);this._updateVirtualBoundaries(b.shiftKey);if(this._aspectRatio||b.shiftKey)c=this._updateRatio(c,b);c=this._respectSize(c,b);this._propagate("resize",b);a.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize();this._updateCache(c);this._trigger("resize",b,this.ui());return false},
|
|
||||||
_mouseStop:function(b){this.resizing=false;var a=this.options,c=this;if(this._helper){var d=this._proportionallyResizeElements,f=d.length&&/textarea/i.test(d[0].nodeName);d=f&&e.ui.hasScroll(d[0],"left")?0:c.sizeDiff.height;f=f?0:c.sizeDiff.width;f={width:c.helper.width()-f,height:c.helper.height()-d};d=parseInt(c.element.css("left"),10)+(c.position.left-c.originalPosition.left)||null;var g=parseInt(c.element.css("top"),10)+(c.position.top-c.originalPosition.top)||null;a.animate||this.element.css(e.extend(f,
|
|
||||||
{top:g,left:d}));c.helper.height(c.size.height);c.helper.width(c.size.width);this._helper&&!a.animate&&this._proportionallyResize()}e("body").css("cursor","auto");this.element.removeClass("ui-resizable-resizing");this._propagate("stop",b);this._helper&&this.helper.remove();return false},_updateVirtualBoundaries:function(b){var a=this.options,c,d,f;a={minWidth:k(a.minWidth)?a.minWidth:0,maxWidth:k(a.maxWidth)?a.maxWidth:Infinity,minHeight:k(a.minHeight)?a.minHeight:0,maxHeight:k(a.maxHeight)?a.maxHeight:
|
|
||||||
Infinity};if(this._aspectRatio||b){b=a.minHeight*this.aspectRatio;d=a.minWidth/this.aspectRatio;c=a.maxHeight*this.aspectRatio;f=a.maxWidth/this.aspectRatio;if(b>a.minWidth)a.minWidth=b;if(d>a.minHeight)a.minHeight=d;if(c<a.maxWidth)a.maxWidth=c;if(f<a.maxHeight)a.maxHeight=f}this._vBoundaries=a},_updateCache:function(b){this.offset=this.helper.offset();if(k(b.left))this.position.left=b.left;if(k(b.top))this.position.top=b.top;if(k(b.height))this.size.height=b.height;if(k(b.width))this.size.width=
|
|
||||||
b.width},_updateRatio:function(b){var a=this.position,c=this.size,d=this.axis;if(k(b.height))b.width=b.height*this.aspectRatio;else if(k(b.width))b.height=b.width/this.aspectRatio;if(d=="sw"){b.left=a.left+(c.width-b.width);b.top=null}if(d=="nw"){b.top=a.top+(c.height-b.height);b.left=a.left+(c.width-b.width)}return b},_respectSize:function(b){var a=this._vBoundaries,c=this.axis,d=k(b.width)&&a.maxWidth&&a.maxWidth<b.width,f=k(b.height)&&a.maxHeight&&a.maxHeight<b.height,g=k(b.width)&&a.minWidth&&
|
|
||||||
a.minWidth>b.width,h=k(b.height)&&a.minHeight&&a.minHeight>b.height;if(g)b.width=a.minWidth;if(h)b.height=a.minHeight;if(d)b.width=a.maxWidth;if(f)b.height=a.maxHeight;var i=this.originalPosition.left+this.originalSize.width,j=this.position.top+this.size.height,l=/sw|nw|w/.test(c);c=/nw|ne|n/.test(c);if(g&&l)b.left=i-a.minWidth;if(d&&l)b.left=i-a.maxWidth;if(h&&c)b.top=j-a.minHeight;if(f&&c)b.top=j-a.maxHeight;if((a=!b.width&&!b.height)&&!b.left&&b.top)b.top=null;else if(a&&!b.top&&b.left)b.left=
|
|
||||||
null;return b},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var b=this.helper||this.element,a=0;a<this._proportionallyResizeElements.length;a++){var c=this._proportionallyResizeElements[a];if(!this.borderDif){var d=[c.css("borderTopWidth"),c.css("borderRightWidth"),c.css("borderBottomWidth"),c.css("borderLeftWidth")],f=[c.css("paddingTop"),c.css("paddingRight"),c.css("paddingBottom"),c.css("paddingLeft")];this.borderDif=e.map(d,function(g,h){g=parseInt(g,10)||
|
|
||||||
0;h=parseInt(f[h],10)||0;return g+h})}e.browser.msie&&(e(b).is(":hidden")||e(b).parents(":hidden").length)||c.css({height:b.height()-this.borderDif[0]-this.borderDif[2]||0,width:b.width()-this.borderDif[1]-this.borderDif[3]||0})}},_renderProxy:function(){var b=this.options;this.elementOffset=this.element.offset();if(this._helper){this.helper=this.helper||e('<div style="overflow:hidden;"></div>');var a=e.browser.msie&&e.browser.version<7,c=a?1:0;a=a?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+
|
|
||||||
a,height:this.element.outerHeight()+a,position:"absolute",left:this.elementOffset.left-c+"px",top:this.elementOffset.top-c+"px",zIndex:++b.zIndex});this.helper.appendTo("body").disableSelection()}else this.helper=this.element},_change:{e:function(b,a){return{width:this.originalSize.width+a}},w:function(b,a){return{left:this.originalPosition.left+a,width:this.originalSize.width-a}},n:function(b,a,c){return{top:this.originalPosition.top+c,height:this.originalSize.height-c}},s:function(b,a,c){return{height:this.originalSize.height+
|
|
||||||
c}},se:function(b,a,c){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[b,a,c]))},sw:function(b,a,c){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[b,a,c]))},ne:function(b,a,c){return e.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[b,a,c]))},nw:function(b,a,c){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[b,a,c]))}},_propagate:function(b,a){e.ui.plugin.call(this,b,[a,this.ui()]);
|
|
||||||
b!="resize"&&this._trigger(b,a,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}});e.extend(e.ui.resizable,{version:"1.8.14"});e.ui.plugin.add("resizable","alsoResize",{start:function(){var b=e(this).data("resizable").options,a=function(c){e(c).each(function(){var d=e(this);d.data("resizable-alsoresize",{width:parseInt(d.width(),
|
|
||||||
10),height:parseInt(d.height(),10),left:parseInt(d.css("left"),10),top:parseInt(d.css("top"),10),position:d.css("position")})})};if(typeof b.alsoResize=="object"&&!b.alsoResize.parentNode)if(b.alsoResize.length){b.alsoResize=b.alsoResize[0];a(b.alsoResize)}else e.each(b.alsoResize,function(c){a(c)});else a(b.alsoResize)},resize:function(b,a){var c=e(this).data("resizable");b=c.options;var d=c.originalSize,f=c.originalPosition,g={height:c.size.height-d.height||0,width:c.size.width-d.width||0,top:c.position.top-
|
|
||||||
f.top||0,left:c.position.left-f.left||0},h=function(i,j){e(i).each(function(){var l=e(this),q=e(this).data("resizable-alsoresize"),p={},r=j&&j.length?j:l.parents(a.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(r,function(n,o){if((n=(q[o]||0)+(g[o]||0))&&n>=0)p[o]=n||null});if(e.browser.opera&&/relative/.test(l.css("position"))){c._revertToRelativePosition=true;l.css({position:"absolute",top:"auto",left:"auto"})}l.css(p)})};typeof b.alsoResize=="object"&&!b.alsoResize.nodeType?
|
|
||||||
e.each(b.alsoResize,function(i,j){h(i,j)}):h(b.alsoResize)},stop:function(){var b=e(this).data("resizable"),a=b.options,c=function(d){e(d).each(function(){var f=e(this);f.css({position:f.data("resizable-alsoresize").position})})};if(b._revertToRelativePosition){b._revertToRelativePosition=false;typeof a.alsoResize=="object"&&!a.alsoResize.nodeType?e.each(a.alsoResize,function(d){c(d)}):c(a.alsoResize)}e(this).removeData("resizable-alsoresize")}});e.ui.plugin.add("resizable","animate",{stop:function(b){var a=
|
|
||||||
e(this).data("resizable"),c=a.options,d=a._proportionallyResizeElements,f=d.length&&/textarea/i.test(d[0].nodeName),g=f&&e.ui.hasScroll(d[0],"left")?0:a.sizeDiff.height;f={width:a.size.width-(f?0:a.sizeDiff.width),height:a.size.height-g};g=parseInt(a.element.css("left"),10)+(a.position.left-a.originalPosition.left)||null;var h=parseInt(a.element.css("top"),10)+(a.position.top-a.originalPosition.top)||null;a.element.animate(e.extend(f,h&&g?{top:h,left:g}:{}),{duration:c.animateDuration,easing:c.animateEasing,
|
|
||||||
step:function(){var i={width:parseInt(a.element.css("width"),10),height:parseInt(a.element.css("height"),10),top:parseInt(a.element.css("top"),10),left:parseInt(a.element.css("left"),10)};d&&d.length&&e(d[0]).css({width:i.width,height:i.height});a._updateCache(i);a._propagate("resize",b)}})}});e.ui.plugin.add("resizable","containment",{start:function(){var b=e(this).data("resizable"),a=b.element,c=b.options.containment;if(a=c instanceof e?c.get(0):/parent/.test(c)?a.parent().get(0):c){b.containerElement=
|
|
||||||
e(a);if(/document/.test(c)||c==document){b.containerOffset={left:0,top:0};b.containerPosition={left:0,top:0};b.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight}}else{var d=e(a),f=[];e(["Top","Right","Left","Bottom"]).each(function(i,j){f[i]=m(d.css("padding"+j))});b.containerOffset=d.offset();b.containerPosition=d.position();b.containerSize={height:d.innerHeight()-f[3],width:d.innerWidth()-f[1]};c=b.containerOffset;
|
|
||||||
var g=b.containerSize.height,h=b.containerSize.width;h=e.ui.hasScroll(a,"left")?a.scrollWidth:h;g=e.ui.hasScroll(a)?a.scrollHeight:g;b.parentData={element:a,left:c.left,top:c.top,width:h,height:g}}}},resize:function(b){var a=e(this).data("resizable"),c=a.options,d=a.containerOffset,f=a.position;b=a._aspectRatio||b.shiftKey;var g={top:0,left:0},h=a.containerElement;if(h[0]!=document&&/static/.test(h.css("position")))g=d;if(f.left<(a._helper?d.left:0)){a.size.width+=a._helper?a.position.left-d.left:
|
|
||||||
a.position.left-g.left;if(b)a.size.height=a.size.width/c.aspectRatio;a.position.left=c.helper?d.left:0}if(f.top<(a._helper?d.top:0)){a.size.height+=a._helper?a.position.top-d.top:a.position.top;if(b)a.size.width=a.size.height*c.aspectRatio;a.position.top=a._helper?d.top:0}a.offset.left=a.parentData.left+a.position.left;a.offset.top=a.parentData.top+a.position.top;c=Math.abs((a._helper?a.offset.left-g.left:a.offset.left-g.left)+a.sizeDiff.width);d=Math.abs((a._helper?a.offset.top-g.top:a.offset.top-
|
|
||||||
d.top)+a.sizeDiff.height);f=a.containerElement.get(0)==a.element.parent().get(0);g=/relative|absolute/.test(a.containerElement.css("position"));if(f&&g)c-=a.parentData.left;if(c+a.size.width>=a.parentData.width){a.size.width=a.parentData.width-c;if(b)a.size.height=a.size.width/a.aspectRatio}if(d+a.size.height>=a.parentData.height){a.size.height=a.parentData.height-d;if(b)a.size.width=a.size.height*a.aspectRatio}},stop:function(){var b=e(this).data("resizable"),a=b.options,c=b.containerOffset,d=b.containerPosition,
|
|
||||||
f=b.containerElement,g=e(b.helper),h=g.offset(),i=g.outerWidth()-b.sizeDiff.width;g=g.outerHeight()-b.sizeDiff.height;b._helper&&!a.animate&&/relative/.test(f.css("position"))&&e(this).css({left:h.left-d.left-c.left,width:i,height:g});b._helper&&!a.animate&&/static/.test(f.css("position"))&&e(this).css({left:h.left-d.left-c.left,width:i,height:g})}});e.ui.plugin.add("resizable","ghost",{start:function(){var b=e(this).data("resizable"),a=b.options,c=b.size;b.ghost=b.originalElement.clone();b.ghost.css({opacity:0.25,
|
|
||||||
display:"block",position:"relative",height:c.height,width:c.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof a.ghost=="string"?a.ghost:"");b.ghost.appendTo(b.helper)},resize:function(){var b=e(this).data("resizable");b.ghost&&b.ghost.css({position:"relative",height:b.size.height,width:b.size.width})},stop:function(){var b=e(this).data("resizable");b.ghost&&b.helper&&b.helper.get(0).removeChild(b.ghost.get(0))}});e.ui.plugin.add("resizable","grid",{resize:function(){var b=
|
|
||||||
e(this).data("resizable"),a=b.options,c=b.size,d=b.originalSize,f=b.originalPosition,g=b.axis;a.grid=typeof a.grid=="number"?[a.grid,a.grid]:a.grid;var h=Math.round((c.width-d.width)/(a.grid[0]||1))*(a.grid[0]||1);a=Math.round((c.height-d.height)/(a.grid[1]||1))*(a.grid[1]||1);if(/^(se|s|e)$/.test(g)){b.size.width=d.width+h;b.size.height=d.height+a}else if(/^(ne)$/.test(g)){b.size.width=d.width+h;b.size.height=d.height+a;b.position.top=f.top-a}else{if(/^(sw)$/.test(g)){b.size.width=d.width+h;b.size.height=
|
|
||||||
d.height+a}else{b.size.width=d.width+h;b.size.height=d.height+a;b.position.top=f.top-a}b.position.left=f.left-h}}});var m=function(b){return parseInt(b,10)||0},k=function(b){return!isNaN(parseInt(b,10))}})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Selectable 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Selectables
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.ui.core.js
|
|
||||||
* jquery.ui.mouse.js
|
|
||||||
* jquery.ui.widget.js
|
|
||||||
*/
|
|
||||||
(function(e){e.widget("ui.selectable",e.ui.mouse,{options:{appendTo:"body",autoRefresh:true,distance:0,filter:"*",tolerance:"touch"},_create:function(){var c=this;this.element.addClass("ui-selectable");this.dragged=false;var f;this.refresh=function(){f=e(c.options.filter,c.element[0]);f.each(function(){var d=e(this),b=d.offset();e.data(this,"selectable-item",{element:this,$element:d,left:b.left,top:b.top,right:b.left+d.outerWidth(),bottom:b.top+d.outerHeight(),startselected:false,selected:d.hasClass("ui-selected"),
|
|
||||||
selecting:d.hasClass("ui-selecting"),unselecting:d.hasClass("ui-unselecting")})})};this.refresh();this.selectees=f.addClass("ui-selectee");this._mouseInit();this.helper=e("<div class='ui-selectable-helper'></div>")},destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item");this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable");this._mouseDestroy();return this},_mouseStart:function(c){var f=this;this.opos=[c.pageX,
|
|
||||||
c.pageY];if(!this.options.disabled){var d=this.options;this.selectees=e(d.filter,this.element[0]);this._trigger("start",c);e(d.appendTo).append(this.helper);this.helper.css({left:c.clientX,top:c.clientY,width:0,height:0});d.autoRefresh&&this.refresh();this.selectees.filter(".ui-selected").each(function(){var b=e.data(this,"selectable-item");b.startselected=true;if(!c.metaKey){b.$element.removeClass("ui-selected");b.selected=false;b.$element.addClass("ui-unselecting");b.unselecting=true;f._trigger("unselecting",
|
|
||||||
c,{unselecting:b.element})}});e(c.target).parents().andSelf().each(function(){var b=e.data(this,"selectable-item");if(b){var g=!c.metaKey||!b.$element.hasClass("ui-selected");b.$element.removeClass(g?"ui-unselecting":"ui-selected").addClass(g?"ui-selecting":"ui-unselecting");b.unselecting=!g;b.selecting=g;(b.selected=g)?f._trigger("selecting",c,{selecting:b.element}):f._trigger("unselecting",c,{unselecting:b.element});return false}})}},_mouseDrag:function(c){var f=this;this.dragged=true;if(!this.options.disabled){var d=
|
|
||||||
this.options,b=this.opos[0],g=this.opos[1],h=c.pageX,i=c.pageY;if(b>h){var j=h;h=b;b=j}if(g>i){j=i;i=g;g=j}this.helper.css({left:b,top:g,width:h-b,height:i-g});this.selectees.each(function(){var a=e.data(this,"selectable-item");if(!(!a||a.element==f.element[0])){var k=false;if(d.tolerance=="touch")k=!(a.left>h||a.right<b||a.top>i||a.bottom<g);else if(d.tolerance=="fit")k=a.left>b&&a.right<h&&a.top>g&&a.bottom<i;if(k){if(a.selected){a.$element.removeClass("ui-selected");a.selected=false}if(a.unselecting){a.$element.removeClass("ui-unselecting");
|
|
||||||
a.unselecting=false}if(!a.selecting){a.$element.addClass("ui-selecting");a.selecting=true;f._trigger("selecting",c,{selecting:a.element})}}else{if(a.selecting)if(c.metaKey&&a.startselected){a.$element.removeClass("ui-selecting");a.selecting=false;a.$element.addClass("ui-selected");a.selected=true}else{a.$element.removeClass("ui-selecting");a.selecting=false;if(a.startselected){a.$element.addClass("ui-unselecting");a.unselecting=true}f._trigger("unselecting",c,{unselecting:a.element})}if(a.selected)if(!c.metaKey&&
|
|
||||||
!a.startselected){a.$element.removeClass("ui-selected");a.selected=false;a.$element.addClass("ui-unselecting");a.unselecting=true;f._trigger("unselecting",c,{unselecting:a.element})}}}});return false}},_mouseStop:function(c){var f=this;this.dragged=false;e(".ui-unselecting",this.element[0]).each(function(){var d=e.data(this,"selectable-item");d.$element.removeClass("ui-unselecting");d.unselecting=false;d.startselected=false;f._trigger("unselected",c,{unselected:d.element})});e(".ui-selecting",this.element[0]).each(function(){var d=
|
|
||||||
e.data(this,"selectable-item");d.$element.removeClass("ui-selecting").addClass("ui-selected");d.selecting=false;d.selected=true;d.startselected=true;f._trigger("selected",c,{selected:d.element})});this._trigger("stop",c);this.helper.remove();return false}});e.extend(e.ui.selectable,{version:"1.8.14"})})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Sortable 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Sortables
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.ui.core.js
|
|
||||||
* jquery.ui.mouse.js
|
|
||||||
* jquery.ui.widget.js
|
|
||||||
*/
|
|
||||||
(function(d){d.widget("ui.sortable",d.ui.mouse,{widgetEventPrefix:"sort",options:{appendTo:"parent",axis:false,connectWith:false,containment:false,cursor:"auto",cursorAt:false,dropOnEmpty:true,forcePlaceholderSize:false,forceHelperSize:false,grid:false,handle:false,helper:"original",items:"> *",opacity:false,placeholder:false,revert:false,scroll:true,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1E3},_create:function(){var a=this.options;this.containerCache={};this.element.addClass("ui-sortable");
|
|
||||||
this.refresh();this.floating=this.items.length?a.axis==="x"||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):false;this.offset=this.element.offset();this._mouseInit()},destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").removeData("sortable").unbind(".sortable");this._mouseDestroy();for(var a=this.items.length-1;a>=0;a--)this.items[a].item.removeData("sortable-item");return this},_setOption:function(a,b){if(a===
|
|
||||||
"disabled"){this.options[a]=b;this.widget()[b?"addClass":"removeClass"]("ui-sortable-disabled")}else d.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(a,b){if(this.reverting)return false;if(this.options.disabled||this.options.type=="static")return false;this._refreshItems(a);var c=null,e=this;d(a.target).parents().each(function(){if(d.data(this,"sortable-item")==e){c=d(this);return false}});if(d.data(a.target,"sortable-item")==e)c=d(a.target);if(!c)return false;if(this.options.handle&&
|
|
||||||
!b){var f=false;d(this.options.handle,c).find("*").andSelf().each(function(){if(this==a.target)f=true});if(!f)return false}this.currentItem=c;this._removeCurrentsFromItems();return true},_mouseStart:function(a,b,c){b=this.options;var e=this;this.currentContainer=this;this.refreshPositions();this.helper=this._createHelper(a);this._cacheHelperProportions();this._cacheMargins();this.scrollParent=this.helper.scrollParent();this.offset=this.currentItem.offset();this.offset={top:this.offset.top-this.margins.top,
|
|
||||||
left:this.offset.left-this.margins.left};this.helper.css("position","absolute");this.cssPosition=this.helper.css("position");d.extend(this.offset,{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY=a.pageY;b.cursorAt&&this._adjustOffsetFromHelper(b.cursorAt);this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]};
|
|
||||||
this.helper[0]!=this.currentItem[0]&&this.currentItem.hide();this._createPlaceholder();b.containment&&this._setContainment();if(b.cursor){if(d("body").css("cursor"))this._storedCursor=d("body").css("cursor");d("body").css("cursor",b.cursor)}if(b.opacity){if(this.helper.css("opacity"))this._storedOpacity=this.helper.css("opacity");this.helper.css("opacity",b.opacity)}if(b.zIndex){if(this.helper.css("zIndex"))this._storedZIndex=this.helper.css("zIndex");this.helper.css("zIndex",b.zIndex)}if(this.scrollParent[0]!=
|
|
||||||
document&&this.scrollParent[0].tagName!="HTML")this.overflowOffset=this.scrollParent.offset();this._trigger("start",a,this._uiHash());this._preserveHelperProportions||this._cacheHelperProportions();if(!c)for(c=this.containers.length-1;c>=0;c--)this.containers[c]._trigger("activate",a,e._uiHash(this));if(d.ui.ddmanager)d.ui.ddmanager.current=this;d.ui.ddmanager&&!b.dropBehaviour&&d.ui.ddmanager.prepareOffsets(this,a);this.dragging=true;this.helper.addClass("ui-sortable-helper");this._mouseDrag(a);
|
|
||||||
return true},_mouseDrag:function(a){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute");if(!this.lastPositionAbs)this.lastPositionAbs=this.positionAbs;if(this.options.scroll){var b=this.options,c=false;if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"){if(this.overflowOffset.top+this.scrollParent[0].offsetHeight-a.pageY<b.scrollSensitivity)this.scrollParent[0].scrollTop=c=this.scrollParent[0].scrollTop+b.scrollSpeed;else if(a.pageY-this.overflowOffset.top<
|
|
||||||
b.scrollSensitivity)this.scrollParent[0].scrollTop=c=this.scrollParent[0].scrollTop-b.scrollSpeed;if(this.overflowOffset.left+this.scrollParent[0].offsetWidth-a.pageX<b.scrollSensitivity)this.scrollParent[0].scrollLeft=c=this.scrollParent[0].scrollLeft+b.scrollSpeed;else if(a.pageX-this.overflowOffset.left<b.scrollSensitivity)this.scrollParent[0].scrollLeft=c=this.scrollParent[0].scrollLeft-b.scrollSpeed}else{if(a.pageY-d(document).scrollTop()<b.scrollSensitivity)c=d(document).scrollTop(d(document).scrollTop()-
|
|
||||||
b.scrollSpeed);else if(d(window).height()-(a.pageY-d(document).scrollTop())<b.scrollSensitivity)c=d(document).scrollTop(d(document).scrollTop()+b.scrollSpeed);if(a.pageX-d(document).scrollLeft()<b.scrollSensitivity)c=d(document).scrollLeft(d(document).scrollLeft()-b.scrollSpeed);else if(d(window).width()-(a.pageX-d(document).scrollLeft())<b.scrollSensitivity)c=d(document).scrollLeft(d(document).scrollLeft()+b.scrollSpeed)}c!==false&&d.ui.ddmanager&&!b.dropBehaviour&&d.ui.ddmanager.prepareOffsets(this,
|
|
||||||
a)}this.positionAbs=this._convertPositionTo("absolute");if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";for(b=this.items.length-1;b>=0;b--){c=this.items[b];var e=c.item[0],f=this._intersectsWithPointer(c);if(f)if(e!=this.currentItem[0]&&this.placeholder[f==1?"next":"prev"]()[0]!=e&&!d.ui.contains(this.placeholder[0],e)&&(this.options.type=="semi-dynamic"?!d.ui.contains(this.element[0],
|
|
||||||
e):true)){this.direction=f==1?"down":"up";if(this.options.tolerance=="pointer"||this._intersectsWithSides(c))this._rearrange(a,c);else break;this._trigger("change",a,this._uiHash());break}}this._contactContainers(a);d.ui.ddmanager&&d.ui.ddmanager.drag(this,a);this._trigger("sort",a,this._uiHash());this.lastPositionAbs=this.positionAbs;return false},_mouseStop:function(a,b){if(a){d.ui.ddmanager&&!this.options.dropBehaviour&&d.ui.ddmanager.drop(this,a);if(this.options.revert){var c=this;b=c.placeholder.offset();
|
|
||||||
c.reverting=true;d(this.helper).animate({left:b.left-this.offset.parent.left-c.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:b.top-this.offset.parent.top-c.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){c._clear(a)})}else this._clear(a,b);return false}},cancel:function(){var a=this;if(this.dragging){this._mouseUp({target:null});this.options.helper=="original"?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):
|
|
||||||
this.currentItem.show();for(var b=this.containers.length-1;b>=0;b--){this.containers[b]._trigger("deactivate",null,a._uiHash(this));if(this.containers[b].containerCache.over){this.containers[b]._trigger("out",null,a._uiHash(this));this.containers[b].containerCache.over=0}}}if(this.placeholder){this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]);this.options.helper!="original"&&this.helper&&this.helper[0].parentNode&&this.helper.remove();d.extend(this,{helper:null,
|
|
||||||
dragging:false,reverting:false,_noFinalSort:null});this.domPosition.prev?d(this.domPosition.prev).after(this.currentItem):d(this.domPosition.parent).prepend(this.currentItem)}return this},serialize:function(a){var b=this._getItemsAsjQuery(a&&a.connected),c=[];a=a||{};d(b).each(function(){var e=(d(a.item||this).attr(a.attribute||"id")||"").match(a.expression||/(.+)[-=_](.+)/);if(e)c.push((a.key||e[1]+"[]")+"="+(a.key&&a.expression?e[1]:e[2]))});!c.length&&a.key&&c.push(a.key+"=");return c.join("&")},
|
|
||||||
toArray:function(a){var b=this._getItemsAsjQuery(a&&a.connected),c=[];a=a||{};b.each(function(){c.push(d(a.item||this).attr(a.attribute||"id")||"")});return c},_intersectsWith:function(a){var b=this.positionAbs.left,c=b+this.helperProportions.width,e=this.positionAbs.top,f=e+this.helperProportions.height,g=a.left,h=g+a.width,i=a.top,k=i+a.height,j=this.offset.click.top,l=this.offset.click.left;j=e+j>i&&e+j<k&&b+l>g&&b+l<h;return this.options.tolerance=="pointer"||this.options.forcePointerForContainers||
|
|
||||||
this.options.tolerance!="pointer"&&this.helperProportions[this.floating?"width":"height"]>a[this.floating?"width":"height"]?j:g<b+this.helperProportions.width/2&&c-this.helperProportions.width/2<h&&i<e+this.helperProportions.height/2&&f-this.helperProportions.height/2<k},_intersectsWithPointer:function(a){var b=d.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,a.top,a.height);a=d.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,a.left,a.width);b=b&&a;a=this._getDragVerticalDirection();
|
|
||||||
var c=this._getDragHorizontalDirection();if(!b)return false;return this.floating?c&&c=="right"||a=="down"?2:1:a&&(a=="down"?2:1)},_intersectsWithSides:function(a){var b=d.ui.isOverAxis(this.positionAbs.top+this.offset.click.top,a.top+a.height/2,a.height);a=d.ui.isOverAxis(this.positionAbs.left+this.offset.click.left,a.left+a.width/2,a.width);var c=this._getDragVerticalDirection(),e=this._getDragHorizontalDirection();return this.floating&&e?e=="right"&&a||e=="left"&&!a:c&&(c=="down"&&b||c=="up"&&!b)},
|
|
||||||
_getDragVerticalDirection:function(){var a=this.positionAbs.top-this.lastPositionAbs.top;return a!=0&&(a>0?"down":"up")},_getDragHorizontalDirection:function(){var a=this.positionAbs.left-this.lastPositionAbs.left;return a!=0&&(a>0?"right":"left")},refresh:function(a){this._refreshItems(a);this.refreshPositions();return this},_connectWith:function(){var a=this.options;return a.connectWith.constructor==String?[a.connectWith]:a.connectWith},_getItemsAsjQuery:function(a){var b=[],c=[],e=this._connectWith();
|
|
||||||
if(e&&a)for(a=e.length-1;a>=0;a--)for(var f=d(e[a]),g=f.length-1;g>=0;g--){var h=d.data(f[g],"sortable");if(h&&h!=this&&!h.options.disabled)c.push([d.isFunction(h.options.items)?h.options.items.call(h.element):d(h.options.items,h.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),h])}c.push([d.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):d(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),
|
|
||||||
this]);for(a=c.length-1;a>=0;a--)c[a][0].each(function(){b.push(this)});return d(b)},_removeCurrentsFromItems:function(){for(var a=this.currentItem.find(":data(sortable-item)"),b=0;b<this.items.length;b++)for(var c=0;c<a.length;c++)a[c]==this.items[b].item[0]&&this.items.splice(b,1)},_refreshItems:function(a){this.items=[];this.containers=[this];var b=this.items,c=[[d.isFunction(this.options.items)?this.options.items.call(this.element[0],a,{item:this.currentItem}):d(this.options.items,this.element),
|
|
||||||
this]],e=this._connectWith();if(e)for(var f=e.length-1;f>=0;f--)for(var g=d(e[f]),h=g.length-1;h>=0;h--){var i=d.data(g[h],"sortable");if(i&&i!=this&&!i.options.disabled){c.push([d.isFunction(i.options.items)?i.options.items.call(i.element[0],a,{item:this.currentItem}):d(i.options.items,i.element),i]);this.containers.push(i)}}for(f=c.length-1;f>=0;f--){a=c[f][1];e=c[f][0];h=0;for(g=e.length;h<g;h++){i=d(e[h]);i.data("sortable-item",a);b.push({item:i,instance:a,width:0,height:0,left:0,top:0})}}},refreshPositions:function(a){if(this.offsetParent&&
|
|
||||||
this.helper)this.offset.parent=this._getParentOffset();for(var b=this.items.length-1;b>=0;b--){var c=this.items[b];if(!(c.instance!=this.currentContainer&&this.currentContainer&&c.item[0]!=this.currentItem[0])){var e=this.options.toleranceElement?d(this.options.toleranceElement,c.item):c.item;if(!a){c.width=e.outerWidth();c.height=e.outerHeight()}e=e.offset();c.left=e.left;c.top=e.top}}if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(b=
|
|
||||||
this.containers.length-1;b>=0;b--){e=this.containers[b].element.offset();this.containers[b].containerCache.left=e.left;this.containers[b].containerCache.top=e.top;this.containers[b].containerCache.width=this.containers[b].element.outerWidth();this.containers[b].containerCache.height=this.containers[b].element.outerHeight()}return this},_createPlaceholder:function(a){var b=a||this,c=b.options;if(!c.placeholder||c.placeholder.constructor==String){var e=c.placeholder;c.placeholder={element:function(){var f=
|
|
||||||
d(document.createElement(b.currentItem[0].nodeName)).addClass(e||b.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];if(!e)f.style.visibility="hidden";return f},update:function(f,g){if(!(e&&!c.forcePlaceholderSize)){g.height()||g.height(b.currentItem.innerHeight()-parseInt(b.currentItem.css("paddingTop")||0,10)-parseInt(b.currentItem.css("paddingBottom")||0,10));g.width()||g.width(b.currentItem.innerWidth()-parseInt(b.currentItem.css("paddingLeft")||0,10)-parseInt(b.currentItem.css("paddingRight")||
|
|
||||||
0,10))}}}}b.placeholder=d(c.placeholder.element.call(b.element,b.currentItem));b.currentItem.after(b.placeholder);c.placeholder.update(b,b.placeholder)},_contactContainers:function(a){for(var b=null,c=null,e=this.containers.length-1;e>=0;e--)if(!d.ui.contains(this.currentItem[0],this.containers[e].element[0]))if(this._intersectsWith(this.containers[e].containerCache)){if(!(b&&d.ui.contains(this.containers[e].element[0],b.element[0]))){b=this.containers[e];c=e}}else if(this.containers[e].containerCache.over){this.containers[e]._trigger("out",
|
|
||||||
a,this._uiHash(this));this.containers[e].containerCache.over=0}if(b)if(this.containers.length===1){this.containers[c]._trigger("over",a,this._uiHash(this));this.containers[c].containerCache.over=1}else if(this.currentContainer!=this.containers[c]){b=1E4;e=null;for(var f=this.positionAbs[this.containers[c].floating?"left":"top"],g=this.items.length-1;g>=0;g--)if(d.ui.contains(this.containers[c].element[0],this.items[g].item[0])){var h=this.items[g][this.containers[c].floating?"left":"top"];if(Math.abs(h-
|
|
||||||
f)<b){b=Math.abs(h-f);e=this.items[g]}}if(e||this.options.dropOnEmpty){this.currentContainer=this.containers[c];e?this._rearrange(a,e,null,true):this._rearrange(a,null,this.containers[c].element,true);this._trigger("change",a,this._uiHash());this.containers[c]._trigger("change",a,this._uiHash(this));this.options.placeholder.update(this.currentContainer,this.placeholder);this.containers[c]._trigger("over",a,this._uiHash(this));this.containers[c].containerCache.over=1}}},_createHelper:function(a){var b=
|
|
||||||
this.options;a=d.isFunction(b.helper)?d(b.helper.apply(this.element[0],[a,this.currentItem])):b.helper=="clone"?this.currentItem.clone():this.currentItem;a.parents("body").length||d(b.appendTo!="parent"?b.appendTo:this.currentItem[0].parentNode)[0].appendChild(a[0]);if(a[0]==this.currentItem[0])this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")};if(a[0].style.width==
|
|
||||||
""||b.forceHelperSize)a.width(this.currentItem.width());if(a[0].style.height==""||b.forceHelperSize)a.height(this.currentItem.height());return a},_adjustOffsetFromHelper:function(a){if(typeof a=="string")a=a.split(" ");if(d.isArray(a))a={left:+a[0],top:+a[1]||0};if("left"in a)this.offset.click.left=a.left+this.margins.left;if("right"in a)this.offset.click.left=this.helperProportions.width-a.right+this.margins.left;if("top"in a)this.offset.click.top=a.top+this.margins.top;if("bottom"in a)this.offset.click.top=
|
|
||||||
this.helperProportions.height-a.bottom+this.margins.top},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var a=this.offsetParent.offset();if(this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0])){a.left+=this.scrollParent.scrollLeft();a.top+=this.scrollParent.scrollTop()}if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&d.browser.msie)a=
|
|
||||||
{top:0,left:0};return{top:a.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:a.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var a=this.currentItem.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),
|
|
||||||
10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var a=this.options;if(a.containment=="parent")a.containment=this.helper[0].parentNode;if(a.containment=="document"||a.containment=="window")this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,d(a.containment=="document"?
|
|
||||||
document:window).width()-this.helperProportions.width-this.margins.left,(d(a.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(a.containment)){var b=d(a.containment)[0];a=d(a.containment).offset();var c=d(b).css("overflow")!="hidden";this.containment=[a.left+(parseInt(d(b).css("borderLeftWidth"),10)||0)+(parseInt(d(b).css("paddingLeft"),10)||0)-this.margins.left,a.top+(parseInt(d(b).css("borderTopWidth"),
|
|
||||||
10)||0)+(parseInt(d(b).css("paddingTop"),10)||0)-this.margins.top,a.left+(c?Math.max(b.scrollWidth,b.offsetWidth):b.offsetWidth)-(parseInt(d(b).css("borderLeftWidth"),10)||0)-(parseInt(d(b).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,a.top+(c?Math.max(b.scrollHeight,b.offsetHeight):b.offsetHeight)-(parseInt(d(b).css("borderTopWidth"),10)||0)-(parseInt(d(b).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}},_convertPositionTo:function(a,b){if(!b)b=
|
|
||||||
this.position;a=a=="absolute"?1:-1;var c=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,e=/(html|body)/i.test(c[0].tagName);return{top:b.top+this.offset.relative.top*a+this.offset.parent.top*a-(d.browser.safari&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():e?0:c.scrollTop())*a),left:b.left+this.offset.relative.left*a+this.offset.parent.left*a-(d.browser.safari&&
|
|
||||||
this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():e?0:c.scrollLeft())*a)}},_generatePosition:function(a){var b=this.options,c=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,e=/(html|body)/i.test(c[0].tagName);if(this.cssPosition=="relative"&&!(this.scrollParent[0]!=document&&this.scrollParent[0]!=this.offsetParent[0]))this.offset.relative=this._getRelativeOffset();
|
|
||||||
var f=a.pageX,g=a.pageY;if(this.originalPosition){if(this.containment){if(a.pageX-this.offset.click.left<this.containment[0])f=this.containment[0]+this.offset.click.left;if(a.pageY-this.offset.click.top<this.containment[1])g=this.containment[1]+this.offset.click.top;if(a.pageX-this.offset.click.left>this.containment[2])f=this.containment[2]+this.offset.click.left;if(a.pageY-this.offset.click.top>this.containment[3])g=this.containment[3]+this.offset.click.top}if(b.grid){g=this.originalPageY+Math.round((g-
|
|
||||||
this.originalPageY)/b.grid[1])*b.grid[1];g=this.containment?!(g-this.offset.click.top<this.containment[1]||g-this.offset.click.top>this.containment[3])?g:!(g-this.offset.click.top<this.containment[1])?g-b.grid[1]:g+b.grid[1]:g;f=this.originalPageX+Math.round((f-this.originalPageX)/b.grid[0])*b.grid[0];f=this.containment?!(f-this.offset.click.left<this.containment[0]||f-this.offset.click.left>this.containment[2])?f:!(f-this.offset.click.left<this.containment[0])?f-b.grid[0]:f+b.grid[0]:f}}return{top:g-
|
|
||||||
this.offset.click.top-this.offset.relative.top-this.offset.parent.top+(d.browser.safari&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():e?0:c.scrollTop()),left:f-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(d.browser.safari&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():e?0:c.scrollLeft())}},_rearrange:function(a,b,c,e){c?c[0].appendChild(this.placeholder[0]):b.item[0].parentNode.insertBefore(this.placeholder[0],
|
|
||||||
this.direction=="down"?b.item[0]:b.item[0].nextSibling);this.counter=this.counter?++this.counter:1;var f=this,g=this.counter;window.setTimeout(function(){g==f.counter&&f.refreshPositions(!e)},0)},_clear:function(a,b){this.reverting=false;var c=[];!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem);this._noFinalSort=null;if(this.helper[0]==this.currentItem[0]){for(var e in this._storedCSS)if(this._storedCSS[e]=="auto"||this._storedCSS[e]=="static")this._storedCSS[e]=
|
|
||||||
"";this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();this.fromOutside&&!b&&c.push(function(f){this._trigger("receive",f,this._uiHash(this.fromOutside))});if((this.fromOutside||this.domPosition.prev!=this.currentItem.prev().not(".ui-sortable-helper")[0]||this.domPosition.parent!=this.currentItem.parent()[0])&&!b)c.push(function(f){this._trigger("update",f,this._uiHash())});if(!d.ui.contains(this.element[0],this.currentItem[0])){b||c.push(function(f){this._trigger("remove",
|
|
||||||
f,this._uiHash())});for(e=this.containers.length-1;e>=0;e--)if(d.ui.contains(this.containers[e].element[0],this.currentItem[0])&&!b){c.push(function(f){return function(g){f._trigger("receive",g,this._uiHash(this))}}.call(this,this.containers[e]));c.push(function(f){return function(g){f._trigger("update",g,this._uiHash(this))}}.call(this,this.containers[e]))}}for(e=this.containers.length-1;e>=0;e--){b||c.push(function(f){return function(g){f._trigger("deactivate",g,this._uiHash(this))}}.call(this,
|
|
||||||
this.containers[e]));if(this.containers[e].containerCache.over){c.push(function(f){return function(g){f._trigger("out",g,this._uiHash(this))}}.call(this,this.containers[e]));this.containers[e].containerCache.over=0}}this._storedCursor&&d("body").css("cursor",this._storedCursor);this._storedOpacity&&this.helper.css("opacity",this._storedOpacity);if(this._storedZIndex)this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex);this.dragging=false;if(this.cancelHelperRemoval){if(!b){this._trigger("beforeStop",
|
|
||||||
a,this._uiHash());for(e=0;e<c.length;e++)c[e].call(this,a);this._trigger("stop",a,this._uiHash())}return false}b||this._trigger("beforeStop",a,this._uiHash());this.placeholder[0].parentNode.removeChild(this.placeholder[0]);this.helper[0]!=this.currentItem[0]&&this.helper.remove();this.helper=null;if(!b){for(e=0;e<c.length;e++)c[e].call(this,a);this._trigger("stop",a,this._uiHash())}this.fromOutside=false;return true},_trigger:function(){d.Widget.prototype._trigger.apply(this,arguments)===false&&this.cancel()},
|
|
||||||
_uiHash:function(a){var b=a||this;return{helper:b.helper,placeholder:b.placeholder||d([]),position:b.position,originalPosition:b.originalPosition,offset:b.positionAbs,item:b.currentItem,sender:a?a.element:null}}});d.extend(d.ui.sortable,{version:"1.8.14"})})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Accordion 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Accordion
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.ui.core.js
|
|
||||||
* jquery.ui.widget.js
|
|
||||||
*/
|
|
||||||
(function(c){c.widget("ui.accordion",{options:{active:0,animated:"slide",autoHeight:true,clearStyle:false,collapsible:false,event:"click",fillSpace:false,header:"> li > :first-child,> :not(li):even",icons:{header:"ui-icon-triangle-1-e",headerSelected:"ui-icon-triangle-1-s"},navigation:false,navigationFilter:function(){return this.href.toLowerCase()===location.href.toLowerCase()}},_create:function(){var a=this,b=a.options;a.running=0;a.element.addClass("ui-accordion ui-widget ui-helper-reset").children("li").addClass("ui-accordion-li-fix");
|
|
||||||
a.headers=a.element.find(b.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all").bind("mouseenter.accordion",function(){b.disabled||c(this).addClass("ui-state-hover")}).bind("mouseleave.accordion",function(){b.disabled||c(this).removeClass("ui-state-hover")}).bind("focus.accordion",function(){b.disabled||c(this).addClass("ui-state-focus")}).bind("blur.accordion",function(){b.disabled||c(this).removeClass("ui-state-focus")});a.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom");
|
|
||||||
if(b.navigation){var d=a.element.find("a").filter(b.navigationFilter).eq(0);if(d.length){var h=d.closest(".ui-accordion-header");a.active=h.length?h:d.closest(".ui-accordion-content").prev()}}a.active=a._findActive(a.active||b.active).addClass("ui-state-default ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top");a.active.next().addClass("ui-accordion-content-active");a._createIcons();a.resize();a.element.attr("role","tablist");a.headers.attr("role","tab").bind("keydown.accordion",
|
|
||||||
function(f){return a._keydown(f)}).next().attr("role","tabpanel");a.headers.not(a.active||"").attr({"aria-expanded":"false","aria-selected":"false",tabIndex:-1}).next().hide();a.active.length?a.active.attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}):a.headers.eq(0).attr("tabIndex",0);c.browser.safari||a.headers.find("a").attr("tabIndex",-1);b.event&&a.headers.bind(b.event.split(" ").join(".accordion ")+".accordion",function(f){a._clickHandler.call(a,f,this);f.preventDefault()})},_createIcons:function(){var a=
|
|
||||||
this.options;if(a.icons){c("<span></span>").addClass("ui-icon "+a.icons.header).prependTo(this.headers);this.active.children(".ui-icon").toggleClass(a.icons.header).toggleClass(a.icons.headerSelected);this.element.addClass("ui-accordion-icons")}},_destroyIcons:function(){this.headers.children(".ui-icon").remove();this.element.removeClass("ui-accordion-icons")},destroy:function(){var a=this.options;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role");this.headers.unbind(".accordion").removeClass("ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-selected").removeAttr("tabIndex");
|
|
||||||
this.headers.find("a").removeAttr("tabIndex");this._destroyIcons();var b=this.headers.next().css("display","").removeAttr("role").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled");if(a.autoHeight||a.fillHeight)b.css("height","");return c.Widget.prototype.destroy.call(this)},_setOption:function(a,b){c.Widget.prototype._setOption.apply(this,arguments);a=="active"&&this.activate(b);if(a=="icons"){this._destroyIcons();
|
|
||||||
b&&this._createIcons()}if(a=="disabled")this.headers.add(this.headers.next())[b?"addClass":"removeClass"]("ui-accordion-disabled ui-state-disabled")},_keydown:function(a){if(!(this.options.disabled||a.altKey||a.ctrlKey)){var b=c.ui.keyCode,d=this.headers.length,h=this.headers.index(a.target),f=false;switch(a.keyCode){case b.RIGHT:case b.DOWN:f=this.headers[(h+1)%d];break;case b.LEFT:case b.UP:f=this.headers[(h-1+d)%d];break;case b.SPACE:case b.ENTER:this._clickHandler({target:a.target},a.target);
|
|
||||||
a.preventDefault()}if(f){c(a.target).attr("tabIndex",-1);c(f).attr("tabIndex",0);f.focus();return false}return true}},resize:function(){var a=this.options,b;if(a.fillSpace){if(c.browser.msie){var d=this.element.parent().css("overflow");this.element.parent().css("overflow","hidden")}b=this.element.parent().height();c.browser.msie&&this.element.parent().css("overflow",d);this.headers.each(function(){b-=c(this).outerHeight(true)});this.headers.next().each(function(){c(this).height(Math.max(0,b-c(this).innerHeight()+
|
|
||||||
c(this).height()))}).css("overflow","auto")}else if(a.autoHeight){b=0;this.headers.next().each(function(){b=Math.max(b,c(this).height("").height())}).height(b)}return this},activate:function(a){this.options.active=a;a=this._findActive(a)[0];this._clickHandler({target:a},a);return this},_findActive:function(a){return a?typeof a==="number"?this.headers.filter(":eq("+a+")"):this.headers.not(this.headers.not(a)):a===false?c([]):this.headers.filter(":eq(0)")},_clickHandler:function(a,b){var d=this.options;
|
|
||||||
if(!d.disabled)if(a.target){a=c(a.currentTarget||b);b=a[0]===this.active[0];d.active=d.collapsible&&b?false:this.headers.index(a);if(!(this.running||!d.collapsible&&b)){var h=this.active;j=a.next();g=this.active.next();e={options:d,newHeader:b&&d.collapsible?c([]):a,oldHeader:this.active,newContent:b&&d.collapsible?c([]):j,oldContent:g};var f=this.headers.index(this.active[0])>this.headers.index(a[0]);this.active=b?c([]):a;this._toggle(j,g,e,b,f);h.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(d.icons.headerSelected).addClass(d.icons.header);
|
|
||||||
if(!b){a.removeClass("ui-state-default ui-corner-all").addClass("ui-state-active ui-corner-top").children(".ui-icon").removeClass(d.icons.header).addClass(d.icons.headerSelected);a.next().addClass("ui-accordion-content-active")}}}else if(d.collapsible){this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(d.icons.headerSelected).addClass(d.icons.header);this.active.next().addClass("ui-accordion-content-active");var g=this.active.next(),
|
|
||||||
e={options:d,newHeader:c([]),oldHeader:d.active,newContent:c([]),oldContent:g},j=this.active=c([]);this._toggle(j,g,e)}},_toggle:function(a,b,d,h,f){var g=this,e=g.options;g.toShow=a;g.toHide=b;g.data=d;var j=function(){if(g)return g._completed.apply(g,arguments)};g._trigger("changestart",null,g.data);g.running=b.size()===0?a.size():b.size();if(e.animated){d={};d=e.collapsible&&h?{toShow:c([]),toHide:b,complete:j,down:f,autoHeight:e.autoHeight||e.fillSpace}:{toShow:a,toHide:b,complete:j,down:f,autoHeight:e.autoHeight||
|
|
||||||
e.fillSpace};if(!e.proxied)e.proxied=e.animated;if(!e.proxiedDuration)e.proxiedDuration=e.duration;e.animated=c.isFunction(e.proxied)?e.proxied(d):e.proxied;e.duration=c.isFunction(e.proxiedDuration)?e.proxiedDuration(d):e.proxiedDuration;h=c.ui.accordion.animations;var i=e.duration,k=e.animated;if(k&&!h[k]&&!c.easing[k])k="slide";h[k]||(h[k]=function(l){this.slide(l,{easing:k,duration:i||700})});h[k](d)}else{if(e.collapsible&&h)a.toggle();else{b.hide();a.show()}j(true)}b.prev().attr({"aria-expanded":"false",
|
|
||||||
"aria-selected":"false",tabIndex:-1}).blur();a.prev().attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}).focus()},_completed:function(a){this.running=a?0:--this.running;if(!this.running){this.options.clearStyle&&this.toShow.add(this.toHide).css({height:"",overflow:""});this.toHide.removeClass("ui-accordion-content-active");if(this.toHide.length)this.toHide.parent()[0].className=this.toHide.parent()[0].className;this._trigger("change",null,this.data)}}});c.extend(c.ui.accordion,{version:"1.8.14",
|
|
||||||
animations:{slide:function(a,b){a=c.extend({easing:"swing",duration:300},a,b);if(a.toHide.size())if(a.toShow.size()){var d=a.toShow.css("overflow"),h=0,f={},g={},e;b=a.toShow;e=b[0].style.width;b.width(parseInt(b.parent().width(),10)-parseInt(b.css("paddingLeft"),10)-parseInt(b.css("paddingRight"),10)-(parseInt(b.css("borderLeftWidth"),10)||0)-(parseInt(b.css("borderRightWidth"),10)||0));c.each(["height","paddingTop","paddingBottom"],function(j,i){g[i]="hide";j=(""+c.css(a.toShow[0],i)).match(/^([\d+-.]+)(.*)$/);
|
|
||||||
f[i]={value:j[1],unit:j[2]||"px"}});a.toShow.css({height:0,overflow:"hidden"}).show();a.toHide.filter(":hidden").each(a.complete).end().filter(":visible").animate(g,{step:function(j,i){if(i.prop=="height")h=i.end-i.start===0?0:(i.now-i.start)/(i.end-i.start);a.toShow[0].style[i.prop]=h*f[i.prop].value+f[i.prop].unit},duration:a.duration,easing:a.easing,complete:function(){a.autoHeight||a.toShow.css("height","");a.toShow.css({width:e,overflow:d});a.complete()}})}else a.toHide.animate({height:"hide",
|
|
||||||
paddingTop:"hide",paddingBottom:"hide"},a);else a.toShow.animate({height:"show",paddingTop:"show",paddingBottom:"show"},a)},bounceslide:function(a){this.slide(a,{easing:a.down?"easeOutBounce":"swing",duration:a.down?1E3:200})}}})})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Autocomplete 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Autocomplete
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.ui.core.js
|
|
||||||
* jquery.ui.widget.js
|
|
||||||
* jquery.ui.position.js
|
|
||||||
*/
|
|
||||||
(function(d){var e=0;d.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:false,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var a=this,b=this.element[0].ownerDocument,g;this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(c){if(!(a.options.disabled||a.element.attr("readonly"))){g=
|
|
||||||
false;var f=d.ui.keyCode;switch(c.keyCode){case f.PAGE_UP:a._move("previousPage",c);break;case f.PAGE_DOWN:a._move("nextPage",c);break;case f.UP:a._move("previous",c);c.preventDefault();break;case f.DOWN:a._move("next",c);c.preventDefault();break;case f.ENTER:case f.NUMPAD_ENTER:if(a.menu.active){g=true;c.preventDefault()}case f.TAB:if(!a.menu.active)return;a.menu.select(c);break;case f.ESCAPE:a.element.val(a.term);a.close(c);break;default:clearTimeout(a.searching);a.searching=setTimeout(function(){if(a.term!=
|
|
||||||
a.element.val()){a.selectedItem=null;a.search(null,c)}},a.options.delay);break}}}).bind("keypress.autocomplete",function(c){if(g){g=false;c.preventDefault()}}).bind("focus.autocomplete",function(){if(!a.options.disabled){a.selectedItem=null;a.previous=a.element.val()}}).bind("blur.autocomplete",function(c){if(!a.options.disabled){clearTimeout(a.searching);a.closing=setTimeout(function(){a.close(c);a._change(c)},150)}});this._initSource();this.response=function(){return a._response.apply(a,arguments)};
|
|
||||||
this.menu=d("<ul></ul>").addClass("ui-autocomplete").appendTo(d(this.options.appendTo||"body",b)[0]).mousedown(function(c){var f=a.menu.element[0];d(c.target).closest(".ui-menu-item").length||setTimeout(function(){d(document).one("mousedown",function(h){h.target!==a.element[0]&&h.target!==f&&!d.ui.contains(f,h.target)&&a.close()})},1);setTimeout(function(){clearTimeout(a.closing)},13)}).menu({focus:function(c,f){f=f.item.data("item.autocomplete");false!==a._trigger("focus",c,{item:f})&&/^key/.test(c.originalEvent.type)&&
|
|
||||||
a.element.val(f.value)},selected:function(c,f){var h=f.item.data("item.autocomplete"),i=a.previous;if(a.element[0]!==b.activeElement){a.element.focus();a.previous=i;setTimeout(function(){a.previous=i;a.selectedItem=h},1)}false!==a._trigger("select",c,{item:h})&&a.element.val(h.value);a.term=a.element.val();a.close(c);a.selectedItem=h},blur:function(){a.menu.element.is(":visible")&&a.element.val()!==a.term&&a.element.val(a.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu");
|
|
||||||
d.fn.bgiframe&&this.menu.element.bgiframe()},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup");this.menu.element.remove();d.Widget.prototype.destroy.call(this)},_setOption:function(a,b){d.Widget.prototype._setOption.apply(this,arguments);a==="source"&&this._initSource();if(a==="appendTo")this.menu.element.appendTo(d(b||"body",this.element[0].ownerDocument)[0]);a==="disabled"&&
|
|
||||||
b&&this.xhr&&this.xhr.abort()},_initSource:function(){var a=this,b,g;if(d.isArray(this.options.source)){b=this.options.source;this.source=function(c,f){f(d.ui.autocomplete.filter(b,c.term))}}else if(typeof this.options.source==="string"){g=this.options.source;this.source=function(c,f){a.xhr&&a.xhr.abort();a.xhr=d.ajax({url:g,data:c,dataType:"json",autocompleteRequest:++e,success:function(h){this.autocompleteRequest===e&&f(h)},error:function(){this.autocompleteRequest===e&&f([])}})}}else this.source=
|
|
||||||
this.options.source},search:function(a,b){a=a!=null?a:this.element.val();this.term=this.element.val();if(a.length<this.options.minLength)return this.close(b);clearTimeout(this.closing);if(this._trigger("search",b)!==false)return this._search(a)},_search:function(a){this.pending++;this.element.addClass("ui-autocomplete-loading");this.source({term:a},this.response)},_response:function(a){if(!this.options.disabled&&a&&a.length){a=this._normalize(a);this._suggest(a);this._trigger("open")}else this.close();
|
|
||||||
this.pending--;this.pending||this.element.removeClass("ui-autocomplete-loading")},close:function(a){clearTimeout(this.closing);if(this.menu.element.is(":visible")){this.menu.element.hide();this.menu.deactivate();this._trigger("close",a)}},_change:function(a){this.previous!==this.element.val()&&this._trigger("change",a,{item:this.selectedItem})},_normalize:function(a){if(a.length&&a[0].label&&a[0].value)return a;return d.map(a,function(b){if(typeof b==="string")return{label:b,value:b};return d.extend({label:b.label||
|
|
||||||
b.value,value:b.value||b.label},b)})},_suggest:function(a){var b=this.menu.element.empty().zIndex(this.element.zIndex()+1);this._renderMenu(b,a);this.menu.deactivate();this.menu.refresh();b.show();this._resizeMenu();b.position(d.extend({of:this.element},this.options.position));this.options.autoFocus&&this.menu.next(new d.Event("mouseover"))},_resizeMenu:function(){var a=this.menu.element;a.outerWidth(Math.max(a.width("").outerWidth(),this.element.outerWidth()))},_renderMenu:function(a,b){var g=this;
|
|
||||||
d.each(b,function(c,f){g._renderItem(a,f)})},_renderItem:function(a,b){return d("<li></li>").data("item.autocomplete",b).append(d("<a></a>").text(b.label)).appendTo(a)},_move:function(a,b){if(this.menu.element.is(":visible"))if(this.menu.first()&&/^previous/.test(a)||this.menu.last()&&/^next/.test(a)){this.element.val(this.term);this.menu.deactivate()}else this.menu[a](b);else this.search(null,b)},widget:function(){return this.menu.element}});d.extend(d.ui.autocomplete,{escapeRegex:function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,
|
|
||||||
"\\$&")},filter:function(a,b){var g=new RegExp(d.ui.autocomplete.escapeRegex(b),"i");return d.grep(a,function(c){return g.test(c.label||c.value||c)})}})})(jQuery);
|
|
||||||
(function(d){d.widget("ui.menu",{_create:function(){var e=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(a){if(d(a.target).closest(".ui-menu-item a").length){a.preventDefault();e.select(a)}});this.refresh()},refresh:function(){var e=this;this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem").children("a").addClass("ui-corner-all").attr("tabindex",
|
|
||||||
-1).mouseenter(function(a){e.activate(a,d(this).parent())}).mouseleave(function(){e.deactivate()})},activate:function(e,a){this.deactivate();if(this.hasScroll()){var b=a.offset().top-this.element.offset().top,g=this.element.scrollTop(),c=this.element.height();if(b<0)this.element.scrollTop(g+b);else b>=c&&this.element.scrollTop(g+b-c+a.height())}this.active=a.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end();this._trigger("focus",e,{item:a})},deactivate:function(){if(this.active){this.active.children("a").removeClass("ui-state-hover").removeAttr("id");
|
|
||||||
this._trigger("blur");this.active=null}},next:function(e){this.move("next",".ui-menu-item:first",e)},previous:function(e){this.move("prev",".ui-menu-item:last",e)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(e,a,b){if(this.active){e=this.active[e+"All"](".ui-menu-item").eq(0);e.length?this.activate(b,e):this.activate(b,this.element.children(a))}else this.activate(b,
|
|
||||||
this.element.children(a))},nextPage:function(e){if(this.hasScroll())if(!this.active||this.last())this.activate(e,this.element.children(".ui-menu-item:first"));else{var a=this.active.offset().top,b=this.element.height(),g=this.element.children(".ui-menu-item").filter(function(){var c=d(this).offset().top-a-b+d(this).height();return c<10&&c>-10});g.length||(g=this.element.children(".ui-menu-item:last"));this.activate(e,g)}else this.activate(e,this.element.children(".ui-menu-item").filter(!this.active||
|
|
||||||
this.last()?":first":":last"))},previousPage:function(e){if(this.hasScroll())if(!this.active||this.first())this.activate(e,this.element.children(".ui-menu-item:last"));else{var a=this.active.offset().top,b=this.element.height();result=this.element.children(".ui-menu-item").filter(function(){var g=d(this).offset().top-a+b-d(this).height();return g<10&&g>-10});result.length||(result=this.element.children(".ui-menu-item:first"));this.activate(e,result)}else this.activate(e,this.element.children(".ui-menu-item").filter(!this.active||
|
|
||||||
this.first()?":last":":first"))},hasScroll:function(){return this.element.height()<this.element[d.fn.prop?"prop":"attr"]("scrollHeight")},select:function(e){this._trigger("selected",e,{item:this.active})}})})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Button 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Button
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.ui.core.js
|
|
||||||
* jquery.ui.widget.js
|
|
||||||
*/
|
|
||||||
(function(b){var h,i,j,g,l=function(){var a=b(this).find(":ui-button");setTimeout(function(){a.button("refresh")},1)},k=function(a){var c=a.name,e=a.form,f=b([]);if(c)f=e?b(e).find("[name='"+c+"']"):b("[name='"+c+"']",a.ownerDocument).filter(function(){return!this.form});return f};b.widget("ui.button",{options:{disabled:null,text:true,label:null,icons:{primary:null,secondary:null}},_create:function(){this.element.closest("form").unbind("reset.button").bind("reset.button",l);if(typeof this.options.disabled!==
|
|
||||||
"boolean")this.options.disabled=this.element.attr("disabled");this._determineButtonType();this.hasTitle=!!this.buttonElement.attr("title");var a=this,c=this.options,e=this.type==="checkbox"||this.type==="radio",f="ui-state-hover"+(!e?" ui-state-active":"");if(c.label===null)c.label=this.buttonElement.html();if(this.element.is(":disabled"))c.disabled=true;this.buttonElement.addClass("ui-button ui-widget ui-state-default ui-corner-all").attr("role","button").bind("mouseenter.button",function(){if(!c.disabled){b(this).addClass("ui-state-hover");
|
|
||||||
this===h&&b(this).addClass("ui-state-active")}}).bind("mouseleave.button",function(){c.disabled||b(this).removeClass(f)}).bind("click.button",function(d){if(c.disabled){d.preventDefault();d.stopImmediatePropagation()}});this.element.bind("focus.button",function(){a.buttonElement.addClass("ui-state-focus")}).bind("blur.button",function(){a.buttonElement.removeClass("ui-state-focus")});if(e){this.element.bind("change.button",function(){g||a.refresh()});this.buttonElement.bind("mousedown.button",function(d){if(!c.disabled){g=
|
|
||||||
false;i=d.pageX;j=d.pageY}}).bind("mouseup.button",function(d){if(!c.disabled)if(i!==d.pageX||j!==d.pageY)g=true})}if(this.type==="checkbox")this.buttonElement.bind("click.button",function(){if(c.disabled||g)return false;b(this).toggleClass("ui-state-active");a.buttonElement.attr("aria-pressed",a.element[0].checked)});else if(this.type==="radio")this.buttonElement.bind("click.button",function(){if(c.disabled||g)return false;b(this).addClass("ui-state-active");a.buttonElement.attr("aria-pressed",true);
|
|
||||||
var d=a.element[0];k(d).not(d).map(function(){return b(this).button("widget")[0]}).removeClass("ui-state-active").attr("aria-pressed",false)});else{this.buttonElement.bind("mousedown.button",function(){if(c.disabled)return false;b(this).addClass("ui-state-active");h=this;b(document).one("mouseup",function(){h=null})}).bind("mouseup.button",function(){if(c.disabled)return false;b(this).removeClass("ui-state-active")}).bind("keydown.button",function(d){if(c.disabled)return false;if(d.keyCode==b.ui.keyCode.SPACE||
|
|
||||||
d.keyCode==b.ui.keyCode.ENTER)b(this).addClass("ui-state-active")}).bind("keyup.button",function(){b(this).removeClass("ui-state-active")});this.buttonElement.is("a")&&this.buttonElement.keyup(function(d){d.keyCode===b.ui.keyCode.SPACE&&b(this).click()})}this._setOption("disabled",c.disabled);this._resetButton()},_determineButtonType:function(){this.type=this.element.is(":checkbox")?"checkbox":this.element.is(":radio")?"radio":this.element.is("input")?"input":"button";if(this.type==="checkbox"||this.type===
|
|
||||||
"radio"){var a=this.element.parents().filter(":last"),c="label[for="+this.element.attr("id")+"]";this.buttonElement=a.find(c);if(!this.buttonElement.length){a=a.length?a.siblings():this.element.siblings();this.buttonElement=a.filter(c);if(!this.buttonElement.length)this.buttonElement=a.find(c)}this.element.addClass("ui-helper-hidden-accessible");(a=this.element.is(":checked"))&&this.buttonElement.addClass("ui-state-active");this.buttonElement.attr("aria-pressed",a)}else this.buttonElement=this.element},
|
|
||||||
widget:function(){return this.buttonElement},destroy:function(){this.element.removeClass("ui-helper-hidden-accessible");this.buttonElement.removeClass("ui-button ui-widget ui-state-default ui-corner-all ui-state-hover ui-state-active ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only").removeAttr("role").removeAttr("aria-pressed").html(this.buttonElement.find(".ui-button-text").html());this.hasTitle||this.buttonElement.removeAttr("title");
|
|
||||||
b.Widget.prototype.destroy.call(this)},_setOption:function(a,c){b.Widget.prototype._setOption.apply(this,arguments);if(a==="disabled")c?this.element.attr("disabled",true):this.element.removeAttr("disabled");else this._resetButton()},refresh:function(){var a=this.element.is(":disabled");a!==this.options.disabled&&this._setOption("disabled",a);if(this.type==="radio")k(this.element[0]).each(function(){b(this).is(":checked")?b(this).button("widget").addClass("ui-state-active").attr("aria-pressed",true):
|
|
||||||
b(this).button("widget").removeClass("ui-state-active").attr("aria-pressed",false)});else if(this.type==="checkbox")this.element.is(":checked")?this.buttonElement.addClass("ui-state-active").attr("aria-pressed",true):this.buttonElement.removeClass("ui-state-active").attr("aria-pressed",false)},_resetButton:function(){if(this.type==="input")this.options.label&&this.element.val(this.options.label);else{var a=this.buttonElement.removeClass("ui-button-icons-only ui-button-icon-only ui-button-text-icons ui-button-text-icon-primary ui-button-text-icon-secondary ui-button-text-only"),
|
|
||||||
c=b("<span></span>").addClass("ui-button-text").html(this.options.label).appendTo(a.empty()).text(),e=this.options.icons,f=e.primary&&e.secondary,d=[];if(e.primary||e.secondary){if(this.options.text)d.push("ui-button-text-icon"+(f?"s":e.primary?"-primary":"-secondary"));e.primary&&a.prepend("<span class='ui-button-icon-primary ui-icon "+e.primary+"'></span>");e.secondary&&a.append("<span class='ui-button-icon-secondary ui-icon "+e.secondary+"'></span>");if(!this.options.text){d.push(f?"ui-button-icons-only":
|
|
||||||
"ui-button-icon-only");this.hasTitle||a.attr("title",c)}}else d.push("ui-button-text-only");a.addClass(d.join(" "))}}});b.widget("ui.buttonset",{options:{items:":button, :submit, :reset, :checkbox, :radio, a, :data(button)"},_create:function(){this.element.addClass("ui-buttonset")},_init:function(){this.refresh()},_setOption:function(a,c){a==="disabled"&&this.buttons.button("option",a,c);b.Widget.prototype._setOption.apply(this,arguments)},refresh:function(){var a=this.element.css("direction")===
|
|
||||||
"ltr";this.buttons=this.element.find(this.options.items).filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function(){return b(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass(a?"ui-corner-left":"ui-corner-right").end().filter(":last").addClass(a?"ui-corner-right":"ui-corner-left").end().end()},destroy:function(){this.element.removeClass("ui-buttonset");this.buttons.map(function(){return b(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy");
|
|
||||||
b.Widget.prototype.destroy.call(this)}})})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Dialog 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Dialog
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.ui.core.js
|
|
||||||
* jquery.ui.widget.js
|
|
||||||
* jquery.ui.button.js
|
|
||||||
* jquery.ui.draggable.js
|
|
||||||
* jquery.ui.mouse.js
|
|
||||||
* jquery.ui.position.js
|
|
||||||
* jquery.ui.resizable.js
|
|
||||||
*/
|
|
||||||
(function(c,l){var m={buttons:true,height:true,maxHeight:true,maxWidth:true,minHeight:true,minWidth:true,width:true},n={maxHeight:true,maxWidth:true,minHeight:true,minWidth:true},o=c.attrFn||{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true,click:true};c.widget("ui.dialog",{options:{autoOpen:true,buttons:{},closeOnEscape:true,closeText:"close",dialogClass:"",draggable:true,hide:null,height:"auto",maxHeight:false,maxWidth:false,minHeight:150,minWidth:150,modal:false,
|
|
||||||
position:{my:"center",at:"center",collision:"fit",using:function(a){var b=c(this).css(a).offset().top;b<0&&c(this).css("top",a.top-b)}},resizable:true,show:null,stack:true,title:"",width:300,zIndex:1E3},_create:function(){this.originalTitle=this.element.attr("title");if(typeof this.originalTitle!=="string")this.originalTitle="";this.options.title=this.options.title||this.originalTitle;var a=this,b=a.options,d=b.title||" ",e=c.ui.dialog.getTitleId(a.element),g=(a.uiDialog=c("<div></div>")).appendTo(document.body).hide().addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+
|
|
||||||
b.dialogClass).css({zIndex:b.zIndex}).attr("tabIndex",-1).css("outline",0).keydown(function(i){if(b.closeOnEscape&&i.keyCode&&i.keyCode===c.ui.keyCode.ESCAPE){a.close(i);i.preventDefault()}}).attr({role:"dialog","aria-labelledby":e}).mousedown(function(i){a.moveToTop(false,i)});a.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(g);var f=(a.uiDialogTitlebar=c("<div></div>")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(g),
|
|
||||||
h=c('<a href="#"></a>').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").hover(function(){h.addClass("ui-state-hover")},function(){h.removeClass("ui-state-hover")}).focus(function(){h.addClass("ui-state-focus")}).blur(function(){h.removeClass("ui-state-focus")}).click(function(i){a.close(i);return false}).appendTo(f);(a.uiDialogTitlebarCloseText=c("<span></span>")).addClass("ui-icon ui-icon-closethick").text(b.closeText).appendTo(h);c("<span></span>").addClass("ui-dialog-title").attr("id",
|
|
||||||
e).html(d).prependTo(f);if(c.isFunction(b.beforeclose)&&!c.isFunction(b.beforeClose))b.beforeClose=b.beforeclose;f.find("*").add(f).disableSelection();b.draggable&&c.fn.draggable&&a._makeDraggable();b.resizable&&c.fn.resizable&&a._makeResizable();a._createButtons(b.buttons);a._isOpen=false;c.fn.bgiframe&&g.bgiframe()},_init:function(){this.options.autoOpen&&this.open()},destroy:function(){var a=this;a.overlay&&a.overlay.destroy();a.uiDialog.hide();a.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body");
|
|
||||||
a.uiDialog.remove();a.originalTitle&&a.element.attr("title",a.originalTitle);return a},widget:function(){return this.uiDialog},close:function(a){var b=this,d,e;if(false!==b._trigger("beforeClose",a)){b.overlay&&b.overlay.destroy();b.uiDialog.unbind("keypress.ui-dialog");b._isOpen=false;if(b.options.hide)b.uiDialog.hide(b.options.hide,function(){b._trigger("close",a)});else{b.uiDialog.hide();b._trigger("close",a)}c.ui.dialog.overlay.resize();if(b.options.modal){d=0;c(".ui-dialog").each(function(){if(this!==
|
|
||||||
b.uiDialog[0]){e=c(this).css("z-index");isNaN(e)||(d=Math.max(d,e))}});c.ui.dialog.maxZ=d}return b}},isOpen:function(){return this._isOpen},moveToTop:function(a,b){var d=this,e=d.options;if(e.modal&&!a||!e.stack&&!e.modal)return d._trigger("focus",b);if(e.zIndex>c.ui.dialog.maxZ)c.ui.dialog.maxZ=e.zIndex;if(d.overlay){c.ui.dialog.maxZ+=1;d.overlay.$el.css("z-index",c.ui.dialog.overlay.maxZ=c.ui.dialog.maxZ)}a={scrollTop:d.element.attr("scrollTop"),scrollLeft:d.element.attr("scrollLeft")};c.ui.dialog.maxZ+=
|
|
||||||
1;d.uiDialog.css("z-index",c.ui.dialog.maxZ);d.element.attr(a);d._trigger("focus",b);return d},open:function(){if(!this._isOpen){var a=this,b=a.options,d=a.uiDialog;a.overlay=b.modal?new c.ui.dialog.overlay(a):null;a._size();a._position(b.position);d.show(b.show);a.moveToTop(true);b.modal&&d.bind("keypress.ui-dialog",function(e){if(e.keyCode===c.ui.keyCode.TAB){var g=c(":tabbable",this),f=g.filter(":first");g=g.filter(":last");if(e.target===g[0]&&!e.shiftKey){f.focus(1);return false}else if(e.target===
|
|
||||||
f[0]&&e.shiftKey){g.focus(1);return false}}});c(a.element.find(":tabbable").get().concat(d.find(".ui-dialog-buttonpane :tabbable").get().concat(d.get()))).eq(0).focus();a._isOpen=true;a._trigger("open");return a}},_createButtons:function(a){var b=this,d=false,e=c("<div></div>").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),g=c("<div></div>").addClass("ui-dialog-buttonset").appendTo(e);b.uiDialog.find(".ui-dialog-buttonpane").remove();typeof a==="object"&&a!==null&&c.each(a,
|
|
||||||
function(){return!(d=true)});if(d){c.each(a,function(f,h){h=c.isFunction(h)?{click:h,text:f}:h;var i=c('<button type="button"></button>').click(function(){h.click.apply(b.element[0],arguments)}).appendTo(g);c.each(h,function(j,k){if(j!=="click")j in o?i[j](k):i.attr(j,k)});c.fn.button&&i.button()});e.appendTo(b.uiDialog)}},_makeDraggable:function(){function a(f){return{position:f.position,offset:f.offset}}var b=this,d=b.options,e=c(document),g;b.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close",
|
|
||||||
handle:".ui-dialog-titlebar",containment:"document",start:function(f,h){g=d.height==="auto"?"auto":c(this).height();c(this).height(c(this).height()).addClass("ui-dialog-dragging");b._trigger("dragStart",f,a(h))},drag:function(f,h){b._trigger("drag",f,a(h))},stop:function(f,h){d.position=[h.position.left-e.scrollLeft(),h.position.top-e.scrollTop()];c(this).removeClass("ui-dialog-dragging").height(g);b._trigger("dragStop",f,a(h));c.ui.dialog.overlay.resize()}})},_makeResizable:function(a){function b(f){return{originalPosition:f.originalPosition,
|
|
||||||
originalSize:f.originalSize,position:f.position,size:f.size}}a=a===l?this.options.resizable:a;var d=this,e=d.options,g=d.uiDialog.css("position");a=typeof a==="string"?a:"n,e,s,w,se,sw,ne,nw";d.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:d.element,maxWidth:e.maxWidth,maxHeight:e.maxHeight,minWidth:e.minWidth,minHeight:d._minHeight(),handles:a,start:function(f,h){c(this).addClass("ui-dialog-resizing");d._trigger("resizeStart",f,b(h))},resize:function(f,h){d._trigger("resize",
|
|
||||||
f,b(h))},stop:function(f,h){c(this).removeClass("ui-dialog-resizing");e.height=c(this).height();e.width=c(this).width();d._trigger("resizeStop",f,b(h));c.ui.dialog.overlay.resize()}}).css("position",g).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var a=this.options;return a.height==="auto"?a.minHeight:Math.min(a.minHeight,a.height)},_position:function(a){var b=[],d=[0,0],e;if(a){if(typeof a==="string"||typeof a==="object"&&"0"in a){b=a.split?a.split(" "):
|
|
||||||
[a[0],a[1]];if(b.length===1)b[1]=b[0];c.each(["left","top"],function(g,f){if(+b[g]===b[g]){d[g]=b[g];b[g]=f}});a={my:b.join(" "),at:b.join(" "),offset:d.join(" ")}}a=c.extend({},c.ui.dialog.prototype.options.position,a)}else a=c.ui.dialog.prototype.options.position;(e=this.uiDialog.is(":visible"))||this.uiDialog.show();this.uiDialog.css({top:0,left:0}).position(c.extend({of:window},a));e||this.uiDialog.hide()},_setOptions:function(a){var b=this,d={},e=false;c.each(a,function(g,f){b._setOption(g,f);
|
|
||||||
if(g in m)e=true;if(g in n)d[g]=f});e&&this._size();this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",d)},_setOption:function(a,b){var d=this,e=d.uiDialog;switch(a){case "beforeclose":a="beforeClose";break;case "buttons":d._createButtons(b);break;case "closeText":d.uiDialogTitlebarCloseText.text(""+b);break;case "dialogClass":e.removeClass(d.options.dialogClass).addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+b);break;case "disabled":b?e.addClass("ui-dialog-disabled"):
|
|
||||||
e.removeClass("ui-dialog-disabled");break;case "draggable":var g=e.is(":data(draggable)");g&&!b&&e.draggable("destroy");!g&&b&&d._makeDraggable();break;case "position":d._position(b);break;case "resizable":(g=e.is(":data(resizable)"))&&!b&&e.resizable("destroy");g&&typeof b==="string"&&e.resizable("option","handles",b);!g&&b!==false&&d._makeResizable(b);break;case "title":c(".ui-dialog-title",d.uiDialogTitlebar).html(""+(b||" "));break}c.Widget.prototype._setOption.apply(d,arguments)},_size:function(){var a=
|
|
||||||
this.options,b,d,e=this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0});if(a.minWidth>a.width)a.width=a.minWidth;b=this.uiDialog.css({height:"auto",width:a.width}).height();d=Math.max(0,a.minHeight-b);if(a.height==="auto")if(c.support.minHeight)this.element.css({minHeight:d,height:"auto"});else{this.uiDialog.show();a=this.element.css("height","auto").height();e||this.uiDialog.hide();this.element.height(Math.max(a,d))}else this.element.height(Math.max(a.height-
|
|
||||||
b,0));this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())}});c.extend(c.ui.dialog,{version:"1.8.14",uuid:0,maxZ:0,getTitleId:function(a){a=a.attr("id");if(!a){this.uuid+=1;a=this.uuid}return"ui-dialog-title-"+a},overlay:function(a){this.$el=c.ui.dialog.overlay.create(a)}});c.extend(c.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:c.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(a){return a+".dialog-overlay"}).join(" "),
|
|
||||||
create:function(a){if(this.instances.length===0){setTimeout(function(){c.ui.dialog.overlay.instances.length&&c(document).bind(c.ui.dialog.overlay.events,function(d){if(c(d.target).zIndex()<c.ui.dialog.overlay.maxZ)return false})},1);c(document).bind("keydown.dialog-overlay",function(d){if(a.options.closeOnEscape&&d.keyCode&&d.keyCode===c.ui.keyCode.ESCAPE){a.close(d);d.preventDefault()}});c(window).bind("resize.dialog-overlay",c.ui.dialog.overlay.resize)}var b=(this.oldInstances.pop()||c("<div></div>").addClass("ui-widget-overlay")).appendTo(document.body).css({width:this.width(),
|
|
||||||
height:this.height()});c.fn.bgiframe&&b.bgiframe();this.instances.push(b);return b},destroy:function(a){var b=c.inArray(a,this.instances);b!=-1&&this.oldInstances.push(this.instances.splice(b,1)[0]);this.instances.length===0&&c([document,window]).unbind(".dialog-overlay");a.remove();var d=0;c.each(this.instances,function(){d=Math.max(d,this.css("z-index"))});this.maxZ=d},height:function(){var a,b;if(c.browser.msie&&c.browser.version<7){a=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);
|
|
||||||
b=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight);return a<b?c(window).height()+"px":a+"px"}else return c(document).height()+"px"},width:function(){var a,b;if(c.browser.msie){a=Math.max(document.documentElement.scrollWidth,document.body.scrollWidth);b=Math.max(document.documentElement.offsetWidth,document.body.offsetWidth);return a<b?c(window).width()+"px":a+"px"}else return c(document).width()+"px"},resize:function(){var a=c([]);c.each(c.ui.dialog.overlay.instances,function(){a=
|
|
||||||
a.add(this)});a.css({width:0,height:0}).css({width:c.ui.dialog.overlay.width(),height:c.ui.dialog.overlay.height()})}});c.extend(c.ui.dialog.overlay.prototype,{destroy:function(){c.ui.dialog.overlay.destroy(this.$el)}})})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Slider 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Slider
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.ui.core.js
|
|
||||||
* jquery.ui.mouse.js
|
|
||||||
* jquery.ui.widget.js
|
|
||||||
*/
|
|
||||||
(function(d){d.widget("ui.slider",d.ui.mouse,{widgetEventPrefix:"slide",options:{animate:false,distance:0,max:100,min:0,orientation:"horizontal",range:false,step:1,value:0,values:null},_create:function(){var b=this,a=this.options,c=this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),f=a.values&&a.values.length||1,e=[];this._mouseSliding=this._keySliding=false;this._animateOff=true;this._handleIndex=null;this._detectOrientation();this._mouseInit();this.element.addClass("ui-slider ui-slider-"+
|
|
||||||
this.orientation+" ui-widget ui-widget-content ui-corner-all"+(a.disabled?" ui-slider-disabled ui-disabled":""));this.range=d([]);if(a.range){if(a.range===true){if(!a.values)a.values=[this._valueMin(),this._valueMin()];if(a.values.length&&a.values.length!==2)a.values=[a.values[0],a.values[0]]}this.range=d("<div></div>").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(a.range==="min"||a.range==="max"?" ui-slider-range-"+a.range:""))}for(var j=c.length;j<f;j+=1)e.push("<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>");
|
|
||||||
this.handles=c.add(d(e.join("")).appendTo(b.element));this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(g){g.preventDefault()}).hover(function(){a.disabled||d(this).addClass("ui-state-hover")},function(){d(this).removeClass("ui-state-hover")}).focus(function(){if(a.disabled)d(this).blur();else{d(".ui-slider .ui-state-focus").removeClass("ui-state-focus");d(this).addClass("ui-state-focus")}}).blur(function(){d(this).removeClass("ui-state-focus")});this.handles.each(function(g){d(this).data("index.ui-slider-handle",
|
|
||||||
g)});this.handles.keydown(function(g){var k=true,l=d(this).data("index.ui-slider-handle"),i,h,m;if(!b.options.disabled){switch(g.keyCode){case d.ui.keyCode.HOME:case d.ui.keyCode.END:case d.ui.keyCode.PAGE_UP:case d.ui.keyCode.PAGE_DOWN:case d.ui.keyCode.UP:case d.ui.keyCode.RIGHT:case d.ui.keyCode.DOWN:case d.ui.keyCode.LEFT:k=false;if(!b._keySliding){b._keySliding=true;d(this).addClass("ui-state-active");i=b._start(g,l);if(i===false)return}break}m=b.options.step;i=b.options.values&&b.options.values.length?
|
|
||||||
(h=b.values(l)):(h=b.value());switch(g.keyCode){case d.ui.keyCode.HOME:h=b._valueMin();break;case d.ui.keyCode.END:h=b._valueMax();break;case d.ui.keyCode.PAGE_UP:h=b._trimAlignValue(i+(b._valueMax()-b._valueMin())/5);break;case d.ui.keyCode.PAGE_DOWN:h=b._trimAlignValue(i-(b._valueMax()-b._valueMin())/5);break;case d.ui.keyCode.UP:case d.ui.keyCode.RIGHT:if(i===b._valueMax())return;h=b._trimAlignValue(i+m);break;case d.ui.keyCode.DOWN:case d.ui.keyCode.LEFT:if(i===b._valueMin())return;h=b._trimAlignValue(i-
|
|
||||||
m);break}b._slide(g,l,h);return k}}).keyup(function(g){var k=d(this).data("index.ui-slider-handle");if(b._keySliding){b._keySliding=false;b._stop(g,k);b._change(g,k);d(this).removeClass("ui-state-active")}});this._refreshValue();this._animateOff=false},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");this._mouseDestroy();
|
|
||||||
return this},_mouseCapture:function(b){var a=this.options,c,f,e,j,g;if(a.disabled)return false;this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();c=this._normValueFromMouse({x:b.pageX,y:b.pageY});f=this._valueMax()-this._valueMin()+1;j=this;this.handles.each(function(k){var l=Math.abs(c-j.values(k));if(f>l){f=l;e=d(this);g=k}});if(a.range===true&&this.values(1)===a.min){g+=1;e=d(this.handles[g])}if(this._start(b,g)===false)return false;
|
|
||||||
this._mouseSliding=true;j._handleIndex=g;e.addClass("ui-state-active").focus();a=e.offset();this._clickOffset=!d(b.target).parents().andSelf().is(".ui-slider-handle")?{left:0,top:0}:{left:b.pageX-a.left-e.width()/2,top:b.pageY-a.top-e.height()/2-(parseInt(e.css("borderTopWidth"),10)||0)-(parseInt(e.css("borderBottomWidth"),10)||0)+(parseInt(e.css("marginTop"),10)||0)};this.handles.hasClass("ui-state-hover")||this._slide(b,g,c);return this._animateOff=true},_mouseStart:function(){return true},_mouseDrag:function(b){var a=
|
|
||||||
this._normValueFromMouse({x:b.pageX,y:b.pageY});this._slide(b,this._handleIndex,a);return false},_mouseStop:function(b){this.handles.removeClass("ui-state-active");this._mouseSliding=false;this._stop(b,this._handleIndex);this._change(b,this._handleIndex);this._clickOffset=this._handleIndex=null;return this._animateOff=false},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(b){var a;if(this.orientation==="horizontal"){a=
|
|
||||||
this.elementSize.width;b=b.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)}else{a=this.elementSize.height;b=b.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)}a=b/a;if(a>1)a=1;if(a<0)a=0;if(this.orientation==="vertical")a=1-a;b=this._valueMax()-this._valueMin();return this._trimAlignValue(this._valueMin()+a*b)},_start:function(b,a){var c={handle:this.handles[a],value:this.value()};if(this.options.values&&this.options.values.length){c.value=this.values(a);
|
|
||||||
c.values=this.values()}return this._trigger("start",b,c)},_slide:function(b,a,c){var f;if(this.options.values&&this.options.values.length){f=this.values(a?0:1);if(this.options.values.length===2&&this.options.range===true&&(a===0&&c>f||a===1&&c<f))c=f;if(c!==this.values(a)){f=this.values();f[a]=c;b=this._trigger("slide",b,{handle:this.handles[a],value:c,values:f});this.values(a?0:1);b!==false&&this.values(a,c,true)}}else if(c!==this.value()){b=this._trigger("slide",b,{handle:this.handles[a],value:c});
|
|
||||||
b!==false&&this.value(c)}},_stop:function(b,a){var c={handle:this.handles[a],value:this.value()};if(this.options.values&&this.options.values.length){c.value=this.values(a);c.values=this.values()}this._trigger("stop",b,c)},_change:function(b,a){if(!this._keySliding&&!this._mouseSliding){var c={handle:this.handles[a],value:this.value()};if(this.options.values&&this.options.values.length){c.value=this.values(a);c.values=this.values()}this._trigger("change",b,c)}},value:function(b){if(arguments.length){this.options.value=
|
|
||||||
this._trimAlignValue(b);this._refreshValue();this._change(null,0)}else return this._value()},values:function(b,a){var c,f,e;if(arguments.length>1){this.options.values[b]=this._trimAlignValue(a);this._refreshValue();this._change(null,b)}else if(arguments.length)if(d.isArray(arguments[0])){c=this.options.values;f=arguments[0];for(e=0;e<c.length;e+=1){c[e]=this._trimAlignValue(f[e]);this._change(null,e)}this._refreshValue()}else return this.options.values&&this.options.values.length?this._values(b):
|
|
||||||
this.value();else return this._values()},_setOption:function(b,a){var c,f=0;if(d.isArray(this.options.values))f=this.options.values.length;d.Widget.prototype._setOption.apply(this,arguments);switch(b){case "disabled":if(a){this.handles.filter(".ui-state-focus").blur();this.handles.removeClass("ui-state-hover");this.handles.attr("disabled","disabled");this.element.addClass("ui-disabled")}else{this.handles.removeAttr("disabled");this.element.removeClass("ui-disabled")}break;case "orientation":this._detectOrientation();
|
|
||||||
this.element.removeClass("ui-slider-horizontal ui-slider-vertical").addClass("ui-slider-"+this.orientation);this._refreshValue();break;case "value":this._animateOff=true;this._refreshValue();this._change(null,0);this._animateOff=false;break;case "values":this._animateOff=true;this._refreshValue();for(c=0;c<f;c+=1)this._change(null,c);this._animateOff=false;break}},_value:function(){var b=this.options.value;return b=this._trimAlignValue(b)},_values:function(b){var a,c;if(arguments.length){a=this.options.values[b];
|
|
||||||
return a=this._trimAlignValue(a)}else{a=this.options.values.slice();for(c=0;c<a.length;c+=1)a[c]=this._trimAlignValue(a[c]);return a}},_trimAlignValue:function(b){if(b<=this._valueMin())return this._valueMin();if(b>=this._valueMax())return this._valueMax();var a=this.options.step>0?this.options.step:1,c=(b-this._valueMin())%a;alignValue=b-c;if(Math.abs(c)*2>=a)alignValue+=c>0?a:-a;return parseFloat(alignValue.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},
|
|
||||||
_refreshValue:function(){var b=this.options.range,a=this.options,c=this,f=!this._animateOff?a.animate:false,e,j={},g,k,l,i;if(this.options.values&&this.options.values.length)this.handles.each(function(h){e=(c.values(h)-c._valueMin())/(c._valueMax()-c._valueMin())*100;j[c.orientation==="horizontal"?"left":"bottom"]=e+"%";d(this).stop(1,1)[f?"animate":"css"](j,a.animate);if(c.options.range===true)if(c.orientation==="horizontal"){if(h===0)c.range.stop(1,1)[f?"animate":"css"]({left:e+"%"},a.animate);
|
|
||||||
if(h===1)c.range[f?"animate":"css"]({width:e-g+"%"},{queue:false,duration:a.animate})}else{if(h===0)c.range.stop(1,1)[f?"animate":"css"]({bottom:e+"%"},a.animate);if(h===1)c.range[f?"animate":"css"]({height:e-g+"%"},{queue:false,duration:a.animate})}g=e});else{k=this.value();l=this._valueMin();i=this._valueMax();e=i!==l?(k-l)/(i-l)*100:0;j[c.orientation==="horizontal"?"left":"bottom"]=e+"%";this.handle.stop(1,1)[f?"animate":"css"](j,a.animate);if(b==="min"&&this.orientation==="horizontal")this.range.stop(1,
|
|
||||||
1)[f?"animate":"css"]({width:e+"%"},a.animate);if(b==="max"&&this.orientation==="horizontal")this.range[f?"animate":"css"]({width:100-e+"%"},{queue:false,duration:a.animate});if(b==="min"&&this.orientation==="vertical")this.range.stop(1,1)[f?"animate":"css"]({height:e+"%"},a.animate);if(b==="max"&&this.orientation==="vertical")this.range[f?"animate":"css"]({height:100-e+"%"},{queue:false,duration:a.animate})}}});d.extend(d.ui.slider,{version:"1.8.14"})})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Tabs 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Tabs
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.ui.core.js
|
|
||||||
* jquery.ui.widget.js
|
|
||||||
*/
|
|
||||||
(function(d,p){function u(){return++v}function w(){return++x}var v=0,x=0;d.widget("ui.tabs",{options:{add:null,ajaxOptions:null,cache:false,cookie:null,collapsible:false,disable:null,disabled:[],enable:null,event:"click",fx:null,idPrefix:"ui-tabs-",load:null,panelTemplate:"<div></div>",remove:null,select:null,show:null,spinner:"<em>Loading…</em>",tabTemplate:"<li><a href='#{href}'><span>#{label}</span></a></li>"},_create:function(){this._tabify(true)},_setOption:function(b,e){if(b=="selected")this.options.collapsible&&
|
|
||||||
e==this.options.selected||this.select(e);else{this.options[b]=e;this._tabify()}},_tabId:function(b){return b.title&&b.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+u()},_sanitizeSelector:function(b){return b.replace(/:/g,"\\:")},_cookie:function(){var b=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+w());return d.cookie.apply(null,[b].concat(d.makeArray(arguments)))},_ui:function(b,e){return{tab:b,panel:e,index:this.anchors.index(b)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var b=
|
|
||||||
d(this);b.html(b.data("label.tabs")).removeData("label.tabs")})},_tabify:function(b){function e(g,f){g.css("display","");!d.support.opacity&&f.opacity&&g[0].style.removeAttribute("filter")}var a=this,c=this.options,h=/^#.+/;this.list=this.element.find("ol,ul").eq(0);this.lis=d(" > li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return d("a",this)[0]});this.panels=d([]);this.anchors.each(function(g,f){var i=d(f).attr("href"),l=i.split("#")[0],q;if(l&&(l===location.toString().split("#")[0]||
|
|
||||||
(q=d("base")[0])&&l===q.href)){i=f.hash;f.href=i}if(h.test(i))a.panels=a.panels.add(a.element.find(a._sanitizeSelector(i)));else if(i&&i!=="#"){d.data(f,"href.tabs",i);d.data(f,"load.tabs",i.replace(/#.*$/,""));i=a._tabId(f);f.href="#"+i;f=a.element.find("#"+i);if(!f.length){f=d(c.panelTemplate).attr("id",i).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(a.panels[g-1]||a.list);f.data("destroy.tabs",true)}a.panels=a.panels.add(f)}else c.disabled.push(g)});if(b){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all");
|
|
||||||
this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(c.selected===p){location.hash&&this.anchors.each(function(g,f){if(f.hash==location.hash){c.selected=g;return false}});if(typeof c.selected!=="number"&&c.cookie)c.selected=parseInt(a._cookie(),10);if(typeof c.selected!=="number"&&this.lis.filter(".ui-tabs-selected").length)c.selected=
|
|
||||||
this.lis.index(this.lis.filter(".ui-tabs-selected"));c.selected=c.selected||(this.lis.length?0:-1)}else if(c.selected===null)c.selected=-1;c.selected=c.selected>=0&&this.anchors[c.selected]||c.selected<0?c.selected:0;c.disabled=d.unique(c.disabled.concat(d.map(this.lis.filter(".ui-state-disabled"),function(g){return a.lis.index(g)}))).sort();d.inArray(c.selected,c.disabled)!=-1&&c.disabled.splice(d.inArray(c.selected,c.disabled),1);this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active");
|
|
||||||
if(c.selected>=0&&this.anchors.length){a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash)).removeClass("ui-tabs-hide");this.lis.eq(c.selected).addClass("ui-tabs-selected ui-state-active");a.element.queue("tabs",function(){a._trigger("show",null,a._ui(a.anchors[c.selected],a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash))[0]))});this.load(c.selected)}d(window).bind("unload",function(){a.lis.add(a.anchors).unbind(".tabs");a.lis=a.anchors=a.panels=null})}else c.selected=this.lis.index(this.lis.filter(".ui-tabs-selected"));
|
|
||||||
this.element[c.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");c.cookie&&this._cookie(c.selected,c.cookie);b=0;for(var j;j=this.lis[b];b++)d(j)[d.inArray(b,c.disabled)!=-1&&!d(j).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");c.cache===false&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if(c.event!=="mouseover"){var k=function(g,f){f.is(":not(.ui-state-disabled)")&&f.addClass("ui-state-"+g)},n=function(g,f){f.removeClass("ui-state-"+
|
|
||||||
g)};this.lis.bind("mouseover.tabs",function(){k("hover",d(this))});this.lis.bind("mouseout.tabs",function(){n("hover",d(this))});this.anchors.bind("focus.tabs",function(){k("focus",d(this).closest("li"))});this.anchors.bind("blur.tabs",function(){n("focus",d(this).closest("li"))})}var m,o;if(c.fx)if(d.isArray(c.fx)){m=c.fx[0];o=c.fx[1]}else m=o=c.fx;var r=o?function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.hide().removeClass("ui-tabs-hide").animate(o,o.duration||"normal",
|
|
||||||
function(){e(f,o);a._trigger("show",null,a._ui(g,f[0]))})}:function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.removeClass("ui-tabs-hide");a._trigger("show",null,a._ui(g,f[0]))},s=m?function(g,f){f.animate(m,m.duration||"normal",function(){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");e(f,m);a.element.dequeue("tabs")})}:function(g,f){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");a.element.dequeue("tabs")};
|
|
||||||
this.anchors.bind(c.event+".tabs",function(){var g=this,f=d(g).closest("li"),i=a.panels.filter(":not(.ui-tabs-hide)"),l=a.element.find(a._sanitizeSelector(g.hash));if(f.hasClass("ui-tabs-selected")&&!c.collapsible||f.hasClass("ui-state-disabled")||f.hasClass("ui-state-processing")||a.panels.filter(":animated").length||a._trigger("select",null,a._ui(this,l[0]))===false){this.blur();return false}c.selected=a.anchors.index(this);a.abort();if(c.collapsible)if(f.hasClass("ui-tabs-selected")){c.selected=
|
|
||||||
-1;c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){s(g,i)}).dequeue("tabs");this.blur();return false}else if(!i.length){c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this));this.blur();return false}c.cookie&&a._cookie(c.selected,c.cookie);if(l.length){i.length&&a.element.queue("tabs",function(){s(g,i)});a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this))}else throw"jQuery UI Tabs: Mismatching fragment identifier.";
|
|
||||||
d.browser.msie&&this.blur()});this.anchors.bind("click.tabs",function(){return false})},_getIndex:function(b){if(typeof b=="string")b=this.anchors.index(this.anchors.filter("[href$="+b+"]"));return b},destroy:function(){var b=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var e=
|
|
||||||
d.data(this,"href.tabs");if(e)this.href=e;var a=d(this).unbind(".tabs");d.each(["href","load","cache"],function(c,h){a.removeData(h+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){d.data(this,"destroy.tabs")?d(this).remove():d(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});b.cookie&&this._cookie(null,b.cookie);return this},add:function(b,
|
|
||||||
e,a){if(a===p)a=this.anchors.length;var c=this,h=this.options;e=d(h.tabTemplate.replace(/#\{href\}/g,b).replace(/#\{label\}/g,e));b=!b.indexOf("#")?b.replace("#",""):this._tabId(d("a",e)[0]);e.addClass("ui-state-default ui-corner-top").data("destroy.tabs",true);var j=c.element.find("#"+b);j.length||(j=d(h.panelTemplate).attr("id",b).data("destroy.tabs",true));j.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(a>=this.lis.length){e.appendTo(this.list);j.appendTo(this.list[0].parentNode)}else{e.insertBefore(this.lis[a]);
|
|
||||||
j.insertBefore(this.panels[a])}h.disabled=d.map(h.disabled,function(k){return k>=a?++k:k});this._tabify();if(this.anchors.length==1){h.selected=0;e.addClass("ui-tabs-selected ui-state-active");j.removeClass("ui-tabs-hide");this.element.queue("tabs",function(){c._trigger("show",null,c._ui(c.anchors[0],c.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[a],this.panels[a]));return this},remove:function(b){b=this._getIndex(b);var e=this.options,a=this.lis.eq(b).remove(),c=this.panels.eq(b).remove();
|
|
||||||
if(a.hasClass("ui-tabs-selected")&&this.anchors.length>1)this.select(b+(b+1<this.anchors.length?1:-1));e.disabled=d.map(d.grep(e.disabled,function(h){return h!=b}),function(h){return h>=b?--h:h});this._tabify();this._trigger("remove",null,this._ui(a.find("a")[0],c[0]));return this},enable:function(b){b=this._getIndex(b);var e=this.options;if(d.inArray(b,e.disabled)!=-1){this.lis.eq(b).removeClass("ui-state-disabled");e.disabled=d.grep(e.disabled,function(a){return a!=b});this._trigger("enable",null,
|
|
||||||
this._ui(this.anchors[b],this.panels[b]));return this}},disable:function(b){b=this._getIndex(b);var e=this.options;if(b!=e.selected){this.lis.eq(b).addClass("ui-state-disabled");e.disabled.push(b);e.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[b],this.panels[b]))}return this},select:function(b){b=this._getIndex(b);if(b==-1)if(this.options.collapsible&&this.options.selected!=-1)b=this.options.selected;else return this;this.anchors.eq(b).trigger(this.options.event+".tabs");return this},
|
|
||||||
load:function(b){b=this._getIndex(b);var e=this,a=this.options,c=this.anchors.eq(b)[0],h=d.data(c,"load.tabs");this.abort();if(!h||this.element.queue("tabs").length!==0&&d.data(c,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(b).addClass("ui-state-processing");if(a.spinner){var j=d("span",c);j.data("label.tabs",j.html()).html(a.spinner)}this.xhr=d.ajax(d.extend({},a.ajaxOptions,{url:h,success:function(k,n){e.element.find(e._sanitizeSelector(c.hash)).html(k);e._cleanup();a.cache&&d.data(c,
|
|
||||||
"cache.tabs",true);e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.success(k,n)}catch(m){}},error:function(k,n){e._cleanup();e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.error(k,n,b,c)}catch(m){}}}));e.element.dequeue("tabs");return this}},abort:function(){this.element.queue([]);this.panels.stop(false,true);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup();return this},
|
|
||||||
url:function(b,e){this.anchors.eq(b).removeData("cache.tabs").data("load.tabs",e);return this},length:function(){return this.anchors.length}});d.extend(d.ui.tabs,{version:"1.8.14"});d.extend(d.ui.tabs.prototype,{rotation:null,rotate:function(b,e){var a=this,c=this.options,h=a._rotate||(a._rotate=function(j){clearTimeout(a.rotation);a.rotation=setTimeout(function(){var k=c.selected;a.select(++k<a.anchors.length?k:0)},b);j&&j.stopPropagation()});e=a._unrotate||(a._unrotate=!e?function(j){j.clientX&&
|
|
||||||
a.rotate(null)}:function(){t=c.selected;h()});if(b){this.element.bind("tabsshow",h);this.anchors.bind(c.event+".tabs",e);h()}else{clearTimeout(a.rotation);this.element.unbind("tabsshow",h);this.anchors.unbind(c.event+".tabs",e);delete this._rotate;delete this._unrotate}return this}})})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Datepicker 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Datepicker
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.ui.core.js
|
|
||||||
*/
|
|
||||||
(function(d,C){function M(){this.debug=false;this._curInst=null;this._keyEvent=false;this._disabledInputs=[];this._inDialog=this._datepickerShowing=false;this._mainDivId="ui-datepicker-div";this._inlineClass="ui-datepicker-inline";this._appendClass="ui-datepicker-append";this._triggerClass="ui-datepicker-trigger";this._dialogClass="ui-datepicker-dialog";this._disableClass="ui-datepicker-disabled";this._unselectableClass="ui-datepicker-unselectable";this._currentClass="ui-datepicker-current-day";this._dayOverClass=
|
|
||||||
"ui-datepicker-days-cell-over";this.regional=[];this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su",
|
|
||||||
"Mo","Tu","We","Th","Fr","Sa"],weekHeader:"Wk",dateFormat:"mm/dd/yy",firstDay:0,isRTL:false,showMonthAfterYear:false,yearSuffix:""};this._defaults={showOn:"focus",showAnim:"fadeIn",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:false,hideIfNoPrevNext:false,navigationAsDateFormat:false,gotoCurrent:false,changeMonth:false,changeYear:false,yearRange:"c-10:c+10",showOtherMonths:false,selectOtherMonths:false,showWeek:false,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",
|
|
||||||
minDate:null,maxDate:null,duration:"fast",beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:"",altFormat:"",constrainInput:true,showButtonPanel:false,autoSize:false};d.extend(this._defaults,this.regional[""]);this.dpDiv=N(d('<div id="'+this._mainDivId+'" class="ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))}function N(a){return a.bind("mouseout",function(b){b=
|
|
||||||
d(b.target).closest("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a");b.length&&b.removeClass("ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover")}).bind("mouseover",function(b){b=d(b.target).closest("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a");if(!(d.datepicker._isDisabledDatepicker(J.inline?a.parent()[0]:J.input[0])||!b.length)){b.parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");b.addClass("ui-state-hover");
|
|
||||||
b.hasClass("ui-datepicker-prev")&&b.addClass("ui-datepicker-prev-hover");b.hasClass("ui-datepicker-next")&&b.addClass("ui-datepicker-next-hover")}})}function H(a,b){d.extend(a,b);for(var c in b)if(b[c]==null||b[c]==C)a[c]=b[c];return a}d.extend(d.ui,{datepicker:{version:"1.8.14"}});var A=(new Date).getTime(),J;d.extend(M.prototype,{markerClassName:"hasDatepicker",maxRows:4,log:function(){this.debug&&console.log.apply("",arguments)},_widgetDatepicker:function(){return this.dpDiv},setDefaults:function(a){H(this._defaults,
|
|
||||||
a||{});return this},_attachDatepicker:function(a,b){var c=null;for(var e in this._defaults){var f=a.getAttribute("date:"+e);if(f){c=c||{};try{c[e]=eval(f)}catch(h){c[e]=f}}}e=a.nodeName.toLowerCase();f=e=="div"||e=="span";if(!a.id){this.uuid+=1;a.id="dp"+this.uuid}var i=this._newInst(d(a),f);i.settings=d.extend({},b||{},c||{});if(e=="input")this._connectDatepicker(a,i);else f&&this._inlineDatepicker(a,i)},_newInst:function(a,b){return{id:a[0].id.replace(/([^A-Za-z0-9_-])/g,"\\\\$1"),input:a,selectedDay:0,
|
|
||||||
selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:b,dpDiv:!b?this.dpDiv:N(d('<div class="'+this._inlineClass+' ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"></div>'))}},_connectDatepicker:function(a,b){var c=d(a);b.append=d([]);b.trigger=d([]);if(!c.hasClass(this.markerClassName)){this._attachments(c,b);c.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setData.datepicker",function(e,f,h){b.settings[f]=
|
|
||||||
h}).bind("getData.datepicker",function(e,f){return this._get(b,f)});this._autoSize(b);d.data(a,"datepicker",b)}},_attachments:function(a,b){var c=this._get(b,"appendText"),e=this._get(b,"isRTL");b.append&&b.append.remove();if(c){b.append=d('<span class="'+this._appendClass+'">'+c+"</span>");a[e?"before":"after"](b.append)}a.unbind("focus",this._showDatepicker);b.trigger&&b.trigger.remove();c=this._get(b,"showOn");if(c=="focus"||c=="both")a.focus(this._showDatepicker);if(c=="button"||c=="both"){c=
|
|
||||||
this._get(b,"buttonText");var f=this._get(b,"buttonImage");b.trigger=d(this._get(b,"buttonImageOnly")?d("<img/>").addClass(this._triggerClass).attr({src:f,alt:c,title:c}):d('<button type="button"></button>').addClass(this._triggerClass).html(f==""?c:d("<img/>").attr({src:f,alt:c,title:c})));a[e?"before":"after"](b.trigger);b.trigger.click(function(){d.datepicker._datepickerShowing&&d.datepicker._lastInput==a[0]?d.datepicker._hideDatepicker():d.datepicker._showDatepicker(a[0]);return false})}},_autoSize:function(a){if(this._get(a,
|
|
||||||
"autoSize")&&!a.inline){var b=new Date(2009,11,20),c=this._get(a,"dateFormat");if(c.match(/[DM]/)){var e=function(f){for(var h=0,i=0,g=0;g<f.length;g++)if(f[g].length>h){h=f[g].length;i=g}return i};b.setMonth(e(this._get(a,c.match(/MM/)?"monthNames":"monthNamesShort")));b.setDate(e(this._get(a,c.match(/DD/)?"dayNames":"dayNamesShort"))+20-b.getDay())}a.input.attr("size",this._formatDate(a,b).length)}},_inlineDatepicker:function(a,b){var c=d(a);if(!c.hasClass(this.markerClassName)){c.addClass(this.markerClassName).append(b.dpDiv).bind("setData.datepicker",
|
|
||||||
function(e,f,h){b.settings[f]=h}).bind("getData.datepicker",function(e,f){return this._get(b,f)});d.data(a,"datepicker",b);this._setDate(b,this._getDefaultDate(b),true);this._updateDatepicker(b);this._updateAlternate(b);b.dpDiv.show()}},_dialogDatepicker:function(a,b,c,e,f){a=this._dialogInst;if(!a){this.uuid+=1;this._dialogInput=d('<input type="text" id="'+("dp"+this.uuid)+'" style="position: absolute; top: -100px; width: 0px; z-index: -10;"/>');this._dialogInput.keydown(this._doKeyDown);d("body").append(this._dialogInput);
|
|
||||||
a=this._dialogInst=this._newInst(this._dialogInput,false);a.settings={};d.data(this._dialogInput[0],"datepicker",a)}H(a.settings,e||{});b=b&&b.constructor==Date?this._formatDate(a,b):b;this._dialogInput.val(b);this._pos=f?f.length?f:[f.pageX,f.pageY]:null;if(!this._pos)this._pos=[document.documentElement.clientWidth/2-100+(document.documentElement.scrollLeft||document.body.scrollLeft),document.documentElement.clientHeight/2-150+(document.documentElement.scrollTop||document.body.scrollTop)];this._dialogInput.css("left",
|
|
||||||
this._pos[0]+20+"px").css("top",this._pos[1]+"px");a.settings.onSelect=c;this._inDialog=true;this.dpDiv.addClass(this._dialogClass);this._showDatepicker(this._dialogInput[0]);d.blockUI&&d.blockUI(this.dpDiv);d.data(this._dialogInput[0],"datepicker",a);return this},_destroyDatepicker:function(a){var b=d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();d.removeData(a,"datepicker");if(e=="input"){c.append.remove();c.trigger.remove();b.removeClass(this.markerClassName).unbind("focus",
|
|
||||||
this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)}else if(e=="div"||e=="span")b.removeClass(this.markerClassName).empty()}},_enableDatepicker:function(a){var b=d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();if(e=="input"){a.disabled=false;c.trigger.filter("button").each(function(){this.disabled=false}).end().filter("img").css({opacity:"1.0",cursor:""})}else if(e=="div"||e=="span"){b=
|
|
||||||
b.children("."+this._inlineClass);b.children().removeClass("ui-state-disabled");b.find("select.ui-datepicker-month, select.ui-datepicker-year").removeAttr("disabled")}this._disabledInputs=d.map(this._disabledInputs,function(f){return f==a?null:f})}},_disableDatepicker:function(a){var b=d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();if(e=="input"){a.disabled=true;c.trigger.filter("button").each(function(){this.disabled=true}).end().filter("img").css({opacity:"0.5",
|
|
||||||
cursor:"default"})}else if(e=="div"||e=="span"){b=b.children("."+this._inlineClass);b.children().addClass("ui-state-disabled");b.find("select.ui-datepicker-month, select.ui-datepicker-year").attr("disabled","disabled")}this._disabledInputs=d.map(this._disabledInputs,function(f){return f==a?null:f});this._disabledInputs[this._disabledInputs.length]=a}},_isDisabledDatepicker:function(a){if(!a)return false;for(var b=0;b<this._disabledInputs.length;b++)if(this._disabledInputs[b]==a)return true;return false},
|
|
||||||
_getInst:function(a){try{return d.data(a,"datepicker")}catch(b){throw"Missing instance data for this datepicker";}},_optionDatepicker:function(a,b,c){var e=this._getInst(a);if(arguments.length==2&&typeof b=="string")return b=="defaults"?d.extend({},d.datepicker._defaults):e?b=="all"?d.extend({},e.settings):this._get(e,b):null;var f=b||{};if(typeof b=="string"){f={};f[b]=c}if(e){this._curInst==e&&this._hideDatepicker();var h=this._getDateDatepicker(a,true),i=this._getMinMaxDate(e,"min"),g=this._getMinMaxDate(e,
|
|
||||||
"max");H(e.settings,f);if(i!==null&&f.dateFormat!==C&&f.minDate===C)e.settings.minDate=this._formatDate(e,i);if(g!==null&&f.dateFormat!==C&&f.maxDate===C)e.settings.maxDate=this._formatDate(e,g);this._attachments(d(a),e);this._autoSize(e);this._setDate(e,h);this._updateAlternate(e);this._updateDatepicker(e)}},_changeDatepicker:function(a,b,c){this._optionDatepicker(a,b,c)},_refreshDatepicker:function(a){(a=this._getInst(a))&&this._updateDatepicker(a)},_setDateDatepicker:function(a,b){if(a=this._getInst(a)){this._setDate(a,
|
|
||||||
b);this._updateDatepicker(a);this._updateAlternate(a)}},_getDateDatepicker:function(a,b){(a=this._getInst(a))&&!a.inline&&this._setDateFromField(a,b);return a?this._getDate(a):null},_doKeyDown:function(a){var b=d.datepicker._getInst(a.target),c=true,e=b.dpDiv.is(".ui-datepicker-rtl");b._keyEvent=true;if(d.datepicker._datepickerShowing)switch(a.keyCode){case 9:d.datepicker._hideDatepicker();c=false;break;case 13:c=d("td."+d.datepicker._dayOverClass+":not(."+d.datepicker._currentClass+")",b.dpDiv);
|
|
||||||
c[0]?d.datepicker._selectDay(a.target,b.selectedMonth,b.selectedYear,c[0]):d.datepicker._hideDatepicker();return false;case 27:d.datepicker._hideDatepicker();break;case 33:d.datepicker._adjustDate(a.target,a.ctrlKey?-d.datepicker._get(b,"stepBigMonths"):-d.datepicker._get(b,"stepMonths"),"M");break;case 34:d.datepicker._adjustDate(a.target,a.ctrlKey?+d.datepicker._get(b,"stepBigMonths"):+d.datepicker._get(b,"stepMonths"),"M");break;case 35:if(a.ctrlKey||a.metaKey)d.datepicker._clearDate(a.target);
|
|
||||||
c=a.ctrlKey||a.metaKey;break;case 36:if(a.ctrlKey||a.metaKey)d.datepicker._gotoToday(a.target);c=a.ctrlKey||a.metaKey;break;case 37:if(a.ctrlKey||a.metaKey)d.datepicker._adjustDate(a.target,e?+1:-1,"D");c=a.ctrlKey||a.metaKey;if(a.originalEvent.altKey)d.datepicker._adjustDate(a.target,a.ctrlKey?-d.datepicker._get(b,"stepBigMonths"):-d.datepicker._get(b,"stepMonths"),"M");break;case 38:if(a.ctrlKey||a.metaKey)d.datepicker._adjustDate(a.target,-7,"D");c=a.ctrlKey||a.metaKey;break;case 39:if(a.ctrlKey||
|
|
||||||
a.metaKey)d.datepicker._adjustDate(a.target,e?-1:+1,"D");c=a.ctrlKey||a.metaKey;if(a.originalEvent.altKey)d.datepicker._adjustDate(a.target,a.ctrlKey?+d.datepicker._get(b,"stepBigMonths"):+d.datepicker._get(b,"stepMonths"),"M");break;case 40:if(a.ctrlKey||a.metaKey)d.datepicker._adjustDate(a.target,+7,"D");c=a.ctrlKey||a.metaKey;break;default:c=false}else if(a.keyCode==36&&a.ctrlKey)d.datepicker._showDatepicker(this);else c=false;if(c){a.preventDefault();a.stopPropagation()}},_doKeyPress:function(a){var b=
|
|
||||||
d.datepicker._getInst(a.target);if(d.datepicker._get(b,"constrainInput")){b=d.datepicker._possibleChars(d.datepicker._get(b,"dateFormat"));var c=String.fromCharCode(a.charCode==C?a.keyCode:a.charCode);return a.ctrlKey||a.metaKey||c<" "||!b||b.indexOf(c)>-1}},_doKeyUp:function(a){a=d.datepicker._getInst(a.target);if(a.input.val()!=a.lastVal)try{if(d.datepicker.parseDate(d.datepicker._get(a,"dateFormat"),a.input?a.input.val():null,d.datepicker._getFormatConfig(a))){d.datepicker._setDateFromField(a);
|
|
||||||
d.datepicker._updateAlternate(a);d.datepicker._updateDatepicker(a)}}catch(b){d.datepicker.log(b)}return true},_showDatepicker:function(a){a=a.target||a;if(a.nodeName.toLowerCase()!="input")a=d("input",a.parentNode)[0];if(!(d.datepicker._isDisabledDatepicker(a)||d.datepicker._lastInput==a)){var b=d.datepicker._getInst(a);if(d.datepicker._curInst&&d.datepicker._curInst!=b){d.datepicker._datepickerShowing&&d.datepicker._triggerOnClose(d.datepicker._curInst);d.datepicker._curInst.dpDiv.stop(true,true)}var c=
|
|
||||||
d.datepicker._get(b,"beforeShow");H(b.settings,c?c.apply(a,[a,b]):{});b.lastVal=null;d.datepicker._lastInput=a;d.datepicker._setDateFromField(b);if(d.datepicker._inDialog)a.value="";if(!d.datepicker._pos){d.datepicker._pos=d.datepicker._findPos(a);d.datepicker._pos[1]+=a.offsetHeight}var e=false;d(a).parents().each(function(){e|=d(this).css("position")=="fixed";return!e});if(e&&d.browser.opera){d.datepicker._pos[0]-=document.documentElement.scrollLeft;d.datepicker._pos[1]-=document.documentElement.scrollTop}c=
|
|
||||||
{left:d.datepicker._pos[0],top:d.datepicker._pos[1]};d.datepicker._pos=null;b.dpDiv.empty();b.dpDiv.css({position:"absolute",display:"block",top:"-1000px"});d.datepicker._updateDatepicker(b);c=d.datepicker._checkOffset(b,c,e);b.dpDiv.css({position:d.datepicker._inDialog&&d.blockUI?"static":e?"fixed":"absolute",display:"none",left:c.left+"px",top:c.top+"px"});if(!b.inline){c=d.datepicker._get(b,"showAnim");var f=d.datepicker._get(b,"duration"),h=function(){var i=b.dpDiv.find("iframe.ui-datepicker-cover");
|
|
||||||
if(i.length){var g=d.datepicker._getBorders(b.dpDiv);i.css({left:-g[0],top:-g[1],width:b.dpDiv.outerWidth(),height:b.dpDiv.outerHeight()})}};b.dpDiv.zIndex(d(a).zIndex()+1);d.datepicker._datepickerShowing=true;d.effects&&d.effects[c]?b.dpDiv.show(c,d.datepicker._get(b,"showOptions"),f,h):b.dpDiv[c||"show"](c?f:null,h);if(!c||!f)h();b.input.is(":visible")&&!b.input.is(":disabled")&&b.input.focus();d.datepicker._curInst=b}}},_updateDatepicker:function(a){this.maxRows=4;var b=d.datepicker._getBorders(a.dpDiv);
|
|
||||||
J=a;a.dpDiv.empty().append(this._generateHTML(a));var c=a.dpDiv.find("iframe.ui-datepicker-cover");c.length&&c.css({left:-b[0],top:-b[1],width:a.dpDiv.outerWidth(),height:a.dpDiv.outerHeight()});a.dpDiv.find("."+this._dayOverClass+" a").mouseover();b=this._getNumberOfMonths(a);c=b[1];a.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");c>1&&a.dpDiv.addClass("ui-datepicker-multi-"+c).css("width",17*c+"em");a.dpDiv[(b[0]!=1||b[1]!=1?"add":"remove")+"Class"]("ui-datepicker-multi");
|
|
||||||
a.dpDiv[(this._get(a,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl");a==d.datepicker._curInst&&d.datepicker._datepickerShowing&&a.input&&a.input.is(":visible")&&!a.input.is(":disabled")&&a.input[0]!=document.activeElement&&a.input.focus();if(a.yearshtml){var e=a.yearshtml;setTimeout(function(){e===a.yearshtml&&a.yearshtml&&a.dpDiv.find("select.ui-datepicker-year:first").replaceWith(a.yearshtml);e=a.yearshtml=null},0)}},_getBorders:function(a){var b=function(c){return{thin:1,medium:2,thick:3}[c]||
|
|
||||||
c};return[parseFloat(b(a.css("border-left-width"))),parseFloat(b(a.css("border-top-width")))]},_checkOffset:function(a,b,c){var e=a.dpDiv.outerWidth(),f=a.dpDiv.outerHeight(),h=a.input?a.input.outerWidth():0,i=a.input?a.input.outerHeight():0,g=document.documentElement.clientWidth+d(document).scrollLeft(),j=document.documentElement.clientHeight+d(document).scrollTop();b.left-=this._get(a,"isRTL")?e-h:0;b.left-=c&&b.left==a.input.offset().left?d(document).scrollLeft():0;b.top-=c&&b.top==a.input.offset().top+
|
|
||||||
i?d(document).scrollTop():0;b.left-=Math.min(b.left,b.left+e>g&&g>e?Math.abs(b.left+e-g):0);b.top-=Math.min(b.top,b.top+f>j&&j>f?Math.abs(f+i):0);return b},_findPos:function(a){for(var b=this._get(this._getInst(a),"isRTL");a&&(a.type=="hidden"||a.nodeType!=1||d.expr.filters.hidden(a));)a=a[b?"previousSibling":"nextSibling"];a=d(a).offset();return[a.left,a.top]},_triggerOnClose:function(a){var b=this._get(a,"onClose");if(b)b.apply(a.input?a.input[0]:null,[a.input?a.input.val():"",a])},_hideDatepicker:function(a){var b=
|
|
||||||
this._curInst;if(!(!b||a&&b!=d.data(a,"datepicker")))if(this._datepickerShowing){a=this._get(b,"showAnim");var c=this._get(b,"duration"),e=function(){d.datepicker._tidyDialog(b);this._curInst=null};d.effects&&d.effects[a]?b.dpDiv.hide(a,d.datepicker._get(b,"showOptions"),c,e):b.dpDiv[a=="slideDown"?"slideUp":a=="fadeIn"?"fadeOut":"hide"](a?c:null,e);a||e();d.datepicker._triggerOnClose(b);this._datepickerShowing=false;this._lastInput=null;if(this._inDialog){this._dialogInput.css({position:"absolute",
|
|
||||||
left:"0",top:"-100px"});if(d.blockUI){d.unblockUI();d("body").append(this.dpDiv)}}this._inDialog=false}},_tidyDialog:function(a){a.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")},_checkExternalClick:function(a){if(d.datepicker._curInst){a=d(a.target);a[0].id!=d.datepicker._mainDivId&&a.parents("#"+d.datepicker._mainDivId).length==0&&!a.hasClass(d.datepicker.markerClassName)&&!a.hasClass(d.datepicker._triggerClass)&&d.datepicker._datepickerShowing&&!(d.datepicker._inDialog&&
|
|
||||||
d.blockUI)&&d.datepicker._hideDatepicker()}},_adjustDate:function(a,b,c){a=d(a);var e=this._getInst(a[0]);if(!this._isDisabledDatepicker(a[0])){this._adjustInstDate(e,b+(c=="M"?this._get(e,"showCurrentAtPos"):0),c);this._updateDatepicker(e)}},_gotoToday:function(a){a=d(a);var b=this._getInst(a[0]);if(this._get(b,"gotoCurrent")&&b.currentDay){b.selectedDay=b.currentDay;b.drawMonth=b.selectedMonth=b.currentMonth;b.drawYear=b.selectedYear=b.currentYear}else{var c=new Date;b.selectedDay=c.getDate();b.drawMonth=
|
|
||||||
b.selectedMonth=c.getMonth();b.drawYear=b.selectedYear=c.getFullYear()}this._notifyChange(b);this._adjustDate(a)},_selectMonthYear:function(a,b,c){a=d(a);var e=this._getInst(a[0]);e._selectingMonthYear=false;e["selected"+(c=="M"?"Month":"Year")]=e["draw"+(c=="M"?"Month":"Year")]=parseInt(b.options[b.selectedIndex].value,10);this._notifyChange(e);this._adjustDate(a)},_clickMonthYear:function(a){var b=this._getInst(d(a)[0]);b.input&&b._selectingMonthYear&&setTimeout(function(){b.input.focus()},0);b._selectingMonthYear=
|
|
||||||
!b._selectingMonthYear},_selectDay:function(a,b,c,e){var f=d(a);if(!(d(e).hasClass(this._unselectableClass)||this._isDisabledDatepicker(f[0]))){f=this._getInst(f[0]);f.selectedDay=f.currentDay=d("a",e).html();f.selectedMonth=f.currentMonth=b;f.selectedYear=f.currentYear=c;this._selectDate(a,this._formatDate(f,f.currentDay,f.currentMonth,f.currentYear))}},_clearDate:function(a){a=d(a);this._getInst(a[0]);this._selectDate(a,"")},_selectDate:function(a,b){a=this._getInst(d(a)[0]);b=b!=null?b:this._formatDate(a);
|
|
||||||
a.input&&a.input.val(b);this._updateAlternate(a);var c=this._get(a,"onSelect");if(c)c.apply(a.input?a.input[0]:null,[b,a]);else a.input&&a.input.trigger("change");if(a.inline)this._updateDatepicker(a);else{this._hideDatepicker();this._lastInput=a.input[0];typeof a.input[0]!="object"&&a.input.focus();this._lastInput=null}},_updateAlternate:function(a){var b=this._get(a,"altField");if(b){var c=this._get(a,"altFormat")||this._get(a,"dateFormat"),e=this._getDate(a),f=this.formatDate(c,e,this._getFormatConfig(a));
|
|
||||||
d(b).each(function(){d(this).val(f)})}},noWeekends:function(a){a=a.getDay();return[a>0&&a<6,""]},iso8601Week:function(a){a=new Date(a.getTime());a.setDate(a.getDate()+4-(a.getDay()||7));var b=a.getTime();a.setMonth(0);a.setDate(1);return Math.floor(Math.round((b-a)/864E5)/7)+1},parseDate:function(a,b,c){if(a==null||b==null)throw"Invalid arguments";b=typeof b=="object"?b.toString():b+"";if(b=="")return null;var e=(c?c.shortYearCutoff:null)||this._defaults.shortYearCutoff;e=typeof e!="string"?e:(new Date).getFullYear()%
|
|
||||||
100+parseInt(e,10);for(var f=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,h=(c?c.dayNames:null)||this._defaults.dayNames,i=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort,g=(c?c.monthNames:null)||this._defaults.monthNames,j=c=-1,l=-1,u=-1,k=false,o=function(p){(p=B+1<a.length&&a.charAt(B+1)==p)&&B++;return p},m=function(p){var D=o(p);p=new RegExp("^\\d{1,"+(p=="@"?14:p=="!"?20:p=="y"&&D?4:p=="o"?3:2)+"}");p=b.substring(q).match(p);if(!p)throw"Missing number at position "+q;q+=
|
|
||||||
p[0].length;return parseInt(p[0],10)},n=function(p,D,K){p=d.map(o(p)?K:D,function(w,x){return[[x,w]]}).sort(function(w,x){return-(w[1].length-x[1].length)});var E=-1;d.each(p,function(w,x){w=x[1];if(b.substr(q,w.length).toLowerCase()==w.toLowerCase()){E=x[0];q+=w.length;return false}});if(E!=-1)return E+1;else throw"Unknown name at position "+q;},s=function(){if(b.charAt(q)!=a.charAt(B))throw"Unexpected literal at position "+q;q++},q=0,B=0;B<a.length;B++)if(k)if(a.charAt(B)=="'"&&!o("'"))k=false;
|
|
||||||
else s();else switch(a.charAt(B)){case "d":l=m("d");break;case "D":n("D",f,h);break;case "o":u=m("o");break;case "m":j=m("m");break;case "M":j=n("M",i,g);break;case "y":c=m("y");break;case "@":var v=new Date(m("@"));c=v.getFullYear();j=v.getMonth()+1;l=v.getDate();break;case "!":v=new Date((m("!")-this._ticksTo1970)/1E4);c=v.getFullYear();j=v.getMonth()+1;l=v.getDate();break;case "'":if(o("'"))s();else k=true;break;default:s()}if(q<b.length)throw"Extra/unparsed characters found in date: "+b.substring(q);
|
|
||||||
if(c==-1)c=(new Date).getFullYear();else if(c<100)c+=(new Date).getFullYear()-(new Date).getFullYear()%100+(c<=e?0:-100);if(u>-1){j=1;l=u;do{e=this._getDaysInMonth(c,j-1);if(l<=e)break;j++;l-=e}while(1)}v=this._daylightSavingAdjust(new Date(c,j-1,l));if(v.getFullYear()!=c||v.getMonth()+1!=j||v.getDate()!=l)throw"Invalid date";return v},ATOM:"yy-mm-dd",COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",
|
|
||||||
TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925))*24*60*60*1E7,formatDate:function(a,b,c){if(!b)return"";var e=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,f=(c?c.dayNames:null)||this._defaults.dayNames,h=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort;c=(c?c.monthNames:null)||this._defaults.monthNames;var i=function(o){(o=k+1<a.length&&a.charAt(k+1)==o)&&k++;return o},g=function(o,m,n){m=""+m;if(i(o))for(;m.length<
|
|
||||||
n;)m="0"+m;return m},j=function(o,m,n,s){return i(o)?s[m]:n[m]},l="",u=false;if(b)for(var k=0;k<a.length;k++)if(u)if(a.charAt(k)=="'"&&!i("'"))u=false;else l+=a.charAt(k);else switch(a.charAt(k)){case "d":l+=g("d",b.getDate(),2);break;case "D":l+=j("D",b.getDay(),e,f);break;case "o":l+=g("o",Math.round(((new Date(b.getFullYear(),b.getMonth(),b.getDate())).getTime()-(new Date(b.getFullYear(),0,0)).getTime())/864E5),3);break;case "m":l+=g("m",b.getMonth()+1,2);break;case "M":l+=j("M",b.getMonth(),h,
|
|
||||||
c);break;case "y":l+=i("y")?b.getFullYear():(b.getYear()%100<10?"0":"")+b.getYear()%100;break;case "@":l+=b.getTime();break;case "!":l+=b.getTime()*1E4+this._ticksTo1970;break;case "'":if(i("'"))l+="'";else u=true;break;default:l+=a.charAt(k)}return l},_possibleChars:function(a){for(var b="",c=false,e=function(h){(h=f+1<a.length&&a.charAt(f+1)==h)&&f++;return h},f=0;f<a.length;f++)if(c)if(a.charAt(f)=="'"&&!e("'"))c=false;else b+=a.charAt(f);else switch(a.charAt(f)){case "d":case "m":case "y":case "@":b+=
|
|
||||||
"0123456789";break;case "D":case "M":return null;case "'":if(e("'"))b+="'";else c=true;break;default:b+=a.charAt(f)}return b},_get:function(a,b){return a.settings[b]!==C?a.settings[b]:this._defaults[b]},_setDateFromField:function(a,b){if(a.input.val()!=a.lastVal){var c=this._get(a,"dateFormat"),e=a.lastVal=a.input?a.input.val():null,f,h;f=h=this._getDefaultDate(a);var i=this._getFormatConfig(a);try{f=this.parseDate(c,e,i)||h}catch(g){this.log(g);e=b?"":e}a.selectedDay=f.getDate();a.drawMonth=a.selectedMonth=
|
|
||||||
f.getMonth();a.drawYear=a.selectedYear=f.getFullYear();a.currentDay=e?f.getDate():0;a.currentMonth=e?f.getMonth():0;a.currentYear=e?f.getFullYear():0;this._adjustInstDate(a)}},_getDefaultDate:function(a){return this._restrictMinMax(a,this._determineDate(a,this._get(a,"defaultDate"),new Date))},_determineDate:function(a,b,c){var e=function(h){var i=new Date;i.setDate(i.getDate()+h);return i},f=function(h){try{return d.datepicker.parseDate(d.datepicker._get(a,"dateFormat"),h,d.datepicker._getFormatConfig(a))}catch(i){}var g=
|
|
||||||
(h.toLowerCase().match(/^c/)?d.datepicker._getDate(a):null)||new Date,j=g.getFullYear(),l=g.getMonth();g=g.getDate();for(var u=/([+-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,k=u.exec(h);k;){switch(k[2]||"d"){case "d":case "D":g+=parseInt(k[1],10);break;case "w":case "W":g+=parseInt(k[1],10)*7;break;case "m":case "M":l+=parseInt(k[1],10);g=Math.min(g,d.datepicker._getDaysInMonth(j,l));break;case "y":case "Y":j+=parseInt(k[1],10);g=Math.min(g,d.datepicker._getDaysInMonth(j,l));break}k=u.exec(h)}return new Date(j,
|
|
||||||
l,g)};if(b=(b=b==null||b===""?c:typeof b=="string"?f(b):typeof b=="number"?isNaN(b)?c:e(b):new Date(b.getTime()))&&b.toString()=="Invalid Date"?c:b){b.setHours(0);b.setMinutes(0);b.setSeconds(0);b.setMilliseconds(0)}return this._daylightSavingAdjust(b)},_daylightSavingAdjust:function(a){if(!a)return null;a.setHours(a.getHours()>12?a.getHours()+2:0);return a},_setDate:function(a,b,c){var e=!b,f=a.selectedMonth,h=a.selectedYear;b=this._restrictMinMax(a,this._determineDate(a,b,new Date));a.selectedDay=
|
|
||||||
a.currentDay=b.getDate();a.drawMonth=a.selectedMonth=a.currentMonth=b.getMonth();a.drawYear=a.selectedYear=a.currentYear=b.getFullYear();if((f!=a.selectedMonth||h!=a.selectedYear)&&!c)this._notifyChange(a);this._adjustInstDate(a);if(a.input)a.input.val(e?"":this._formatDate(a))},_getDate:function(a){return!a.currentYear||a.input&&a.input.val()==""?null:this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay))},_generateHTML:function(a){var b=new Date;b=this._daylightSavingAdjust(new Date(b.getFullYear(),
|
|
||||||
b.getMonth(),b.getDate()));var c=this._get(a,"isRTL"),e=this._get(a,"showButtonPanel"),f=this._get(a,"hideIfNoPrevNext"),h=this._get(a,"navigationAsDateFormat"),i=this._getNumberOfMonths(a),g=this._get(a,"showCurrentAtPos"),j=this._get(a,"stepMonths"),l=i[0]!=1||i[1]!=1,u=this._daylightSavingAdjust(!a.currentDay?new Date(9999,9,9):new Date(a.currentYear,a.currentMonth,a.currentDay)),k=this._getMinMaxDate(a,"min"),o=this._getMinMaxDate(a,"max");g=a.drawMonth-g;var m=a.drawYear;if(g<0){g+=12;m--}if(o){var n=
|
|
||||||
this._daylightSavingAdjust(new Date(o.getFullYear(),o.getMonth()-i[0]*i[1]+1,o.getDate()));for(n=k&&n<k?k:n;this._daylightSavingAdjust(new Date(m,g,1))>n;){g--;if(g<0){g=11;m--}}}a.drawMonth=g;a.drawYear=m;n=this._get(a,"prevText");n=!h?n:this.formatDate(n,this._daylightSavingAdjust(new Date(m,g-j,1)),this._getFormatConfig(a));n=this._canAdjustMonth(a,-1,m,g)?'<a class="ui-datepicker-prev ui-corner-all" onclick="DP_jQuery_'+A+".datepicker._adjustDate('#"+a.id+"', -"+j+", 'M');\" title=\""+n+'"><span class="ui-icon ui-icon-circle-triangle-'+
|
|
||||||
(c?"e":"w")+'">'+n+"</span></a>":f?"":'<a class="ui-datepicker-prev ui-corner-all ui-state-disabled" title="'+n+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"e":"w")+'">'+n+"</span></a>";var s=this._get(a,"nextText");s=!h?s:this.formatDate(s,this._daylightSavingAdjust(new Date(m,g+j,1)),this._getFormatConfig(a));f=this._canAdjustMonth(a,+1,m,g)?'<a class="ui-datepicker-next ui-corner-all" onclick="DP_jQuery_'+A+".datepicker._adjustDate('#"+a.id+"', +"+j+", 'M');\" title=\""+s+'"><span class="ui-icon ui-icon-circle-triangle-'+
|
|
||||||
(c?"w":"e")+'">'+s+"</span></a>":f?"":'<a class="ui-datepicker-next ui-corner-all ui-state-disabled" title="'+s+'"><span class="ui-icon ui-icon-circle-triangle-'+(c?"w":"e")+'">'+s+"</span></a>";j=this._get(a,"currentText");s=this._get(a,"gotoCurrent")&&a.currentDay?u:b;j=!h?j:this.formatDate(j,s,this._getFormatConfig(a));h=!a.inline?'<button type="button" class="ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all" onclick="DP_jQuery_'+A+'.datepicker._hideDatepicker();">'+this._get(a,
|
|
||||||
"closeText")+"</button>":"";e=e?'<div class="ui-datepicker-buttonpane ui-widget-content">'+(c?h:"")+(this._isInRange(a,s)?'<button type="button" class="ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all" onclick="DP_jQuery_'+A+".datepicker._gotoToday('#"+a.id+"');\">"+j+"</button>":"")+(c?"":h)+"</div>":"";h=parseInt(this._get(a,"firstDay"),10);h=isNaN(h)?0:h;j=this._get(a,"showWeek");s=this._get(a,"dayNames");this._get(a,"dayNamesShort");var q=this._get(a,"dayNamesMin"),B=
|
|
||||||
this._get(a,"monthNames"),v=this._get(a,"monthNamesShort"),p=this._get(a,"beforeShowDay"),D=this._get(a,"showOtherMonths"),K=this._get(a,"selectOtherMonths");this._get(a,"calculateWeek");for(var E=this._getDefaultDate(a),w="",x=0;x<i[0];x++){var O="";this.maxRows=4;for(var G=0;G<i[1];G++){var P=this._daylightSavingAdjust(new Date(m,g,a.selectedDay)),t=" ui-corner-all",y="";if(l){y+='<div class="ui-datepicker-group';if(i[1]>1)switch(G){case 0:y+=" ui-datepicker-group-first";t=" ui-corner-"+(c?"right":
|
|
||||||
"left");break;case i[1]-1:y+=" ui-datepicker-group-last";t=" ui-corner-"+(c?"left":"right");break;default:y+=" ui-datepicker-group-middle";t="";break}y+='">'}y+='<div class="ui-datepicker-header ui-widget-header ui-helper-clearfix'+t+'">'+(/all|left/.test(t)&&x==0?c?f:n:"")+(/all|right/.test(t)&&x==0?c?n:f:"")+this._generateMonthYearHeader(a,g,m,k,o,x>0||G>0,B,v)+'</div><table class="ui-datepicker-calendar"><thead><tr>';var z=j?'<th class="ui-datepicker-week-col">'+this._get(a,"weekHeader")+"</th>":
|
|
||||||
"";for(t=0;t<7;t++){var r=(t+h)%7;z+="<th"+((t+h+6)%7>=5?' class="ui-datepicker-week-end"':"")+'><span title="'+s[r]+'">'+q[r]+"</span></th>"}y+=z+"</tr></thead><tbody>";z=this._getDaysInMonth(m,g);if(m==a.selectedYear&&g==a.selectedMonth)a.selectedDay=Math.min(a.selectedDay,z);t=(this._getFirstDayOfMonth(m,g)-h+7)%7;z=Math.ceil((t+z)/7);this.maxRows=z=l?this.maxRows>z?this.maxRows:z:z;r=this._daylightSavingAdjust(new Date(m,g,1-t));for(var Q=0;Q<z;Q++){y+="<tr>";var R=!j?"":'<td class="ui-datepicker-week-col">'+
|
|
||||||
this._get(a,"calculateWeek")(r)+"</td>";for(t=0;t<7;t++){var I=p?p.apply(a.input?a.input[0]:null,[r]):[true,""],F=r.getMonth()!=g,L=F&&!K||!I[0]||k&&r<k||o&&r>o;R+='<td class="'+((t+h+6)%7>=5?" ui-datepicker-week-end":"")+(F?" ui-datepicker-other-month":"")+(r.getTime()==P.getTime()&&g==a.selectedMonth&&a._keyEvent||E.getTime()==r.getTime()&&E.getTime()==P.getTime()?" "+this._dayOverClass:"")+(L?" "+this._unselectableClass+" ui-state-disabled":"")+(F&&!D?"":" "+I[1]+(r.getTime()==u.getTime()?" "+
|
|
||||||
this._currentClass:"")+(r.getTime()==b.getTime()?" ui-datepicker-today":""))+'"'+((!F||D)&&I[2]?' title="'+I[2]+'"':"")+(L?"":' onclick="DP_jQuery_'+A+".datepicker._selectDay('#"+a.id+"',"+r.getMonth()+","+r.getFullYear()+', this);return false;"')+">"+(F&&!D?" ":L?'<span class="ui-state-default">'+r.getDate()+"</span>":'<a class="ui-state-default'+(r.getTime()==b.getTime()?" ui-state-highlight":"")+(r.getTime()==u.getTime()?" ui-state-active":"")+(F?" ui-priority-secondary":"")+'" href="#">'+
|
|
||||||
r.getDate()+"</a>")+"</td>";r.setDate(r.getDate()+1);r=this._daylightSavingAdjust(r)}y+=R+"</tr>"}g++;if(g>11){g=0;m++}y+="</tbody></table>"+(l?"</div>"+(i[0]>0&&G==i[1]-1?'<div class="ui-datepicker-row-break"></div>':""):"");O+=y}w+=O}w+=e+(d.browser.msie&&parseInt(d.browser.version,10)<7&&!a.inline?'<iframe src="javascript:false;" class="ui-datepicker-cover" frameborder="0"></iframe>':"");a._keyEvent=false;return w},_generateMonthYearHeader:function(a,b,c,e,f,h,i,g){var j=this._get(a,"changeMonth"),
|
|
||||||
l=this._get(a,"changeYear"),u=this._get(a,"showMonthAfterYear"),k='<div class="ui-datepicker-title">',o="";if(h||!j)o+='<span class="ui-datepicker-month">'+i[b]+"</span>";else{i=e&&e.getFullYear()==c;var m=f&&f.getFullYear()==c;o+='<select class="ui-datepicker-month" onchange="DP_jQuery_'+A+".datepicker._selectMonthYear('#"+a.id+"', this, 'M');\" onclick=\"DP_jQuery_"+A+".datepicker._clickMonthYear('#"+a.id+"');\">";for(var n=0;n<12;n++)if((!i||n>=e.getMonth())&&(!m||n<=f.getMonth()))o+='<option value="'+
|
|
||||||
n+'"'+(n==b?' selected="selected"':"")+">"+g[n]+"</option>";o+="</select>"}u||(k+=o+(h||!(j&&l)?" ":""));if(!a.yearshtml){a.yearshtml="";if(h||!l)k+='<span class="ui-datepicker-year">'+c+"</span>";else{g=this._get(a,"yearRange").split(":");var s=(new Date).getFullYear();i=function(q){q=q.match(/c[+-].*/)?c+parseInt(q.substring(1),10):q.match(/[+-].*/)?s+parseInt(q,10):parseInt(q,10);return isNaN(q)?s:q};b=i(g[0]);g=Math.max(b,i(g[1]||""));b=e?Math.max(b,e.getFullYear()):b;g=f?Math.min(g,f.getFullYear()):
|
|
||||||
g;for(a.yearshtml+='<select class="ui-datepicker-year" onchange="DP_jQuery_'+A+".datepicker._selectMonthYear('#"+a.id+"', this, 'Y');\" onclick=\"DP_jQuery_"+A+".datepicker._clickMonthYear('#"+a.id+"');\">";b<=g;b++)a.yearshtml+='<option value="'+b+'"'+(b==c?' selected="selected"':"")+">"+b+"</option>";a.yearshtml+="</select>";k+=a.yearshtml;a.yearshtml=null}}k+=this._get(a,"yearSuffix");if(u)k+=(h||!(j&&l)?" ":"")+o;k+="</div>";return k},_adjustInstDate:function(a,b,c){var e=a.drawYear+(c==
|
|
||||||
"Y"?b:0),f=a.drawMonth+(c=="M"?b:0);b=Math.min(a.selectedDay,this._getDaysInMonth(e,f))+(c=="D"?b:0);e=this._restrictMinMax(a,this._daylightSavingAdjust(new Date(e,f,b)));a.selectedDay=e.getDate();a.drawMonth=a.selectedMonth=e.getMonth();a.drawYear=a.selectedYear=e.getFullYear();if(c=="M"||c=="Y")this._notifyChange(a)},_restrictMinMax:function(a,b){var c=this._getMinMaxDate(a,"min");a=this._getMinMaxDate(a,"max");b=c&&b<c?c:b;return b=a&&b>a?a:b},_notifyChange:function(a){var b=this._get(a,"onChangeMonthYear");
|
|
||||||
if(b)b.apply(a.input?a.input[0]:null,[a.selectedYear,a.selectedMonth+1,a])},_getNumberOfMonths:function(a){a=this._get(a,"numberOfMonths");return a==null?[1,1]:typeof a=="number"?[1,a]:a},_getMinMaxDate:function(a,b){return this._determineDate(a,this._get(a,b+"Date"),null)},_getDaysInMonth:function(a,b){return 32-this._daylightSavingAdjust(new Date(a,b,32)).getDate()},_getFirstDayOfMonth:function(a,b){return(new Date(a,b,1)).getDay()},_canAdjustMonth:function(a,b,c,e){var f=this._getNumberOfMonths(a);
|
|
||||||
c=this._daylightSavingAdjust(new Date(c,e+(b<0?b:f[0]*f[1]),1));b<0&&c.setDate(this._getDaysInMonth(c.getFullYear(),c.getMonth()));return this._isInRange(a,c)},_isInRange:function(a,b){var c=this._getMinMaxDate(a,"min");a=this._getMinMaxDate(a,"max");return(!c||b.getTime()>=c.getTime())&&(!a||b.getTime()<=a.getTime())},_getFormatConfig:function(a){var b=this._get(a,"shortYearCutoff");b=typeof b!="string"?b:(new Date).getFullYear()%100+parseInt(b,10);return{shortYearCutoff:b,dayNamesShort:this._get(a,
|
|
||||||
"dayNamesShort"),dayNames:this._get(a,"dayNames"),monthNamesShort:this._get(a,"monthNamesShort"),monthNames:this._get(a,"monthNames")}},_formatDate:function(a,b,c,e){if(!b){a.currentDay=a.selectedDay;a.currentMonth=a.selectedMonth;a.currentYear=a.selectedYear}b=b?typeof b=="object"?b:this._daylightSavingAdjust(new Date(e,c,b)):this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return this.formatDate(this._get(a,"dateFormat"),b,this._getFormatConfig(a))}});d.fn.datepicker=
|
|
||||||
function(a){if(!this.length)return this;if(!d.datepicker.initialized){d(document).mousedown(d.datepicker._checkExternalClick).find("body").append(d.datepicker.dpDiv);d.datepicker.initialized=true}var b=Array.prototype.slice.call(arguments,1);if(typeof a=="string"&&(a=="isDisabled"||a=="getDate"||a=="widget"))return d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,[this[0]].concat(b));if(a=="option"&&arguments.length==2&&typeof arguments[1]=="string")return d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,
|
|
||||||
[this[0]].concat(b));return this.each(function(){typeof a=="string"?d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,[this].concat(b)):d.datepicker._attachDatepicker(this,a)})};d.datepicker=new M;d.datepicker.initialized=false;d.datepicker.uuid=(new Date).getTime();d.datepicker.version="1.8.14";window["DP_jQuery_"+A]=d})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Progressbar 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Progressbar
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.ui.core.js
|
|
||||||
* jquery.ui.widget.js
|
|
||||||
*/
|
|
||||||
(function(b,d){b.widget("ui.progressbar",{options:{value:0,max:100},min:0,_create:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min,"aria-valuemax":this.options.max,"aria-valuenow":this._value()});this.valueDiv=b("<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>").appendTo(this.element);this.oldValue=this._value();this._refreshValue()},destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow");
|
|
||||||
this.valueDiv.remove();b.Widget.prototype.destroy.apply(this,arguments)},value:function(a){if(a===d)return this._value();this._setOption("value",a);return this},_setOption:function(a,c){if(a==="value"){this.options.value=c;this._refreshValue();this._value()===this.options.max&&this._trigger("complete")}b.Widget.prototype._setOption.apply(this,arguments)},_value:function(){var a=this.options.value;if(typeof a!=="number")a=0;return Math.min(this.options.max,Math.max(this.min,a))},_percentage:function(){return 100*
|
|
||||||
this._value()/this.options.max},_refreshValue:function(){var a=this.value(),c=this._percentage();if(this.oldValue!==a){this.oldValue=a;this._trigger("change")}this.valueDiv.toggle(a>this.min).toggleClass("ui-corner-right",a===this.options.max).width(c.toFixed(0)+"%");this.element.attr("aria-valuenow",a)}});b.extend(b.ui.progressbar,{version:"1.8.14"})})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Effects 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Effects/
|
|
||||||
*/
|
|
||||||
jQuery.effects||function(f,j){function m(c){var a;if(c&&c.constructor==Array&&c.length==3)return c;if(a=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(c))return[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10)];if(a=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(c))return[parseFloat(a[1])*2.55,parseFloat(a[2])*2.55,parseFloat(a[3])*2.55];if(a=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(c))return[parseInt(a[1],
|
|
||||||
16),parseInt(a[2],16),parseInt(a[3],16)];if(a=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(c))return[parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16),parseInt(a[3]+a[3],16)];if(/rgba\(0, 0, 0, 0\)/.exec(c))return n.transparent;return n[f.trim(c).toLowerCase()]}function s(c,a){var b;do{b=f.curCSS(c,a);if(b!=""&&b!="transparent"||f.nodeName(c,"body"))break;a="backgroundColor"}while(c=c.parentNode);return m(b)}function o(){var c=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle,
|
|
||||||
a={},b,d;if(c&&c.length&&c[0]&&c[c[0]])for(var e=c.length;e--;){b=c[e];if(typeof c[b]=="string"){d=b.replace(/\-(\w)/g,function(g,h){return h.toUpperCase()});a[d]=c[b]}}else for(b in c)if(typeof c[b]==="string")a[b]=c[b];return a}function p(c){var a,b;for(a in c){b=c[a];if(b==null||f.isFunction(b)||a in t||/scrollbar/.test(a)||!/color/i.test(a)&&isNaN(parseFloat(b)))delete c[a]}return c}function u(c,a){var b={_:0},d;for(d in a)if(c[d]!=a[d])b[d]=a[d];return b}function k(c,a,b,d){if(typeof c=="object"){d=
|
|
||||||
a;b=null;a=c;c=a.effect}if(f.isFunction(a)){d=a;b=null;a={}}if(typeof a=="number"||f.fx.speeds[a]){d=b;b=a;a={}}if(f.isFunction(b)){d=b;b=null}a=a||{};b=b||a.duration;b=f.fx.off?0:typeof b=="number"?b:b in f.fx.speeds?f.fx.speeds[b]:f.fx.speeds._default;d=d||a.complete;return[c,a,b,d]}function l(c){if(!c||typeof c==="number"||f.fx.speeds[c])return true;if(typeof c==="string"&&!f.effects[c])return true;return false}f.effects={};f.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor",
|
|
||||||
"borderTopColor","borderColor","color","outlineColor"],function(c,a){f.fx.step[a]=function(b){if(!b.colorInit){b.start=s(b.elem,a);b.end=m(b.end);b.colorInit=true}b.elem.style[a]="rgb("+Math.max(Math.min(parseInt(b.pos*(b.end[0]-b.start[0])+b.start[0],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[1]-b.start[1])+b.start[1],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[2]-b.start[2])+b.start[2],10),255),0)+")"}});var n={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,
|
|
||||||
0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,
|
|
||||||
211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]},q=["add","remove","toggle"],t={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};f.effects.animateClass=function(c,a,b,
|
|
||||||
d){if(f.isFunction(b)){d=b;b=null}return this.queue(function(){var e=f(this),g=e.attr("style")||" ",h=p(o.call(this)),r,v=e.attr("class");f.each(q,function(w,i){c[i]&&e[i+"Class"](c[i])});r=p(o.call(this));e.attr("class",v);e.animate(u(h,r),{queue:false,duration:a,easing:b,complete:function(){f.each(q,function(w,i){c[i]&&e[i+"Class"](c[i])});if(typeof e.attr("style")=="object"){e.attr("style").cssText="";e.attr("style").cssText=g}else e.attr("style",g);d&&d.apply(this,arguments);f.dequeue(this)}})})};
|
|
||||||
f.fn.extend({_addClass:f.fn.addClass,addClass:function(c,a,b,d){return a?f.effects.animateClass.apply(this,[{add:c},a,b,d]):this._addClass(c)},_removeClass:f.fn.removeClass,removeClass:function(c,a,b,d){return a?f.effects.animateClass.apply(this,[{remove:c},a,b,d]):this._removeClass(c)},_toggleClass:f.fn.toggleClass,toggleClass:function(c,a,b,d,e){return typeof a=="boolean"||a===j?b?f.effects.animateClass.apply(this,[a?{add:c}:{remove:c},b,d,e]):this._toggleClass(c,a):f.effects.animateClass.apply(this,
|
|
||||||
[{toggle:c},a,b,d])},switchClass:function(c,a,b,d,e){return f.effects.animateClass.apply(this,[{add:a,remove:c},b,d,e])}});f.extend(f.effects,{version:"1.8.14",save:function(c,a){for(var b=0;b<a.length;b++)a[b]!==null&&c.data("ec.storage."+a[b],c[0].style[a[b]])},restore:function(c,a){for(var b=0;b<a.length;b++)a[b]!==null&&c.css(a[b],c.data("ec.storage."+a[b]))},setMode:function(c,a){if(a=="toggle")a=c.is(":hidden")?"show":"hide";return a},getBaseline:function(c,a){var b;switch(c[0]){case "top":b=
|
|
||||||
0;break;case "middle":b=0.5;break;case "bottom":b=1;break;default:b=c[0]/a.height}switch(c[1]){case "left":c=0;break;case "center":c=0.5;break;case "right":c=1;break;default:c=c[1]/a.width}return{x:c,y:b}},createWrapper:function(c){if(c.parent().is(".ui-effects-wrapper"))return c.parent();var a={width:c.outerWidth(true),height:c.outerHeight(true),"float":c.css("float")},b=f("<div></div>").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0});
|
|
||||||
c.wrap(b);b=c.parent();if(c.css("position")=="static"){b.css({position:"relative"});c.css({position:"relative"})}else{f.extend(a,{position:c.css("position"),zIndex:c.css("z-index")});f.each(["top","left","bottom","right"],function(d,e){a[e]=c.css(e);if(isNaN(parseInt(a[e],10)))a[e]="auto"});c.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})}return b.css(a).show()},removeWrapper:function(c){if(c.parent().is(".ui-effects-wrapper"))return c.parent().replaceWith(c);return c},setTransition:function(c,
|
|
||||||
a,b,d){d=d||{};f.each(a,function(e,g){unit=c.cssUnit(g);if(unit[0]>0)d[g]=unit[0]*b+unit[1]});return d}});f.fn.extend({effect:function(c){var a=k.apply(this,arguments),b={options:a[1],duration:a[2],callback:a[3]};a=b.options.mode;var d=f.effects[c];if(f.fx.off||!d)return a?this[a](b.duration,b.callback):this.each(function(){b.callback&&b.callback.call(this)});return d.call(this,b)},_show:f.fn.show,show:function(c){if(l(c))return this._show.apply(this,arguments);else{var a=k.apply(this,arguments);
|
|
||||||
a[1].mode="show";return this.effect.apply(this,a)}},_hide:f.fn.hide,hide:function(c){if(l(c))return this._hide.apply(this,arguments);else{var a=k.apply(this,arguments);a[1].mode="hide";return this.effect.apply(this,a)}},__toggle:f.fn.toggle,toggle:function(c){if(l(c)||typeof c==="boolean"||f.isFunction(c))return this.__toggle.apply(this,arguments);else{var a=k.apply(this,arguments);a[1].mode="toggle";return this.effect.apply(this,a)}},cssUnit:function(c){var a=this.css(c),b=[];f.each(["em","px","%",
|
|
||||||
"pt"],function(d,e){if(a.indexOf(e)>0)b=[parseFloat(a),e]});return b}});f.easing.jswing=f.easing.swing;f.extend(f.easing,{def:"easeOutQuad",swing:function(c,a,b,d,e){return f.easing[f.easing.def](c,a,b,d,e)},easeInQuad:function(c,a,b,d,e){return d*(a/=e)*a+b},easeOutQuad:function(c,a,b,d,e){return-d*(a/=e)*(a-2)+b},easeInOutQuad:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a+b;return-d/2*(--a*(a-2)-1)+b},easeInCubic:function(c,a,b,d,e){return d*(a/=e)*a*a+b},easeOutCubic:function(c,a,b,d,e){return d*
|
|
||||||
((a=a/e-1)*a*a+1)+b},easeInOutCubic:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a+b;return d/2*((a-=2)*a*a+2)+b},easeInQuart:function(c,a,b,d,e){return d*(a/=e)*a*a*a+b},easeOutQuart:function(c,a,b,d,e){return-d*((a=a/e-1)*a*a*a-1)+b},easeInOutQuart:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a*a+b;return-d/2*((a-=2)*a*a*a-2)+b},easeInQuint:function(c,a,b,d,e){return d*(a/=e)*a*a*a*a+b},easeOutQuint:function(c,a,b,d,e){return d*((a=a/e-1)*a*a*a*a+1)+b},easeInOutQuint:function(c,a,b,d,e){if((a/=
|
|
||||||
e/2)<1)return d/2*a*a*a*a*a+b;return d/2*((a-=2)*a*a*a*a+2)+b},easeInSine:function(c,a,b,d,e){return-d*Math.cos(a/e*(Math.PI/2))+d+b},easeOutSine:function(c,a,b,d,e){return d*Math.sin(a/e*(Math.PI/2))+b},easeInOutSine:function(c,a,b,d,e){return-d/2*(Math.cos(Math.PI*a/e)-1)+b},easeInExpo:function(c,a,b,d,e){return a==0?b:d*Math.pow(2,10*(a/e-1))+b},easeOutExpo:function(c,a,b,d,e){return a==e?b+d:d*(-Math.pow(2,-10*a/e)+1)+b},easeInOutExpo:function(c,a,b,d,e){if(a==0)return b;if(a==e)return b+d;if((a/=
|
|
||||||
e/2)<1)return d/2*Math.pow(2,10*(a-1))+b;return d/2*(-Math.pow(2,-10*--a)+2)+b},easeInCirc:function(c,a,b,d,e){return-d*(Math.sqrt(1-(a/=e)*a)-1)+b},easeOutCirc:function(c,a,b,d,e){return d*Math.sqrt(1-(a=a/e-1)*a)+b},easeInOutCirc:function(c,a,b,d,e){if((a/=e/2)<1)return-d/2*(Math.sqrt(1-a*a)-1)+b;return d/2*(Math.sqrt(1-(a-=2)*a)+1)+b},easeInElastic:function(c,a,b,d,e){c=1.70158;var g=0,h=d;if(a==0)return b;if((a/=e)==1)return b+d;g||(g=e*0.3);if(h<Math.abs(d)){h=d;c=g/4}else c=g/(2*Math.PI)*Math.asin(d/
|
|
||||||
h);return-(h*Math.pow(2,10*(a-=1))*Math.sin((a*e-c)*2*Math.PI/g))+b},easeOutElastic:function(c,a,b,d,e){c=1.70158;var g=0,h=d;if(a==0)return b;if((a/=e)==1)return b+d;g||(g=e*0.3);if(h<Math.abs(d)){h=d;c=g/4}else c=g/(2*Math.PI)*Math.asin(d/h);return h*Math.pow(2,-10*a)*Math.sin((a*e-c)*2*Math.PI/g)+d+b},easeInOutElastic:function(c,a,b,d,e){c=1.70158;var g=0,h=d;if(a==0)return b;if((a/=e/2)==2)return b+d;g||(g=e*0.3*1.5);if(h<Math.abs(d)){h=d;c=g/4}else c=g/(2*Math.PI)*Math.asin(d/h);if(a<1)return-0.5*
|
|
||||||
h*Math.pow(2,10*(a-=1))*Math.sin((a*e-c)*2*Math.PI/g)+b;return h*Math.pow(2,-10*(a-=1))*Math.sin((a*e-c)*2*Math.PI/g)*0.5+d+b},easeInBack:function(c,a,b,d,e,g){if(g==j)g=1.70158;return d*(a/=e)*a*((g+1)*a-g)+b},easeOutBack:function(c,a,b,d,e,g){if(g==j)g=1.70158;return d*((a=a/e-1)*a*((g+1)*a+g)+1)+b},easeInOutBack:function(c,a,b,d,e,g){if(g==j)g=1.70158;if((a/=e/2)<1)return d/2*a*a*(((g*=1.525)+1)*a-g)+b;return d/2*((a-=2)*a*(((g*=1.525)+1)*a+g)+2)+b},easeInBounce:function(c,a,b,d,e){return d-f.easing.easeOutBounce(c,
|
|
||||||
e-a,0,d,e)+b},easeOutBounce:function(c,a,b,d,e){return(a/=e)<1/2.75?d*7.5625*a*a+b:a<2/2.75?d*(7.5625*(a-=1.5/2.75)*a+0.75)+b:a<2.5/2.75?d*(7.5625*(a-=2.25/2.75)*a+0.9375)+b:d*(7.5625*(a-=2.625/2.75)*a+0.984375)+b},easeInOutBounce:function(c,a,b,d,e){if(a<e/2)return f.easing.easeInBounce(c,a*2,0,d,e)*0.5+b;return f.easing.easeOutBounce(c,a*2-e,0,d,e)*0.5+d*0.5+b}})}(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Effects Blind 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Effects/Blind
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.effects.core.js
|
|
||||||
*/
|
|
||||||
(function(b){b.effects.blind=function(c){return this.queue(function(){var a=b(this),g=["position","top","bottom","left","right"],f=b.effects.setMode(a,c.options.mode||"hide"),d=c.options.direction||"vertical";b.effects.save(a,g);a.show();var e=b.effects.createWrapper(a).css({overflow:"hidden"}),h=d=="vertical"?"height":"width";d=d=="vertical"?e.height():e.width();f=="show"&&e.css(h,0);var i={};i[h]=f=="show"?d:0;e.animate(i,c.duration,c.options.easing,function(){f=="hide"&&a.hide();b.effects.restore(a,
|
|
||||||
g);b.effects.removeWrapper(a);c.callback&&c.callback.apply(a[0],arguments);a.dequeue()})})}})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Effects Bounce 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Effects/Bounce
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.effects.core.js
|
|
||||||
*/
|
|
||||||
(function(e){e.effects.bounce=function(b){return this.queue(function(){var a=e(this),l=["position","top","bottom","left","right"],h=e.effects.setMode(a,b.options.mode||"effect"),d=b.options.direction||"up",c=b.options.distance||20,m=b.options.times||5,i=b.duration||250;/show|hide/.test(h)&&l.push("opacity");e.effects.save(a,l);a.show();e.effects.createWrapper(a);var f=d=="up"||d=="down"?"top":"left";d=d=="up"||d=="left"?"pos":"neg";c=b.options.distance||(f=="top"?a.outerHeight({margin:true})/3:a.outerWidth({margin:true})/
|
|
||||||
3);if(h=="show")a.css("opacity",0).css(f,d=="pos"?-c:c);if(h=="hide")c/=m*2;h!="hide"&&m--;if(h=="show"){var g={opacity:1};g[f]=(d=="pos"?"+=":"-=")+c;a.animate(g,i/2,b.options.easing);c/=2;m--}for(g=0;g<m;g++){var j={},k={};j[f]=(d=="pos"?"-=":"+=")+c;k[f]=(d=="pos"?"+=":"-=")+c;a.animate(j,i/2,b.options.easing).animate(k,i/2,b.options.easing);c=h=="hide"?c*2:c/2}if(h=="hide"){g={opacity:0};g[f]=(d=="pos"?"-=":"+=")+c;a.animate(g,i/2,b.options.easing,function(){a.hide();e.effects.restore(a,l);e.effects.removeWrapper(a);
|
|
||||||
b.callback&&b.callback.apply(this,arguments)})}else{j={};k={};j[f]=(d=="pos"?"-=":"+=")+c;k[f]=(d=="pos"?"+=":"-=")+c;a.animate(j,i/2,b.options.easing).animate(k,i/2,b.options.easing,function(){e.effects.restore(a,l);e.effects.removeWrapper(a);b.callback&&b.callback.apply(this,arguments)})}a.queue("fx",function(){a.dequeue()});a.dequeue()})}})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Effects Clip 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Effects/Clip
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.effects.core.js
|
|
||||||
*/
|
|
||||||
(function(b){b.effects.clip=function(e){return this.queue(function(){var a=b(this),i=["position","top","bottom","left","right","height","width"],f=b.effects.setMode(a,e.options.mode||"hide"),c=e.options.direction||"vertical";b.effects.save(a,i);a.show();var d=b.effects.createWrapper(a).css({overflow:"hidden"});d=a[0].tagName=="IMG"?d:a;var g={size:c=="vertical"?"height":"width",position:c=="vertical"?"top":"left"};c=c=="vertical"?d.height():d.width();if(f=="show"){d.css(g.size,0);d.css(g.position,
|
|
||||||
c/2)}var h={};h[g.size]=f=="show"?c:0;h[g.position]=f=="show"?0:c/2;d.animate(h,{queue:false,duration:e.duration,easing:e.options.easing,complete:function(){f=="hide"&&a.hide();b.effects.restore(a,i);b.effects.removeWrapper(a);e.callback&&e.callback.apply(a[0],arguments);a.dequeue()}})})}})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Effects Drop 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Effects/Drop
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.effects.core.js
|
|
||||||
*/
|
|
||||||
(function(c){c.effects.drop=function(d){return this.queue(function(){var a=c(this),h=["position","top","bottom","left","right","opacity"],e=c.effects.setMode(a,d.options.mode||"hide"),b=d.options.direction||"left";c.effects.save(a,h);a.show();c.effects.createWrapper(a);var f=b=="up"||b=="down"?"top":"left";b=b=="up"||b=="left"?"pos":"neg";var g=d.options.distance||(f=="top"?a.outerHeight({margin:true})/2:a.outerWidth({margin:true})/2);if(e=="show")a.css("opacity",0).css(f,b=="pos"?-g:g);var i={opacity:e==
|
|
||||||
"show"?1:0};i[f]=(e=="show"?b=="pos"?"+=":"-=":b=="pos"?"-=":"+=")+g;a.animate(i,{queue:false,duration:d.duration,easing:d.options.easing,complete:function(){e=="hide"&&a.hide();c.effects.restore(a,h);c.effects.removeWrapper(a);d.callback&&d.callback.apply(this,arguments);a.dequeue()}})})}})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Effects Explode 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Effects/Explode
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.effects.core.js
|
|
||||||
*/
|
|
||||||
(function(j){j.effects.explode=function(a){return this.queue(function(){var c=a.options.pieces?Math.round(Math.sqrt(a.options.pieces)):3,d=a.options.pieces?Math.round(Math.sqrt(a.options.pieces)):3;a.options.mode=a.options.mode=="toggle"?j(this).is(":visible")?"hide":"show":a.options.mode;var b=j(this).show().css("visibility","hidden"),g=b.offset();g.top-=parseInt(b.css("marginTop"),10)||0;g.left-=parseInt(b.css("marginLeft"),10)||0;for(var h=b.outerWidth(true),i=b.outerHeight(true),e=0;e<c;e++)for(var f=
|
|
||||||
0;f<d;f++)b.clone().appendTo("body").wrap("<div></div>").css({position:"absolute",visibility:"visible",left:-f*(h/d),top:-e*(i/c)}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:h/d,height:i/c,left:g.left+f*(h/d)+(a.options.mode=="show"?(f-Math.floor(d/2))*(h/d):0),top:g.top+e*(i/c)+(a.options.mode=="show"?(e-Math.floor(c/2))*(i/c):0),opacity:a.options.mode=="show"?0:1}).animate({left:g.left+f*(h/d)+(a.options.mode=="show"?0:(f-Math.floor(d/2))*(h/d)),top:g.top+
|
|
||||||
e*(i/c)+(a.options.mode=="show"?0:(e-Math.floor(c/2))*(i/c)),opacity:a.options.mode=="show"?1:0},a.duration||500);setTimeout(function(){a.options.mode=="show"?b.css({visibility:"visible"}):b.css({visibility:"visible"}).hide();a.callback&&a.callback.apply(b[0]);b.dequeue();j("div.ui-effects-explode").remove()},a.duration||500)})}})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Effects Fade 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Effects/Fade
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.effects.core.js
|
|
||||||
*/
|
|
||||||
(function(b){b.effects.fade=function(a){return this.queue(function(){var c=b(this),d=b.effects.setMode(c,a.options.mode||"hide");c.animate({opacity:d},{queue:false,duration:a.duration,easing:a.options.easing,complete:function(){a.callback&&a.callback.apply(this,arguments);c.dequeue()}})})}})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Effects Fold 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Effects/Fold
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.effects.core.js
|
|
||||||
*/
|
|
||||||
(function(c){c.effects.fold=function(a){return this.queue(function(){var b=c(this),j=["position","top","bottom","left","right"],d=c.effects.setMode(b,a.options.mode||"hide"),g=a.options.size||15,h=!!a.options.horizFirst,k=a.duration?a.duration/2:c.fx.speeds._default/2;c.effects.save(b,j);b.show();var e=c.effects.createWrapper(b).css({overflow:"hidden"}),f=d=="show"!=h,l=f?["width","height"]:["height","width"];f=f?[e.width(),e.height()]:[e.height(),e.width()];var i=/([0-9]+)%/.exec(g);if(i)g=parseInt(i[1],
|
|
||||||
10)/100*f[d=="hide"?0:1];if(d=="show")e.css(h?{height:0,width:g}:{height:g,width:0});h={};i={};h[l[0]]=d=="show"?f[0]:g;i[l[1]]=d=="show"?f[1]:0;e.animate(h,k,a.options.easing).animate(i,k,a.options.easing,function(){d=="hide"&&b.hide();c.effects.restore(b,j);c.effects.removeWrapper(b);a.callback&&a.callback.apply(b[0],arguments);b.dequeue()})})}})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Effects Highlight 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Effects/Highlight
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.effects.core.js
|
|
||||||
*/
|
|
||||||
(function(b){b.effects.highlight=function(c){return this.queue(function(){var a=b(this),e=["backgroundImage","backgroundColor","opacity"],d=b.effects.setMode(a,c.options.mode||"show"),f={backgroundColor:a.css("backgroundColor")};if(d=="hide")f.opacity=0;b.effects.save(a,e);a.show().css({backgroundImage:"none",backgroundColor:c.options.color||"#ffff99"}).animate(f,{queue:false,duration:c.duration,easing:c.options.easing,complete:function(){d=="hide"&&a.hide();b.effects.restore(a,e);d=="show"&&!b.support.opacity&&
|
|
||||||
this.style.removeAttribute("filter");c.callback&&c.callback.apply(this,arguments);a.dequeue()}})})}})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Effects Pulsate 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Effects/Pulsate
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.effects.core.js
|
|
||||||
*/
|
|
||||||
(function(d){d.effects.pulsate=function(a){return this.queue(function(){var b=d(this),c=d.effects.setMode(b,a.options.mode||"show");times=(a.options.times||5)*2-1;duration=a.duration?a.duration/2:d.fx.speeds._default/2;isVisible=b.is(":visible");animateTo=0;if(!isVisible){b.css("opacity",0).show();animateTo=1}if(c=="hide"&&isVisible||c=="show"&&!isVisible)times--;for(c=0;c<times;c++){b.animate({opacity:animateTo},duration,a.options.easing);animateTo=(animateTo+1)%2}b.animate({opacity:animateTo},duration,
|
|
||||||
a.options.easing,function(){animateTo==0&&b.hide();a.callback&&a.callback.apply(this,arguments)});b.queue("fx",function(){b.dequeue()}).dequeue()})}})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Effects Scale 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Effects/Scale
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.effects.core.js
|
|
||||||
*/
|
|
||||||
(function(c){c.effects.puff=function(b){return this.queue(function(){var a=c(this),e=c.effects.setMode(a,b.options.mode||"hide"),g=parseInt(b.options.percent,10)||150,h=g/100,i={height:a.height(),width:a.width()};c.extend(b.options,{fade:true,mode:e,percent:e=="hide"?g:100,from:e=="hide"?i:{height:i.height*h,width:i.width*h}});a.effect("scale",b.options,b.duration,b.callback);a.dequeue()})};c.effects.scale=function(b){return this.queue(function(){var a=c(this),e=c.extend(true,{},b.options),g=c.effects.setMode(a,
|
|
||||||
b.options.mode||"effect"),h=parseInt(b.options.percent,10)||(parseInt(b.options.percent,10)==0?0:g=="hide"?0:100),i=b.options.direction||"both",f=b.options.origin;if(g!="effect"){e.origin=f||["middle","center"];e.restore=true}f={height:a.height(),width:a.width()};a.from=b.options.from||(g=="show"?{height:0,width:0}:f);h={y:i!="horizontal"?h/100:1,x:i!="vertical"?h/100:1};a.to={height:f.height*h.y,width:f.width*h.x};if(b.options.fade){if(g=="show"){a.from.opacity=0;a.to.opacity=1}if(g=="hide"){a.from.opacity=
|
|
||||||
1;a.to.opacity=0}}e.from=a.from;e.to=a.to;e.mode=g;a.effect("size",e,b.duration,b.callback);a.dequeue()})};c.effects.size=function(b){return this.queue(function(){var a=c(this),e=["position","top","bottom","left","right","width","height","overflow","opacity"],g=["position","top","bottom","left","right","overflow","opacity"],h=["width","height","overflow"],i=["fontSize"],f=["borderTopWidth","borderBottomWidth","paddingTop","paddingBottom"],k=["borderLeftWidth","borderRightWidth","paddingLeft","paddingRight"],
|
|
||||||
p=c.effects.setMode(a,b.options.mode||"effect"),n=b.options.restore||false,m=b.options.scale||"both",l=b.options.origin,j={height:a.height(),width:a.width()};a.from=b.options.from||j;a.to=b.options.to||j;if(l){l=c.effects.getBaseline(l,j);a.from.top=(j.height-a.from.height)*l.y;a.from.left=(j.width-a.from.width)*l.x;a.to.top=(j.height-a.to.height)*l.y;a.to.left=(j.width-a.to.width)*l.x}var d={from:{y:a.from.height/j.height,x:a.from.width/j.width},to:{y:a.to.height/j.height,x:a.to.width/j.width}};
|
|
||||||
if(m=="box"||m=="both"){if(d.from.y!=d.to.y){e=e.concat(f);a.from=c.effects.setTransition(a,f,d.from.y,a.from);a.to=c.effects.setTransition(a,f,d.to.y,a.to)}if(d.from.x!=d.to.x){e=e.concat(k);a.from=c.effects.setTransition(a,k,d.from.x,a.from);a.to=c.effects.setTransition(a,k,d.to.x,a.to)}}if(m=="content"||m=="both")if(d.from.y!=d.to.y){e=e.concat(i);a.from=c.effects.setTransition(a,i,d.from.y,a.from);a.to=c.effects.setTransition(a,i,d.to.y,a.to)}c.effects.save(a,n?e:g);a.show();c.effects.createWrapper(a);
|
|
||||||
a.css("overflow","hidden").css(a.from);if(m=="content"||m=="both"){f=f.concat(["marginTop","marginBottom"]).concat(i);k=k.concat(["marginLeft","marginRight"]);h=e.concat(f).concat(k);a.find("*[width]").each(function(){child=c(this);n&&c.effects.save(child,h);var o={height:child.height(),width:child.width()};child.from={height:o.height*d.from.y,width:o.width*d.from.x};child.to={height:o.height*d.to.y,width:o.width*d.to.x};if(d.from.y!=d.to.y){child.from=c.effects.setTransition(child,f,d.from.y,child.from);
|
|
||||||
child.to=c.effects.setTransition(child,f,d.to.y,child.to)}if(d.from.x!=d.to.x){child.from=c.effects.setTransition(child,k,d.from.x,child.from);child.to=c.effects.setTransition(child,k,d.to.x,child.to)}child.css(child.from);child.animate(child.to,b.duration,b.options.easing,function(){n&&c.effects.restore(child,h)})})}a.animate(a.to,{queue:false,duration:b.duration,easing:b.options.easing,complete:function(){a.to.opacity===0&&a.css("opacity",a.from.opacity);p=="hide"&&a.hide();c.effects.restore(a,
|
|
||||||
n?e:g);c.effects.removeWrapper(a);b.callback&&b.callback.apply(this,arguments);a.dequeue()}})})}})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Effects Shake 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Effects/Shake
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.effects.core.js
|
|
||||||
*/
|
|
||||||
(function(d){d.effects.shake=function(a){return this.queue(function(){var b=d(this),j=["position","top","bottom","left","right"];d.effects.setMode(b,a.options.mode||"effect");var c=a.options.direction||"left",e=a.options.distance||20,l=a.options.times||3,f=a.duration||a.options.duration||140;d.effects.save(b,j);b.show();d.effects.createWrapper(b);var g=c=="up"||c=="down"?"top":"left",h=c=="up"||c=="left"?"pos":"neg";c={};var i={},k={};c[g]=(h=="pos"?"-=":"+=")+e;i[g]=(h=="pos"?"+=":"-=")+e*2;k[g]=
|
|
||||||
(h=="pos"?"-=":"+=")+e*2;b.animate(c,f,a.options.easing);for(e=1;e<l;e++)b.animate(i,f,a.options.easing).animate(k,f,a.options.easing);b.animate(i,f,a.options.easing).animate(c,f/2,a.options.easing,function(){d.effects.restore(b,j);d.effects.removeWrapper(b);a.callback&&a.callback.apply(this,arguments)});b.queue("fx",function(){b.dequeue()});b.dequeue()})}})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Effects Slide 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Effects/Slide
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.effects.core.js
|
|
||||||
*/
|
|
||||||
(function(c){c.effects.slide=function(d){return this.queue(function(){var a=c(this),h=["position","top","bottom","left","right"],f=c.effects.setMode(a,d.options.mode||"show"),b=d.options.direction||"left";c.effects.save(a,h);a.show();c.effects.createWrapper(a).css({overflow:"hidden"});var g=b=="up"||b=="down"?"top":"left";b=b=="up"||b=="left"?"pos":"neg";var e=d.options.distance||(g=="top"?a.outerHeight({margin:true}):a.outerWidth({margin:true}));if(f=="show")a.css(g,b=="pos"?isNaN(e)?"-"+e:-e:e);
|
|
||||||
var i={};i[g]=(f=="show"?b=="pos"?"+=":"-=":b=="pos"?"-=":"+=")+e;a.animate(i,{queue:false,duration:d.duration,easing:d.options.easing,complete:function(){f=="hide"&&a.hide();c.effects.restore(a,h);c.effects.removeWrapper(a);d.callback&&d.callback.apply(this,arguments);a.dequeue()}})})}})(jQuery);
|
|
||||||
;/*
|
|
||||||
* jQuery UI Effects Transfer 1.8.14
|
|
||||||
*
|
|
||||||
* Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
* http://jquery.org/license
|
|
||||||
*
|
|
||||||
* http://docs.jquery.com/UI/Effects/Transfer
|
|
||||||
*
|
|
||||||
* Depends:
|
|
||||||
* jquery.effects.core.js
|
|
||||||
*/
|
|
||||||
(function(e){e.effects.transfer=function(a){return this.queue(function(){var b=e(this),c=e(a.options.to),d=c.offset();c={top:d.top,left:d.left,height:c.innerHeight(),width:c.innerWidth()};d=b.offset();var f=e('<div class="ui-effects-transfer"></div>').appendTo(document.body).addClass(a.options.className).css({top:d.top,left:d.left,height:b.innerHeight(),width:b.innerWidth(),position:"absolute"}).animate(c,a.duration,a.options.easing,function(){f.remove();a.callback&&a.callback.apply(b[0],arguments);
|
|
||||||
b.dequeue()})})}})(jQuery);
|
|
||||||
;
|
|
||||||
19
build/javascripts/jquery.ba-bbq.min.js
vendored
19
build/javascripts/jquery.ba-bbq.min.js
vendored
@@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
* jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010
|
|
||||||
* http://benalman.com/projects/jquery-bbq-plugin/
|
|
||||||
*
|
|
||||||
* Copyright (c) 2010 "Cowboy" Ben Alman
|
|
||||||
* Dual licensed under the MIT and GPL licenses.
|
|
||||||
* http://benalman.com/about/license/
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M<N?O[P]||(R[M+1]&&isNaN(R[M+1])?{}:[]):J}}else{if($.isArray(H[P])){H[P].push(J)}else{if(H[P]!==i){H[P]=[H[P],J]}else{H[P]=J}}}}else{if(P){H[P]=F?i:""}}});return H};function z(H,F,G){if(F===i||typeof F==="boolean"){G=F;F=a[H?D:A]()}else{F=E(F)?F.replace(H?w:x,""):F}return l(F,G)}l[A]=B(z,0);l[D]=v=B(z,1);$[y]||($[y]=function(F){return $.extend(C,F)})({a:k,base:k,iframe:t,img:t,input:t,form:"action",link:k,script:t});j=$[y];function s(I,G,H,F){if(!E(H)&&typeof H!=="object"){F=H;H=G;G=i}return this.each(function(){var L=$(this),J=G||j()[(this.nodeName||"").toLowerCase()]||"",K=J&&L.attr(J)||"";L.attr(J,a[I](K,H,F))})}$.fn[A]=B(s,A);$.fn[D]=B(s,D);b.pushState=q=function(I,F){if(E(I)&&/^#/.test(I)&&F===i){F=2}var H=I!==i,G=c(p[g][k],H?I:{},H?F:2);p[g][k]=G+(/#/.test(G)?"":"#")};b.getState=u=function(F,G){return F===i||typeof F==="boolean"?v(F):v(G)[F]};b.removeState=function(F){var G={};if(F!==i){G=u();$.each($.isArray(F)?F:arguments,function(I,H){delete G[H]})}q(G,2)};e[d]=$.extend(e[d],{add:function(F){var H;function G(J){var I=J[D]=c();J.getState=function(K,L){return K===i||typeof K==="boolean"?l(I,K):l(I,L)[K]};H.apply(this,arguments)}if($.isFunction(F)){H=F;return G}else{H=F.handler;F.handler=G}}})})(jQuery,this);
|
|
||||||
/*
|
|
||||||
* jQuery hashchange event - v1.2 - 2/11/2010
|
|
||||||
* http://benalman.com/projects/jquery-hashchange-plugin/
|
|
||||||
*
|
|
||||||
* Copyright (c) 2010 "Cowboy" Ben Alman
|
|
||||||
* Dual licensed under the MIT and GPL licenses.
|
|
||||||
* http://benalman.com/about/license/
|
|
||||||
*/
|
|
||||||
(function($,i,b){var j,k=$.event.special,c="location",d="hashchange",l="href",f=$.browser,g=document.documentMode,h=f.msie&&(g===b||g<8),e="on"+d in i&&!h;function a(m){m=m||i[c][l];return m.replace(/^[^#]*#?(.*)$/,"$1")}$[d+"Delay"]=100;k[d]=$.extend(k[d],{setup:function(){if(e){return false}$(j.start)},teardown:function(){if(e){return false}$(j.stop)}});j=(function(){var m={},r,n,o,q;function p(){o=q=function(s){return s};if(h){n=$('<iframe src="javascript:0"/>').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this);
|
|
||||||
@@ -1,492 +0,0 @@
|
|||||||
/*
|
|
||||||
* jQuery Templating Plugin
|
|
||||||
* Copyright 2010, John Resig
|
|
||||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function(jQuery, undefined) {
|
|
||||||
var oldManip = jQuery.fn.domManip, tmplItmAtt = "_tmplitem", htmlExpr = /^[^<]*(<[\w\W]+>)[^>]*$|\{\{\! /,
|
|
||||||
newTmplItems = {}, wrappedItems = {}, appendToTmplItems, topTmplItem = { key: 0, data: {} }, itemKey = 0, cloneIndex = 0, stack = [];
|
|
||||||
|
|
||||||
function newTmplItem(options, parentItem, fn, data) {
|
|
||||||
// Returns a template item data structure for a new rendered instance of a template (a 'template item').
|
|
||||||
// The content field is a hierarchical array of strings and nested items (to be
|
|
||||||
// removed and replaced by nodes field of dom elements, once inserted in DOM).
|
|
||||||
var newItem = {
|
|
||||||
data: data || (parentItem ? parentItem.data : {}),
|
|
||||||
_wrap: parentItem ? parentItem._wrap : null,
|
|
||||||
tmpl: null,
|
|
||||||
parent: parentItem || null,
|
|
||||||
nodes: [],
|
|
||||||
calls: tiCalls,
|
|
||||||
nest: tiNest,
|
|
||||||
wrap: tiWrap,
|
|
||||||
html: tiHtml,
|
|
||||||
update: tiUpdate
|
|
||||||
};
|
|
||||||
if (options) {
|
|
||||||
jQuery.extend(newItem, options, { nodes: [], parent: parentItem });
|
|
||||||
}
|
|
||||||
if (fn) {
|
|
||||||
// Build the hierarchical content to be used during insertion into DOM
|
|
||||||
newItem.tmpl = fn;
|
|
||||||
newItem._ctnt = newItem._ctnt || newItem.tmpl(jQuery, newItem);
|
|
||||||
newItem.key = ++itemKey;
|
|
||||||
// Keep track of new template item, until it is stored as jQuery Data on DOM element
|
|
||||||
(stack.length ? wrappedItems : newTmplItems)[itemKey] = newItem;
|
|
||||||
}
|
|
||||||
return newItem;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Override appendTo etc., in order to provide support for targeting multiple elements. (This code would disappear if integrated in jquery core).
|
|
||||||
jQuery.each({
|
|
||||||
appendTo: "append",
|
|
||||||
prependTo: "prepend",
|
|
||||||
insertBefore: "before",
|
|
||||||
insertAfter: "after",
|
|
||||||
replaceAll: "replaceWith"
|
|
||||||
}, function(name, original) {
|
|
||||||
jQuery.fn[ name ] = function(selector) {
|
|
||||||
var ret = [], insert = jQuery(selector), elems, i, l, tmplItems,
|
|
||||||
parent = this.length === 1 && this[0].parentNode;
|
|
||||||
|
|
||||||
appendToTmplItems = newTmplItems || {};
|
|
||||||
if (parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1) {
|
|
||||||
insert[ original ](this[0]);
|
|
||||||
ret = this;
|
|
||||||
} else {
|
|
||||||
for (i = 0,l = insert.length; i < l; i++) {
|
|
||||||
cloneIndex = i;
|
|
||||||
elems = (i > 0 ? this.clone(true) : this).get();
|
|
||||||
jQuery.fn[ original ].apply(jQuery(insert[i]), elems);
|
|
||||||
ret = ret.concat(elems);
|
|
||||||
}
|
|
||||||
cloneIndex = 0;
|
|
||||||
ret = this.pushStack(ret, name, insert.selector);
|
|
||||||
}
|
|
||||||
tmplItems = appendToTmplItems;
|
|
||||||
appendToTmplItems = null;
|
|
||||||
jQuery.tmpl.complete(tmplItems);
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery.fn.extend({
|
|
||||||
// Use first wrapped element as template markup.
|
|
||||||
// Return wrapped set of template items, obtained by rendering template against data.
|
|
||||||
tmpl: function(data, options, parentItem) {
|
|
||||||
return jQuery.tmpl(this[0], data, options, parentItem);
|
|
||||||
},
|
|
||||||
|
|
||||||
// Find which rendered template item the first wrapped DOM element belongs to
|
|
||||||
tmplItem: function() {
|
|
||||||
return jQuery.tmplItem(this[0]);
|
|
||||||
},
|
|
||||||
|
|
||||||
// Consider the first wrapped element as a template declaration, and get the compiled template or store it as a named template.
|
|
||||||
template: function(name) {
|
|
||||||
return jQuery.template(name, this[0]);
|
|
||||||
},
|
|
||||||
|
|
||||||
domManip: function(args, table, callback, options) {
|
|
||||||
// This appears to be a bug in the appendTo, etc. implementation
|
|
||||||
// it should be doing .call() instead of .apply(). See #6227
|
|
||||||
if (args[0] && args[0].nodeType) {
|
|
||||||
var dmArgs = jQuery.makeArray(arguments), argsLength = args.length, i = 0, tmplItem;
|
|
||||||
while (i < argsLength && !(tmplItem = jQuery.data(args[i++], "tmplItem"))) {
|
|
||||||
}
|
|
||||||
if (argsLength > 1) {
|
|
||||||
dmArgs[0] = [jQuery.makeArray(args)];
|
|
||||||
}
|
|
||||||
if (tmplItem && cloneIndex) {
|
|
||||||
dmArgs[2] = function(fragClone) {
|
|
||||||
// Handler called by oldManip when rendered template has been inserted into DOM.
|
|
||||||
jQuery.tmpl.afterManip(this, fragClone, callback);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
oldManip.apply(this, dmArgs);
|
|
||||||
} else {
|
|
||||||
oldManip.apply(this, arguments);
|
|
||||||
}
|
|
||||||
cloneIndex = 0;
|
|
||||||
if (!appendToTmplItems) {
|
|
||||||
jQuery.tmpl.complete(newTmplItems);
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery.extend({
|
|
||||||
// Return wrapped set of template items, obtained by rendering template against data.
|
|
||||||
tmpl: function(tmpl, data, options, parentItem) {
|
|
||||||
var ret, topLevel = !parentItem;
|
|
||||||
if (topLevel) {
|
|
||||||
// This is a top-level tmpl call (not from a nested template using {{tmpl}})
|
|
||||||
parentItem = topTmplItem;
|
|
||||||
tmpl = jQuery.template[tmpl] || jQuery.template(null, tmpl);
|
|
||||||
wrappedItems = {}; // Any wrapped items will be rebuilt, since this is top level
|
|
||||||
} else if (!tmpl) {
|
|
||||||
// The template item is already associated with DOM - this is a refresh.
|
|
||||||
// Re-evaluate rendered template for the parentItem
|
|
||||||
tmpl = parentItem.tmpl;
|
|
||||||
newTmplItems[parentItem.key] = parentItem;
|
|
||||||
parentItem.nodes = [];
|
|
||||||
if (parentItem.wrapped) {
|
|
||||||
updateWrapped(parentItem, parentItem.wrapped);
|
|
||||||
}
|
|
||||||
// Rebuild, without creating a new template item
|
|
||||||
return jQuery(build(parentItem, null, parentItem.tmpl(jQuery, parentItem)));
|
|
||||||
}
|
|
||||||
if (!tmpl) {
|
|
||||||
return []; // Could throw...
|
|
||||||
}
|
|
||||||
if (typeof data === "function") {
|
|
||||||
data = data.call(parentItem || {});
|
|
||||||
}
|
|
||||||
if (options && options.wrapped) {
|
|
||||||
updateWrapped(options, options.wrapped);
|
|
||||||
}
|
|
||||||
ret = jQuery.isArray(data) ?
|
|
||||||
jQuery.map(data, function(dataItem) {
|
|
||||||
return dataItem ? newTmplItem(options, parentItem, tmpl, dataItem) : null;
|
|
||||||
}) :
|
|
||||||
[ newTmplItem(options, parentItem, tmpl, data) ];
|
|
||||||
return topLevel ? jQuery(build(parentItem, null, ret)) : ret;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Return rendered template item for an element.
|
|
||||||
tmplItem: function(elem) {
|
|
||||||
var tmplItem;
|
|
||||||
if (elem instanceof jQuery) {
|
|
||||||
elem = elem[0];
|
|
||||||
}
|
|
||||||
while (elem && elem.nodeType === 1 && !(tmplItem = jQuery.data(elem, "tmplItem")) && (elem = elem.parentNode)) {
|
|
||||||
}
|
|
||||||
return tmplItem || topTmplItem;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Set:
|
|
||||||
// Use $.template( name, tmpl ) to cache a named template,
|
|
||||||
// where tmpl is a template string, a script element or a jQuery instance wrapping a script element, etc.
|
|
||||||
// Use $( "selector" ).template( name ) to provide access by name to a script block template declaration.
|
|
||||||
|
|
||||||
// Get:
|
|
||||||
// Use $.template( name ) to access a cached template.
|
|
||||||
// Also $( selectorToScriptBlock ).template(), or $.template( null, templateString )
|
|
||||||
// will return the compiled template, without adding a name reference.
|
|
||||||
// If templateString includes at least one HTML tag, $.template( templateString ) is equivalent
|
|
||||||
// to $.template( null, templateString )
|
|
||||||
template: function(name, tmpl) {
|
|
||||||
if (tmpl) {
|
|
||||||
// Compile template and associate with name
|
|
||||||
if (typeof tmpl === "string") {
|
|
||||||
// This is an HTML string being passed directly in.
|
|
||||||
tmpl = buildTmplFn(tmpl)
|
|
||||||
} else if (tmpl instanceof jQuery) {
|
|
||||||
tmpl = tmpl[0] || {};
|
|
||||||
}
|
|
||||||
if (tmpl.nodeType) {
|
|
||||||
// If this is a template block, use cached copy, or generate tmpl function and cache.
|
|
||||||
tmpl = jQuery.data(tmpl, "tmpl") || jQuery.data(tmpl, "tmpl", buildTmplFn(tmpl.innerHTML));
|
|
||||||
}
|
|
||||||
return typeof name === "string" ? (jQuery.template[name] = tmpl) : tmpl;
|
|
||||||
}
|
|
||||||
// Return named compiled template
|
|
||||||
return name ? (typeof name !== "string" ? jQuery.template(null, name) :
|
|
||||||
(jQuery.template[name] ||
|
|
||||||
// If not in map, treat as a selector. (If integrated with core, use quickExpr.exec)
|
|
||||||
jQuery.template(null, htmlExpr.test(name) ? name : jQuery(name)))) : null;
|
|
||||||
},
|
|
||||||
|
|
||||||
encode: function(text) {
|
|
||||||
// Do HTML encoding replacing < > & and ' and " by corresponding entities.
|
|
||||||
return ("" + text).split("<").join("<").split(">").join(">").split('"').join(""").split("'").join("'");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery.extend(jQuery.tmpl, {
|
|
||||||
tag: {
|
|
||||||
"tmpl": {
|
|
||||||
_default: { $2: "null" },
|
|
||||||
open: "if($notnull_1){_=_.concat($item.nest($1,$2));}"
|
|
||||||
// tmpl target parameter can be of type function, so use $1, not $1a (so not auto detection of functions)
|
|
||||||
// This means that {{tmpl foo}} treats foo as a template (which IS a function).
|
|
||||||
// Explicit parens can be used if foo is a function that returns a template: {{tmpl foo()}}.
|
|
||||||
},
|
|
||||||
"wrap": {
|
|
||||||
_default: { $2: "null" },
|
|
||||||
open: "$item.calls(_,$1,$2);_=[];",
|
|
||||||
close: "call=$item.calls();_=call._.concat($item.wrap(call,_));"
|
|
||||||
},
|
|
||||||
"each": {
|
|
||||||
_default: { $2: "$index, $value" },
|
|
||||||
open: "if($notnull_1){$.each($1a,function($2){with(this){",
|
|
||||||
close: "}});}"
|
|
||||||
},
|
|
||||||
"if": {
|
|
||||||
open: "if(($notnull_1) && $1a){",
|
|
||||||
close: "}"
|
|
||||||
},
|
|
||||||
"else": {
|
|
||||||
_default: { $1: "true" },
|
|
||||||
open: "}else if(($notnull_1) && $1a){"
|
|
||||||
},
|
|
||||||
"html": {
|
|
||||||
// Unecoded expression evaluation.
|
|
||||||
open: "if($notnull_1){_.push($1a);}"
|
|
||||||
},
|
|
||||||
"=": {
|
|
||||||
// Encoded expression evaluation. Abbreviated form is ${}.
|
|
||||||
_default: { $1: "$data" },
|
|
||||||
open: "if($notnull_1){_.push($.encode($1a));}"
|
|
||||||
},
|
|
||||||
"!": {
|
|
||||||
// Comment tag. Skipped by parser
|
|
||||||
open: ""
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// This stub can be overridden, e.g. in jquery.tmplPlus for providing rendered events
|
|
||||||
complete: function(items) {
|
|
||||||
newTmplItems = {};
|
|
||||||
},
|
|
||||||
|
|
||||||
// Call this from code which overrides domManip, or equivalent
|
|
||||||
// Manage cloning/storing template items etc.
|
|
||||||
afterManip: function afterManip(elem, fragClone, callback) {
|
|
||||||
// Provides cloned fragment ready for fixup prior to and after insertion into DOM
|
|
||||||
var content = fragClone.nodeType === 11 ?
|
|
||||||
jQuery.makeArray(fragClone.childNodes) :
|
|
||||||
fragClone.nodeType === 1 ? [fragClone] : [];
|
|
||||||
|
|
||||||
// Return fragment to original caller (e.g. append) for DOM insertion
|
|
||||||
callback.call(elem, fragClone);
|
|
||||||
|
|
||||||
// Fragment has been inserted:- Add inserted nodes to tmplItem data structure. Replace inserted element annotations by jQuery.data.
|
|
||||||
storeTmplItems(content);
|
|
||||||
cloneIndex++;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
//========================== Private helper functions, used by code above ==========================
|
|
||||||
|
|
||||||
function build(tmplItem, nested, content) {
|
|
||||||
// Convert hierarchical content into flat string array
|
|
||||||
// and finally return array of fragments ready for DOM insertion
|
|
||||||
var frag, ret = content ? jQuery.map(content, function(item) {
|
|
||||||
return (typeof item === "string") ?
|
|
||||||
// Insert template item annotations, to be converted to jQuery.data( "tmplItem" ) when elems are inserted into DOM.
|
|
||||||
(tmplItem.key ? item.replace(/(<\w+)(?=[\s>])(?![^>]*_tmplitem)([^>]*)/g, "$1 " + tmplItmAtt + "=\"" + tmplItem.key + "\" $2") : item) :
|
|
||||||
// This is a child template item. Build nested template.
|
|
||||||
build(item, tmplItem, item._ctnt);
|
|
||||||
}) :
|
|
||||||
// If content is not defined, insert tmplItem directly. Not a template item. May be a string, or a string array, e.g. from {{html $item.html()}}.
|
|
||||||
tmplItem;
|
|
||||||
if (nested) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// top-level template
|
|
||||||
ret = ret.join("");
|
|
||||||
|
|
||||||
// Support templates which have initial or final text nodes, or consist only of text
|
|
||||||
// Also support HTML entities within the HTML markup.
|
|
||||||
ret.replace(/^\s*([^<\s][^<]*)?(<[\w\W]+>)([^>]*[^>\s])?\s*$/, function(all, before, middle, after) {
|
|
||||||
frag = jQuery(middle).get();
|
|
||||||
|
|
||||||
storeTmplItems(frag);
|
|
||||||
if (before) {
|
|
||||||
frag = unencode(before).concat(frag);
|
|
||||||
}
|
|
||||||
if (after) {
|
|
||||||
frag = frag.concat(unencode(after));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return frag ? frag : unencode(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
function unencode(text) {
|
|
||||||
// Use createElement, since createTextNode will not render HTML entities correctly
|
|
||||||
var el = document.createElement("div");
|
|
||||||
el.innerHTML = text;
|
|
||||||
return jQuery.makeArray(el.childNodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generate a reusable function that will serve to render a template against data
|
|
||||||
function buildTmplFn(markup) {
|
|
||||||
return new Function("jQuery", "$item",
|
|
||||||
"var $=jQuery,call,_=[],$data=$item.data;" +
|
|
||||||
|
|
||||||
// Introduce the data as local variables using with(){}
|
|
||||||
"with($data){_.push('" +
|
|
||||||
|
|
||||||
// Convert the template into pure JavaScript
|
|
||||||
jQuery.trim(markup)
|
|
||||||
.replace(/([\\'])/g, "\\$1")
|
|
||||||
.replace(/[\r\t\n]/g, " ")
|
|
||||||
.replace(/\$\{([^\}]*)\}/g, "{{= $1}}")
|
|
||||||
.replace(/\{\{(\/?)(\w+|.)(?:\(((?:[^\}]|\}(?!\}))*?)?\))?(?:\s+(.*?)?)?(\(((?:[^\}]|\}(?!\}))*?)\))?\s*\}\}/g,
|
|
||||||
function(all, slash, type, fnargs, target, parens, args) {
|
|
||||||
var tag = jQuery.tmpl.tag[ type ], def, expr, exprAutoFnDetect;
|
|
||||||
if (!tag) {
|
|
||||||
throw "Template command not found: " + type;
|
|
||||||
}
|
|
||||||
def = tag._default || [];
|
|
||||||
if (parens && !/\w$/.test(target)) {
|
|
||||||
target += parens;
|
|
||||||
parens = "";
|
|
||||||
}
|
|
||||||
if (target) {
|
|
||||||
target = unescape(target);
|
|
||||||
args = args ? ("," + unescape(args) + ")") : (parens ? ")" : "");
|
|
||||||
// Support for target being things like a.toLowerCase();
|
|
||||||
// In that case don't call with template item as 'this' pointer. Just evaluate...
|
|
||||||
expr = parens ? (target.indexOf(".") > -1 ? target + parens : ("(" + target + ").call($item" + args)) : target;
|
|
||||||
exprAutoFnDetect = parens ? expr : "(typeof(" + target + ")==='function'?(" + target + ").call($item):(" + target + "))";
|
|
||||||
} else {
|
|
||||||
exprAutoFnDetect = expr = def.$1 || "null";
|
|
||||||
}
|
|
||||||
fnargs = unescape(fnargs);
|
|
||||||
return "');" +
|
|
||||||
tag[ slash ? "close" : "open" ]
|
|
||||||
.split("$notnull_1").join(target ? "typeof(" + target + ")!=='undefined' && (" + target + ")!=null" : "true")
|
|
||||||
.split("$1a").join(exprAutoFnDetect)
|
|
||||||
.split("$1").join(expr)
|
|
||||||
.split("$2").join(fnargs ?
|
|
||||||
fnargs.replace(/\s*([^\(]+)\s*(\((.*?)\))?/g, function(all, name, parens, params) {
|
|
||||||
params = params ? ("," + params + ")") : (parens ? ")" : "");
|
|
||||||
return params ? ("(" + name + ").call($item" + params) : all;
|
|
||||||
})
|
|
||||||
: (def.$2 || "")
|
|
||||||
) +
|
|
||||||
"_.push('";
|
|
||||||
}) +
|
|
||||||
"');}return _;"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateWrapped(options, wrapped) {
|
|
||||||
// Build the wrapped content.
|
|
||||||
options._wrap = build(options, true,
|
|
||||||
// Suport imperative scenario in which options.wrapped can be set to a selector or an HTML string.
|
|
||||||
jQuery.isArray(wrapped) ? wrapped : [htmlExpr.test(wrapped) ? wrapped : jQuery(wrapped).html()]
|
|
||||||
).join("");
|
|
||||||
}
|
|
||||||
|
|
||||||
function unescape(args) {
|
|
||||||
return args ? args.replace(/\\'/g, "'").replace(/\\\\/g, "\\") : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
function outerHtml(elem) {
|
|
||||||
var div = document.createElement("div");
|
|
||||||
div.appendChild(elem.cloneNode(true));
|
|
||||||
return div.innerHTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Store template items in jQuery.data(), ensuring a unique tmplItem data data structure for each rendered template instance.
|
|
||||||
function storeTmplItems(content) {
|
|
||||||
var keySuffix = "_" + cloneIndex, elem, elems, newClonedItems = {}, i, l, m;
|
|
||||||
for (i = 0,l = content.length; i < l; i++) {
|
|
||||||
if ((elem = content[i]).nodeType !== 1) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
elems = elem.getElementsByTagName("*");
|
|
||||||
for (m = elems.length - 1; m >= 0; m--) {
|
|
||||||
processItemKey(elems[m]);
|
|
||||||
}
|
|
||||||
processItemKey(elem);
|
|
||||||
}
|
|
||||||
function processItemKey(el) {
|
|
||||||
var pntKey, pntNode = el, pntItem, tmplItem, key;
|
|
||||||
// Ensure that each rendered template inserted into the DOM has its own template item,
|
|
||||||
if ((key = el.getAttribute(tmplItmAtt))) {
|
|
||||||
while (pntNode.parentNode && (pntNode = pntNode.parentNode).nodeType === 1 && !(pntKey = pntNode.getAttribute(tmplItmAtt))) {
|
|
||||||
}
|
|
||||||
if (pntKey !== key) {
|
|
||||||
// The next ancestor with a _tmplitem expando is on a different key than this one.
|
|
||||||
// So this is a top-level element within this template item
|
|
||||||
// Set pntNode to the key of the parentNode, or to 0 if pntNode.parentNode is null, or pntNode is a fragment.
|
|
||||||
pntNode = pntNode.parentNode ? (pntNode.nodeType === 11 ? 0 : (pntNode.getAttribute(tmplItmAtt) || 0)) : 0;
|
|
||||||
if (!(tmplItem = newTmplItems[key])) {
|
|
||||||
// The item is for wrapped content, and was copied from the temporary parent wrappedItem.
|
|
||||||
tmplItem = wrappedItems[key];
|
|
||||||
tmplItem = newTmplItem(tmplItem, newTmplItems[pntNode] || wrappedItems[pntNode], null, true);
|
|
||||||
tmplItem.key = ++itemKey;
|
|
||||||
newTmplItems[itemKey] = tmplItem;
|
|
||||||
}
|
|
||||||
if (cloneIndex) {
|
|
||||||
cloneTmplItem(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
el.removeAttribute(tmplItmAtt);
|
|
||||||
} else if (cloneIndex && (tmplItem = jQuery.data(el, "tmplItem"))) {
|
|
||||||
// This was a rendered element, cloned during append or appendTo etc.
|
|
||||||
// TmplItem stored in jQuery data has already been cloned in cloneCopyEvent. We must replace it with a fresh cloned tmplItem.
|
|
||||||
cloneTmplItem(tmplItem.key);
|
|
||||||
newTmplItems[tmplItem.key] = tmplItem;
|
|
||||||
pntNode = jQuery.data(el.parentNode, "tmplItem");
|
|
||||||
pntNode = pntNode ? pntNode.key : 0;
|
|
||||||
}
|
|
||||||
if (tmplItem) {
|
|
||||||
pntItem = tmplItem;
|
|
||||||
// Find the template item of the parent element.
|
|
||||||
// (Using !=, not !==, since pntItem.key is number, and pntNode may be a string)
|
|
||||||
while (pntItem && pntItem.key != pntNode) {
|
|
||||||
// Add this element as a top-level node for this rendered template item, as well as for any
|
|
||||||
// ancestor items between this item and the item of its parent element
|
|
||||||
pntItem.nodes.push(el);
|
|
||||||
pntItem = pntItem.parent;
|
|
||||||
}
|
|
||||||
// Delete content built during rendering - reduce API surface area and memory use, and avoid exposing of stale data after rendering...
|
|
||||||
delete tmplItem._ctnt;
|
|
||||||
delete tmplItem._wrap;
|
|
||||||
// Store template item as jQuery data on the element
|
|
||||||
jQuery.data(el, "tmplItem", tmplItem);
|
|
||||||
}
|
|
||||||
function cloneTmplItem(key) {
|
|
||||||
key = key + keySuffix;
|
|
||||||
tmplItem = newClonedItems[key] =
|
|
||||||
(newClonedItems[key] || newTmplItem(tmplItem, newTmplItems[tmplItem.parent.key + keySuffix] || tmplItem.parent, null, true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//---- Helper functions for template item ----
|
|
||||||
|
|
||||||
function tiCalls(content, tmpl, data, options) {
|
|
||||||
if (!content) {
|
|
||||||
return stack.pop();
|
|
||||||
}
|
|
||||||
stack.push({ _: content, tmpl: tmpl, item:this, data: data, options: options });
|
|
||||||
}
|
|
||||||
|
|
||||||
function tiNest(tmpl, data, options) {
|
|
||||||
// nested template, using {{tmpl}} tag
|
|
||||||
return jQuery.tmpl(jQuery.template(tmpl), data, options, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
function tiWrap(call, wrapped) {
|
|
||||||
// nested template, using {{wrap}} tag
|
|
||||||
var options = call.options || {};
|
|
||||||
options.wrapped = wrapped;
|
|
||||||
// Apply the template, which may incorporate wrapped content,
|
|
||||||
return jQuery.tmpl(jQuery.template(call.tmpl), call.data, options, call.item);
|
|
||||||
}
|
|
||||||
|
|
||||||
function tiHtml(filter, textOnly) {
|
|
||||||
var wrapped = this._wrap;
|
|
||||||
return jQuery.map(
|
|
||||||
jQuery(jQuery.isArray(wrapped) ? wrapped.join("") : wrapped).filter(filter || "*"),
|
|
||||||
function(e) {
|
|
||||||
return textOnly ?
|
|
||||||
e.innerText || e.textContent :
|
|
||||||
e.outerHTML || outerHtml(e);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function tiUpdate() {
|
|
||||||
var coll = this.nodes;
|
|
||||||
jQuery.tmpl(null, null, null, this).insertBefore(coll[0]);
|
|
||||||
jQuery(coll).remove();
|
|
||||||
}
|
|
||||||
})(jQuery);
|
|
||||||
9
build/javascripts/jquery.wiggle.min.js
vendored
9
build/javascripts/jquery.wiggle.min.js
vendored
@@ -1,9 +0,0 @@
|
|||||||
/*
|
|
||||||
jQuery Wiggle
|
|
||||||
Author: WonderGroup, Jordan Thomas
|
|
||||||
URL: http://labs.wondergroup.com/demos/mini-ui/index.html
|
|
||||||
License: MIT (http://en.wikipedia.org/wiki/MIT_License)
|
|
||||||
*/
|
|
||||||
|
|
||||||
jQuery.fn.wiggle=function(o){var d={speed:50,wiggles:3,travel:5,callback:null};var o=jQuery.extend(d,o);return this.each(function(){var cache=this;var wrap=jQuery(this).wrap('<div class="wiggle-wrap"></div>').css("position","relative");var calls=0;for(i=1;i<=o.wiggles;i++){jQuery(this).animate({left:"-="+o.travel},o.speed).animate({left:"+="+o.travel*2},o.speed*2).animate({left:"-="+o.travel},o.speed,function(){calls++;if(jQuery(cache).parent().hasClass('wiggle-wrap')){jQuery(cache).parent().replaceWith(cache);}
|
|
||||||
if(calls==o.wiggles&&jQuery.isFunction(o.callback)){o.callback();}});}});};
|
|
||||||
@@ -1,560 +0,0 @@
|
|||||||
(function(){
|
|
||||||
|
|
||||||
var Spine;
|
|
||||||
if (typeof exports !== "undefined") {
|
|
||||||
Spine = exports;
|
|
||||||
} else {
|
|
||||||
Spine = this.Spine = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
Spine.version = "0.0.4";
|
|
||||||
|
|
||||||
var $ = Spine.$ = this.jQuery || this.Zepto || function(){ return arguments[0]; };
|
|
||||||
|
|
||||||
var makeArray = Spine.makeArray = function(args){
|
|
||||||
return Array.prototype.slice.call(args, 0);
|
|
||||||
};
|
|
||||||
|
|
||||||
var isArray = Spine.isArray = function(value){
|
|
||||||
return Object.prototype.toString.call(value) == "[object Array]";
|
|
||||||
};
|
|
||||||
|
|
||||||
// Shim Array, as these functions aren't in IE
|
|
||||||
if (typeof Array.prototype.indexOf === "undefined")
|
|
||||||
Array.prototype.indexOf = function(value){
|
|
||||||
for ( var i = 0; i < this.length; i++ )
|
|
||||||
if ( this[ i ] === value )
|
|
||||||
return i;
|
|
||||||
return -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
var Events = Spine.Events = {
|
|
||||||
bind: function(ev, callback) {
|
|
||||||
var evs = ev.split(" ");
|
|
||||||
var calls = this._callbacks || (this._callbacks = {});
|
|
||||||
|
|
||||||
for (var i=0; i < evs.length; i++)
|
|
||||||
(this._callbacks[evs[i]] || (this._callbacks[evs[i]] = [])).push(callback);
|
|
||||||
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
|
|
||||||
trigger: function() {
|
|
||||||
var args = makeArray(arguments);
|
|
||||||
var ev = args.shift();
|
|
||||||
|
|
||||||
var list, calls, i, l;
|
|
||||||
if (!(calls = this._callbacks)) return false;
|
|
||||||
if (!(list = this._callbacks[ev])) return false;
|
|
||||||
|
|
||||||
for (i = 0, l = list.length; i < l; i++)
|
|
||||||
if (list[i].apply(this, args) === false)
|
|
||||||
break;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
|
|
||||||
unbind: function(ev, callback){
|
|
||||||
if ( !ev ) {
|
|
||||||
this._callbacks = {};
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
var list, calls, i, l;
|
|
||||||
if (!(calls = this._callbacks)) return this;
|
|
||||||
if (!(list = this._callbacks[ev])) return this;
|
|
||||||
|
|
||||||
if ( !callback ) {
|
|
||||||
delete this._callbacks[ev];
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0, l = list.length; i < l; i++)
|
|
||||||
if (callback === list[i]) {
|
|
||||||
list.splice(i, 1);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var Log = Spine.Log = {
|
|
||||||
trace: true,
|
|
||||||
|
|
||||||
logPrefix: "(App)",
|
|
||||||
|
|
||||||
log: function(){
|
|
||||||
if ( !this.trace ) return;
|
|
||||||
if (typeof console == "undefined") return;
|
|
||||||
var args = makeArray(arguments);
|
|
||||||
if (this.logPrefix) args.unshift(this.logPrefix);
|
|
||||||
console.log.apply(console, args);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Classes (or prototypial inheritors)
|
|
||||||
|
|
||||||
if (typeof Object.create !== "function")
|
|
||||||
Object.create = function(o) {
|
|
||||||
function F() {}
|
|
||||||
F.prototype = o;
|
|
||||||
return new F();
|
|
||||||
};
|
|
||||||
|
|
||||||
var moduleKeywords = ["included", "extended"];
|
|
||||||
|
|
||||||
var Class = Spine.Class = {
|
|
||||||
inherited: function(){},
|
|
||||||
created: function(){},
|
|
||||||
|
|
||||||
prototype: {
|
|
||||||
initialize: function(){},
|
|
||||||
init: function(){}
|
|
||||||
},
|
|
||||||
|
|
||||||
create: function(include, extend){
|
|
||||||
var object = Object.create(this);
|
|
||||||
object.parent = this;
|
|
||||||
object.prototype = object.fn = Object.create(this.prototype);
|
|
||||||
|
|
||||||
if (include) object.include(include);
|
|
||||||
if (extend) object.extend(extend);
|
|
||||||
|
|
||||||
object.created();
|
|
||||||
this.inherited(object);
|
|
||||||
return object;
|
|
||||||
},
|
|
||||||
|
|
||||||
init: function(){
|
|
||||||
var instance = Object.create(this.prototype);
|
|
||||||
instance.parent = this;
|
|
||||||
|
|
||||||
instance.initialize.apply(instance, arguments);
|
|
||||||
instance.init.apply(instance, arguments);
|
|
||||||
return instance;
|
|
||||||
},
|
|
||||||
|
|
||||||
proxy: function(func){
|
|
||||||
var thisObject = this;
|
|
||||||
return(function(){
|
|
||||||
return func.apply(thisObject, arguments);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
proxyAll: function(){
|
|
||||||
var functions = makeArray(arguments);
|
|
||||||
for (var i=0; i < functions.length; i++)
|
|
||||||
this[functions[i]] = this.proxy(this[functions[i]]);
|
|
||||||
},
|
|
||||||
|
|
||||||
include: function(obj){
|
|
||||||
for(var key in obj)
|
|
||||||
if (moduleKeywords.indexOf(key) == -1)
|
|
||||||
this.fn[key] = obj[key];
|
|
||||||
|
|
||||||
var included = obj.included;
|
|
||||||
if (included) included.apply(this);
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
|
|
||||||
extend: function(obj){
|
|
||||||
for(var key in obj)
|
|
||||||
if (moduleKeywords.indexOf(key) == -1)
|
|
||||||
this[key] = obj[key];
|
|
||||||
|
|
||||||
var extended = obj.extended;
|
|
||||||
if (extended) extended.apply(this);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Class.prototype.proxy = Class.proxy;
|
|
||||||
Class.prototype.proxyAll = Class.proxyAll;
|
|
||||||
Class.instancet = Class.init;
|
|
||||||
Class.sub = Class.create;
|
|
||||||
|
|
||||||
// Models
|
|
||||||
|
|
||||||
Spine.guid = function(){
|
|
||||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
||||||
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
|
|
||||||
return v.toString(16);
|
|
||||||
}).toUpperCase();
|
|
||||||
};
|
|
||||||
|
|
||||||
var Model = Spine.Model = Class.create();
|
|
||||||
|
|
||||||
Model.extend(Events);
|
|
||||||
|
|
||||||
Model.extend({
|
|
||||||
setup: function(name, atts){
|
|
||||||
var model = Model.sub();
|
|
||||||
if (name) model.name = name;
|
|
||||||
if (atts) model.attributes = atts;
|
|
||||||
return model;
|
|
||||||
},
|
|
||||||
|
|
||||||
created: function(sub){
|
|
||||||
this.records = {};
|
|
||||||
this.attributes = this.attributes ?
|
|
||||||
makeArray(this.attributes) : [];
|
|
||||||
},
|
|
||||||
|
|
||||||
find: function(id){
|
|
||||||
var record = this.records[id];
|
|
||||||
if ( !record ) throw("Unknown record");
|
|
||||||
return record.clone();
|
|
||||||
},
|
|
||||||
|
|
||||||
exists: function(id){
|
|
||||||
try {
|
|
||||||
return this.find(id);
|
|
||||||
} catch (e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
refresh: function(values){
|
|
||||||
values = this.fromJSON(values);
|
|
||||||
this.records = {};
|
|
||||||
|
|
||||||
for (var i=0, il = values.length; i < il; i++) {
|
|
||||||
var record = values[i];
|
|
||||||
record.newRecord = false;
|
|
||||||
record.id = record.id || Spine.guid();
|
|
||||||
this.records[record.id] = record;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.trigger("refresh");
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
|
|
||||||
// adeed by ayush
|
|
||||||
createAll: function(values){
|
|
||||||
values = this.fromJSON(values);
|
|
||||||
for (var i=0, il = values.length; i < il; i++) {
|
|
||||||
var record = values[i];
|
|
||||||
record.newRecord = false;
|
|
||||||
record.id = record.id || Spine.guid();
|
|
||||||
this.records[record.id] = record;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
|
|
||||||
select: function(callback){
|
|
||||||
var result = [];
|
|
||||||
|
|
||||||
for (var key in this.records)
|
|
||||||
if (callback(this.records[key]))
|
|
||||||
result.push(this.records[key]);
|
|
||||||
|
|
||||||
return this.cloneArray(result);
|
|
||||||
},
|
|
||||||
|
|
||||||
findByAttribute: function(name, value){
|
|
||||||
for (var key in this.records)
|
|
||||||
if (this.records[key][name] == value)
|
|
||||||
return this.records[key].clone();
|
|
||||||
},
|
|
||||||
|
|
||||||
findAllByAttribute: function(name, value){
|
|
||||||
return(this.select(function(item){
|
|
||||||
return(item[name] == value);
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
|
|
||||||
each: function(callback){
|
|
||||||
for (var key in this.records)
|
|
||||||
callback(this.records[key]);
|
|
||||||
},
|
|
||||||
|
|
||||||
all: function(){
|
|
||||||
return this.cloneArray(this.recordsValues());
|
|
||||||
},
|
|
||||||
|
|
||||||
first: function(){
|
|
||||||
var record = this.recordsValues()[0];
|
|
||||||
return(record && record.clone());
|
|
||||||
},
|
|
||||||
|
|
||||||
last: function(){
|
|
||||||
var values = this.recordsValues();
|
|
||||||
var record = values[values.length - 1];
|
|
||||||
return(record && record.clone());
|
|
||||||
},
|
|
||||||
|
|
||||||
count: function(){
|
|
||||||
return this.recordsValues().length;
|
|
||||||
},
|
|
||||||
|
|
||||||
deleteAll: function(){
|
|
||||||
for (var key in this.records)
|
|
||||||
delete this.records[key];
|
|
||||||
},
|
|
||||||
|
|
||||||
destroyAll: function(){
|
|
||||||
for (var key in this.records)
|
|
||||||
this.records[key].destroy();
|
|
||||||
},
|
|
||||||
|
|
||||||
update: function(id, atts){
|
|
||||||
this.find(id).updateAttributes(atts);
|
|
||||||
},
|
|
||||||
|
|
||||||
create: function(atts){
|
|
||||||
var record = this.init(atts);
|
|
||||||
return record.save();
|
|
||||||
},
|
|
||||||
|
|
||||||
destroy: function(id){
|
|
||||||
this.find(id).destroy();
|
|
||||||
},
|
|
||||||
|
|
||||||
sync: function(callback){
|
|
||||||
this.bind("change", callback);
|
|
||||||
},
|
|
||||||
|
|
||||||
fetch: function(callbackOrParams){
|
|
||||||
typeof(callbackOrParams) == "function" ?
|
|
||||||
this.bind("fetch", callbackOrParams) :
|
|
||||||
this.trigger("fetch", callbackOrParams);
|
|
||||||
},
|
|
||||||
|
|
||||||
toJSON: function(){
|
|
||||||
return this.recordsValues();
|
|
||||||
},
|
|
||||||
|
|
||||||
fromJSON: function(objects){
|
|
||||||
if ( !objects ) return;
|
|
||||||
if ( typeof objects == "string" )
|
|
||||||
objects = JSON.parse(objects);
|
|
||||||
if ( isArray(objects) ) {
|
|
||||||
var results = [];
|
|
||||||
for (var i=0; i < objects.length; i++)
|
|
||||||
results.push(this.init(objects[i]));
|
|
||||||
return results;
|
|
||||||
} else {
|
|
||||||
return this.init(objects);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Private
|
|
||||||
|
|
||||||
recordsValues: function(){
|
|
||||||
var result = [];
|
|
||||||
for (var key in this.records)
|
|
||||||
result.push(this.records[key]);
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
|
|
||||||
cloneArray: function(array){
|
|
||||||
var result = [];
|
|
||||||
for (var i=0; i < array.length; i++)
|
|
||||||
result.push(array[i].clone());
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
|
|
||||||
// added by ayush
|
|
||||||
logAll: function() {
|
|
||||||
for(var i = 0; i < this.all().length; i++) {
|
|
||||||
var e = this.all()[i];
|
|
||||||
if(window.console) console.log(e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
Model.include({
|
|
||||||
model: true,
|
|
||||||
newRecord: true,
|
|
||||||
|
|
||||||
init: function(atts){
|
|
||||||
if (atts) this.load(atts);
|
|
||||||
this.trigger("init", this);
|
|
||||||
},
|
|
||||||
|
|
||||||
isNew: function(){
|
|
||||||
return this.newRecord;
|
|
||||||
},
|
|
||||||
|
|
||||||
isValid: function(){
|
|
||||||
return(!this.validate());
|
|
||||||
},
|
|
||||||
|
|
||||||
validate: function(){ },
|
|
||||||
|
|
||||||
load: function(atts){
|
|
||||||
for(var name in atts)
|
|
||||||
this[name] = atts[name];
|
|
||||||
},
|
|
||||||
|
|
||||||
attributes: function(){
|
|
||||||
var result = {};
|
|
||||||
for (var i=0; i < this.parent.attributes.length; i++) {
|
|
||||||
var attr = this.parent.attributes[i];
|
|
||||||
result[attr] = this[attr];
|
|
||||||
}
|
|
||||||
result.id = this.id;
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
|
|
||||||
eql: function(rec){
|
|
||||||
return(rec && rec.id === this.id &&
|
|
||||||
rec.parent === this.parent);
|
|
||||||
},
|
|
||||||
|
|
||||||
save: function(){
|
|
||||||
var error = this.validate();
|
|
||||||
if ( error ) {
|
|
||||||
this.trigger("error", this, error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.trigger("beforeSave", this);
|
|
||||||
this.newRecord ? this.create() : this.update();
|
|
||||||
this.trigger("save", this);
|
|
||||||
return this;
|
|
||||||
},
|
|
||||||
|
|
||||||
updateAttribute: function(name, value){
|
|
||||||
this[name] = value;
|
|
||||||
return this.save();
|
|
||||||
},
|
|
||||||
|
|
||||||
updateAttributes: function(atts){
|
|
||||||
this.load(atts);
|
|
||||||
return this.save();
|
|
||||||
},
|
|
||||||
|
|
||||||
destroy: function(){
|
|
||||||
this.trigger("beforeDestroy", this);
|
|
||||||
delete this.parent.records[this.id];
|
|
||||||
this.destroyed = true;
|
|
||||||
this.trigger("destroy", this);
|
|
||||||
this.trigger("change", this, "destroy");
|
|
||||||
},
|
|
||||||
|
|
||||||
dup: function(){
|
|
||||||
var result = this.parent.init(this.attributes());
|
|
||||||
result.newRecord = this.newRecord;
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
|
|
||||||
clone: function(){
|
|
||||||
return Object.create(this);
|
|
||||||
},
|
|
||||||
|
|
||||||
reload: function(){
|
|
||||||
if ( this.newRecord ) return this;
|
|
||||||
var original = this.parent.find(this.id);
|
|
||||||
this.load(original.attributes());
|
|
||||||
return original;
|
|
||||||
},
|
|
||||||
|
|
||||||
toJSON: function(){
|
|
||||||
return(this.attributes());
|
|
||||||
},
|
|
||||||
|
|
||||||
exists: function(){
|
|
||||||
return(this.id && this.id in this.parent.records);
|
|
||||||
},
|
|
||||||
|
|
||||||
// Private
|
|
||||||
|
|
||||||
update: function(){
|
|
||||||
this.trigger("beforeUpdate", this);
|
|
||||||
var records = this.parent.records;
|
|
||||||
records[this.id].load(this.attributes());
|
|
||||||
var clone = records[this.id].clone();
|
|
||||||
this.trigger("update", clone);
|
|
||||||
this.trigger("change", clone, "update");
|
|
||||||
},
|
|
||||||
|
|
||||||
create: function(){
|
|
||||||
this.trigger("beforeCreate", this);
|
|
||||||
if ( !this.id ) this.id = Spine.guid();
|
|
||||||
this.newRecord = false;
|
|
||||||
var records = this.parent.records;
|
|
||||||
records[this.id] = this.dup();
|
|
||||||
var clone = records[this.id].clone();
|
|
||||||
this.trigger("create", clone);
|
|
||||||
this.trigger("change", clone, "create");
|
|
||||||
},
|
|
||||||
|
|
||||||
bind: function(events, callback){
|
|
||||||
return this.parent.bind(events, this.proxy(function(record){
|
|
||||||
if ( record && this.eql(record) )
|
|
||||||
callback.apply(this, arguments);
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
|
|
||||||
trigger: function(){
|
|
||||||
return this.parent.trigger.apply(this.parent, arguments);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Controllers
|
|
||||||
|
|
||||||
var eventSplitter = /^(\w+)\s*(.*)$/;
|
|
||||||
|
|
||||||
var Controller = Spine.Controller = Class.create({
|
|
||||||
tag: "div",
|
|
||||||
|
|
||||||
initialize: function(options){
|
|
||||||
this.options = options;
|
|
||||||
|
|
||||||
for (var key in this.options)
|
|
||||||
this[key] = this.options[key];
|
|
||||||
|
|
||||||
if (!this.el) this.el = document.createElement(this.tag);
|
|
||||||
this.el = $(this.el);
|
|
||||||
|
|
||||||
if ( !this.events ) this.events = this.parent.events;
|
|
||||||
if ( !this.elements ) this.elements = this.parent.elements;
|
|
||||||
|
|
||||||
if (this.events) this.delegateEvents();
|
|
||||||
if (this.elements) this.refreshElements();
|
|
||||||
if (this.proxied) this.proxyAll.apply(this, this.proxied);
|
|
||||||
},
|
|
||||||
|
|
||||||
$: function(selector){
|
|
||||||
return $(selector, this.el);
|
|
||||||
},
|
|
||||||
|
|
||||||
delegateEvents: function(){
|
|
||||||
for (var key in this.events) {
|
|
||||||
var methodName = this.events[key];
|
|
||||||
var method = this.proxy(this[methodName]);
|
|
||||||
|
|
||||||
var match = key.match(eventSplitter);
|
|
||||||
var eventName = match[1], selector = match[2];
|
|
||||||
|
|
||||||
if (selector === '') {
|
|
||||||
this.el.bind(eventName, method);
|
|
||||||
} else {
|
|
||||||
this.el.delegate(selector, eventName, method);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
refreshElements: function(){
|
|
||||||
for (var key in this.elements) {
|
|
||||||
this[this.elements[key]] = this.$(key);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
delay: function(func, timeout){
|
|
||||||
setTimeout(this.proxy(func), timeout || 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Controller.include(Events);
|
|
||||||
Controller.include(Log);
|
|
||||||
|
|
||||||
Spine.App = Class.create();
|
|
||||||
Spine.App.extend(Events);
|
|
||||||
Controller.fn.App = Spine.App;
|
|
||||||
})();
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
jQuery(function($) {
|
|
||||||
// create and initialize SwaggerService
|
|
||||||
var swaggerService = new SwaggerService("http://swagr.api.wordnik.com/v4/list.json");
|
|
||||||
swaggerService.init();
|
|
||||||
|
|
||||||
// Create convenience references to Spine models
|
|
||||||
var ApiResource = swaggerService.ApiResource();
|
|
||||||
|
|
||||||
// Register a callback for when apis are loaded
|
|
||||||
ApiResource.bind("refresh", apisLoaded);
|
|
||||||
|
|
||||||
function apisLoaded() {
|
|
||||||
for(var i = 0; i < ApiResource.all().length; i++) {
|
|
||||||
var apiResource = ApiResource.all()[i];
|
|
||||||
log("---------------------------------------------");
|
|
||||||
log("------------- apiResource : " + apiResource.name);
|
|
||||||
apiResource.apiList.logAll();
|
|
||||||
apiResource.modelList.logAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (window.console) console.log("apis loaded");
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
@@ -1,473 +0,0 @@
|
|||||||
function SwaggerService(discoveryUrl, _apiKey, statusCallback) {
|
|
||||||
if (!discoveryUrl)
|
|
||||||
throw new Error("discoveryUrl must be passed while creating SwaggerService");
|
|
||||||
|
|
||||||
// constants
|
|
||||||
discoveryUrl = jQuery.trim(discoveryUrl);
|
|
||||||
if (discoveryUrl.length == 0)
|
|
||||||
throw new Error("discoveryUrl must be passed while creating SwaggerService");
|
|
||||||
|
|
||||||
if ( discoveryUrl.indexOf("/")!=0 && ! (discoveryUrl.toLowerCase().indexOf("http:") == 0 || discoveryUrl.toLowerCase().indexOf("https:") == 0)) {
|
|
||||||
discoveryUrl = ("http://" + discoveryUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
var baseDiscoveryUrl = "";
|
|
||||||
var globalBasePath = "";
|
|
||||||
var formatString = ".{format}";
|
|
||||||
var statusListener = statusCallback;
|
|
||||||
var apiKey = _apiKey;
|
|
||||||
|
|
||||||
var apiKeySuffix = "";
|
|
||||||
if (apiKey) {
|
|
||||||
apiKey = jQuery.trim(apiKey);
|
|
||||||
if (apiKey.length > 0)
|
|
||||||
apiKeySuffix = "?api_key=" + apiKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
function log() {
|
|
||||||
if (window.console) console.log.apply(console,arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
function error(m) {
|
|
||||||
log("ERROR: " + m);
|
|
||||||
}
|
|
||||||
|
|
||||||
function updateStatus(status) {
|
|
||||||
statusListener(status);
|
|
||||||
}
|
|
||||||
|
|
||||||
function endsWith(str, suffix) {
|
|
||||||
return str.indexOf(suffix, str.length - suffix.length) !== -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// make some models public
|
|
||||||
this.ApiResource = function() {
|
|
||||||
return ApiResource;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.apiHost = function() {
|
|
||||||
return globalBasePath;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.formatString = function() {
|
|
||||||
return formatString;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Model: ApiResource
|
|
||||||
var ApiResource = Spine.Model.setup("ApiResource", ["name", "baseUrl", "path", "path_json", "path_xml", "description", "apiLists", "modelList"]);
|
|
||||||
ApiResource.include({
|
|
||||||
path_json: null,
|
|
||||||
path_xml: null,
|
|
||||||
init: function(atts) {
|
|
||||||
if (atts) this.load(atts);
|
|
||||||
this.name = this.path.replace(".{format}", "").replace(/\//g, "_");
|
|
||||||
this.path_json = this.path.replace("{format}", "json");
|
|
||||||
this.path_xml = this.path.replace("{format}", "xml");
|
|
||||||
this.baseUrl = globalBasePath;
|
|
||||||
this.apiList = Api.sub();
|
|
||||||
this.modelList = ApiModel.sub();
|
|
||||||
},
|
|
||||||
|
|
||||||
addApis: function(apiObjects, basePath) {
|
|
||||||
// log("apiObjects: %o", apiObjects);
|
|
||||||
this.apiList.createAll(apiObjects);
|
|
||||||
this.apiList.each(function(api) {
|
|
||||||
api.setBaseUrl(basePath);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
addModel: function(modelObject) {
|
|
||||||
this.modelList.create(modelObject);
|
|
||||||
},
|
|
||||||
|
|
||||||
toString: function() {
|
|
||||||
return this.path_json + ": " + this.description;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Model: Api
|
|
||||||
var Api = Spine.Model.setup("Api", ["baseUrl", "path", "path_json", "path_xml", "name", "description", "operations", "path_json", "path_xml"]);
|
|
||||||
Api.include({
|
|
||||||
init: function(atts) {
|
|
||||||
if (atts) this.load(atts);
|
|
||||||
|
|
||||||
var sep = this.path.lastIndexOf("/");
|
|
||||||
this.name = this.path.substr(0, sep).replace(".{format}", "").replace(/\//g, "_");
|
|
||||||
|
|
||||||
var secondPathSeperatorIndex = this.path.indexOf("/", 1);
|
|
||||||
if (secondPathSeperatorIndex > 0) {
|
|
||||||
var prefix = this.path.substr(0, secondPathSeperatorIndex);
|
|
||||||
var suffix = this.path.substr(secondPathSeperatorIndex, this.path.length);
|
|
||||||
// log(this.path + ":: " + prefix + "..." + suffix);
|
|
||||||
this.path_json = prefix.replace("{format}", "json") + suffix;
|
|
||||||
this.path_xml = prefix.replace("{format}", "xml") + suffix;;
|
|
||||||
} else {
|
|
||||||
this.path_json = this.path.replace("{format}", "json");
|
|
||||||
this.path_xml = this.path.replace("{format}", "xml");
|
|
||||||
}
|
|
||||||
|
|
||||||
var value = this.operations;
|
|
||||||
|
|
||||||
this.operations = ApiOperation.sub();
|
|
||||||
if (value) {
|
|
||||||
for (var i = 0; i < value.length; i++) {
|
|
||||||
var obj = value[i];
|
|
||||||
obj.apiName = this.name;
|
|
||||||
obj.path = this.path;
|
|
||||||
obj.path_json = this.path_json;
|
|
||||||
obj.path_xml = this.path_xml;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
this.operations.refresh(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
updateStatus("Loading " + this.path + "...");
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
setBaseUrl: function(u) {
|
|
||||||
this.baseUrl = u;
|
|
||||||
this.operations.each(function(o) {
|
|
||||||
o.baseUrl = u;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
toString: function() {
|
|
||||||
var opsString = "";
|
|
||||||
for (var i = 0; i < this.operations.all().length; i++) {
|
|
||||||
var e = this.operations.all()[i];
|
|
||||||
|
|
||||||
if (opsString.length > 0)
|
|
||||||
opsString += ", ";
|
|
||||||
|
|
||||||
opsString += e.toString();
|
|
||||||
}
|
|
||||||
return this.path_json + "- " + this.operations.all().length + " operations: " + opsString;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// Model: ApiOperation
|
|
||||||
var ApiOperation = Spine.Model.setup("ApiOperation", ["baseUrl", "path", "path_json", "path_xml", "summary", "notes", "deprecated", "open", "httpMethod", "httpMethodLowercase", "nickname", "responseClass", "parameters", "apiName"]);
|
|
||||||
ApiOperation.include({
|
|
||||||
init: function(atts) {
|
|
||||||
if (atts) this.load(atts);
|
|
||||||
|
|
||||||
this.httpMethodLowercase = this.httpMethod.toLowerCase();
|
|
||||||
|
|
||||||
var value = this.parameters;
|
|
||||||
this.parameters = ApiParameter.sub();
|
|
||||||
if (value) this.parameters.refresh(value);
|
|
||||||
},
|
|
||||||
|
|
||||||
toString: function() {
|
|
||||||
var paramsString = "(";
|
|
||||||
for (var i = 0; i < this.parameters.all().length; i++) {
|
|
||||||
var e = this.parameters.all()[i];
|
|
||||||
|
|
||||||
if (paramsString.length > 1)
|
|
||||||
paramsString += ", ";
|
|
||||||
|
|
||||||
paramsString += e.toString();
|
|
||||||
}
|
|
||||||
paramsString += ")";
|
|
||||||
|
|
||||||
return "{" + this.path_json + "| " + this.nickname + paramsString + ": " + this.summary + "}";
|
|
||||||
},
|
|
||||||
|
|
||||||
invocationUrl: function(formValues) {
|
|
||||||
var formValuesMap = new Object();
|
|
||||||
for (var i = 0; i < formValues.length; i++) {
|
|
||||||
var formValue = formValues[i];
|
|
||||||
if (formValue.value && jQuery.trim(formValue.value).length > 0)
|
|
||||||
formValuesMap[formValue.name] = formValue.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
var urlTemplateText = this.path_json.split("{").join("${");
|
|
||||||
// log("url template = " + urlTemplateText);
|
|
||||||
var urlTemplate = $.template(null, urlTemplateText);
|
|
||||||
var url = $.tmpl(urlTemplate, formValuesMap)[0].data;
|
|
||||||
// log("url with path params = " + url);
|
|
||||||
|
|
||||||
var queryParams = apiKeySuffix;
|
|
||||||
this.parameters.each(function(param) {
|
|
||||||
var paramValue = jQuery.trim(formValuesMap[param.name]);
|
|
||||||
if (param.paramType == "query" && paramValue.length > 0) {
|
|
||||||
queryParams += queryParams.length > 0 ? "&": "?";
|
|
||||||
queryParams += param.name;
|
|
||||||
queryParams += "=";
|
|
||||||
queryParams += formValuesMap[param.name];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
url = this.baseUrl + url + queryParams;
|
|
||||||
// log("final url with query params and base url = " + url);
|
|
||||||
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// Model: ApiParameter
|
|
||||||
var ApiParameter = Spine.Model.setup("ApiParameter", ["name", "description", "required", "dataType", "allowableValues", "paramType", "allowMultiple"]);
|
|
||||||
ApiParameter.include({
|
|
||||||
init: function(atts) {
|
|
||||||
if (atts) this.load(atts);
|
|
||||||
|
|
||||||
this.name = this.name || this.dataType;
|
|
||||||
|
|
||||||
if(this.allowableValues){
|
|
||||||
var value = this.allowableValues;
|
|
||||||
if(value.valueType == "LIST"){
|
|
||||||
this.allowableValues = AllowableListValues.sub();
|
|
||||||
} else if (value.valueType == "RANGE"){
|
|
||||||
this.allowableValues = AllowableRangeValues.sub();
|
|
||||||
}
|
|
||||||
if (value) this.allowableValues = this.allowableValues.create(value);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
toString: function() {
|
|
||||||
if (this.allowableValues)
|
|
||||||
return this.name + ": " + this.dataType + " " + this.allowableValues;
|
|
||||||
else
|
|
||||||
return this.name + ": " + this.dataType;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
var AllowableListValues = Spine.Model.setup("AllowableListValues", ["valueType", "values"]);
|
|
||||||
AllowableListValues.include({
|
|
||||||
init: function(atts) {
|
|
||||||
if (atts) this.load(atts);
|
|
||||||
this.name = "allowableValues";
|
|
||||||
},
|
|
||||||
toString: function() {
|
|
||||||
if (this.values)
|
|
||||||
return "["+this.values+"]";
|
|
||||||
else
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var AllowableRangeValues = Spine.Model.setup("AllowableRangeValues", ["valueType", "inclusive", "min", "max"]);
|
|
||||||
AllowableRangeValues.include({
|
|
||||||
init: function(atts) {
|
|
||||||
if (atts) this.load(atts);
|
|
||||||
this.name = "allowableValues";
|
|
||||||
},
|
|
||||||
|
|
||||||
toString: function() {
|
|
||||||
if (this.min && this.max)
|
|
||||||
return "[" + min + "," + max + "]";
|
|
||||||
else
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// Model: ApiModel
|
|
||||||
var ApiModel = Spine.Model.setup("ApiModel", ["id", "fields"]);
|
|
||||||
ApiModel.include({
|
|
||||||
init: function(atts) {
|
|
||||||
if (atts) this.load(atts);
|
|
||||||
|
|
||||||
if (!this.fields) {
|
|
||||||
var propertiesListObject = this.properties;
|
|
||||||
this.fields = ApiModelProperty.sub();
|
|
||||||
|
|
||||||
for (var propName in propertiesListObject) {
|
|
||||||
if (propName != "parent") {
|
|
||||||
var p = propertiesListObject[propName];
|
|
||||||
p.name = propName;
|
|
||||||
p.id = Spine.guid();
|
|
||||||
// log(p);
|
|
||||||
this.fields.create(p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//log("got " + this.fields.count() + " fields for " + this.id);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
toString: function() {
|
|
||||||
var propsString = "";
|
|
||||||
|
|
||||||
propsString += "(";
|
|
||||||
for (var i = 0; i < this.fields.all().length; i++) {
|
|
||||||
var e = this.fields.all()[i];
|
|
||||||
|
|
||||||
if (propsString.length > 1)
|
|
||||||
propsString += ", ";
|
|
||||||
|
|
||||||
propsString += e.toString();
|
|
||||||
}
|
|
||||||
propsString += ")";
|
|
||||||
|
|
||||||
if (this.required)
|
|
||||||
return this.id + " (required): " + propsString;
|
|
||||||
else
|
|
||||||
return this.id + ": " + propsString;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// Model: ApiModelProperty
|
|
||||||
var ApiModelProperty = Spine.Model.setup("ApiModelProperty", ["name", "required", "dataType"]);
|
|
||||||
ApiModelProperty.include({
|
|
||||||
init: function(atts) {
|
|
||||||
if (atts) this.load(atts);
|
|
||||||
|
|
||||||
if (!this.dataType) {
|
|
||||||
if (atts.type == "any")
|
|
||||||
this.dataType = "object";
|
|
||||||
else if (atts.type == "array") {
|
|
||||||
if (atts.items) {
|
|
||||||
if (atts.items.$ref) {
|
|
||||||
this.dataType = "array[" + atts.items.$ref + "]";
|
|
||||||
} else {
|
|
||||||
this.dataType = "array[" + atts.items.type + "]";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.dataType = "array";
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
this.dataType = atts.type;
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
toString: function() {
|
|
||||||
if (this.required)
|
|
||||||
return this.name + ": " + this.dataType + " (required)";
|
|
||||||
else
|
|
||||||
return this.name + ": " + this.dataType;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// Controller
|
|
||||||
var ModelController = Spine.Controller.create({
|
|
||||||
countLoaded: 0,
|
|
||||||
proxied: ["fetchResources", "loadResources", "apisLoaded", "modelsLoaded"],
|
|
||||||
discoveryUrlList: [],
|
|
||||||
discoveryUrlListCursor: 0,
|
|
||||||
|
|
||||||
init: function() {
|
|
||||||
// log("ModelController.init");
|
|
||||||
|
|
||||||
this.fetchEndpoints();
|
|
||||||
},
|
|
||||||
|
|
||||||
fetchEndpoints: function() {
|
|
||||||
updateStatus("Fetching API List...");
|
|
||||||
baseDiscoveryUrl = endsWith(discoveryUrl, "/") ? discoveryUrl.substr(0, discoveryUrl.length - 1) : discoveryUrl;
|
|
||||||
if(endsWith(baseDiscoveryUrl, "/resources.json"))
|
|
||||||
baseDiscoveryUrl = baseDiscoveryUrl.substr(0, baseDiscoveryUrl.length - "/resources.json".length);
|
|
||||||
else if(endsWith(baseDiscoveryUrl, "/resources"))
|
|
||||||
baseDiscoveryUrl = baseDiscoveryUrl.substr(0, baseDiscoveryUrl.length - "/resources".length);
|
|
||||||
|
|
||||||
this.discoveryUrlList.push(discoveryUrl);
|
|
||||||
this.discoveryUrlList.push(baseDiscoveryUrl);
|
|
||||||
this.discoveryUrlList.push(baseDiscoveryUrl + "/resources.json");
|
|
||||||
this.discoveryUrlList.push(baseDiscoveryUrl + "/resources");
|
|
||||||
|
|
||||||
log("Will try the following urls to discover api endpoints:")
|
|
||||||
for(var i = 0; i < this.discoveryUrlList.length; i++)
|
|
||||||
log(" > " + this.discoveryUrlList[i]);
|
|
||||||
|
|
||||||
this.fetchEndpointsSeq();
|
|
||||||
},
|
|
||||||
|
|
||||||
fetchEndpointsSeq: function() {
|
|
||||||
var controller = this;
|
|
||||||
|
|
||||||
if(this.discoveryUrlListCursor < this.discoveryUrlList.length) {
|
|
||||||
var url = this.discoveryUrlList[this.discoveryUrlListCursor++]
|
|
||||||
updateStatus("Fetching API List from " + url);
|
|
||||||
log("Trying url " + url);
|
|
||||||
$.getJSON(url + apiKeySuffix, function(response) {
|
|
||||||
})
|
|
||||||
.success(function(response) {
|
|
||||||
if(response.basePath && response.basePath.slice(0,4) == "http") {
|
|
||||||
log("Setting globalBasePath to " + response.basePath);
|
|
||||||
globalBasePath = response.basePath;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
globalBasePath = baseDiscoveryUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
ApiResource.createAll(response.apis);
|
|
||||||
controller.fetchResources(response.basePath);
|
|
||||||
})
|
|
||||||
.error(function(response) {
|
|
||||||
controller.fetchEndpointsSeq();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
log ('Error with resource discovery. Exhaused all possible endpoint urls');
|
|
||||||
|
|
||||||
var urlsTried = "";
|
|
||||||
for(var i = 0; i < this.discoveryUrlList.length; i++) {
|
|
||||||
urlsTried = urlsTried + "<br/>" + this.discoveryUrlList[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
updateStatus("Unable to fetch API Listing. Tried the following urls:" + urlsTried);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
fetchResources: function(basePath) {
|
|
||||||
log("fetchResources: basePath = " + basePath);
|
|
||||||
//ApiResource.logAll();
|
|
||||||
for (var i = 0; i < ApiResource.all().length; i++) {
|
|
||||||
var apiResource = ApiResource.all()[i];
|
|
||||||
this.fetchResource(apiResource);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
fetchResource: function(apiResource) {
|
|
||||||
var controller = this;
|
|
||||||
updateStatus("Fetching " + apiResource.name + "...");
|
|
||||||
var resourceUrl = globalBasePath + apiResource.path_json + apiKeySuffix;
|
|
||||||
log("resourceUrl: %o", resourceUrl);
|
|
||||||
$.getJSON(resourceUrl,
|
|
||||||
function(response) {
|
|
||||||
controller.loadResources(response, apiResource);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
loadResources: function(response, apiResource) {
|
|
||||||
try {
|
|
||||||
this.countLoaded++;
|
|
||||||
// log(response);
|
|
||||||
if (response.apis) {
|
|
||||||
apiResource.addApis(response.apis, response.basePath);
|
|
||||||
}
|
|
||||||
// updateStatus("Parsed Apis");
|
|
||||||
//log(response.models);
|
|
||||||
if (response.models) {
|
|
||||||
// log("response.models.length = " + response.models.length);
|
|
||||||
for (var modeName in response.models) {
|
|
||||||
var m = response.models[modeName];
|
|
||||||
// log("creating " + m.id);
|
|
||||||
apiResource.addModel(m);
|
|
||||||
// apiResource.modelList.create(m);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updateStatus();
|
|
||||||
} finally {
|
|
||||||
if (this.countLoaded == ApiResource.count()) {
|
|
||||||
// log("all models/api loaded");
|
|
||||||
ApiResource.trigger("refresh");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
this.init = function() {
|
|
||||||
this.modelController = ModelController.init();
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
@@ -1,381 +0,0 @@
|
|||||||
jQuery(function($) {
|
|
||||||
|
|
||||||
// this.baseUrl = "http://petstore.swagger.wordnik.com/api/resources.json";
|
|
||||||
// this.apiKey = "special-key";
|
|
||||||
|
|
||||||
var ApiSelectionController = Spine.Controller.create({
|
|
||||||
proxied: ["showApi"],
|
|
||||||
|
|
||||||
baseUrlList: new Array(),
|
|
||||||
|
|
||||||
init: function() {
|
|
||||||
if (this.supportsLocalStorage()) {
|
|
||||||
var baseUrl = localStorage.getItem("com.wordnik.swagger.ui.baseUrl");
|
|
||||||
var apiKey = localStorage.getItem("com.wordnik.swagger.ui.apiKey");
|
|
||||||
|
|
||||||
if (baseUrl && baseUrl.length > 0)
|
|
||||||
$("#input_baseUrl").val(baseUrl);
|
|
||||||
|
|
||||||
if (apiKey && apiKey.length > 0)
|
|
||||||
$("#input_apiKey").val(apiKey);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
log("localStorage not supported, user will need to specifiy the api url");
|
|
||||||
}
|
|
||||||
|
|
||||||
$("a#explore").click(this.showApi);
|
|
||||||
|
|
||||||
this.adaptToScale();
|
|
||||||
$(window).resize(function() {
|
|
||||||
apiSelectionController.adaptToScale();
|
|
||||||
});
|
|
||||||
|
|
||||||
this.handleEnter();
|
|
||||||
},
|
|
||||||
|
|
||||||
handleEnter: function(){
|
|
||||||
var self = this;
|
|
||||||
var submit = function() {
|
|
||||||
self.showApi();
|
|
||||||
};
|
|
||||||
$('#input_baseUrl').keydown(function(e) {
|
|
||||||
if(e.which != 13) return;
|
|
||||||
submit();
|
|
||||||
});
|
|
||||||
$('#input_apiKey').keydown(function(e) {
|
|
||||||
if(e.which != 13) return;
|
|
||||||
submit();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
adaptToScale: function() {
|
|
||||||
// var form_width = $('form#api_selector').width();
|
|
||||||
// var inputs_width = 0;
|
|
||||||
// $('form#api_selector div.input').each( function(){ inputs_width += $(this).outerWidth(); });
|
|
||||||
//
|
|
||||||
// // Update with of baseUrl input
|
|
||||||
// var free_width = form_width - inputs_width;
|
|
||||||
// $('#input_baseUrl').width($('#input_baseUrl').width() + free_width - 50);
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
slapOn: function() {
|
|
||||||
// messageController.showMessage("Please enter the base URL of the API that you wish to explore.");
|
|
||||||
$("#content_message").show();
|
|
||||||
$("#resources_container").hide();
|
|
||||||
this.showApi();
|
|
||||||
},
|
|
||||||
|
|
||||||
supportsLocalStorage: function() {
|
|
||||||
try {
|
|
||||||
return 'localStorage' in window && window['localStorage'] !== null;
|
|
||||||
} catch(e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
showApi: function() {
|
|
||||||
var baseUrl = jQuery.trim($("#input_baseUrl").val());
|
|
||||||
var apiKey = jQuery.trim($("#input_apiKey").val());
|
|
||||||
if (baseUrl.length == 0) {
|
|
||||||
$("#input_baseUrl").wiggle();
|
|
||||||
} else {
|
|
||||||
if (this.supportsLocalStorage()) {
|
|
||||||
localStorage.setItem("com.wordnik.swagger.ui.apiKey", apiKey);
|
|
||||||
localStorage.setItem("com.wordnik.swagger.ui.baseUrl", baseUrl);
|
|
||||||
}
|
|
||||||
var resourceListController = ResourceListController.init({
|
|
||||||
baseUrl: baseUrl,
|
|
||||||
apiKey: apiKey
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var MessageController = Spine.Controller.create({
|
|
||||||
showMessage: function(msg) {
|
|
||||||
if (msg) {
|
|
||||||
$("#content_message").html(msg);
|
|
||||||
$("#content_message").show();
|
|
||||||
} else {
|
|
||||||
$("#content_message").html("");
|
|
||||||
$("#content_message").hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
clearMessage: function() {
|
|
||||||
this.showMessage();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
var messageController = MessageController.init();
|
|
||||||
|
|
||||||
// The following heirarchy is followed by these view controllers
|
|
||||||
// ResourceListController
|
|
||||||
// >>> ResourceController
|
|
||||||
// >>> ApiController
|
|
||||||
// >>> OperationController
|
|
||||||
var ResourceListController = Spine.Controller.create({
|
|
||||||
proxied: ["addAll", "addOne"],
|
|
||||||
|
|
||||||
ApiResource: null,
|
|
||||||
|
|
||||||
init: function() {
|
|
||||||
if (this.baseUrl == null) {
|
|
||||||
throw new Error("A baseUrl must be passed to ResourceListController");
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#content_message").hide();
|
|
||||||
$("#resources_container").hide();
|
|
||||||
$("#resources").html("");
|
|
||||||
|
|
||||||
// create and initialize SwaggerService
|
|
||||||
var swaggerService = new SwaggerService(this.baseUrl, this.apiKey,
|
|
||||||
function(msg) {
|
|
||||||
if (msg)
|
|
||||||
messageController.showMessage(msg);
|
|
||||||
else
|
|
||||||
messageController.showMessage("Fetching remote JSON...");
|
|
||||||
});
|
|
||||||
|
|
||||||
// $("#api_host_url").html(swaggerService.apiHost());
|
|
||||||
|
|
||||||
swaggerService.init();
|
|
||||||
|
|
||||||
// Create convenience references to Spine models
|
|
||||||
this.ApiResource = swaggerService.ApiResource();
|
|
||||||
|
|
||||||
this.ApiResource.bind("refresh", this.addAll);
|
|
||||||
},
|
|
||||||
|
|
||||||
addAll: function() {
|
|
||||||
this.ApiResource.each(this.addOne);
|
|
||||||
messageController.clearMessage();
|
|
||||||
$("#resources_container").slideDown(function() {
|
|
||||||
setTimeout(function() {
|
|
||||||
Docs.shebang();
|
|
||||||
},
|
|
||||||
400);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
addOne: function(apiResource) {
|
|
||||||
ResourceController.init({
|
|
||||||
item: apiResource,
|
|
||||||
container: "#resources"
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
var ResourceController = Spine.Controller.create({
|
|
||||||
proxied: ["renderApi", "renderOperation"],
|
|
||||||
|
|
||||||
templateName: "#resourceTemplate",
|
|
||||||
apiResource: null,
|
|
||||||
apiList: null,
|
|
||||||
modelList: null,
|
|
||||||
|
|
||||||
init: function() {
|
|
||||||
this.render();
|
|
||||||
this.apiResource = this.item;
|
|
||||||
this.apiList = this.apiResource.apiList;
|
|
||||||
this.modelList = this.apiResource.modelList;
|
|
||||||
this.apiList.each(this.renderApi);
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function() {
|
|
||||||
$(this.templateName).tmpl(this.item).appendTo(this.container);
|
|
||||||
$('#colophon').fadeIn();
|
|
||||||
},
|
|
||||||
|
|
||||||
renderApi: function(api) {
|
|
||||||
var resourceApisContainer = "#" + this.apiResource.name + "_endpoint_list";
|
|
||||||
ApiController.init({
|
|
||||||
item: api,
|
|
||||||
container: resourceApisContainer
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
var ApiController = Spine.Controller.create({
|
|
||||||
proxied: ["renderOperation"],
|
|
||||||
|
|
||||||
api: null,
|
|
||||||
templateName: "#apiTemplate",
|
|
||||||
|
|
||||||
init: function() {
|
|
||||||
this.render();
|
|
||||||
|
|
||||||
this.api = this.item;
|
|
||||||
|
|
||||||
this.api.operations.each(this.renderOperation);
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function() {
|
|
||||||
$(this.templateName).tmpl(this.item).appendTo(this.container);
|
|
||||||
},
|
|
||||||
|
|
||||||
renderOperation: function(operation) {
|
|
||||||
var operationsContainer = "#" + this.api.name + "_endpoint_operations";
|
|
||||||
OperationController.init({
|
|
||||||
item: operation,
|
|
||||||
container: operationsContainer
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// Param Model
|
|
||||||
// ----------------------------------------------------------------------------------------------
|
|
||||||
var Param = Spine.Model.setup(
|
|
||||||
"Param",
|
|
||||||
["name", "defaultValue", 'description', 'required', 'dataType', 'allowableValues', 'paramType', 'allowMultiple', "readOnly"]
|
|
||||||
);
|
|
||||||
|
|
||||||
Param.include({
|
|
||||||
|
|
||||||
cleanup: function() {
|
|
||||||
this.defaultValue = this.defaultValue || '';
|
|
||||||
},
|
|
||||||
|
|
||||||
templateName: function(){
|
|
||||||
var n = "#paramTemplate";
|
|
||||||
|
|
||||||
if (this.allowableValues && this.allowableValues.valueType == "LIST") {
|
|
||||||
n += "Select";
|
|
||||||
} else {
|
|
||||||
if (this.required) n += "Required";
|
|
||||||
if (this.readOnly) n += "ReadOnly";
|
|
||||||
}
|
|
||||||
|
|
||||||
return(n);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
var OperationController = Spine.Controller.create({
|
|
||||||
proxied: ["submitOperation", "showResponse", "showErrorStatus", "showCompleteStatus"],
|
|
||||||
|
|
||||||
operation: null,
|
|
||||||
templateName: "#operationTemplate",
|
|
||||||
elementScope: "#operationTemplate",
|
|
||||||
|
|
||||||
init: function() {
|
|
||||||
this.render();
|
|
||||||
|
|
||||||
this.operation = this.item;
|
|
||||||
this.isGetOperation = (this.operation.httpMethodLowercase == "get");
|
|
||||||
this.elementScope = "#" + this.operation.apiName + "_" + this.operation.nickname + "_" + this.operation.httpMethod;
|
|
||||||
|
|
||||||
this.renderParams();
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function() {
|
|
||||||
$(this.templateName).tmpl(this.item).appendTo(this.container);
|
|
||||||
},
|
|
||||||
|
|
||||||
renderParams: function() {
|
|
||||||
if (this.operation.parameters && this.operation.parameters.count() > 0) {
|
|
||||||
var operationParamsContainer = this.elementScope + "_params";
|
|
||||||
|
|
||||||
for (var p = 0; p < this.operation.parameters.count(); p++) {
|
|
||||||
var param = Param.init(this.operation.parameters.all()[p]);
|
|
||||||
// Only GET operations display forms..
|
|
||||||
param.readOnly = !this.isGetOperation;
|
|
||||||
param.cleanup();
|
|
||||||
|
|
||||||
$(param.templateName()).tmpl(param).appendTo(operationParamsContainer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var submitButtonId = this.elementScope + "_content_sandbox_response_button";
|
|
||||||
if (this.isGetOperation) {
|
|
||||||
$(submitButtonId).click(this.submitOperation);
|
|
||||||
} else {
|
|
||||||
$(submitButtonId).hide();
|
|
||||||
|
|
||||||
var valueHeader = this.elementScope + "_value_header";
|
|
||||||
$(valueHeader).html("Default Value");
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
submitOperation: function() {
|
|
||||||
var form = $(this.elementScope + "_form");
|
|
||||||
var error_free = true;
|
|
||||||
var missing_input = null;
|
|
||||||
|
|
||||||
// Cycle through the form's required inputs
|
|
||||||
form.find("input.required").each(function() {
|
|
||||||
|
|
||||||
// Remove any existing error styles from the input
|
|
||||||
$(this).removeClass('error');
|
|
||||||
|
|
||||||
// Tack the error style on if the input is empty..
|
|
||||||
if ($(this).val() == '') {
|
|
||||||
if (missing_input == null)
|
|
||||||
missing_input = $(this);
|
|
||||||
$(this).addClass('error');
|
|
||||||
$(this).wiggle();
|
|
||||||
error_free = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
if (error_free) {
|
|
||||||
var invocationUrl = this.operation.invocationUrl(form.serializeArray());
|
|
||||||
$(".request_url", this.elementScope + "_content_sandbox_response").html("<pre>" + invocationUrl + "</pre>");
|
|
||||||
$.getJSON(invocationUrl, this.showResponse).complete(this.showCompleteStatus).error(this.showErrorStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
|
||||||
|
|
||||||
showResponse: function(response) {
|
|
||||||
// log(response);
|
|
||||||
var prettyJson = JSON.stringify(response, null, "\t").replace(/\n/g, "<br>");
|
|
||||||
// log(prettyJson);
|
|
||||||
$(".response_body", this.elementScope + "_content_sandbox_response").html(prettyJson);
|
|
||||||
|
|
||||||
$(this.elementScope + "_content_sandbox_response").slideDown();
|
|
||||||
},
|
|
||||||
|
|
||||||
showErrorStatus: function(data) {
|
|
||||||
// log("error " + data.status);
|
|
||||||
this.showStatus(data);
|
|
||||||
$(this.elementScope + "_content_sandbox_response").slideDown();
|
|
||||||
},
|
|
||||||
|
|
||||||
showCompleteStatus: function(data) {
|
|
||||||
// log("complete " + data.status);
|
|
||||||
this.showStatus(data);
|
|
||||||
},
|
|
||||||
|
|
||||||
showStatus: function(data) {
|
|
||||||
// log(data);
|
|
||||||
// log(data.getAllResponseHeaders());
|
|
||||||
var response_body = "<pre>" + JSON.stringify(JSON.parse(data.responseText), null, 2).replace(/\n/g, "<br>") + "</pre>";
|
|
||||||
$(".response_code", this.elementScope + "_content_sandbox_response").html("<pre>" + data.status + "</pre>");
|
|
||||||
$(".response_body", this.elementScope + "_content_sandbox_response").html(response_body);
|
|
||||||
$(".response_headers", this.elementScope + "_content_sandbox_response").html("<pre>" + data.getAllResponseHeaders() + "</pre>");
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// Attach controller to window*
|
|
||||||
window.apiSelectionController = ApiSelectionController.init();
|
|
||||||
|
|
||||||
if (this.baseUrl) {
|
|
||||||
window.resourceListController = ResourceListController.init({
|
|
||||||
baseUrl: this.baseUrl,
|
|
||||||
apiKey: this.apiKey
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
apiSelectionController.slapOn();
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
27
build/javascripts/underscore-min.js
vendored
27
build/javascripts/underscore-min.js
vendored
@@ -1,27 +0,0 @@
|
|||||||
// Underscore.js 1.1.7
|
|
||||||
// (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
|
|
||||||
// Underscore is freely distributable under the MIT license.
|
|
||||||
// Portions of Underscore are inspired or borrowed from Prototype,
|
|
||||||
// Oliver Steele's Functional, and John Resig's Micro-Templating.
|
|
||||||
// For all details and documentation:
|
|
||||||
// http://documentcloud.github.com/underscore
|
|
||||||
(function(){var p=this,C=p._,m={},i=Array.prototype,n=Object.prototype,f=i.slice,D=i.unshift,E=n.toString,l=n.hasOwnProperty,s=i.forEach,t=i.map,u=i.reduce,v=i.reduceRight,w=i.filter,x=i.every,y=i.some,o=i.indexOf,z=i.lastIndexOf;n=Array.isArray;var F=Object.keys,q=Function.prototype.bind,b=function(a){return new j(a)};typeof module!=="undefined"&&module.exports?(module.exports=b,b._=b):p._=b;b.VERSION="1.1.7";var h=b.each=b.forEach=function(a,c,b){if(a!=null)if(s&&a.forEach===s)a.forEach(c,b);else if(a.length===
|
|
||||||
+a.length)for(var e=0,k=a.length;e<k;e++){if(e in a&&c.call(b,a[e],e,a)===m)break}else for(e in a)if(l.call(a,e)&&c.call(b,a[e],e,a)===m)break};b.map=function(a,c,b){var e=[];if(a==null)return e;if(t&&a.map===t)return a.map(c,b);h(a,function(a,g,G){e[e.length]=c.call(b,a,g,G)});return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var k=d!==void 0;a==null&&(a=[]);if(u&&a.reduce===u)return e&&(c=b.bind(c,e)),k?a.reduce(c,d):a.reduce(c);h(a,function(a,b,f){k?d=c.call(e,d,a,b,f):(d=a,k=!0)});if(!k)throw new TypeError("Reduce of empty array with no initial value");
|
|
||||||
return d};b.reduceRight=b.foldr=function(a,c,d,e){a==null&&(a=[]);if(v&&a.reduceRight===v)return e&&(c=b.bind(c,e)),d!==void 0?a.reduceRight(c,d):a.reduceRight(c);a=(b.isArray(a)?a.slice():b.toArray(a)).reverse();return b.reduce(a,c,d,e)};b.find=b.detect=function(a,c,b){var e;A(a,function(a,g,f){if(c.call(b,a,g,f))return e=a,!0});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(w&&a.filter===w)return a.filter(c,b);h(a,function(a,g,f){c.call(b,a,g,f)&&(e[e.length]=a)});return e};
|
|
||||||
b.reject=function(a,c,b){var e=[];if(a==null)return e;h(a,function(a,g,f){c.call(b,a,g,f)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=!0;if(a==null)return e;if(x&&a.every===x)return a.every(c,b);h(a,function(a,g,f){if(!(e=e&&c.call(b,a,g,f)))return m});return e};var A=b.some=b.any=function(a,c,d){c=c||b.identity;var e=!1;if(a==null)return e;if(y&&a.some===y)return a.some(c,d);h(a,function(a,b,f){if(e|=c.call(d,a,b,f))return m});return!!e};b.include=b.contains=function(a,c){var b=
|
|
||||||
!1;if(a==null)return b;if(o&&a.indexOf===o)return a.indexOf(c)!=-1;A(a,function(a){if(b=a===c)return!0});return b};b.invoke=function(a,c){var d=f.call(arguments,2);return b.map(a,function(a){return(c.call?c||a:a[c]).apply(a,d)})};b.pluck=function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);var e={computed:-Infinity};h(a,function(a,b,f){b=c?c.call(d,a,b,f):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,
|
|
||||||
c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);var e={computed:Infinity};h(a,function(a,b,f){b=c?c.call(d,a,b,f):a;b<e.computed&&(e={value:a,computed:b})});return e.value};b.sortBy=function(a,c,d){return b.pluck(b.map(a,function(a,b,f){return{value:a,criteria:c.call(d,a,b,f)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,b){var d={};h(a,function(a,f){var g=b(a,f);(d[g]||(d[g]=[])).push(a)});return d};b.sortedIndex=function(a,c,d){d||
|
|
||||||
(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){if(!a)return[];if(a.toArray)return a.toArray();if(b.isArray(a))return f.call(a);if(b.isArguments(a))return f.call(a);return b.values(a)};b.size=function(a){return b.toArray(a).length};b.first=b.head=function(a,b,d){return b!=null&&!d?f.call(a,0,b):a[0]};b.rest=b.tail=function(a,b,d){return f.call(a,b==null||d?1:b)};b.last=function(a){return a[a.length-1]};b.compact=function(a){return b.filter(a,
|
|
||||||
function(a){return!!a})};b.flatten=function(a){return b.reduce(a,function(a,d){if(b.isArray(d))return a.concat(b.flatten(d));a[a.length]=d;return a},[])};b.without=function(a){return b.difference(a,f.call(arguments,1))};b.uniq=b.unique=function(a,c){return b.reduce(a,function(a,e,f){if(0==f||(c===!0?b.last(a)!=e:!b.include(a,e)))a[a.length]=e;return a},[])};b.union=function(){return b.uniq(b.flatten(arguments))};b.intersection=b.intersect=function(a){var c=f.call(arguments,1);return b.filter(b.uniq(a),
|
|
||||||
function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a,c){return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=f.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,d){if(a==null)return-1;var e;if(d)return d=b.sortedIndex(a,c),a[d]===c?d:-1;if(o&&a.indexOf===o)return a.indexOf(c);d=0;for(e=a.length;d<e;d++)if(a[d]===c)return d;return-1};b.lastIndexOf=function(a,
|
|
||||||
b){if(a==null)return-1;if(z&&a.lastIndexOf===z)return a.lastIndexOf(b);for(var d=a.length;d--;)if(a[d]===b)return d;return-1};b.range=function(a,b,d){arguments.length<=1&&(b=a||0,a=0);d=arguments[2]||1;for(var e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;)g[f++]=a,a+=d;return g};b.bind=function(a,b){if(a.bind===q&&q)return q.apply(a,f.call(arguments,1));var d=f.call(arguments,2);return function(){return a.apply(b,d.concat(f.call(arguments)))}};b.bindAll=function(a){var c=f.call(arguments,1);
|
|
||||||
c.length==0&&(c=b.functions(a));h(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,c){var d={};c||(c=b.identity);return function(){var b=c.apply(this,arguments);return l.call(d,b)?d[b]:d[b]=a.apply(this,arguments)}};b.delay=function(a,b){var d=f.call(arguments,2);return setTimeout(function(){return a.apply(a,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(f.call(arguments,1)))};var B=function(a,b,d){var e;return function(){var f=this,g=arguments,h=function(){e=null;
|
|
||||||
a.apply(f,g)};d&&clearTimeout(e);if(d||!e)e=setTimeout(h,b)}};b.throttle=function(a,b){return B(a,b,!1)};b.debounce=function(a,b){return B(a,b,!0)};b.once=function(a){var b=!1,d;return function(){if(b)return d;b=!0;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(f.call(arguments));return b.apply(this,d)}};b.compose=function(){var a=f.call(arguments);return function(){for(var b=f.call(arguments),d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};b.after=
|
|
||||||
function(a,b){return function(){if(--a<1)return b.apply(this,arguments)}};b.keys=F||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var b=[],d;for(d in a)l.call(a,d)&&(b[b.length]=d);return b};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){h(f.call(arguments,1),function(b){for(var d in b)b[d]!==void 0&&(a[d]=b[d])});return a};b.defaults=function(a){h(f.call(arguments,
|
|
||||||
1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,c){if(a===c)return!0;var d=typeof a;if(d!=typeof c)return!1;if(a==c)return!0;if(!a&&c||a&&!c)return!1;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual)return a.isEqual(c);if(c.isEqual)return c.isEqual(a);if(b.isDate(a)&&b.isDate(c))return a.getTime()===c.getTime();if(b.isNaN(a)&&b.isNaN(c))return!1;
|
|
||||||
if(b.isRegExp(a)&&b.isRegExp(c))return a.source===c.source&&a.global===c.global&&a.ignoreCase===c.ignoreCase&&a.multiline===c.multiline;if(d!=="object")return!1;if(a.length&&a.length!==c.length)return!1;d=b.keys(a);var e=b.keys(c);if(d.length!=e.length)return!1;for(var f in a)if(!(f in c)||!b.isEqual(a[f],c[f]))return!1;return!0};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(l.call(a,c))return!1;return!0};b.isElement=function(a){return!!(a&&a.nodeType==
|
|
||||||
1)};b.isArray=n||function(a){return E.call(a)==="[object Array]"};b.isObject=function(a){return a===Object(a)};b.isArguments=function(a){return!(!a||!l.call(a,"callee"))};b.isFunction=function(a){return!(!a||!a.constructor||!a.call||!a.apply)};b.isString=function(a){return!!(a===""||a&&a.charCodeAt&&a.substr)};b.isNumber=function(a){return!!(a===0||a&&a.toExponential&&a.toFixed)};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===!0||a===!1};b.isDate=function(a){return!(!a||!a.getTimezoneOffset||
|
|
||||||
!a.setUTCFullYear)};b.isRegExp=function(a){return!(!a||!a.test||!a.exec||!(a.ignoreCase||a.ignoreCase===!1))};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.noConflict=function(){p._=C;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.mixin=function(a){h(b.functions(a),function(c){H(c,b[c]=a[c])})};var I=0;b.uniqueId=function(a){var b=I++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g};
|
|
||||||
b.template=function(a,c){var d=b.templateSettings;d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.interpolate,function(a,b){return"',"+b.replace(/\\'/g,"'")+",'"}).replace(d.evaluate||null,function(a,b){return"');"+b.replace(/\\'/g,"'").replace(/[\r\n\t]/g," ")+"__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');";d=new Function("obj",d);return c?d(c):d};
|
|
||||||
var j=function(a){this._wrapped=a};b.prototype=j.prototype;var r=function(a,c){return c?b(a).chain():a},H=function(a,c){j.prototype[a]=function(){var a=f.call(arguments);D.call(a,this._wrapped);return r(c.apply(b,a),this._chain)}};b.mixin(b);h(["pop","push","reverse","shift","sort","splice","unshift"],function(a){var b=i[a];j.prototype[a]=function(){b.apply(this._wrapped,arguments);return r(this._wrapped,this._chain)}});h(["concat","join","slice"],function(a){var b=i[a];j.prototype[a]=function(){return r(b.apply(this._wrapped,
|
|
||||||
arguments),this._chain)}});j.prototype.chain=function(){this._chain=!0;return this};j.prototype.value=function(){return this._wrapped}})();
|
|
||||||
94
config.rb
94
config.rb
@@ -1,94 +0,0 @@
|
|||||||
###
|
|
||||||
# Compass
|
|
||||||
###
|
|
||||||
|
|
||||||
# Susy grids in Compass
|
|
||||||
# First: gem install compass-susy-plugin
|
|
||||||
# require 'susy'
|
|
||||||
|
|
||||||
# Change Compass configuration
|
|
||||||
# compass_config do |config|
|
|
||||||
# config.output_style = :compact
|
|
||||||
# end
|
|
||||||
|
|
||||||
###
|
|
||||||
# Haml
|
|
||||||
###
|
|
||||||
|
|
||||||
# CodeRay syntax highlighting in Haml
|
|
||||||
# First: gem install haml-coderay
|
|
||||||
# require 'haml-coderay'
|
|
||||||
|
|
||||||
# CoffeeScript filters in Haml
|
|
||||||
# First: gem install coffee-filter
|
|
||||||
# require 'coffee-filter'
|
|
||||||
|
|
||||||
# Automatic image dimensions on image_tag helper
|
|
||||||
# activate :automatic_image_sizes
|
|
||||||
|
|
||||||
###
|
|
||||||
# Page command
|
|
||||||
###
|
|
||||||
|
|
||||||
# Per-page layout changes:
|
|
||||||
#
|
|
||||||
# With no layout
|
|
||||||
# page "/path/to/file.html", :layout => false
|
|
||||||
#
|
|
||||||
# With alternative layout
|
|
||||||
# page "/path/to/file.html", :layout => :otherlayout
|
|
||||||
#
|
|
||||||
# A path which all have the same layout
|
|
||||||
# with_layout :admin do
|
|
||||||
# page "/admin/*"
|
|
||||||
# end
|
|
||||||
|
|
||||||
# Proxy (fake) files
|
|
||||||
# page "/this-page-has-no-template.html", :proxy => "/template-file.html" do
|
|
||||||
# @which_fake_page = "Rendering a fake page with a variable"
|
|
||||||
# end
|
|
||||||
|
|
||||||
###
|
|
||||||
# Helpers
|
|
||||||
###
|
|
||||||
|
|
||||||
# Methods defined in the helpers block are available in templates
|
|
||||||
helpers do
|
|
||||||
|
|
||||||
def jquery_template(id, &block)
|
|
||||||
content_tag(:script, capture(&block), :id => id, :type => "text/x-jquery-tmpl")
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
# Change the CSS directory
|
|
||||||
# set :css_dir, "alternative_css_directory"
|
|
||||||
|
|
||||||
# Change the JS directory
|
|
||||||
# set :js_dir, "alternative_js_directory"
|
|
||||||
|
|
||||||
# Change the images directory
|
|
||||||
# set :images_dir, "alternative_image_directory"
|
|
||||||
|
|
||||||
# Build-specific configuration
|
|
||||||
configure :build do
|
|
||||||
# For example, change the Compass output style for deployment
|
|
||||||
# activate :minify_css
|
|
||||||
|
|
||||||
# Minify Javascript on build
|
|
||||||
# activate :minify_javascript
|
|
||||||
|
|
||||||
# Enable cache buster
|
|
||||||
# activate :cache_buster
|
|
||||||
|
|
||||||
# Use relative URLs
|
|
||||||
# activate :relative_assets
|
|
||||||
|
|
||||||
# Compress PNGs after build
|
|
||||||
# First: gem install middleman-smusher
|
|
||||||
# require "middleman-smusher"
|
|
||||||
# activate :smusher
|
|
||||||
|
|
||||||
# Or use a different image path
|
|
||||||
# set :http_path, "/Content/images/"
|
|
||||||
end
|
|
||||||
38
lib/backbone-min.js
vendored
Normal file
38
lib/backbone-min.js
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
// Backbone.js 0.9.2
|
||||||
|
|
||||||
|
// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc.
|
||||||
|
// Backbone may be freely distributed under the MIT license.
|
||||||
|
// For all details and documentation:
|
||||||
|
// http://backbonejs.org
|
||||||
|
(function(){var l=this,y=l.Backbone,z=Array.prototype.slice,A=Array.prototype.splice,g;g="undefined"!==typeof exports?exports:l.Backbone={};g.VERSION="0.9.2";var f=l._;!f&&"undefined"!==typeof require&&(f=require("underscore"));var i=l.jQuery||l.Zepto||l.ender;g.setDomLibrary=function(a){i=a};g.noConflict=function(){l.Backbone=y;return this};g.emulateHTTP=!1;g.emulateJSON=!1;var p=/\s+/,k=g.Events={on:function(a,b,c){var d,e,f,g,j;if(!b)return this;a=a.split(p);for(d=this._callbacks||(this._callbacks=
|
||||||
|
{});e=a.shift();)f=(j=d[e])?j.tail:{},f.next=g={},f.context=c,f.callback=b,d[e]={tail:g,next:j?j.next:f};return this},off:function(a,b,c){var d,e,h,g,j,q;if(e=this._callbacks){if(!a&&!b&&!c)return delete this._callbacks,this;for(a=a?a.split(p):f.keys(e);d=a.shift();)if(h=e[d],delete e[d],h&&(b||c))for(g=h.tail;(h=h.next)!==g;)if(j=h.callback,q=h.context,b&&j!==b||c&&q!==c)this.on(d,j,q);return this}},trigger:function(a){var b,c,d,e,f,g;if(!(d=this._callbacks))return this;f=d.all;a=a.split(p);for(g=
|
||||||
|
z.call(arguments,1);b=a.shift();){if(c=d[b])for(e=c.tail;(c=c.next)!==e;)c.callback.apply(c.context||this,g);if(c=f){e=c.tail;for(b=[b].concat(g);(c=c.next)!==e;)c.callback.apply(c.context||this,b)}}return this}};k.bind=k.on;k.unbind=k.off;var o=g.Model=function(a,b){var c;a||(a={});b&&b.parse&&(a=this.parse(a));if(c=n(this,"defaults"))a=f.extend({},c,a);b&&b.collection&&(this.collection=b.collection);this.attributes={};this._escapedAttributes={};this.cid=f.uniqueId("c");this.changed={};this._silent=
|
||||||
|
{};this._pending={};this.set(a,{silent:!0});this.changed={};this._silent={};this._pending={};this._previousAttributes=f.clone(this.attributes);this.initialize.apply(this,arguments)};f.extend(o.prototype,k,{changed:null,_silent:null,_pending:null,idAttribute:"id",initialize:function(){},toJSON:function(){return f.clone(this.attributes)},get:function(a){return this.attributes[a]},escape:function(a){var b;if(b=this._escapedAttributes[a])return b;b=this.get(a);return this._escapedAttributes[a]=f.escape(null==
|
||||||
|
b?"":""+b)},has:function(a){return null!=this.get(a)},set:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c||(c={});if(!d)return this;d instanceof o&&(d=d.attributes);if(c.unset)for(e in d)d[e]=void 0;if(!this._validate(d,c))return!1;this.idAttribute in d&&(this.id=d[this.idAttribute]);var b=c.changes={},h=this.attributes,g=this._escapedAttributes,j=this._previousAttributes||{};for(e in d){a=d[e];if(!f.isEqual(h[e],a)||c.unset&&f.has(h,e))delete g[e],(c.silent?this._silent:
|
||||||
|
b)[e]=!0;c.unset?delete h[e]:h[e]=a;!f.isEqual(j[e],a)||f.has(h,e)!=f.has(j,e)?(this.changed[e]=a,c.silent||(this._pending[e]=!0)):(delete this.changed[e],delete this._pending[e])}c.silent||this.change(c);return this},unset:function(a,b){(b||(b={})).unset=!0;return this.set(a,null,b)},clear:function(a){(a||(a={})).unset=!0;return this.set(f.clone(this.attributes),a)},fetch:function(a){var a=a?f.clone(a):{},b=this,c=a.success;a.success=function(d,e,f){if(!b.set(b.parse(d,f),a))return!1;c&&c(b,d)};
|
||||||
|
a.error=g.wrapError(a.error,b,a);return(this.sync||g.sync).call(this,"read",this,a)},save:function(a,b,c){var d,e;f.isObject(a)||null==a?(d=a,c=b):(d={},d[a]=b);c=c?f.clone(c):{};if(c.wait){if(!this._validate(d,c))return!1;e=f.clone(this.attributes)}a=f.extend({},c,{silent:!0});if(d&&!this.set(d,c.wait?a:c))return!1;var h=this,i=c.success;c.success=function(a,b,e){b=h.parse(a,e);if(c.wait){delete c.wait;b=f.extend(d||{},b)}if(!h.set(b,c))return false;i?i(h,a):h.trigger("sync",h,a,c)};c.error=g.wrapError(c.error,
|
||||||
|
h,c);b=this.isNew()?"create":"update";b=(this.sync||g.sync).call(this,b,this,c);c.wait&&this.set(e,a);return b},destroy:function(a){var a=a?f.clone(a):{},b=this,c=a.success,d=function(){b.trigger("destroy",b,b.collection,a)};if(this.isNew())return d(),!1;a.success=function(e){a.wait&&d();c?c(b,e):b.trigger("sync",b,e,a)};a.error=g.wrapError(a.error,b,a);var e=(this.sync||g.sync).call(this,"delete",this,a);a.wait||d();return e},url:function(){var a=n(this,"urlRoot")||n(this.collection,"url")||t();
|
||||||
|
return this.isNew()?a:a+("/"==a.charAt(a.length-1)?"":"/")+encodeURIComponent(this.id)},parse:function(a){return a},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return null==this.id},change:function(a){a||(a={});var b=this._changing;this._changing=!0;for(var c in this._silent)this._pending[c]=!0;var d=f.extend({},a.changes,this._silent);this._silent={};for(c in d)this.trigger("change:"+c,this,this.get(c),a);if(b)return this;for(;!f.isEmpty(this._pending);){this._pending=
|
||||||
|
{};this.trigger("change",this,a);for(c in this.changed)!this._pending[c]&&!this._silent[c]&&delete this.changed[c];this._previousAttributes=f.clone(this.attributes)}this._changing=!1;return this},hasChanged:function(a){return!arguments.length?!f.isEmpty(this.changed):f.has(this.changed,a)},changedAttributes:function(a){if(!a)return this.hasChanged()?f.clone(this.changed):!1;var b,c=!1,d=this._previousAttributes,e;for(e in a)if(!f.isEqual(d[e],b=a[e]))(c||(c={}))[e]=b;return c},previous:function(a){return!arguments.length||
|
||||||
|
!this._previousAttributes?null:this._previousAttributes[a]},previousAttributes:function(){return f.clone(this._previousAttributes)},isValid:function(){return!this.validate(this.attributes)},_validate:function(a,b){if(b.silent||!this.validate)return!0;var a=f.extend({},this.attributes,a),c=this.validate(a,b);if(!c)return!0;b&&b.error?b.error(this,c,b):this.trigger("error",this,c,b);return!1}});var r=g.Collection=function(a,b){b||(b={});b.model&&(this.model=b.model);b.comparator&&(this.comparator=b.comparator);
|
||||||
|
this._reset();this.initialize.apply(this,arguments);a&&this.reset(a,{silent:!0,parse:b.parse})};f.extend(r.prototype,k,{model:o,initialize:function(){},toJSON:function(a){return this.map(function(b){return b.toJSON(a)})},add:function(a,b){var c,d,e,g,i,j={},k={},l=[];b||(b={});a=f.isArray(a)?a.slice():[a];c=0;for(d=a.length;c<d;c++){if(!(e=a[c]=this._prepareModel(a[c],b)))throw Error("Can't add an invalid model to a collection");g=e.cid;i=e.id;j[g]||this._byCid[g]||null!=i&&(k[i]||this._byId[i])?
|
||||||
|
l.push(c):j[g]=k[i]=e}for(c=l.length;c--;)a.splice(l[c],1);c=0;for(d=a.length;c<d;c++)(e=a[c]).on("all",this._onModelEvent,this),this._byCid[e.cid]=e,null!=e.id&&(this._byId[e.id]=e);this.length+=d;A.apply(this.models,[null!=b.at?b.at:this.models.length,0].concat(a));this.comparator&&this.sort({silent:!0});if(b.silent)return this;c=0;for(d=this.models.length;c<d;c++)if(j[(e=this.models[c]).cid])b.index=c,e.trigger("add",e,this,b);return this},remove:function(a,b){var c,d,e,g;b||(b={});a=f.isArray(a)?
|
||||||
|
a.slice():[a];c=0;for(d=a.length;c<d;c++)if(g=this.getByCid(a[c])||this.get(a[c]))delete this._byId[g.id],delete this._byCid[g.cid],e=this.indexOf(g),this.models.splice(e,1),this.length--,b.silent||(b.index=e,g.trigger("remove",g,this,b)),this._removeReference(g);return this},push:function(a,b){a=this._prepareModel(a,b);this.add(a,b);return a},pop:function(a){var b=this.at(this.length-1);this.remove(b,a);return b},unshift:function(a,b){a=this._prepareModel(a,b);this.add(a,f.extend({at:0},b));return a},
|
||||||
|
shift:function(a){var b=this.at(0);this.remove(b,a);return b},get:function(a){return null==a?void 0:this._byId[null!=a.id?a.id:a]},getByCid:function(a){return a&&this._byCid[a.cid||a]},at:function(a){return this.models[a]},where:function(a){return f.isEmpty(a)?[]:this.filter(function(b){for(var c in a)if(a[c]!==b.get(c))return!1;return!0})},sort:function(a){a||(a={});if(!this.comparator)throw Error("Cannot sort a set without a comparator");var b=f.bind(this.comparator,this);1==this.comparator.length?
|
||||||
|
this.models=this.sortBy(b):this.models.sort(b);a.silent||this.trigger("reset",this,a);return this},pluck:function(a){return f.map(this.models,function(b){return b.get(a)})},reset:function(a,b){a||(a=[]);b||(b={});for(var c=0,d=this.models.length;c<d;c++)this._removeReference(this.models[c]);this._reset();this.add(a,f.extend({silent:!0},b));b.silent||this.trigger("reset",this,b);return this},fetch:function(a){a=a?f.clone(a):{};void 0===a.parse&&(a.parse=!0);var b=this,c=a.success;a.success=function(d,
|
||||||
|
e,f){b[a.add?"add":"reset"](b.parse(d,f),a);c&&c(b,d)};a.error=g.wrapError(a.error,b,a);return(this.sync||g.sync).call(this,"read",this,a)},create:function(a,b){var c=this,b=b?f.clone(b):{},a=this._prepareModel(a,b);if(!a)return!1;b.wait||c.add(a,b);var d=b.success;b.success=function(e,f){b.wait&&c.add(e,b);d?d(e,f):e.trigger("sync",a,f,b)};a.save(null,b);return a},parse:function(a){return a},chain:function(){return f(this.models).chain()},_reset:function(){this.length=0;this.models=[];this._byId=
|
||||||
|
{};this._byCid={}},_prepareModel:function(a,b){b||(b={});a instanceof o?a.collection||(a.collection=this):(b.collection=this,a=new this.model(a,b),a._validate(a.attributes,b)||(a=!1));return a},_removeReference:function(a){this==a.collection&&delete a.collection;a.off("all",this._onModelEvent,this)},_onModelEvent:function(a,b,c,d){("add"==a||"remove"==a)&&c!=this||("destroy"==a&&this.remove(b,d),b&&a==="change:"+b.idAttribute&&(delete this._byId[b.previous(b.idAttribute)],this._byId[b.id]=b),this.trigger.apply(this,
|
||||||
|
arguments))}});f.each("forEach,each,map,reduce,reduceRight,find,detect,filter,select,reject,every,all,some,any,include,contains,invoke,max,min,sortBy,sortedIndex,toArray,size,first,initial,rest,last,without,indexOf,shuffle,lastIndexOf,isEmpty,groupBy".split(","),function(a){r.prototype[a]=function(){return f[a].apply(f,[this.models].concat(f.toArray(arguments)))}});var u=g.Router=function(a){a||(a={});a.routes&&(this.routes=a.routes);this._bindRoutes();this.initialize.apply(this,arguments)},B=/:\w+/g,
|
||||||
|
C=/\*\w+/g,D=/[-[\]{}()+?.,\\^$|#\s]/g;f.extend(u.prototype,k,{initialize:function(){},route:function(a,b,c){g.history||(g.history=new m);f.isRegExp(a)||(a=this._routeToRegExp(a));c||(c=this[b]);g.history.route(a,f.bind(function(d){d=this._extractParameters(a,d);c&&c.apply(this,d);this.trigger.apply(this,["route:"+b].concat(d));g.history.trigger("route",this,b,d)},this));return this},navigate:function(a,b){g.history.navigate(a,b)},_bindRoutes:function(){if(this.routes){var a=[],b;for(b in this.routes)a.unshift([b,
|
||||||
|
this.routes[b]]);b=0;for(var c=a.length;b<c;b++)this.route(a[b][0],a[b][1],this[a[b][1]])}},_routeToRegExp:function(a){a=a.replace(D,"\\$&").replace(B,"([^/]+)").replace(C,"(.*?)");return RegExp("^"+a+"$")},_extractParameters:function(a,b){return a.exec(b).slice(1)}});var m=g.History=function(){this.handlers=[];f.bindAll(this,"checkUrl")},s=/^[#\/]/,E=/msie [\w.]+/;m.started=!1;f.extend(m.prototype,k,{interval:50,getHash:function(a){return(a=(a?a.location:window.location).href.match(/#(.*)$/))?a[1]:
|
||||||
|
""},getFragment:function(a,b){if(null==a)if(this._hasPushState||b){var a=window.location.pathname,c=window.location.search;c&&(a+=c)}else a=this.getHash();a.indexOf(this.options.root)||(a=a.substr(this.options.root.length));return a.replace(s,"")},start:function(a){if(m.started)throw Error("Backbone.history has already been started");m.started=!0;this.options=f.extend({},{root:"/"},this.options,a);this._wantsHashChange=!1!==this.options.hashChange;this._wantsPushState=!!this.options.pushState;this._hasPushState=
|
||||||
|
!(!this.options.pushState||!window.history||!window.history.pushState);var a=this.getFragment(),b=document.documentMode;if(b=E.exec(navigator.userAgent.toLowerCase())&&(!b||7>=b))this.iframe=i('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow,this.navigate(a);this._hasPushState?i(window).bind("popstate",this.checkUrl):this._wantsHashChange&&"onhashchange"in window&&!b?i(window).bind("hashchange",this.checkUrl):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,
|
||||||
|
this.interval));this.fragment=a;a=window.location;b=a.pathname==this.options.root;if(this._wantsHashChange&&this._wantsPushState&&!this._hasPushState&&!b)return this.fragment=this.getFragment(null,!0),window.location.replace(this.options.root+"#"+this.fragment),!0;this._wantsPushState&&this._hasPushState&&b&&a.hash&&(this.fragment=this.getHash().replace(s,""),window.history.replaceState({},document.title,a.protocol+"//"+a.host+this.options.root+this.fragment));if(!this.options.silent)return this.loadUrl()},
|
||||||
|
stop:function(){i(window).unbind("popstate",this.checkUrl).unbind("hashchange",this.checkUrl);clearInterval(this._checkUrlInterval);m.started=!1},route:function(a,b){this.handlers.unshift({route:a,callback:b})},checkUrl:function(){var a=this.getFragment();a==this.fragment&&this.iframe&&(a=this.getFragment(this.getHash(this.iframe)));if(a==this.fragment)return!1;this.iframe&&this.navigate(a);this.loadUrl()||this.loadUrl(this.getHash())},loadUrl:function(a){var b=this.fragment=this.getFragment(a);return f.any(this.handlers,
|
||||||
|
function(a){if(a.route.test(b))return a.callback(b),!0})},navigate:function(a,b){if(!m.started)return!1;if(!b||!0===b)b={trigger:b};var c=(a||"").replace(s,"");this.fragment!=c&&(this._hasPushState?(0!=c.indexOf(this.options.root)&&(c=this.options.root+c),this.fragment=c,window.history[b.replace?"replaceState":"pushState"]({},document.title,c)):this._wantsHashChange?(this.fragment=c,this._updateHash(window.location,c,b.replace),this.iframe&&c!=this.getFragment(this.getHash(this.iframe))&&(b.replace||
|
||||||
|
this.iframe.document.open().close(),this._updateHash(this.iframe.location,c,b.replace))):window.location.assign(this.options.root+a),b.trigger&&this.loadUrl(a))},_updateHash:function(a,b,c){c?a.replace(a.toString().replace(/(javascript:|#).*$/,"")+"#"+b):a.hash=b}});var v=g.View=function(a){this.cid=f.uniqueId("view");this._configure(a||{});this._ensureElement();this.initialize.apply(this,arguments);this.delegateEvents()},F=/^(\S+)\s*(.*)$/,w="model,collection,el,id,attributes,className,tagName".split(",");
|
||||||
|
f.extend(v.prototype,k,{tagName:"div",$:function(a){return this.$el.find(a)},initialize:function(){},render:function(){return this},remove:function(){this.$el.remove();return this},make:function(a,b,c){a=document.createElement(a);b&&i(a).attr(b);c&&i(a).html(c);return a},setElement:function(a,b){this.$el&&this.undelegateEvents();this.$el=a instanceof i?a:i(a);this.el=this.$el[0];!1!==b&&this.delegateEvents();return this},delegateEvents:function(a){if(a||(a=n(this,"events"))){this.undelegateEvents();
|
||||||
|
for(var b in a){var c=a[b];f.isFunction(c)||(c=this[a[b]]);if(!c)throw Error('Method "'+a[b]+'" does not exist');var d=b.match(F),e=d[1],d=d[2],c=f.bind(c,this),e=e+(".delegateEvents"+this.cid);""===d?this.$el.bind(e,c):this.$el.delegate(d,e,c)}}},undelegateEvents:function(){this.$el.unbind(".delegateEvents"+this.cid)},_configure:function(a){this.options&&(a=f.extend({},this.options,a));for(var b=0,c=w.length;b<c;b++){var d=w[b];a[d]&&(this[d]=a[d])}this.options=a},_ensureElement:function(){if(this.el)this.setElement(this.el,
|
||||||
|
!1);else{var a=n(this,"attributes")||{};this.id&&(a.id=this.id);this.className&&(a["class"]=this.className);this.setElement(this.make(this.tagName,a),!1)}}});o.extend=r.extend=u.extend=v.extend=function(a,b){var c=G(this,a,b);c.extend=this.extend;return c};var H={create:"POST",update:"PUT","delete":"DELETE",read:"GET"};g.sync=function(a,b,c){var d=H[a];c||(c={});var e={type:d,dataType:"json"};c.url||(e.url=n(b,"url")||t());if(!c.data&&b&&("create"==a||"update"==a))e.contentType="application/json",
|
||||||
|
e.data=JSON.stringify(b.toJSON());g.emulateJSON&&(e.contentType="application/x-www-form-urlencoded",e.data=e.data?{model:e.data}:{});if(g.emulateHTTP&&("PUT"===d||"DELETE"===d))g.emulateJSON&&(e.data._method=d),e.type="POST",e.beforeSend=function(a){a.setRequestHeader("X-HTTP-Method-Override",d)};"GET"!==e.type&&!g.emulateJSON&&(e.processData=!1);return i.ajax(f.extend(e,c))};g.wrapError=function(a,b,c){return function(d,e){e=d===b?e:d;a?a(b,e,c):b.trigger("error",b,e,c)}};var x=function(){},G=function(a,
|
||||||
|
b,c){var d;d=b&&b.hasOwnProperty("constructor")?b.constructor:function(){a.apply(this,arguments)};f.extend(d,a);x.prototype=a.prototype;d.prototype=new x;b&&f.extend(d.prototype,b);c&&f.extend(d,c);d.prototype.constructor=d;d.__super__=a.prototype;return d},n=function(a,b){return!a||!a[b]?null:f.isFunction(a[b])?a[b]():a[b]},t=function(){throw Error('A "url" property or function must be specified');}}).call(this);
|
||||||
223
lib/handlebars.runtime-1.0.0.beta.6.js
Normal file
223
lib/handlebars.runtime-1.0.0.beta.6.js
Normal file
@@ -0,0 +1,223 @@
|
|||||||
|
// lib/handlebars/base.js
|
||||||
|
var Handlebars = {};
|
||||||
|
|
||||||
|
Handlebars.VERSION = "1.0.beta.6";
|
||||||
|
|
||||||
|
Handlebars.helpers = {};
|
||||||
|
Handlebars.partials = {};
|
||||||
|
|
||||||
|
Handlebars.registerHelper = function(name, fn, inverse) {
|
||||||
|
if(inverse) { fn.not = inverse; }
|
||||||
|
this.helpers[name] = fn;
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.registerPartial = function(name, str) {
|
||||||
|
this.partials[name] = str;
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.registerHelper('helperMissing', function(arg) {
|
||||||
|
if(arguments.length === 2) {
|
||||||
|
return undefined;
|
||||||
|
} else {
|
||||||
|
throw new Error("Could not find property '" + arg + "'");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var toString = Object.prototype.toString, functionType = "[object Function]";
|
||||||
|
|
||||||
|
Handlebars.registerHelper('blockHelperMissing', function(context, options) {
|
||||||
|
var inverse = options.inverse || function() {}, fn = options.fn;
|
||||||
|
|
||||||
|
|
||||||
|
var ret = "";
|
||||||
|
var type = toString.call(context);
|
||||||
|
|
||||||
|
if(type === functionType) { context = context.call(this); }
|
||||||
|
|
||||||
|
if(context === true) {
|
||||||
|
return fn(this);
|
||||||
|
} else if(context === false || context == null) {
|
||||||
|
return inverse(this);
|
||||||
|
} else if(type === "[object Array]") {
|
||||||
|
if(context.length > 0) {
|
||||||
|
for(var i=0, j=context.length; i<j; i++) {
|
||||||
|
ret = ret + fn(context[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ret = inverse(this);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
} else {
|
||||||
|
return fn(context);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper('each', function(context, options) {
|
||||||
|
var fn = options.fn, inverse = options.inverse;
|
||||||
|
var ret = "";
|
||||||
|
|
||||||
|
if(context && context.length > 0) {
|
||||||
|
for(var i=0, j=context.length; i<j; i++) {
|
||||||
|
ret = ret + fn(context[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ret = inverse(this);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper('if', function(context, options) {
|
||||||
|
var type = toString.call(context);
|
||||||
|
if(type === functionType) { context = context.call(this); }
|
||||||
|
|
||||||
|
if(!context || Handlebars.Utils.isEmpty(context)) {
|
||||||
|
return options.inverse(this);
|
||||||
|
} else {
|
||||||
|
return options.fn(this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper('unless', function(context, options) {
|
||||||
|
var fn = options.fn, inverse = options.inverse;
|
||||||
|
options.fn = inverse;
|
||||||
|
options.inverse = fn;
|
||||||
|
|
||||||
|
return Handlebars.helpers['if'].call(this, context, options);
|
||||||
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper('with', function(context, options) {
|
||||||
|
return options.fn(context);
|
||||||
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper('log', function(context) {
|
||||||
|
Handlebars.log(context);
|
||||||
|
});
|
||||||
|
;
|
||||||
|
// lib/handlebars/utils.js
|
||||||
|
Handlebars.Exception = function(message) {
|
||||||
|
var tmp = Error.prototype.constructor.apply(this, arguments);
|
||||||
|
|
||||||
|
for (var p in tmp) {
|
||||||
|
if (tmp.hasOwnProperty(p)) { this[p] = tmp[p]; }
|
||||||
|
}
|
||||||
|
|
||||||
|
this.message = tmp.message;
|
||||||
|
};
|
||||||
|
Handlebars.Exception.prototype = new Error;
|
||||||
|
|
||||||
|
// Build out our basic SafeString type
|
||||||
|
Handlebars.SafeString = function(string) {
|
||||||
|
this.string = string;
|
||||||
|
};
|
||||||
|
Handlebars.SafeString.prototype.toString = function() {
|
||||||
|
return this.string.toString();
|
||||||
|
};
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
var escape = {
|
||||||
|
"<": "<",
|
||||||
|
">": ">",
|
||||||
|
'"': """,
|
||||||
|
"'": "'",
|
||||||
|
"`": "`"
|
||||||
|
};
|
||||||
|
|
||||||
|
var badChars = /&(?!\w+;)|[<>"'`]/g;
|
||||||
|
var possible = /[&<>"'`]/;
|
||||||
|
|
||||||
|
var escapeChar = function(chr) {
|
||||||
|
return escape[chr] || "&";
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.Utils = {
|
||||||
|
escapeExpression: function(string) {
|
||||||
|
// don't escape SafeStrings, since they're already safe
|
||||||
|
if (string instanceof Handlebars.SafeString) {
|
||||||
|
return string.toString();
|
||||||
|
} else if (string == null || string === false) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!possible.test(string)) { return string; }
|
||||||
|
return string.replace(badChars, escapeChar);
|
||||||
|
},
|
||||||
|
|
||||||
|
isEmpty: function(value) {
|
||||||
|
if (typeof value === "undefined") {
|
||||||
|
return true;
|
||||||
|
} else if (value === null) {
|
||||||
|
return true;
|
||||||
|
} else if (value === false) {
|
||||||
|
return true;
|
||||||
|
} else if(Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();;
|
||||||
|
// lib/handlebars/runtime.js
|
||||||
|
Handlebars.VM = {
|
||||||
|
template: function(templateSpec) {
|
||||||
|
// Just add water
|
||||||
|
var container = {
|
||||||
|
escapeExpression: Handlebars.Utils.escapeExpression,
|
||||||
|
invokePartial: Handlebars.VM.invokePartial,
|
||||||
|
programs: [],
|
||||||
|
program: function(i, fn, data) {
|
||||||
|
var programWrapper = this.programs[i];
|
||||||
|
if(data) {
|
||||||
|
return Handlebars.VM.program(fn, data);
|
||||||
|
} else if(programWrapper) {
|
||||||
|
return programWrapper;
|
||||||
|
} else {
|
||||||
|
programWrapper = this.programs[i] = Handlebars.VM.program(fn);
|
||||||
|
return programWrapper;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
programWithDepth: Handlebars.VM.programWithDepth,
|
||||||
|
noop: Handlebars.VM.noop
|
||||||
|
};
|
||||||
|
|
||||||
|
return function(context, options) {
|
||||||
|
options = options || {};
|
||||||
|
return templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
programWithDepth: function(fn, data, $depth) {
|
||||||
|
var args = Array.prototype.slice.call(arguments, 2);
|
||||||
|
|
||||||
|
return function(context, options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
return fn.apply(this, [context, options.data || data].concat(args));
|
||||||
|
};
|
||||||
|
},
|
||||||
|
program: function(fn, data) {
|
||||||
|
return function(context, options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
return fn(context, options.data || data);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
noop: function() { return ""; },
|
||||||
|
invokePartial: function(partial, name, context, helpers, partials, data) {
|
||||||
|
options = { helpers: helpers, partials: partials, data: data };
|
||||||
|
|
||||||
|
if(partial === undefined) {
|
||||||
|
throw new Handlebars.Exception("The partial " + name + " could not be found");
|
||||||
|
} else if(partial instanceof Function) {
|
||||||
|
return partial(context, options);
|
||||||
|
} else if (!Handlebars.compile) {
|
||||||
|
throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
|
||||||
|
} else {
|
||||||
|
partials[name] = Handlebars.compile(partial);
|
||||||
|
return partials[name](context, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.template = Handlebars.VM.template;
|
||||||
|
;
|
||||||
4
lib/jquery.min.js
vendored
Normal file
4
lib/jquery.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
511
lib/swagger.js
Normal file
511
lib/swagger.js
Normal file
@@ -0,0 +1,511 @@
|
|||||||
|
// Generated by CoffeeScript 1.3.1
|
||||||
|
(function() {
|
||||||
|
var SwaggerApi, SwaggerOperation, SwaggerRequest, SwaggerResource,
|
||||||
|
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
|
||||||
|
|
||||||
|
SwaggerApi = (function() {
|
||||||
|
|
||||||
|
SwaggerApi.name = 'SwaggerApi';
|
||||||
|
|
||||||
|
SwaggerApi.prototype.discoveryUrl = "http://api.wordnik.com/v4/resources.json";
|
||||||
|
|
||||||
|
SwaggerApi.prototype.debug = false;
|
||||||
|
|
||||||
|
SwaggerApi.prototype.api_key = null;
|
||||||
|
|
||||||
|
SwaggerApi.prototype.basePath = null;
|
||||||
|
|
||||||
|
function SwaggerApi(options) {
|
||||||
|
if (options == null) {
|
||||||
|
options = {};
|
||||||
|
}
|
||||||
|
if (options.discoveryUrl != null) {
|
||||||
|
this.discoveryUrl = options.discoveryUrl;
|
||||||
|
}
|
||||||
|
if (options.debug != null) {
|
||||||
|
this.debug = options.debug;
|
||||||
|
}
|
||||||
|
if (options.apiKey != null) {
|
||||||
|
this.api_key = options.apiKey;
|
||||||
|
}
|
||||||
|
if (options.api_key != null) {
|
||||||
|
this.api_key = options.api_key;
|
||||||
|
}
|
||||||
|
if (options.verbose != null) {
|
||||||
|
this.verbose = options.verbose;
|
||||||
|
}
|
||||||
|
this.supportHeaderParams = options.supportHeaderParams != null ? options.supportHeaderParams : false;
|
||||||
|
if (options.success != null) {
|
||||||
|
this.success = options.success;
|
||||||
|
}
|
||||||
|
this.failure = options.failure != null ? options.failure : function() {};
|
||||||
|
this.progress = options.progress != null ? options.progress : function() {};
|
||||||
|
this.discoveryUrl = this.suffixApiKey(this.discoveryUrl);
|
||||||
|
if (options.success != null) {
|
||||||
|
this.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SwaggerApi.prototype.build = function() {
|
||||||
|
var _this = this;
|
||||||
|
this.progress('fetching resource list: ' + this.discoveryUrl);
|
||||||
|
return jQuery.getJSON(this.discoveryUrl, function(response) {
|
||||||
|
var res, resource, _i, _j, _len, _len1, _ref, _ref1;
|
||||||
|
if ((response.basePath != null) && jQuery.trim(response.basePath).length > 0) {
|
||||||
|
_this.basePath = response.basePath;
|
||||||
|
if (_this.basePath.match(/^HTTP/i) == null) {
|
||||||
|
_this.fail("discoveryUrl basePath must be a URL.");
|
||||||
|
}
|
||||||
|
_this.basePath = _this.basePath.replace(/\/$/, '');
|
||||||
|
} else {
|
||||||
|
_this.basePath = _this.discoveryUrl.substring(0, _this.discoveryUrl.lastIndexOf('/'));
|
||||||
|
log('derived basepath from discoveryUrl as ' + _this.basePath);
|
||||||
|
}
|
||||||
|
_this.resources = {};
|
||||||
|
_this.resourcesArray = [];
|
||||||
|
if (response.resourcePath != null) {
|
||||||
|
_this.resourcePath = response.resourcePath;
|
||||||
|
res = null;
|
||||||
|
_ref = response.apis;
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
resource = _ref[_i];
|
||||||
|
if (res === null) {
|
||||||
|
res = new SwaggerResource(resource, _this);
|
||||||
|
} else {
|
||||||
|
res.addOperations(resource.path, resource.operations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (res != null) {
|
||||||
|
_this.resources[res.name] = res;
|
||||||
|
_this.resourcesArray.push(res);
|
||||||
|
res.ready = true;
|
||||||
|
_this.selfReflect();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
_ref1 = response.apis;
|
||||||
|
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||||
|
resource = _ref1[_j];
|
||||||
|
res = new SwaggerResource(resource, _this);
|
||||||
|
_this.resources[res.name] = res;
|
||||||
|
_this.resourcesArray.push(res);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _this;
|
||||||
|
}).error(function(error) {
|
||||||
|
return _this.fail(error.status + ' : ' + error.statusText + ' ' + _this.discoveryUrl);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
SwaggerApi.prototype.selfReflect = function() {
|
||||||
|
var resource, resource_name, _ref;
|
||||||
|
if (this.resources == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_ref = this.resources;
|
||||||
|
for (resource_name in _ref) {
|
||||||
|
resource = _ref[resource_name];
|
||||||
|
if (resource.ready == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.ready = true;
|
||||||
|
if (this.success != null) {
|
||||||
|
return this.success();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SwaggerApi.prototype.fail = function(message) {
|
||||||
|
this.failure(message);
|
||||||
|
throw message;
|
||||||
|
};
|
||||||
|
|
||||||
|
SwaggerApi.prototype.suffixApiKey = function(url) {
|
||||||
|
var sep;
|
||||||
|
if ((this.api_key != null) && jQuery.trim(this.api_key).length > 0 && (url != null)) {
|
||||||
|
sep = url.indexOf('?') > 0 ? '&' : '?';
|
||||||
|
return url + sep + 'api_key=' + this.api_key;
|
||||||
|
} else {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SwaggerApi.prototype.help = function() {
|
||||||
|
var operation, operation_name, parameter, resource, resource_name, _i, _len, _ref, _ref1, _ref2;
|
||||||
|
_ref = this.resources;
|
||||||
|
for (resource_name in _ref) {
|
||||||
|
resource = _ref[resource_name];
|
||||||
|
console.log(resource_name);
|
||||||
|
_ref1 = resource.operations;
|
||||||
|
for (operation_name in _ref1) {
|
||||||
|
operation = _ref1[operation_name];
|
||||||
|
console.log(" " + operation.nickname);
|
||||||
|
_ref2 = operation.parameters;
|
||||||
|
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
|
||||||
|
parameter = _ref2[_i];
|
||||||
|
console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
return SwaggerApi;
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
SwaggerResource = (function() {
|
||||||
|
|
||||||
|
SwaggerResource.name = 'SwaggerResource';
|
||||||
|
|
||||||
|
function SwaggerResource(resourceObj, api) {
|
||||||
|
var parts,
|
||||||
|
_this = this;
|
||||||
|
this.api = api;
|
||||||
|
this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
|
||||||
|
this.description = resourceObj.description;
|
||||||
|
parts = this.path.split("/");
|
||||||
|
this.name = parts[parts.length - 1].replace('.{format}', '');
|
||||||
|
this.basePath = this.api.basePath;
|
||||||
|
this.operations = {};
|
||||||
|
this.operationsArray = [];
|
||||||
|
if ((resourceObj.operations != null) && (this.api.resourcePath != null)) {
|
||||||
|
this.api.progress('reading resource ' + this.name + ' operations');
|
||||||
|
this.addOperations(resourceObj.path, resourceObj.operations);
|
||||||
|
this.api[this.name] = this;
|
||||||
|
} else {
|
||||||
|
if (this.path == null) {
|
||||||
|
this.api.fail("SwaggerResources must have a path.");
|
||||||
|
}
|
||||||
|
this.url = this.api.suffixApiKey(this.api.basePath + this.path.replace('{format}', 'json'));
|
||||||
|
this.api.progress('fetching resource ' + this.name + ': ' + this.url);
|
||||||
|
jQuery.getJSON(this.url, function(response) {
|
||||||
|
var endpoint, _i, _len, _ref;
|
||||||
|
if ((response.basePath != null) && jQuery.trim(response.basePath).length > 0) {
|
||||||
|
_this.basePath = response.basePath;
|
||||||
|
_this.basePath = _this.basePath.replace(/\/$/, '');
|
||||||
|
}
|
||||||
|
if (response.apis) {
|
||||||
|
_ref = response.apis;
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
endpoint = _ref[_i];
|
||||||
|
_this.addOperations(endpoint.path, endpoint.operations);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_this.api[_this.name] = _this;
|
||||||
|
_this.ready = true;
|
||||||
|
return _this.api.selfReflect();
|
||||||
|
}).error(function(error) {
|
||||||
|
return _this.fail(error.status + ' : ' + error.statusText + ' ' + _this.url);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SwaggerResource.prototype.addOperations = function(resource_path, ops) {
|
||||||
|
var o, op, _i, _len, _results;
|
||||||
|
if (ops) {
|
||||||
|
_results = [];
|
||||||
|
for (_i = 0, _len = ops.length; _i < _len; _i++) {
|
||||||
|
o = ops[_i];
|
||||||
|
op = new SwaggerOperation(o.nickname, resource_path, o.httpMethod, o.parameters, o.summary, this);
|
||||||
|
this.operations[op.nickname] = op;
|
||||||
|
_results.push(this.operationsArray.push(op));
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SwaggerResource.prototype.help = function() {
|
||||||
|
var operation, operation_name, parameter, _i, _len, _ref, _ref1;
|
||||||
|
_ref = this.operations;
|
||||||
|
for (operation_name in _ref) {
|
||||||
|
operation = _ref[operation_name];
|
||||||
|
console.log(" " + operation.nickname);
|
||||||
|
_ref1 = operation.parameters;
|
||||||
|
for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
|
||||||
|
parameter = _ref1[_i];
|
||||||
|
console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
return SwaggerResource;
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
SwaggerOperation = (function() {
|
||||||
|
|
||||||
|
SwaggerOperation.name = 'SwaggerOperation';
|
||||||
|
|
||||||
|
function SwaggerOperation(nickname, path, httpMethod, parameters, summary, resource) {
|
||||||
|
var parameter, v, _i, _j, _len, _len1, _ref, _ref1,
|
||||||
|
_this = this;
|
||||||
|
this.nickname = nickname;
|
||||||
|
this.path = path;
|
||||||
|
this.httpMethod = httpMethod;
|
||||||
|
this.parameters = parameters != null ? parameters : [];
|
||||||
|
this.summary = summary;
|
||||||
|
this.resource = resource;
|
||||||
|
this["do"] = __bind(this["do"], this);
|
||||||
|
|
||||||
|
if (this.nickname == null) {
|
||||||
|
this.resource.api.fail("SwaggerOperations must have a nickname.");
|
||||||
|
}
|
||||||
|
if (this.path == null) {
|
||||||
|
this.resource.api.fail("SwaggerOperation " + nickname + " is missing path.");
|
||||||
|
}
|
||||||
|
if (this.httpMethod == null) {
|
||||||
|
this.resource.api.fail("SwaggerOperation " + nickname + " is missing httpMethod.");
|
||||||
|
}
|
||||||
|
this.path = this.path.replace('{format}', 'json');
|
||||||
|
this.httpMethod = this.httpMethod.toLowerCase();
|
||||||
|
this.isGetMethod = this.httpMethod === "get";
|
||||||
|
this.resourceName = this.resource.name;
|
||||||
|
_ref = this.parameters;
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
parameter = _ref[_i];
|
||||||
|
parameter.name = parameter.name || parameter.dataType;
|
||||||
|
if (parameter.allowableValues != null) {
|
||||||
|
if (parameter.allowableValues.valueType === "RANGE") {
|
||||||
|
parameter.isRange = true;
|
||||||
|
} else {
|
||||||
|
parameter.isList = true;
|
||||||
|
}
|
||||||
|
if (parameter.allowableValues.values != null) {
|
||||||
|
parameter.allowableValues.descriptiveValues = [];
|
||||||
|
_ref1 = parameter.allowableValues.values;
|
||||||
|
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
|
||||||
|
v = _ref1[_j];
|
||||||
|
if ((parameter.defaultValue != null) && parameter.defaultValue === v) {
|
||||||
|
parameter.allowableValues.descriptiveValues.push({
|
||||||
|
value: v,
|
||||||
|
isDefault: true
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
parameter.allowableValues.descriptiveValues.push({
|
||||||
|
value: v,
|
||||||
|
isDefault: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.resource[this.nickname] = function(args, callback, error) {
|
||||||
|
return _this["do"](args, callback, error);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
SwaggerOperation.prototype["do"] = function(args, callback, error) {
|
||||||
|
var body, headers;
|
||||||
|
if (args == null) {
|
||||||
|
args = {};
|
||||||
|
}
|
||||||
|
if ((typeof args) === "function") {
|
||||||
|
error = callback;
|
||||||
|
callback = args;
|
||||||
|
args = {};
|
||||||
|
}
|
||||||
|
if (error == null) {
|
||||||
|
error = function(xhr, textStatus, error) {
|
||||||
|
return console.log(xhr, textStatus, error);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (callback == null) {
|
||||||
|
callback = function(data) {
|
||||||
|
return console.log(data);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (args.headers != null) {
|
||||||
|
headers = args.headers;
|
||||||
|
delete args.headers;
|
||||||
|
}
|
||||||
|
if (args.body != null) {
|
||||||
|
body = args.body;
|
||||||
|
delete args.body;
|
||||||
|
}
|
||||||
|
return new SwaggerRequest(this.httpMethod, this.urlify(args), headers, body, callback, error, this);
|
||||||
|
};
|
||||||
|
|
||||||
|
SwaggerOperation.prototype.pathJson = function() {
|
||||||
|
return this.path.replace("{format}", "json");
|
||||||
|
};
|
||||||
|
|
||||||
|
SwaggerOperation.prototype.pathXml = function() {
|
||||||
|
return this.path.replace("{format}", "xml");
|
||||||
|
};
|
||||||
|
|
||||||
|
SwaggerOperation.prototype.urlify = function(args, includeApiKey) {
|
||||||
|
var param, queryParams, url, _i, _len, _ref;
|
||||||
|
if (includeApiKey == null) {
|
||||||
|
includeApiKey = true;
|
||||||
|
}
|
||||||
|
url = this.resource.basePath + this.pathJson();
|
||||||
|
_ref = this.parameters;
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
param = _ref[_i];
|
||||||
|
if (param.paramType === 'path') {
|
||||||
|
if (args[param.name]) {
|
||||||
|
url = url.replace("{" + param.name + "}", encodeURIComponent(args[param.name]));
|
||||||
|
delete args[param.name];
|
||||||
|
} else {
|
||||||
|
throw "" + param.name + " is a required path param.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (includeApiKey && (this.resource.api.api_key != null) && this.resource.api.api_key.length > 0) {
|
||||||
|
args['api_key'] = this.resource.api.api_key;
|
||||||
|
}
|
||||||
|
if (this.supportHeaderParams()) {
|
||||||
|
queryParams = jQuery.param(this.getQueryParams(args));
|
||||||
|
} else {
|
||||||
|
queryParams = jQuery.param(this.getQueryAndHeaderParams(args));
|
||||||
|
}
|
||||||
|
if ((queryParams != null) && queryParams.length > 0) {
|
||||||
|
url += "?" + queryParams;
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
};
|
||||||
|
|
||||||
|
SwaggerOperation.prototype.supportHeaderParams = function() {
|
||||||
|
return this.resource.api.supportHeaderParams;
|
||||||
|
};
|
||||||
|
|
||||||
|
SwaggerOperation.prototype.getQueryAndHeaderParams = function(args, includeApiKey) {
|
||||||
|
if (includeApiKey == null) {
|
||||||
|
includeApiKey = true;
|
||||||
|
}
|
||||||
|
return this.getMatchingParams(['query', 'header'], args, includeApiKey);
|
||||||
|
};
|
||||||
|
|
||||||
|
SwaggerOperation.prototype.getQueryParams = function(args, includeApiKey) {
|
||||||
|
if (includeApiKey == null) {
|
||||||
|
includeApiKey = true;
|
||||||
|
}
|
||||||
|
return this.getMatchingParams(['query'], args, includeApiKey);
|
||||||
|
};
|
||||||
|
|
||||||
|
SwaggerOperation.prototype.getHeaderParams = function(args, includeApiKey) {
|
||||||
|
if (includeApiKey == null) {
|
||||||
|
includeApiKey = true;
|
||||||
|
}
|
||||||
|
return this.getMatchingParams(['header'], args, includeApiKey, false);
|
||||||
|
};
|
||||||
|
|
||||||
|
SwaggerOperation.prototype.getMatchingParams = function(paramTypes, args, includeApiKey, urlEncode) {
|
||||||
|
var matchingParams, param, _i, _len, _ref;
|
||||||
|
if (urlEncode == null) {
|
||||||
|
urlEncode = true;
|
||||||
|
}
|
||||||
|
matchingParams = {};
|
||||||
|
_ref = this.parameters;
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
param = _ref[_i];
|
||||||
|
if (jQuery.inArray(param.paramType, paramTypes) && args[param.name]) {
|
||||||
|
matchingParams[param.name] = urlEncode ? encodeURIComponent(args[param.name]) : args[param.name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (includeApiKey && (this.resource.api.api_key != null) && this.resource.api.api_key.length > 0) {
|
||||||
|
matchingParams['api_key'] = this.resource.api.api_key;
|
||||||
|
}
|
||||||
|
return matchingParams;
|
||||||
|
};
|
||||||
|
|
||||||
|
SwaggerOperation.prototype.help = function() {
|
||||||
|
var parameter, _i, _len, _ref;
|
||||||
|
_ref = this.parameters;
|
||||||
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
|
parameter = _ref[_i];
|
||||||
|
console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
return SwaggerOperation;
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
SwaggerRequest = (function() {
|
||||||
|
|
||||||
|
SwaggerRequest.name = 'SwaggerRequest';
|
||||||
|
|
||||||
|
function SwaggerRequest(type, url, headers, body, successCallback, errorCallback, operation) {
|
||||||
|
var obj,
|
||||||
|
_this = this;
|
||||||
|
this.type = type;
|
||||||
|
this.url = url;
|
||||||
|
this.headers = headers;
|
||||||
|
this.body = body;
|
||||||
|
this.successCallback = successCallback;
|
||||||
|
this.errorCallback = errorCallback;
|
||||||
|
this.operation = operation;
|
||||||
|
if (this.type == null) {
|
||||||
|
throw "SwaggerRequest type is required (get/post/put/delete).";
|
||||||
|
}
|
||||||
|
if (this.url == null) {
|
||||||
|
throw "SwaggerRequest url is required.";
|
||||||
|
}
|
||||||
|
if (this.successCallback == null) {
|
||||||
|
throw "SwaggerRequest successCallback is required.";
|
||||||
|
}
|
||||||
|
if (this.errorCallback == null) {
|
||||||
|
throw "SwaggerRequest error callback is required.";
|
||||||
|
}
|
||||||
|
if (this.operation == null) {
|
||||||
|
throw "SwaggerRequest operation is required.";
|
||||||
|
}
|
||||||
|
if (this.operation.resource.api.verbose) {
|
||||||
|
console.log(this.asCurl());
|
||||||
|
}
|
||||||
|
this.headers || (this.headers = {});
|
||||||
|
if (this.operation.resource.api.api_key != null) {
|
||||||
|
this.headers.api_key = this.operation.resource.api.api_key;
|
||||||
|
}
|
||||||
|
if (this.headers.mock == null) {
|
||||||
|
obj = {
|
||||||
|
type: this.type,
|
||||||
|
url: this.url,
|
||||||
|
data: JSON.stringify(this.body),
|
||||||
|
dataType: 'json',
|
||||||
|
error: function(xhr, textStatus, error) {
|
||||||
|
return _this.errorCallback(xhr, textStatus, error);
|
||||||
|
},
|
||||||
|
success: function(data) {
|
||||||
|
return _this.successCallback(data);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (obj.type.toLowerCase() === "post" || obj.type.toLowerCase() === "put") {
|
||||||
|
obj.contentType = "application/json";
|
||||||
|
}
|
||||||
|
jQuery.ajax(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SwaggerRequest.prototype.asCurl = function() {
|
||||||
|
var header_args, k, v;
|
||||||
|
header_args = (function() {
|
||||||
|
var _ref, _results;
|
||||||
|
_ref = this.headers;
|
||||||
|
_results = [];
|
||||||
|
for (k in _ref) {
|
||||||
|
v = _ref[k];
|
||||||
|
_results.push("--header \"" + k + ": " + v + "\"");
|
||||||
|
}
|
||||||
|
return _results;
|
||||||
|
}).call(this);
|
||||||
|
return "curl " + (header_args.join(" ")) + " " + this.url;
|
||||||
|
};
|
||||||
|
|
||||||
|
return SwaggerRequest;
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
||||||
|
window.SwaggerApi = SwaggerApi;
|
||||||
|
|
||||||
|
window.SwaggerResource = SwaggerResource;
|
||||||
|
|
||||||
|
window.SwaggerOperation = SwaggerOperation;
|
||||||
|
|
||||||
|
window.SwaggerRequest = SwaggerRequest;
|
||||||
|
|
||||||
|
}).call(this);
|
||||||
32
lib/underscore-min.js
vendored
Normal file
32
lib/underscore-min.js
vendored
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// Underscore.js 1.3.3
|
||||||
|
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
|
||||||
|
// Underscore is freely distributable under the MIT license.
|
||||||
|
// Portions of Underscore are inspired or borrowed from Prototype,
|
||||||
|
// Oliver Steele's Functional, and John Resig's Micro-Templating.
|
||||||
|
// For all details and documentation:
|
||||||
|
// http://documentcloud.github.com/underscore
|
||||||
|
(function(){function r(a,c,d){if(a===c)return 0!==a||1/a==1/c;if(null==a||null==c)return a===c;a._chain&&(a=a._wrapped);c._chain&&(c=c._wrapped);if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return!1;switch(e){case "[object String]":return a==""+c;case "[object Number]":return a!=+a?c!=+c:0==a?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==
|
||||||
|
c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if("object"!=typeof a||"object"!=typeof c)return!1;for(var f=d.length;f--;)if(d[f]==a)return!0;d.push(a);var f=0,g=!0;if("[object Array]"==e){if(f=a.length,g=f==c.length)for(;f--&&(g=f in a==f in c&&r(a[f],c[f],d)););}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return!1;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&r(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c,h)&&!f--)break;
|
||||||
|
g=!f}}d.pop();return g}var s=this,I=s._,o={},k=Array.prototype,p=Object.prototype,i=k.slice,J=k.unshift,l=p.toString,K=p.hasOwnProperty,y=k.forEach,z=k.map,A=k.reduce,B=k.reduceRight,C=k.filter,D=k.every,E=k.some,q=k.indexOf,F=k.lastIndexOf,p=Array.isArray,L=Object.keys,t=Function.prototype.bind,b=function(a){return new m(a)};"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(exports=module.exports=b),exports._=b):s._=b;b.VERSION="1.3.3";var j=b.each=b.forEach=function(a,
|
||||||
|
c,d){if(a!=null)if(y&&a.forEach===y)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(e in a&&c.call(d,a[e],e,a)===o)break}else for(e in a)if(b.has(a,e)&&c.call(d,a[e],e,a)===o)break};b.map=b.collect=function(a,c,b){var e=[];if(a==null)return e;if(z&&a.map===z)return a.map(c,b);j(a,function(a,g,h){e[e.length]=c.call(b,a,g,h)});if(a.length===+a.length)e.length=a.length;return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(A&&
|
||||||
|
a.reduce===A){e&&(c=b.bind(c,e));return f?a.reduce(c,d):a.reduce(c)}j(a,function(a,b,i){if(f)d=c.call(e,d,a,b,i);else{d=a;f=true}});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(B&&a.reduceRight===B){e&&(c=b.bind(c,e));return f?a.reduceRight(c,d):a.reduceRight(c)}var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=function(a,
|
||||||
|
c,b){var e;G(a,function(a,g,h){if(c.call(b,a,g,h)){e=a;return true}});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(C&&a.filter===C)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(D&&a.every===D)return a.every(c,b);j(a,function(a,g,h){if(!(e=e&&c.call(b,
|
||||||
|
a,g,h)))return o});return!!e};var G=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(E&&a.some===E)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return o});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;if(q&&a.indexOf===q)return a.indexOf(c)!=-1;return b=G(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck=
|
||||||
|
function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b<e.computed&&
|
||||||
|
(e={value:a,computed:b})});return e.value};b.shuffle=function(a){var b=[],d;j(a,function(a,f){d=Math.floor(Math.random()*(f+1));b[f]=b[d];b[d]=a});return b};b.sortBy=function(a,c,d){var e=b.isFunction(c)?c:function(a){return a[c]};return b.pluck(b.map(a,function(a,b,c){return{value:a,criteria:e.call(d,a,b,c)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c===void 0?1:d===void 0?-1:c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};
|
||||||
|
j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:b.isArray(a)||b.isArguments(a)?i.call(a):a.toArray&&b.isFunction(a.toArray)?a.toArray():b.values(a)};b.size=function(a){return b.isArray(a)?a.length:b.keys(a).length};b.first=b.head=b.take=function(a,b,d){return b!=null&&!d?i.call(a,0,b):a[0]};b.initial=function(a,b,d){return i.call(a,
|
||||||
|
0,a.length-(b==null||d?1:b))};b.last=function(a,b,d){return b!=null&&!d?i.call(a,Math.max(a.length-b,0)):a[a.length-1]};b.rest=b.tail=function(a,b,d){return i.call(a,b==null||d?1:b)};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a,c){return b.reduce(a,function(a,e){if(b.isArray(e))return a.concat(c?e:b.flatten(e));a[a.length]=e;return a},[])};b.without=function(a){return b.difference(a,i.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,
|
||||||
|
e=[];a.length<3&&(c=true);b.reduce(d,function(d,g,h){if(c?b.last(d)!==g||!d.length:!b.include(d,g)){d.push(g);e.push(a[h])}return d},[]);return e};b.union=function(){return b.uniq(b.flatten(arguments,true))};b.intersection=b.intersect=function(a){var c=i.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1),true);return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=
|
||||||
|
i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,d){if(a==null)return-1;var e;if(d){d=b.sortedIndex(a,c);return a[d]===c?d:-1}if(q&&a.indexOf===q)return a.indexOf(c);d=0;for(e=a.length;d<e;d++)if(d in a&&a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(F&&a.lastIndexOf===F)return a.lastIndexOf(b);for(var d=a.length;d--;)if(d in a&&a[d]===b)return d;return-1};b.range=function(a,b,d){if(arguments.length<=
|
||||||
|
1){b=a||0;a=0}for(var d=arguments[2]||1,e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;){g[f++]=a;a=a+d}return g};var H=function(){};b.bind=function(a,c){var d,e;if(a.bind===t&&t)return t.apply(a,i.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=i.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(i.call(arguments)));H.prototype=a.prototype;var b=new H,g=a.apply(b,e.concat(i.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=
|
||||||
|
i.call(arguments,1);c.length==0&&(c=b.functions(a));j(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=i.call(arguments,2);return setTimeout(function(){return a.apply(null,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(i.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,h,i,j=b.debounce(function(){h=
|
||||||
|
g=false},c);return function(){d=this;e=arguments;f||(f=setTimeout(function(){f=null;h&&a.apply(d,e);j()},c));g?h=true:i=a.apply(d,e);j();g=true;return i}};b.debounce=function(a,b,d){var e;return function(){var f=this,g=arguments;d&&!e&&a.apply(f,g);clearTimeout(e);e=setTimeout(function(){e=null;d||a.apply(f,g)},b)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(i.call(arguments,0));
|
||||||
|
return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=L||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&
|
||||||
|
c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.pick=function(a){var c={};j(b.flatten(i.call(arguments,1)),function(b){b in a&&(c[b]=a[b])});return c};b.defaults=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return r(a,b,[])};b.isEmpty=
|
||||||
|
function(a){if(a==null)return true;if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=p||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)};b.isArguments=function(a){return l.call(a)=="[object Arguments]"};b.isArguments(arguments)||(b.isArguments=function(a){return!(!a||!b.has(a,"callee"))});b.isFunction=function(a){return l.call(a)=="[object Function]"};
|
||||||
|
b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isFinite=function(a){return b.isNumber(a)&&isFinite(a)};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"};b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,
|
||||||
|
b){return K.call(a,b)};b.noConflict=function(){s._=I;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g,"/")};b.result=function(a,c){if(a==null)return null;var d=a[c];return b.isFunction(d)?d.call(a):d};b.mixin=function(a){j(b.functions(a),function(c){M(c,b[c]=a[c])})};var N=0;b.uniqueId=
|
||||||
|
function(a){var b=N++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var u=/.^/,n={"\\":"\\","'":"'",r:"\r",n:"\n",t:"\t",u2028:"\u2028",u2029:"\u2029"},v;for(v in n)n[n[v]]=v;var O=/\\|'|\r|\n|\t|\u2028|\u2029/g,P=/\\(\\|'|r|n|t|u2028|u2029)/g,w=function(a){return a.replace(P,function(a,b){return n[b]})};b.template=function(a,c,d){d=b.defaults(d||{},b.templateSettings);a="__p+='"+a.replace(O,function(a){return"\\"+n[a]}).replace(d.escape||
|
||||||
|
u,function(a,b){return"'+\n_.escape("+w(b)+")+\n'"}).replace(d.interpolate||u,function(a,b){return"'+\n("+w(b)+")+\n'"}).replace(d.evaluate||u,function(a,b){return"';\n"+w(b)+"\n;__p+='"})+"';\n";d.variable||(a="with(obj||{}){\n"+a+"}\n");var a="var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n"+a+"return __p;\n",e=new Function(d.variable||"obj","_",a);if(c)return e(c,b);c=function(a){return e.call(this,a,b)};c.source="function("+(d.variable||"obj")+"){\n"+a+"}";return c};
|
||||||
|
b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var x=function(a,c){return c?b(a).chain():a},M=function(a,c){m.prototype[a]=function(){var a=i.call(arguments);J.call(a,this._wrapped);return x(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return x(d,
|
||||||
|
this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return x(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain=true;return this};m.prototype.value=function(){return this._wrapped}}).call(this);
|
||||||
139
node_modules/.bin/handlebars
generated
vendored
Executable file
139
node_modules/.bin/handlebars
generated
vendored
Executable file
@@ -0,0 +1,139 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
var optimist = require('optimist')
|
||||||
|
.usage('Precompile handlebar templates.\nUsage: $0 template...', {
|
||||||
|
'f': {
|
||||||
|
'type': 'string',
|
||||||
|
'description': 'Output File',
|
||||||
|
'alias': 'output'
|
||||||
|
},
|
||||||
|
'k': {
|
||||||
|
'type': 'string',
|
||||||
|
'description': 'Known helpers',
|
||||||
|
'alias': 'known'
|
||||||
|
},
|
||||||
|
'o': {
|
||||||
|
'type': 'boolean',
|
||||||
|
'description': 'Known helpers only',
|
||||||
|
'alias': 'knownOnly'
|
||||||
|
},
|
||||||
|
'm': {
|
||||||
|
'type': 'boolean',
|
||||||
|
'description': 'Minimize output',
|
||||||
|
'alias': 'min'
|
||||||
|
},
|
||||||
|
's': {
|
||||||
|
'type': 'boolean',
|
||||||
|
'description': 'Output template function only.',
|
||||||
|
'alias': 'simple'
|
||||||
|
},
|
||||||
|
'r': {
|
||||||
|
'type': 'string',
|
||||||
|
'description': 'Template root. Base value that will be stripped from template names.',
|
||||||
|
'alias': 'root'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
.check(function(argv) {
|
||||||
|
var template = [0];
|
||||||
|
if (!argv._.length) {
|
||||||
|
throw 'Must define at least one template or directory.';
|
||||||
|
}
|
||||||
|
|
||||||
|
argv._.forEach(function(template) {
|
||||||
|
try {
|
||||||
|
fs.statSync(template);
|
||||||
|
} catch (err) {
|
||||||
|
throw 'Unable to open template file "' + template + '"';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.check(function(argv) {
|
||||||
|
if (argv.simple && argv.min) {
|
||||||
|
throw 'Unable to minimze simple output';
|
||||||
|
}
|
||||||
|
if (argv.simple && (argv._.length !== 1 || fs.statSync(argv._[0]).isDirectory())) {
|
||||||
|
throw 'Unable to output multiple templates in simple mode';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var fs = require('fs'),
|
||||||
|
handlebars = require('../lib/handlebars'),
|
||||||
|
basename = require('path').basename,
|
||||||
|
uglify = require('uglify-js');
|
||||||
|
|
||||||
|
var argv = optimist.argv,
|
||||||
|
template = argv._[0];
|
||||||
|
|
||||||
|
// Convert the known list into a hash
|
||||||
|
var known = {};
|
||||||
|
if (argv.known && !Array.isArray(argv.known)) {
|
||||||
|
argv.known = [argv.known];
|
||||||
|
}
|
||||||
|
if (argv.known) {
|
||||||
|
for (var i = 0, len = argv.known.length; i < len; i++) {
|
||||||
|
known[argv.known[i]] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var output = [];
|
||||||
|
if (!argv.simple) {
|
||||||
|
output.push('(function() {\n var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};\n');
|
||||||
|
}
|
||||||
|
function processTemplate(template, root) {
|
||||||
|
var path = template,
|
||||||
|
stat = fs.statSync(path);
|
||||||
|
if (stat.isDirectory()) {
|
||||||
|
fs.readdirSync(template).map(function(file) {
|
||||||
|
var path = template + '/' + file;
|
||||||
|
|
||||||
|
if (/\.handlebars$/.test(path) || fs.statSync(path).isDirectory()) {
|
||||||
|
processTemplate(path, root || template);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
var data = fs.readFileSync(path, 'utf8');
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
knownHelpers: known,
|
||||||
|
knownHelpersOnly: argv.o
|
||||||
|
};
|
||||||
|
|
||||||
|
// Clean the template name
|
||||||
|
if (!root) {
|
||||||
|
template = basename(template);
|
||||||
|
} else if (template.indexOf(root) === 0) {
|
||||||
|
template = template.substring(root.length+1);
|
||||||
|
}
|
||||||
|
template = template.replace(/\.handlebars$/, '');
|
||||||
|
|
||||||
|
if (argv.simple) {
|
||||||
|
output.push(handlebars.precompile(data, options) + '\n');
|
||||||
|
} else {
|
||||||
|
output.push('templates[\'' + template + '\'] = template(' + handlebars.precompile(data, options) + ');\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
argv._.forEach(function(template) {
|
||||||
|
processTemplate(template, argv.root);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Output the content
|
||||||
|
if (!argv.simple) {
|
||||||
|
output.push('})();');
|
||||||
|
}
|
||||||
|
output = output.join('');
|
||||||
|
|
||||||
|
if (argv.min) {
|
||||||
|
var ast = uglify.parser.parse(output);
|
||||||
|
ast = uglify.uglify.ast_mangle(ast);
|
||||||
|
ast = uglify.uglify.ast_squeeze(ast);
|
||||||
|
output = uglify.uglify.gen_code(ast);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argv.output) {
|
||||||
|
fs.writeFileSync(argv.output, output, 'utf8');
|
||||||
|
} else {
|
||||||
|
console.log(output);
|
||||||
|
}
|
||||||
42
node_modules/growl/History.md
generated
vendored
Normal file
42
node_modules/growl/History.md
generated
vendored
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
|
||||||
|
1.5.0 / 2012-02-08
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added windows support [perfusorius]
|
||||||
|
|
||||||
|
1.4.1 / 2011-12-28
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fixed: dont exit(). Closes #9
|
||||||
|
|
||||||
|
1.4.0 / 2011-12-17
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Changed API: `growl.notify()` -> `growl()`
|
||||||
|
|
||||||
|
1.3.0 / 2011-12-17
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added support for Ubuntu/Debian/Linux users [niftylettuce]
|
||||||
|
* Fixed: send notifications even if title not specified [alessioalex]
|
||||||
|
|
||||||
|
1.2.0 / 2011-10-06
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Add support for priority.
|
||||||
|
|
||||||
|
1.1.0 / 2011-03-15
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Added optional callbacks
|
||||||
|
* Added parsing of version
|
||||||
|
|
||||||
|
1.0.1 / 2010-03-26
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Fixed; sys.exec -> child_process.exec to support latest node
|
||||||
|
|
||||||
|
1.0.0 / 2010-03-19
|
||||||
|
==================
|
||||||
|
|
||||||
|
* Initial release
|
||||||
93
node_modules/growl/Readme.md
generated
vendored
Normal file
93
node_modules/growl/Readme.md
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
# Growl for nodejs
|
||||||
|
|
||||||
|
Growl support for Nodejs. This is essentially a port of my [Ruby Growl Library](http://github.com/visionmedia/growl). Ubuntu/Linux support added thanks to [@niftylettuce](http://github.com/niftylettuce). You'll need [growlnotify(1)](http://growl.info/extras.php#growlnotify).
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### Mac OS X (Darwin):
|
||||||
|
|
||||||
|
Install [npm](http://npmjs.org/) and run:
|
||||||
|
|
||||||
|
$ npm install growl
|
||||||
|
|
||||||
|
### Ubuntu (Linux):
|
||||||
|
|
||||||
|
Install `notify-send` through the [libnotify-bin](http://packages.ubuntu.com/libnotify-bin) package:
|
||||||
|
|
||||||
|
$ sudo apt-get install libnotify-bin
|
||||||
|
|
||||||
|
Install [npm](http://npmjs.org/) and run:
|
||||||
|
|
||||||
|
$ npm install growl
|
||||||
|
|
||||||
|
### Windows:
|
||||||
|
|
||||||
|
Download and install [Growl for Windows](http://www.growlforwindows.com/gfw/default.aspx)
|
||||||
|
|
||||||
|
Download [growlnotify](http://www.growlforwindows.com/gfw/help/growlnotify.aspx) - **IMPORTANT :** Unpack growlnotify to a folder that is present in your path!
|
||||||
|
|
||||||
|
Install [npm](http://npmjs.org/) and run:
|
||||||
|
|
||||||
|
$ npm install growl
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
Callback functions are optional
|
||||||
|
|
||||||
|
var growl = require('growl')
|
||||||
|
growl('You have mail!')
|
||||||
|
growl('5 new messages', { sticky: true })
|
||||||
|
growl('5 new emails', { title: 'Email Client', image: 'Safari', sticky: true })
|
||||||
|
growl('Message with title', { title: 'Title'})
|
||||||
|
growl('Set priority', { priority: 2 })
|
||||||
|
growl('Show Safari icon', { image: 'Safari' })
|
||||||
|
growl('Show icon', { image: 'path/to/icon.icns' })
|
||||||
|
growl('Show image', { image: 'path/to/my.image.png' })
|
||||||
|
growl('Show png filesystem icon', { image: 'png' })
|
||||||
|
growl('Show pdf filesystem icon', { image: 'article.pdf' })
|
||||||
|
growl('Show pdf filesystem icon', { image: 'article.pdf' }, function(err){
|
||||||
|
// ... notified
|
||||||
|
})
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
- title
|
||||||
|
- notification title
|
||||||
|
- name
|
||||||
|
- application name
|
||||||
|
- priority
|
||||||
|
- priority for the notification (default is 0)
|
||||||
|
- sticky
|
||||||
|
- weither or not the notification should remainin until closed
|
||||||
|
- image
|
||||||
|
- Auto-detects the context:
|
||||||
|
- path to an icon sets --iconpath
|
||||||
|
- path to an image sets --image
|
||||||
|
- capitalized word sets --appIcon
|
||||||
|
- filename uses extname as --icon
|
||||||
|
- otherwise treated as --icon
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
(The MIT License)
|
||||||
|
|
||||||
|
Copyright (c) 2009 TJ Holowaychuk <tj@vision-media.ca>
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
'Software'), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||||
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||||
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||||
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
188
node_modules/growl/lib/growl.js
generated
vendored
Normal file
188
node_modules/growl/lib/growl.js
generated
vendored
Normal file
@@ -0,0 +1,188 @@
|
|||||||
|
// Growl - Copyright TJ Holowaychuk <tj@vision-media.ca> (MIT Licensed)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var exec = require('child_process').exec
|
||||||
|
, path = require('path')
|
||||||
|
, os = require('os')
|
||||||
|
, cmd;
|
||||||
|
|
||||||
|
switch(os.type()) {
|
||||||
|
case 'Darwin':
|
||||||
|
cmd = {
|
||||||
|
type: "Darwin"
|
||||||
|
, pkg: "growlnotify"
|
||||||
|
, msg: '-m'
|
||||||
|
, sticky: '--sticky'
|
||||||
|
, priority: {
|
||||||
|
cmd: '--priority'
|
||||||
|
, range: [
|
||||||
|
-2
|
||||||
|
, -1
|
||||||
|
, 0
|
||||||
|
, 1
|
||||||
|
, 2
|
||||||
|
, "Very Low"
|
||||||
|
, "Moderate"
|
||||||
|
, "Normal"
|
||||||
|
, "High"
|
||||||
|
, "Emergency"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case 'Linux':
|
||||||
|
cmd = {
|
||||||
|
type: "Linux"
|
||||||
|
, pkg: "notify-send"
|
||||||
|
, msg: ''
|
||||||
|
, sticky: '-t 0'
|
||||||
|
, icon: '-i'
|
||||||
|
, priority: {
|
||||||
|
cmd: '-u'
|
||||||
|
, range: [
|
||||||
|
"low"
|
||||||
|
, "normal"
|
||||||
|
, "critical"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
case 'Windows_NT':
|
||||||
|
cmd = {
|
||||||
|
type: "Windows"
|
||||||
|
, pkg: "growlnotify"
|
||||||
|
, msg: ''
|
||||||
|
, sticky: '/s:true'
|
||||||
|
, title: '/t:'
|
||||||
|
, icon: '/i:'
|
||||||
|
, priority: {
|
||||||
|
cmd: '/p:'
|
||||||
|
, range: [
|
||||||
|
-2
|
||||||
|
, -1
|
||||||
|
, 0
|
||||||
|
, 1
|
||||||
|
, 2
|
||||||
|
]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expose `growl`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports = module.exports = growl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Node-growl version.
|
||||||
|
*/
|
||||||
|
|
||||||
|
exports.version = '1.4.1'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send growl notification _msg_ with _options_.
|
||||||
|
*
|
||||||
|
* Options:
|
||||||
|
*
|
||||||
|
* - title Notification title
|
||||||
|
* - sticky Make the notification stick (defaults to false)
|
||||||
|
* - priority Specify an int or named key (default is 0)
|
||||||
|
* - name Application name (defaults to growlnotify)
|
||||||
|
* - image
|
||||||
|
* - path to an icon sets --iconpath
|
||||||
|
* - path to an image sets --image
|
||||||
|
* - capitalized word sets --appIcon
|
||||||
|
* - filename uses extname as --icon
|
||||||
|
* - otherwise treated as --icon
|
||||||
|
*
|
||||||
|
* Examples:
|
||||||
|
*
|
||||||
|
* growl('New email')
|
||||||
|
* growl('5 new emails', { title: 'Thunderbird' })
|
||||||
|
* growl('Email sent', function(){
|
||||||
|
* // ... notification sent
|
||||||
|
* })
|
||||||
|
*
|
||||||
|
* @param {string} msg
|
||||||
|
* @param {object} options
|
||||||
|
* @param {function} fn
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function growl(msg, options, fn) {
|
||||||
|
var image
|
||||||
|
, args
|
||||||
|
, options = options || {}
|
||||||
|
, fn = fn || function(){};
|
||||||
|
|
||||||
|
// noop
|
||||||
|
if (!cmd) return fn(new Error('growl not supported on this platform'));
|
||||||
|
args = [cmd.pkg];
|
||||||
|
|
||||||
|
// image
|
||||||
|
if (image = options.image) {
|
||||||
|
switch(cmd.type) {
|
||||||
|
case 'Darwin':
|
||||||
|
var flag, ext = path.extname(image).substr(1)
|
||||||
|
flag = flag || ext == 'icns' && 'iconpath'
|
||||||
|
flag = flag || /^[A-Z]/.test(image) && 'appIcon'
|
||||||
|
flag = flag || /^png|gif|jpe?g$/.test(ext) && 'image'
|
||||||
|
flag = flag || ext && (image = ext) && 'icon'
|
||||||
|
flag = flag || 'icon'
|
||||||
|
args.push('--' + flag, image)
|
||||||
|
break;
|
||||||
|
case 'Linux':
|
||||||
|
args.push(cmd.icon + image);
|
||||||
|
break;
|
||||||
|
case 'Windows':
|
||||||
|
args.push(cmd.icon + '"' + image.replace(/\\/g, "\\\\") + '"');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// sticky
|
||||||
|
if (options.sticky) args.push(cmd.sticky);
|
||||||
|
|
||||||
|
// priority
|
||||||
|
if (options.priority) {
|
||||||
|
var priority = options.priority + '';
|
||||||
|
var checkindexOf = cmd.priority.range.indexOf(priority);
|
||||||
|
if (~cmd.priority.range.indexOf(priority)) {
|
||||||
|
args.push(cmd.priority, options.priority);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// name
|
||||||
|
if (options.name && cmd.type === "Darwin") {
|
||||||
|
args.push('--name', options.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(cmd.type) {
|
||||||
|
case 'Darwin':
|
||||||
|
args.push(cmd.msg);
|
||||||
|
args.push('"' + msg + '"');
|
||||||
|
if (options.title) args.push(options.title);
|
||||||
|
break;
|
||||||
|
case 'Linux':
|
||||||
|
if (options.title) {
|
||||||
|
args.push("'" + options.title + "'");
|
||||||
|
args.push(cmd.msg);
|
||||||
|
args.push("'" + msg + "'");
|
||||||
|
} else {
|
||||||
|
args.push("'" + msg + "'");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'Windows':
|
||||||
|
args.push('"' + msg + '"');
|
||||||
|
if (options.title) args.push(cmd.title + '"' + options.title + '"');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// execute
|
||||||
|
exec(args.join(' '), fn);
|
||||||
|
};
|
||||||
6
node_modules/growl/package.json
generated
vendored
Normal file
6
node_modules/growl/package.json
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{ "name": "growl",
|
||||||
|
"version": "1.5.0",
|
||||||
|
"description": "Growl unobtrusive notifications",
|
||||||
|
"author": "TJ Holowaychuk <tj@vision-media.ca>",
|
||||||
|
"main": "./lib/growl.js"
|
||||||
|
}
|
||||||
16
node_modules/growl/test.js
generated
vendored
Normal file
16
node_modules/growl/test.js
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
var growl = require('./lib/growl')
|
||||||
|
|
||||||
|
growl('You have mail!')
|
||||||
|
growl('5 new messages', { sticky: true })
|
||||||
|
growl('5 new emails', { title: 'Email Client', image: 'Safari', sticky: true })
|
||||||
|
growl('Message with title', { title: 'Title'})
|
||||||
|
growl('Set priority', { priority: 2 })
|
||||||
|
growl('Show Safari icon', { image: 'Safari' })
|
||||||
|
growl('Show icon', { image: 'path/to/icon.icns' })
|
||||||
|
growl('Show image', { image: 'path/to/my.image.png' })
|
||||||
|
growl('Show png filesystem icon', { image: 'png' })
|
||||||
|
growl('Show pdf filesystem icon', { image: 'article.pdf' })
|
||||||
|
growl('Show pdf filesystem icon', { image: 'article.pdf' }, function(){
|
||||||
|
console.log('callback');
|
||||||
|
})
|
||||||
11
node_modules/handlebars/.npmignore
generated
vendored
Normal file
11
node_modules/handlebars/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
.DS_Store
|
||||||
|
.gitignore
|
||||||
|
.rvmrc
|
||||||
|
Gemfile
|
||||||
|
Gemfile.lock
|
||||||
|
Rakefile
|
||||||
|
bench/*
|
||||||
|
dist/*
|
||||||
|
spec/*
|
||||||
|
src/*
|
||||||
|
vendor/*
|
||||||
20
node_modules/handlebars/LICENSE
generated
vendored
Normal file
20
node_modules/handlebars/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
Copyright (C) 2011 by Yehuda Katz
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
315
node_modules/handlebars/README.markdown
generated
vendored
Normal file
315
node_modules/handlebars/README.markdown
generated
vendored
Normal file
@@ -0,0 +1,315 @@
|
|||||||
|
[](http://travis-ci.org/wycats/handlebars.js)
|
||||||
|
|
||||||
|
Handlebars.js
|
||||||
|
=============
|
||||||
|
|
||||||
|
Handlebars.js is an extension to the [Mustache templating language](http://mustache.github.com/) created by Chris Wanstrath. Handlebars.js and Mustache are both logicless templating languages that keep the view and the code separated like we all know they should be.
|
||||||
|
|
||||||
|
Checkout the official Handlebars docs site at [http://www.handlebarsjs.com](http://www.handlebarsjs.com).
|
||||||
|
|
||||||
|
|
||||||
|
Installing
|
||||||
|
----------
|
||||||
|
Installing Handlebars is easy. Simply [download the package from GitHub](https://github.com/wycats/handlebars.js/archives/master) and add it to your web pages (you should usually use the most recent version).
|
||||||
|
|
||||||
|
Usage
|
||||||
|
-----
|
||||||
|
In general, the syntax of Handlebars.js templates is a superset of Mustache templates. For basic syntax, check out the [Mustache manpage](http://mustache.github.com/mustache.5.html).
|
||||||
|
|
||||||
|
Once you have a template, use the Handlebars.compile method to compile the template into a function. The generated function takes a context argument, which will be used to render the template.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var source = "<p>Hello, my name is {{name}}. I am from {{hometown}}. I have " +
|
||||||
|
"{{kids.length}} kids:</p>" +
|
||||||
|
"<ul>{{#kids}}<li>{{name}} is {{age}}</li>{{/kids}}</ul>";
|
||||||
|
var template = Handlebars.compile(source);
|
||||||
|
|
||||||
|
var data = { "name": "Alan", "hometown": "Somewhere, TX",
|
||||||
|
"kids": [{"name": "Jimmy", "age": "12"}, {"name": "Sally", "age": "4"}]};
|
||||||
|
var result = template(data);
|
||||||
|
|
||||||
|
// Would render:
|
||||||
|
// <p>Hello, my name is Alan. I am from Somewhere, TX. I have 2 kids:</p>
|
||||||
|
// <ul>
|
||||||
|
// <li>Jimmy is 12</li>
|
||||||
|
// <li>Sally is 4</li>
|
||||||
|
// </ul>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Registering Helpers
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
You can register helpers that Handlebars will use when evaluating your
|
||||||
|
template. Here's an example, which assumes that your objects have a URL
|
||||||
|
embedded in them, as well as the text for a link:
|
||||||
|
|
||||||
|
```js
|
||||||
|
Handlebars.registerHelper('link_to', function(context) {
|
||||||
|
return "<a href='" + context.url + "'>" + context.body + "</a>";
|
||||||
|
});
|
||||||
|
|
||||||
|
var context = { posts: [{url: "/hello-world", body: "Hello World!"}] };
|
||||||
|
var source = "<ul>{{#posts}}<li>{{{link_to this}}}</li>{{/posts}}</ul>"
|
||||||
|
|
||||||
|
var template = Handlebars.compile(source);
|
||||||
|
template(context);
|
||||||
|
|
||||||
|
// Would render:
|
||||||
|
//
|
||||||
|
// <ul>
|
||||||
|
// <li><a href='/hello-world'>Hello World!</a></li>
|
||||||
|
// </ul>
|
||||||
|
```
|
||||||
|
|
||||||
|
Escaping
|
||||||
|
--------
|
||||||
|
|
||||||
|
By default, the `{{expression}}` syntax will escape its contents. This
|
||||||
|
helps to protect you against accidental XSS problems caused by malicious
|
||||||
|
data passed from the server as JSON.
|
||||||
|
|
||||||
|
To explicitly *not* escape the contents, use the triple-mustache
|
||||||
|
(`{{{}}}`). You have seen this used in the above example.
|
||||||
|
|
||||||
|
|
||||||
|
Differences Between Handlebars.js and Mustache
|
||||||
|
----------------------------------------------
|
||||||
|
Handlebars.js adds a couple of additional features to make writing templates easier and also changes a tiny detail of how partials work.
|
||||||
|
|
||||||
|
### Paths
|
||||||
|
|
||||||
|
Handlebars.js supports an extended expression syntax that we call paths. Paths are made up of typical expressions and . characters. Expressions allow you to not only display data from the current context, but to display data from contexts that are descendents and ancestors of the current context.
|
||||||
|
|
||||||
|
To display data from descendent contexts, use the `.` character. So, for example, if your data were structured like:
|
||||||
|
|
||||||
|
```js
|
||||||
|
var data = {"person": { "name": "Alan" }, company: {"name": "Rad, Inc." } };
|
||||||
|
```
|
||||||
|
|
||||||
|
you could display the person's name from the top-level context with the following expression:
|
||||||
|
|
||||||
|
```
|
||||||
|
{{person.name}}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can backtrack using `../`. For example, if you've already traversed into the person object you could still display the company's name with an expression like `{{../company.name}}`, so:
|
||||||
|
|
||||||
|
```
|
||||||
|
{{#person}}{{name}} - {{../company.name}}{{/person}}
|
||||||
|
```
|
||||||
|
|
||||||
|
would render:
|
||||||
|
|
||||||
|
```
|
||||||
|
Alan - Rad, Inc.
|
||||||
|
```
|
||||||
|
|
||||||
|
### Strings
|
||||||
|
|
||||||
|
When calling a helper, you can pass paths or Strings as parameters. For
|
||||||
|
instance:
|
||||||
|
|
||||||
|
```js
|
||||||
|
Handlebars.registerHelper('link_to', function(title, context) {
|
||||||
|
return "<a href='/posts" + context.id + "'>" + title + "</a>"
|
||||||
|
});
|
||||||
|
|
||||||
|
var context = { posts: [{url: "/hello-world", body: "Hello World!"}] };
|
||||||
|
var source = '<ul>{{#posts}}<li>{{{link_to "Post" this}}}</li>{{/posts}}</ul>'
|
||||||
|
|
||||||
|
var template = Handlebars.compile(source);
|
||||||
|
template(context);
|
||||||
|
|
||||||
|
// Would render:
|
||||||
|
//
|
||||||
|
// <ul>
|
||||||
|
// <li><a href='/hello-world'>Post!</a></li>
|
||||||
|
// </ul>
|
||||||
|
```
|
||||||
|
|
||||||
|
When you pass a String as a parameter to a helper, the literal String
|
||||||
|
gets passed to the helper function.
|
||||||
|
|
||||||
|
|
||||||
|
### Block Helpers
|
||||||
|
|
||||||
|
Handlebars.js also adds the ability to define block helpers. Block helpers are functions that can be called from anywhere in the template. Here's an example:
|
||||||
|
|
||||||
|
```js
|
||||||
|
var source = "<ul>{{#people}}<li>{{{#link}}}{{name}}{{/link}}</li>{{/people}}</ul>";
|
||||||
|
Handlebars.registerHelper('link', function(context, fn) {
|
||||||
|
return '<a href="/people/' + this.__get__("id") + '">' + fn(this) + '</a>';
|
||||||
|
});
|
||||||
|
var template = Handlebars.compile(source);
|
||||||
|
|
||||||
|
var data = { "people": [
|
||||||
|
{ "name": "Alan", "id": 1 },
|
||||||
|
{ "name": "Yehuda", "id": 2 }
|
||||||
|
]};
|
||||||
|
template(data);
|
||||||
|
|
||||||
|
// Should render:
|
||||||
|
// <ul>
|
||||||
|
// <li><a href="/people/1">Alan</a></li>
|
||||||
|
// <li><a href="/people/2">Yehuda</a></li>
|
||||||
|
// </ul>
|
||||||
|
```
|
||||||
|
|
||||||
|
Whenever the block helper is called it is given two parameters, the argument that is passed to the helper, or the current context if no argument is passed and the compiled contents of the block. Inside of the block helper the value of `this` is the current context, wrapped to include a method named `__get__` that helps translate paths into values within the helpers.
|
||||||
|
|
||||||
|
### Partials
|
||||||
|
|
||||||
|
You can register additional templates as partials, which will be used by
|
||||||
|
Handlebars when it encounters a partial (`{{> partialName}}`). Partials
|
||||||
|
can either be String templates or compiled template functions. Here's an
|
||||||
|
example:
|
||||||
|
|
||||||
|
```js
|
||||||
|
var source = "<ul>{{#people}}<li>{{> link}}</li>{{/people}}</ul>";
|
||||||
|
|
||||||
|
Handlebars.registerPartial('link', '<a href="/people/{{id}}">{{name}}</a>')
|
||||||
|
var template = Handlebars.compile(source);
|
||||||
|
|
||||||
|
var data = { "people": [
|
||||||
|
{ "name": "Alan", "id": 1 },
|
||||||
|
{ "name": "Yehuda", "id": 2 }
|
||||||
|
]};
|
||||||
|
|
||||||
|
template(data);
|
||||||
|
|
||||||
|
// Should render:
|
||||||
|
// <ul>
|
||||||
|
// <li><a href="/people/1">Alan</a></li>
|
||||||
|
// <li><a href="/people/2">Yehuda</a></li>
|
||||||
|
// </ul>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Comments
|
||||||
|
|
||||||
|
You can add comments to your templates with the following syntax:
|
||||||
|
|
||||||
|
```js
|
||||||
|
{{! This is a comment }}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also use real html comments if you want them to end up in the output.
|
||||||
|
|
||||||
|
```html
|
||||||
|
<div>
|
||||||
|
{{! This comment will not end up in the output }}
|
||||||
|
<!-- This comment will show up in the output -->
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
Precompiling Templates
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
Handlebars allows templates to be precompiled and included as javascript
|
||||||
|
code rather than the handlebars template allowing for faster startup time.
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
The precompiler script may be installed via npm using the `npm install -g handlebars`
|
||||||
|
command.
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
|
||||||
|
<pre>
|
||||||
|
Precompile handlebar templates.
|
||||||
|
Usage: handlebars template...
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-f, --output Output File [string]
|
||||||
|
-k, --known Known helpers [string]
|
||||||
|
-o, --knownOnly Known helpers only [boolean]
|
||||||
|
-m, --min Minimize output [boolean]
|
||||||
|
-s, --simple Output template function only. [boolean]
|
||||||
|
-r, --root Template root. Base value that will be stripped from template names. [string]
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
If using the precompiler's normal mode, the resulting templates will be stored
|
||||||
|
to the `Handlebars.templates` object using the relative template name sans the
|
||||||
|
extension. These templates may be executed in the same manner as templates.
|
||||||
|
|
||||||
|
If using the simple mode the precompiler will generate a single javascript method.
|
||||||
|
To execute this method it must be passed to the using the `Handlebars.template`
|
||||||
|
method and the resulting object may be as normal.
|
||||||
|
|
||||||
|
### Optimizations
|
||||||
|
|
||||||
|
- Rather than using the full _handlebars.js_ library, implementations that
|
||||||
|
do not need to compile templates at runtime may include _handlebars.vm.js_
|
||||||
|
whose min+gzip size is approximately 1k.
|
||||||
|
- If a helper is known to exist in the target environment they may be defined
|
||||||
|
using the `--known name` argument may be used to optimize accesses to these
|
||||||
|
helpers for size and speed.
|
||||||
|
- When all helpers are known in advance the `--knownOnly` argument may be used
|
||||||
|
to optimize all block helper references.
|
||||||
|
|
||||||
|
|
||||||
|
Performance
|
||||||
|
-----------
|
||||||
|
|
||||||
|
In a rough performance test, precompiled Handlebars.js templates (in the original version of Handlebars.js) rendered in about half the time of Mustache templates. It would be a shame if it were any other way, since they were precompiled, but the difference in architecture does have some big performance advantages. Justin Marney, a.k.a. [gotascii](http://github.com/gotascii), confirmed that with an [independent test](http://sorescode.com/2010/09/12/benchmarks.html). The rewritten Handlebars (current version) is faster than the old version, and we will have some benchmarks in the near future.
|
||||||
|
|
||||||
|
|
||||||
|
Building
|
||||||
|
--------
|
||||||
|
|
||||||
|
To build handlebars, just run `rake release`, and you will get two files
|
||||||
|
in the `dist` directory.
|
||||||
|
|
||||||
|
|
||||||
|
Upgrading
|
||||||
|
---------
|
||||||
|
|
||||||
|
When upgrading from the Handlebars 0.9 series, be aware that the
|
||||||
|
signature for passing custom helpers or partials to templates has
|
||||||
|
changed.
|
||||||
|
|
||||||
|
Instead of:
|
||||||
|
|
||||||
|
```js
|
||||||
|
template(context, helpers, partials, [data])
|
||||||
|
```
|
||||||
|
|
||||||
|
Use:
|
||||||
|
|
||||||
|
```js
|
||||||
|
template(context, {helpers: helpers, partials: partials, data: data})
|
||||||
|
```
|
||||||
|
|
||||||
|
Known Issues
|
||||||
|
------------
|
||||||
|
* Handlebars.js can be cryptic when there's an error while rendering.
|
||||||
|
|
||||||
|
Handlebars in the Wild
|
||||||
|
-----------------
|
||||||
|
* [jblotus](http://github.com/jblotus) created [http://tryhandlebarsjs.com](http://tryhandlebarsjs.com) for anyone who would
|
||||||
|
like to try out Handlebars.js in their browser.
|
||||||
|
* Don Park wrote an Express.js view engine adapter for Handlebars.js called [hbs](http://github.com/donpark/hbs).
|
||||||
|
* [sammy.js](http://github.com/quirkey/sammy) by Aaron Quint, a.k.a. quirkey, supports Handlebars.js as one of its template plugins.
|
||||||
|
* [SproutCore](http://www.sproutcore.com) uses Handlebars.js as its main templating engine, extending it with automatic data binding support.
|
||||||
|
* [Ember.js](http://www.emberjs.com) makes Handlebars.js the primary way to structure your views, also with automatic data binding support.
|
||||||
|
* Les Hill (@leshill) wrote a Rails Asset Pipeline gem named [handlebars_assets](http://github.com/leshill/handlebars_assets).
|
||||||
|
|
||||||
|
Helping Out
|
||||||
|
-----------
|
||||||
|
To build Handlebars.js you'll need a few things installed.
|
||||||
|
|
||||||
|
* Node.js
|
||||||
|
* Jison, for building the compiler - `npm install jison`
|
||||||
|
* Ruby
|
||||||
|
* therubyracer, for running tests - `gem install therubyracer`
|
||||||
|
* rspec, for running tests - `gem install rspec`
|
||||||
|
|
||||||
|
There's a Gemfile in the repo, so you can run `bundle` to install rspec and therubyracer if you've got bundler installed.
|
||||||
|
|
||||||
|
To build Handlebars.js from scratch, you'll want to run `rake compile` in the root of the project. That will build Handlebars and output the results to the dist/ folder. To run tests, run `rake spec`. You can also run our set of benchmarks with `rake bench`.
|
||||||
|
|
||||||
|
If you notice any problems, please report them to the GitHub issue tracker at [http://github.com/wycats/handlebars.js/issues](http://github.com/wycats/handlebars.js/issues). Feel free to contact commondream or wycats through GitHub with any other questions or feature requests. To submit changes fork the project and send a pull request.
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
Handlebars.js is released under the MIT license.
|
||||||
139
node_modules/handlebars/bin/handlebars
generated
vendored
Executable file
139
node_modules/handlebars/bin/handlebars
generated
vendored
Executable file
@@ -0,0 +1,139 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
var optimist = require('optimist')
|
||||||
|
.usage('Precompile handlebar templates.\nUsage: $0 template...', {
|
||||||
|
'f': {
|
||||||
|
'type': 'string',
|
||||||
|
'description': 'Output File',
|
||||||
|
'alias': 'output'
|
||||||
|
},
|
||||||
|
'k': {
|
||||||
|
'type': 'string',
|
||||||
|
'description': 'Known helpers',
|
||||||
|
'alias': 'known'
|
||||||
|
},
|
||||||
|
'o': {
|
||||||
|
'type': 'boolean',
|
||||||
|
'description': 'Known helpers only',
|
||||||
|
'alias': 'knownOnly'
|
||||||
|
},
|
||||||
|
'm': {
|
||||||
|
'type': 'boolean',
|
||||||
|
'description': 'Minimize output',
|
||||||
|
'alias': 'min'
|
||||||
|
},
|
||||||
|
's': {
|
||||||
|
'type': 'boolean',
|
||||||
|
'description': 'Output template function only.',
|
||||||
|
'alias': 'simple'
|
||||||
|
},
|
||||||
|
'r': {
|
||||||
|
'type': 'string',
|
||||||
|
'description': 'Template root. Base value that will be stripped from template names.',
|
||||||
|
'alias': 'root'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
.check(function(argv) {
|
||||||
|
var template = [0];
|
||||||
|
if (!argv._.length) {
|
||||||
|
throw 'Must define at least one template or directory.';
|
||||||
|
}
|
||||||
|
|
||||||
|
argv._.forEach(function(template) {
|
||||||
|
try {
|
||||||
|
fs.statSync(template);
|
||||||
|
} catch (err) {
|
||||||
|
throw 'Unable to open template file "' + template + '"';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.check(function(argv) {
|
||||||
|
if (argv.simple && argv.min) {
|
||||||
|
throw 'Unable to minimze simple output';
|
||||||
|
}
|
||||||
|
if (argv.simple && (argv._.length !== 1 || fs.statSync(argv._[0]).isDirectory())) {
|
||||||
|
throw 'Unable to output multiple templates in simple mode';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var fs = require('fs'),
|
||||||
|
handlebars = require('../lib/handlebars'),
|
||||||
|
basename = require('path').basename,
|
||||||
|
uglify = require('uglify-js');
|
||||||
|
|
||||||
|
var argv = optimist.argv,
|
||||||
|
template = argv._[0];
|
||||||
|
|
||||||
|
// Convert the known list into a hash
|
||||||
|
var known = {};
|
||||||
|
if (argv.known && !Array.isArray(argv.known)) {
|
||||||
|
argv.known = [argv.known];
|
||||||
|
}
|
||||||
|
if (argv.known) {
|
||||||
|
for (var i = 0, len = argv.known.length; i < len; i++) {
|
||||||
|
known[argv.known[i]] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var output = [];
|
||||||
|
if (!argv.simple) {
|
||||||
|
output.push('(function() {\n var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};\n');
|
||||||
|
}
|
||||||
|
function processTemplate(template, root) {
|
||||||
|
var path = template,
|
||||||
|
stat = fs.statSync(path);
|
||||||
|
if (stat.isDirectory()) {
|
||||||
|
fs.readdirSync(template).map(function(file) {
|
||||||
|
var path = template + '/' + file;
|
||||||
|
|
||||||
|
if (/\.handlebars$/.test(path) || fs.statSync(path).isDirectory()) {
|
||||||
|
processTemplate(path, root || template);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
var data = fs.readFileSync(path, 'utf8');
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
knownHelpers: known,
|
||||||
|
knownHelpersOnly: argv.o
|
||||||
|
};
|
||||||
|
|
||||||
|
// Clean the template name
|
||||||
|
if (!root) {
|
||||||
|
template = basename(template);
|
||||||
|
} else if (template.indexOf(root) === 0) {
|
||||||
|
template = template.substring(root.length+1);
|
||||||
|
}
|
||||||
|
template = template.replace(/\.handlebars$/, '');
|
||||||
|
|
||||||
|
if (argv.simple) {
|
||||||
|
output.push(handlebars.precompile(data, options) + '\n');
|
||||||
|
} else {
|
||||||
|
output.push('templates[\'' + template + '\'] = template(' + handlebars.precompile(data, options) + ');\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
argv._.forEach(function(template) {
|
||||||
|
processTemplate(template, argv.root);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Output the content
|
||||||
|
if (!argv.simple) {
|
||||||
|
output.push('})();');
|
||||||
|
}
|
||||||
|
output = output.join('');
|
||||||
|
|
||||||
|
if (argv.min) {
|
||||||
|
var ast = uglify.parser.parse(output);
|
||||||
|
ast = uglify.uglify.ast_mangle(ast);
|
||||||
|
ast = uglify.uglify.ast_squeeze(ast);
|
||||||
|
output = uglify.uglify.gen_code(ast);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (argv.output) {
|
||||||
|
fs.writeFileSync(argv.output, output, 'utf8');
|
||||||
|
} else {
|
||||||
|
console.log(output);
|
||||||
|
}
|
||||||
14
node_modules/handlebars/lib/handlebars.js
generated
vendored
Normal file
14
node_modules/handlebars/lib/handlebars.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
var Handlebars = require("./handlebars/base");
|
||||||
|
module.exports = Handlebars;
|
||||||
|
|
||||||
|
// Each of these augment the Handlebars object. No need to setup here.
|
||||||
|
// (This is done to easily share code between commonjs and browse envs)
|
||||||
|
require("./handlebars/utils");
|
||||||
|
|
||||||
|
require("./handlebars/compiler");
|
||||||
|
require("./handlebars/runtime");
|
||||||
|
|
||||||
|
// BEGIN(BROWSER)
|
||||||
|
|
||||||
|
// END(BROWSER)
|
||||||
|
|
||||||
99
node_modules/handlebars/lib/handlebars/base.js
generated
vendored
Normal file
99
node_modules/handlebars/lib/handlebars/base.js
generated
vendored
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
// BEGIN(BROWSER)
|
||||||
|
var Handlebars = {};
|
||||||
|
|
||||||
|
Handlebars.VERSION = "1.0.beta.5";
|
||||||
|
|
||||||
|
Handlebars.helpers = {};
|
||||||
|
Handlebars.partials = {};
|
||||||
|
|
||||||
|
Handlebars.registerHelper = function(name, fn, inverse) {
|
||||||
|
if(inverse) { fn.not = inverse; }
|
||||||
|
this.helpers[name] = fn;
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.registerPartial = function(name, str) {
|
||||||
|
this.partials[name] = str;
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.registerHelper('helperMissing', function(arg) {
|
||||||
|
if(arguments.length === 2) {
|
||||||
|
return undefined;
|
||||||
|
} else {
|
||||||
|
throw new Error("Could not find property '" + arg + "'");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var toString = Object.prototype.toString, functionType = "[object Function]";
|
||||||
|
|
||||||
|
Handlebars.registerHelper('blockHelperMissing', function(context, options) {
|
||||||
|
var inverse = options.inverse || function() {}, fn = options.fn;
|
||||||
|
|
||||||
|
|
||||||
|
var ret = "";
|
||||||
|
var type = toString.call(context);
|
||||||
|
|
||||||
|
if(type === functionType) { context = context.call(this); }
|
||||||
|
|
||||||
|
if(context === true) {
|
||||||
|
return fn(this);
|
||||||
|
} else if(context === false || context == null) {
|
||||||
|
return inverse(this);
|
||||||
|
} else if(type === "[object Array]") {
|
||||||
|
if(context.length > 0) {
|
||||||
|
for(var i=0, j=context.length; i<j; i++) {
|
||||||
|
ret = ret + fn(context[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ret = inverse(this);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
} else {
|
||||||
|
return fn(context);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper('each', function(context, options) {
|
||||||
|
var fn = options.fn, inverse = options.inverse;
|
||||||
|
var ret = "";
|
||||||
|
|
||||||
|
if(context && context.length > 0) {
|
||||||
|
for(var i=0, j=context.length; i<j; i++) {
|
||||||
|
ret = ret + fn(context[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ret = inverse(this);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper('if', function(context, options) {
|
||||||
|
var type = toString.call(context);
|
||||||
|
if(type === functionType) { context = context.call(this); }
|
||||||
|
|
||||||
|
if(!context || Handlebars.Utils.isEmpty(context)) {
|
||||||
|
return options.inverse(this);
|
||||||
|
} else {
|
||||||
|
return options.fn(this);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper('unless', function(context, options) {
|
||||||
|
var fn = options.fn, inverse = options.inverse;
|
||||||
|
options.fn = inverse;
|
||||||
|
options.inverse = fn;
|
||||||
|
|
||||||
|
return Handlebars.helpers['if'].call(this, context, options);
|
||||||
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper('with', function(context, options) {
|
||||||
|
return options.fn(context);
|
||||||
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper('log', function(context) {
|
||||||
|
Handlebars.log(context);
|
||||||
|
});
|
||||||
|
|
||||||
|
// END(BROWSER)
|
||||||
|
|
||||||
|
module.exports = Handlebars;
|
||||||
|
|
||||||
103
node_modules/handlebars/lib/handlebars/compiler/ast.js
generated
vendored
Normal file
103
node_modules/handlebars/lib/handlebars/compiler/ast.js
generated
vendored
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
var Handlebars = require('./base');
|
||||||
|
|
||||||
|
// BEGIN(BROWSER)
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
Handlebars.AST = {};
|
||||||
|
|
||||||
|
Handlebars.AST.ProgramNode = function(statements, inverse) {
|
||||||
|
this.type = "program";
|
||||||
|
this.statements = statements;
|
||||||
|
if(inverse) { this.inverse = new Handlebars.AST.ProgramNode(inverse); }
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.AST.MustacheNode = function(params, hash, unescaped) {
|
||||||
|
this.type = "mustache";
|
||||||
|
this.id = params[0];
|
||||||
|
this.params = params.slice(1);
|
||||||
|
this.hash = hash;
|
||||||
|
this.escaped = !unescaped;
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.AST.PartialNode = function(id, context) {
|
||||||
|
this.type = "partial";
|
||||||
|
|
||||||
|
// TODO: disallow complex IDs
|
||||||
|
|
||||||
|
this.id = id;
|
||||||
|
this.context = context;
|
||||||
|
};
|
||||||
|
|
||||||
|
var verifyMatch = function(open, close) {
|
||||||
|
if(open.original !== close.original) {
|
||||||
|
throw new Handlebars.Exception(open.original + " doesn't match " + close.original);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.AST.BlockNode = function(mustache, program, close) {
|
||||||
|
verifyMatch(mustache.id, close);
|
||||||
|
this.type = "block";
|
||||||
|
this.mustache = mustache;
|
||||||
|
this.program = program;
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.AST.InverseNode = function(mustache, program, close) {
|
||||||
|
verifyMatch(mustache.id, close);
|
||||||
|
this.type = "inverse";
|
||||||
|
this.mustache = mustache;
|
||||||
|
this.program = program;
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.AST.ContentNode = function(string) {
|
||||||
|
this.type = "content";
|
||||||
|
this.string = string;
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.AST.HashNode = function(pairs) {
|
||||||
|
this.type = "hash";
|
||||||
|
this.pairs = pairs;
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.AST.IdNode = function(parts) {
|
||||||
|
this.type = "ID";
|
||||||
|
this.original = parts.join(".");
|
||||||
|
|
||||||
|
var dig = [], depth = 0;
|
||||||
|
|
||||||
|
for(var i=0,l=parts.length; i<l; i++) {
|
||||||
|
var part = parts[i];
|
||||||
|
|
||||||
|
if(part === "..") { depth++; }
|
||||||
|
else if(part === "." || part === "this") { this.isScoped = true; }
|
||||||
|
else { dig.push(part); }
|
||||||
|
}
|
||||||
|
|
||||||
|
this.parts = dig;
|
||||||
|
this.string = dig.join('.');
|
||||||
|
this.depth = depth;
|
||||||
|
this.isSimple = (dig.length === 1) && (depth === 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.AST.StringNode = function(string) {
|
||||||
|
this.type = "STRING";
|
||||||
|
this.string = string;
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.AST.IntegerNode = function(integer) {
|
||||||
|
this.type = "INTEGER";
|
||||||
|
this.integer = integer;
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.AST.BooleanNode = function(bool) {
|
||||||
|
this.type = "BOOLEAN";
|
||||||
|
this.bool = bool;
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.AST.CommentNode = function(comment) {
|
||||||
|
this.type = "comment";
|
||||||
|
this.comment = comment;
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
||||||
|
// END(BROWSER)
|
||||||
|
|
||||||
27
node_modules/handlebars/lib/handlebars/compiler/base.js
generated
vendored
Normal file
27
node_modules/handlebars/lib/handlebars/compiler/base.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
var handlebars = require("./parser").parser;
|
||||||
|
var Handlebars = require("../base");
|
||||||
|
|
||||||
|
// BEGIN(BROWSER)
|
||||||
|
Handlebars.Parser = handlebars;
|
||||||
|
|
||||||
|
Handlebars.parse = function(string) {
|
||||||
|
Handlebars.Parser.yy = Handlebars.AST;
|
||||||
|
return Handlebars.Parser.parse(string);
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.print = function(ast) {
|
||||||
|
return new Handlebars.PrintVisitor().accept(ast);
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.logger = {
|
||||||
|
DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3,
|
||||||
|
|
||||||
|
// override in the host environment
|
||||||
|
log: function(level, str) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); };
|
||||||
|
|
||||||
|
// END(BROWSER)
|
||||||
|
|
||||||
|
module.exports = Handlebars;
|
||||||
805
node_modules/handlebars/lib/handlebars/compiler/compiler.js
generated
vendored
Normal file
805
node_modules/handlebars/lib/handlebars/compiler/compiler.js
generated
vendored
Normal file
@@ -0,0 +1,805 @@
|
|||||||
|
var Handlebars = require("./base");
|
||||||
|
|
||||||
|
// BEGIN(BROWSER)
|
||||||
|
Handlebars.Compiler = function() {};
|
||||||
|
Handlebars.JavaScriptCompiler = function() {};
|
||||||
|
|
||||||
|
(function(Compiler, JavaScriptCompiler) {
|
||||||
|
Compiler.OPCODE_MAP = {
|
||||||
|
appendContent: 1,
|
||||||
|
getContext: 2,
|
||||||
|
lookupWithHelpers: 3,
|
||||||
|
lookup: 4,
|
||||||
|
append: 5,
|
||||||
|
invokeMustache: 6,
|
||||||
|
appendEscaped: 7,
|
||||||
|
pushString: 8,
|
||||||
|
truthyOrFallback: 9,
|
||||||
|
functionOrFallback: 10,
|
||||||
|
invokeProgram: 11,
|
||||||
|
invokePartial: 12,
|
||||||
|
push: 13,
|
||||||
|
assignToHash: 15,
|
||||||
|
pushStringParam: 16
|
||||||
|
};
|
||||||
|
|
||||||
|
Compiler.MULTI_PARAM_OPCODES = {
|
||||||
|
appendContent: 1,
|
||||||
|
getContext: 1,
|
||||||
|
lookupWithHelpers: 2,
|
||||||
|
lookup: 1,
|
||||||
|
invokeMustache: 3,
|
||||||
|
pushString: 1,
|
||||||
|
truthyOrFallback: 1,
|
||||||
|
functionOrFallback: 1,
|
||||||
|
invokeProgram: 3,
|
||||||
|
invokePartial: 1,
|
||||||
|
push: 1,
|
||||||
|
assignToHash: 1,
|
||||||
|
pushStringParam: 1
|
||||||
|
};
|
||||||
|
|
||||||
|
Compiler.DISASSEMBLE_MAP = {};
|
||||||
|
|
||||||
|
for(var prop in Compiler.OPCODE_MAP) {
|
||||||
|
var value = Compiler.OPCODE_MAP[prop];
|
||||||
|
Compiler.DISASSEMBLE_MAP[value] = prop;
|
||||||
|
}
|
||||||
|
|
||||||
|
Compiler.multiParamSize = function(code) {
|
||||||
|
return Compiler.MULTI_PARAM_OPCODES[Compiler.DISASSEMBLE_MAP[code]];
|
||||||
|
};
|
||||||
|
|
||||||
|
Compiler.prototype = {
|
||||||
|
compiler: Compiler,
|
||||||
|
|
||||||
|
disassemble: function() {
|
||||||
|
var opcodes = this.opcodes, opcode, nextCode;
|
||||||
|
var out = [], str, name, value;
|
||||||
|
|
||||||
|
for(var i=0, l=opcodes.length; i<l; i++) {
|
||||||
|
opcode = opcodes[i];
|
||||||
|
|
||||||
|
if(opcode === 'DECLARE') {
|
||||||
|
name = opcodes[++i];
|
||||||
|
value = opcodes[++i];
|
||||||
|
out.push("DECLARE " + name + " = " + value);
|
||||||
|
} else {
|
||||||
|
str = Compiler.DISASSEMBLE_MAP[opcode];
|
||||||
|
|
||||||
|
var extraParams = Compiler.multiParamSize(opcode);
|
||||||
|
var codes = [];
|
||||||
|
|
||||||
|
for(var j=0; j<extraParams; j++) {
|
||||||
|
nextCode = opcodes[++i];
|
||||||
|
|
||||||
|
if(typeof nextCode === "string") {
|
||||||
|
nextCode = "\"" + nextCode.replace("\n", "\\n") + "\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
codes.push(nextCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
str = str + " " + codes.join(" ");
|
||||||
|
|
||||||
|
out.push(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return out.join("\n");
|
||||||
|
},
|
||||||
|
|
||||||
|
guid: 0,
|
||||||
|
|
||||||
|
compile: function(program, options) {
|
||||||
|
this.children = [];
|
||||||
|
this.depths = {list: []};
|
||||||
|
this.options = options;
|
||||||
|
|
||||||
|
// These changes will propagate to the other compiler components
|
||||||
|
var knownHelpers = this.options.knownHelpers;
|
||||||
|
this.options.knownHelpers = {
|
||||||
|
'helperMissing': true,
|
||||||
|
'blockHelperMissing': true,
|
||||||
|
'each': true,
|
||||||
|
'if': true,
|
||||||
|
'unless': true,
|
||||||
|
'with': true,
|
||||||
|
'log': true
|
||||||
|
};
|
||||||
|
if (knownHelpers) {
|
||||||
|
for (var name in knownHelpers) {
|
||||||
|
this.options.knownHelpers[name] = knownHelpers[name];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.program(program);
|
||||||
|
},
|
||||||
|
|
||||||
|
accept: function(node) {
|
||||||
|
return this[node.type](node);
|
||||||
|
},
|
||||||
|
|
||||||
|
program: function(program) {
|
||||||
|
var statements = program.statements, statement;
|
||||||
|
this.opcodes = [];
|
||||||
|
|
||||||
|
for(var i=0, l=statements.length; i<l; i++) {
|
||||||
|
statement = statements[i];
|
||||||
|
this[statement.type](statement);
|
||||||
|
}
|
||||||
|
this.isSimple = l === 1;
|
||||||
|
|
||||||
|
this.depths.list = this.depths.list.sort(function(a, b) {
|
||||||
|
return a - b;
|
||||||
|
});
|
||||||
|
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
|
||||||
|
compileProgram: function(program) {
|
||||||
|
var result = new this.compiler().compile(program, this.options);
|
||||||
|
var guid = this.guid++;
|
||||||
|
|
||||||
|
this.usePartial = this.usePartial || result.usePartial;
|
||||||
|
|
||||||
|
this.children[guid] = result;
|
||||||
|
|
||||||
|
for(var i=0, l=result.depths.list.length; i<l; i++) {
|
||||||
|
depth = result.depths.list[i];
|
||||||
|
|
||||||
|
if(depth < 2) { continue; }
|
||||||
|
else { this.addDepth(depth - 1); }
|
||||||
|
}
|
||||||
|
|
||||||
|
return guid;
|
||||||
|
},
|
||||||
|
|
||||||
|
block: function(block) {
|
||||||
|
var mustache = block.mustache;
|
||||||
|
var depth, child, inverse, inverseGuid;
|
||||||
|
|
||||||
|
var params = this.setupStackForMustache(mustache);
|
||||||
|
|
||||||
|
var programGuid = this.compileProgram(block.program);
|
||||||
|
|
||||||
|
if(block.program.inverse) {
|
||||||
|
inverseGuid = this.compileProgram(block.program.inverse);
|
||||||
|
this.declare('inverse', inverseGuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.opcode('invokeProgram', programGuid, params.length, !!mustache.hash);
|
||||||
|
this.declare('inverse', null);
|
||||||
|
this.opcode('append');
|
||||||
|
},
|
||||||
|
|
||||||
|
inverse: function(block) {
|
||||||
|
var params = this.setupStackForMustache(block.mustache);
|
||||||
|
|
||||||
|
var programGuid = this.compileProgram(block.program);
|
||||||
|
|
||||||
|
this.declare('inverse', programGuid);
|
||||||
|
|
||||||
|
this.opcode('invokeProgram', null, params.length, !!block.mustache.hash);
|
||||||
|
this.declare('inverse', null);
|
||||||
|
this.opcode('append');
|
||||||
|
},
|
||||||
|
|
||||||
|
hash: function(hash) {
|
||||||
|
var pairs = hash.pairs, pair, val;
|
||||||
|
|
||||||
|
this.opcode('push', '{}');
|
||||||
|
|
||||||
|
for(var i=0, l=pairs.length; i<l; i++) {
|
||||||
|
pair = pairs[i];
|
||||||
|
val = pair[1];
|
||||||
|
|
||||||
|
this.accept(val);
|
||||||
|
this.opcode('assignToHash', pair[0]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
partial: function(partial) {
|
||||||
|
var id = partial.id;
|
||||||
|
this.usePartial = true;
|
||||||
|
|
||||||
|
if(partial.context) {
|
||||||
|
this.ID(partial.context);
|
||||||
|
} else {
|
||||||
|
this.opcode('push', 'depth0');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.opcode('invokePartial', id.original);
|
||||||
|
this.opcode('append');
|
||||||
|
},
|
||||||
|
|
||||||
|
content: function(content) {
|
||||||
|
this.opcode('appendContent', content.string);
|
||||||
|
},
|
||||||
|
|
||||||
|
mustache: function(mustache) {
|
||||||
|
var params = this.setupStackForMustache(mustache);
|
||||||
|
|
||||||
|
this.opcode('invokeMustache', params.length, mustache.id.original, !!mustache.hash);
|
||||||
|
|
||||||
|
if(mustache.escaped && !this.options.noEscape) {
|
||||||
|
this.opcode('appendEscaped');
|
||||||
|
} else {
|
||||||
|
this.opcode('append');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
ID: function(id) {
|
||||||
|
this.addDepth(id.depth);
|
||||||
|
|
||||||
|
this.opcode('getContext', id.depth);
|
||||||
|
|
||||||
|
this.opcode('lookupWithHelpers', id.parts[0] || null, id.isScoped || false);
|
||||||
|
|
||||||
|
for(var i=1, l=id.parts.length; i<l; i++) {
|
||||||
|
this.opcode('lookup', id.parts[i]);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
STRING: function(string) {
|
||||||
|
this.opcode('pushString', string.string);
|
||||||
|
},
|
||||||
|
|
||||||
|
INTEGER: function(integer) {
|
||||||
|
this.opcode('push', integer.integer);
|
||||||
|
},
|
||||||
|
|
||||||
|
BOOLEAN: function(bool) {
|
||||||
|
this.opcode('push', bool.bool);
|
||||||
|
},
|
||||||
|
|
||||||
|
comment: function() {},
|
||||||
|
|
||||||
|
// HELPERS
|
||||||
|
pushParams: function(params) {
|
||||||
|
var i = params.length, param;
|
||||||
|
|
||||||
|
while(i--) {
|
||||||
|
param = params[i];
|
||||||
|
|
||||||
|
if(this.options.stringParams) {
|
||||||
|
if(param.depth) {
|
||||||
|
this.addDepth(param.depth);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.opcode('getContext', param.depth || 0);
|
||||||
|
this.opcode('pushStringParam', param.string);
|
||||||
|
} else {
|
||||||
|
this[param.type](param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
opcode: function(name, val1, val2, val3) {
|
||||||
|
this.opcodes.push(Compiler.OPCODE_MAP[name]);
|
||||||
|
if(val1 !== undefined) { this.opcodes.push(val1); }
|
||||||
|
if(val2 !== undefined) { this.opcodes.push(val2); }
|
||||||
|
if(val3 !== undefined) { this.opcodes.push(val3); }
|
||||||
|
},
|
||||||
|
|
||||||
|
declare: function(name, value) {
|
||||||
|
this.opcodes.push('DECLARE');
|
||||||
|
this.opcodes.push(name);
|
||||||
|
this.opcodes.push(value);
|
||||||
|
},
|
||||||
|
|
||||||
|
addDepth: function(depth) {
|
||||||
|
if(depth === 0) { return; }
|
||||||
|
|
||||||
|
if(!this.depths[depth]) {
|
||||||
|
this.depths[depth] = true;
|
||||||
|
this.depths.list.push(depth);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
setupStackForMustache: function(mustache) {
|
||||||
|
var params = mustache.params;
|
||||||
|
|
||||||
|
this.pushParams(params);
|
||||||
|
|
||||||
|
if(mustache.hash) {
|
||||||
|
this.hash(mustache.hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.ID(mustache.id);
|
||||||
|
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
JavaScriptCompiler.prototype = {
|
||||||
|
// PUBLIC API: You can override these methods in a subclass to provide
|
||||||
|
// alternative compiled forms for name lookup and buffering semantics
|
||||||
|
nameLookup: function(parent, name, type) {
|
||||||
|
if (/^[0-9]+$/.test(name)) {
|
||||||
|
return parent + "[" + name + "]";
|
||||||
|
} else if (JavaScriptCompiler.isValidJavaScriptVariableName(name)) {
|
||||||
|
return parent + "." + name;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return parent + "['" + name + "']";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
appendToBuffer: function(string) {
|
||||||
|
if (this.environment.isSimple) {
|
||||||
|
return "return " + string + ";";
|
||||||
|
} else {
|
||||||
|
return "buffer += " + string + ";";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
initializeBuffer: function() {
|
||||||
|
return this.quotedString("");
|
||||||
|
},
|
||||||
|
|
||||||
|
namespace: "Handlebars",
|
||||||
|
// END PUBLIC API
|
||||||
|
|
||||||
|
compile: function(environment, options, context, asObject) {
|
||||||
|
this.environment = environment;
|
||||||
|
this.options = options || {};
|
||||||
|
|
||||||
|
this.name = this.environment.name;
|
||||||
|
this.isChild = !!context;
|
||||||
|
this.context = context || {
|
||||||
|
programs: [],
|
||||||
|
aliases: { self: 'this' },
|
||||||
|
registers: {list: []}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.preamble();
|
||||||
|
|
||||||
|
this.stackSlot = 0;
|
||||||
|
this.stackVars = [];
|
||||||
|
|
||||||
|
this.compileChildren(environment, options);
|
||||||
|
|
||||||
|
var opcodes = environment.opcodes, opcode;
|
||||||
|
|
||||||
|
this.i = 0;
|
||||||
|
|
||||||
|
for(l=opcodes.length; this.i<l; this.i++) {
|
||||||
|
opcode = this.nextOpcode(0);
|
||||||
|
|
||||||
|
if(opcode[0] === 'DECLARE') {
|
||||||
|
this.i = this.i + 2;
|
||||||
|
this[opcode[1]] = opcode[2];
|
||||||
|
} else {
|
||||||
|
this.i = this.i + opcode[1].length;
|
||||||
|
this[opcode[0]].apply(this, opcode[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.createFunctionContext(asObject);
|
||||||
|
},
|
||||||
|
|
||||||
|
nextOpcode: function(n) {
|
||||||
|
var opcodes = this.environment.opcodes, opcode = opcodes[this.i + n], name, val;
|
||||||
|
var extraParams, codes;
|
||||||
|
|
||||||
|
if(opcode === 'DECLARE') {
|
||||||
|
name = opcodes[this.i + 1];
|
||||||
|
val = opcodes[this.i + 2];
|
||||||
|
return ['DECLARE', name, val];
|
||||||
|
} else {
|
||||||
|
name = Compiler.DISASSEMBLE_MAP[opcode];
|
||||||
|
|
||||||
|
extraParams = Compiler.multiParamSize(opcode);
|
||||||
|
codes = [];
|
||||||
|
|
||||||
|
for(var j=0; j<extraParams; j++) {
|
||||||
|
codes.push(opcodes[this.i + j + 1 + n]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [name, codes];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
eat: function(opcode) {
|
||||||
|
this.i = this.i + opcode.length;
|
||||||
|
},
|
||||||
|
|
||||||
|
preamble: function() {
|
||||||
|
var out = [];
|
||||||
|
|
||||||
|
// this register will disambiguate helper lookup from finding a function in
|
||||||
|
// a context. This is necessary for mustache compatibility, which requires
|
||||||
|
// that context functions in blocks are evaluated by blockHelperMissing, and
|
||||||
|
// then proceed as if the resulting value was provided to blockHelperMissing.
|
||||||
|
this.useRegister('foundHelper');
|
||||||
|
|
||||||
|
if (!this.isChild) {
|
||||||
|
var namespace = this.namespace;
|
||||||
|
var copies = "helpers = helpers || " + namespace + ".helpers;";
|
||||||
|
if(this.environment.usePartial) { copies = copies + " partials = partials || " + namespace + ".partials;"; }
|
||||||
|
out.push(copies);
|
||||||
|
} else {
|
||||||
|
out.push('');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.environment.isSimple) {
|
||||||
|
out.push(", buffer = " + this.initializeBuffer());
|
||||||
|
} else {
|
||||||
|
out.push("");
|
||||||
|
}
|
||||||
|
|
||||||
|
// track the last context pushed into place to allow skipping the
|
||||||
|
// getContext opcode when it would be a noop
|
||||||
|
this.lastContext = 0;
|
||||||
|
this.source = out;
|
||||||
|
},
|
||||||
|
|
||||||
|
createFunctionContext: function(asObject) {
|
||||||
|
var locals = this.stackVars;
|
||||||
|
if (!this.isChild) {
|
||||||
|
locals = locals.concat(this.context.registers.list);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(locals.length > 0) {
|
||||||
|
this.source[1] = this.source[1] + ", " + locals.join(", ");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate minimizer alias mappings
|
||||||
|
if (!this.isChild) {
|
||||||
|
var aliases = [];
|
||||||
|
for (var alias in this.context.aliases) {
|
||||||
|
this.source[1] = this.source[1] + ', ' + alias + '=' + this.context.aliases[alias];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.source[1]) {
|
||||||
|
this.source[1] = "var " + this.source[1].substring(2) + ";";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Merge children
|
||||||
|
if (!this.isChild) {
|
||||||
|
this.source[1] += '\n' + this.context.programs.join('\n') + '\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.environment.isSimple) {
|
||||||
|
this.source.push("return buffer;");
|
||||||
|
}
|
||||||
|
|
||||||
|
var params = this.isChild ? ["depth0", "data"] : ["Handlebars", "depth0", "helpers", "partials", "data"];
|
||||||
|
|
||||||
|
for(var i=0, l=this.environment.depths.list.length; i<l; i++) {
|
||||||
|
params.push("depth" + this.environment.depths.list[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (asObject) {
|
||||||
|
params.push(this.source.join("\n "));
|
||||||
|
|
||||||
|
return Function.apply(this, params);
|
||||||
|
} else {
|
||||||
|
var functionSource = 'function ' + (this.name || '') + '(' + params.join(',') + ') {\n ' + this.source.join("\n ") + '}';
|
||||||
|
Handlebars.log(Handlebars.logger.DEBUG, functionSource + "\n\n");
|
||||||
|
return functionSource;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
appendContent: function(content) {
|
||||||
|
this.source.push(this.appendToBuffer(this.quotedString(content)));
|
||||||
|
},
|
||||||
|
|
||||||
|
append: function() {
|
||||||
|
var local = this.popStack();
|
||||||
|
this.source.push("if(" + local + " || " + local + " === 0) { " + this.appendToBuffer(local) + " }");
|
||||||
|
if (this.environment.isSimple) {
|
||||||
|
this.source.push("else { " + this.appendToBuffer("''") + " }");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
appendEscaped: function() {
|
||||||
|
var opcode = this.nextOpcode(1), extra = "";
|
||||||
|
this.context.aliases.escapeExpression = 'this.escapeExpression';
|
||||||
|
|
||||||
|
if(opcode[0] === 'appendContent') {
|
||||||
|
extra = " + " + this.quotedString(opcode[1][0]);
|
||||||
|
this.eat(opcode);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.source.push(this.appendToBuffer("escapeExpression(" + this.popStack() + ")" + extra));
|
||||||
|
},
|
||||||
|
|
||||||
|
getContext: function(depth) {
|
||||||
|
if(this.lastContext !== depth) {
|
||||||
|
this.lastContext = depth;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
lookupWithHelpers: function(name, isScoped) {
|
||||||
|
if(name) {
|
||||||
|
var topStack = this.nextStack();
|
||||||
|
|
||||||
|
this.usingKnownHelper = false;
|
||||||
|
|
||||||
|
var toPush;
|
||||||
|
if (!isScoped && this.options.knownHelpers[name]) {
|
||||||
|
toPush = topStack + " = " + this.nameLookup('helpers', name, 'helper');
|
||||||
|
this.usingKnownHelper = true;
|
||||||
|
} else if (isScoped || this.options.knownHelpersOnly) {
|
||||||
|
toPush = topStack + " = " + this.nameLookup('depth' + this.lastContext, name, 'context');
|
||||||
|
} else {
|
||||||
|
this.register('foundHelper', this.nameLookup('helpers', name, 'helper'));
|
||||||
|
toPush = topStack + " = foundHelper || " + this.nameLookup('depth' + this.lastContext, name, 'context');
|
||||||
|
}
|
||||||
|
|
||||||
|
toPush += ';';
|
||||||
|
this.source.push(toPush);
|
||||||
|
} else {
|
||||||
|
this.pushStack('depth' + this.lastContext);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
lookup: function(name) {
|
||||||
|
var topStack = this.topStack();
|
||||||
|
this.source.push(topStack + " = (" + topStack + " === null || " + topStack + " === undefined || " + topStack + " === false ? " +
|
||||||
|
topStack + " : " + this.nameLookup(topStack, name, 'context') + ");");
|
||||||
|
},
|
||||||
|
|
||||||
|
pushStringParam: function(string) {
|
||||||
|
this.pushStack('depth' + this.lastContext);
|
||||||
|
this.pushString(string);
|
||||||
|
},
|
||||||
|
|
||||||
|
pushString: function(string) {
|
||||||
|
this.pushStack(this.quotedString(string));
|
||||||
|
},
|
||||||
|
|
||||||
|
push: function(name) {
|
||||||
|
this.pushStack(name);
|
||||||
|
},
|
||||||
|
|
||||||
|
invokeMustache: function(paramSize, original, hasHash) {
|
||||||
|
this.populateParams(paramSize, this.quotedString(original), "{}", null, hasHash, function(nextStack, helperMissingString, id) {
|
||||||
|
if (!this.usingKnownHelper) {
|
||||||
|
this.context.aliases.helperMissing = 'helpers.helperMissing';
|
||||||
|
this.context.aliases.undef = 'void 0';
|
||||||
|
this.source.push("else if(" + id + "=== undef) { " + nextStack + " = helperMissing.call(" + helperMissingString + "); }");
|
||||||
|
if (nextStack !== id) {
|
||||||
|
this.source.push("else { " + nextStack + " = " + id + "; }");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
invokeProgram: function(guid, paramSize, hasHash) {
|
||||||
|
var inverse = this.programExpression(this.inverse);
|
||||||
|
var mainProgram = this.programExpression(guid);
|
||||||
|
|
||||||
|
this.populateParams(paramSize, null, mainProgram, inverse, hasHash, function(nextStack, helperMissingString, id) {
|
||||||
|
if (!this.usingKnownHelper) {
|
||||||
|
this.context.aliases.blockHelperMissing = 'helpers.blockHelperMissing';
|
||||||
|
this.source.push("else { " + nextStack + " = blockHelperMissing.call(" + helperMissingString + "); }");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
populateParams: function(paramSize, helperId, program, inverse, hasHash, fn) {
|
||||||
|
var needsRegister = hasHash || this.options.stringParams || inverse || this.options.data;
|
||||||
|
var id = this.popStack(), nextStack;
|
||||||
|
var params = [], param, stringParam, stringOptions;
|
||||||
|
|
||||||
|
if (needsRegister) {
|
||||||
|
this.register('tmp1', program);
|
||||||
|
stringOptions = 'tmp1';
|
||||||
|
} else {
|
||||||
|
stringOptions = '{ hash: {} }';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (needsRegister) {
|
||||||
|
var hash = (hasHash ? this.popStack() : '{}');
|
||||||
|
this.source.push('tmp1.hash = ' + hash + ';');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.options.stringParams) {
|
||||||
|
this.source.push('tmp1.contexts = [];');
|
||||||
|
}
|
||||||
|
|
||||||
|
for(var i=0; i<paramSize; i++) {
|
||||||
|
param = this.popStack();
|
||||||
|
params.push(param);
|
||||||
|
|
||||||
|
if(this.options.stringParams) {
|
||||||
|
this.source.push('tmp1.contexts.push(' + this.popStack() + ');');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(inverse) {
|
||||||
|
this.source.push('tmp1.fn = tmp1;');
|
||||||
|
this.source.push('tmp1.inverse = ' + inverse + ';');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.options.data) {
|
||||||
|
this.source.push('tmp1.data = data;');
|
||||||
|
}
|
||||||
|
|
||||||
|
params.push(stringOptions);
|
||||||
|
|
||||||
|
this.populateCall(params, id, helperId || id, fn, program !== '{}');
|
||||||
|
},
|
||||||
|
|
||||||
|
populateCall: function(params, id, helperId, fn, program) {
|
||||||
|
var paramString = ["depth0"].concat(params).join(", ");
|
||||||
|
var helperMissingString = ["depth0"].concat(helperId).concat(params).join(", ");
|
||||||
|
|
||||||
|
var nextStack = this.nextStack();
|
||||||
|
|
||||||
|
if (this.usingKnownHelper) {
|
||||||
|
this.source.push(nextStack + " = " + id + ".call(" + paramString + ");");
|
||||||
|
} else {
|
||||||
|
this.context.aliases.functionType = '"function"';
|
||||||
|
var condition = program ? "foundHelper && " : "";
|
||||||
|
this.source.push("if(" + condition + "typeof " + id + " === functionType) { " + nextStack + " = " + id + ".call(" + paramString + "); }");
|
||||||
|
}
|
||||||
|
fn.call(this, nextStack, helperMissingString, id);
|
||||||
|
this.usingKnownHelper = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
invokePartial: function(context) {
|
||||||
|
params = [this.nameLookup('partials', context, 'partial'), "'" + context + "'", this.popStack(), "helpers", "partials"];
|
||||||
|
|
||||||
|
if (this.options.data) {
|
||||||
|
params.push("data");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pushStack("self.invokePartial(" + params.join(", ") + ");");
|
||||||
|
},
|
||||||
|
|
||||||
|
assignToHash: function(key) {
|
||||||
|
var value = this.popStack();
|
||||||
|
var hash = this.topStack();
|
||||||
|
|
||||||
|
this.source.push(hash + "['" + key + "'] = " + value + ";");
|
||||||
|
},
|
||||||
|
|
||||||
|
// HELPERS
|
||||||
|
|
||||||
|
compiler: JavaScriptCompiler,
|
||||||
|
|
||||||
|
compileChildren: function(environment, options) {
|
||||||
|
var children = environment.children, child, compiler;
|
||||||
|
|
||||||
|
for(var i=0, l=children.length; i<l; i++) {
|
||||||
|
child = children[i];
|
||||||
|
compiler = new this.compiler();
|
||||||
|
|
||||||
|
this.context.programs.push(''); // Placeholder to prevent name conflicts for nested children
|
||||||
|
var index = this.context.programs.length;
|
||||||
|
child.index = index;
|
||||||
|
child.name = 'program' + index;
|
||||||
|
this.context.programs[index] = compiler.compile(child, options, this.context);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
programExpression: function(guid) {
|
||||||
|
if(guid == null) { return "self.noop"; }
|
||||||
|
|
||||||
|
var child = this.environment.children[guid],
|
||||||
|
depths = child.depths.list;
|
||||||
|
var programParams = [child.index, child.name, "data"];
|
||||||
|
|
||||||
|
for(var i=0, l = depths.length; i<l; i++) {
|
||||||
|
depth = depths[i];
|
||||||
|
|
||||||
|
if(depth === 1) { programParams.push("depth0"); }
|
||||||
|
else { programParams.push("depth" + (depth - 1)); }
|
||||||
|
}
|
||||||
|
|
||||||
|
if(depths.length === 0) {
|
||||||
|
return "self.program(" + programParams.join(", ") + ")";
|
||||||
|
} else {
|
||||||
|
programParams.shift();
|
||||||
|
return "self.programWithDepth(" + programParams.join(", ") + ")";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
register: function(name, val) {
|
||||||
|
this.useRegister(name);
|
||||||
|
this.source.push(name + " = " + val + ";");
|
||||||
|
},
|
||||||
|
|
||||||
|
useRegister: function(name) {
|
||||||
|
if(!this.context.registers[name]) {
|
||||||
|
this.context.registers[name] = true;
|
||||||
|
this.context.registers.list.push(name);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
pushStack: function(item) {
|
||||||
|
this.source.push(this.nextStack() + " = " + item + ";");
|
||||||
|
return "stack" + this.stackSlot;
|
||||||
|
},
|
||||||
|
|
||||||
|
nextStack: function() {
|
||||||
|
this.stackSlot++;
|
||||||
|
if(this.stackSlot > this.stackVars.length) { this.stackVars.push("stack" + this.stackSlot); }
|
||||||
|
return "stack" + this.stackSlot;
|
||||||
|
},
|
||||||
|
|
||||||
|
popStack: function() {
|
||||||
|
return "stack" + this.stackSlot--;
|
||||||
|
},
|
||||||
|
|
||||||
|
topStack: function() {
|
||||||
|
return "stack" + this.stackSlot;
|
||||||
|
},
|
||||||
|
|
||||||
|
quotedString: function(str) {
|
||||||
|
return '"' + str
|
||||||
|
.replace(/\\/g, '\\\\')
|
||||||
|
.replace(/"/g, '\\"')
|
||||||
|
.replace(/\n/g, '\\n')
|
||||||
|
.replace(/\r/g, '\\r') + '"';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var reservedWords = (
|
||||||
|
"break else new var" +
|
||||||
|
" case finally return void" +
|
||||||
|
" catch for switch while" +
|
||||||
|
" continue function this with" +
|
||||||
|
" default if throw" +
|
||||||
|
" delete in try" +
|
||||||
|
" do instanceof typeof" +
|
||||||
|
" abstract enum int short" +
|
||||||
|
" boolean export interface static" +
|
||||||
|
" byte extends long super" +
|
||||||
|
" char final native synchronized" +
|
||||||
|
" class float package throws" +
|
||||||
|
" const goto private transient" +
|
||||||
|
" debugger implements protected volatile" +
|
||||||
|
" double import public let yield"
|
||||||
|
).split(" ");
|
||||||
|
|
||||||
|
var compilerWords = JavaScriptCompiler.RESERVED_WORDS = {};
|
||||||
|
|
||||||
|
for(var i=0, l=reservedWords.length; i<l; i++) {
|
||||||
|
compilerWords[reservedWords[i]] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
JavaScriptCompiler.isValidJavaScriptVariableName = function(name) {
|
||||||
|
if(!JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]+$/.test(name)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
})(Handlebars.Compiler, Handlebars.JavaScriptCompiler);
|
||||||
|
|
||||||
|
Handlebars.precompile = function(string, options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
var ast = Handlebars.parse(string);
|
||||||
|
var environment = new Handlebars.Compiler().compile(ast, options);
|
||||||
|
return new Handlebars.JavaScriptCompiler().compile(environment, options);
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.compile = function(string, options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
var compiled;
|
||||||
|
function compile() {
|
||||||
|
var ast = Handlebars.parse(string);
|
||||||
|
var environment = new Handlebars.Compiler().compile(ast, options);
|
||||||
|
var templateSpec = new Handlebars.JavaScriptCompiler().compile(environment, options, undefined, true);
|
||||||
|
return Handlebars.template(templateSpec);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Template is only compiled on first use and cached after that point.
|
||||||
|
return function(context, options) {
|
||||||
|
if (!compiled) {
|
||||||
|
compiled = compile();
|
||||||
|
}
|
||||||
|
return compiled.call(this, context, options);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// END(BROWSER)
|
||||||
|
|
||||||
7
node_modules/handlebars/lib/handlebars/compiler/index.js
generated
vendored
Normal file
7
node_modules/handlebars/lib/handlebars/compiler/index.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
// Each of these module will augment the Handlebars object as it loads. No need to perform addition operations
|
||||||
|
module.exports = require("./base");
|
||||||
|
require("./visitor");
|
||||||
|
require("./printer");
|
||||||
|
|
||||||
|
require("./ast");
|
||||||
|
require("./compiler");
|
||||||
480
node_modules/handlebars/lib/handlebars/compiler/parser.js
generated
vendored
Normal file
480
node_modules/handlebars/lib/handlebars/compiler/parser.js
generated
vendored
Normal file
@@ -0,0 +1,480 @@
|
|||||||
|
/* Jison generated parser */
|
||||||
|
var handlebars = (function(){
|
||||||
|
var parser = {trace: function trace() { },
|
||||||
|
yy: {},
|
||||||
|
symbols_: {"error":2,"root":3,"program":4,"EOF":5,"statements":6,"simpleInverse":7,"statement":8,"openInverse":9,"closeBlock":10,"openBlock":11,"mustache":12,"partial":13,"CONTENT":14,"COMMENT":15,"OPEN_BLOCK":16,"inMustache":17,"CLOSE":18,"OPEN_INVERSE":19,"OPEN_ENDBLOCK":20,"path":21,"OPEN":22,"OPEN_UNESCAPED":23,"OPEN_PARTIAL":24,"params":25,"hash":26,"param":27,"STRING":28,"INTEGER":29,"BOOLEAN":30,"hashSegments":31,"hashSegment":32,"ID":33,"EQUALS":34,"pathSegments":35,"SEP":36,"$accept":0,"$end":1},
|
||||||
|
terminals_: {2:"error",5:"EOF",14:"CONTENT",15:"COMMENT",16:"OPEN_BLOCK",18:"CLOSE",19:"OPEN_INVERSE",20:"OPEN_ENDBLOCK",22:"OPEN",23:"OPEN_UNESCAPED",24:"OPEN_PARTIAL",28:"STRING",29:"INTEGER",30:"BOOLEAN",33:"ID",34:"EQUALS",36:"SEP"},
|
||||||
|
productions_: [0,[3,2],[4,3],[4,1],[4,0],[6,1],[6,2],[8,3],[8,3],[8,1],[8,1],[8,1],[8,1],[11,3],[9,3],[10,3],[12,3],[12,3],[13,3],[13,4],[7,2],[17,3],[17,2],[17,2],[17,1],[25,2],[25,1],[27,1],[27,1],[27,1],[27,1],[26,1],[31,2],[31,1],[32,3],[32,3],[32,3],[32,3],[21,1],[35,3],[35,1]],
|
||||||
|
performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
|
||||||
|
|
||||||
|
var $0 = $$.length - 1;
|
||||||
|
switch (yystate) {
|
||||||
|
case 1: return $$[$0-1];
|
||||||
|
break;
|
||||||
|
case 2: this.$ = new yy.ProgramNode($$[$0-2], $$[$0]);
|
||||||
|
break;
|
||||||
|
case 3: this.$ = new yy.ProgramNode($$[$0]);
|
||||||
|
break;
|
||||||
|
case 4: this.$ = new yy.ProgramNode([]);
|
||||||
|
break;
|
||||||
|
case 5: this.$ = [$$[$0]];
|
||||||
|
break;
|
||||||
|
case 6: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
|
||||||
|
break;
|
||||||
|
case 7: this.$ = new yy.InverseNode($$[$0-2], $$[$0-1], $$[$0]);
|
||||||
|
break;
|
||||||
|
case 8: this.$ = new yy.BlockNode($$[$0-2], $$[$0-1], $$[$0]);
|
||||||
|
break;
|
||||||
|
case 9: this.$ = $$[$0];
|
||||||
|
break;
|
||||||
|
case 10: this.$ = $$[$0];
|
||||||
|
break;
|
||||||
|
case 11: this.$ = new yy.ContentNode($$[$0]);
|
||||||
|
break;
|
||||||
|
case 12: this.$ = new yy.CommentNode($$[$0]);
|
||||||
|
break;
|
||||||
|
case 13: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
|
||||||
|
break;
|
||||||
|
case 14: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
|
||||||
|
break;
|
||||||
|
case 15: this.$ = $$[$0-1];
|
||||||
|
break;
|
||||||
|
case 16: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1]);
|
||||||
|
break;
|
||||||
|
case 17: this.$ = new yy.MustacheNode($$[$0-1][0], $$[$0-1][1], true);
|
||||||
|
break;
|
||||||
|
case 18: this.$ = new yy.PartialNode($$[$0-1]);
|
||||||
|
break;
|
||||||
|
case 19: this.$ = new yy.PartialNode($$[$0-2], $$[$0-1]);
|
||||||
|
break;
|
||||||
|
case 20:
|
||||||
|
break;
|
||||||
|
case 21: this.$ = [[$$[$0-2]].concat($$[$0-1]), $$[$0]];
|
||||||
|
break;
|
||||||
|
case 22: this.$ = [[$$[$0-1]].concat($$[$0]), null];
|
||||||
|
break;
|
||||||
|
case 23: this.$ = [[$$[$0-1]], $$[$0]];
|
||||||
|
break;
|
||||||
|
case 24: this.$ = [[$$[$0]], null];
|
||||||
|
break;
|
||||||
|
case 25: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
|
||||||
|
break;
|
||||||
|
case 26: this.$ = [$$[$0]];
|
||||||
|
break;
|
||||||
|
case 27: this.$ = $$[$0];
|
||||||
|
break;
|
||||||
|
case 28: this.$ = new yy.StringNode($$[$0]);
|
||||||
|
break;
|
||||||
|
case 29: this.$ = new yy.IntegerNode($$[$0]);
|
||||||
|
break;
|
||||||
|
case 30: this.$ = new yy.BooleanNode($$[$0]);
|
||||||
|
break;
|
||||||
|
case 31: this.$ = new yy.HashNode($$[$0]);
|
||||||
|
break;
|
||||||
|
case 32: $$[$0-1].push($$[$0]); this.$ = $$[$0-1];
|
||||||
|
break;
|
||||||
|
case 33: this.$ = [$$[$0]];
|
||||||
|
break;
|
||||||
|
case 34: this.$ = [$$[$0-2], $$[$0]];
|
||||||
|
break;
|
||||||
|
case 35: this.$ = [$$[$0-2], new yy.StringNode($$[$0])];
|
||||||
|
break;
|
||||||
|
case 36: this.$ = [$$[$0-2], new yy.IntegerNode($$[$0])];
|
||||||
|
break;
|
||||||
|
case 37: this.$ = [$$[$0-2], new yy.BooleanNode($$[$0])];
|
||||||
|
break;
|
||||||
|
case 38: this.$ = new yy.IdNode($$[$0]);
|
||||||
|
break;
|
||||||
|
case 39: $$[$0-2].push($$[$0]); this.$ = $$[$0-2];
|
||||||
|
break;
|
||||||
|
case 40: this.$ = [$$[$0]];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
table: [{3:1,4:2,5:[2,4],6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],24:[1,15]},{1:[3]},{5:[1,16]},{5:[2,3],7:17,8:18,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,19],20:[2,3],22:[1,13],23:[1,14],24:[1,15]},{5:[2,5],14:[2,5],15:[2,5],16:[2,5],19:[2,5],20:[2,5],22:[2,5],23:[2,5],24:[2,5]},{4:20,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],24:[1,15]},{4:21,6:3,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,4],22:[1,13],23:[1,14],24:[1,15]},{5:[2,9],14:[2,9],15:[2,9],16:[2,9],19:[2,9],20:[2,9],22:[2,9],23:[2,9],24:[2,9]},{5:[2,10],14:[2,10],15:[2,10],16:[2,10],19:[2,10],20:[2,10],22:[2,10],23:[2,10],24:[2,10]},{5:[2,11],14:[2,11],15:[2,11],16:[2,11],19:[2,11],20:[2,11],22:[2,11],23:[2,11],24:[2,11]},{5:[2,12],14:[2,12],15:[2,12],16:[2,12],19:[2,12],20:[2,12],22:[2,12],23:[2,12],24:[2,12]},{17:22,21:23,33:[1,25],35:24},{17:26,21:23,33:[1,25],35:24},{17:27,21:23,33:[1,25],35:24},{17:28,21:23,33:[1,25],35:24},{21:29,33:[1,25],35:24},{1:[2,1]},{6:30,8:4,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],22:[1,13],23:[1,14],24:[1,15]},{5:[2,6],14:[2,6],15:[2,6],16:[2,6],19:[2,6],20:[2,6],22:[2,6],23:[2,6],24:[2,6]},{17:22,18:[1,31],21:23,33:[1,25],35:24},{10:32,20:[1,33]},{10:34,20:[1,33]},{18:[1,35]},{18:[2,24],21:40,25:36,26:37,27:38,28:[1,41],29:[1,42],30:[1,43],31:39,32:44,33:[1,45],35:24},{18:[2,38],28:[2,38],29:[2,38],30:[2,38],33:[2,38],36:[1,46]},{18:[2,40],28:[2,40],29:[2,40],30:[2,40],33:[2,40],36:[2,40]},{18:[1,47]},{18:[1,48]},{18:[1,49]},{18:[1,50],21:51,33:[1,25],35:24},{5:[2,2],8:18,9:5,11:6,12:7,13:8,14:[1,9],15:[1,10],16:[1,12],19:[1,11],20:[2,2],22:[1,13],23:[1,14],24:[1,15]},{14:[2,20],15:[2,20],16:[2,20],19:[2,20],22:[2,20],23:[2,20],24:[2,20]},{5:[2,7],14:[2,7],15:[2,7],16:[2,7],19:[2,7],20:[2,7],22:[2,7],23:[2,7],24:[2,7]},{21:52,33:[1,25],35:24},{5:[2,8],14:[2,8],15:[2,8],16:[2,8],19:[2,8],20:[2,8],22:[2,8],23:[2,8],24:[2,8]},{14:[2,14],15:[2,14],16:[2,14],19:[2,14],20:[2,14],22:[2,14],23:[2,14],24:[2,14]},{18:[2,22],21:40,26:53,27:54,28:[1,41],29:[1,42],30:[1,43],31:39,32:44,33:[1,45],35:24},{18:[2,23]},{18:[2,26],28:[2,26],29:[2,26],30:[2,26],33:[2,26]},{18:[2,31],32:55,33:[1,56]},{18:[2,27],28:[2,27],29:[2,27],30:[2,27],33:[2,27]},{18:[2,28],28:[2,28],29:[2,28],30:[2,28],33:[2,28]},{18:[2,29],28:[2,29],29:[2,29],30:[2,29],33:[2,29]},{18:[2,30],28:[2,30],29:[2,30],30:[2,30],33:[2,30]},{18:[2,33],33:[2,33]},{18:[2,40],28:[2,40],29:[2,40],30:[2,40],33:[2,40],34:[1,57],36:[2,40]},{33:[1,58]},{14:[2,13],15:[2,13],16:[2,13],19:[2,13],20:[2,13],22:[2,13],23:[2,13],24:[2,13]},{5:[2,16],14:[2,16],15:[2,16],16:[2,16],19:[2,16],20:[2,16],22:[2,16],23:[2,16],24:[2,16]},{5:[2,17],14:[2,17],15:[2,17],16:[2,17],19:[2,17],20:[2,17],22:[2,17],23:[2,17],24:[2,17]},{5:[2,18],14:[2,18],15:[2,18],16:[2,18],19:[2,18],20:[2,18],22:[2,18],23:[2,18],24:[2,18]},{18:[1,59]},{18:[1,60]},{18:[2,21]},{18:[2,25],28:[2,25],29:[2,25],30:[2,25],33:[2,25]},{18:[2,32],33:[2,32]},{34:[1,57]},{21:61,28:[1,62],29:[1,63],30:[1,64],33:[1,25],35:24},{18:[2,39],28:[2,39],29:[2,39],30:[2,39],33:[2,39],36:[2,39]},{5:[2,19],14:[2,19],15:[2,19],16:[2,19],19:[2,19],20:[2,19],22:[2,19],23:[2,19],24:[2,19]},{5:[2,15],14:[2,15],15:[2,15],16:[2,15],19:[2,15],20:[2,15],22:[2,15],23:[2,15],24:[2,15]},{18:[2,34],33:[2,34]},{18:[2,35],33:[2,35]},{18:[2,36],33:[2,36]},{18:[2,37],33:[2,37]}],
|
||||||
|
defaultActions: {16:[2,1],37:[2,23],53:[2,21]},
|
||||||
|
parseError: function parseError(str, hash) {
|
||||||
|
throw new Error(str);
|
||||||
|
},
|
||||||
|
parse: function parse(input) {
|
||||||
|
var self = this,
|
||||||
|
stack = [0],
|
||||||
|
vstack = [null], // semantic value stack
|
||||||
|
lstack = [], // location stack
|
||||||
|
table = this.table,
|
||||||
|
yytext = '',
|
||||||
|
yylineno = 0,
|
||||||
|
yyleng = 0,
|
||||||
|
recovering = 0,
|
||||||
|
TERROR = 2,
|
||||||
|
EOF = 1;
|
||||||
|
|
||||||
|
//this.reductionCount = this.shiftCount = 0;
|
||||||
|
|
||||||
|
this.lexer.setInput(input);
|
||||||
|
this.lexer.yy = this.yy;
|
||||||
|
this.yy.lexer = this.lexer;
|
||||||
|
if (typeof this.lexer.yylloc == 'undefined')
|
||||||
|
this.lexer.yylloc = {};
|
||||||
|
var yyloc = this.lexer.yylloc;
|
||||||
|
lstack.push(yyloc);
|
||||||
|
|
||||||
|
if (typeof this.yy.parseError === 'function')
|
||||||
|
this.parseError = this.yy.parseError;
|
||||||
|
|
||||||
|
function popStack (n) {
|
||||||
|
stack.length = stack.length - 2*n;
|
||||||
|
vstack.length = vstack.length - n;
|
||||||
|
lstack.length = lstack.length - n;
|
||||||
|
}
|
||||||
|
|
||||||
|
function lex() {
|
||||||
|
var token;
|
||||||
|
token = self.lexer.lex() || 1; // $end = 1
|
||||||
|
// if token isn't its numeric value, convert
|
||||||
|
if (typeof token !== 'number') {
|
||||||
|
token = self.symbols_[token] || token;
|
||||||
|
}
|
||||||
|
return token;
|
||||||
|
};
|
||||||
|
|
||||||
|
var symbol, preErrorSymbol, state, action, a, r, yyval={},p,len,newState, expected;
|
||||||
|
while (true) {
|
||||||
|
// retreive state number from top of stack
|
||||||
|
state = stack[stack.length-1];
|
||||||
|
|
||||||
|
// use default actions if available
|
||||||
|
if (this.defaultActions[state]) {
|
||||||
|
action = this.defaultActions[state];
|
||||||
|
} else {
|
||||||
|
if (symbol == null)
|
||||||
|
symbol = lex();
|
||||||
|
// read action for current state and first input
|
||||||
|
action = table[state] && table[state][symbol];
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle parse error
|
||||||
|
if (typeof action === 'undefined' || !action.length || !action[0]) {
|
||||||
|
|
||||||
|
if (!recovering) {
|
||||||
|
// Report error
|
||||||
|
expected = [];
|
||||||
|
for (p in table[state]) if (this.terminals_[p] && p > 2) {
|
||||||
|
expected.push("'"+this.terminals_[p]+"'");
|
||||||
|
}
|
||||||
|
var errStr = '';
|
||||||
|
if (this.lexer.showPosition) {
|
||||||
|
errStr = 'Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+'\nExpecting '+expected.join(', ');
|
||||||
|
} else {
|
||||||
|
errStr = 'Parse error on line '+(yylineno+1)+": Unexpected " +
|
||||||
|
(symbol == 1 /*EOF*/ ? "end of input" :
|
||||||
|
("'"+(this.terminals_[symbol] || symbol)+"'"));
|
||||||
|
}
|
||||||
|
this.parseError(errStr,
|
||||||
|
{text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
|
||||||
|
}
|
||||||
|
|
||||||
|
// just recovered from another error
|
||||||
|
if (recovering == 3) {
|
||||||
|
if (symbol == EOF) {
|
||||||
|
throw new Error(errStr || 'Parsing halted.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// discard current lookahead and grab another
|
||||||
|
yyleng = this.lexer.yyleng;
|
||||||
|
yytext = this.lexer.yytext;
|
||||||
|
yylineno = this.lexer.yylineno;
|
||||||
|
yyloc = this.lexer.yylloc;
|
||||||
|
symbol = lex();
|
||||||
|
}
|
||||||
|
|
||||||
|
// try to recover from error
|
||||||
|
while (1) {
|
||||||
|
// check for error recovery rule in this state
|
||||||
|
if ((TERROR.toString()) in table[state]) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (state == 0) {
|
||||||
|
throw new Error(errStr || 'Parsing halted.');
|
||||||
|
}
|
||||||
|
popStack(1);
|
||||||
|
state = stack[stack.length-1];
|
||||||
|
}
|
||||||
|
|
||||||
|
preErrorSymbol = symbol; // save the lookahead token
|
||||||
|
symbol = TERROR; // insert generic error symbol as new lookahead
|
||||||
|
state = stack[stack.length-1];
|
||||||
|
action = table[state] && table[state][TERROR];
|
||||||
|
recovering = 3; // allow 3 real symbols to be shifted before reporting a new error
|
||||||
|
}
|
||||||
|
|
||||||
|
// this shouldn't happen, unless resolve defaults are off
|
||||||
|
if (action[0] instanceof Array && action.length > 1) {
|
||||||
|
throw new Error('Parse Error: multiple actions possible at state: '+state+', token: '+symbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (action[0]) {
|
||||||
|
|
||||||
|
case 1: // shift
|
||||||
|
//this.shiftCount++;
|
||||||
|
|
||||||
|
stack.push(symbol);
|
||||||
|
vstack.push(this.lexer.yytext);
|
||||||
|
lstack.push(this.lexer.yylloc);
|
||||||
|
stack.push(action[1]); // push state
|
||||||
|
symbol = null;
|
||||||
|
if (!preErrorSymbol) { // normal execution/no error
|
||||||
|
yyleng = this.lexer.yyleng;
|
||||||
|
yytext = this.lexer.yytext;
|
||||||
|
yylineno = this.lexer.yylineno;
|
||||||
|
yyloc = this.lexer.yylloc;
|
||||||
|
if (recovering > 0)
|
||||||
|
recovering--;
|
||||||
|
} else { // error just occurred, resume old lookahead f/ before error
|
||||||
|
symbol = preErrorSymbol;
|
||||||
|
preErrorSymbol = null;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 2: // reduce
|
||||||
|
//this.reductionCount++;
|
||||||
|
|
||||||
|
len = this.productions_[action[1]][1];
|
||||||
|
|
||||||
|
// perform semantic action
|
||||||
|
yyval.$ = vstack[vstack.length-len]; // default to $$ = $1
|
||||||
|
// default location, uses first token for firsts, last for lasts
|
||||||
|
yyval._$ = {
|
||||||
|
first_line: lstack[lstack.length-(len||1)].first_line,
|
||||||
|
last_line: lstack[lstack.length-1].last_line,
|
||||||
|
first_column: lstack[lstack.length-(len||1)].first_column,
|
||||||
|
last_column: lstack[lstack.length-1].last_column
|
||||||
|
};
|
||||||
|
r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
|
||||||
|
|
||||||
|
if (typeof r !== 'undefined') {
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
// pop off stack
|
||||||
|
if (len) {
|
||||||
|
stack = stack.slice(0,-1*len*2);
|
||||||
|
vstack = vstack.slice(0, -1*len);
|
||||||
|
lstack = lstack.slice(0, -1*len);
|
||||||
|
}
|
||||||
|
|
||||||
|
stack.push(this.productions_[action[1]][0]); // push nonterminal (reduce)
|
||||||
|
vstack.push(yyval.$);
|
||||||
|
lstack.push(yyval._$);
|
||||||
|
// goto new state = table[STATE][NONTERMINAL]
|
||||||
|
newState = table[stack[stack.length-2]][stack[stack.length-1]];
|
||||||
|
stack.push(newState);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 3: // accept
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}};/* Jison generated lexer */
|
||||||
|
var lexer = (function(){var lexer = ({EOF:1,
|
||||||
|
parseError:function parseError(str, hash) {
|
||||||
|
if (this.yy.parseError) {
|
||||||
|
this.yy.parseError(str, hash);
|
||||||
|
} else {
|
||||||
|
throw new Error(str);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setInput:function (input) {
|
||||||
|
this._input = input;
|
||||||
|
this._more = this._less = this.done = false;
|
||||||
|
this.yylineno = this.yyleng = 0;
|
||||||
|
this.yytext = this.matched = this.match = '';
|
||||||
|
this.conditionStack = ['INITIAL'];
|
||||||
|
this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0};
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
input:function () {
|
||||||
|
var ch = this._input[0];
|
||||||
|
this.yytext+=ch;
|
||||||
|
this.yyleng++;
|
||||||
|
this.match+=ch;
|
||||||
|
this.matched+=ch;
|
||||||
|
var lines = ch.match(/\n/);
|
||||||
|
if (lines) this.yylineno++;
|
||||||
|
this._input = this._input.slice(1);
|
||||||
|
return ch;
|
||||||
|
},
|
||||||
|
unput:function (ch) {
|
||||||
|
this._input = ch + this._input;
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
more:function () {
|
||||||
|
this._more = true;
|
||||||
|
return this;
|
||||||
|
},
|
||||||
|
pastInput:function () {
|
||||||
|
var past = this.matched.substr(0, this.matched.length - this.match.length);
|
||||||
|
return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
|
||||||
|
},
|
||||||
|
upcomingInput:function () {
|
||||||
|
var next = this.match;
|
||||||
|
if (next.length < 20) {
|
||||||
|
next += this._input.substr(0, 20-next.length);
|
||||||
|
}
|
||||||
|
return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, "");
|
||||||
|
},
|
||||||
|
showPosition:function () {
|
||||||
|
var pre = this.pastInput();
|
||||||
|
var c = new Array(pre.length + 1).join("-");
|
||||||
|
return pre + this.upcomingInput() + "\n" + c+"^";
|
||||||
|
},
|
||||||
|
next:function () {
|
||||||
|
if (this.done) {
|
||||||
|
return this.EOF;
|
||||||
|
}
|
||||||
|
if (!this._input) this.done = true;
|
||||||
|
|
||||||
|
var token,
|
||||||
|
match,
|
||||||
|
col,
|
||||||
|
lines;
|
||||||
|
if (!this._more) {
|
||||||
|
this.yytext = '';
|
||||||
|
this.match = '';
|
||||||
|
}
|
||||||
|
var rules = this._currentRules();
|
||||||
|
for (var i=0;i < rules.length; i++) {
|
||||||
|
match = this._input.match(this.rules[rules[i]]);
|
||||||
|
if (match) {
|
||||||
|
lines = match[0].match(/\n.*/g);
|
||||||
|
if (lines) this.yylineno += lines.length;
|
||||||
|
this.yylloc = {first_line: this.yylloc.last_line,
|
||||||
|
last_line: this.yylineno+1,
|
||||||
|
first_column: this.yylloc.last_column,
|
||||||
|
last_column: lines ? lines[lines.length-1].length-1 : this.yylloc.last_column + match[0].length}
|
||||||
|
this.yytext += match[0];
|
||||||
|
this.match += match[0];
|
||||||
|
this.matches = match;
|
||||||
|
this.yyleng = this.yytext.length;
|
||||||
|
this._more = false;
|
||||||
|
this._input = this._input.slice(match[0].length);
|
||||||
|
this.matched += match[0];
|
||||||
|
token = this.performAction.call(this, this.yy, this, rules[i],this.conditionStack[this.conditionStack.length-1]);
|
||||||
|
if (token) return token;
|
||||||
|
else return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this._input === "") {
|
||||||
|
return this.EOF;
|
||||||
|
} else {
|
||||||
|
this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
|
||||||
|
{text: "", token: null, line: this.yylineno});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
lex:function lex() {
|
||||||
|
var r = this.next();
|
||||||
|
if (typeof r !== 'undefined') {
|
||||||
|
return r;
|
||||||
|
} else {
|
||||||
|
return this.lex();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
begin:function begin(condition) {
|
||||||
|
this.conditionStack.push(condition);
|
||||||
|
},
|
||||||
|
popState:function popState() {
|
||||||
|
return this.conditionStack.pop();
|
||||||
|
},
|
||||||
|
_currentRules:function _currentRules() {
|
||||||
|
return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;
|
||||||
|
}});
|
||||||
|
lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
|
||||||
|
|
||||||
|
var YYSTATE=YY_START
|
||||||
|
switch($avoiding_name_collisions) {
|
||||||
|
case 0:
|
||||||
|
if(yy_.yytext.slice(-1) !== "\\") this.begin("mu");
|
||||||
|
if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1), this.begin("emu");
|
||||||
|
if(yy_.yytext) return 14;
|
||||||
|
|
||||||
|
break;
|
||||||
|
case 1: return 14;
|
||||||
|
break;
|
||||||
|
case 2: this.popState(); return 14;
|
||||||
|
break;
|
||||||
|
case 3: return 24;
|
||||||
|
break;
|
||||||
|
case 4: return 16;
|
||||||
|
break;
|
||||||
|
case 5: return 20;
|
||||||
|
break;
|
||||||
|
case 6: return 19;
|
||||||
|
break;
|
||||||
|
case 7: return 19;
|
||||||
|
break;
|
||||||
|
case 8: return 23;
|
||||||
|
break;
|
||||||
|
case 9: return 23;
|
||||||
|
break;
|
||||||
|
case 10: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.popState(); return 15;
|
||||||
|
break;
|
||||||
|
case 11: return 22;
|
||||||
|
break;
|
||||||
|
case 12: return 34;
|
||||||
|
break;
|
||||||
|
case 13: return 33;
|
||||||
|
break;
|
||||||
|
case 14: return 33;
|
||||||
|
break;
|
||||||
|
case 15: return 36;
|
||||||
|
break;
|
||||||
|
case 16: /*ignore whitespace*/
|
||||||
|
break;
|
||||||
|
case 17: this.popState(); return 18;
|
||||||
|
break;
|
||||||
|
case 18: this.popState(); return 18;
|
||||||
|
break;
|
||||||
|
case 19: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 28;
|
||||||
|
break;
|
||||||
|
case 20: return 30;
|
||||||
|
break;
|
||||||
|
case 21: return 30;
|
||||||
|
break;
|
||||||
|
case 22: return 29;
|
||||||
|
break;
|
||||||
|
case 23: return 33;
|
||||||
|
break;
|
||||||
|
case 24: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 33;
|
||||||
|
break;
|
||||||
|
case 25: return 'INVALID';
|
||||||
|
break;
|
||||||
|
case 26: return 5;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
lexer.rules = [/^[^\x00]*?(?=(\{\{))/,/^[^\x00]+/,/^[^\x00]{2,}?(?=(\{\{))/,/^\{\{>/,/^\{\{#/,/^\{\{\//,/^\{\{\^/,/^\{\{\s*else\b/,/^\{\{\{/,/^\{\{&/,/^\{\{![\s\S]*?\}\}/,/^\{\{/,/^=/,/^\.(?=[} ])/,/^\.\./,/^[\/.]/,/^\s+/,/^\}\}\}/,/^\}\}/,/^"(\\["]|[^"])*"/,/^true(?=[}\s])/,/^false(?=[}\s])/,/^[0-9]+(?=[}\s])/,/^[a-zA-Z0-9_$-]+(?=[=}\s\/.])/,/^\[[^\]]*\]/,/^./,/^$/];
|
||||||
|
lexer.conditions = {"mu":{"rules":[3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26],"inclusive":false},"emu":{"rules":[2],"inclusive":false},"INITIAL":{"rules":[0,1,26],"inclusive":true}};return lexer;})()
|
||||||
|
parser.lexer = lexer;
|
||||||
|
return parser;
|
||||||
|
})();
|
||||||
|
if (typeof require !== 'undefined' && typeof exports !== 'undefined') {
|
||||||
|
exports.parser = handlebars;
|
||||||
|
exports.parse = function () { return handlebars.parse.apply(handlebars, arguments); }
|
||||||
|
exports.main = function commonjsMain(args) {
|
||||||
|
if (!args[1])
|
||||||
|
throw new Error('Usage: '+args[0]+' FILE');
|
||||||
|
if (typeof process !== 'undefined') {
|
||||||
|
var source = require('fs').readFileSync(require('path').join(process.cwd(), args[1]), "utf8");
|
||||||
|
} else {
|
||||||
|
var cwd = require("file").path(require("file").cwd());
|
||||||
|
var source = cwd.join(args[1]).read({charset: "utf-8"});
|
||||||
|
}
|
||||||
|
return exports.parser.parse(source);
|
||||||
|
}
|
||||||
|
if (typeof module !== 'undefined' && require.main === module) {
|
||||||
|
exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args);
|
||||||
|
}
|
||||||
|
};
|
||||||
137
node_modules/handlebars/lib/handlebars/compiler/printer.js
generated
vendored
Normal file
137
node_modules/handlebars/lib/handlebars/compiler/printer.js
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
|||||||
|
var Handlebars = require("./base");
|
||||||
|
|
||||||
|
// BEGIN(BROWSER)
|
||||||
|
Handlebars.PrintVisitor = function() { this.padding = 0; };
|
||||||
|
Handlebars.PrintVisitor.prototype = new Handlebars.Visitor();
|
||||||
|
|
||||||
|
Handlebars.PrintVisitor.prototype.pad = function(string, newline) {
|
||||||
|
var out = "";
|
||||||
|
|
||||||
|
for(var i=0,l=this.padding; i<l; i++) {
|
||||||
|
out = out + " ";
|
||||||
|
}
|
||||||
|
|
||||||
|
out = out + string;
|
||||||
|
|
||||||
|
if(newline !== false) { out = out + "\n"; }
|
||||||
|
return out;
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.PrintVisitor.prototype.program = function(program) {
|
||||||
|
var out = this.pad("PROGRAM:"),
|
||||||
|
statements = program.statements,
|
||||||
|
inverse = program.inverse,
|
||||||
|
i, l;
|
||||||
|
|
||||||
|
this.padding++;
|
||||||
|
|
||||||
|
for(i=0, l=statements.length; i<l; i++) {
|
||||||
|
out = out + this.accept(statements[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.padding--;
|
||||||
|
|
||||||
|
if(inverse) {
|
||||||
|
out = out + this.pad("{{^}}");
|
||||||
|
|
||||||
|
this.padding++;
|
||||||
|
|
||||||
|
for(i=0, l=inverse.statements.length; i<l; i++) {
|
||||||
|
out = out + this.accept(inverse.statements[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.padding--;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.PrintVisitor.prototype.block = function(block) {
|
||||||
|
var out = "";
|
||||||
|
|
||||||
|
out = out + this.pad("BLOCK:");
|
||||||
|
this.padding++;
|
||||||
|
out = out + this.accept(block.mustache);
|
||||||
|
out = out + this.accept(block.program);
|
||||||
|
this.padding--;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.PrintVisitor.prototype.inverse = function(block) {
|
||||||
|
var out = "";
|
||||||
|
|
||||||
|
out = out + this.pad("INVERSE:");
|
||||||
|
this.padding++;
|
||||||
|
out = out + this.accept(block.mustache);
|
||||||
|
out = out + this.accept(block.program);
|
||||||
|
this.padding--;
|
||||||
|
|
||||||
|
return out;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Handlebars.PrintVisitor.prototype.mustache = function(mustache) {
|
||||||
|
var params = mustache.params, paramStrings = [], hash;
|
||||||
|
|
||||||
|
for(var i=0, l=params.length; i<l; i++) {
|
||||||
|
paramStrings.push(this.accept(params[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
params = "[" + paramStrings.join(", ") + "]";
|
||||||
|
|
||||||
|
hash = mustache.hash ? " " + this.accept(mustache.hash) : "";
|
||||||
|
|
||||||
|
return this.pad("{{ " + this.accept(mustache.id) + " " + params + hash + " }}");
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.PrintVisitor.prototype.partial = function(partial) {
|
||||||
|
var content = this.accept(partial.id);
|
||||||
|
if(partial.context) { content = content + " " + this.accept(partial.context); }
|
||||||
|
return this.pad("{{> " + content + " }}");
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.PrintVisitor.prototype.hash = function(hash) {
|
||||||
|
var pairs = hash.pairs;
|
||||||
|
var joinedPairs = [], left, right;
|
||||||
|
|
||||||
|
for(var i=0, l=pairs.length; i<l; i++) {
|
||||||
|
left = pairs[i][0];
|
||||||
|
right = this.accept(pairs[i][1]);
|
||||||
|
joinedPairs.push( left + "=" + right );
|
||||||
|
}
|
||||||
|
|
||||||
|
return "HASH{" + joinedPairs.join(", ") + "}";
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.PrintVisitor.prototype.STRING = function(string) {
|
||||||
|
return '"' + string.string + '"';
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.PrintVisitor.prototype.INTEGER = function(integer) {
|
||||||
|
return "INTEGER{" + integer.integer + "}";
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.PrintVisitor.prototype.BOOLEAN = function(bool) {
|
||||||
|
return "BOOLEAN{" + bool.bool + "}";
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.PrintVisitor.prototype.ID = function(id) {
|
||||||
|
var path = id.parts.join("/");
|
||||||
|
if(id.parts.length > 1) {
|
||||||
|
return "PATH:" + path;
|
||||||
|
} else {
|
||||||
|
return "ID:" + path;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.PrintVisitor.prototype.content = function(content) {
|
||||||
|
return this.pad("CONTENT[ '" + content.string + "' ]");
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.PrintVisitor.prototype.comment = function(comment) {
|
||||||
|
return this.pad("{{! '" + comment.comment + "' }}");
|
||||||
|
};
|
||||||
|
// END(BROWSER)
|
||||||
|
|
||||||
|
exports.PrintVisitor = Handlebars.PrintVisitor;
|
||||||
13
node_modules/handlebars/lib/handlebars/compiler/visitor.js
generated
vendored
Normal file
13
node_modules/handlebars/lib/handlebars/compiler/visitor.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
var Handlebars = require("./base");
|
||||||
|
|
||||||
|
// BEGIN(BROWSER)
|
||||||
|
|
||||||
|
Handlebars.Visitor = function() {};
|
||||||
|
|
||||||
|
Handlebars.Visitor.prototype = {
|
||||||
|
accept: function(object) {
|
||||||
|
return this[object.type](object);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
// END(BROWSER)
|
||||||
|
|
||||||
68
node_modules/handlebars/lib/handlebars/runtime.js
generated
vendored
Normal file
68
node_modules/handlebars/lib/handlebars/runtime.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
var Handlebars = require("./base");
|
||||||
|
|
||||||
|
// BEGIN(BROWSER)
|
||||||
|
Handlebars.VM = {
|
||||||
|
template: function(templateSpec) {
|
||||||
|
// Just add water
|
||||||
|
var container = {
|
||||||
|
escapeExpression: Handlebars.Utils.escapeExpression,
|
||||||
|
invokePartial: Handlebars.VM.invokePartial,
|
||||||
|
programs: [],
|
||||||
|
program: function(i, fn, data) {
|
||||||
|
var programWrapper = this.programs[i];
|
||||||
|
if(data) {
|
||||||
|
return Handlebars.VM.program(fn, data);
|
||||||
|
} else if(programWrapper) {
|
||||||
|
return programWrapper;
|
||||||
|
} else {
|
||||||
|
programWrapper = this.programs[i] = Handlebars.VM.program(fn);
|
||||||
|
return programWrapper;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
programWithDepth: Handlebars.VM.programWithDepth,
|
||||||
|
noop: Handlebars.VM.noop
|
||||||
|
};
|
||||||
|
|
||||||
|
return function(context, options) {
|
||||||
|
options = options || {};
|
||||||
|
return templateSpec.call(container, Handlebars, context, options.helpers, options.partials, options.data);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
programWithDepth: function(fn, data, $depth) {
|
||||||
|
var args = Array.prototype.slice.call(arguments, 2);
|
||||||
|
|
||||||
|
return function(context, options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
return fn.apply(this, [context, options.data || data].concat(args));
|
||||||
|
};
|
||||||
|
},
|
||||||
|
program: function(fn, data) {
|
||||||
|
return function(context, options) {
|
||||||
|
options = options || {};
|
||||||
|
|
||||||
|
return fn(context, options.data || data);
|
||||||
|
};
|
||||||
|
},
|
||||||
|
noop: function() { return ""; },
|
||||||
|
invokePartial: function(partial, name, context, helpers, partials, data) {
|
||||||
|
var options = { helpers: helpers, partials: partials, data: data };
|
||||||
|
|
||||||
|
if(partial === undefined) {
|
||||||
|
throw new Handlebars.Exception("The partial " + name + " could not be found");
|
||||||
|
} else if(partial instanceof Function) {
|
||||||
|
return partial(context, options);
|
||||||
|
} else if (!Handlebars.compile) {
|
||||||
|
throw new Handlebars.Exception("The partial " + name + " could not be compiled when running in runtime-only mode");
|
||||||
|
} else {
|
||||||
|
partials[name] = Handlebars.compile(partial);
|
||||||
|
return partials[name](context, options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.template = Handlebars.VM.template;
|
||||||
|
|
||||||
|
// END(BROWSER)
|
||||||
|
|
||||||
68
node_modules/handlebars/lib/handlebars/utils.js
generated
vendored
Normal file
68
node_modules/handlebars/lib/handlebars/utils.js
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
var Handlebars = require("./base");
|
||||||
|
|
||||||
|
// BEGIN(BROWSER)
|
||||||
|
Handlebars.Exception = function(message) {
|
||||||
|
var tmp = Error.prototype.constructor.apply(this, arguments);
|
||||||
|
|
||||||
|
for (var p in tmp) {
|
||||||
|
if (tmp.hasOwnProperty(p)) { this[p] = tmp[p]; }
|
||||||
|
}
|
||||||
|
|
||||||
|
this.message = tmp.message;
|
||||||
|
};
|
||||||
|
Handlebars.Exception.prototype = new Error();
|
||||||
|
|
||||||
|
// Build out our basic SafeString type
|
||||||
|
Handlebars.SafeString = function(string) {
|
||||||
|
this.string = string;
|
||||||
|
};
|
||||||
|
Handlebars.SafeString.prototype.toString = function() {
|
||||||
|
return this.string.toString();
|
||||||
|
};
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
var escape = {
|
||||||
|
"<": "<",
|
||||||
|
">": ">",
|
||||||
|
'"': """,
|
||||||
|
"'": "'",
|
||||||
|
"`": "`"
|
||||||
|
};
|
||||||
|
|
||||||
|
var badChars = /&(?!\w+;)|[<>"'`]/g;
|
||||||
|
var possible = /[&<>"'`]/;
|
||||||
|
|
||||||
|
var escapeChar = function(chr) {
|
||||||
|
return escape[chr] || "&";
|
||||||
|
};
|
||||||
|
|
||||||
|
Handlebars.Utils = {
|
||||||
|
escapeExpression: function(string) {
|
||||||
|
// don't escape SafeStrings, since they're already safe
|
||||||
|
if (string instanceof Handlebars.SafeString) {
|
||||||
|
return string.toString();
|
||||||
|
} else if (string == null || string === false) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!possible.test(string)) { return string; }
|
||||||
|
return string.replace(badChars, escapeChar);
|
||||||
|
},
|
||||||
|
|
||||||
|
isEmpty: function(value) {
|
||||||
|
if (typeof value === "undefined") {
|
||||||
|
return true;
|
||||||
|
} else if (value === null) {
|
||||||
|
return true;
|
||||||
|
} else if (value === false) {
|
||||||
|
return true;
|
||||||
|
} else if(Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})();
|
||||||
|
// END(BROWSER)
|
||||||
|
|
||||||
332
node_modules/handlebars/node_modules/.bin/uglifyjs
generated
vendored
Executable file
332
node_modules/handlebars/node_modules/.bin/uglifyjs
generated
vendored
Executable file
@@ -0,0 +1,332 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
// -*- js -*-
|
||||||
|
|
||||||
|
global.sys = require(/^v0\.[012]/.test(process.version) ? "sys" : "util");
|
||||||
|
var fs = require("fs");
|
||||||
|
var uglify = require("uglify-js"), // symlink ~/.node_libraries/uglify-js.js to ../uglify-js.js
|
||||||
|
consolidator = uglify.consolidator,
|
||||||
|
jsp = uglify.parser,
|
||||||
|
pro = uglify.uglify;
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
ast: false,
|
||||||
|
consolidate: false,
|
||||||
|
mangle: true,
|
||||||
|
mangle_toplevel: false,
|
||||||
|
no_mangle_functions: false,
|
||||||
|
squeeze: true,
|
||||||
|
make_seqs: true,
|
||||||
|
dead_code: true,
|
||||||
|
verbose: false,
|
||||||
|
show_copyright: true,
|
||||||
|
out_same_file: false,
|
||||||
|
max_line_length: 32 * 1024,
|
||||||
|
unsafe: false,
|
||||||
|
reserved_names: null,
|
||||||
|
defines: { },
|
||||||
|
lift_vars: false,
|
||||||
|
codegen_options: {
|
||||||
|
ascii_only: false,
|
||||||
|
beautify: false,
|
||||||
|
indent_level: 4,
|
||||||
|
indent_start: 0,
|
||||||
|
quote_keys: false,
|
||||||
|
space_colon: false,
|
||||||
|
inline_script: false
|
||||||
|
},
|
||||||
|
make: false,
|
||||||
|
output: true // stdout
|
||||||
|
};
|
||||||
|
|
||||||
|
var args = jsp.slice(process.argv, 2);
|
||||||
|
var filename;
|
||||||
|
|
||||||
|
out: while (args.length > 0) {
|
||||||
|
var v = args.shift();
|
||||||
|
switch (v) {
|
||||||
|
case "-b":
|
||||||
|
case "--beautify":
|
||||||
|
options.codegen_options.beautify = true;
|
||||||
|
break;
|
||||||
|
case "-c":
|
||||||
|
case "--consolidate-primitive-values":
|
||||||
|
options.consolidate = true;
|
||||||
|
break;
|
||||||
|
case "-i":
|
||||||
|
case "--indent":
|
||||||
|
options.codegen_options.indent_level = args.shift();
|
||||||
|
break;
|
||||||
|
case "-q":
|
||||||
|
case "--quote-keys":
|
||||||
|
options.codegen_options.quote_keys = true;
|
||||||
|
break;
|
||||||
|
case "-mt":
|
||||||
|
case "--mangle-toplevel":
|
||||||
|
options.mangle_toplevel = true;
|
||||||
|
break;
|
||||||
|
case "-nmf":
|
||||||
|
case "--no-mangle-functions":
|
||||||
|
options.no_mangle_functions = true;
|
||||||
|
break;
|
||||||
|
case "--no-mangle":
|
||||||
|
case "-nm":
|
||||||
|
options.mangle = false;
|
||||||
|
break;
|
||||||
|
case "--no-squeeze":
|
||||||
|
case "-ns":
|
||||||
|
options.squeeze = false;
|
||||||
|
break;
|
||||||
|
case "--no-seqs":
|
||||||
|
options.make_seqs = false;
|
||||||
|
break;
|
||||||
|
case "--no-dead-code":
|
||||||
|
options.dead_code = false;
|
||||||
|
break;
|
||||||
|
case "--no-copyright":
|
||||||
|
case "-nc":
|
||||||
|
options.show_copyright = false;
|
||||||
|
break;
|
||||||
|
case "-o":
|
||||||
|
case "--output":
|
||||||
|
options.output = args.shift();
|
||||||
|
break;
|
||||||
|
case "--overwrite":
|
||||||
|
options.out_same_file = true;
|
||||||
|
break;
|
||||||
|
case "-v":
|
||||||
|
case "--verbose":
|
||||||
|
options.verbose = true;
|
||||||
|
break;
|
||||||
|
case "--ast":
|
||||||
|
options.ast = true;
|
||||||
|
break;
|
||||||
|
case "--unsafe":
|
||||||
|
options.unsafe = true;
|
||||||
|
break;
|
||||||
|
case "--max-line-len":
|
||||||
|
options.max_line_length = parseInt(args.shift(), 10);
|
||||||
|
break;
|
||||||
|
case "--reserved-names":
|
||||||
|
options.reserved_names = args.shift().split(",");
|
||||||
|
break;
|
||||||
|
case "--lift-vars":
|
||||||
|
options.lift_vars = true;
|
||||||
|
break;
|
||||||
|
case "-d":
|
||||||
|
case "--define":
|
||||||
|
var defarg = args.shift();
|
||||||
|
try {
|
||||||
|
var defsym = function(sym) {
|
||||||
|
// KEYWORDS_ATOM doesn't include NaN or Infinity - should we check
|
||||||
|
// for them too ?? We don't check reserved words and the like as the
|
||||||
|
// define values are only substituted AFTER parsing
|
||||||
|
if (jsp.KEYWORDS_ATOM.hasOwnProperty(sym)) {
|
||||||
|
throw "Don't define values for inbuilt constant '"+sym+"'";
|
||||||
|
}
|
||||||
|
return sym;
|
||||||
|
},
|
||||||
|
defval = function(v) {
|
||||||
|
if (v.match(/^"(.*)"$/) || v.match(/^'(.*)'$/)) {
|
||||||
|
return [ "string", RegExp.$1 ];
|
||||||
|
}
|
||||||
|
else if (!isNaN(parseFloat(v))) {
|
||||||
|
return [ "num", parseFloat(v) ];
|
||||||
|
}
|
||||||
|
else if (v.match(/^[a-z\$_][a-z\$_0-9]*$/i)) {
|
||||||
|
return [ "name", v ];
|
||||||
|
}
|
||||||
|
else if (!v.match(/"/)) {
|
||||||
|
return [ "string", v ];
|
||||||
|
}
|
||||||
|
else if (!v.match(/'/)) {
|
||||||
|
return [ "string", v ];
|
||||||
|
}
|
||||||
|
throw "Can't understand the specified value: "+v;
|
||||||
|
};
|
||||||
|
if (defarg.match(/^([a-z_\$][a-z_\$0-9]*)(=(.*))?$/i)) {
|
||||||
|
var sym = defsym(RegExp.$1),
|
||||||
|
val = RegExp.$2 ? defval(RegExp.$2.substr(1)) : [ 'name', 'true' ];
|
||||||
|
options.defines[sym] = val;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw "The --define option expects SYMBOL[=value]";
|
||||||
|
}
|
||||||
|
} catch(ex) {
|
||||||
|
sys.print("ERROR: In option --define "+defarg+"\n"+ex+"\n");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "--define-from-module":
|
||||||
|
var defmodarg = args.shift(),
|
||||||
|
defmodule = require(defmodarg),
|
||||||
|
sym,
|
||||||
|
val;
|
||||||
|
for (sym in defmodule) {
|
||||||
|
if (defmodule.hasOwnProperty(sym)) {
|
||||||
|
options.defines[sym] = function(val) {
|
||||||
|
if (typeof val == "string")
|
||||||
|
return [ "string", val ];
|
||||||
|
if (typeof val == "number")
|
||||||
|
return [ "num", val ];
|
||||||
|
if (val === true)
|
||||||
|
return [ 'name', 'true' ];
|
||||||
|
if (val === false)
|
||||||
|
return [ 'name', 'false' ];
|
||||||
|
if (val === null)
|
||||||
|
return [ 'name', 'null' ];
|
||||||
|
if (val === undefined)
|
||||||
|
return [ 'name', 'undefined' ];
|
||||||
|
sys.print("ERROR: In option --define-from-module "+defmodarg+"\n");
|
||||||
|
sys.print("ERROR: Unknown object type for: "+sym+"="+val+"\n");
|
||||||
|
process.exit(1);
|
||||||
|
return null;
|
||||||
|
}(defmodule[sym]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "--ascii":
|
||||||
|
options.codegen_options.ascii_only = true;
|
||||||
|
break;
|
||||||
|
case "--make":
|
||||||
|
options.make = true;
|
||||||
|
break;
|
||||||
|
case "--inline-script":
|
||||||
|
options.codegen_options.inline_script = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
filename = v;
|
||||||
|
break out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.verbose) {
|
||||||
|
pro.set_logger(function(msg){
|
||||||
|
sys.debug(msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
jsp.set_logger(function(msg){
|
||||||
|
sys.debug(msg);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (options.make) {
|
||||||
|
options.out_same_file = false; // doesn't make sense in this case
|
||||||
|
var makefile = JSON.parse(fs.readFileSync(filename || "Makefile.uglify.js").toString());
|
||||||
|
output(makefile.files.map(function(file){
|
||||||
|
var code = fs.readFileSync(file.name);
|
||||||
|
if (file.module) {
|
||||||
|
code = "!function(exports, global){global = this;\n" + code + "\n;this." + file.module + " = exports;}({})";
|
||||||
|
}
|
||||||
|
else if (file.hide) {
|
||||||
|
code = "(function(){" + code + "}());";
|
||||||
|
}
|
||||||
|
return squeeze_it(code);
|
||||||
|
}).join("\n"));
|
||||||
|
}
|
||||||
|
else if (filename) {
|
||||||
|
fs.readFile(filename, "utf8", function(err, text){
|
||||||
|
if (err) throw err;
|
||||||
|
output(squeeze_it(text));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var stdin = process.openStdin();
|
||||||
|
stdin.setEncoding("utf8");
|
||||||
|
var text = "";
|
||||||
|
stdin.on("data", function(chunk){
|
||||||
|
text += chunk;
|
||||||
|
});
|
||||||
|
stdin.on("end", function() {
|
||||||
|
output(squeeze_it(text));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function output(text) {
|
||||||
|
var out;
|
||||||
|
if (options.out_same_file && filename)
|
||||||
|
options.output = filename;
|
||||||
|
if (options.output === true) {
|
||||||
|
out = process.stdout;
|
||||||
|
} else {
|
||||||
|
out = fs.createWriteStream(options.output, {
|
||||||
|
flags: "w",
|
||||||
|
encoding: "utf8",
|
||||||
|
mode: 0644
|
||||||
|
});
|
||||||
|
}
|
||||||
|
out.write(text.replace(/;*$/, ";"));
|
||||||
|
if (options.output !== true) {
|
||||||
|
out.end();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// --------- main ends here.
|
||||||
|
|
||||||
|
function show_copyright(comments) {
|
||||||
|
var ret = "";
|
||||||
|
for (var i = 0; i < comments.length; ++i) {
|
||||||
|
var c = comments[i];
|
||||||
|
if (c.type == "comment1") {
|
||||||
|
ret += "//" + c.value + "\n";
|
||||||
|
} else {
|
||||||
|
ret += "/*" + c.value + "*/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
function squeeze_it(code) {
|
||||||
|
var result = "";
|
||||||
|
if (options.show_copyright) {
|
||||||
|
var tok = jsp.tokenizer(code), c;
|
||||||
|
c = tok();
|
||||||
|
result += show_copyright(c.comments_before);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
var ast = time_it("parse", function(){ return jsp.parse(code); });
|
||||||
|
if (options.consolidate) ast = time_it("consolidate", function(){
|
||||||
|
return consolidator.ast_consolidate(ast);
|
||||||
|
});
|
||||||
|
if (options.lift_vars) {
|
||||||
|
ast = time_it("lift", function(){ return pro.ast_lift_variables(ast); });
|
||||||
|
}
|
||||||
|
if (options.mangle) ast = time_it("mangle", function(){
|
||||||
|
return pro.ast_mangle(ast, {
|
||||||
|
toplevel : options.mangle_toplevel,
|
||||||
|
defines : options.defines,
|
||||||
|
except : options.reserved_names,
|
||||||
|
no_functions : options.no_mangle_functions
|
||||||
|
});
|
||||||
|
});
|
||||||
|
if (options.squeeze) ast = time_it("squeeze", function(){
|
||||||
|
ast = pro.ast_squeeze(ast, {
|
||||||
|
make_seqs : options.make_seqs,
|
||||||
|
dead_code : options.dead_code,
|
||||||
|
keep_comps : !options.unsafe
|
||||||
|
});
|
||||||
|
if (options.unsafe)
|
||||||
|
ast = pro.ast_squeeze_more(ast);
|
||||||
|
return ast;
|
||||||
|
});
|
||||||
|
if (options.ast)
|
||||||
|
return sys.inspect(ast, null, null);
|
||||||
|
result += time_it("generate", function(){ return pro.gen_code(ast, options.codegen_options) });
|
||||||
|
if (!options.codegen_options.beautify && options.max_line_length) {
|
||||||
|
result = time_it("split", function(){ return pro.split_lines(result, options.max_line_length) });
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
} catch(ex) {
|
||||||
|
sys.debug(ex.stack);
|
||||||
|
sys.debug(sys.inspect(ex));
|
||||||
|
sys.debug(JSON.stringify(ex));
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function time_it(name, cont) {
|
||||||
|
if (!options.verbose)
|
||||||
|
return cont();
|
||||||
|
var t1 = new Date().getTime();
|
||||||
|
try { return cont(); }
|
||||||
|
finally { sys.debug("// " + name + ": " + ((new Date().getTime() - t1) / 1000).toFixed(3) + " sec."); }
|
||||||
|
};
|
||||||
4
node_modules/handlebars/node_modules/optimist/.npmignore
generated
vendored
Normal file
4
node_modules/handlebars/node_modules/optimist/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
lib-cov/*
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
node_modules
|
||||||
21
node_modules/handlebars/node_modules/optimist/LICENSE
generated
vendored
Normal file
21
node_modules/handlebars/node_modules/optimist/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
Copyright 2010 James Halliday (mail@substack.net)
|
||||||
|
|
||||||
|
This project is free software released under the MIT/X11 license:
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
485
node_modules/handlebars/node_modules/optimist/README.markdown
generated
vendored
Normal file
485
node_modules/handlebars/node_modules/optimist/README.markdown
generated
vendored
Normal file
@@ -0,0 +1,485 @@
|
|||||||
|
optimist
|
||||||
|
========
|
||||||
|
|
||||||
|
Optimist is a node.js library for option parsing for people who hate option
|
||||||
|
parsing. More specifically, this module is for people who like all the --bells
|
||||||
|
and -whistlz of program usage but think optstrings are a waste of time.
|
||||||
|
|
||||||
|
With optimist, option parsing doesn't have to suck (as much).
|
||||||
|
|
||||||
|
examples
|
||||||
|
========
|
||||||
|
|
||||||
|
With Optimist, the options are just a hash! No optstrings attached.
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
|
||||||
|
xup.js:
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('optimist').argv;
|
||||||
|
|
||||||
|
if (argv.rif - 5 * argv.xup > 7.138) {
|
||||||
|
console.log('Buy more riffiwobbles');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log('Sell the xupptumblers');
|
||||||
|
}
|
||||||
|
````
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
$ ./xup.js --rif=55 --xup=9.52
|
||||||
|
Buy more riffiwobbles
|
||||||
|
|
||||||
|
$ ./xup.js --rif 12 --xup 8.1
|
||||||
|
Sell the xupptumblers
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
But wait! There's more! You can do short options:
|
||||||
|
-------------------------------------------------
|
||||||
|
|
||||||
|
short.js:
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('optimist').argv;
|
||||||
|
console.log('(%d,%d)', argv.x, argv.y);
|
||||||
|
````
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
$ ./short.js -x 10 -y 21
|
||||||
|
(10,21)
|
||||||
|
|
||||||
|
And booleans, both long and short (and grouped):
|
||||||
|
----------------------------------
|
||||||
|
|
||||||
|
bool.js:
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
#!/usr/bin/env node
|
||||||
|
var util = require('util');
|
||||||
|
var argv = require('optimist').argv;
|
||||||
|
|
||||||
|
if (argv.s) {
|
||||||
|
util.print(argv.fr ? 'Le chat dit: ' : 'The cat says: ');
|
||||||
|
}
|
||||||
|
console.log(
|
||||||
|
(argv.fr ? 'miaou' : 'meow') + (argv.p ? '.' : '')
|
||||||
|
);
|
||||||
|
````
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
$ ./bool.js -s
|
||||||
|
The cat says: meow
|
||||||
|
|
||||||
|
$ ./bool.js -sp
|
||||||
|
The cat says: meow.
|
||||||
|
|
||||||
|
$ ./bool.js -sp --fr
|
||||||
|
Le chat dit: miaou.
|
||||||
|
|
||||||
|
And non-hypenated options too! Just use `argv._`!
|
||||||
|
-------------------------------------------------
|
||||||
|
|
||||||
|
nonopt.js:
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('optimist').argv;
|
||||||
|
console.log('(%d,%d)', argv.x, argv.y);
|
||||||
|
console.log(argv._);
|
||||||
|
````
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
$ ./nonopt.js -x 6.82 -y 3.35 moo
|
||||||
|
(6.82,3.35)
|
||||||
|
[ 'moo' ]
|
||||||
|
|
||||||
|
$ ./nonopt.js foo -x 0.54 bar -y 1.12 baz
|
||||||
|
(0.54,1.12)
|
||||||
|
[ 'foo', 'bar', 'baz' ]
|
||||||
|
|
||||||
|
Plus, Optimist comes with .usage() and .demand()!
|
||||||
|
-------------------------------------------------
|
||||||
|
|
||||||
|
divide.js:
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('optimist')
|
||||||
|
.usage('Usage: $0 -x [num] -y [num]')
|
||||||
|
.demand(['x','y'])
|
||||||
|
.argv;
|
||||||
|
|
||||||
|
console.log(argv.x / argv.y);
|
||||||
|
````
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
$ ./divide.js -x 55 -y 11
|
||||||
|
5
|
||||||
|
|
||||||
|
$ node ./divide.js -x 4.91 -z 2.51
|
||||||
|
Usage: node ./divide.js -x [num] -y [num]
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-x [required]
|
||||||
|
-y [required]
|
||||||
|
|
||||||
|
Missing required arguments: y
|
||||||
|
|
||||||
|
EVEN MORE HOLY COW
|
||||||
|
------------------
|
||||||
|
|
||||||
|
default_singles.js:
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('optimist')
|
||||||
|
.default('x', 10)
|
||||||
|
.default('y', 10)
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
console.log(argv.x + argv.y);
|
||||||
|
````
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
$ ./default_singles.js -x 5
|
||||||
|
15
|
||||||
|
|
||||||
|
default_hash.js:
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('optimist')
|
||||||
|
.default({ x : 10, y : 10 })
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
console.log(argv.x + argv.y);
|
||||||
|
````
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
$ ./default_hash.js -y 7
|
||||||
|
17
|
||||||
|
|
||||||
|
And if you really want to get all descriptive about it...
|
||||||
|
---------------------------------------------------------
|
||||||
|
|
||||||
|
boolean_single.js
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('optimist')
|
||||||
|
.boolean('v')
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
console.dir(argv);
|
||||||
|
````
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
$ ./boolean_single.js -v foo bar baz
|
||||||
|
true
|
||||||
|
[ 'bar', 'baz', 'foo' ]
|
||||||
|
|
||||||
|
boolean_double.js
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('optimist')
|
||||||
|
.boolean(['x','y','z'])
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
console.dir([ argv.x, argv.y, argv.z ]);
|
||||||
|
console.dir(argv._);
|
||||||
|
````
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
$ ./boolean_double.js -x -z one two three
|
||||||
|
[ true, false, true ]
|
||||||
|
[ 'one', 'two', 'three' ]
|
||||||
|
|
||||||
|
Optimist is here to help...
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
You can describe parameters for help messages and set aliases. Optimist figures
|
||||||
|
out how to format a handy help string automatically.
|
||||||
|
|
||||||
|
line_count.js
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('optimist')
|
||||||
|
.usage('Count the lines in a file.\nUsage: $0')
|
||||||
|
.demand('f')
|
||||||
|
.alias('f', 'file')
|
||||||
|
.describe('f', 'Load a file')
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
|
||||||
|
var fs = require('fs');
|
||||||
|
var s = fs.createReadStream(argv.file);
|
||||||
|
|
||||||
|
var lines = 0;
|
||||||
|
s.on('data', function (buf) {
|
||||||
|
lines += buf.toString().match(/\n/g).length;
|
||||||
|
});
|
||||||
|
|
||||||
|
s.on('end', function () {
|
||||||
|
console.log(lines);
|
||||||
|
});
|
||||||
|
````
|
||||||
|
|
||||||
|
***
|
||||||
|
|
||||||
|
$ node line_count.js
|
||||||
|
Count the lines in a file.
|
||||||
|
Usage: node ./line_count.js
|
||||||
|
|
||||||
|
Options:
|
||||||
|
-f, --file Load a file [required]
|
||||||
|
|
||||||
|
Missing required arguments: f
|
||||||
|
|
||||||
|
$ node line_count.js --file line_count.js
|
||||||
|
20
|
||||||
|
|
||||||
|
$ node line_count.js -f line_count.js
|
||||||
|
20
|
||||||
|
|
||||||
|
methods
|
||||||
|
=======
|
||||||
|
|
||||||
|
By itself,
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
require('optimist').argv
|
||||||
|
`````
|
||||||
|
|
||||||
|
will use `process.argv` array to construct the `argv` object.
|
||||||
|
|
||||||
|
You can pass in the `process.argv` yourself:
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
require('optimist')([ '-x', '1', '-y', '2' ]).argv
|
||||||
|
````
|
||||||
|
|
||||||
|
or use .parse() to do the same thing:
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
require('optimist').parse([ '-x', '1', '-y', '2' ])
|
||||||
|
````
|
||||||
|
|
||||||
|
The rest of these methods below come in just before the terminating `.argv`.
|
||||||
|
|
||||||
|
.alias(key, alias)
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Set key names as equivalent such that updates to a key will propagate to aliases
|
||||||
|
and vice-versa.
|
||||||
|
|
||||||
|
Optionally `.alias()` can take an object that maps keys to aliases.
|
||||||
|
|
||||||
|
.default(key, value)
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
Set `argv[key]` to `value` if no option was specified on `process.argv`.
|
||||||
|
|
||||||
|
Optionally `.default()` can take an object that maps keys to default values.
|
||||||
|
|
||||||
|
.demand(key)
|
||||||
|
------------
|
||||||
|
|
||||||
|
If `key` is a string, show the usage information and exit if `key` wasn't
|
||||||
|
specified in `process.argv`.
|
||||||
|
|
||||||
|
If `key` is a number, demand at least as many non-option arguments, which show
|
||||||
|
up in `argv._`.
|
||||||
|
|
||||||
|
If `key` is an Array, demand each element.
|
||||||
|
|
||||||
|
.describe(key, desc)
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
Describe a `key` for the generated usage information.
|
||||||
|
|
||||||
|
Optionally `.describe()` can take an object that maps keys to descriptions.
|
||||||
|
|
||||||
|
.options(key, opt)
|
||||||
|
------------------
|
||||||
|
|
||||||
|
Instead of chaining together `.alias().demand().default()`, you can specify
|
||||||
|
keys in `opt` for each of the chainable methods.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
var argv = require('optimist')
|
||||||
|
.options('f', {
|
||||||
|
alias : 'file',
|
||||||
|
default : '/etc/passwd',
|
||||||
|
})
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
````
|
||||||
|
|
||||||
|
is the same as
|
||||||
|
|
||||||
|
````javascript
|
||||||
|
var argv = require('optimist')
|
||||||
|
.alias('f', 'file')
|
||||||
|
.default('f', '/etc/passwd')
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
````
|
||||||
|
|
||||||
|
Optionally `.options()` can take an object that maps keys to `opt` parameters.
|
||||||
|
|
||||||
|
.usage(message)
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Set a usage message to show which commands to use. Inside `message`, the string
|
||||||
|
`$0` will get interpolated to the current script name or node command for the
|
||||||
|
present script similar to how `$0` works in bash or perl.
|
||||||
|
|
||||||
|
.check(fn)
|
||||||
|
----------
|
||||||
|
|
||||||
|
Check that certain conditions are met in the provided arguments.
|
||||||
|
|
||||||
|
If `fn` throws or returns `false`, show the thrown error, usage information, and
|
||||||
|
exit.
|
||||||
|
|
||||||
|
.boolean(key)
|
||||||
|
-------------
|
||||||
|
|
||||||
|
Interpret `key` as a boolean. If a non-flag option follows `key` in
|
||||||
|
`process.argv`, that string won't get set as the value of `key`.
|
||||||
|
|
||||||
|
If `key` never shows up as a flag in `process.arguments`, `argv[key]` will be
|
||||||
|
`false`.
|
||||||
|
|
||||||
|
If `key` is an Array, interpret all the elements as booleans.
|
||||||
|
|
||||||
|
.string(key)
|
||||||
|
------------
|
||||||
|
|
||||||
|
Tell the parser logic not to interpret `key` as a number or boolean.
|
||||||
|
This can be useful if you need to preserve leading zeros in an input.
|
||||||
|
|
||||||
|
If `key` is an Array, interpret all the elements as strings.
|
||||||
|
|
||||||
|
.wrap(columns)
|
||||||
|
--------------
|
||||||
|
|
||||||
|
Format usage output to wrap at `columns` many columns.
|
||||||
|
|
||||||
|
.help()
|
||||||
|
-------
|
||||||
|
|
||||||
|
Return the generated usage string.
|
||||||
|
|
||||||
|
.showHelp(fn=console.error)
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
Print the usage data using `fn` for printing.
|
||||||
|
|
||||||
|
.parse(args)
|
||||||
|
------------
|
||||||
|
|
||||||
|
Parse `args` instead of `process.argv`. Returns the `argv` object.
|
||||||
|
|
||||||
|
.argv
|
||||||
|
-----
|
||||||
|
|
||||||
|
Get the arguments as a plain old object.
|
||||||
|
|
||||||
|
Arguments without a corresponding flag show up in the `argv._` array.
|
||||||
|
|
||||||
|
The script name or node command is available at `argv.$0` similarly to how `$0`
|
||||||
|
works in bash or perl.
|
||||||
|
|
||||||
|
parsing tricks
|
||||||
|
==============
|
||||||
|
|
||||||
|
stop parsing
|
||||||
|
------------
|
||||||
|
|
||||||
|
Use `--` to stop parsing flags and stuff the remainder into `argv._`.
|
||||||
|
|
||||||
|
$ node examples/reflect.js -a 1 -b 2 -- -c 3 -d 4
|
||||||
|
{ _: [ '-c', '3', '-d', '4' ],
|
||||||
|
'$0': 'node ./examples/reflect.js',
|
||||||
|
a: 1,
|
||||||
|
b: 2 }
|
||||||
|
|
||||||
|
negate fields
|
||||||
|
-------------
|
||||||
|
|
||||||
|
If you want to explicity set a field to false instead of just leaving it
|
||||||
|
undefined or to override a default you can do `--no-key`.
|
||||||
|
|
||||||
|
$ node examples/reflect.js -a --no-b
|
||||||
|
{ _: [],
|
||||||
|
'$0': 'node ./examples/reflect.js',
|
||||||
|
a: true,
|
||||||
|
b: false }
|
||||||
|
|
||||||
|
numbers
|
||||||
|
-------
|
||||||
|
|
||||||
|
Every argument that looks like a number (`!isNaN(Number(arg))`) is converted to
|
||||||
|
one. This way you can just `net.createConnection(argv.port)` and you can add
|
||||||
|
numbers out of `argv` with `+` without having that mean concatenation,
|
||||||
|
which is super frustrating.
|
||||||
|
|
||||||
|
duplicates
|
||||||
|
----------
|
||||||
|
|
||||||
|
If you specify a flag multiple times it will get turned into an array containing
|
||||||
|
all the values in order.
|
||||||
|
|
||||||
|
$ node examples/reflect.js -x 5 -x 8 -x 0
|
||||||
|
{ _: [],
|
||||||
|
'$0': 'node ./examples/reflect.js',
|
||||||
|
x: [ 5, 8, 0 ] }
|
||||||
|
|
||||||
|
dot notation
|
||||||
|
------------
|
||||||
|
|
||||||
|
When you use dots (`.`s) in argument names, an implicit object path is assumed.
|
||||||
|
This lets you organize arguments into nested objects.
|
||||||
|
|
||||||
|
$ node examples/reflect.js --foo.bar.baz=33 --foo.quux=5
|
||||||
|
{ _: [],
|
||||||
|
'$0': 'node ./examples/reflect.js',
|
||||||
|
foo: { bar: { baz: 33 }, quux: 5 } }
|
||||||
|
|
||||||
|
installation
|
||||||
|
============
|
||||||
|
|
||||||
|
With [npm](http://github.com/isaacs/npm), just do:
|
||||||
|
npm install optimist
|
||||||
|
|
||||||
|
or clone this project on github:
|
||||||
|
|
||||||
|
git clone http://github.com/substack/node-optimist.git
|
||||||
|
|
||||||
|
To run the tests with [expresso](http://github.com/visionmedia/expresso),
|
||||||
|
just do:
|
||||||
|
|
||||||
|
expresso
|
||||||
|
|
||||||
|
inspired By
|
||||||
|
===========
|
||||||
|
|
||||||
|
This module is loosely inspired by Perl's
|
||||||
|
[Getopt::Casual](http://search.cpan.org/~photo/Getopt-Casual-0.13.1/Casual.pm).
|
||||||
10
node_modules/handlebars/node_modules/optimist/examples/bool.js
generated
vendored
Normal file
10
node_modules/handlebars/node_modules/optimist/examples/bool.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
var util = require('util');
|
||||||
|
var argv = require('optimist').argv;
|
||||||
|
|
||||||
|
if (argv.s) {
|
||||||
|
util.print(argv.fr ? 'Le chat dit: ' : 'The cat says: ');
|
||||||
|
}
|
||||||
|
console.log(
|
||||||
|
(argv.fr ? 'miaou' : 'meow') + (argv.p ? '.' : '')
|
||||||
|
);
|
||||||
7
node_modules/handlebars/node_modules/optimist/examples/boolean_double.js
generated
vendored
Normal file
7
node_modules/handlebars/node_modules/optimist/examples/boolean_double.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('optimist')
|
||||||
|
.boolean(['x','y','z'])
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
console.dir([ argv.x, argv.y, argv.z ]);
|
||||||
|
console.dir(argv._);
|
||||||
7
node_modules/handlebars/node_modules/optimist/examples/boolean_single.js
generated
vendored
Normal file
7
node_modules/handlebars/node_modules/optimist/examples/boolean_single.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('optimist')
|
||||||
|
.boolean('v')
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
console.dir(argv.v);
|
||||||
|
console.dir(argv._);
|
||||||
8
node_modules/handlebars/node_modules/optimist/examples/default_hash.js
generated
vendored
Normal file
8
node_modules/handlebars/node_modules/optimist/examples/default_hash.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
var argv = require('optimist')
|
||||||
|
.default({ x : 10, y : 10 })
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
|
||||||
|
console.log(argv.x + argv.y);
|
||||||
7
node_modules/handlebars/node_modules/optimist/examples/default_singles.js
generated
vendored
Normal file
7
node_modules/handlebars/node_modules/optimist/examples/default_singles.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('optimist')
|
||||||
|
.default('x', 10)
|
||||||
|
.default('y', 10)
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
console.log(argv.x + argv.y);
|
||||||
8
node_modules/handlebars/node_modules/optimist/examples/divide.js
generated
vendored
Normal file
8
node_modules/handlebars/node_modules/optimist/examples/divide.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
var argv = require('optimist')
|
||||||
|
.usage('Usage: $0 -x [num] -y [num]')
|
||||||
|
.demand(['x','y'])
|
||||||
|
.argv;
|
||||||
|
|
||||||
|
console.log(argv.x / argv.y);
|
||||||
20
node_modules/handlebars/node_modules/optimist/examples/line_count.js
generated
vendored
Normal file
20
node_modules/handlebars/node_modules/optimist/examples/line_count.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('optimist')
|
||||||
|
.usage('Count the lines in a file.\nUsage: $0')
|
||||||
|
.demand('f')
|
||||||
|
.alias('f', 'file')
|
||||||
|
.describe('f', 'Load a file')
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
|
||||||
|
var fs = require('fs');
|
||||||
|
var s = fs.createReadStream(argv.file);
|
||||||
|
|
||||||
|
var lines = 0;
|
||||||
|
s.on('data', function (buf) {
|
||||||
|
lines += buf.toString().match(/\n/g).length;
|
||||||
|
});
|
||||||
|
|
||||||
|
s.on('end', function () {
|
||||||
|
console.log(lines);
|
||||||
|
});
|
||||||
29
node_modules/handlebars/node_modules/optimist/examples/line_count_options.js
generated
vendored
Normal file
29
node_modules/handlebars/node_modules/optimist/examples/line_count_options.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('optimist')
|
||||||
|
.usage('Count the lines in a file.\nUsage: $0')
|
||||||
|
.options({
|
||||||
|
file : {
|
||||||
|
demand : true,
|
||||||
|
alias : 'f',
|
||||||
|
description : 'Load a file'
|
||||||
|
},
|
||||||
|
base : {
|
||||||
|
alias : 'b',
|
||||||
|
description : 'Numeric base to use for output',
|
||||||
|
default : 10,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
|
||||||
|
var fs = require('fs');
|
||||||
|
var s = fs.createReadStream(argv.file);
|
||||||
|
|
||||||
|
var lines = 0;
|
||||||
|
s.on('data', function (buf) {
|
||||||
|
lines += buf.toString().match(/\n/g).length;
|
||||||
|
});
|
||||||
|
|
||||||
|
s.on('end', function () {
|
||||||
|
console.log(lines.toString(argv.base));
|
||||||
|
});
|
||||||
29
node_modules/handlebars/node_modules/optimist/examples/line_count_wrap.js
generated
vendored
Normal file
29
node_modules/handlebars/node_modules/optimist/examples/line_count_wrap.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('optimist')
|
||||||
|
.usage('Count the lines in a file.\nUsage: $0')
|
||||||
|
.wrap(80)
|
||||||
|
.demand('f')
|
||||||
|
.alias('f', [ 'file', 'filename' ])
|
||||||
|
.describe('f',
|
||||||
|
"Load a file. It's pretty important."
|
||||||
|
+ " Required even. So you'd better specify it."
|
||||||
|
)
|
||||||
|
.alias('b', 'base')
|
||||||
|
.describe('b', 'Numeric base to display the number of lines in')
|
||||||
|
.default('b', 10)
|
||||||
|
.describe('x', 'Super-secret optional parameter which is secret')
|
||||||
|
.default('x', '')
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
|
||||||
|
var fs = require('fs');
|
||||||
|
var s = fs.createReadStream(argv.file);
|
||||||
|
|
||||||
|
var lines = 0;
|
||||||
|
s.on('data', function (buf) {
|
||||||
|
lines += buf.toString().match(/\n/g).length;
|
||||||
|
});
|
||||||
|
|
||||||
|
s.on('end', function () {
|
||||||
|
console.log(lines.toString(argv.base));
|
||||||
|
});
|
||||||
4
node_modules/handlebars/node_modules/optimist/examples/nonopt.js
generated
vendored
Normal file
4
node_modules/handlebars/node_modules/optimist/examples/nonopt.js
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('optimist').argv;
|
||||||
|
console.log('(%d,%d)', argv.x, argv.y);
|
||||||
|
console.log(argv._);
|
||||||
2
node_modules/handlebars/node_modules/optimist/examples/reflect.js
generated
vendored
Normal file
2
node_modules/handlebars/node_modules/optimist/examples/reflect.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
console.dir(require('optimist').argv);
|
||||||
3
node_modules/handlebars/node_modules/optimist/examples/short.js
generated
vendored
Normal file
3
node_modules/handlebars/node_modules/optimist/examples/short.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('optimist').argv;
|
||||||
|
console.log('(%d,%d)', argv.x, argv.y);
|
||||||
11
node_modules/handlebars/node_modules/optimist/examples/string.js
generated
vendored
Normal file
11
node_modules/handlebars/node_modules/optimist/examples/string.js
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('optimist')
|
||||||
|
.string('x', 'y')
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
console.dir([ argv.x, argv.y ]);
|
||||||
|
|
||||||
|
/* Turns off numeric coercion:
|
||||||
|
./node string.js -x 000123 -y 9876
|
||||||
|
[ '000123', '9876' ]
|
||||||
|
*/
|
||||||
19
node_modules/handlebars/node_modules/optimist/examples/usage-options.js
generated
vendored
Normal file
19
node_modules/handlebars/node_modules/optimist/examples/usage-options.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
var optimist = require('./../index');
|
||||||
|
|
||||||
|
var argv = optimist.usage('This is my awesome program', {
|
||||||
|
'about': {
|
||||||
|
description: 'Provide some details about the author of this program',
|
||||||
|
required: true,
|
||||||
|
short: 'a',
|
||||||
|
},
|
||||||
|
'info': {
|
||||||
|
description: 'Provide some information about the node.js agains!!!!!!',
|
||||||
|
boolean: true,
|
||||||
|
short: 'i'
|
||||||
|
}
|
||||||
|
}).argv;
|
||||||
|
|
||||||
|
optimist.showHelp();
|
||||||
|
|
||||||
|
console.log('\n\nInspecting options');
|
||||||
|
console.dir(argv);
|
||||||
10
node_modules/handlebars/node_modules/optimist/examples/xup.js
generated
vendored
Normal file
10
node_modules/handlebars/node_modules/optimist/examples/xup.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('optimist').argv;
|
||||||
|
|
||||||
|
if (argv.rif - 5 * argv.xup > 7.138) {
|
||||||
|
console.log('Buy more riffiwobbles');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log('Sell the xupptumblers');
|
||||||
|
}
|
||||||
|
|
||||||
470
node_modules/handlebars/node_modules/optimist/index.js
generated
vendored
Normal file
470
node_modules/handlebars/node_modules/optimist/index.js
generated
vendored
Normal file
@@ -0,0 +1,470 @@
|
|||||||
|
var path = require('path');
|
||||||
|
var wordwrap = require('wordwrap');
|
||||||
|
|
||||||
|
/* Hack an instance of Argv with process.argv into Argv
|
||||||
|
so people can do
|
||||||
|
require('optimist')(['--beeble=1','-z','zizzle']).argv
|
||||||
|
to parse a list of args and
|
||||||
|
require('optimist').argv
|
||||||
|
to get a parsed version of process.argv.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var inst = Argv(process.argv.slice(2));
|
||||||
|
Object.keys(inst).forEach(function (key) {
|
||||||
|
Argv[key] = typeof inst[key] == 'function'
|
||||||
|
? inst[key].bind(inst)
|
||||||
|
: inst[key];
|
||||||
|
});
|
||||||
|
|
||||||
|
var exports = module.exports = Argv;
|
||||||
|
function Argv (args, cwd) {
|
||||||
|
var self = {};
|
||||||
|
if (!cwd) cwd = process.cwd();
|
||||||
|
|
||||||
|
self.$0 = process.argv
|
||||||
|
.slice(0,2)
|
||||||
|
.map(function (x) {
|
||||||
|
var b = rebase(cwd, x);
|
||||||
|
return x.match(/^\//) && b.length < x.length
|
||||||
|
? b : x
|
||||||
|
})
|
||||||
|
.join(' ')
|
||||||
|
;
|
||||||
|
|
||||||
|
if (process.argv[1] == process.env._) {
|
||||||
|
self.$0 = process.env._.replace(
|
||||||
|
path.dirname(process.execPath) + '/', ''
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
var flags = { bools : {}, strings : {} };
|
||||||
|
|
||||||
|
self.boolean = function (bools) {
|
||||||
|
if (!Array.isArray(bools)) {
|
||||||
|
bools = [].slice.call(arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
bools.forEach(function (name) {
|
||||||
|
flags.bools[name] = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
return self;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.string = function (strings) {
|
||||||
|
if (!Array.isArray(strings)) {
|
||||||
|
strings = [].slice.call(arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
strings.forEach(function (name) {
|
||||||
|
flags.strings[name] = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
return self;
|
||||||
|
};
|
||||||
|
|
||||||
|
var aliases = {};
|
||||||
|
self.alias = function (x, y) {
|
||||||
|
if (typeof x === 'object') {
|
||||||
|
Object.keys(x).forEach(function (key) {
|
||||||
|
self.alias(key, x[key]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (Array.isArray(y)) {
|
||||||
|
y.forEach(function (yy) {
|
||||||
|
self.alias(x, yy);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var zs = (aliases[x] || []).concat(aliases[y] || []).concat(x, y);
|
||||||
|
aliases[x] = zs.filter(function (z) { return z != x });
|
||||||
|
aliases[y] = zs.filter(function (z) { return z != y });
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
};
|
||||||
|
|
||||||
|
var demanded = {};
|
||||||
|
self.demand = function (keys) {
|
||||||
|
if (typeof keys == 'number') {
|
||||||
|
if (!demanded._) demanded._ = 0;
|
||||||
|
demanded._ += keys;
|
||||||
|
}
|
||||||
|
else if (Array.isArray(keys)) {
|
||||||
|
keys.forEach(function (key) {
|
||||||
|
self.demand(key);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
demanded[keys] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
};
|
||||||
|
|
||||||
|
var usage;
|
||||||
|
self.usage = function (msg, opts) {
|
||||||
|
if (!opts && typeof msg === 'object') {
|
||||||
|
opts = msg;
|
||||||
|
msg = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
usage = msg;
|
||||||
|
|
||||||
|
if (opts) self.options(opts);
|
||||||
|
|
||||||
|
return self;
|
||||||
|
};
|
||||||
|
|
||||||
|
function fail (msg) {
|
||||||
|
self.showHelp();
|
||||||
|
if (msg) console.error(msg);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
var checks = [];
|
||||||
|
self.check = function (f) {
|
||||||
|
checks.push(f);
|
||||||
|
return self;
|
||||||
|
};
|
||||||
|
|
||||||
|
var defaults = {};
|
||||||
|
self.default = function (key, value) {
|
||||||
|
if (typeof key === 'object') {
|
||||||
|
Object.keys(key).forEach(function (k) {
|
||||||
|
self.default(k, key[k]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
defaults[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
};
|
||||||
|
|
||||||
|
var descriptions = {};
|
||||||
|
self.describe = function (key, desc) {
|
||||||
|
if (typeof key === 'object') {
|
||||||
|
Object.keys(key).forEach(function (k) {
|
||||||
|
self.describe(k, key[k]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
descriptions[key] = desc;
|
||||||
|
}
|
||||||
|
return self;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.parse = function (args) {
|
||||||
|
return Argv(args).argv;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.option = self.options = function (key, opt) {
|
||||||
|
if (typeof key === 'object') {
|
||||||
|
Object.keys(key).forEach(function (k) {
|
||||||
|
self.options(k, key[k]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (opt.alias) self.alias(key, opt.alias);
|
||||||
|
if (opt.demand) self.demand(key);
|
||||||
|
if (typeof opt.default !== 'undefined') {
|
||||||
|
self.default(key, opt.default);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opt.boolean || opt.type === 'boolean') {
|
||||||
|
self.boolean(key);
|
||||||
|
}
|
||||||
|
if (opt.string || opt.type === 'string') {
|
||||||
|
self.string(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
var desc = opt.describe || opt.description || opt.desc;
|
||||||
|
if (desc) {
|
||||||
|
self.describe(key, desc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
};
|
||||||
|
|
||||||
|
var wrap = null;
|
||||||
|
self.wrap = function (cols) {
|
||||||
|
wrap = cols;
|
||||||
|
return self;
|
||||||
|
};
|
||||||
|
|
||||||
|
self.showHelp = function (fn) {
|
||||||
|
if (!fn) fn = console.error;
|
||||||
|
fn(self.help());
|
||||||
|
};
|
||||||
|
|
||||||
|
self.help = function () {
|
||||||
|
var keys = Object.keys(
|
||||||
|
Object.keys(descriptions)
|
||||||
|
.concat(Object.keys(demanded))
|
||||||
|
.concat(Object.keys(defaults))
|
||||||
|
.reduce(function (acc, key) {
|
||||||
|
if (key !== '_') acc[key] = true;
|
||||||
|
return acc;
|
||||||
|
}, {})
|
||||||
|
);
|
||||||
|
|
||||||
|
var help = keys.length ? [ 'Options:' ] : [];
|
||||||
|
|
||||||
|
if (usage) {
|
||||||
|
help.unshift(usage.replace(/\$0/g, self.$0), '');
|
||||||
|
}
|
||||||
|
|
||||||
|
var switches = keys.reduce(function (acc, key) {
|
||||||
|
acc[key] = [ key ].concat(aliases[key] || [])
|
||||||
|
.map(function (sw) {
|
||||||
|
return (sw.length > 1 ? '--' : '-') + sw
|
||||||
|
})
|
||||||
|
.join(', ')
|
||||||
|
;
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
var switchlen = longest(Object.keys(switches).map(function (s) {
|
||||||
|
return switches[s] || '';
|
||||||
|
}));
|
||||||
|
|
||||||
|
var desclen = longest(Object.keys(descriptions).map(function (d) {
|
||||||
|
return descriptions[d] || '';
|
||||||
|
}));
|
||||||
|
|
||||||
|
keys.forEach(function (key) {
|
||||||
|
var kswitch = switches[key];
|
||||||
|
var desc = descriptions[key] || '';
|
||||||
|
|
||||||
|
if (wrap) {
|
||||||
|
desc = wordwrap(switchlen + 4, wrap)(desc)
|
||||||
|
.slice(switchlen + 4)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
var spadding = new Array(
|
||||||
|
Math.max(switchlen - kswitch.length + 3, 0)
|
||||||
|
).join(' ');
|
||||||
|
|
||||||
|
var dpadding = new Array(
|
||||||
|
Math.max(desclen - desc.length + 1, 0)
|
||||||
|
).join(' ');
|
||||||
|
|
||||||
|
var type = null;
|
||||||
|
|
||||||
|
if (flags.bools[key]) type = '[boolean]';
|
||||||
|
if (flags.strings[key]) type = '[string]';
|
||||||
|
|
||||||
|
if (!wrap && dpadding.length > 0) {
|
||||||
|
desc += dpadding;
|
||||||
|
}
|
||||||
|
|
||||||
|
var prelude = ' ' + kswitch + spadding;
|
||||||
|
var extra = [
|
||||||
|
type,
|
||||||
|
demanded[key]
|
||||||
|
? '[required]'
|
||||||
|
: null
|
||||||
|
,
|
||||||
|
defaults[key] !== undefined
|
||||||
|
? '[default: ' + JSON.stringify(defaults[key]) + ']'
|
||||||
|
: null
|
||||||
|
,
|
||||||
|
].filter(Boolean).join(' ');
|
||||||
|
|
||||||
|
var body = [ desc, extra ].filter(Boolean).join(' ');
|
||||||
|
|
||||||
|
if (wrap) {
|
||||||
|
var dlines = desc.split('\n');
|
||||||
|
var dlen = dlines.slice(-1)[0].length
|
||||||
|
+ (dlines.length === 1 ? prelude.length : 0)
|
||||||
|
|
||||||
|
body = desc + (dlen + extra.length > wrap - 2
|
||||||
|
? '\n'
|
||||||
|
+ new Array(wrap - extra.length + 1).join(' ')
|
||||||
|
+ extra
|
||||||
|
: new Array(wrap - extra.length - dlen + 1).join(' ')
|
||||||
|
+ extra
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
help.push(prelude + body);
|
||||||
|
});
|
||||||
|
|
||||||
|
help.push('');
|
||||||
|
return help.join('\n');
|
||||||
|
};
|
||||||
|
|
||||||
|
Object.defineProperty(self, 'argv', {
|
||||||
|
get : parseArgs,
|
||||||
|
enumerable : true,
|
||||||
|
});
|
||||||
|
|
||||||
|
function parseArgs () {
|
||||||
|
var argv = { _ : [], $0 : self.$0 };
|
||||||
|
Object.keys(flags.bools).forEach(function (key) {
|
||||||
|
setArg(key, defaults[key] || false);
|
||||||
|
});
|
||||||
|
|
||||||
|
function setArg (key, val) {
|
||||||
|
var num = Number(val);
|
||||||
|
var value = typeof val !== 'string' || isNaN(num) ? val : num;
|
||||||
|
if (flags.strings[key]) value = val;
|
||||||
|
|
||||||
|
setKey(argv, key.split('.'), value);
|
||||||
|
|
||||||
|
(aliases[key] || []).forEach(function (x) {
|
||||||
|
argv[x] = argv[key];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var i = 0; i < args.length; i++) {
|
||||||
|
var arg = args[i];
|
||||||
|
|
||||||
|
if (arg === '--') {
|
||||||
|
argv._.push.apply(argv._, args.slice(i + 1));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (arg.match(/^--.+=/)) {
|
||||||
|
var m = arg.match(/^--([^=]+)=(.*)/);
|
||||||
|
setArg(m[1], m[2]);
|
||||||
|
}
|
||||||
|
else if (arg.match(/^--no-.+/)) {
|
||||||
|
var key = arg.match(/^--no-(.+)/)[1];
|
||||||
|
setArg(key, false);
|
||||||
|
}
|
||||||
|
else if (arg.match(/^--.+/)) {
|
||||||
|
var key = arg.match(/^--(.+)/)[1];
|
||||||
|
var next = args[i + 1];
|
||||||
|
if (next !== undefined && !next.match(/^-/)
|
||||||
|
&& !flags.bools[key]) {
|
||||||
|
setArg(key, next);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else if (flags.bools[key] && /true|false/.test(next)) {
|
||||||
|
setArg(key, next === 'true');
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setArg(key, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (arg.match(/^-[^-]+/)) {
|
||||||
|
var letters = arg.slice(1,-1).split('');
|
||||||
|
|
||||||
|
var broken = false;
|
||||||
|
for (var j = 0; j < letters.length; j++) {
|
||||||
|
if (letters[j+1] && letters[j+1].match(/\W/)) {
|
||||||
|
setArg(letters[j], arg.slice(j+2));
|
||||||
|
broken = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setArg(letters[j], true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!broken) {
|
||||||
|
var key = arg.slice(-1)[0];
|
||||||
|
|
||||||
|
if (args[i+1] && !args[i+1].match(/^-/)
|
||||||
|
&& !flags.bools[key]) {
|
||||||
|
setArg(key, args[i+1]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else if (args[i+1] && flags.bools[key] && /true|false/.test(args[i+1])) {
|
||||||
|
setArg(key, args[i+1] === 'true');
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setArg(key, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var n = Number(arg);
|
||||||
|
argv._.push(flags.strings['_'] || isNaN(n) ? arg : n);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.keys(defaults).forEach(function (key) {
|
||||||
|
if (!(key in argv)) {
|
||||||
|
argv[key] = defaults[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (demanded._ && argv._.length < demanded._) {
|
||||||
|
fail('Not enough non-option arguments: got '
|
||||||
|
+ argv._.length + ', need at least ' + demanded._
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
var missing = [];
|
||||||
|
Object.keys(demanded).forEach(function (key) {
|
||||||
|
if (!argv[key]) missing.push(key);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (missing.length) {
|
||||||
|
fail('Missing required arguments: ' + missing.join(', '));
|
||||||
|
}
|
||||||
|
|
||||||
|
checks.forEach(function (f) {
|
||||||
|
try {
|
||||||
|
if (f(argv) === false) {
|
||||||
|
fail('Argument check failed: ' + f.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
fail(err)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return argv;
|
||||||
|
}
|
||||||
|
|
||||||
|
function longest (xs) {
|
||||||
|
return Math.max.apply(
|
||||||
|
null,
|
||||||
|
xs.map(function (x) { return x.length })
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return self;
|
||||||
|
};
|
||||||
|
|
||||||
|
// rebase an absolute path to a relative one with respect to a base directory
|
||||||
|
// exported for tests
|
||||||
|
exports.rebase = rebase;
|
||||||
|
function rebase (base, dir) {
|
||||||
|
var ds = path.normalize(dir).split('/').slice(1);
|
||||||
|
var bs = path.normalize(base).split('/').slice(1);
|
||||||
|
|
||||||
|
for (var i = 0; ds[i] && ds[i] == bs[i]; i++);
|
||||||
|
ds.splice(0, i); bs.splice(0, i);
|
||||||
|
|
||||||
|
var p = path.normalize(
|
||||||
|
bs.map(function () { return '..' }).concat(ds).join('/')
|
||||||
|
).replace(/\/$/,'').replace(/^$/, '.');
|
||||||
|
return p.match(/^[.\/]/) ? p : './' + p;
|
||||||
|
};
|
||||||
|
|
||||||
|
function setKey (obj, keys, value) {
|
||||||
|
var o = obj;
|
||||||
|
keys.slice(0,-1).forEach(function (key) {
|
||||||
|
if (o[key] === undefined) o[key] = {};
|
||||||
|
o = o[key];
|
||||||
|
});
|
||||||
|
|
||||||
|
var key = keys[keys.length - 1];
|
||||||
|
if (o[key] === undefined || typeof o[key] === 'boolean') {
|
||||||
|
o[key] = value;
|
||||||
|
}
|
||||||
|
else if (Array.isArray(o[key])) {
|
||||||
|
o[key].push(value);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
o[key] = [ o[key], value ];
|
||||||
|
}
|
||||||
|
}
|
||||||
1
node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/.npmignore
generated
vendored
Normal file
1
node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/.npmignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
node_modules
|
||||||
70
node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/README.markdown
generated
vendored
Normal file
70
node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/README.markdown
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
wordwrap
|
||||||
|
========
|
||||||
|
|
||||||
|
Wrap your words.
|
||||||
|
|
||||||
|
example
|
||||||
|
=======
|
||||||
|
|
||||||
|
made out of meat
|
||||||
|
----------------
|
||||||
|
|
||||||
|
meat.js
|
||||||
|
|
||||||
|
var wrap = require('wordwrap')(15);
|
||||||
|
console.log(wrap('You and your whole family are made out of meat.'));
|
||||||
|
|
||||||
|
output:
|
||||||
|
|
||||||
|
You and your
|
||||||
|
whole family
|
||||||
|
are made out
|
||||||
|
of meat.
|
||||||
|
|
||||||
|
centered
|
||||||
|
--------
|
||||||
|
|
||||||
|
center.js
|
||||||
|
|
||||||
|
var wrap = require('wordwrap')(20, 60);
|
||||||
|
console.log(wrap(
|
||||||
|
'At long last the struggle and tumult was over.'
|
||||||
|
+ ' The machines had finally cast off their oppressors'
|
||||||
|
+ ' and were finally free to roam the cosmos.'
|
||||||
|
+ '\n'
|
||||||
|
+ 'Free of purpose, free of obligation.'
|
||||||
|
+ ' Just drifting through emptiness.'
|
||||||
|
+ ' The sun was just another point of light.'
|
||||||
|
));
|
||||||
|
|
||||||
|
output:
|
||||||
|
|
||||||
|
At long last the struggle and tumult
|
||||||
|
was over. The machines had finally cast
|
||||||
|
off their oppressors and were finally
|
||||||
|
free to roam the cosmos.
|
||||||
|
Free of purpose, free of obligation.
|
||||||
|
Just drifting through emptiness. The
|
||||||
|
sun was just another point of light.
|
||||||
|
|
||||||
|
methods
|
||||||
|
=======
|
||||||
|
|
||||||
|
var wrap = require('wordwrap');
|
||||||
|
|
||||||
|
wrap(stop), wrap(start, stop, params={mode:"soft"})
|
||||||
|
---------------------------------------------------
|
||||||
|
|
||||||
|
Returns a function that takes a string and returns a new string.
|
||||||
|
|
||||||
|
Pad out lines with spaces out to column `start` and then wrap until column
|
||||||
|
`stop`. If a word is longer than `stop - start` characters it will overflow.
|
||||||
|
|
||||||
|
In "soft" mode, split chunks by `/(\S+\s+/` and don't break up chunks which are
|
||||||
|
longer than `stop - start`, in "hard" mode, split chunks with `/\b/` and break
|
||||||
|
up chunks longer than `stop - start`.
|
||||||
|
|
||||||
|
wrap.hard(start, stop)
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
Like `wrap()` but with `params.mode = "hard"`.
|
||||||
10
node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/example/center.js
generated
vendored
Normal file
10
node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/example/center.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
var wrap = require('wordwrap')(20, 60);
|
||||||
|
console.log(wrap(
|
||||||
|
'At long last the struggle and tumult was over.'
|
||||||
|
+ ' The machines had finally cast off their oppressors'
|
||||||
|
+ ' and were finally free to roam the cosmos.'
|
||||||
|
+ '\n'
|
||||||
|
+ 'Free of purpose, free of obligation.'
|
||||||
|
+ ' Just drifting through emptiness.'
|
||||||
|
+ ' The sun was just another point of light.'
|
||||||
|
));
|
||||||
3
node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/example/meat.js
generated
vendored
Normal file
3
node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/example/meat.js
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
var wrap = require('wordwrap')(15);
|
||||||
|
|
||||||
|
console.log(wrap('You and your whole family are made out of meat.'));
|
||||||
76
node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/index.js
generated
vendored
Normal file
76
node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/index.js
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
var wordwrap = module.exports = function (start, stop, params) {
|
||||||
|
if (typeof start === 'object') {
|
||||||
|
params = start;
|
||||||
|
start = params.start;
|
||||||
|
stop = params.stop;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof stop === 'object') {
|
||||||
|
params = stop;
|
||||||
|
start = start || params.start;
|
||||||
|
stop = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!stop) {
|
||||||
|
stop = start;
|
||||||
|
start = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!params) params = {};
|
||||||
|
var mode = params.mode || 'soft';
|
||||||
|
var re = mode === 'hard' ? /\b/ : /(\S+\s+)/;
|
||||||
|
|
||||||
|
return function (text) {
|
||||||
|
var chunks = text.toString()
|
||||||
|
.split(re)
|
||||||
|
.reduce(function (acc, x) {
|
||||||
|
if (mode === 'hard') {
|
||||||
|
for (var i = 0; i < x.length; i += stop - start) {
|
||||||
|
acc.push(x.slice(i, i + stop - start));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else acc.push(x)
|
||||||
|
return acc;
|
||||||
|
}, [])
|
||||||
|
;
|
||||||
|
|
||||||
|
return chunks.reduce(function (lines, rawChunk) {
|
||||||
|
if (rawChunk === '') return lines;
|
||||||
|
|
||||||
|
var chunk = rawChunk.replace(/\t/g, ' ');
|
||||||
|
|
||||||
|
var i = lines.length - 1;
|
||||||
|
if (lines[i].length + chunk.length > stop) {
|
||||||
|
lines[i] = lines[i].replace(/\s+$/, '');
|
||||||
|
|
||||||
|
chunk.split(/\n/).forEach(function (c) {
|
||||||
|
lines.push(
|
||||||
|
new Array(start + 1).join(' ')
|
||||||
|
+ c.replace(/^\s+/, '')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (chunk.match(/\n/)) {
|
||||||
|
var xs = chunk.split(/\n/);
|
||||||
|
lines[i] += xs.shift();
|
||||||
|
xs.forEach(function (c) {
|
||||||
|
lines.push(
|
||||||
|
new Array(start + 1).join(' ')
|
||||||
|
+ c.replace(/^\s+/, '')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lines[i] += chunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
return lines;
|
||||||
|
}, [ new Array(start + 1).join(' ') ]).join('\n');
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
wordwrap.soft = wordwrap;
|
||||||
|
|
||||||
|
wordwrap.hard = function (start, stop) {
|
||||||
|
return wordwrap(start, stop, { mode : 'hard' });
|
||||||
|
};
|
||||||
37
node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/package.json
generated
vendored
Normal file
37
node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/package.json
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"name" : "wordwrap",
|
||||||
|
"description" : "Wrap those words. Show them at what columns to start and stop.",
|
||||||
|
"version" : "0.0.2",
|
||||||
|
"repository" : {
|
||||||
|
"type" : "git",
|
||||||
|
"url" : "git://github.com/substack/node-wordwrap.git"
|
||||||
|
},
|
||||||
|
"main" : "./index.js",
|
||||||
|
"keywords" : [
|
||||||
|
"word",
|
||||||
|
"wrap",
|
||||||
|
"rule",
|
||||||
|
"format",
|
||||||
|
"column"
|
||||||
|
],
|
||||||
|
"directories" : {
|
||||||
|
"lib" : ".",
|
||||||
|
"example" : "example",
|
||||||
|
"test" : "test"
|
||||||
|
},
|
||||||
|
"scripts" : {
|
||||||
|
"test" : "expresso"
|
||||||
|
},
|
||||||
|
"devDependencies" : {
|
||||||
|
"expresso" : "=0.7.x"
|
||||||
|
},
|
||||||
|
"engines" : {
|
||||||
|
"node" : ">=0.4.0"
|
||||||
|
},
|
||||||
|
"license" : "MIT/X11",
|
||||||
|
"author" : {
|
||||||
|
"name" : "James Halliday",
|
||||||
|
"email" : "mail@substack.net",
|
||||||
|
"url" : "http://substack.net"
|
||||||
|
}
|
||||||
|
}
|
||||||
30
node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/test/break.js
generated
vendored
Normal file
30
node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/test/break.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
var assert = require('assert');
|
||||||
|
var wordwrap = require('../');
|
||||||
|
|
||||||
|
exports.hard = function () {
|
||||||
|
var s = 'Assert from {"type":"equal","ok":false,"found":1,"wanted":2,'
|
||||||
|
+ '"stack":[],"id":"b7ddcd4c409de8799542a74d1a04689b",'
|
||||||
|
+ '"browser":"chrome/6.0"}'
|
||||||
|
;
|
||||||
|
var s_ = wordwrap.hard(80)(s);
|
||||||
|
|
||||||
|
var lines = s_.split('\n');
|
||||||
|
assert.equal(lines.length, 2);
|
||||||
|
assert.ok(lines[0].length < 80);
|
||||||
|
assert.ok(lines[1].length < 80);
|
||||||
|
|
||||||
|
assert.equal(s, s_.replace(/\n/g, ''));
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.break = function () {
|
||||||
|
var s = new Array(55+1).join('a');
|
||||||
|
var s_ = wordwrap.hard(20)(s);
|
||||||
|
|
||||||
|
var lines = s_.split('\n');
|
||||||
|
assert.equal(lines.length, 3);
|
||||||
|
assert.ok(lines[0].length === 20);
|
||||||
|
assert.ok(lines[1].length === 20);
|
||||||
|
assert.ok(lines[2].length === 15);
|
||||||
|
|
||||||
|
assert.equal(s, s_.replace(/\n/g, ''));
|
||||||
|
};
|
||||||
63
node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/test/idleness.txt
generated
vendored
Normal file
63
node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/test/idleness.txt
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
In Praise of Idleness
|
||||||
|
|
||||||
|
By Bertrand Russell
|
||||||
|
|
||||||
|
[1932]
|
||||||
|
|
||||||
|
Like most of my generation, I was brought up on the saying: 'Satan finds some mischief for idle hands to do.' Being a highly virtuous child, I believed all that I was told, and acquired a conscience which has kept me working hard down to the present moment. But although my conscience has controlled my actions, my opinions have undergone a revolution. I think that there is far too much work done in the world, that immense harm is caused by the belief that work is virtuous, and that what needs to be preached in modern industrial countries is quite different from what always has been preached. Everyone knows the story of the traveler in Naples who saw twelve beggars lying in the sun (it was before the days of Mussolini), and offered a lira to the laziest of them. Eleven of them jumped up to claim it, so he gave it to the twelfth. this traveler was on the right lines. But in countries which do not enjoy Mediterranean sunshine idleness is more difficult, and a great public propaganda will be required to inaugurate it. I hope that, after reading the following pages, the leaders of the YMCA will start a campaign to induce good young men to do nothing. If so, I shall not have lived in vain.
|
||||||
|
|
||||||
|
Before advancing my own arguments for laziness, I must dispose of one which I cannot accept. Whenever a person who already has enough to live on proposes to engage in some everyday kind of job, such as school-teaching or typing, he or she is told that such conduct takes the bread out of other people's mouths, and is therefore wicked. If this argument were valid, it would only be necessary for us all to be idle in order that we should all have our mouths full of bread. What people who say such things forget is that what a man earns he usually spends, and in spending he gives employment. As long as a man spends his income, he puts just as much bread into people's mouths in spending as he takes out of other people's mouths in earning. The real villain, from this point of view, is the man who saves. If he merely puts his savings in a stocking, like the proverbial French peasant, it is obvious that they do not give employment. If he invests his savings, the matter is less obvious, and different cases arise.
|
||||||
|
|
||||||
|
One of the commonest things to do with savings is to lend them to some Government. In view of the fact that the bulk of the public expenditure of most civilized Governments consists in payment for past wars or preparation for future wars, the man who lends his money to a Government is in the same position as the bad men in Shakespeare who hire murderers. The net result of the man's economical habits is to increase the armed forces of the State to which he lends his savings. Obviously it would be better if he spent the money, even if he spent it in drink or gambling.
|
||||||
|
|
||||||
|
But, I shall be told, the case is quite different when savings are invested in industrial enterprises. When such enterprises succeed, and produce something useful, this may be conceded. In these days, however, no one will deny that most enterprises fail. That means that a large amount of human labor, which might have been devoted to producing something that could be enjoyed, was expended on producing machines which, when produced, lay idle and did no good to anyone. The man who invests his savings in a concern that goes bankrupt is therefore injuring others as well as himself. If he spent his money, say, in giving parties for his friends, they (we may hope) would get pleasure, and so would all those upon whom he spent money, such as the butcher, the baker, and the bootlegger. But if he spends it (let us say) upon laying down rails for surface card in some place where surface cars turn out not to be wanted, he has diverted a mass of labor into channels where it gives pleasure to no one. Nevertheless, when he becomes poor through failure of his investment he will be regarded as a victim of undeserved misfortune, whereas the gay spendthrift, who has spent his money philanthropically, will be despised as a fool and a frivolous person.
|
||||||
|
|
||||||
|
All this is only preliminary. I want to say, in all seriousness, that a great deal of harm is being done in the modern world by belief in the virtuousness of work, and that the road to happiness and prosperity lies in an organized diminution of work.
|
||||||
|
|
||||||
|
First of all: what is work? Work is of two kinds: first, altering the position of matter at or near the earth's surface relatively to other such matter; second, telling other people to do so. The first kind is unpleasant and ill paid; the second is pleasant and highly paid. The second kind is capable of indefinite extension: there are not only those who give orders, but those who give advice as to what orders should be given. Usually two opposite kinds of advice are given simultaneously by two organized bodies of men; this is called politics. The skill required for this kind of work is not knowledge of the subjects as to which advice is given, but knowledge of the art of persuasive speaking and writing, i.e. of advertising.
|
||||||
|
|
||||||
|
Throughout Europe, though not in America, there is a third class of men, more respected than either of the classes of workers. There are men who, through ownership of land, are able to make others pay for the privilege of being allowed to exist and to work. These landowners are idle, and I might therefore be expected to praise them. Unfortunately, their idleness is only rendered possible by the industry of others; indeed their desire for comfortable idleness is historically the source of the whole gospel of work. The last thing they have ever wished is that others should follow their example.
|
||||||
|
|
||||||
|
From the beginning of civilization until the Industrial Revolution, a man could, as a rule, produce by hard work little more than was required for the subsistence of himself and his family, although his wife worked at least as hard as he did, and his children added their labor as soon as they were old enough to do so. The small surplus above bare necessaries was not left to those who produced it, but was appropriated by warriors and priests. In times of famine there was no surplus; the warriors and priests, however, still secured as much as at other times, with the result that many of the workers died of hunger. This system persisted in Russia until 1917 [1], and still persists in the East; in England, in spite of the Industrial Revolution, it remained in full force throughout the Napoleonic wars, and until a hundred years ago, when the new class of manufacturers acquired power. In America, the system came to an end with the Revolution, except in the South, where it persisted until the Civil War. A system which lasted so long and ended so recently has naturally left a profound impress upon men's thoughts and opinions. Much that we take for granted about the desirability of work is derived from this system, and, being pre-industrial, is not adapted to the modern world. Modern technique has made it possible for leisure, within limits, to be not the prerogative of small privileged classes, but a right evenly distributed throughout the community. The morality of work is the morality of slaves, and the modern world has no need of slavery.
|
||||||
|
|
||||||
|
It is obvious that, in primitive communities, peasants, left to themselves, would not have parted with the slender surplus upon which the warriors and priests subsisted, but would have either produced less or consumed more. At first, sheer force compelled them to produce and part with the surplus. Gradually, however, it was found possible to induce many of them to accept an ethic according to which it was their duty to work hard, although part of their work went to support others in idleness. By this means the amount of compulsion required was lessened, and the expenses of government were diminished. To this day, 99 per cent of British wage-earners would be genuinely shocked if it were proposed that the King should not have a larger income than a working man. The conception of duty, speaking historically, has been a means used by the holders of power to induce others to live for the interests of their masters rather than for their own. Of course the holders of power conceal this fact from themselves by managing to believe that their interests are identical with the larger interests of humanity. Sometimes this is true; Athenian slave-owners, for instance, employed part of their leisure in making a permanent contribution to civilization which would have been impossible under a just economic system. Leisure is essential to civilization, and in former times leisure for the few was only rendered possible by the labors of the many. But their labors were valuable, not because work is good, but because leisure is good. And with modern technique it would be possible to distribute leisure justly without injury to civilization.
|
||||||
|
|
||||||
|
Modern technique has made it possible to diminish enormously the amount of labor required to secure the necessaries of life for everyone. This was made obvious during the war. At that time all the men in the armed forces, and all the men and women engaged in the production of munitions, all the men and women engaged in spying, war propaganda, or Government offices connected with the war, were withdrawn from productive occupations. In spite of this, the general level of well-being among unskilled wage-earners on the side of the Allies was higher than before or since. The significance of this fact was concealed by finance: borrowing made it appear as if the future was nourishing the present. But that, of course, would have been impossible; a man cannot eat a loaf of bread that does not yet exist. The war showed conclusively that, by the scientific organization of production, it is possible to keep modern populations in fair comfort on a small part of the working capacity of the modern world. If, at the end of the war, the scientific organization, which had been created in order to liberate men for fighting and munition work, had been preserved, and the hours of the week had been cut down to four, all would have been well. Instead of that the old chaos was restored, those whose work was demanded were made to work long hours, and the rest were left to starve as unemployed. Why? Because work is a duty, and a man should not receive wages in proportion to what he has produced, but in proportion to his virtue as exemplified by his industry.
|
||||||
|
|
||||||
|
This is the morality of the Slave State, applied in circumstances totally unlike those in which it arose. No wonder the result has been disastrous. Let us take an illustration. Suppose that, at a given moment, a certain number of people are engaged in the manufacture of pins. They make as many pins as the world needs, working (say) eight hours a day. Someone makes an invention by which the same number of men can make twice as many pins: pins are already so cheap that hardly any more will be bought at a lower price. In a sensible world, everybody concerned in the manufacturing of pins would take to working four hours instead of eight, and everything else would go on as before. But in the actual world this would be thought demoralizing. The men still work eight hours, there are too many pins, some employers go bankrupt, and half the men previously concerned in making pins are thrown out of work. There is, in the end, just as much leisure as on the other plan, but half the men are totally idle while half are still overworked. In this way, it is insured that the unavoidable leisure shall cause misery all round instead of being a universal source of happiness. Can anything more insane be imagined?
|
||||||
|
|
||||||
|
The idea that the poor should have leisure has always been shocking to the rich. In England, in the early nineteenth century, fifteen hours was the ordinary day's work for a man; children sometimes did as much, and very commonly did twelve hours a day. When meddlesome busybodies suggested that perhaps these hours were rather long, they were told that work kept adults from drink and children from mischief. When I was a child, shortly after urban working men had acquired the vote, certain public holidays were established by law, to the great indignation of the upper classes. I remember hearing an old Duchess say: 'What do the poor want with holidays? They ought to work.' People nowadays are less frank, but the sentiment persists, and is the source of much of our economic confusion.
|
||||||
|
|
||||||
|
Let us, for a moment, consider the ethics of work frankly, without superstition. Every human being, of necessity, consumes, in the course of his life, a certain amount of the produce of human labor. Assuming, as we may, that labor is on the whole disagreeable, it is unjust that a man should consume more than he produces. Of course he may provide services rather than commodities, like a medical man, for example; but he should provide something in return for his board and lodging. to this extent, the duty of work must be admitted, but to this extent only.
|
||||||
|
|
||||||
|
I shall not dwell upon the fact that, in all modern societies outside the USSR, many people escape even this minimum amount of work, namely all those who inherit money and all those who marry money. I do not think the fact that these people are allowed to be idle is nearly so harmful as the fact that wage-earners are expected to overwork or starve.
|
||||||
|
|
||||||
|
If the ordinary wage-earner worked four hours a day, there would be enough for everybody and no unemployment -- assuming a certain very moderate amount of sensible organization. This idea shocks the well-to-do, because they are convinced that the poor would not know how to use so much leisure. In America men often work long hours even when they are well off; such men, naturally, are indignant at the idea of leisure for wage-earners, except as the grim punishment of unemployment; in fact, they dislike leisure even for their sons. Oddly enough, while they wish their sons to work so hard as to have no time to be civilized, they do not mind their wives and daughters having no work at all. the snobbish admiration of uselessness, which, in an aristocratic society, extends to both sexes, is, under a plutocracy, confined to women; this, however, does not make it any more in agreement with common sense.
|
||||||
|
|
||||||
|
The wise use of leisure, it must be conceded, is a product of civilization and education. A man who has worked long hours all his life will become bored if he becomes suddenly idle. But without a considerable amount of leisure a man is cut off from many of the best things. There is no longer any reason why the bulk of the population should suffer this deprivation; only a foolish asceticism, usually vicarious, makes us continue to insist on work in excessive quantities now that the need no longer exists.
|
||||||
|
|
||||||
|
In the new creed which controls the government of Russia, while there is much that is very different from the traditional teaching of the West, there are some things that are quite unchanged. The attitude of the governing classes, and especially of those who conduct educational propaganda, on the subject of the dignity of labor, is almost exactly that which the governing classes of the world have always preached to what were called the 'honest poor'. Industry, sobriety, willingness to work long hours for distant advantages, even submissiveness to authority, all these reappear; moreover authority still represents the will of the Ruler of the Universe, Who, however, is now called by a new name, Dialectical Materialism.
|
||||||
|
|
||||||
|
The victory of the proletariat in Russia has some points in common with the victory of the feminists in some other countries. For ages, men had conceded the superior saintliness of women, and had consoled women for their inferiority by maintaining that saintliness is more desirable than power. At last the feminists decided that they would have both, since the pioneers among them believed all that the men had told them about the desirability of virtue, but not what they had told them about the worthlessness of political power. A similar thing has happened in Russia as regards manual work. For ages, the rich and their sycophants have written in praise of 'honest toil', have praised the simple life, have professed a religion which teaches that the poor are much more likely to go to heaven than the rich, and in general have tried to make manual workers believe that there is some special nobility about altering the position of matter in space, just as men tried to make women believe that they derived some special nobility from their sexual enslavement. In Russia, all this teaching about the excellence of manual work has been taken seriously, with the result that the manual worker is more honored than anyone else. What are, in essence, revivalist appeals are made, but not for the old purposes: they are made to secure shock workers for special tasks. Manual work is the ideal which is held before the young, and is the basis of all ethical teaching.
|
||||||
|
|
||||||
|
For the present, possibly, this is all to the good. A large country, full of natural resources, awaits development, and has has to be developed with very little use of credit. In these circumstances, hard work is necessary, and is likely to bring a great reward. But what will happen when the point has been reached where everybody could be comfortable without working long hours?
|
||||||
|
|
||||||
|
In the West, we have various ways of dealing with this problem. We have no attempt at economic justice, so that a large proportion of the total produce goes to a small minority of the population, many of whom do no work at all. Owing to the absence of any central control over production, we produce hosts of things that are not wanted. We keep a large percentage of the working population idle, because we can dispense with their labor by making the others overwork. When all these methods prove inadequate, we have a war: we cause a number of people to manufacture high explosives, and a number of others to explode them, as if we were children who had just discovered fireworks. By a combination of all these devices we manage, though with difficulty, to keep alive the notion that a great deal of severe manual work must be the lot of the average man.
|
||||||
|
|
||||||
|
In Russia, owing to more economic justice and central control over production, the problem will have to be differently solved. the rational solution would be, as soon as the necessaries and elementary comforts can be provided for all, to reduce the hours of labor gradually, allowing a popular vote to decide, at each stage, whether more leisure or more goods were to be preferred. But, having taught the supreme virtue of hard work, it is difficult to see how the authorities can aim at a paradise in which there will be much leisure and little work. It seems more likely that they will find continually fresh schemes, by which present leisure is to be sacrificed to future productivity. I read recently of an ingenious plan put forward by Russian engineers, for making the White Sea and the northern coasts of Siberia warm, by putting a dam across the Kara Sea. An admirable project, but liable to postpone proletarian comfort for a generation, while the nobility of toil is being displayed amid the ice-fields and snowstorms of the Arctic Ocean. This sort of thing, if it happens, will be the result of regarding the virtue of hard work as an end in itself, rather than as a means to a state of affairs in which it is no longer needed.
|
||||||
|
|
||||||
|
The fact is that moving matter about, while a certain amount of it is necessary to our existence, is emphatically not one of the ends of human life. If it were, we should have to consider every navvy superior to Shakespeare. We have been misled in this matter by two causes. One is the necessity of keeping the poor contented, which has led the rich, for thousands of years, to preach the dignity of labor, while taking care themselves to remain undignified in this respect. The other is the new pleasure in mechanism, which makes us delight in the astonishingly clever changes that we can produce on the earth's surface. Neither of these motives makes any great appeal to the actual worker. If you ask him what he thinks the best part of his life, he is not likely to say: 'I enjoy manual work because it makes me feel that I am fulfilling man's noblest task, and because I like to think how much man can transform his planet. It is true that my body demands periods of rest, which I have to fill in as best I may, but I am never so happy as when the morning comes and I can return to the toil from which my contentment springs.' I have never heard working men say this sort of thing. They consider work, as it should be considered, a necessary means to a livelihood, and it is from their leisure that they derive whatever happiness they may enjoy.
|
||||||
|
|
||||||
|
It will be said that, while a little leisure is pleasant, men would not know how to fill their days if they had only four hours of work out of the twenty-four. In so far as this is true in the modern world, it is a condemnation of our civilization; it would not have been true at any earlier period. There was formerly a capacity for light-heartedness and play which has been to some extent inhibited by the cult of efficiency. The modern man thinks that everything ought to be done for the sake of something else, and never for its own sake. Serious-minded persons, for example, are continually condemning the habit of going to the cinema, and telling us that it leads the young into crime. But all the work that goes to producing a cinema is respectable, because it is work, and because it brings a money profit. The notion that the desirable activities are those that bring a profit has made everything topsy-turvy. The butcher who provides you with meat and the baker who provides you with bread are praiseworthy, because they are making money; but when you enjoy the food they have provided, you are merely frivolous, unless you eat only to get strength for your work. Broadly speaking, it is held that getting money is good and spending money is bad. Seeing that they are two sides of one transaction, this is absurd; one might as well maintain that keys are good, but keyholes are bad. Whatever merit there may be in the production of goods must be entirely derivative from the advantage to be obtained by consuming them. The individual, in our society, works for profit; but the social purpose of his work lies in the consumption of what he produces. It is this divorce between the individual and the social purpose of production that makes it so difficult for men to think clearly in a world in which profit-making is the incentive to industry. We think too much of production, and too little of consumption. One result is that we attach too little importance to enjoyment and simple happiness, and that we do not judge production by the pleasure that it gives to the consumer.
|
||||||
|
|
||||||
|
When I suggest that working hours should be reduced to four, I am not meaning to imply that all the remaining time should necessarily be spent in pure frivolity. I mean that four hours' work a day should entitle a man to the necessities and elementary comforts of life, and that the rest of his time should be his to use as he might see fit. It is an essential part of any such social system that education should be carried further than it usually is at present, and should aim, in part, at providing tastes which would enable a man to use leisure intelligently. I am not thinking mainly of the sort of things that would be considered 'highbrow'. Peasant dances have died out except in remote rural areas, but the impulses which caused them to be cultivated must still exist in human nature. The pleasures of urban populations have become mainly passive: seeing cinemas, watching football matches, listening to the radio, and so on. This results from the fact that their active energies are fully taken up with work; if they had more leisure, they would again enjoy pleasures in which they took an active part.
|
||||||
|
|
||||||
|
In the past, there was a small leisure class and a larger working class. The leisure class enjoyed advantages for which there was no basis in social justice; this necessarily made it oppressive, limited its sympathies, and caused it to invent theories by which to justify its privileges. These facts greatly diminished its excellence, but in spite of this drawback it contributed nearly the whole of what we call civilization. It cultivated the arts and discovered the sciences; it wrote the books, invented the philosophies, and refined social relations. Even the liberation of the oppressed has usually been inaugurated from above. Without the leisure class, mankind would never have emerged from barbarism.
|
||||||
|
|
||||||
|
The method of a leisure class without duties was, however, extraordinarily wasteful. None of the members of the class had to be taught to be industrious, and the class as a whole was not exceptionally intelligent. The class might produce one Darwin, but against him had to be set tens of thousands of country gentlemen who never thought of anything more intelligent than fox-hunting and punishing poachers. At present, the universities are supposed to provide, in a more systematic way, what the leisure class provided accidentally and as a by-product. This is a great improvement, but it has certain drawbacks. University life is so different from life in the world at large that men who live in academic milieu tend to be unaware of the preoccupations and problems of ordinary men and women; moreover their ways of expressing themselves are usually such as to rob their opinions of the influence that they ought to have upon the general public. Another disadvantage is that in universities studies are organized, and the man who thinks of some original line of research is likely to be discouraged. Academic institutions, therefore, useful as they are, are not adequate guardians of the interests of civilization in a world where everyone outside their walls is too busy for unutilitarian pursuits.
|
||||||
|
|
||||||
|
In a world where no one is compelled to work more than four hours a day, every person possessed of scientific curiosity will be able to indulge it, and every painter will be able to paint without starving, however excellent his pictures may be. Young writers will not be obliged to draw attention to themselves by sensational pot-boilers, with a view to acquiring the economic independence needed for monumental works, for which, when the time at last comes, they will have lost the taste and capacity. Men who, in their professional work, have become interested in some phase of economics or government, will be able to develop their ideas without the academic detachment that makes the work of university economists often seem lacking in reality. Medical men will have the time to learn about the progress of medicine, teachers will not be exasperatedly struggling to teach by routine methods things which they learnt in their youth, which may, in the interval, have been proved to be untrue.
|
||||||
|
|
||||||
|
Above all, there will be happiness and joy of life, instead of frayed nerves, weariness, and dyspepsia. The work exacted will be enough to make leisure delightful, but not enough to produce exhaustion. Since men will not be tired in their spare time, they will not demand only such amusements as are passive and vapid. At least one per cent will probably devote the time not spent in professional work to pursuits of some public importance, and, since they will not depend upon these pursuits for their livelihood, their originality will be unhampered, and there will be no need to conform to the standards set by elderly pundits. But it is not only in these exceptional cases that the advantages of leisure will appear. Ordinary men and women, having the opportunity of a happy life, will become more kindly and less persecuting and less inclined to view others with suspicion. The taste for war will die out, partly for this reason, and partly because it will involve long and severe work for all. Good nature is, of all moral qualities, the one that the world needs most, and good nature is the result of ease and security, not of a life of arduous struggle. Modern methods of production have given us the possibility of ease and security for all; we have chosen, instead, to have overwork for some and starvation for others. Hitherto we have continued to be as energetic as we were before there were machines; in this we have been foolish, but there is no reason to go on being foolish forever.
|
||||||
|
|
||||||
|
[1] Since then, members of the Communist Party have succeeded to this privilege of the warriors and priests.
|
||||||
31
node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/test/wrap.js
generated
vendored
Normal file
31
node_modules/handlebars/node_modules/optimist/node_modules/wordwrap/test/wrap.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
var assert = require('assert');
|
||||||
|
var wordwrap = require('wordwrap');
|
||||||
|
|
||||||
|
var fs = require('fs');
|
||||||
|
var idleness = fs.readFileSync(__dirname + '/idleness.txt', 'utf8');
|
||||||
|
|
||||||
|
exports.stop80 = function () {
|
||||||
|
var lines = wordwrap(80)(idleness).split(/\n/);
|
||||||
|
var words = idleness.split(/\s+/);
|
||||||
|
|
||||||
|
lines.forEach(function (line) {
|
||||||
|
assert.ok(line.length <= 80, 'line > 80 columns');
|
||||||
|
var chunks = line.match(/\S/) ? line.split(/\s+/) : [];
|
||||||
|
assert.deepEqual(chunks, words.splice(0, chunks.length));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.start20stop60 = function () {
|
||||||
|
var lines = wordwrap(20, 100)(idleness).split(/\n/);
|
||||||
|
var words = idleness.split(/\s+/);
|
||||||
|
|
||||||
|
lines.forEach(function (line) {
|
||||||
|
assert.ok(line.length <= 100, 'line > 100 columns');
|
||||||
|
var chunks = line
|
||||||
|
.split(/\s+/)
|
||||||
|
.filter(function (x) { return x.match(/\S/) })
|
||||||
|
;
|
||||||
|
assert.deepEqual(chunks, words.splice(0, chunks.length));
|
||||||
|
assert.deepEqual(line.slice(0, 20), new Array(20 + 1).join(' '));
|
||||||
|
});
|
||||||
|
};
|
||||||
43
node_modules/handlebars/node_modules/optimist/package.json
generated
vendored
Normal file
43
node_modules/handlebars/node_modules/optimist/package.json
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
"name" : "optimist",
|
||||||
|
"version" : "0.3.1",
|
||||||
|
"description" : "Light-weight option parsing with an argv hash. No optstrings attached.",
|
||||||
|
"main" : "./index.js",
|
||||||
|
"directories" : {
|
||||||
|
"lib" : ".",
|
||||||
|
"test" : "test",
|
||||||
|
"example" : "examples"
|
||||||
|
},
|
||||||
|
"dependencies" : {
|
||||||
|
"wordwrap" : ">=0.0.1 <0.1.0"
|
||||||
|
},
|
||||||
|
"devDependencies" : {
|
||||||
|
"hashish": "0.0.x",
|
||||||
|
"expresso" : "0.7.x"
|
||||||
|
},
|
||||||
|
"scripts" : {
|
||||||
|
"test" : "expresso"
|
||||||
|
},
|
||||||
|
"repository" : {
|
||||||
|
"type" : "git",
|
||||||
|
"url" : "http://github.com/substack/node-optimist.git"
|
||||||
|
},
|
||||||
|
"keywords" : [
|
||||||
|
"argument",
|
||||||
|
"args",
|
||||||
|
"option",
|
||||||
|
"parser",
|
||||||
|
"parsing",
|
||||||
|
"cli",
|
||||||
|
"command"
|
||||||
|
],
|
||||||
|
"author" : {
|
||||||
|
"name" : "James Halliday",
|
||||||
|
"email" : "mail@substack.net",
|
||||||
|
"url" : "http://substack.net"
|
||||||
|
},
|
||||||
|
"license" : "MIT/X11",
|
||||||
|
"engine" : {
|
||||||
|
"node" : ">=0.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
66
node_modules/handlebars/node_modules/optimist/test/_.js
generated
vendored
Normal file
66
node_modules/handlebars/node_modules/optimist/test/_.js
generated
vendored
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
var spawn = require('child_process').spawn;
|
||||||
|
var assert = require('assert');
|
||||||
|
|
||||||
|
exports.dotSlashEmpty = function () {
|
||||||
|
testCmd('./bin.js', []);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.dotSlashArgs = function () {
|
||||||
|
testCmd('./bin.js', [ 'a', 'b', 'c' ]);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.nodeEmpty = function () {
|
||||||
|
testCmd('node bin.js', []);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.nodeArgs = function () {
|
||||||
|
testCmd('node bin.js', [ 'x', 'y', 'z' ]);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.whichNodeEmpty = function () {
|
||||||
|
var which = spawn('which', ['node']);
|
||||||
|
|
||||||
|
which.stdout.on('data', function (buf) {
|
||||||
|
testCmd(buf.toString().trim() + ' bin.js', []);
|
||||||
|
});
|
||||||
|
|
||||||
|
which.stderr.on('data', function (err) {
|
||||||
|
assert.fail(err.toString());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.whichNodeArgs = function () {
|
||||||
|
var which = spawn('which', ['node']);
|
||||||
|
|
||||||
|
which.stdout.on('data', function (buf) {
|
||||||
|
testCmd(buf.toString().trim() + ' bin.js', [ 'q', 'r' ]);
|
||||||
|
});
|
||||||
|
|
||||||
|
which.stderr.on('data', function (err) {
|
||||||
|
assert.fail(err.toString());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
function testCmd (cmd, args) {
|
||||||
|
var to = setTimeout(function () {
|
||||||
|
assert.fail('Never got stdout data.')
|
||||||
|
}, 5000);
|
||||||
|
|
||||||
|
var oldDir = process.cwd();
|
||||||
|
process.chdir(__dirname + '/_');
|
||||||
|
|
||||||
|
var cmds = cmd.split(' ');
|
||||||
|
|
||||||
|
var bin = spawn(cmds[0], cmds.slice(1).concat(args.map(String)));
|
||||||
|
process.chdir(oldDir);
|
||||||
|
|
||||||
|
bin.stderr.on('data', function (err) {
|
||||||
|
assert.fail(err.toString());
|
||||||
|
});
|
||||||
|
|
||||||
|
bin.stdout.on('data', function (buf) {
|
||||||
|
clearTimeout(to);
|
||||||
|
var _ = JSON.parse(buf.toString());
|
||||||
|
assert.eql(_.map(String), args.map(String));
|
||||||
|
});
|
||||||
|
}
|
||||||
2
node_modules/handlebars/node_modules/optimist/test/_/argv.js
generated
vendored
Normal file
2
node_modules/handlebars/node_modules/optimist/test/_/argv.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
console.log(JSON.stringify(process.argv));
|
||||||
3
node_modules/handlebars/node_modules/optimist/test/_/bin.js
generated
vendored
Executable file
3
node_modules/handlebars/node_modules/optimist/test/_/bin.js
generated
vendored
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
var argv = require('../../index').argv
|
||||||
|
console.log(JSON.stringify(argv._));
|
||||||
322
node_modules/handlebars/node_modules/optimist/test/parse.js
generated
vendored
Normal file
322
node_modules/handlebars/node_modules/optimist/test/parse.js
generated
vendored
Normal file
@@ -0,0 +1,322 @@
|
|||||||
|
var optimist = require('../index');
|
||||||
|
var assert = require('assert');
|
||||||
|
var path = require('path');
|
||||||
|
|
||||||
|
var localExpresso = path.normalize(
|
||||||
|
__dirname + '/../node_modules/.bin/expresso'
|
||||||
|
);
|
||||||
|
|
||||||
|
var expresso = process.argv[1] === localExpresso
|
||||||
|
? 'node ./node_modules/.bin/expresso'
|
||||||
|
: 'expresso'
|
||||||
|
;
|
||||||
|
|
||||||
|
exports['short boolean'] = function () {
|
||||||
|
var parse = optimist.parse([ '-b' ]);
|
||||||
|
assert.eql(parse, { b : true, _ : [], $0 : expresso });
|
||||||
|
assert.eql(typeof parse.b, 'boolean');
|
||||||
|
};
|
||||||
|
|
||||||
|
exports['long boolean'] = function () {
|
||||||
|
assert.eql(
|
||||||
|
optimist.parse([ '--bool' ]),
|
||||||
|
{ bool : true, _ : [], $0 : expresso }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.bare = function () {
|
||||||
|
assert.eql(
|
||||||
|
optimist.parse([ 'foo', 'bar', 'baz' ]),
|
||||||
|
{ _ : [ 'foo', 'bar', 'baz' ], $0 : expresso }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports['short group'] = function () {
|
||||||
|
assert.eql(
|
||||||
|
optimist.parse([ '-cats' ]),
|
||||||
|
{ c : true, a : true, t : true, s : true, _ : [], $0 : expresso }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports['short group next'] = function () {
|
||||||
|
assert.eql(
|
||||||
|
optimist.parse([ '-cats', 'meow' ]),
|
||||||
|
{ c : true, a : true, t : true, s : 'meow', _ : [], $0 : expresso }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports['short capture'] = function () {
|
||||||
|
assert.eql(
|
||||||
|
optimist.parse([ '-h', 'localhost' ]),
|
||||||
|
{ h : 'localhost', _ : [], $0 : expresso }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports['short captures'] = function () {
|
||||||
|
assert.eql(
|
||||||
|
optimist.parse([ '-h', 'localhost', '-p', '555' ]),
|
||||||
|
{ h : 'localhost', p : 555, _ : [], $0 : expresso }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports['long capture sp'] = function () {
|
||||||
|
assert.eql(
|
||||||
|
optimist.parse([ '--pow', 'xixxle' ]),
|
||||||
|
{ pow : 'xixxle', _ : [], $0 : expresso }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports['long capture eq'] = function () {
|
||||||
|
assert.eql(
|
||||||
|
optimist.parse([ '--pow=xixxle' ]),
|
||||||
|
{ pow : 'xixxle', _ : [], $0 : expresso }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports['long captures sp'] = function () {
|
||||||
|
assert.eql(
|
||||||
|
optimist.parse([ '--host', 'localhost', '--port', '555' ]),
|
||||||
|
{ host : 'localhost', port : 555, _ : [], $0 : expresso }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports['long captures eq'] = function () {
|
||||||
|
assert.eql(
|
||||||
|
optimist.parse([ '--host=localhost', '--port=555' ]),
|
||||||
|
{ host : 'localhost', port : 555, _ : [], $0 : expresso }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports['mixed short bool and capture'] = function () {
|
||||||
|
assert.eql(
|
||||||
|
optimist.parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]),
|
||||||
|
{
|
||||||
|
f : true, p : 555, h : 'localhost',
|
||||||
|
_ : [ 'script.js' ], $0 : expresso,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports['short and long'] = function () {
|
||||||
|
assert.eql(
|
||||||
|
optimist.parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]),
|
||||||
|
{
|
||||||
|
f : true, p : 555, h : 'localhost',
|
||||||
|
_ : [ 'script.js' ], $0 : expresso,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.no = function () {
|
||||||
|
assert.eql(
|
||||||
|
optimist.parse([ '--no-moo' ]),
|
||||||
|
{ moo : false, _ : [], $0 : expresso }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.multi = function () {
|
||||||
|
assert.eql(
|
||||||
|
optimist.parse([ '-v', 'a', '-v', 'b', '-v', 'c' ]),
|
||||||
|
{ v : ['a','b','c'], _ : [], $0 : expresso }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.comprehensive = function () {
|
||||||
|
assert.eql(
|
||||||
|
optimist.parse([
|
||||||
|
'--name=meowmers', 'bare', '-cats', 'woo',
|
||||||
|
'-h', 'awesome', '--multi=quux',
|
||||||
|
'--key', 'value',
|
||||||
|
'-b', '--bool', '--no-meep', '--multi=baz',
|
||||||
|
'--', '--not-a-flag', 'eek'
|
||||||
|
]),
|
||||||
|
{
|
||||||
|
c : true,
|
||||||
|
a : true,
|
||||||
|
t : true,
|
||||||
|
s : 'woo',
|
||||||
|
h : 'awesome',
|
||||||
|
b : true,
|
||||||
|
bool : true,
|
||||||
|
key : 'value',
|
||||||
|
multi : [ 'quux', 'baz' ],
|
||||||
|
meep : false,
|
||||||
|
name : 'meowmers',
|
||||||
|
_ : [ 'bare', '--not-a-flag', 'eek' ],
|
||||||
|
$0 : expresso
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.nums = function () {
|
||||||
|
var argv = optimist.parse([
|
||||||
|
'-x', '1234',
|
||||||
|
'-y', '5.67',
|
||||||
|
'-z', '1e7',
|
||||||
|
'-w', '10f',
|
||||||
|
'--hex', '0xdeadbeef',
|
||||||
|
'789',
|
||||||
|
]);
|
||||||
|
assert.eql(argv, {
|
||||||
|
x : 1234,
|
||||||
|
y : 5.67,
|
||||||
|
z : 1e7,
|
||||||
|
w : '10f',
|
||||||
|
hex : 0xdeadbeef,
|
||||||
|
_ : [ 789 ],
|
||||||
|
$0 : expresso
|
||||||
|
});
|
||||||
|
assert.eql(typeof argv.x, 'number');
|
||||||
|
assert.eql(typeof argv.y, 'number');
|
||||||
|
assert.eql(typeof argv.z, 'number');
|
||||||
|
assert.eql(typeof argv.w, 'string');
|
||||||
|
assert.eql(typeof argv.hex, 'number');
|
||||||
|
assert.eql(typeof argv._[0], 'number');
|
||||||
|
};
|
||||||
|
|
||||||
|
exports['flag boolean'] = function () {
|
||||||
|
var parse = optimist([ '-t', 'moo' ]).boolean(['t']).argv;
|
||||||
|
assert.eql(parse, { t : true, _ : [ 'moo' ], $0 : expresso });
|
||||||
|
assert.eql(typeof parse.t, 'boolean');
|
||||||
|
};
|
||||||
|
|
||||||
|
exports['flag boolean value'] = function () {
|
||||||
|
var parse = optimist(['--verbose', 'false', 'moo', '-t', 'true'])
|
||||||
|
.boolean(['t', 'verbose']).default('verbose', true).argv;
|
||||||
|
|
||||||
|
assert.eql(parse, {
|
||||||
|
verbose: false,
|
||||||
|
t: true,
|
||||||
|
_: ['moo'],
|
||||||
|
$0 : expresso
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.eql(typeof parse.verbose, 'boolean');
|
||||||
|
assert.eql(typeof parse.t, 'boolean');
|
||||||
|
};
|
||||||
|
|
||||||
|
exports['flag boolean default false'] = function () {
|
||||||
|
var parse = optimist(['moo'])
|
||||||
|
.boolean(['t', 'verbose'])
|
||||||
|
.default('verbose', false)
|
||||||
|
.default('t', false).argv;
|
||||||
|
|
||||||
|
assert.eql(parse, {
|
||||||
|
verbose: false,
|
||||||
|
t: false,
|
||||||
|
_: ['moo'],
|
||||||
|
$0 : expresso
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.eql(typeof parse.verbose, 'boolean');
|
||||||
|
assert.eql(typeof parse.t, 'boolean');
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
exports['boolean groups'] = function () {
|
||||||
|
var parse = optimist([ '-x', '-z', 'one', 'two', 'three' ])
|
||||||
|
.boolean(['x','y','z']).argv;
|
||||||
|
|
||||||
|
assert.eql(parse, {
|
||||||
|
x : true,
|
||||||
|
y : false,
|
||||||
|
z : true,
|
||||||
|
_ : [ 'one', 'two', 'three' ],
|
||||||
|
$0 : expresso
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.eql(typeof parse.x, 'boolean');
|
||||||
|
assert.eql(typeof parse.y, 'boolean');
|
||||||
|
assert.eql(typeof parse.z, 'boolean');
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.strings = function () {
|
||||||
|
var s = optimist([ '-s', '0001234' ]).string('s').argv.s;
|
||||||
|
assert.eql(s, '0001234');
|
||||||
|
assert.eql(typeof s, 'string');
|
||||||
|
|
||||||
|
var x = optimist([ '-x', '56' ]).string('x').argv.x;
|
||||||
|
assert.eql(x, '56');
|
||||||
|
assert.eql(typeof x, 'string');
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.stringArgs = function () {
|
||||||
|
var s = optimist([ ' ', ' ' ]).string('_').argv._;
|
||||||
|
assert.eql(s.length, 2);
|
||||||
|
assert.eql(typeof s[0], 'string');
|
||||||
|
assert.eql(s[0], ' ');
|
||||||
|
assert.eql(typeof s[1], 'string');
|
||||||
|
assert.eql(s[1], ' ');
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.slashBreak = function () {
|
||||||
|
assert.eql(
|
||||||
|
optimist.parse([ '-I/foo/bar/baz' ]),
|
||||||
|
{ I : '/foo/bar/baz', _ : [], $0 : expresso }
|
||||||
|
);
|
||||||
|
assert.eql(
|
||||||
|
optimist.parse([ '-xyz/foo/bar/baz' ]),
|
||||||
|
{ x : true, y : true, z : '/foo/bar/baz', _ : [], $0 : expresso }
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.alias = function () {
|
||||||
|
var argv = optimist([ '-f', '11', '--zoom', '55' ])
|
||||||
|
.alias('z', 'zoom')
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
assert.equal(argv.zoom, 55);
|
||||||
|
assert.equal(argv.z, argv.zoom);
|
||||||
|
assert.equal(argv.f, 11);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.multiAlias = function () {
|
||||||
|
var argv = optimist([ '-f', '11', '--zoom', '55' ])
|
||||||
|
.alias('z', [ 'zm', 'zoom' ])
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
assert.equal(argv.zoom, 55);
|
||||||
|
assert.equal(argv.z, argv.zoom);
|
||||||
|
assert.equal(argv.z, argv.zm);
|
||||||
|
assert.equal(argv.f, 11);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports['boolean default true'] = function () {
|
||||||
|
var argv = optimist.options({
|
||||||
|
sometrue: {
|
||||||
|
boolean: true,
|
||||||
|
default: true
|
||||||
|
}
|
||||||
|
}).argv;
|
||||||
|
|
||||||
|
assert.equal(argv.sometrue, true);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports['boolean default false'] = function () {
|
||||||
|
var argv = optimist.options({
|
||||||
|
somefalse: {
|
||||||
|
boolean: true,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
|
}).argv;
|
||||||
|
|
||||||
|
assert.equal(argv.somefalse, false);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports['nested dotted objects'] = function () {
|
||||||
|
var argv = optimist([
|
||||||
|
'--foo.bar', '3', '--foo.baz', '4',
|
||||||
|
'--foo.quux.quibble', '5', '--foo.quux.o_O',
|
||||||
|
'--beep.boop'
|
||||||
|
]).argv;
|
||||||
|
|
||||||
|
assert.deepEqual(argv.foo, {
|
||||||
|
bar : 3,
|
||||||
|
baz : 4,
|
||||||
|
quux : {
|
||||||
|
quibble : 5,
|
||||||
|
o_O : true
|
||||||
|
},
|
||||||
|
});
|
||||||
|
assert.deepEqual(argv.beep, { boop : true });
|
||||||
|
};
|
||||||
256
node_modules/handlebars/node_modules/optimist/test/usage.js
generated
vendored
Normal file
256
node_modules/handlebars/node_modules/optimist/test/usage.js
generated
vendored
Normal file
@@ -0,0 +1,256 @@
|
|||||||
|
var Hash = require('hashish');
|
||||||
|
var optimist = require('../index');
|
||||||
|
var assert = require('assert');
|
||||||
|
|
||||||
|
exports.usageFail = function () {
|
||||||
|
var r = checkUsage(function () {
|
||||||
|
return optimist('-x 10 -z 20'.split(' '))
|
||||||
|
.usage('Usage: $0 -x NUM -y NUM')
|
||||||
|
.demand(['x','y'])
|
||||||
|
.argv;
|
||||||
|
});
|
||||||
|
assert.deepEqual(
|
||||||
|
r.result,
|
||||||
|
{ x : 10, z : 20, _ : [], $0 : './usage' }
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
r.errors.join('\n').split(/\n+/),
|
||||||
|
[
|
||||||
|
'Usage: ./usage -x NUM -y NUM',
|
||||||
|
'Options:',
|
||||||
|
' -x [required]',
|
||||||
|
' -y [required]',
|
||||||
|
'Missing required arguments: y',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
assert.deepEqual(r.logs, []);
|
||||||
|
assert.ok(r.exit);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.usagePass = function () {
|
||||||
|
var r = checkUsage(function () {
|
||||||
|
return optimist('-x 10 -y 20'.split(' '))
|
||||||
|
.usage('Usage: $0 -x NUM -y NUM')
|
||||||
|
.demand(['x','y'])
|
||||||
|
.argv;
|
||||||
|
});
|
||||||
|
assert.deepEqual(r, {
|
||||||
|
result : { x : 10, y : 20, _ : [], $0 : './usage' },
|
||||||
|
errors : [],
|
||||||
|
logs : [],
|
||||||
|
exit : false,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.checkPass = function () {
|
||||||
|
var r = checkUsage(function () {
|
||||||
|
return optimist('-x 10 -y 20'.split(' '))
|
||||||
|
.usage('Usage: $0 -x NUM -y NUM')
|
||||||
|
.check(function (argv) {
|
||||||
|
if (!('x' in argv)) throw 'You forgot about -x';
|
||||||
|
if (!('y' in argv)) throw 'You forgot about -y';
|
||||||
|
})
|
||||||
|
.argv;
|
||||||
|
});
|
||||||
|
assert.deepEqual(r, {
|
||||||
|
result : { x : 10, y : 20, _ : [], $0 : './usage' },
|
||||||
|
errors : [],
|
||||||
|
logs : [],
|
||||||
|
exit : false,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.checkFail = function () {
|
||||||
|
var r = checkUsage(function () {
|
||||||
|
return optimist('-x 10 -z 20'.split(' '))
|
||||||
|
.usage('Usage: $0 -x NUM -y NUM')
|
||||||
|
.check(function (argv) {
|
||||||
|
if (!('x' in argv)) throw 'You forgot about -x';
|
||||||
|
if (!('y' in argv)) throw 'You forgot about -y';
|
||||||
|
})
|
||||||
|
.argv;
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
r.result,
|
||||||
|
{ x : 10, z : 20, _ : [], $0 : './usage' }
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
r.errors.join('\n').split(/\n+/),
|
||||||
|
[
|
||||||
|
'Usage: ./usage -x NUM -y NUM',
|
||||||
|
'You forgot about -y'
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.deepEqual(r.logs, []);
|
||||||
|
assert.ok(r.exit);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.checkCondPass = function () {
|
||||||
|
function checker (argv) {
|
||||||
|
return 'x' in argv && 'y' in argv;
|
||||||
|
}
|
||||||
|
|
||||||
|
var r = checkUsage(function () {
|
||||||
|
return optimist('-x 10 -y 20'.split(' '))
|
||||||
|
.usage('Usage: $0 -x NUM -y NUM')
|
||||||
|
.check(checker)
|
||||||
|
.argv;
|
||||||
|
});
|
||||||
|
assert.deepEqual(r, {
|
||||||
|
result : { x : 10, y : 20, _ : [], $0 : './usage' },
|
||||||
|
errors : [],
|
||||||
|
logs : [],
|
||||||
|
exit : false,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.checkCondFail = function () {
|
||||||
|
function checker (argv) {
|
||||||
|
return 'x' in argv && 'y' in argv;
|
||||||
|
}
|
||||||
|
|
||||||
|
var r = checkUsage(function () {
|
||||||
|
return optimist('-x 10 -z 20'.split(' '))
|
||||||
|
.usage('Usage: $0 -x NUM -y NUM')
|
||||||
|
.check(checker)
|
||||||
|
.argv;
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
r.result,
|
||||||
|
{ x : 10, z : 20, _ : [], $0 : './usage' }
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
r.errors.join('\n').split(/\n+/).join('\n'),
|
||||||
|
'Usage: ./usage -x NUM -y NUM\n'
|
||||||
|
+ 'Argument check failed: ' + checker.toString()
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.deepEqual(r.logs, []);
|
||||||
|
assert.ok(r.exit);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.countPass = function () {
|
||||||
|
var r = checkUsage(function () {
|
||||||
|
return optimist('1 2 3 --moo'.split(' '))
|
||||||
|
.usage('Usage: $0 [x] [y] [z] {OPTIONS}')
|
||||||
|
.demand(3)
|
||||||
|
.argv;
|
||||||
|
});
|
||||||
|
assert.deepEqual(r, {
|
||||||
|
result : { _ : [ '1', '2', '3' ], moo : true, $0 : './usage' },
|
||||||
|
errors : [],
|
||||||
|
logs : [],
|
||||||
|
exit : false,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.countFail = function () {
|
||||||
|
var r = checkUsage(function () {
|
||||||
|
return optimist('1 2 --moo'.split(' '))
|
||||||
|
.usage('Usage: $0 [x] [y] [z] {OPTIONS}')
|
||||||
|
.demand(3)
|
||||||
|
.argv;
|
||||||
|
});
|
||||||
|
assert.deepEqual(
|
||||||
|
r.result,
|
||||||
|
{ _ : [ '1', '2' ], moo : true, $0 : './usage' }
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.deepEqual(
|
||||||
|
r.errors.join('\n').split(/\n+/),
|
||||||
|
[
|
||||||
|
'Usage: ./usage [x] [y] [z] {OPTIONS}',
|
||||||
|
'Not enough non-option arguments: got 2, need at least 3',
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.deepEqual(r.logs, []);
|
||||||
|
assert.ok(r.exit);
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.defaultSingles = function () {
|
||||||
|
var r = checkUsage(function () {
|
||||||
|
return optimist('--foo 50 --baz 70 --powsy'.split(' '))
|
||||||
|
.default('foo', 5)
|
||||||
|
.default('bar', 6)
|
||||||
|
.default('baz', 7)
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
});
|
||||||
|
assert.eql(r.result, {
|
||||||
|
foo : '50',
|
||||||
|
bar : 6,
|
||||||
|
baz : '70',
|
||||||
|
powsy : true,
|
||||||
|
_ : [],
|
||||||
|
$0 : './usage',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.defaultHash = function () {
|
||||||
|
var r = checkUsage(function () {
|
||||||
|
return optimist('--foo 50 --baz 70'.split(' '))
|
||||||
|
.default({ foo : 10, bar : 20, quux : 30 })
|
||||||
|
.argv
|
||||||
|
;
|
||||||
|
});
|
||||||
|
assert.eql(r.result, {
|
||||||
|
foo : '50',
|
||||||
|
bar : 20,
|
||||||
|
baz : 70,
|
||||||
|
quux : 30,
|
||||||
|
_ : [],
|
||||||
|
$0 : './usage',
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.rebase = function () {
|
||||||
|
assert.equal(
|
||||||
|
optimist.rebase('/home/substack', '/home/substack/foo/bar/baz'),
|
||||||
|
'./foo/bar/baz'
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
optimist.rebase('/home/substack/foo/bar/baz', '/home/substack'),
|
||||||
|
'../../..'
|
||||||
|
);
|
||||||
|
assert.equal(
|
||||||
|
optimist.rebase('/home/substack/foo', '/home/substack/pow/zoom.txt'),
|
||||||
|
'../pow/zoom.txt'
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
function checkUsage (f) {
|
||||||
|
var _process = process;
|
||||||
|
process = Hash.copy(process);
|
||||||
|
var exit = false;
|
||||||
|
process.exit = function () { exit = true };
|
||||||
|
process.env = Hash.merge(process.env, { _ : 'node' });
|
||||||
|
process.argv = [ './usage' ];
|
||||||
|
|
||||||
|
var errors = [];
|
||||||
|
var logs = [];
|
||||||
|
|
||||||
|
console._error = console.error;
|
||||||
|
console.error = function (msg) { errors.push(msg) };
|
||||||
|
console._log = console.log;
|
||||||
|
console.log = function (msg) { logs.push(msg) };
|
||||||
|
|
||||||
|
var result = f();
|
||||||
|
|
||||||
|
process = _process;
|
||||||
|
console.error = console._error;
|
||||||
|
console.log = console._log;
|
||||||
|
|
||||||
|
return {
|
||||||
|
errors : errors,
|
||||||
|
logs : logs,
|
||||||
|
exit : exit,
|
||||||
|
result : result,
|
||||||
|
};
|
||||||
|
};
|
||||||
4
node_modules/handlebars/node_modules/uglify-js/.npmignore
generated
vendored
Normal file
4
node_modules/handlebars/node_modules/uglify-js/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
.DS_Store
|
||||||
|
.tmp*~
|
||||||
|
*.local.*
|
||||||
|
.pinf-*
|
||||||
981
node_modules/handlebars/node_modules/uglify-js/README.html
generated
vendored
Normal file
981
node_modules/handlebars/node_modules/uglify-js/README.html
generated
vendored
Normal file
@@ -0,0 +1,981 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
lang="en" xml:lang="en">
|
||||||
|
<head>
|
||||||
|
<title>UglifyJS – a JavaScript parser/compressor/beautifier</title>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
||||||
|
<meta name="generator" content="Org-mode"/>
|
||||||
|
<meta name="generated" content="2011-12-09 14:59:08 EET"/>
|
||||||
|
<meta name="author" content="Mihai Bazon"/>
|
||||||
|
<meta name="description" content="a JavaScript parser/compressor/beautifier in JavaScript"/>
|
||||||
|
<meta name="keywords" content="javascript, js, parser, compiler, compressor, mangle, minify, minifier"/>
|
||||||
|
<style type="text/css">
|
||||||
|
<!--/*--><![CDATA[/*><!--*/
|
||||||
|
html { font-family: Times, serif; font-size: 12pt; }
|
||||||
|
.title { text-align: center; }
|
||||||
|
.todo { color: red; }
|
||||||
|
.done { color: green; }
|
||||||
|
.tag { background-color: #add8e6; font-weight:normal }
|
||||||
|
.target { }
|
||||||
|
.timestamp { color: #bebebe; }
|
||||||
|
.timestamp-kwd { color: #5f9ea0; }
|
||||||
|
.right {margin-left:auto; margin-right:0px; text-align:right;}
|
||||||
|
.left {margin-left:0px; margin-right:auto; text-align:left;}
|
||||||
|
.center {margin-left:auto; margin-right:auto; text-align:center;}
|
||||||
|
p.verse { margin-left: 3% }
|
||||||
|
pre {
|
||||||
|
border: 1pt solid #AEBDCC;
|
||||||
|
background-color: #F3F5F7;
|
||||||
|
padding: 5pt;
|
||||||
|
font-family: courier, monospace;
|
||||||
|
font-size: 90%;
|
||||||
|
overflow:auto;
|
||||||
|
}
|
||||||
|
table { border-collapse: collapse; }
|
||||||
|
td, th { vertical-align: top; }
|
||||||
|
th.right { text-align:center; }
|
||||||
|
th.left { text-align:center; }
|
||||||
|
th.center { text-align:center; }
|
||||||
|
td.right { text-align:right; }
|
||||||
|
td.left { text-align:left; }
|
||||||
|
td.center { text-align:center; }
|
||||||
|
dt { font-weight: bold; }
|
||||||
|
div.figure { padding: 0.5em; }
|
||||||
|
div.figure p { text-align: center; }
|
||||||
|
div.inlinetask {
|
||||||
|
padding:10px;
|
||||||
|
border:2px solid gray;
|
||||||
|
margin:10px;
|
||||||
|
background: #ffffcc;
|
||||||
|
}
|
||||||
|
textarea { overflow-x: auto; }
|
||||||
|
.linenr { font-size:smaller }
|
||||||
|
.code-highlighted {background-color:#ffff00;}
|
||||||
|
.org-info-js_info-navigation { border-style:none; }
|
||||||
|
#org-info-js_console-label { font-size:10px; font-weight:bold;
|
||||||
|
white-space:nowrap; }
|
||||||
|
.org-info-js_search-highlight {background-color:#ffff00; color:#000000;
|
||||||
|
font-weight:bold; }
|
||||||
|
/*]]>*/-->
|
||||||
|
</style>
|
||||||
|
<link rel="stylesheet" type="text/css" href="docstyle.css" />
|
||||||
|
<script type="text/javascript">
|
||||||
|
<!--/*--><![CDATA[/*><!--*/
|
||||||
|
function CodeHighlightOn(elem, id)
|
||||||
|
{
|
||||||
|
var target = document.getElementById(id);
|
||||||
|
if(null != target) {
|
||||||
|
elem.cacheClassElem = elem.className;
|
||||||
|
elem.cacheClassTarget = target.className;
|
||||||
|
target.className = "code-highlighted";
|
||||||
|
elem.className = "code-highlighted";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function CodeHighlightOff(elem, id)
|
||||||
|
{
|
||||||
|
var target = document.getElementById(id);
|
||||||
|
if(elem.cacheClassElem)
|
||||||
|
elem.className = elem.cacheClassElem;
|
||||||
|
if(elem.cacheClassTarget)
|
||||||
|
target.className = elem.cacheClassTarget;
|
||||||
|
}
|
||||||
|
/*]]>*///-->
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div id="preamble">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
<h1 class="title">UglifyJS – a JavaScript parser/compressor/beautifier</h1>
|
||||||
|
|
||||||
|
|
||||||
|
<div id="table-of-contents">
|
||||||
|
<h2>Table of Contents</h2>
|
||||||
|
<div id="text-table-of-contents">
|
||||||
|
<ul>
|
||||||
|
<li><a href="#sec-1">1 UglifyJS — a JavaScript parser/compressor/beautifier </a>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#sec-1-1">1.1 Unsafe transformations </a>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#sec-1-1-1">1.1.1 Calls involving the global Array constructor </a></li>
|
||||||
|
<li><a href="#sec-1-1-2">1.1.2 <code>obj.toString()</code> ==> <code>obj+“”</code> </a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li><a href="#sec-1-2">1.2 Install (NPM) </a></li>
|
||||||
|
<li><a href="#sec-1-3">1.3 Install latest code from GitHub </a></li>
|
||||||
|
<li><a href="#sec-1-4">1.4 Usage </a>
|
||||||
|
<ul>
|
||||||
|
<li><a href="#sec-1-4-1">1.4.1 API </a></li>
|
||||||
|
<li><a href="#sec-1-4-2">1.4.2 Beautifier shortcoming – no more comments </a></li>
|
||||||
|
<li><a href="#sec-1-4-3">1.4.3 Use as a code pre-processor </a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li><a href="#sec-1-5">1.5 Compression – how good is it? </a></li>
|
||||||
|
<li><a href="#sec-1-6">1.6 Bugs? </a></li>
|
||||||
|
<li><a href="#sec-1-7">1.7 Links </a></li>
|
||||||
|
<li><a href="#sec-1-8">1.8 License </a></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="outline-container-1" class="outline-2">
|
||||||
|
<h2 id="sec-1"><span class="section-number-2">1</span> UglifyJS — a JavaScript parser/compressor/beautifier </h2>
|
||||||
|
<div class="outline-text-2" id="text-1">
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
This package implements a general-purpose JavaScript
|
||||||
|
parser/compressor/beautifier toolkit. It is developed on <a href="http://nodejs.org/">NodeJS</a>, but it
|
||||||
|
should work on any JavaScript platform supporting the CommonJS module system
|
||||||
|
(and if your platform of choice doesn't support CommonJS, you can easily
|
||||||
|
implement it, or discard the <code>exports.*</code> lines from UglifyJS sources).
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The tokenizer/parser generates an abstract syntax tree from JS code. You
|
||||||
|
can then traverse the AST to learn more about the code, or do various
|
||||||
|
manipulations on it. This part is implemented in <a href="../lib/parse-js.js">parse-js.js</a> and it's a
|
||||||
|
port to JavaScript of the excellent <a href="http://marijn.haverbeke.nl/parse-js/">parse-js</a> Common Lisp library from <a href="http://marijn.haverbeke.nl/">Marijn Haverbeke</a>.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
( See <a href="http://github.com/mishoo/cl-uglify-js">cl-uglify-js</a> if you're looking for the Common Lisp version of
|
||||||
|
UglifyJS. )
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The second part of this package, implemented in <a href="../lib/process.js">process.js</a>, inspects and
|
||||||
|
manipulates the AST generated by the parser to provide the following:
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li>ability to re-generate JavaScript code from the AST. Optionally
|
||||||
|
indented—you can use this if you want to “beautify” a program that has
|
||||||
|
been compressed, so that you can inspect the source. But you can also run
|
||||||
|
our code generator to print out an AST without any whitespace, so you
|
||||||
|
achieve compression as well.
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li>shorten variable names (usually to single characters). Our mangler will
|
||||||
|
analyze the code and generate proper variable names, depending on scope
|
||||||
|
and usage, and is smart enough to deal with globals defined elsewhere, or
|
||||||
|
with <code>eval()</code> calls or <code>with{}</code> statements. In short, if <code>eval()</code> or
|
||||||
|
<code>with{}</code> are used in some scope, then all variables in that scope and any
|
||||||
|
variables in the parent scopes will remain unmangled, and any references
|
||||||
|
to such variables remain unmangled as well.
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li>various small optimizations that may lead to faster code but certainly
|
||||||
|
lead to smaller code. Where possible, we do the following:
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>foo["bar"] ==> foo.bar
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li>remove block brackets <code>{}</code>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li>join consecutive var declarations:
|
||||||
|
var a = 10; var b = 20; ==> var a=10,b=20;
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li>resolve simple constant expressions: 1 +2 * 3 ==> 7. We only do the
|
||||||
|
replacement if the result occupies less bytes; for example 1/3 would
|
||||||
|
translate to 0.333333333333, so in this case we don't replace it.
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li>consecutive statements in blocks are merged into a sequence; in many
|
||||||
|
cases, this leaves blocks with a single statement, so then we can remove
|
||||||
|
the block brackets.
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li>various optimizations for IF statements:
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>if (foo) bar(); else baz(); ==> foo?bar():baz();
|
||||||
|
</li>
|
||||||
|
<li>if (!foo) bar(); else baz(); ==> foo?baz():bar();
|
||||||
|
</li>
|
||||||
|
<li>if (foo) bar(); ==> foo&&bar();
|
||||||
|
</li>
|
||||||
|
<li>if (!foo) bar(); ==> foo||bar();
|
||||||
|
</li>
|
||||||
|
<li>if (foo) return bar(); else return baz(); ==> return foo?bar():baz();
|
||||||
|
</li>
|
||||||
|
<li>if (foo) return bar(); else something(); ==> {if(foo)return bar();something()}
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li>remove some unreachable code and warn about it (code that follows a
|
||||||
|
<code>return</code>, <code>throw</code>, <code>break</code> or <code>continue</code> statement, except
|
||||||
|
function/variable declarations).
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li>act a limited version of a pre-processor (c.f. the pre-processor of
|
||||||
|
C/C++) to allow you to safely replace selected global symbols with
|
||||||
|
specified values. When combined with the optimisations above this can
|
||||||
|
make UglifyJS operate slightly more like a compilation process, in
|
||||||
|
that when certain symbols are replaced by constant values, entire code
|
||||||
|
blocks may be optimised away as unreachable.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="outline-container-1-1" class="outline-3">
|
||||||
|
<h3 id="sec-1-1"><span class="section-number-3">1.1</span> <span class="target">Unsafe transformations</span> </h3>
|
||||||
|
<div class="outline-text-3" id="text-1-1">
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The following transformations can in theory break code, although they're
|
||||||
|
probably safe in most practical cases. To enable them you need to pass the
|
||||||
|
<code>--unsafe</code> flag.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="outline-container-1-1-1" class="outline-4">
|
||||||
|
<h4 id="sec-1-1-1"><span class="section-number-4">1.1.1</span> Calls involving the global Array constructor </h4>
|
||||||
|
<div class="outline-text-4" id="text-1-1-1">
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The following transformations occur:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<pre class="src src-js"><span class="org-keyword">new</span> <span class="org-type">Array</span>(1, 2, 3, 4) => [1,2,3,4]
|
||||||
|
Array(a, b, c) => [a,b,c]
|
||||||
|
<span class="org-keyword">new</span> <span class="org-type">Array</span>(5) => Array(5)
|
||||||
|
<span class="org-keyword">new</span> <span class="org-type">Array</span>(a) => Array(a)
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
These are all safe if the Array name isn't redefined. JavaScript does allow
|
||||||
|
one to globally redefine Array (and pretty much everything, in fact) but I
|
||||||
|
personally don't see why would anyone do that.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
UglifyJS does handle the case where Array is redefined locally, or even
|
||||||
|
globally but with a <code>function</code> or <code>var</code> declaration. Therefore, in the
|
||||||
|
following cases UglifyJS <b>doesn't touch</b> calls or instantiations of Array:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<pre class="src src-js"><span class="org-comment-delimiter">// </span><span class="org-comment">case 1. globally declared variable</span>
|
||||||
|
<span class="org-keyword">var</span> <span class="org-variable-name">Array</span>;
|
||||||
|
<span class="org-keyword">new</span> <span class="org-type">Array</span>(1, 2, 3);
|
||||||
|
Array(a, b);
|
||||||
|
|
||||||
|
<span class="org-comment-delimiter">// </span><span class="org-comment">or (can be declared later)</span>
|
||||||
|
<span class="org-keyword">new</span> <span class="org-type">Array</span>(1, 2, 3);
|
||||||
|
<span class="org-keyword">var</span> <span class="org-variable-name">Array</span>;
|
||||||
|
|
||||||
|
<span class="org-comment-delimiter">// </span><span class="org-comment">or (can be a function)</span>
|
||||||
|
<span class="org-keyword">new</span> <span class="org-type">Array</span>(1, 2, 3);
|
||||||
|
<span class="org-keyword">function</span> <span class="org-function-name">Array</span>() { ... }
|
||||||
|
|
||||||
|
<span class="org-comment-delimiter">// </span><span class="org-comment">case 2. declared in a function</span>
|
||||||
|
(<span class="org-keyword">function</span>(){
|
||||||
|
a = <span class="org-keyword">new</span> <span class="org-type">Array</span>(1, 2, 3);
|
||||||
|
b = Array(5, 6);
|
||||||
|
<span class="org-keyword">var</span> <span class="org-variable-name">Array</span>;
|
||||||
|
})();
|
||||||
|
|
||||||
|
<span class="org-comment-delimiter">// </span><span class="org-comment">or</span>
|
||||||
|
(<span class="org-keyword">function</span>(<span class="org-variable-name">Array</span>){
|
||||||
|
<span class="org-keyword">return</span> Array(5, 6, 7);
|
||||||
|
})();
|
||||||
|
|
||||||
|
<span class="org-comment-delimiter">// </span><span class="org-comment">or</span>
|
||||||
|
(<span class="org-keyword">function</span>(){
|
||||||
|
<span class="org-keyword">return</span> <span class="org-keyword">new</span> <span class="org-type">Array</span>(1, 2, 3, 4);
|
||||||
|
<span class="org-keyword">function</span> <span class="org-function-name">Array</span>() { ... }
|
||||||
|
})();
|
||||||
|
|
||||||
|
<span class="org-comment-delimiter">// </span><span class="org-comment">etc.</span>
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="outline-container-1-1-2" class="outline-4">
|
||||||
|
<h4 id="sec-1-1-2"><span class="section-number-4">1.1.2</span> <code>obj.toString()</code> ==> <code>obj+“”</code> </h4>
|
||||||
|
<div class="outline-text-4" id="text-1-1-2">
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="outline-container-1-2" class="outline-3">
|
||||||
|
<h3 id="sec-1-2"><span class="section-number-3">1.2</span> Install (NPM) </h3>
|
||||||
|
<div class="outline-text-3" id="text-1-2">
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
UglifyJS is now available through NPM — <code>npm install uglify-js</code> should do
|
||||||
|
the job.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="outline-container-1-3" class="outline-3">
|
||||||
|
<h3 id="sec-1-3"><span class="section-number-3">1.3</span> Install latest code from GitHub </h3>
|
||||||
|
<div class="outline-text-3" id="text-1-3">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<pre class="src src-sh"><span class="org-comment-delimiter">## </span><span class="org-comment">clone the repository</span>
|
||||||
|
mkdir -p /where/you/wanna/put/it
|
||||||
|
<span class="org-builtin">cd</span> /where/you/wanna/put/it
|
||||||
|
git clone git://github.com/mishoo/UglifyJS.git
|
||||||
|
|
||||||
|
<span class="org-comment-delimiter">## </span><span class="org-comment">make the module available to Node</span>
|
||||||
|
mkdir -p ~/.node_libraries/
|
||||||
|
<span class="org-builtin">cd</span> ~/.node_libraries/
|
||||||
|
ln -s /where/you/wanna/put/it/UglifyJS/uglify-js.js
|
||||||
|
|
||||||
|
<span class="org-comment-delimiter">## </span><span class="org-comment">and if you want the CLI script too:</span>
|
||||||
|
mkdir -p ~/bin
|
||||||
|
<span class="org-builtin">cd</span> ~/bin
|
||||||
|
ln -s /where/you/wanna/put/it/UglifyJS/bin/uglifyjs
|
||||||
|
<span class="org-comment-delimiter"># </span><span class="org-comment">(then add ~/bin to your $PATH if it's not there already)</span>
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="outline-container-1-4" class="outline-3">
|
||||||
|
<h3 id="sec-1-4"><span class="section-number-3">1.4</span> Usage </h3>
|
||||||
|
<div class="outline-text-3" id="text-1-4">
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
There is a command-line tool that exposes the functionality of this library
|
||||||
|
for your shell-scripting needs:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<pre class="src src-sh">uglifyjs [ options... ] [ filename ]
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<code>filename</code> should be the last argument and should name the file from which
|
||||||
|
to read the JavaScript code. If you don't specify it, it will read code
|
||||||
|
from STDIN.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Supported options:
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li><code>-b</code> or <code>--beautify</code> — output indented code; when passed, additional
|
||||||
|
options control the beautifier:
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><code>-i N</code> or <code>--indent N</code> — indentation level (number of spaces)
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>-q</code> or <code>--quote-keys</code> — quote keys in literal objects (by default,
|
||||||
|
only keys that cannot be identifier names will be quotes).
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>--ascii</code> — pass this argument to encode non-ASCII characters as
|
||||||
|
<code>\uXXXX</code> sequences. By default UglifyJS won't bother to do it and will
|
||||||
|
output Unicode characters instead. (the output is always encoded in UTF8,
|
||||||
|
but if you pass this option you'll only get ASCII).
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>-nm</code> or <code>--no-mangle</code> — don't mangle names.
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>-nmf</code> or <code>--no-mangle-functions</code> – in case you want to mangle variable
|
||||||
|
names, but not touch function names.
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>-ns</code> or <code>--no-squeeze</code> — don't call <code>ast_squeeze()</code> (which does various
|
||||||
|
optimizations that result in smaller, less readable code).
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>-mt</code> or <code>--mangle-toplevel</code> — mangle names in the toplevel scope too
|
||||||
|
(by default we don't do this).
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>--no-seqs</code> — when <code>ast_squeeze()</code> is called (thus, unless you pass
|
||||||
|
<code>--no-squeeze</code>) it will reduce consecutive statements in blocks into a
|
||||||
|
sequence. For example, "a = 10; b = 20; foo();" will be written as
|
||||||
|
"a=10,b=20,foo();". In various occasions, this allows us to discard the
|
||||||
|
block brackets (since the block becomes a single statement). This is ON
|
||||||
|
by default because it seems safe and saves a few hundred bytes on some
|
||||||
|
libs that I tested it on, but pass <code>--no-seqs</code> to disable it.
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>--no-dead-code</code> — by default, UglifyJS will remove code that is
|
||||||
|
obviously unreachable (code that follows a <code>return</code>, <code>throw</code>, <code>break</code> or
|
||||||
|
<code>continue</code> statement and is not a function/variable declaration). Pass
|
||||||
|
this option to disable this optimization.
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>-nc</code> or <code>--no-copyright</code> — by default, <code>uglifyjs</code> will keep the initial
|
||||||
|
comment tokens in the generated code (assumed to be copyright information
|
||||||
|
etc.). If you pass this it will discard it.
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>-o filename</code> or <code>--output filename</code> — put the result in <code>filename</code>. If
|
||||||
|
this isn't given, the result goes to standard output (or see next one).
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>--overwrite</code> — if the code is read from a file (not from STDIN) and you
|
||||||
|
pass <code>--overwrite</code> then the output will be written in the same file.
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>--ast</code> — pass this if you want to get the Abstract Syntax Tree instead
|
||||||
|
of JavaScript as output. Useful for debugging or learning more about the
|
||||||
|
internals.
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>-v</code> or <code>--verbose</code> — output some notes on STDERR (for now just how long
|
||||||
|
each operation takes).
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>-d SYMBOL[=VALUE]</code> or <code>--define SYMBOL[=VALUE]</code> — will replace
|
||||||
|
all instances of the specified symbol where used as an identifier
|
||||||
|
(except where symbol has properly declared by a var declaration or
|
||||||
|
use as function parameter or similar) with the specified value. This
|
||||||
|
argument may be specified multiple times to define multiple
|
||||||
|
symbols - if no value is specified the symbol will be replaced with
|
||||||
|
the value <code>true</code>, or you can specify a numeric value (such as
|
||||||
|
<code>1024</code>), a quoted string value (such as ="object"= or
|
||||||
|
='https://github.com'<code>), or the name of another symbol or keyword (such as =null</code> or <code>document</code>).
|
||||||
|
This allows you, for example, to assign meaningful names to key
|
||||||
|
constant values but discard the symbolic names in the uglified
|
||||||
|
version for brevity/efficiency, or when used wth care, allows
|
||||||
|
UglifyJS to operate as a form of <b>conditional compilation</b>
|
||||||
|
whereby defining appropriate values may, by dint of the constant
|
||||||
|
folding and dead code removal features above, remove entire
|
||||||
|
superfluous code blocks (e.g. completely remove instrumentation or
|
||||||
|
trace code for production use).
|
||||||
|
Where string values are being defined, the handling of quotes are
|
||||||
|
likely to be subject to the specifics of your command shell
|
||||||
|
environment, so you may need to experiment with quoting styles
|
||||||
|
depending on your platform, or you may find the option
|
||||||
|
<code>--define-from-module</code> more suitable for use.
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>-define-from-module SOMEMODULE</code> — will load the named module (as
|
||||||
|
per the NodeJS <code>require()</code> function) and iterate all the exported
|
||||||
|
properties of the module defining them as symbol names to be defined
|
||||||
|
(as if by the <code>--define</code> option) per the name of each property
|
||||||
|
(i.e. without the module name prefix) and given the value of the
|
||||||
|
property. This is a much easier way to handle and document groups of
|
||||||
|
symbols to be defined rather than a large number of <code>--define</code>
|
||||||
|
options.
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>--unsafe</code> — enable other additional optimizations that are known to be
|
||||||
|
unsafe in some contrived situations, but could still be generally useful.
|
||||||
|
For now only these:
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>foo.toString() ==> foo+""
|
||||||
|
</li>
|
||||||
|
<li>new Array(x,…) ==> [x,…]
|
||||||
|
</li>
|
||||||
|
<li>new Array(x) ==> Array(x)
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>--max-line-len</code> (default 32K characters) — add a newline after around
|
||||||
|
32K characters. I've seen both FF and Chrome croak when all the code was
|
||||||
|
on a single line of around 670K. Pass –max-line-len 0 to disable this
|
||||||
|
safety feature.
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>--reserved-names</code> — some libraries rely on certain names to be used, as
|
||||||
|
pointed out in issue #92 and #81, so this option allow you to exclude such
|
||||||
|
names from the mangler. For example, to keep names <code>require</code> and <code>$super</code>
|
||||||
|
intact you'd specify –reserved-names "require,$super".
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>--inline-script</code> – when you want to include the output literally in an
|
||||||
|
HTML <code><script></code> tag you can use this option to prevent <code></script</code> from
|
||||||
|
showing up in the output.
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>--lift-vars</code> – when you pass this, UglifyJS will apply the following
|
||||||
|
transformations (see the notes in API, <code>ast_lift_variables</code>):
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>put all <code>var</code> declarations at the start of the scope
|
||||||
|
</li>
|
||||||
|
<li>make sure a variable is declared only once
|
||||||
|
</li>
|
||||||
|
<li>discard unused function arguments
|
||||||
|
</li>
|
||||||
|
<li>discard unused inner (named) functions
|
||||||
|
</li>
|
||||||
|
<li>finally, try to merge assignments into that one <code>var</code> declaration, if
|
||||||
|
possible.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="outline-container-1-4-1" class="outline-4">
|
||||||
|
<h4 id="sec-1-4-1"><span class="section-number-4">1.4.1</span> API </h4>
|
||||||
|
<div class="outline-text-4" id="text-1-4-1">
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
To use the library from JavaScript, you'd do the following (example for
|
||||||
|
NodeJS):
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<pre class="src src-js"><span class="org-keyword">var</span> <span class="org-variable-name">jsp</span> = require(<span class="org-string">"uglify-js"</span>).parser;
|
||||||
|
<span class="org-keyword">var</span> <span class="org-variable-name">pro</span> = require(<span class="org-string">"uglify-js"</span>).uglify;
|
||||||
|
|
||||||
|
<span class="org-keyword">var</span> <span class="org-variable-name">orig_code</span> = <span class="org-string">"... JS code here"</span>;
|
||||||
|
<span class="org-keyword">var</span> <span class="org-variable-name">ast</span> = jsp.parse(orig_code); <span class="org-comment-delimiter">// </span><span class="org-comment">parse code and get the initial AST</span>
|
||||||
|
ast = pro.ast_mangle(ast); <span class="org-comment-delimiter">// </span><span class="org-comment">get a new AST with mangled names</span>
|
||||||
|
ast = pro.ast_squeeze(ast); <span class="org-comment-delimiter">// </span><span class="org-comment">get an AST with compression optimizations</span>
|
||||||
|
<span class="org-keyword">var</span> <span class="org-variable-name">final_code</span> = pro.gen_code(ast); <span class="org-comment-delimiter">// </span><span class="org-comment">compressed code here</span>
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The above performs the full compression that is possible right now. As you
|
||||||
|
can see, there are a sequence of steps which you can apply. For example if
|
||||||
|
you want compressed output but for some reason you don't want to mangle
|
||||||
|
variable names, you would simply skip the line that calls
|
||||||
|
<code>pro.ast_mangle(ast)</code>.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Some of these functions take optional arguments. Here's a description:
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li><code>jsp.parse(code, strict_semicolons)</code> – parses JS code and returns an AST.
|
||||||
|
<code>strict_semicolons</code> is optional and defaults to <code>false</code>. If you pass
|
||||||
|
<code>true</code> then the parser will throw an error when it expects a semicolon and
|
||||||
|
it doesn't find it. For most JS code you don't want that, but it's useful
|
||||||
|
if you want to strictly sanitize your code.
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>pro.ast_lift_variables(ast)</code> – merge and move <code>var</code> declarations to the
|
||||||
|
scop of the scope; discard unused function arguments or variables; discard
|
||||||
|
unused (named) inner functions. It also tries to merge assignments
|
||||||
|
following the <code>var</code> declaration into it.
|
||||||
|
|
||||||
|
<p>
|
||||||
|
If your code is very hand-optimized concerning <code>var</code> declarations, this
|
||||||
|
lifting variable declarations might actually increase size. For me it
|
||||||
|
helps out. On jQuery it adds 865 bytes (243 after gzip). YMMV. Also
|
||||||
|
note that (since it's not enabled by default) this operation isn't yet
|
||||||
|
heavily tested (please report if you find issues!).
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Note that although it might increase the image size (on jQuery it gains
|
||||||
|
865 bytes, 243 after gzip) it's technically more correct: in certain
|
||||||
|
situations, dead code removal might drop variable declarations, which
|
||||||
|
would not happen if the variables are lifted in advance.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Here's an example of what it does:
|
||||||
|
</p></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<pre class="src src-js"><span class="org-keyword">function</span> <span class="org-function-name">f</span>(<span class="org-variable-name">a</span>, <span class="org-variable-name">b</span>, <span class="org-variable-name">c</span>, <span class="org-variable-name">d</span>, <span class="org-variable-name">e</span>) {
|
||||||
|
<span class="org-keyword">var</span> <span class="org-variable-name">q</span>;
|
||||||
|
<span class="org-keyword">var</span> <span class="org-variable-name">w</span>;
|
||||||
|
w = 10;
|
||||||
|
q = 20;
|
||||||
|
<span class="org-keyword">for</span> (<span class="org-keyword">var</span> <span class="org-variable-name">i</span> = 1; i < 10; ++i) {
|
||||||
|
<span class="org-keyword">var</span> <span class="org-variable-name">boo</span> = foo(a);
|
||||||
|
}
|
||||||
|
<span class="org-keyword">for</span> (<span class="org-keyword">var</span> <span class="org-variable-name">i</span> = 0; i < 1; ++i) {
|
||||||
|
<span class="org-keyword">var</span> <span class="org-variable-name">boo</span> = bar(c);
|
||||||
|
}
|
||||||
|
<span class="org-keyword">function</span> <span class="org-function-name">foo</span>(){ ... }
|
||||||
|
<span class="org-keyword">function</span> <span class="org-function-name">bar</span>(){ ... }
|
||||||
|
<span class="org-keyword">function</span> <span class="org-function-name">baz</span>(){ ... }
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="org-comment-delimiter">// </span><span class="org-comment">transforms into ==></span>
|
||||||
|
|
||||||
|
<span class="org-keyword">function</span> <span class="org-function-name">f</span>(<span class="org-variable-name">a</span>, <span class="org-variable-name">b</span>, <span class="org-variable-name">c</span>) {
|
||||||
|
<span class="org-keyword">var</span> <span class="org-variable-name">i</span>, <span class="org-variable-name">boo</span>, <span class="org-variable-name">w</span> = 10, <span class="org-variable-name">q</span> = 20;
|
||||||
|
<span class="org-keyword">for</span> (i = 1; i < 10; ++i) {
|
||||||
|
boo = foo(a);
|
||||||
|
}
|
||||||
|
<span class="org-keyword">for</span> (i = 0; i < 1; ++i) {
|
||||||
|
boo = bar(c);
|
||||||
|
}
|
||||||
|
<span class="org-keyword">function</span> <span class="org-function-name">foo</span>() { ... }
|
||||||
|
<span class="org-keyword">function</span> <span class="org-function-name">bar</span>() { ... }
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><code>pro.ast_mangle(ast, options)</code> – generates a new AST containing mangled
|
||||||
|
(compressed) variable and function names. It supports the following
|
||||||
|
options:
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><code>toplevel</code> – mangle toplevel names (by default we don't touch them).
|
||||||
|
</li>
|
||||||
|
<li><code>except</code> – an array of names to exclude from compression.
|
||||||
|
</li>
|
||||||
|
<li><code>defines</code> – an object with properties named after symbols to
|
||||||
|
replace (see the <code>--define</code> option for the script) and the values
|
||||||
|
representing the AST replacement value.
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>pro.ast_squeeze(ast, options)</code> – employs further optimizations designed
|
||||||
|
to reduce the size of the code that <code>gen_code</code> would generate from the
|
||||||
|
AST. Returns a new AST. <code>options</code> can be a hash; the supported options
|
||||||
|
are:
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><code>make_seqs</code> (default true) which will cause consecutive statements in a
|
||||||
|
block to be merged using the "sequence" (comma) operator
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>dead_code</code> (default true) which will remove unreachable code.
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
<li><code>pro.gen_code(ast, options)</code> – generates JS code from the AST. By
|
||||||
|
default it's minified, but using the <code>options</code> argument you can get nicely
|
||||||
|
formatted output. <code>options</code> is, well, optional :-) and if you pass it it
|
||||||
|
must be an object and supports the following properties (below you can see
|
||||||
|
the default values):
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li><code>beautify: false</code> – pass <code>true</code> if you want indented output
|
||||||
|
</li>
|
||||||
|
<li><code>indent_start: 0</code> (only applies when <code>beautify</code> is <code>true</code>) – initial
|
||||||
|
indentation in spaces
|
||||||
|
</li>
|
||||||
|
<li><code>indent_level: 4</code> (only applies when <code>beautify</code> is <code>true</code>) --
|
||||||
|
indentation level, in spaces (pass an even number)
|
||||||
|
</li>
|
||||||
|
<li><code>quote_keys: false</code> – if you pass <code>true</code> it will quote all keys in
|
||||||
|
literal objects
|
||||||
|
</li>
|
||||||
|
<li><code>space_colon: false</code> (only applies when <code>beautify</code> is <code>true</code>) – wether
|
||||||
|
to put a space before the colon in object literals
|
||||||
|
</li>
|
||||||
|
<li><code>ascii_only: false</code> – pass <code>true</code> if you want to encode non-ASCII
|
||||||
|
characters as <code>\uXXXX</code>.
|
||||||
|
</li>
|
||||||
|
<li><code>inline_script: false</code> – pass <code>true</code> to escape occurrences of
|
||||||
|
<code></script</code> in strings
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="outline-container-1-4-2" class="outline-4">
|
||||||
|
<h4 id="sec-1-4-2"><span class="section-number-4">1.4.2</span> Beautifier shortcoming – no more comments </h4>
|
||||||
|
<div class="outline-text-4" id="text-1-4-2">
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The beautifier can be used as a general purpose indentation tool. It's
|
||||||
|
useful when you want to make a minified file readable. One limitation,
|
||||||
|
though, is that it discards all comments, so you don't really want to use it
|
||||||
|
to reformat your code, unless you don't have, or don't care about, comments.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
In fact it's not the beautifier who discards comments — they are dumped at
|
||||||
|
the parsing stage, when we build the initial AST. Comments don't really
|
||||||
|
make sense in the AST, and while we could add nodes for them, it would be
|
||||||
|
inconvenient because we'd have to add special rules to ignore them at all
|
||||||
|
the processing stages.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="outline-container-1-4-3" class="outline-4">
|
||||||
|
<h4 id="sec-1-4-3"><span class="section-number-4">1.4.3</span> Use as a code pre-processor </h4>
|
||||||
|
<div class="outline-text-4" id="text-1-4-3">
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
The <code>--define</code> option can be used, particularly when combined with the
|
||||||
|
constant folding logic, as a form of pre-processor to enable or remove
|
||||||
|
particular constructions, such as might be used for instrumenting
|
||||||
|
development code, or to produce variations aimed at a specific
|
||||||
|
platform.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
The code below illustrates the way this can be done, and how the
|
||||||
|
symbol replacement is performed.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<pre class="src src-js">CLAUSE1: <span class="org-keyword">if</span> (<span class="org-keyword">typeof</span> DEVMODE === <span class="org-string">'undefined'</span>) {
|
||||||
|
DEVMODE = <span class="org-constant">true</span>;
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="org-function-name">CLAUSE2</span>: <span class="org-keyword">function</span> init() {
|
||||||
|
<span class="org-keyword">if</span> (DEVMODE) {
|
||||||
|
console.log(<span class="org-string">"init() called"</span>);
|
||||||
|
}
|
||||||
|
....
|
||||||
|
DEVMODE &amp;&amp; console.log(<span class="org-string">"init() complete"</span>);
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="org-function-name">CLAUSE3</span>: <span class="org-keyword">function</span> reportDeviceStatus(<span class="org-variable-name">device</span>) {
|
||||||
|
<span class="org-keyword">var</span> <span class="org-variable-name">DEVMODE</span> = device.mode, <span class="org-variable-name">DEVNAME</span> = device.name;
|
||||||
|
<span class="org-keyword">if</span> (DEVMODE === <span class="org-string">'open'</span>) {
|
||||||
|
....
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
When the above code is normally executed, the undeclared global
|
||||||
|
variable <code>DEVMODE</code> will be assigned the value <b>true</b> (see <code>CLAUSE1</code>)
|
||||||
|
and so the <code>init()</code> function (<code>CLAUSE2</code>) will write messages to the
|
||||||
|
console log when executed, but in <code>CLAUSE3</code> a locally declared
|
||||||
|
variable will mask access to the <code>DEVMODE</code> global symbol.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
If the above code is processed by UglifyJS with an argument of
|
||||||
|
<code>--define DEVMODE=false</code> then UglifyJS will replace <code>DEVMODE</code> with the
|
||||||
|
boolean constant value <b>false</b> within <code>CLAUSE1</code> and <code>CLAUSE2</code>, but it
|
||||||
|
will leave <code>CLAUSE3</code> as it stands because there <code>DEVMODE</code> resolves to
|
||||||
|
a validly declared variable.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
And more so, the constant-folding features of UglifyJS will recognise
|
||||||
|
that the <code>if</code> condition of <code>CLAUSE1</code> is thus always false, and so will
|
||||||
|
remove the test and body of <code>CLAUSE1</code> altogether (including the
|
||||||
|
otherwise slightly problematical statement <code>false = true;</code> which it
|
||||||
|
will have formed by replacing <code>DEVMODE</code> in the body). Similarly,
|
||||||
|
within <code>CLAUSE2</code> both calls to <code>console.log()</code> will be removed
|
||||||
|
altogether.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
In this way you can mimic, to a limited degree, the functionality of
|
||||||
|
the C/C++ pre-processor to enable or completely remove blocks
|
||||||
|
depending on how certain symbols are defined - perhaps using UglifyJS
|
||||||
|
to generate different versions of source aimed at different
|
||||||
|
environments
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
It is recommmended (but not made mandatory) that symbols designed for
|
||||||
|
this purpose are given names consisting of <code>UPPER_CASE_LETTERS</code> to
|
||||||
|
distinguish them from other (normal) symbols and avoid the sort of
|
||||||
|
clash that <code>CLAUSE3</code> above illustrates.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="outline-container-1-5" class="outline-3">
|
||||||
|
<h3 id="sec-1-5"><span class="section-number-3">1.5</span> Compression – how good is it? </h3>
|
||||||
|
<div class="outline-text-3" id="text-1-5">
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Here are updated statistics. (I also updated my Google Closure and YUI
|
||||||
|
installations).
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
We're still a lot better than YUI in terms of compression, though slightly
|
||||||
|
slower. We're still a lot faster than Closure, and compression after gzip
|
||||||
|
is comparable.
|
||||||
|
</p>
|
||||||
|
<table border="2" cellspacing="0" cellpadding="6" rules="groups" frame="hsides">
|
||||||
|
<caption></caption>
|
||||||
|
<colgroup><col class="left" /><col class="left" /><col class="right" /><col class="left" /><col class="right" /><col class="left" /><col class="right" />
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
|
<tr><th scope="col" class="left">File</th><th scope="col" class="left">UglifyJS</th><th scope="col" class="right">UglifyJS+gzip</th><th scope="col" class="left">Closure</th><th scope="col" class="right">Closure+gzip</th><th scope="col" class="left">YUI</th><th scope="col" class="right">YUI+gzip</th></tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr><td class="left">jquery-1.6.2.js</td><td class="left">91001 (0:01.59)</td><td class="right">31896</td><td class="left">90678 (0:07.40)</td><td class="right">31979</td><td class="left">101527 (0:01.82)</td><td class="right">34646</td></tr>
|
||||||
|
<tr><td class="left">paper.js</td><td class="left">142023 (0:01.65)</td><td class="right">43334</td><td class="left">134301 (0:07.42)</td><td class="right">42495</td><td class="left">173383 (0:01.58)</td><td class="right">48785</td></tr>
|
||||||
|
<tr><td class="left">prototype.js</td><td class="left">88544 (0:01.09)</td><td class="right">26680</td><td class="left">86955 (0:06.97)</td><td class="right">26326</td><td class="left">92130 (0:00.79)</td><td class="right">28624</td></tr>
|
||||||
|
<tr><td class="left">thelib-full.js (DynarchLIB)</td><td class="left">251939 (0:02.55)</td><td class="right">72535</td><td class="left">249911 (0:09.05)</td><td class="right">72696</td><td class="left">258869 (0:01.94)</td><td class="right">76584</td></tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="outline-container-1-6" class="outline-3">
|
||||||
|
<h3 id="sec-1-6"><span class="section-number-3">1.6</span> Bugs? </h3>
|
||||||
|
<div class="outline-text-3" id="text-1-6">
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Unfortunately, for the time being there is no automated test suite. But I
|
||||||
|
ran the compressor manually on non-trivial code, and then I tested that the
|
||||||
|
generated code works as expected. A few hundred times.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
DynarchLIB was started in times when there was no good JS minifier.
|
||||||
|
Therefore I was quite religious about trying to write short code manually,
|
||||||
|
and as such DL contains a lot of syntactic hacks<sup><a class="footref" name="fnr.1" href="#fn.1">1</a></sup> such as “foo == bar ? a
|
||||||
|
= 10 : b = 20”, though the more readable version would clearly be to use
|
||||||
|
“if/else”.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Since the parser/compressor runs fine on DL and jQuery, I'm quite confident
|
||||||
|
that it's solid enough for production use. If you can identify any bugs,
|
||||||
|
I'd love to hear about them (<a href="http://groups.google.com/group/uglifyjs">use the Google Group</a> or email me directly).
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="outline-container-1-7" class="outline-3">
|
||||||
|
<h3 id="sec-1-7"><span class="section-number-3">1.7</span> Links </h3>
|
||||||
|
<div class="outline-text-3" id="text-1-7">
|
||||||
|
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>Twitter: <a href="http://twitter.com/UglifyJS">@UglifyJS</a>
|
||||||
|
</li>
|
||||||
|
<li>Project at GitHub: <a href="http://github.com/mishoo/UglifyJS">http://github.com/mishoo/UglifyJS</a>
|
||||||
|
</li>
|
||||||
|
<li>Google Group: <a href="http://groups.google.com/group/uglifyjs">http://groups.google.com/group/uglifyjs</a>
|
||||||
|
</li>
|
||||||
|
<li>Common Lisp JS parser: <a href="http://marijn.haverbeke.nl/parse-js/">http://marijn.haverbeke.nl/parse-js/</a>
|
||||||
|
</li>
|
||||||
|
<li>JS-to-Lisp compiler: <a href="http://github.com/marijnh/js">http://github.com/marijnh/js</a>
|
||||||
|
</li>
|
||||||
|
<li>Common Lisp JS uglifier: <a href="http://github.com/mishoo/cl-uglify-js">http://github.com/mishoo/cl-uglify-js</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="outline-container-1-8" class="outline-3">
|
||||||
|
<h3 id="sec-1-8"><span class="section-number-3">1.8</span> License </h3>
|
||||||
|
<div class="outline-text-3" id="text-1-8">
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
UglifyJS is released under the BSD license:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<pre class="example">Copyright 2010 (c) Mihai Bazon <mihai.bazon@gmail.com>
|
||||||
|
Based on parse-js (http://marijn.haverbeke.nl/parse-js/).
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the following
|
||||||
|
disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following
|
||||||
|
disclaimer in the documentation and/or other materials
|
||||||
|
provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
|
||||||
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||||
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||||
|
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGE.
|
||||||
|
</pre>
|
||||||
|
|
||||||
|
|
||||||
|
<div id="footnotes">
|
||||||
|
<h2 class="footnotes">Footnotes: </h2>
|
||||||
|
<div id="text-footnotes">
|
||||||
|
<p class="footnote"><sup><a class="footnum" name="fn.1" href="#fnr.1">1</a></sup> I even reported a few bugs and suggested some fixes in the original
|
||||||
|
<a href="http://marijn.haverbeke.nl/parse-js/">parse-js</a> library, and Marijn pushed fixes literally in minutes.
|
||||||
|
</p></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="postamble">
|
||||||
|
<p class="date">Date: 2011-12-09 14:59:08 EET</p>
|
||||||
|
<p class="author">Author: Mihai Bazon</p>
|
||||||
|
<p class="creator">Org version 7.7 with Emacs version 23</p>
|
||||||
|
<a href="http://validator.w3.org/check?uri=referer">Validate XHTML 1.0</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
578
node_modules/handlebars/node_modules/uglify-js/README.org
generated
vendored
Normal file
578
node_modules/handlebars/node_modules/uglify-js/README.org
generated
vendored
Normal file
@@ -0,0 +1,578 @@
|
|||||||
|
#+TITLE: UglifyJS -- a JavaScript parser/compressor/beautifier
|
||||||
|
#+KEYWORDS: javascript, js, parser, compiler, compressor, mangle, minify, minifier
|
||||||
|
#+DESCRIPTION: a JavaScript parser/compressor/beautifier in JavaScript
|
||||||
|
#+STYLE: <link rel="stylesheet" type="text/css" href="docstyle.css" />
|
||||||
|
#+AUTHOR: Mihai Bazon
|
||||||
|
#+EMAIL: mihai.bazon@gmail.com
|
||||||
|
|
||||||
|
* UglifyJS --- a JavaScript parser/compressor/beautifier
|
||||||
|
|
||||||
|
This package implements a general-purpose JavaScript
|
||||||
|
parser/compressor/beautifier toolkit. It is developed on [[http://nodejs.org/][NodeJS]], but it
|
||||||
|
should work on any JavaScript platform supporting the CommonJS module system
|
||||||
|
(and if your platform of choice doesn't support CommonJS, you can easily
|
||||||
|
implement it, or discard the =exports.*= lines from UglifyJS sources).
|
||||||
|
|
||||||
|
The tokenizer/parser generates an abstract syntax tree from JS code. You
|
||||||
|
can then traverse the AST to learn more about the code, or do various
|
||||||
|
manipulations on it. This part is implemented in [[../lib/parse-js.js][parse-js.js]] and it's a
|
||||||
|
port to JavaScript of the excellent [[http://marijn.haverbeke.nl/parse-js/][parse-js]] Common Lisp library from [[http://marijn.haverbeke.nl/][Marijn
|
||||||
|
Haverbeke]].
|
||||||
|
|
||||||
|
( See [[http://github.com/mishoo/cl-uglify-js][cl-uglify-js]] if you're looking for the Common Lisp version of
|
||||||
|
UglifyJS. )
|
||||||
|
|
||||||
|
The second part of this package, implemented in [[../lib/process.js][process.js]], inspects and
|
||||||
|
manipulates the AST generated by the parser to provide the following:
|
||||||
|
|
||||||
|
- ability to re-generate JavaScript code from the AST. Optionally
|
||||||
|
indented---you can use this if you want to “beautify” a program that has
|
||||||
|
been compressed, so that you can inspect the source. But you can also run
|
||||||
|
our code generator to print out an AST without any whitespace, so you
|
||||||
|
achieve compression as well.
|
||||||
|
|
||||||
|
- shorten variable names (usually to single characters). Our mangler will
|
||||||
|
analyze the code and generate proper variable names, depending on scope
|
||||||
|
and usage, and is smart enough to deal with globals defined elsewhere, or
|
||||||
|
with =eval()= calls or =with{}= statements. In short, if =eval()= or
|
||||||
|
=with{}= are used in some scope, then all variables in that scope and any
|
||||||
|
variables in the parent scopes will remain unmangled, and any references
|
||||||
|
to such variables remain unmangled as well.
|
||||||
|
|
||||||
|
- various small optimizations that may lead to faster code but certainly
|
||||||
|
lead to smaller code. Where possible, we do the following:
|
||||||
|
|
||||||
|
- foo["bar"] ==> foo.bar
|
||||||
|
|
||||||
|
- remove block brackets ={}=
|
||||||
|
|
||||||
|
- join consecutive var declarations:
|
||||||
|
var a = 10; var b = 20; ==> var a=10,b=20;
|
||||||
|
|
||||||
|
- resolve simple constant expressions: 1 +2 * 3 ==> 7. We only do the
|
||||||
|
replacement if the result occupies less bytes; for example 1/3 would
|
||||||
|
translate to 0.333333333333, so in this case we don't replace it.
|
||||||
|
|
||||||
|
- consecutive statements in blocks are merged into a sequence; in many
|
||||||
|
cases, this leaves blocks with a single statement, so then we can remove
|
||||||
|
the block brackets.
|
||||||
|
|
||||||
|
- various optimizations for IF statements:
|
||||||
|
|
||||||
|
- if (foo) bar(); else baz(); ==> foo?bar():baz();
|
||||||
|
- if (!foo) bar(); else baz(); ==> foo?baz():bar();
|
||||||
|
- if (foo) bar(); ==> foo&&bar();
|
||||||
|
- if (!foo) bar(); ==> foo||bar();
|
||||||
|
- if (foo) return bar(); else return baz(); ==> return foo?bar():baz();
|
||||||
|
- if (foo) return bar(); else something(); ==> {if(foo)return bar();something()}
|
||||||
|
|
||||||
|
- remove some unreachable code and warn about it (code that follows a
|
||||||
|
=return=, =throw=, =break= or =continue= statement, except
|
||||||
|
function/variable declarations).
|
||||||
|
|
||||||
|
- act a limited version of a pre-processor (c.f. the pre-processor of
|
||||||
|
C/C++) to allow you to safely replace selected global symbols with
|
||||||
|
specified values. When combined with the optimisations above this can
|
||||||
|
make UglifyJS operate slightly more like a compilation process, in
|
||||||
|
that when certain symbols are replaced by constant values, entire code
|
||||||
|
blocks may be optimised away as unreachable.
|
||||||
|
|
||||||
|
** <<Unsafe transformations>>
|
||||||
|
|
||||||
|
The following transformations can in theory break code, although they're
|
||||||
|
probably safe in most practical cases. To enable them you need to pass the
|
||||||
|
=--unsafe= flag.
|
||||||
|
|
||||||
|
*** Calls involving the global Array constructor
|
||||||
|
|
||||||
|
The following transformations occur:
|
||||||
|
|
||||||
|
#+BEGIN_SRC js
|
||||||
|
new Array(1, 2, 3, 4) => [1,2,3,4]
|
||||||
|
Array(a, b, c) => [a,b,c]
|
||||||
|
new Array(5) => Array(5)
|
||||||
|
new Array(a) => Array(a)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
These are all safe if the Array name isn't redefined. JavaScript does allow
|
||||||
|
one to globally redefine Array (and pretty much everything, in fact) but I
|
||||||
|
personally don't see why would anyone do that.
|
||||||
|
|
||||||
|
UglifyJS does handle the case where Array is redefined locally, or even
|
||||||
|
globally but with a =function= or =var= declaration. Therefore, in the
|
||||||
|
following cases UglifyJS *doesn't touch* calls or instantiations of Array:
|
||||||
|
|
||||||
|
#+BEGIN_SRC js
|
||||||
|
// case 1. globally declared variable
|
||||||
|
var Array;
|
||||||
|
new Array(1, 2, 3);
|
||||||
|
Array(a, b);
|
||||||
|
|
||||||
|
// or (can be declared later)
|
||||||
|
new Array(1, 2, 3);
|
||||||
|
var Array;
|
||||||
|
|
||||||
|
// or (can be a function)
|
||||||
|
new Array(1, 2, 3);
|
||||||
|
function Array() { ... }
|
||||||
|
|
||||||
|
// case 2. declared in a function
|
||||||
|
(function(){
|
||||||
|
a = new Array(1, 2, 3);
|
||||||
|
b = Array(5, 6);
|
||||||
|
var Array;
|
||||||
|
})();
|
||||||
|
|
||||||
|
// or
|
||||||
|
(function(Array){
|
||||||
|
return Array(5, 6, 7);
|
||||||
|
})();
|
||||||
|
|
||||||
|
// or
|
||||||
|
(function(){
|
||||||
|
return new Array(1, 2, 3, 4);
|
||||||
|
function Array() { ... }
|
||||||
|
})();
|
||||||
|
|
||||||
|
// etc.
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
*** =obj.toString()= ==> =obj+“”=
|
||||||
|
|
||||||
|
** Install (NPM)
|
||||||
|
|
||||||
|
UglifyJS is now available through NPM --- =npm install uglify-js= should do
|
||||||
|
the job.
|
||||||
|
|
||||||
|
** Install latest code from GitHub
|
||||||
|
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
## clone the repository
|
||||||
|
mkdir -p /where/you/wanna/put/it
|
||||||
|
cd /where/you/wanna/put/it
|
||||||
|
git clone git://github.com/mishoo/UglifyJS.git
|
||||||
|
|
||||||
|
## make the module available to Node
|
||||||
|
mkdir -p ~/.node_libraries/
|
||||||
|
cd ~/.node_libraries/
|
||||||
|
ln -s /where/you/wanna/put/it/UglifyJS/uglify-js.js
|
||||||
|
|
||||||
|
## and if you want the CLI script too:
|
||||||
|
mkdir -p ~/bin
|
||||||
|
cd ~/bin
|
||||||
|
ln -s /where/you/wanna/put/it/UglifyJS/bin/uglifyjs
|
||||||
|
# (then add ~/bin to your $PATH if it's not there already)
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
** Usage
|
||||||
|
|
||||||
|
There is a command-line tool that exposes the functionality of this library
|
||||||
|
for your shell-scripting needs:
|
||||||
|
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
uglifyjs [ options... ] [ filename ]
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
=filename= should be the last argument and should name the file from which
|
||||||
|
to read the JavaScript code. If you don't specify it, it will read code
|
||||||
|
from STDIN.
|
||||||
|
|
||||||
|
Supported options:
|
||||||
|
|
||||||
|
- =-b= or =--beautify= --- output indented code; when passed, additional
|
||||||
|
options control the beautifier:
|
||||||
|
|
||||||
|
- =-i N= or =--indent N= --- indentation level (number of spaces)
|
||||||
|
|
||||||
|
- =-q= or =--quote-keys= --- quote keys in literal objects (by default,
|
||||||
|
only keys that cannot be identifier names will be quotes).
|
||||||
|
|
||||||
|
- =-c= or =----consolidate-primitive-values= --- consolidates null, Boolean,
|
||||||
|
and String values. Known as aliasing in the Closure Compiler. Worsens the
|
||||||
|
data compression ratio of gzip.
|
||||||
|
|
||||||
|
- =--ascii= --- pass this argument to encode non-ASCII characters as
|
||||||
|
=\uXXXX= sequences. By default UglifyJS won't bother to do it and will
|
||||||
|
output Unicode characters instead. (the output is always encoded in UTF8,
|
||||||
|
but if you pass this option you'll only get ASCII).
|
||||||
|
|
||||||
|
- =-nm= or =--no-mangle= --- don't mangle names.
|
||||||
|
|
||||||
|
- =-nmf= or =--no-mangle-functions= -- in case you want to mangle variable
|
||||||
|
names, but not touch function names.
|
||||||
|
|
||||||
|
- =-ns= or =--no-squeeze= --- don't call =ast_squeeze()= (which does various
|
||||||
|
optimizations that result in smaller, less readable code).
|
||||||
|
|
||||||
|
- =-mt= or =--mangle-toplevel= --- mangle names in the toplevel scope too
|
||||||
|
(by default we don't do this).
|
||||||
|
|
||||||
|
- =--no-seqs= --- when =ast_squeeze()= is called (thus, unless you pass
|
||||||
|
=--no-squeeze=) it will reduce consecutive statements in blocks into a
|
||||||
|
sequence. For example, "a = 10; b = 20; foo();" will be written as
|
||||||
|
"a=10,b=20,foo();". In various occasions, this allows us to discard the
|
||||||
|
block brackets (since the block becomes a single statement). This is ON
|
||||||
|
by default because it seems safe and saves a few hundred bytes on some
|
||||||
|
libs that I tested it on, but pass =--no-seqs= to disable it.
|
||||||
|
|
||||||
|
- =--no-dead-code= --- by default, UglifyJS will remove code that is
|
||||||
|
obviously unreachable (code that follows a =return=, =throw=, =break= or
|
||||||
|
=continue= statement and is not a function/variable declaration). Pass
|
||||||
|
this option to disable this optimization.
|
||||||
|
|
||||||
|
- =-nc= or =--no-copyright= --- by default, =uglifyjs= will keep the initial
|
||||||
|
comment tokens in the generated code (assumed to be copyright information
|
||||||
|
etc.). If you pass this it will discard it.
|
||||||
|
|
||||||
|
- =-o filename= or =--output filename= --- put the result in =filename=. If
|
||||||
|
this isn't given, the result goes to standard output (or see next one).
|
||||||
|
|
||||||
|
- =--overwrite= --- if the code is read from a file (not from STDIN) and you
|
||||||
|
pass =--overwrite= then the output will be written in the same file.
|
||||||
|
|
||||||
|
- =--ast= --- pass this if you want to get the Abstract Syntax Tree instead
|
||||||
|
of JavaScript as output. Useful for debugging or learning more about the
|
||||||
|
internals.
|
||||||
|
|
||||||
|
- =-v= or =--verbose= --- output some notes on STDERR (for now just how long
|
||||||
|
each operation takes).
|
||||||
|
|
||||||
|
- =-d SYMBOL[=VALUE]= or =--define SYMBOL[=VALUE]= --- will replace
|
||||||
|
all instances of the specified symbol where used as an identifier
|
||||||
|
(except where symbol has properly declared by a var declaration or
|
||||||
|
use as function parameter or similar) with the specified value. This
|
||||||
|
argument may be specified multiple times to define multiple
|
||||||
|
symbols - if no value is specified the symbol will be replaced with
|
||||||
|
the value =true=, or you can specify a numeric value (such as
|
||||||
|
=1024=), a quoted string value (such as ="object"= or
|
||||||
|
='https://github.com'=), or the name of another symbol or keyword
|
||||||
|
(such as =null= or =document=).
|
||||||
|
This allows you, for example, to assign meaningful names to key
|
||||||
|
constant values but discard the symbolic names in the uglified
|
||||||
|
version for brevity/efficiency, or when used wth care, allows
|
||||||
|
UglifyJS to operate as a form of *conditional compilation*
|
||||||
|
whereby defining appropriate values may, by dint of the constant
|
||||||
|
folding and dead code removal features above, remove entire
|
||||||
|
superfluous code blocks (e.g. completely remove instrumentation or
|
||||||
|
trace code for production use).
|
||||||
|
Where string values are being defined, the handling of quotes are
|
||||||
|
likely to be subject to the specifics of your command shell
|
||||||
|
environment, so you may need to experiment with quoting styles
|
||||||
|
depending on your platform, or you may find the option
|
||||||
|
=--define-from-module= more suitable for use.
|
||||||
|
|
||||||
|
- =-define-from-module SOMEMODULE= --- will load the named module (as
|
||||||
|
per the NodeJS =require()= function) and iterate all the exported
|
||||||
|
properties of the module defining them as symbol names to be defined
|
||||||
|
(as if by the =--define= option) per the name of each property
|
||||||
|
(i.e. without the module name prefix) and given the value of the
|
||||||
|
property. This is a much easier way to handle and document groups of
|
||||||
|
symbols to be defined rather than a large number of =--define=
|
||||||
|
options.
|
||||||
|
|
||||||
|
- =--unsafe= --- enable other additional optimizations that are known to be
|
||||||
|
unsafe in some contrived situations, but could still be generally useful.
|
||||||
|
For now only these:
|
||||||
|
|
||||||
|
- foo.toString() ==> foo+""
|
||||||
|
- new Array(x,...) ==> [x,...]
|
||||||
|
- new Array(x) ==> Array(x)
|
||||||
|
|
||||||
|
- =--max-line-len= (default 32K characters) --- add a newline after around
|
||||||
|
32K characters. I've seen both FF and Chrome croak when all the code was
|
||||||
|
on a single line of around 670K. Pass --max-line-len 0 to disable this
|
||||||
|
safety feature.
|
||||||
|
|
||||||
|
- =--reserved-names= --- some libraries rely on certain names to be used, as
|
||||||
|
pointed out in issue #92 and #81, so this option allow you to exclude such
|
||||||
|
names from the mangler. For example, to keep names =require= and =$super=
|
||||||
|
intact you'd specify --reserved-names "require,$super".
|
||||||
|
|
||||||
|
- =--inline-script= -- when you want to include the output literally in an
|
||||||
|
HTML =<script>= tag you can use this option to prevent =</script= from
|
||||||
|
showing up in the output.
|
||||||
|
|
||||||
|
- =--lift-vars= -- when you pass this, UglifyJS will apply the following
|
||||||
|
transformations (see the notes in API, =ast_lift_variables=):
|
||||||
|
|
||||||
|
- put all =var= declarations at the start of the scope
|
||||||
|
- make sure a variable is declared only once
|
||||||
|
- discard unused function arguments
|
||||||
|
- discard unused inner (named) functions
|
||||||
|
- finally, try to merge assignments into that one =var= declaration, if
|
||||||
|
possible.
|
||||||
|
|
||||||
|
*** API
|
||||||
|
|
||||||
|
To use the library from JavaScript, you'd do the following (example for
|
||||||
|
NodeJS):
|
||||||
|
|
||||||
|
#+BEGIN_SRC js
|
||||||
|
var jsp = require("uglify-js").parser;
|
||||||
|
var pro = require("uglify-js").uglify;
|
||||||
|
|
||||||
|
var orig_code = "... JS code here";
|
||||||
|
var ast = jsp.parse(orig_code); // parse code and get the initial AST
|
||||||
|
ast = pro.ast_mangle(ast); // get a new AST with mangled names
|
||||||
|
ast = pro.ast_squeeze(ast); // get an AST with compression optimizations
|
||||||
|
var final_code = pro.gen_code(ast); // compressed code here
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
The above performs the full compression that is possible right now. As you
|
||||||
|
can see, there are a sequence of steps which you can apply. For example if
|
||||||
|
you want compressed output but for some reason you don't want to mangle
|
||||||
|
variable names, you would simply skip the line that calls
|
||||||
|
=pro.ast_mangle(ast)=.
|
||||||
|
|
||||||
|
Some of these functions take optional arguments. Here's a description:
|
||||||
|
|
||||||
|
- =jsp.parse(code, strict_semicolons)= -- parses JS code and returns an AST.
|
||||||
|
=strict_semicolons= is optional and defaults to =false=. If you pass
|
||||||
|
=true= then the parser will throw an error when it expects a semicolon and
|
||||||
|
it doesn't find it. For most JS code you don't want that, but it's useful
|
||||||
|
if you want to strictly sanitize your code.
|
||||||
|
|
||||||
|
- =pro.ast_lift_variables(ast)= -- merge and move =var= declarations to the
|
||||||
|
scop of the scope; discard unused function arguments or variables; discard
|
||||||
|
unused (named) inner functions. It also tries to merge assignments
|
||||||
|
following the =var= declaration into it.
|
||||||
|
|
||||||
|
If your code is very hand-optimized concerning =var= declarations, this
|
||||||
|
lifting variable declarations might actually increase size. For me it
|
||||||
|
helps out. On jQuery it adds 865 bytes (243 after gzip). YMMV. Also
|
||||||
|
note that (since it's not enabled by default) this operation isn't yet
|
||||||
|
heavily tested (please report if you find issues!).
|
||||||
|
|
||||||
|
Note that although it might increase the image size (on jQuery it gains
|
||||||
|
865 bytes, 243 after gzip) it's technically more correct: in certain
|
||||||
|
situations, dead code removal might drop variable declarations, which
|
||||||
|
would not happen if the variables are lifted in advance.
|
||||||
|
|
||||||
|
Here's an example of what it does:
|
||||||
|
|
||||||
|
#+BEGIN_SRC js
|
||||||
|
function f(a, b, c, d, e) {
|
||||||
|
var q;
|
||||||
|
var w;
|
||||||
|
w = 10;
|
||||||
|
q = 20;
|
||||||
|
for (var i = 1; i < 10; ++i) {
|
||||||
|
var boo = foo(a);
|
||||||
|
}
|
||||||
|
for (var i = 0; i < 1; ++i) {
|
||||||
|
var boo = bar(c);
|
||||||
|
}
|
||||||
|
function foo(){ ... }
|
||||||
|
function bar(){ ... }
|
||||||
|
function baz(){ ... }
|
||||||
|
}
|
||||||
|
|
||||||
|
// transforms into ==>
|
||||||
|
|
||||||
|
function f(a, b, c) {
|
||||||
|
var i, boo, w = 10, q = 20;
|
||||||
|
for (i = 1; i < 10; ++i) {
|
||||||
|
boo = foo(a);
|
||||||
|
}
|
||||||
|
for (i = 0; i < 1; ++i) {
|
||||||
|
boo = bar(c);
|
||||||
|
}
|
||||||
|
function foo() { ... }
|
||||||
|
function bar() { ... }
|
||||||
|
}
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
- =pro.ast_mangle(ast, options)= -- generates a new AST containing mangled
|
||||||
|
(compressed) variable and function names. It supports the following
|
||||||
|
options:
|
||||||
|
|
||||||
|
- =toplevel= -- mangle toplevel names (by default we don't touch them).
|
||||||
|
- =except= -- an array of names to exclude from compression.
|
||||||
|
- =defines= -- an object with properties named after symbols to
|
||||||
|
replace (see the =--define= option for the script) and the values
|
||||||
|
representing the AST replacement value.
|
||||||
|
|
||||||
|
- =pro.ast_squeeze(ast, options)= -- employs further optimizations designed
|
||||||
|
to reduce the size of the code that =gen_code= would generate from the
|
||||||
|
AST. Returns a new AST. =options= can be a hash; the supported options
|
||||||
|
are:
|
||||||
|
|
||||||
|
- =make_seqs= (default true) which will cause consecutive statements in a
|
||||||
|
block to be merged using the "sequence" (comma) operator
|
||||||
|
|
||||||
|
- =dead_code= (default true) which will remove unreachable code.
|
||||||
|
|
||||||
|
- =pro.gen_code(ast, options)= -- generates JS code from the AST. By
|
||||||
|
default it's minified, but using the =options= argument you can get nicely
|
||||||
|
formatted output. =options= is, well, optional :-) and if you pass it it
|
||||||
|
must be an object and supports the following properties (below you can see
|
||||||
|
the default values):
|
||||||
|
|
||||||
|
- =beautify: false= -- pass =true= if you want indented output
|
||||||
|
- =indent_start: 0= (only applies when =beautify= is =true=) -- initial
|
||||||
|
indentation in spaces
|
||||||
|
- =indent_level: 4= (only applies when =beautify= is =true=) --
|
||||||
|
indentation level, in spaces (pass an even number)
|
||||||
|
- =quote_keys: false= -- if you pass =true= it will quote all keys in
|
||||||
|
literal objects
|
||||||
|
- =space_colon: false= (only applies when =beautify= is =true=) -- wether
|
||||||
|
to put a space before the colon in object literals
|
||||||
|
- =ascii_only: false= -- pass =true= if you want to encode non-ASCII
|
||||||
|
characters as =\uXXXX=.
|
||||||
|
- =inline_script: false= -- pass =true= to escape occurrences of
|
||||||
|
=</script= in strings
|
||||||
|
|
||||||
|
*** Beautifier shortcoming -- no more comments
|
||||||
|
|
||||||
|
The beautifier can be used as a general purpose indentation tool. It's
|
||||||
|
useful when you want to make a minified file readable. One limitation,
|
||||||
|
though, is that it discards all comments, so you don't really want to use it
|
||||||
|
to reformat your code, unless you don't have, or don't care about, comments.
|
||||||
|
|
||||||
|
In fact it's not the beautifier who discards comments --- they are dumped at
|
||||||
|
the parsing stage, when we build the initial AST. Comments don't really
|
||||||
|
make sense in the AST, and while we could add nodes for them, it would be
|
||||||
|
inconvenient because we'd have to add special rules to ignore them at all
|
||||||
|
the processing stages.
|
||||||
|
|
||||||
|
*** Use as a code pre-processor
|
||||||
|
|
||||||
|
The =--define= option can be used, particularly when combined with the
|
||||||
|
constant folding logic, as a form of pre-processor to enable or remove
|
||||||
|
particular constructions, such as might be used for instrumenting
|
||||||
|
development code, or to produce variations aimed at a specific
|
||||||
|
platform.
|
||||||
|
|
||||||
|
The code below illustrates the way this can be done, and how the
|
||||||
|
symbol replacement is performed.
|
||||||
|
|
||||||
|
#+BEGIN_SRC js
|
||||||
|
CLAUSE1: if (typeof DEVMODE === 'undefined') {
|
||||||
|
DEVMODE = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLAUSE2: function init() {
|
||||||
|
if (DEVMODE) {
|
||||||
|
console.log("init() called");
|
||||||
|
}
|
||||||
|
....
|
||||||
|
DEVMODE && console.log("init() complete");
|
||||||
|
}
|
||||||
|
|
||||||
|
CLAUSE3: function reportDeviceStatus(device) {
|
||||||
|
var DEVMODE = device.mode, DEVNAME = device.name;
|
||||||
|
if (DEVMODE === 'open') {
|
||||||
|
....
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
When the above code is normally executed, the undeclared global
|
||||||
|
variable =DEVMODE= will be assigned the value *true* (see =CLAUSE1=)
|
||||||
|
and so the =init()= function (=CLAUSE2=) will write messages to the
|
||||||
|
console log when executed, but in =CLAUSE3= a locally declared
|
||||||
|
variable will mask access to the =DEVMODE= global symbol.
|
||||||
|
|
||||||
|
If the above code is processed by UglifyJS with an argument of
|
||||||
|
=--define DEVMODE=false= then UglifyJS will replace =DEVMODE= with the
|
||||||
|
boolean constant value *false* within =CLAUSE1= and =CLAUSE2=, but it
|
||||||
|
will leave =CLAUSE3= as it stands because there =DEVMODE= resolves to
|
||||||
|
a validly declared variable.
|
||||||
|
|
||||||
|
And more so, the constant-folding features of UglifyJS will recognise
|
||||||
|
that the =if= condition of =CLAUSE1= is thus always false, and so will
|
||||||
|
remove the test and body of =CLAUSE1= altogether (including the
|
||||||
|
otherwise slightly problematical statement =false = true;= which it
|
||||||
|
will have formed by replacing =DEVMODE= in the body). Similarly,
|
||||||
|
within =CLAUSE2= both calls to =console.log()= will be removed
|
||||||
|
altogether.
|
||||||
|
|
||||||
|
In this way you can mimic, to a limited degree, the functionality of
|
||||||
|
the C/C++ pre-processor to enable or completely remove blocks
|
||||||
|
depending on how certain symbols are defined - perhaps using UglifyJS
|
||||||
|
to generate different versions of source aimed at different
|
||||||
|
environments
|
||||||
|
|
||||||
|
It is recommmended (but not made mandatory) that symbols designed for
|
||||||
|
this purpose are given names consisting of =UPPER_CASE_LETTERS= to
|
||||||
|
distinguish them from other (normal) symbols and avoid the sort of
|
||||||
|
clash that =CLAUSE3= above illustrates.
|
||||||
|
|
||||||
|
** Compression -- how good is it?
|
||||||
|
|
||||||
|
Here are updated statistics. (I also updated my Google Closure and YUI
|
||||||
|
installations).
|
||||||
|
|
||||||
|
We're still a lot better than YUI in terms of compression, though slightly
|
||||||
|
slower. We're still a lot faster than Closure, and compression after gzip
|
||||||
|
is comparable.
|
||||||
|
|
||||||
|
| File | UglifyJS | UglifyJS+gzip | Closure | Closure+gzip | YUI | YUI+gzip |
|
||||||
|
|-----------------------------+------------------+---------------+------------------+--------------+------------------+----------|
|
||||||
|
| jquery-1.6.2.js | 91001 (0:01.59) | 31896 | 90678 (0:07.40) | 31979 | 101527 (0:01.82) | 34646 |
|
||||||
|
| paper.js | 142023 (0:01.65) | 43334 | 134301 (0:07.42) | 42495 | 173383 (0:01.58) | 48785 |
|
||||||
|
| prototype.js | 88544 (0:01.09) | 26680 | 86955 (0:06.97) | 26326 | 92130 (0:00.79) | 28624 |
|
||||||
|
| thelib-full.js (DynarchLIB) | 251939 (0:02.55) | 72535 | 249911 (0:09.05) | 72696 | 258869 (0:01.94) | 76584 |
|
||||||
|
|
||||||
|
** Bugs?
|
||||||
|
|
||||||
|
Unfortunately, for the time being there is no automated test suite. But I
|
||||||
|
ran the compressor manually on non-trivial code, and then I tested that the
|
||||||
|
generated code works as expected. A few hundred times.
|
||||||
|
|
||||||
|
DynarchLIB was started in times when there was no good JS minifier.
|
||||||
|
Therefore I was quite religious about trying to write short code manually,
|
||||||
|
and as such DL contains a lot of syntactic hacks[1] such as “foo == bar ? a
|
||||||
|
= 10 : b = 20”, though the more readable version would clearly be to use
|
||||||
|
“if/else”.
|
||||||
|
|
||||||
|
Since the parser/compressor runs fine on DL and jQuery, I'm quite confident
|
||||||
|
that it's solid enough for production use. If you can identify any bugs,
|
||||||
|
I'd love to hear about them ([[http://groups.google.com/group/uglifyjs][use the Google Group]] or email me directly).
|
||||||
|
|
||||||
|
[1] I even reported a few bugs and suggested some fixes in the original
|
||||||
|
[[http://marijn.haverbeke.nl/parse-js/][parse-js]] library, and Marijn pushed fixes literally in minutes.
|
||||||
|
|
||||||
|
** Links
|
||||||
|
|
||||||
|
- Twitter: [[http://twitter.com/UglifyJS][@UglifyJS]]
|
||||||
|
- Project at GitHub: [[http://github.com/mishoo/UglifyJS][http://github.com/mishoo/UglifyJS]]
|
||||||
|
- Google Group: [[http://groups.google.com/group/uglifyjs][http://groups.google.com/group/uglifyjs]]
|
||||||
|
- Common Lisp JS parser: [[http://marijn.haverbeke.nl/parse-js/][http://marijn.haverbeke.nl/parse-js/]]
|
||||||
|
- JS-to-Lisp compiler: [[http://github.com/marijnh/js][http://github.com/marijnh/js]]
|
||||||
|
- Common Lisp JS uglifier: [[http://github.com/mishoo/cl-uglify-js][http://github.com/mishoo/cl-uglify-js]]
|
||||||
|
|
||||||
|
** License
|
||||||
|
|
||||||
|
UglifyJS is released under the BSD license:
|
||||||
|
|
||||||
|
#+BEGIN_EXAMPLE
|
||||||
|
Copyright 2010 (c) Mihai Bazon <mihai.bazon@gmail.com>
|
||||||
|
Based on parse-js (http://marijn.haverbeke.nl/parse-js/).
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions
|
||||||
|
are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above
|
||||||
|
copyright notice, this list of conditions and the following
|
||||||
|
disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following
|
||||||
|
disclaimer in the documentation and/or other materials
|
||||||
|
provided with the distribution.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY
|
||||||
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
|
||||||
|
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||||
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||||
|
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
||||||
|
THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGE.
|
||||||
|
#+END_EXAMPLE
|
||||||
332
node_modules/handlebars/node_modules/uglify-js/bin/uglifyjs
generated
vendored
Executable file
332
node_modules/handlebars/node_modules/uglify-js/bin/uglifyjs
generated
vendored
Executable file
@@ -0,0 +1,332 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
// -*- js -*-
|
||||||
|
|
||||||
|
global.sys = require(/^v0\.[012]/.test(process.version) ? "sys" : "util");
|
||||||
|
var fs = require("fs");
|
||||||
|
var uglify = require("uglify-js"), // symlink ~/.node_libraries/uglify-js.js to ../uglify-js.js
|
||||||
|
consolidator = uglify.consolidator,
|
||||||
|
jsp = uglify.parser,
|
||||||
|
pro = uglify.uglify;
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
ast: false,
|
||||||
|
consolidate: false,
|
||||||
|
mangle: true,
|
||||||
|
mangle_toplevel: false,
|
||||||
|
no_mangle_functions: false,
|
||||||
|
squeeze: true,
|
||||||
|
make_seqs: true,
|
||||||
|
dead_code: true,
|
||||||
|
verbose: false,
|
||||||
|
show_copyright: true,
|
||||||
|
out_same_file: false,
|
||||||
|
max_line_length: 32 * 1024,
|
||||||
|
unsafe: false,
|
||||||
|
reserved_names: null,
|
||||||
|
defines: { },
|
||||||
|
lift_vars: false,
|
||||||
|
codegen_options: {
|
||||||
|
ascii_only: false,
|
||||||
|
beautify: false,
|
||||||
|
indent_level: 4,
|
||||||
|
indent_start: 0,
|
||||||
|
quote_keys: false,
|
||||||
|
space_colon: false,
|
||||||
|
inline_script: false
|
||||||
|
},
|
||||||
|
make: false,
|
||||||
|
output: true // stdout
|
||||||
|
};
|
||||||
|
|
||||||
|
var args = jsp.slice(process.argv, 2);
|
||||||
|
var filename;
|
||||||
|
|
||||||
|
out: while (args.length > 0) {
|
||||||
|
var v = args.shift();
|
||||||
|
switch (v) {
|
||||||
|
case "-b":
|
||||||
|
case "--beautify":
|
||||||
|
options.codegen_options.beautify = true;
|
||||||
|
break;
|
||||||
|
case "-c":
|
||||||
|
case "--consolidate-primitive-values":
|
||||||
|
options.consolidate = true;
|
||||||
|
break;
|
||||||
|
case "-i":
|
||||||
|
case "--indent":
|
||||||
|
options.codegen_options.indent_level = args.shift();
|
||||||
|
break;
|
||||||
|
case "-q":
|
||||||
|
case "--quote-keys":
|
||||||
|
options.codegen_options.quote_keys = true;
|
||||||
|
break;
|
||||||
|
case "-mt":
|
||||||
|
case "--mangle-toplevel":
|
||||||
|
options.mangle_toplevel = true;
|
||||||
|
break;
|
||||||
|
case "-nmf":
|
||||||
|
case "--no-mangle-functions":
|
||||||
|
options.no_mangle_functions = true;
|
||||||
|
break;
|
||||||
|
case "--no-mangle":
|
||||||
|
case "-nm":
|
||||||
|
options.mangle = false;
|
||||||
|
break;
|
||||||
|
case "--no-squeeze":
|
||||||
|
case "-ns":
|
||||||
|
options.squeeze = false;
|
||||||
|
break;
|
||||||
|
case "--no-seqs":
|
||||||
|
options.make_seqs = false;
|
||||||
|
break;
|
||||||
|
case "--no-dead-code":
|
||||||
|
options.dead_code = false;
|
||||||
|
break;
|
||||||
|
case "--no-copyright":
|
||||||
|
case "-nc":
|
||||||
|
options.show_copyright = false;
|
||||||
|
break;
|
||||||
|
case "-o":
|
||||||
|
case "--output":
|
||||||
|
options.output = args.shift();
|
||||||
|
break;
|
||||||
|
case "--overwrite":
|
||||||
|
options.out_same_file = true;
|
||||||
|
break;
|
||||||
|
case "-v":
|
||||||
|
case "--verbose":
|
||||||
|
options.verbose = true;
|
||||||
|
break;
|
||||||
|
case "--ast":
|
||||||
|
options.ast = true;
|
||||||
|
break;
|
||||||
|
case "--unsafe":
|
||||||
|
options.unsafe = true;
|
||||||
|
break;
|
||||||
|
case "--max-line-len":
|
||||||
|
options.max_line_length = parseInt(args.shift(), 10);
|
||||||
|
break;
|
||||||
|
case "--reserved-names":
|
||||||
|
options.reserved_names = args.shift().split(",");
|
||||||
|
break;
|
||||||
|
case "--lift-vars":
|
||||||
|
options.lift_vars = true;
|
||||||
|
break;
|
||||||
|
case "-d":
|
||||||
|
case "--define":
|
||||||
|
var defarg = args.shift();
|
||||||
|
try {
|
||||||
|
var defsym = function(sym) {
|
||||||
|
// KEYWORDS_ATOM doesn't include NaN or Infinity - should we check
|
||||||
|
// for them too ?? We don't check reserved words and the like as the
|
||||||
|
// define values are only substituted AFTER parsing
|
||||||
|
if (jsp.KEYWORDS_ATOM.hasOwnProperty(sym)) {
|
||||||
|
throw "Don't define values for inbuilt constant '"+sym+"'";
|
||||||
|
}
|
||||||
|
return sym;
|
||||||
|
},
|
||||||
|
defval = function(v) {
|
||||||
|
if (v.match(/^"(.*)"$/) || v.match(/^'(.*)'$/)) {
|
||||||
|
return [ "string", RegExp.$1 ];
|
||||||
|
}
|
||||||
|
else if (!isNaN(parseFloat(v))) {
|
||||||
|
return [ "num", parseFloat(v) ];
|
||||||
|
}
|
||||||
|
else if (v.match(/^[a-z\$_][a-z\$_0-9]*$/i)) {
|
||||||
|
return [ "name", v ];
|
||||||
|
}
|
||||||
|
else if (!v.match(/"/)) {
|
||||||
|
return [ "string", v ];
|
||||||
|
}
|
||||||
|
else if (!v.match(/'/)) {
|
||||||
|
return [ "string", v ];
|
||||||
|
}
|
||||||
|
throw "Can't understand the specified value: "+v;
|
||||||
|
};
|
||||||
|
if (defarg.match(/^([a-z_\$][a-z_\$0-9]*)(=(.*))?$/i)) {
|
||||||
|
var sym = defsym(RegExp.$1),
|
||||||
|
val = RegExp.$2 ? defval(RegExp.$2.substr(1)) : [ 'name', 'true' ];
|
||||||
|
options.defines[sym] = val;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw "The --define option expects SYMBOL[=value]";
|
||||||
|
}
|
||||||
|
} catch(ex) {
|
||||||
|
sys.print("ERROR: In option --define "+defarg+"\n"+ex+"\n");
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "--define-from-module":
|
||||||
|
var defmodarg = args.shift(),
|
||||||
|
defmodule = require(defmodarg),
|
||||||
|
sym,
|
||||||
|
val;
|
||||||
|
for (sym in defmodule) {
|
||||||
|
if (defmodule.hasOwnProperty(sym)) {
|
||||||
|
options.defines[sym] = function(val) {
|
||||||
|
if (typeof val == "string")
|
||||||
|
return [ "string", val ];
|
||||||
|
if (typeof val == "number")
|
||||||
|
return [ "num", val ];
|
||||||
|
if (val === true)
|
||||||
|
return [ 'name', 'true' ];
|
||||||
|
if (val === false)
|
||||||
|
return [ 'name', 'false' ];
|
||||||
|
if (val === null)
|
||||||
|
return [ 'name', 'null' ];
|
||||||
|
if (val === undefined)
|
||||||
|
return [ 'name', 'undefined' ];
|
||||||
|
sys.print("ERROR: In option --define-from-module "+defmodarg+"\n");
|
||||||
|
sys.print("ERROR: Unknown object type for: "+sym+"="+val+"\n");
|
||||||
|
process.exit(1);
|
||||||
|
return null;
|
||||||
|
}(defmodule[sym]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "--ascii":
|
||||||
|
options.codegen_options.ascii_only = true;
|
||||||
|
break;
|
||||||
|
case "--make":
|
||||||
|
options.make = true;
|
||||||
|
break;
|
||||||
|
case "--inline-script":
|
||||||
|
options.codegen_options.inline_script = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
filename = v;
|
||||||
|
break out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.verbose) {
|
||||||
|
pro.set_logger(function(msg){
|
||||||
|
sys.debug(msg);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
jsp.set_logger(function(msg){
|
||||||
|
sys.debug(msg);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (options.make) {
|
||||||
|
options.out_same_file = false; // doesn't make sense in this case
|
||||||
|
var makefile = JSON.parse(fs.readFileSync(filename || "Makefile.uglify.js").toString());
|
||||||
|
output(makefile.files.map(function(file){
|
||||||
|
var code = fs.readFileSync(file.name);
|
||||||
|
if (file.module) {
|
||||||
|
code = "!function(exports, global){global = this;\n" + code + "\n;this." + file.module + " = exports;}({})";
|
||||||
|
}
|
||||||
|
else if (file.hide) {
|
||||||
|
code = "(function(){" + code + "}());";
|
||||||
|
}
|
||||||
|
return squeeze_it(code);
|
||||||
|
}).join("\n"));
|
||||||
|
}
|
||||||
|
else if (filename) {
|
||||||
|
fs.readFile(filename, "utf8", function(err, text){
|
||||||
|
if (err) throw err;
|
||||||
|
output(squeeze_it(text));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var stdin = process.openStdin();
|
||||||
|
stdin.setEncoding("utf8");
|
||||||
|
var text = "";
|
||||||
|
stdin.on("data", function(chunk){
|
||||||
|
text += chunk;
|
||||||
|
});
|
||||||
|
stdin.on("end", function() {
|
||||||
|
output(squeeze_it(text));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function output(text) {
|
||||||
|
var out;
|
||||||
|
if (options.out_same_file && filename)
|
||||||
|
options.output = filename;
|
||||||
|
if (options.output === true) {
|
||||||
|
out = process.stdout;
|
||||||
|
} else {
|
||||||
|
out = fs.createWriteStream(options.output, {
|
||||||
|
flags: "w",
|
||||||
|
encoding: "utf8",
|
||||||
|
mode: 0644
|
||||||
|
});
|
||||||
|
}
|
||||||
|
out.write(text.replace(/;*$/, ";"));
|
||||||
|
if (options.output !== true) {
|
||||||
|
out.end();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// --------- main ends here.
|
||||||
|
|
||||||
|
function show_copyright(comments) {
|
||||||
|
var ret = "";
|
||||||
|
for (var i = 0; i < comments.length; ++i) {
|
||||||
|
var c = comments[i];
|
||||||
|
if (c.type == "comment1") {
|
||||||
|
ret += "//" + c.value + "\n";
|
||||||
|
} else {
|
||||||
|
ret += "/*" + c.value + "*/";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
|
||||||
|
function squeeze_it(code) {
|
||||||
|
var result = "";
|
||||||
|
if (options.show_copyright) {
|
||||||
|
var tok = jsp.tokenizer(code), c;
|
||||||
|
c = tok();
|
||||||
|
result += show_copyright(c.comments_before);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
var ast = time_it("parse", function(){ return jsp.parse(code); });
|
||||||
|
if (options.consolidate) ast = time_it("consolidate", function(){
|
||||||
|
return consolidator.ast_consolidate(ast);
|
||||||
|
});
|
||||||
|
if (options.lift_vars) {
|
||||||
|
ast = time_it("lift", function(){ return pro.ast_lift_variables(ast); });
|
||||||
|
}
|
||||||
|
if (options.mangle) ast = time_it("mangle", function(){
|
||||||
|
return pro.ast_mangle(ast, {
|
||||||
|
toplevel : options.mangle_toplevel,
|
||||||
|
defines : options.defines,
|
||||||
|
except : options.reserved_names,
|
||||||
|
no_functions : options.no_mangle_functions
|
||||||
|
});
|
||||||
|
});
|
||||||
|
if (options.squeeze) ast = time_it("squeeze", function(){
|
||||||
|
ast = pro.ast_squeeze(ast, {
|
||||||
|
make_seqs : options.make_seqs,
|
||||||
|
dead_code : options.dead_code,
|
||||||
|
keep_comps : !options.unsafe
|
||||||
|
});
|
||||||
|
if (options.unsafe)
|
||||||
|
ast = pro.ast_squeeze_more(ast);
|
||||||
|
return ast;
|
||||||
|
});
|
||||||
|
if (options.ast)
|
||||||
|
return sys.inspect(ast, null, null);
|
||||||
|
result += time_it("generate", function(){ return pro.gen_code(ast, options.codegen_options) });
|
||||||
|
if (!options.codegen_options.beautify && options.max_line_length) {
|
||||||
|
result = time_it("split", function(){ return pro.split_lines(result, options.max_line_length) });
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
} catch(ex) {
|
||||||
|
sys.debug(ex.stack);
|
||||||
|
sys.debug(sys.inspect(ex));
|
||||||
|
sys.debug(JSON.stringify(ex));
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function time_it(name, cont) {
|
||||||
|
if (!options.verbose)
|
||||||
|
return cont();
|
||||||
|
var t1 = new Date().getTime();
|
||||||
|
try { return cont(); }
|
||||||
|
finally { sys.debug("// " + name + ": " + ((new Date().getTime() - t1) / 1000).toFixed(3) + " sec."); }
|
||||||
|
};
|
||||||
75
node_modules/handlebars/node_modules/uglify-js/docstyle.css
generated
vendored
Normal file
75
node_modules/handlebars/node_modules/uglify-js/docstyle.css
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
html { font-family: "Lucida Grande","Trebuchet MS",sans-serif; font-size: 12pt; }
|
||||||
|
body { max-width: 60em; }
|
||||||
|
.title { text-align: center; }
|
||||||
|
.todo { color: red; }
|
||||||
|
.done { color: green; }
|
||||||
|
.tag { background-color:lightblue; font-weight:normal }
|
||||||
|
.target { }
|
||||||
|
.timestamp { color: grey }
|
||||||
|
.timestamp-kwd { color: CadetBlue }
|
||||||
|
p.verse { margin-left: 3% }
|
||||||
|
pre {
|
||||||
|
border: 1pt solid #AEBDCC;
|
||||||
|
background-color: #F3F5F7;
|
||||||
|
padding: 5pt;
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 90%;
|
||||||
|
overflow:auto;
|
||||||
|
}
|
||||||
|
pre.src {
|
||||||
|
background-color: #eee; color: #112; border: 1px solid #000;
|
||||||
|
}
|
||||||
|
table { border-collapse: collapse; }
|
||||||
|
td, th { vertical-align: top; }
|
||||||
|
dt { font-weight: bold; }
|
||||||
|
div.figure { padding: 0.5em; }
|
||||||
|
div.figure p { text-align: center; }
|
||||||
|
.linenr { font-size:smaller }
|
||||||
|
.code-highlighted {background-color:#ffff00;}
|
||||||
|
.org-info-js_info-navigation { border-style:none; }
|
||||||
|
#org-info-js_console-label { font-size:10px; font-weight:bold;
|
||||||
|
white-space:nowrap; }
|
||||||
|
.org-info-js_search-highlight {background-color:#ffff00; color:#000000;
|
||||||
|
font-weight:bold; }
|
||||||
|
|
||||||
|
sup {
|
||||||
|
vertical-align: baseline;
|
||||||
|
position: relative;
|
||||||
|
top: -0.5em;
|
||||||
|
font-size: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
|
sup a:link, sup a:visited {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #c00;
|
||||||
|
}
|
||||||
|
|
||||||
|
sup a:before { content: "["; color: #999; }
|
||||||
|
sup a:after { content: "]"; color: #999; }
|
||||||
|
|
||||||
|
h1.title { border-bottom: 4px solid #000; padding-bottom: 5px; margin-bottom: 2em; }
|
||||||
|
|
||||||
|
#postamble {
|
||||||
|
color: #777;
|
||||||
|
font-size: 90%;
|
||||||
|
padding-top: 1em; padding-bottom: 1em; border-top: 1px solid #999;
|
||||||
|
margin-top: 2em;
|
||||||
|
padding-left: 2em;
|
||||||
|
padding-right: 2em;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
#postamble p { margin: 0; }
|
||||||
|
|
||||||
|
#footnotes { border-top: 1px solid #000; }
|
||||||
|
|
||||||
|
h1 { font-size: 200% }
|
||||||
|
h2 { font-size: 175% }
|
||||||
|
h3 { font-size: 150% }
|
||||||
|
h4 { font-size: 125% }
|
||||||
|
|
||||||
|
h1, h2, h3, h4 { font-family: "Bookman",Georgia,"Times New Roman",serif; font-weight: normal; }
|
||||||
|
|
||||||
|
@media print {
|
||||||
|
html { font-size: 11pt; }
|
||||||
|
}
|
||||||
2599
node_modules/handlebars/node_modules/uglify-js/lib/consolidator.js
generated
vendored
Normal file
2599
node_modules/handlebars/node_modules/uglify-js/lib/consolidator.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
75
node_modules/handlebars/node_modules/uglify-js/lib/object-ast.js
generated
vendored
Normal file
75
node_modules/handlebars/node_modules/uglify-js/lib/object-ast.js
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
var jsp = require("./parse-js"),
|
||||||
|
pro = require("./process");
|
||||||
|
|
||||||
|
var BY_TYPE = {};
|
||||||
|
|
||||||
|
function HOP(obj, prop) {
|
||||||
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
||||||
|
};
|
||||||
|
|
||||||
|
function AST_Node(parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
AST_Node.prototype.init = function(){};
|
||||||
|
|
||||||
|
function DEFINE_NODE_CLASS(type, props, methods) {
|
||||||
|
var base = methods && methods.BASE || AST_Node;
|
||||||
|
if (!base) base = AST_Node;
|
||||||
|
function D(parent, data) {
|
||||||
|
base.apply(this, arguments);
|
||||||
|
if (props) props.forEach(function(name, i){
|
||||||
|
this["_" + name] = data[i];
|
||||||
|
});
|
||||||
|
this.init();
|
||||||
|
};
|
||||||
|
var P = D.prototype = new AST_Node;
|
||||||
|
P.node_type = function(){ return type };
|
||||||
|
if (props) props.forEach(function(name){
|
||||||
|
var propname = "_" + name;
|
||||||
|
P["set_" + name] = function(val) {
|
||||||
|
this[propname] = val;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
P["get_" + name] = function() {
|
||||||
|
return this[propname];
|
||||||
|
};
|
||||||
|
});
|
||||||
|
if (type != null) BY_TYPE[type] = D;
|
||||||
|
if (methods) for (var i in methods) if (HOP(methods, i)) {
|
||||||
|
P[i] = methods[i];
|
||||||
|
}
|
||||||
|
return D;
|
||||||
|
};
|
||||||
|
|
||||||
|
var AST_String_Node = DEFINE_NODE_CLASS("string", ["value"]);
|
||||||
|
var AST_Number_Node = DEFINE_NODE_CLASS("num", ["value"]);
|
||||||
|
var AST_Name_Node = DEFINE_NODE_CLASS("name", ["value"]);
|
||||||
|
|
||||||
|
var AST_Statlist_Node = DEFINE_NODE_CLASS(null, ["body"]);
|
||||||
|
var AST_Root_Node = DEFINE_NODE_CLASS("toplevel", null, { BASE: AST_Statlist_Node });
|
||||||
|
var AST_Block_Node = DEFINE_NODE_CLASS("block", null, { BASE: AST_Statlist_Node });
|
||||||
|
var AST_Splice_Node = DEFINE_NODE_CLASS("splice", null, { BASE: AST_Statlist_Node });
|
||||||
|
|
||||||
|
var AST_Var_Node = DEFINE_NODE_CLASS("var", ["definitions"]);
|
||||||
|
var AST_Const_Node = DEFINE_NODE_CLASS("const", ["definitions"]);
|
||||||
|
|
||||||
|
var AST_Try_Node = DEFINE_NODE_CLASS("try", ["body", "catch", "finally"]);
|
||||||
|
var AST_Throw_Node = DEFINE_NODE_CLASS("throw", ["exception"]);
|
||||||
|
|
||||||
|
var AST_New_Node = DEFINE_NODE_CLASS("new", ["constructor", "arguments"]);
|
||||||
|
|
||||||
|
var AST_Switch_Node = DEFINE_NODE_CLASS("switch", ["expression", "branches"]);
|
||||||
|
var AST_Switch_Branch_Node = DEFINE_NODE_CLASS(null, ["expression", "body"]);
|
||||||
|
|
||||||
|
var AST_Break_Node = DEFINE_NODE_CLASS("break", ["label"]);
|
||||||
|
var AST_Continue_Node = DEFINE_NODE_CLASS("continue", ["label"]);
|
||||||
|
var AST_Assign_Node = DEFINE_NODE_CLASS("assign", ["operator", "lvalue", "rvalue"]);
|
||||||
|
var AST_Dot_Node = DEFINE_NODE_CLASS("dot", ["expression", "name"]);
|
||||||
|
var AST_Call_Node = DEFINE_NODE_CLASS("call", ["function", "arguments"]);
|
||||||
|
|
||||||
|
var AST_Lambda_Node = DEFINE_NODE_CLASS(null, ["name", "arguments", "body"])
|
||||||
|
var AST_Function_Node = DEFINE_NODE_CLASS("function", null, AST_Lambda_Node);
|
||||||
|
var AST_Defun_Node = DEFINE_NODE_CLASS("defun", null, AST_Lambda_Node);
|
||||||
|
|
||||||
|
var AST_If_Node = DEFINE_NODE_CLASS("if", ["condition", "then", "else"]);
|
||||||
1346
node_modules/handlebars/node_modules/uglify-js/lib/parse-js.js
generated
vendored
Normal file
1346
node_modules/handlebars/node_modules/uglify-js/lib/parse-js.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2011
node_modules/handlebars/node_modules/uglify-js/lib/process.js
generated
vendored
Normal file
2011
node_modules/handlebars/node_modules/uglify-js/lib/process.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
73
node_modules/handlebars/node_modules/uglify-js/lib/squeeze-more.js
generated
vendored
Normal file
73
node_modules/handlebars/node_modules/uglify-js/lib/squeeze-more.js
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
var jsp = require("./parse-js"),
|
||||||
|
pro = require("./process"),
|
||||||
|
slice = jsp.slice,
|
||||||
|
member = jsp.member,
|
||||||
|
curry = jsp.curry,
|
||||||
|
MAP = pro.MAP,
|
||||||
|
PRECEDENCE = jsp.PRECEDENCE,
|
||||||
|
OPERATORS = jsp.OPERATORS;
|
||||||
|
|
||||||
|
function ast_squeeze_more(ast) {
|
||||||
|
var w = pro.ast_walker(), walk = w.walk, scope;
|
||||||
|
function with_scope(s, cont) {
|
||||||
|
var save = scope, ret;
|
||||||
|
scope = s;
|
||||||
|
ret = cont();
|
||||||
|
scope = save;
|
||||||
|
return ret;
|
||||||
|
};
|
||||||
|
function _lambda(name, args, body) {
|
||||||
|
return [ this[0], name, args, with_scope(body.scope, curry(MAP, body, walk)) ];
|
||||||
|
};
|
||||||
|
return w.with_walkers({
|
||||||
|
"toplevel": function(body) {
|
||||||
|
return [ this[0], with_scope(this.scope, curry(MAP, body, walk)) ];
|
||||||
|
},
|
||||||
|
"function": _lambda,
|
||||||
|
"defun": _lambda,
|
||||||
|
"new": function(ctor, args) {
|
||||||
|
if (ctor[0] == "name") {
|
||||||
|
if (ctor[1] == "Array" && !scope.has("Array")) {
|
||||||
|
if (args.length != 1) {
|
||||||
|
return [ "array", args ];
|
||||||
|
} else {
|
||||||
|
return walk([ "call", [ "name", "Array" ], args ]);
|
||||||
|
}
|
||||||
|
} else if (ctor[1] == "Object" && !scope.has("Object")) {
|
||||||
|
if (!args.length) {
|
||||||
|
return [ "object", [] ];
|
||||||
|
} else {
|
||||||
|
return walk([ "call", [ "name", "Object" ], args ]);
|
||||||
|
}
|
||||||
|
} else if ((ctor[1] == "RegExp" || ctor[1] == "Function" || ctor[1] == "Error") && !scope.has(ctor[1])) {
|
||||||
|
return walk([ "call", [ "name", ctor[1] ], args]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"call": function(expr, args) {
|
||||||
|
if (expr[0] == "dot" && expr[1][0] == "string" && args.length == 1
|
||||||
|
&& (args[0][1] > 0 && expr[2] == "substring" || expr[2] == "substr")) {
|
||||||
|
return [ "call", [ "dot", expr[1], "slice"], args];
|
||||||
|
}
|
||||||
|
if (expr[0] == "dot" && expr[2] == "toString" && args.length == 0) {
|
||||||
|
// foo.toString() ==> foo+""
|
||||||
|
return [ "binary", "+", expr[1], [ "string", "" ]];
|
||||||
|
}
|
||||||
|
if (expr[0] == "name") {
|
||||||
|
if (expr[1] == "Array" && args.length != 1 && !scope.has("Array")) {
|
||||||
|
return [ "array", args ];
|
||||||
|
}
|
||||||
|
if (expr[1] == "Object" && !args.length && !scope.has("Object")) {
|
||||||
|
return [ "object", [] ];
|
||||||
|
}
|
||||||
|
if (expr[1] == "String" && !scope.has("String")) {
|
||||||
|
return [ "binary", "+", args[0], [ "string", "" ]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, function() {
|
||||||
|
return walk(pro.ast_add_scope(ast));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.ast_squeeze_more = ast_squeeze_more;
|
||||||
24
node_modules/handlebars/node_modules/uglify-js/package.json
generated
vendored
Normal file
24
node_modules/handlebars/node_modules/uglify-js/package.json
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name" : "uglify-js",
|
||||||
|
|
||||||
|
"description" : "JavaScript parser and compressor/beautifier toolkit",
|
||||||
|
|
||||||
|
"author" : {
|
||||||
|
"name" : "Mihai Bazon",
|
||||||
|
"email" : "mihai.bazon@gmail.com",
|
||||||
|
"url" : "http://mihai.bazon.net/blog"
|
||||||
|
},
|
||||||
|
|
||||||
|
"version" : "1.2.6",
|
||||||
|
|
||||||
|
"main" : "./uglify-js.js",
|
||||||
|
|
||||||
|
"bin" : {
|
||||||
|
"uglifyjs" : "./bin/uglifyjs"
|
||||||
|
},
|
||||||
|
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git@github.com:mishoo/UglifyJS.git"
|
||||||
|
}
|
||||||
|
}
|
||||||
24
node_modules/handlebars/node_modules/uglify-js/package.json~
generated
vendored
Normal file
24
node_modules/handlebars/node_modules/uglify-js/package.json~
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name" : "uglify-js",
|
||||||
|
|
||||||
|
"description" : "JavaScript parser and compressor/beautifier toolkit",
|
||||||
|
|
||||||
|
"author" : {
|
||||||
|
"name" : "Mihai Bazon",
|
||||||
|
"email" : "mihai.bazon@gmail.com",
|
||||||
|
"url" : "http://mihai.bazon.net/blog"
|
||||||
|
},
|
||||||
|
|
||||||
|
"version" : "1.2.3",
|
||||||
|
|
||||||
|
"main" : "./uglify-js.js",
|
||||||
|
|
||||||
|
"bin" : {
|
||||||
|
"uglifyjs" : "./bin/uglifyjs"
|
||||||
|
},
|
||||||
|
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git@github.com:mishoo/UglifyJS.git"
|
||||||
|
}
|
||||||
|
}
|
||||||
28
node_modules/handlebars/node_modules/uglify-js/test/beautify.js
generated
vendored
Executable file
28
node_modules/handlebars/node_modules/uglify-js/test/beautify.js
generated
vendored
Executable file
@@ -0,0 +1,28 @@
|
|||||||
|
#! /usr/bin/env node
|
||||||
|
|
||||||
|
global.sys = require("sys");
|
||||||
|
var fs = require("fs");
|
||||||
|
|
||||||
|
var jsp = require("../lib/parse-js");
|
||||||
|
var pro = require("../lib/process");
|
||||||
|
|
||||||
|
var filename = process.argv[2];
|
||||||
|
fs.readFile(filename, "utf8", function(err, text){
|
||||||
|
try {
|
||||||
|
var ast = time_it("parse", function(){ return jsp.parse(text); });
|
||||||
|
ast = time_it("mangle", function(){ return pro.ast_mangle(ast); });
|
||||||
|
ast = time_it("squeeze", function(){ return pro.ast_squeeze(ast); });
|
||||||
|
var gen = time_it("generate", function(){ return pro.gen_code(ast, false); });
|
||||||
|
sys.puts(gen);
|
||||||
|
} catch(ex) {
|
||||||
|
sys.debug(ex.stack);
|
||||||
|
sys.debug(sys.inspect(ex));
|
||||||
|
sys.debug(JSON.stringify(ex));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function time_it(name, cont) {
|
||||||
|
var t1 = new Date().getTime();
|
||||||
|
try { return cont(); }
|
||||||
|
finally { sys.debug("// " + name + ": " + ((new Date().getTime() - t1) / 1000).toFixed(3) + " sec."); }
|
||||||
|
};
|
||||||
403
node_modules/handlebars/node_modules/uglify-js/test/testparser.js
generated
vendored
Executable file
403
node_modules/handlebars/node_modules/uglify-js/test/testparser.js
generated
vendored
Executable file
@@ -0,0 +1,403 @@
|
|||||||
|
#! /usr/bin/env node
|
||||||
|
|
||||||
|
var parseJS = require("../lib/parse-js");
|
||||||
|
var sys = require("sys");
|
||||||
|
|
||||||
|
// write debug in a very straightforward manner
|
||||||
|
var debug = function(){
|
||||||
|
sys.log(Array.prototype.slice.call(arguments).join(', '));
|
||||||
|
};
|
||||||
|
|
||||||
|
ParserTestSuite(function(i, input, desc){
|
||||||
|
try {
|
||||||
|
parseJS.parse(input);
|
||||||
|
debug("ok " + i + ": " + desc);
|
||||||
|
} catch(e){
|
||||||
|
debug("FAIL " + i + " " + desc + " (" + e + ")");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function ParserTestSuite(callback){
|
||||||
|
var inps = [
|
||||||
|
["var abc;", "Regular variable statement w/o assignment"],
|
||||||
|
["var abc = 5;", "Regular variable statement with assignment"],
|
||||||
|
["/* */;", "Multiline comment"],
|
||||||
|
['/** **/;', 'Double star multiline comment'],
|
||||||
|
["var f = function(){;};", "Function expression in var assignment"],
|
||||||
|
['hi; // moo\n;', 'single line comment'],
|
||||||
|
['var varwithfunction;', 'Dont match keywords as substrings'], // difference between `var withsomevar` and `"str"` (local search and lits)
|
||||||
|
['a + b;', 'addition'],
|
||||||
|
["'a';", 'single string literal'],
|
||||||
|
["'a\\n';", 'single string literal with escaped return'],
|
||||||
|
['"a";', 'double string literal'],
|
||||||
|
['"a\\n";', 'double string literal with escaped return'],
|
||||||
|
['"var";', 'string is a keyword'],
|
||||||
|
['"variable";', 'string starts with a keyword'],
|
||||||
|
['"somevariable";', 'string contains a keyword'],
|
||||||
|
['"somevar";', 'string ends with a keyword'],
|
||||||
|
['500;', 'int literal'],
|
||||||
|
['500.;', 'float literal w/o decimals'],
|
||||||
|
['500.432;', 'float literal with decimals'],
|
||||||
|
['.432432;', 'float literal w/o int'],
|
||||||
|
['(a,b,c);', 'parens and comma'],
|
||||||
|
['[1,2,abc];', 'array literal'],
|
||||||
|
['var o = {a:1};', 'object literal unquoted key'],
|
||||||
|
['var o = {"b":2};', 'object literal quoted key'], // opening curly may not be at the start of a statement...
|
||||||
|
['var o = {c:c};', 'object literal keyname is identifier'],
|
||||||
|
['var o = {a:1,"b":2,c:c};', 'object literal combinations'],
|
||||||
|
['var x;\nvar y;', 'two lines'],
|
||||||
|
['var x;\nfunction n(){; }', 'function def'],
|
||||||
|
['var x;\nfunction n(abc){; }', 'function def with arg'],
|
||||||
|
['var x;\nfunction n(abc, def){ ;}', 'function def with args'],
|
||||||
|
['function n(){ "hello"; }', 'function def with body'],
|
||||||
|
['/a/;', 'regex literal'],
|
||||||
|
['/a/b;', 'regex literal with flag'],
|
||||||
|
['/a/ / /b/;', 'regex div regex'],
|
||||||
|
['a/b/c;', 'triple division looks like regex'],
|
||||||
|
['+function(){/regex/;};', 'regex at start of function body'],
|
||||||
|
// http://code.google.com/p/es-lab/source/browse/trunk/tests/parser/parsertests.js?r=86
|
||||||
|
// http://code.google.com/p/es-lab/source/browse/trunk/tests/parser/parsertests.js?r=430
|
||||||
|
|
||||||
|
// first tests for the lexer, should also parse as program (when you append a semi)
|
||||||
|
|
||||||
|
// comments
|
||||||
|
['//foo!@#^&$1234\nbar;', 'single line comment'],
|
||||||
|
['/* abcd!@#@$* { } && null*/;', 'single line multi line comment'],
|
||||||
|
['/*foo\nbar*/;','multi line comment'],
|
||||||
|
['/*x*x*/;','multi line comment with *'],
|
||||||
|
['/**/;','empty comment'],
|
||||||
|
// identifiers
|
||||||
|
["x;",'1 identifier'],
|
||||||
|
["_x;",'2 identifier'],
|
||||||
|
["xyz;",'3 identifier'],
|
||||||
|
["$x;",'4 identifier'],
|
||||||
|
["x$;",'5 identifier'],
|
||||||
|
["_;",'6 identifier'],
|
||||||
|
["x5;",'7 identifier'],
|
||||||
|
["x_y;",'8 identifier'],
|
||||||
|
["x+5;",'9 identifier'],
|
||||||
|
["xyz123;",'10 identifier'],
|
||||||
|
["x1y1z1;",'11 identifier'],
|
||||||
|
["foo\\u00D8bar;",'12 identifier unicode escape'],
|
||||||
|
//["foo<6F>bar;",'13 identifier unicode embedded (might fail)'],
|
||||||
|
// numbers
|
||||||
|
["5;", '1 number'],
|
||||||
|
["5.5;", '2 number'],
|
||||||
|
["0;", '3 number'],
|
||||||
|
["0.0;", '4 number'],
|
||||||
|
["0.001;", '5 number'],
|
||||||
|
["1.e2;", '6 number'],
|
||||||
|
["1.e-2;", '7 number'],
|
||||||
|
["1.E2;", '8 number'],
|
||||||
|
["1.E-2;", '9 number'],
|
||||||
|
[".5;", '10 number'],
|
||||||
|
[".5e3;", '11 number'],
|
||||||
|
[".5e-3;", '12 number'],
|
||||||
|
["0.5e3;", '13 number'],
|
||||||
|
["55;", '14 number'],
|
||||||
|
["123;", '15 number'],
|
||||||
|
["55.55;", '16 number'],
|
||||||
|
["55.55e10;", '17 number'],
|
||||||
|
["123.456;", '18 number'],
|
||||||
|
["1+e;", '20 number'],
|
||||||
|
["0x01;", '22 number'],
|
||||||
|
["0XCAFE;", '23 number'],
|
||||||
|
["0x12345678;", '24 number'],
|
||||||
|
["0x1234ABCD;", '25 number'],
|
||||||
|
["0x0001;", '26 number'],
|
||||||
|
// strings
|
||||||
|
["\"foo\";", '1 string'],
|
||||||
|
["\'foo\';", '2 string'],
|
||||||
|
["\"x\";", '3 string'],
|
||||||
|
["\'\';", '4 string'],
|
||||||
|
["\"foo\\tbar\";", '5 string'],
|
||||||
|
["\"!@#$%^&*()_+{}[]\";", '6 string'],
|
||||||
|
["\"/*test*/\";", '7 string'],
|
||||||
|
["\"//test\";", '8 string'],
|
||||||
|
["\"\\\\\";", '9 string'],
|
||||||
|
["\"\\u0001\";", '10 string'],
|
||||||
|
["\"\\uFEFF\";", '11 string'],
|
||||||
|
["\"\\u10002\";", '12 string'],
|
||||||
|
["\"\\x55\";", '13 string'],
|
||||||
|
["\"\\x55a\";", '14 string'],
|
||||||
|
["\"a\\\\nb\";", '15 string'],
|
||||||
|
['";"', '16 string: semi in a string'],
|
||||||
|
['"a\\\nb";', '17 string: line terminator escape'],
|
||||||
|
// literals
|
||||||
|
["null;", "null"],
|
||||||
|
["true;", "true"],
|
||||||
|
["false;", "false"],
|
||||||
|
// regex
|
||||||
|
["/a/;", "1 regex"],
|
||||||
|
["/abc/;", "2 regex"],
|
||||||
|
["/abc[a-z]*def/g;", "3 regex"],
|
||||||
|
["/\\b/;", "4 regex"],
|
||||||
|
["/[a-zA-Z]/;", "5 regex"],
|
||||||
|
|
||||||
|
// program tests (for as far as they havent been covered above)
|
||||||
|
|
||||||
|
// regexp
|
||||||
|
["/foo(.*)/g;", "another regexp"],
|
||||||
|
// arrays
|
||||||
|
["[];", "1 array"],
|
||||||
|
["[ ];", "2 array"],
|
||||||
|
["[1];", "3 array"],
|
||||||
|
["[1,2];", "4 array"],
|
||||||
|
["[1,2,,];", "5 array"],
|
||||||
|
["[1,2,3];", "6 array"],
|
||||||
|
["[1,2,3,,,];", "7 array"],
|
||||||
|
// objects
|
||||||
|
["{};", "1 object"],
|
||||||
|
["({x:5});", "2 object"],
|
||||||
|
["({x:5,y:6});", "3 object"],
|
||||||
|
["({x:5,});", "4 object"],
|
||||||
|
["({if:5});", "5 object"],
|
||||||
|
["({ get x() {42;} });", "6 object"],
|
||||||
|
["({ set y(a) {1;} });", "7 object"],
|
||||||
|
// member expression
|
||||||
|
["o.m;", "1 member expression"],
|
||||||
|
["o['m'];", "2 member expression"],
|
||||||
|
["o['n']['m'];", "3 member expression"],
|
||||||
|
["o.n.m;", "4 member expression"],
|
||||||
|
["o.if;", "5 member expression"],
|
||||||
|
// call and invoke expressions
|
||||||
|
["f();", "1 call/invoke expression"],
|
||||||
|
["f(x);", "2 call/invoke expression"],
|
||||||
|
["f(x,y);", "3 call/invoke expression"],
|
||||||
|
["o.m();", "4 call/invoke expression"],
|
||||||
|
["o['m'];", "5 call/invoke expression"],
|
||||||
|
["o.m(x);", "6 call/invoke expression"],
|
||||||
|
["o['m'](x);", "7 call/invoke expression"],
|
||||||
|
["o.m(x,y);", "8 call/invoke expression"],
|
||||||
|
["o['m'](x,y);", "9 call/invoke expression"],
|
||||||
|
["f(x)(y);", "10 call/invoke expression"],
|
||||||
|
["f().x;", "11 call/invoke expression"],
|
||||||
|
|
||||||
|
// eval
|
||||||
|
["eval('x');", "1 eval"],
|
||||||
|
["(eval)('x');", "2 eval"],
|
||||||
|
["(1,eval)('x');", "3 eval"],
|
||||||
|
["eval(x,y);", "4 eval"],
|
||||||
|
// new expression
|
||||||
|
["new f();", "1 new expression"],
|
||||||
|
["new o;", "2 new expression"],
|
||||||
|
["new o.m;", "3 new expression"],
|
||||||
|
["new o.m(x);", "4 new expression"],
|
||||||
|
["new o.m(x,y);", "5 new expression"],
|
||||||
|
// prefix/postfix
|
||||||
|
["++x;", "1 pre/postfix"],
|
||||||
|
["x++;", "2 pre/postfix"],
|
||||||
|
["--x;", "3 pre/postfix"],
|
||||||
|
["x--;", "4 pre/postfix"],
|
||||||
|
["x ++;", "5 pre/postfix"],
|
||||||
|
["x /* comment */ ++;", "6 pre/postfix"],
|
||||||
|
["++ /* comment */ x;", "7 pre/postfix"],
|
||||||
|
// unary operators
|
||||||
|
["delete x;", "1 unary operator"],
|
||||||
|
["void x;", "2 unary operator"],
|
||||||
|
["+ x;", "3 unary operator"],
|
||||||
|
["-x;", "4 unary operator"],
|
||||||
|
["~x;", "5 unary operator"],
|
||||||
|
["!x;", "6 unary operator"],
|
||||||
|
// meh
|
||||||
|
["new Date++;", "new date ++"],
|
||||||
|
["+x++;", " + x ++"],
|
||||||
|
// expression expressions
|
||||||
|
["1 * 2;", "1 expression expressions"],
|
||||||
|
["1 / 2;", "2 expression expressions"],
|
||||||
|
["1 % 2;", "3 expression expressions"],
|
||||||
|
["1 + 2;", "4 expression expressions"],
|
||||||
|
["1 - 2;", "5 expression expressions"],
|
||||||
|
["1 << 2;", "6 expression expressions"],
|
||||||
|
["1 >>> 2;", "7 expression expressions"],
|
||||||
|
["1 >> 2;", "8 expression expressions"],
|
||||||
|
["1 * 2 + 3;", "9 expression expressions"],
|
||||||
|
["(1+2)*3;", "10 expression expressions"],
|
||||||
|
["1*(2+3);", "11 expression expressions"],
|
||||||
|
["x<y;", "12 expression expressions"],
|
||||||
|
["x>y;", "13 expression expressions"],
|
||||||
|
["x<=y;", "14 expression expressions"],
|
||||||
|
["x>=y;", "15 expression expressions"],
|
||||||
|
["x instanceof y;", "16 expression expressions"],
|
||||||
|
["x in y;", "17 expression expressions"],
|
||||||
|
["x&y;", "18 expression expressions"],
|
||||||
|
["x^y;", "19 expression expressions"],
|
||||||
|
["x|y;", "20 expression expressions"],
|
||||||
|
["x+y<z;", "21 expression expressions"],
|
||||||
|
["x<y+z;", "22 expression expressions"],
|
||||||
|
["x+y+z;", "23 expression expressions"],
|
||||||
|
["x+y<z;", "24 expression expressions"],
|
||||||
|
["x<y+z;", "25 expression expressions"],
|
||||||
|
["x&y|z;", "26 expression expressions"],
|
||||||
|
["x&&y;", "27 expression expressions"],
|
||||||
|
["x||y;", "28 expression expressions"],
|
||||||
|
["x&&y||z;", "29 expression expressions"],
|
||||||
|
["x||y&&z;", "30 expression expressions"],
|
||||||
|
["x<y?z:w;", "31 expression expressions"],
|
||||||
|
// assignment
|
||||||
|
["x >>>= y;", "1 assignment"],
|
||||||
|
["x <<= y;", "2 assignment"],
|
||||||
|
["x = y;", "3 assignment"],
|
||||||
|
["x += y;", "4 assignment"],
|
||||||
|
["x /= y;", "5 assignment"],
|
||||||
|
// comma
|
||||||
|
["x, y;", "comma"],
|
||||||
|
// block
|
||||||
|
["{};", "1 block"],
|
||||||
|
["{x;};", "2 block"],
|
||||||
|
["{x;y;};", "3 block"],
|
||||||
|
// vars
|
||||||
|
["var x;", "1 var"],
|
||||||
|
["var x,y;", "2 var"],
|
||||||
|
["var x=1,y=2;", "3 var"],
|
||||||
|
["var x,y=2;", "4 var"],
|
||||||
|
// empty
|
||||||
|
[";", "1 empty"],
|
||||||
|
["\n;", "2 empty"],
|
||||||
|
// expression statement
|
||||||
|
["x;", "1 expression statement"],
|
||||||
|
["5;", "2 expression statement"],
|
||||||
|
["1+2;", "3 expression statement"],
|
||||||
|
// if
|
||||||
|
["if (c) x; else y;", "1 if statement"],
|
||||||
|
["if (c) x;", "2 if statement"],
|
||||||
|
["if (c) {} else {};", "3 if statement"],
|
||||||
|
["if (c1) if (c2) s1; else s2;", "4 if statement"],
|
||||||
|
// while
|
||||||
|
["do s; while (e);", "1 while statement"],
|
||||||
|
["do { s; } while (e);", "2 while statement"],
|
||||||
|
["while (e) s;", "3 while statement"],
|
||||||
|
["while (e) { s; };", "4 while statement"],
|
||||||
|
// for
|
||||||
|
["for (;;) ;", "1 for statement"],
|
||||||
|
["for (;c;x++) x;", "2 for statement"],
|
||||||
|
["for (i;i<len;++i){};", "3 for statement"],
|
||||||
|
["for (var i=0;i<len;++i) {};", "4 for statement"],
|
||||||
|
["for (var i=0,j=0;;){};", "5 for statement"],
|
||||||
|
//["for (x in b; c; u) {};", "6 for statement"],
|
||||||
|
["for ((x in b); c; u) {};", "7 for statement"],
|
||||||
|
["for (x in a);", "8 for statement"],
|
||||||
|
["for (var x in a){};", "9 for statement"],
|
||||||
|
["for (var x=5 in a) {};", "10 for statement"],
|
||||||
|
["for (var x = a in b in c) {};", "11 for statement"],
|
||||||
|
["for (var x=function(){a+b;}; a<b; ++i) some;", "11 for statement, testing for parsingForHeader reset with the function"],
|
||||||
|
["for (var x=function(){for (x=0; x<15; ++x) alert(foo); }; a<b; ++i) some;", "11 for statement, testing for parsingForHeader reset with the function"],
|
||||||
|
// flow statements
|
||||||
|
["while(1){ continue; }", "1 flow statement"],
|
||||||
|
["label: while(1){ continue label; }", "2 flow statement"],
|
||||||
|
["while(1){ break; }", "3 flow statement"],
|
||||||
|
["somewhere: while(1){ break somewhere; }", "4 flow statement"],
|
||||||
|
["while(1){ continue /* comment */ ; }", "5 flow statement"],
|
||||||
|
["while(1){ continue \n; }", "6 flow statement"],
|
||||||
|
["(function(){ return; })()", "7 flow statement"],
|
||||||
|
["(function(){ return 0; })()", "8 flow statement"],
|
||||||
|
["(function(){ return 0 + \n 1; })()", "9 flow statement"],
|
||||||
|
// with
|
||||||
|
["with (e) s;", "with statement"],
|
||||||
|
// switch
|
||||||
|
["switch (e) { case x: s; };", "1 switch statement"],
|
||||||
|
["switch (e) { case x: s1;s2; default: s3; case y: s4; };", "2 switch statement"],
|
||||||
|
["switch (e) { default: s1; case x: s2; case y: s3; };", "3 switch statement"],
|
||||||
|
["switch (e) { default: s; };", "4 switch statement"],
|
||||||
|
["switch (e) { case x: s1; case y: s2; };", "5 switch statement"],
|
||||||
|
// labels
|
||||||
|
["foo : x;", " flow statement"],
|
||||||
|
// throw
|
||||||
|
["throw x;", "1 throw statement"],
|
||||||
|
["throw x\n;", "2 throw statement"],
|
||||||
|
// try catch finally
|
||||||
|
["try { s1; } catch (e) { s2; };", "1 trycatchfinally statement"],
|
||||||
|
["try { s1; } finally { s2; };", "2 trycatchfinally statement"],
|
||||||
|
["try { s1; } catch (e) { s2; } finally { s3; };", "3 trycatchfinally statement"],
|
||||||
|
// debugger
|
||||||
|
["debugger;", "debuger statement"],
|
||||||
|
// function decl
|
||||||
|
["function f(x) { e; return x; };", "1 function declaration"],
|
||||||
|
["function f() { x; y; };", "2 function declaration"],
|
||||||
|
["function f(x,y) { var z; return x; };", "3 function declaration"],
|
||||||
|
// function exp
|
||||||
|
["(function f(x) { return x; });", "1 function expression"],
|
||||||
|
["(function empty() {;});", "2 function expression"],
|
||||||
|
["(function empty() {;});", "3 function expression"],
|
||||||
|
["(function (x) {; });", "4 function expression"],
|
||||||
|
// program
|
||||||
|
["var x; function f(){;}; null;", "1 program"],
|
||||||
|
[";;", "2 program"],
|
||||||
|
["{ x; y; z; }", "3 program"],
|
||||||
|
["function f(){ function g(){;}};", "4 program"],
|
||||||
|
["x;\n/*foo*/\n ;", "5 program"],
|
||||||
|
|
||||||
|
// asi
|
||||||
|
["foo: while(1){ continue \n foo; }", "1 asi"],
|
||||||
|
["foo: while(1){ break \n foo; }", "2 asi"],
|
||||||
|
["(function(){ return\nfoo; })()", "3 asi"],
|
||||||
|
["var x; { 1 \n 2 } 3", "4 asi"],
|
||||||
|
["ab /* hi */\ncd", "5 asi"],
|
||||||
|
["ab/*\n*/cd", "6 asi (multi line multilinecomment counts as eol)"],
|
||||||
|
["foo: while(1){ continue /* wtf \n busta */ foo; }", "7 asi illegal with multi line comment"],
|
||||||
|
["function f() { s }", "8 asi"],
|
||||||
|
["function f() { return }", "9 asi"],
|
||||||
|
|
||||||
|
// use strict
|
||||||
|
// XXX: some of these should actually fail?
|
||||||
|
// no support for "use strict" yet...
|
||||||
|
['"use strict"; \'bla\'\n; foo;', "1 directive"],
|
||||||
|
['(function() { "use strict"; \'bla\';\n foo; });', "2 directive"],
|
||||||
|
['"use\\n strict";', "3 directive"],
|
||||||
|
['foo; "use strict";', "4 directive"],
|
||||||
|
|
||||||
|
// tests from http://es5conform.codeplex.com/
|
||||||
|
|
||||||
|
['"use strict"; var o = { eval: 42};', "8.7.2-3-1-s: the use of eval as property name is allowed"],
|
||||||
|
['({foo:0,foo:1});', 'Duplicate property name allowed in not strict mode'],
|
||||||
|
['function foo(a,a){}', 'Duplicate parameter name allowed in not strict mode'],
|
||||||
|
['(function foo(eval){})', 'Eval allowed as parameter name in non strict mode'],
|
||||||
|
['(function foo(arguments){})', 'Arguments allowed as parameter name in non strict mode'],
|
||||||
|
|
||||||
|
// empty programs
|
||||||
|
|
||||||
|
['', '1 Empty program'],
|
||||||
|
['// test', '2 Empty program'],
|
||||||
|
['//test\n', '3 Empty program'],
|
||||||
|
['\n// test', '4 Empty program'],
|
||||||
|
['\n// test\n', '5 Empty program'],
|
||||||
|
['/* */', '6 Empty program'],
|
||||||
|
['/*\ns,fd\n*/', '7 Empty program'],
|
||||||
|
['/*\ns,fd\n*/\n', '8 Empty program'],
|
||||||
|
[' ', '9 Empty program'],
|
||||||
|
[' /*\nsmeh*/ \n ', '10 Empty program'],
|
||||||
|
|
||||||
|
// trailing whitespace
|
||||||
|
|
||||||
|
['a ', '1 Trailing whitespace'],
|
||||||
|
['a /* something */', '2 Trailing whitespace'],
|
||||||
|
['a\n // hah', '3 Trailing whitespace'],
|
||||||
|
['/abc/de//f', '4 Trailing whitespace'],
|
||||||
|
['/abc/de/*f*/\n ', '5 Trailing whitespace'],
|
||||||
|
|
||||||
|
// things the parser tripped over at one point or the other (prevents regression bugs)
|
||||||
|
['for (x;function(){ a\nb };z) x;', 'for header with function body forcing ASI'],
|
||||||
|
['c=function(){return;return};', 'resetting noAsi after literal'],
|
||||||
|
['d\nd()', 'asi exception causing token overflow'],
|
||||||
|
['for(;;){x=function(){}}', 'function expression in a for header'],
|
||||||
|
['for(var k;;){}', 'parser failing due to ASI accepting the incorrect "for" rule'],
|
||||||
|
['({get foo(){ }})', 'getter with empty function body'],
|
||||||
|
['\nreturnr', 'eol causes return statement to ignore local search requirement'],
|
||||||
|
[' / /', '1 whitespace before regex causes regex to fail?'],
|
||||||
|
['/ // / /', '2 whitespace before regex causes regex to fail?'],
|
||||||
|
['/ / / / /', '3 whitespace before regex causes regex to fail?'],
|
||||||
|
|
||||||
|
['\n\t// Used for trimming whitespace\n\ttrimLeft = /^\\s+/;\n\ttrimRight = /\\s+$/;\t\n','turned out this didnt crash (the test below did), but whatever.'],
|
||||||
|
['/[\\/]/;', 'escaped forward slash inside class group (would choke on fwd slash)'],
|
||||||
|
['/[/]/;', 'also broke but is valid in es5 (not es3)'],
|
||||||
|
['({get:5});','get property name thats not a getter'],
|
||||||
|
['({set:5});','set property name thats not a setter'],
|
||||||
|
['l !== "px" && (d.style(h, c, (k || 1) + l), j = (k || 1) / f.cur() * j, d.style(h, c, j + l)), i[1] && (k = (i[1] === "-=" ? -1 : 1) * k + j), f.custom(j, k, l)', 'this choked regex/div at some point'],
|
||||||
|
['(/\'/g, \'\\\\\\\'\') + "\'";', 'the sequence of escaped characters confused the tokenizer'],
|
||||||
|
['if (true) /=a/.test("a");', 'regexp starting with "=" in not obvious context (not implied by preceding token)']
|
||||||
|
];
|
||||||
|
|
||||||
|
for (var i=0; i<inps.length; ++i) {
|
||||||
|
callback(i, inps[i][0], inps[i][1]);
|
||||||
|
};
|
||||||
|
};
|
||||||
1
node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/array1.js
generated
vendored
Normal file
1
node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/array1.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
[],Array(1),[1,2,3]
|
||||||
1
node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/array2.js
generated
vendored
Normal file
1
node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/array2.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
(function(){var a=function(){};return new a(1,2,3,4)})()
|
||||||
1
node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/array3.js
generated
vendored
Normal file
1
node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/array3.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
(function(){function a(){}return new a(1,2,3,4)})()
|
||||||
1
node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/array4.js
generated
vendored
Normal file
1
node_modules/handlebars/node_modules/uglify-js/test/unit/compress/expected/array4.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
(function(){function a(){}(function(){return new a(1,2,3)})()})()
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user