angular-ui-router-tabs
Version:
Idiot-proof tab panes with route support using Angular.js + Bootstrap 3 + UI Router.
1,341 lines (1,230 loc) • 210 kB
JavaScript
/*
* JSHint, by JSHint Community.
*
* Licensed under the same slightly modified MIT license that JSLint is.
* It stops evil-doers everywhere.
*
* JSHint is a derivative work of JSLint:
*
* Copyright (c) 2002 Douglas Crockford (www.JSLint.com)
*
* 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 shall be used for Good, not Evil.
*
* 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.
*
* JSHint was forked from 2010-12-16 edition of JSLint.
*
*/
/*
JSHINT is a global function. It takes two parameters.
var myResult = JSHINT(source, option);
The first parameter is either a string or an array of strings. If it is a
string, it will be split on '\n' or '\r'. If it is an array of strings, it
is assumed that each string represents one line. The source can be a
JavaScript text, or HTML text, or a JSON text, or a CSS text.
The second parameter is an optional object of options which control the
operation of JSHINT. Most of the options are booleans: They are all
optional and have a default value of false. One of the options, predef,
can be an array of names, which will be used to declare global variables,
or an object whose keys are used as global names, with a boolean value
that determines if they are assignable.
If it checks out, JSHINT returns true. Otherwise, it returns false.
If false, you can inspect JSHINT.errors to find out the problems.
JSHINT.errors is an array of objects containing these members:
{
line : The line (relative to 0) at which the lint was found
character : The character (relative to 0) at which the lint was found
reason : The problem
evidence : The text line in which the problem occurred
raw : The raw message before the details were inserted
a : The first detail
b : The second detail
c : The third detail
d : The fourth detail
}
If a fatal error was found, a null will be the last element of the
JSHINT.errors array.
You can request a Function Report, which shows all of the functions
and the parameters and vars that they use. This can be used to find
implied global variables and other problems. The report is in HTML and
can be inserted in an HTML <body>.
var myReport = JSHINT.report(limited);
If limited is true, then the report will be limited to only errors.
You can request a data structure which contains JSHint's results.
var myData = JSHINT.data();
It returns a structure with this form:
{
errors: [
{
line: NUMBER,
character: NUMBER,
reason: STRING,
evidence: STRING
}
],
functions: [
name: STRING,
line: NUMBER,
last: NUMBER,
param: [
STRING
],
closure: [
STRING
],
var: [
STRING
],
exception: [
STRING
],
outer: [
STRING
],
unused: [
STRING
],
global: [
STRING
],
label: [
STRING
]
],
globals: [
STRING
],
member: {
STRING: NUMBER
},
unuseds: [
{
name: STRING,
line: NUMBER
}
],
implieds: [
{
name: STRING,
line: NUMBER
}
],
urls: [
STRING
],
json: BOOLEAN
}
Empty arrays will not be included.
*/
/*jshint
evil: true, nomen: false, onevar: false, regexp: false, strict: true, boss: true
*/
/*members "\b", "\t", "\n", "\f", "\r", "!=", "!==", "\"", "%",
"(begin)", "(breakage)", "(context)", "(error)", "(global)",
"(identifier)", "(last)", "(line)", "(loopage)", "(name)", "(onevar)",
"(params)", "(scope)", "(statement)", "(verb)", "*", "+", "++", "-",
"--", "\/", "<", "<=", "==", "===", ">", ">=", $, ADSAFE, __filename, __dirname,
ActiveXObject, Array, Boolean, Buffer, COM, CScript, Canvas, CustomAnimation,
Date, Debug, E, Enumerator, Error, EvalError, FadeAnimation, Flash,
FormField, Frame, Function, HotKey, Image, JSON, LN10, LN2, LOG10E,
LOG2E, MAX_VALUE, MIN_VALUE, Math, MenuItem, MoveAnimation,
NEGATIVE_INFINITY, Number, Object, Option, PI, POSITIVE_INFINITY, Point,
RangeError, Rectangle, ReferenceError, RegExp, ResizeAnimation,
RotateAnimation, SQRT1_2, SQRT2, ScrollBar, String, Style, SyntaxError,
System, Text, TextArea, Timer, TypeError, URIError, URL, VBArray,
WScript, Web, Window, XMLDOM, XMLHttpRequest, "\\", a, abbr, acronym,
activeborder, activecaption, addEventListener, address, adsafe, alert,
aliceblue, all, animator, antiquewhite, appleScript, applet, apply,
approved, appworkspace, applicationCache, aqua, aquamarine, area, arguments,
arity, article, asi, aside, audio, autocomplete, azure, b, background,
"background-attachment", "background-color", "background-image",
"background-position", "background-repeat", base, bdo, beep, beige, big,
bisque, bitwise, black, blanchedalmond, block, blockquote, blue,
blueviolet, blur, body, border, "border-bottom", "border-bottom-color",
"border-bottom-style", "border-bottom-width", "border-collapse",
"border-color", "border-left", "border-left-color", "border-left-style",
"border-left-width", "border-right", "border-right-color",
"border-right-style", "border-right-width", "border-spacing",
"border-style", "border-top", "border-top-color", "border-top-style",
"border-top-width", "border-width", bottom, boss, br, braille, brown, browser,
burlywood, button, buttonface, buttonhighlight, buttonshadow,
buttontext, bytesToUIString, c, cadetblue, call, callee, caller, canvas,
cap, caption, "caption-side", captiontext, cases, center, charAt,
charCodeAt, character, chartreuse, chocolate, chooseColor, chooseFile,
chooseFolder, cite, clear, clearInterval, clearTimeout, clip, close,
closeWidget, closed, closure, cm, code, col, colgroup, color, command,
comment, condition, confirm, console, constructor, content,
convertPathToHFS, convertPathToPlatform, coral, cornflowerblue,
cornsilk, couch, "counter-increment", "counter-reset", create, crimson,
css, curly, cursor, cyan, d, darkblue, darkcyan, darkgoldenrod, darkgray,
darkgreen, darkkhaki, darkmagenta, darkolivegreen, darkorange, darkorchid,
darkred, darksalmon, darkseagreen, darkslateblue, darkslategray, darkturquoise,
darkviolet, data, datalist, dd, debug, decodeURI, decodeURIComponent,
deeppink, deepskyblue, defaultStatus, defineClass, del, deserialize,
details, devel, dfn, dialog, dimgray, dir, direction, display, div, dl,
document, dodgerblue, dt, edition, else, em, embed, embossed, emit, empty,
"empty-cells", encodeURI, encodeURIComponent, entityify, eqeqeq, errors,
es5, escape, eval, event, evidence, evil, ex, exception, exec, exps, exports,
fieldset, figure, filesystem, FileReader, firebrick, first, float, floor,
floralwhite, focus, focusWidget, font, "font-family", "font-size",
"font-size-adjust", "font-stretch", "font-style", "font-variant",
"font-weight", footer, forestgreen, forin, form, fragment, frame,
frames, frameset, from, fromCharCode, fuchsia, fud, funct, function,
functions, g, gainsboro, gc, getComputedStyle, getRow, ghostwhite, GLOBAL, global,
globals, gold, goldenrod, gray, graytext, green, greenyellow, h1, h2,
h3, h4, h5, h6, handheld, hasOwnProperty, head, header, height, help,
hgroup, highlight, highlighttext, history, honeydew, hotpink, hr,
"hta:application", html, i, iTunes, id, identifier, iframe, img, immed,
implieds, in, inactiveborder, inactivecaption, inactivecaptiontext,
include, indent, indexOf, indianred, indigo, infobackground, infotext,
init, input, ins, isAlpha, isApplicationRunning, isArray, isDigit,
isFinite, isNaN, ivory, join, jshint, JSHINT, json, jquery, jQuery, kbd,
keygen, keys, khaki, konfabulatorVersion, label, labelled, lang, last,
lavender, lavenderblush, lawngreen, laxbreak, lbp, led, left, legend,
lemonchiffon, length, "letter-spacing", li, lib, lightblue, lightcoral,
lightcyan, lightgoldenrodyellow, lightgreen, lightpink, lightsalmon,
lightseagreen, lightskyblue, lightslategray, lightsteelblue,
lightyellow, lime, limegreen, line, "line-height", linen, link,
"list-style", "list-style-image", "list-style-position",
"list-style-type", load, loadClass, localStorage, location, log, loopfunc, m, magenta,
map, margin, "margin-bottom", "margin-left", "margin-right", "margin-top",
mark, "marker-offset", maroon, match, "max-height", "max-width", maxerr,
maxlen, md5, mediumaquamarine, mediumblue, mediumorchid, mediumpurple,
mediumseagreen, mediumslateblue, mediumspringgreen, mediumturquoise,
mediumvioletred, member, menu, menutext, message, meta, meter,
midnightblue, "min-height", "min-width", mintcream, mistyrose, mm,
moccasin, module, moveBy, moveTo, name, nav, navajowhite, navigator, navy, new,
newcap, noarg, node, noempty, noframes, nomen, nonew, noscript, nud, object, ol,
oldlace, olive, olivedrab, on, onbeforeunload, onblur, onerror, onevar,
onfocus, onload, onresize, onunload, opacity, open, openDatabase, openURL, opener,
opera, optgroup, option, orange, orangered, orchid, outer, outline, "outline-color",
"outline-style", "outline-width", output, overflow, "overflow-x",
"overflow-y", p, padding, "padding-bottom", "padding-left",
"padding-right", "padding-top", "page-break-after", "page-break-before",
palegoldenrod, palegreen, paleturquoise, palevioletred, papayawhip,
param, parent, parseFloat, parseInt, passfail, pc, peachpuff, peru,
pink, play, plum, plusplus, pop, popupMenu, position, powderblue, pre,
predef, preferenceGroups, preferences, print, process, progress, projection,
prompt, prototype, pt, purple, push, px, q, quit, quotes, random, range,
raw, reach, readFile, readUrl, reason, red, regexp, reloadWidget,
removeEventListener, replace, report, require, reserved, resizeBy, resizeTo,
resolvePath, resumeUpdates, respond, rhino, right, rosybrown, royalblue,
rp, rt, ruby, runCommand, runCommandInBg, saddlebrown, safe, salmon, samp,
sandybrown, saveAs, savePreferences, screen, script, scroll, scrollBy,
scrollTo, scrollbar, seagreen, seal, search, seashell, section, send, select,
serialize, setInterval, setTimeout, shift, showWidgetPreferences,
sienna, silver, skyblue, slateblue, slategray, sleep, slice, small,
snow, sort, source, span, spawn, speak, speech, split, springgreen, src,
stack, status, start, steelblue, strict, strong, style, styleproperty, sub,
substr, sum, sup, supplant, suppressUpdates, sync, system, table,
"table-layout", tan, tbody, td, teal, tellWidget, test, "text-align",
"text-decoration", "text-indent", "text-shadow", "text-transform",
textarea, tfoot, th, thead, thistle, threeddarkshadow, threedface,
threedhighlight, threedlightshadow, threedshadow, time, title,
toLowerCase, toString, toUpperCase, toint32, token, tomato, top, tr, tt,
tty, turquoise, tv, type, u, ul, undef, unescape, "unicode-bidi",
unused, unwatch, updateNow, urls, value, valueOf, var, version,
"vertical-align", video, violet, visibility, watch, WebSocket, wheat, white,
"white-space", whitesmoke, widget, width, window, windowframe, windows,
windowtext, Worker, "word-spacing", "word-wrap", yahooCheckLogin,
yahooLogin, yahooLogout, yellow, yellowgreen, "z-index"
*/
/*global exports: false */
// We build the application inside a function so that we produce only a single
// global variable. That function will be invoked immediately, and its return
// value is the JSHINT function itself.
var JSHINT = (function () {
"use strict";
var adsafe_id, // The widget's ADsafe id.
adsafe_may, // The widget may load approved scripts.
adsafe_went, // ADSAFE.go has been called.
anonname, // The guessed name for anonymous functions.
approved, // ADsafe approved urls.
// These are operators that should not be used with the ! operator.
bang = {
'<' : true,
'<=' : true,
'==' : true,
'===': true,
'!==': true,
'!=' : true,
'>' : true,
'>=' : true,
'+' : true,
'-' : true,
'*' : true,
'/' : true,
'%' : true
},
// These are property names that should not be permitted in the safe subset.
banned = { // the member names that ADsafe prohibits.
'arguments' : true,
callee : true,
caller : true,
constructor : true,
'eval' : true,
prototype : true,
stack : true,
unwatch : true,
valueOf : true,
watch : true
},
// These are the JSHint boolean options.
boolOptions = {
adsafe : true, // if ADsafe should be enforced
asi : true, // if automatic semicolon insertion should be tolerated
bitwise : true, // if bitwise operators should not be allowed
boss : true, // if advanced usage of assignments and == should be allowed
browser : true, // if the standard browser globals should be predefined
cap : true, // if upper case HTML should be allowed
couch : true, // if CouchDB globals should be predefined
css : true, // if CSS workarounds should be tolerated
curly : true, // if curly braces around blocks should be required (even in if/for/while)
debug : true, // if debugger statements should be allowed
devel : true, // if logging should be allowed (console, alert, etc.)
eqeqeq : true, // if === should be required
es5 : true, // if ES5 syntax should be allowed
evil : true, // if eval should be allowed
forin : true, // if for in statements must filter
fragment : true, // if HTML fragments should be allowed
immed : true, // if immediate invocations must be wrapped in parens
jquery : true, // if jQuery globals should be predefined
laxbreak : true, // if line breaks should not be checked
loopfunc : true, // if functions should be allowed to be defined within loops
newcap : true, // if constructor names must be capitalized
noarg : true, // if arguments.caller and arguments.callee should be disallowed
node : true, // if the Node.js environment globals should be predefined
noempty : true, // if empty blocks should be disallowed
nonew : true, // if using `new` for side-effects should be disallowed
nomen : true, // if names should be checked
on : true, // if HTML event handlers should be allowed
onevar : true, // if only one var statement per function should be allowed
passfail : true, // if the scan should stop on first error
plusplus : true, // if increment/decrement should not be allowed
regexp : true, // if the . should not be allowed in regexp literals
rhino : true, // if the Rhino environment globals should be predefined
undef : true, // if variables should be declared before used
safe : true, // if use of some browser features should be restricted
windows : true, // if MS Windows-specigic globals should be predefined
strict : true, // require the "use strict"; pragma
sub : true, // if all forms of subscript notation are tolerated
white : true, // if strict whitespace rules apply
widget : true // if the Yahoo Widgets globals should be predefined
},
// browser contains a set of global names which are commonly provided by a
// web browser environment.
browser = {
addEventListener: false,
applicationCache: false,
blur : false,
clearInterval : false,
clearTimeout : false,
close : false,
closed : false,
defaultStatus : false,
document : false,
event : false,
FileReader : false,
focus : false,
frames : false,
getComputedStyle: false,
history : false,
Image : false,
length : false,
localStorage : false,
location : false,
moveBy : false,
moveTo : false,
name : false,
navigator : false,
onbeforeunload : true,
onblur : true,
onerror : true,
onfocus : true,
onload : true,
onresize : true,
onunload : true,
open : false,
openDatabase : false,
opener : false,
Option : false,
parent : false,
print : false,
removeEventListener: false,
resizeBy : false,
resizeTo : false,
screen : false,
scroll : false,
scrollBy : false,
scrollTo : false,
setInterval : false,
setTimeout : false,
status : false,
top : false,
WebSocket : false,
window : false,
Worker : false,
XMLHttpRequest : false
},
couch = {
"require" : false,
respond : false,
getRow : false,
emit : false,
send : false,
start : false,
sum : false,
log : false,
exports : false,
module : false
},
cssAttributeData,
cssAny,
cssColorData = {
"aliceblue" : true,
"antiquewhite" : true,
"aqua" : true,
"aquamarine" : true,
"azure" : true,
"beige" : true,
"bisque" : true,
"black" : true,
"blanchedalmond" : true,
"blue" : true,
"blueviolet" : true,
"brown" : true,
"burlywood" : true,
"cadetblue" : true,
"chartreuse" : true,
"chocolate" : true,
"coral" : true,
"cornflowerblue" : true,
"cornsilk" : true,
"crimson" : true,
"cyan" : true,
"darkblue" : true,
"darkcyan" : true,
"darkgoldenrod" : true,
"darkgray" : true,
"darkgreen" : true,
"darkkhaki" : true,
"darkmagenta" : true,
"darkolivegreen" : true,
"darkorange" : true,
"darkorchid" : true,
"darkred" : true,
"darksalmon" : true,
"darkseagreen" : true,
"darkslateblue" : true,
"darkslategray" : true,
"darkturquoise" : true,
"darkviolet" : true,
"deeppink" : true,
"deepskyblue" : true,
"dimgray" : true,
"dodgerblue" : true,
"firebrick" : true,
"floralwhite" : true,
"forestgreen" : true,
"fuchsia" : true,
"gainsboro" : true,
"ghostwhite" : true,
"gold" : true,
"goldenrod" : true,
"gray" : true,
"green" : true,
"greenyellow" : true,
"honeydew" : true,
"hotpink" : true,
"indianred" : true,
"indigo" : true,
"ivory" : true,
"khaki" : true,
"lavender" : true,
"lavenderblush" : true,
"lawngreen" : true,
"lemonchiffon" : true,
"lightblue" : true,
"lightcoral" : true,
"lightcyan" : true,
"lightgoldenrodyellow" : true,
"lightgreen" : true,
"lightpink" : true,
"lightsalmon" : true,
"lightseagreen" : true,
"lightskyblue" : true,
"lightslategray" : true,
"lightsteelblue" : true,
"lightyellow" : true,
"lime" : true,
"limegreen" : true,
"linen" : true,
"magenta" : true,
"maroon" : true,
"mediumaquamarine" : true,
"mediumblue" : true,
"mediumorchid" : true,
"mediumpurple" : true,
"mediumseagreen" : true,
"mediumslateblue" : true,
"mediumspringgreen" : true,
"mediumturquoise" : true,
"mediumvioletred" : true,
"midnightblue" : true,
"mintcream" : true,
"mistyrose" : true,
"moccasin" : true,
"navajowhite" : true,
"navy" : true,
"oldlace" : true,
"olive" : true,
"olivedrab" : true,
"orange" : true,
"orangered" : true,
"orchid" : true,
"palegoldenrod" : true,
"palegreen" : true,
"paleturquoise" : true,
"palevioletred" : true,
"papayawhip" : true,
"peachpuff" : true,
"peru" : true,
"pink" : true,
"plum" : true,
"powderblue" : true,
"purple" : true,
"red" : true,
"rosybrown" : true,
"royalblue" : true,
"saddlebrown" : true,
"salmon" : true,
"sandybrown" : true,
"seagreen" : true,
"seashell" : true,
"sienna" : true,
"silver" : true,
"skyblue" : true,
"slateblue" : true,
"slategray" : true,
"snow" : true,
"springgreen" : true,
"steelblue" : true,
"tan" : true,
"teal" : true,
"thistle" : true,
"tomato" : true,
"turquoise" : true,
"violet" : true,
"wheat" : true,
"white" : true,
"whitesmoke" : true,
"yellow" : true,
"yellowgreen" : true,
"activeborder" : true,
"activecaption" : true,
"appworkspace" : true,
"background" : true,
"buttonface" : true,
"buttonhighlight" : true,
"buttonshadow" : true,
"buttontext" : true,
"captiontext" : true,
"graytext" : true,
"highlight" : true,
"highlighttext" : true,
"inactiveborder" : true,
"inactivecaption" : true,
"inactivecaptiontext" : true,
"infobackground" : true,
"infotext" : true,
"menu" : true,
"menutext" : true,
"scrollbar" : true,
"threeddarkshadow" : true,
"threedface" : true,
"threedhighlight" : true,
"threedlightshadow" : true,
"threedshadow" : true,
"window" : true,
"windowframe" : true,
"windowtext" : true
},
cssBorderStyle,
cssBreak,
cssLengthData = {
'%': true,
'cm': true,
'em': true,
'ex': true,
'in': true,
'mm': true,
'pc': true,
'pt': true,
'px': true
},
cssMedia,
cssOverflow,
devel = {
alert : false,
confirm : false,
console : false,
Debug : false,
opera : false,
prompt : false
},
escapes = {
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'/' : '\\/',
'\\': '\\\\'
},
funct, // The current function
functionicity = [
'closure', 'exception', 'global', 'label',
'outer', 'unused', 'var'
],
functions, // All of the functions
global, // The global scope
htmltag = {
a: {},
abbr: {},
acronym: {},
address: {},
applet: {},
area: {empty: true, parent: ' map '},
article: {},
aside: {},
audio: {},
b: {},
base: {empty: true, parent: ' head '},
bdo: {},
big: {},
blockquote: {},
body: {parent: ' html noframes '},
br: {empty: true},
button: {},
canvas: {parent: ' body p div th td '},
caption: {parent: ' table '},
center: {},
cite: {},
code: {},
col: {empty: true, parent: ' table colgroup '},
colgroup: {parent: ' table '},
command: {parent: ' menu '},
datalist: {},
dd: {parent: ' dl '},
del: {},
details: {},
dialog: {},
dfn: {},
dir: {},
div: {},
dl: {},
dt: {parent: ' dl '},
em: {},
embed: {},
fieldset: {},
figure: {},
font: {},
footer: {},
form: {},
frame: {empty: true, parent: ' frameset '},
frameset: {parent: ' html frameset '},
h1: {},
h2: {},
h3: {},
h4: {},
h5: {},
h6: {},
head: {parent: ' html '},
header: {},
hgroup: {},
hr: {empty: true},
'hta:application':
{empty: true, parent: ' head '},
html: {parent: '*'},
i: {},
iframe: {},
img: {empty: true},
input: {empty: true},
ins: {},
kbd: {},
keygen: {},
label: {},
legend: {parent: ' details fieldset figure '},
li: {parent: ' dir menu ol ul '},
link: {empty: true, parent: ' head '},
map: {},
mark: {},
menu: {},
meta: {empty: true, parent: ' head noframes noscript '},
meter: {},
nav: {},
noframes: {parent: ' html body '},
noscript: {parent: ' body head noframes '},
object: {},
ol: {},
optgroup: {parent: ' select '},
option: {parent: ' optgroup select '},
output: {},
p: {},
param: {empty: true, parent: ' applet object '},
pre: {},
progress: {},
q: {},
rp: {},
rt: {},
ruby: {},
samp: {},
script: {empty: true, parent: ' body div frame head iframe p pre span '},
section: {},
select: {},
small: {},
span: {},
source: {},
strong: {},
style: {parent: ' head ', empty: true},
sub: {},
sup: {},
table: {},
tbody: {parent: ' table '},
td: {parent: ' tr '},
textarea: {},
tfoot: {parent: ' table '},
th: {parent: ' tr '},
thead: {parent: ' table '},
time: {},
title: {parent: ' head '},
tr: {parent: ' table tbody thead tfoot '},
tt: {},
u: {},
ul: {},
'var': {},
video: {}
},
ids, // HTML ids
implied, // Implied globals
inblock,
indent,
jsonmode,
jquery = {
'$' : false,
jQuery : false
},
lines,
lookahead,
member,
membersOnly,
nexttoken,
node = {
__filename : false,
__dirname : false,
Buffer : false,
GLOBAL : false,
global : false,
module : false,
process : false,
require : false
},
noreach,
option,
predefined, // Global variables defined by option
prereg,
prevtoken,
rhino = {
defineClass : false,
deserialize : false,
gc : false,
help : false,
load : false,
loadClass : false,
print : false,
quit : false,
readFile : false,
readUrl : false,
runCommand : false,
seal : false,
serialize : false,
spawn : false,
sync : false,
toint32 : false,
version : false
},
scope, // The current scope
src,
stack,
// standard contains the global names that are provided by the
// ECMAScript standard.
standard = {
Array : false,
Boolean : false,
Date : false,
decodeURI : false,
decodeURIComponent : false,
encodeURI : false,
encodeURIComponent : false,
Error : false,
'eval' : false,
EvalError : false,
Function : false,
hasOwnProperty : false,
isFinite : false,
isNaN : false,
JSON : false,
Math : false,
Number : false,
Object : false,
parseInt : false,
parseFloat : false,
RangeError : false,
ReferenceError : false,
RegExp : false,
String : false,
SyntaxError : false,
TypeError : false,
URIError : false
},
standard_member = {
E : true,
LN2 : true,
LN10 : true,
LOG2E : true,
LOG10E : true,
MAX_VALUE : true,
MIN_VALUE : true,
NEGATIVE_INFINITY : true,
PI : true,
POSITIVE_INFINITY : true,
SQRT1_2 : true,
SQRT2 : true
},
strict_mode,
syntax = {},
tab,
token,
urls,
warnings,
// widget contains the global names which are provided to a Yahoo
// (fna Konfabulator) widget.
widget = {
alert : true,
animator : true,
appleScript : true,
beep : true,
bytesToUIString : true,
Canvas : true,
chooseColor : true,
chooseFile : true,
chooseFolder : true,
closeWidget : true,
COM : true,
convertPathToHFS : true,
convertPathToPlatform : true,
CustomAnimation : true,
escape : true,
FadeAnimation : true,
filesystem : true,
Flash : true,
focusWidget : true,
form : true,
FormField : true,
Frame : true,
HotKey : true,
Image : true,
include : true,
isApplicationRunning : true,
iTunes : true,
konfabulatorVersion : true,
log : true,
md5 : true,
MenuItem : true,
MoveAnimation : true,
openURL : true,
play : true,
Point : true,
popupMenu : true,
preferenceGroups : true,
preferences : true,
print : true,
prompt : true,
random : true,
Rectangle : true,
reloadWidget : true,
ResizeAnimation : true,
resolvePath : true,
resumeUpdates : true,
RotateAnimation : true,
runCommand : true,
runCommandInBg : true,
saveAs : true,
savePreferences : true,
screen : true,
ScrollBar : true,
showWidgetPreferences : true,
sleep : true,
speak : true,
Style : true,
suppressUpdates : true,
system : true,
tellWidget : true,
Text : true,
TextArea : true,
Timer : true,
unescape : true,
updateNow : true,
URL : true,
Web : true,
widget : true,
Window : true,
XMLDOM : true,
XMLHttpRequest : true,
yahooCheckLogin : true,
yahooLogin : true,
yahooLogout : true
},
windows = {
ActiveXObject: false,
CScript : false,
Debug : false,
Enumerator : false,
System : false,
VBArray : false,
WScript : false
},
// xmode is used to adapt to the exceptions in html parsing.
// It can have these states:
// false .js script file
// html
// outer
// script
// style
// scriptstring
// styleproperty
xmode,
xquote,
// Regular expressions. Some of these are stupidly long.
// unsafe comment or string
ax = /@cc|<\/?|script|\]\s*\]|<\s*!|</i,
// unsafe characters that are silently deleted by one or more browsers
cx = /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
// token
tx = /^\s*([(){}\[.,:;'"~\?\]#@]|==?=?|\/(\*(jshint|members?|global)?|=|\/)?|\*[\/=]?|\+(?:=|\++)?|-(?:=|-+)?|%=?|&[&=]?|\|[|=]?|>>?>?=?|<([\/=!]|\!(\[|--)?|<=?)?|\^=?|\!=?=?|[a-zA-Z_$][a-zA-Z0-9_$]*|[0-9]+([xX][0-9a-fA-F]+|\.[0-9]*)?([eE][+\-]?[0-9]+)?)/,
// html token
hx = /^\s*(['"=>\/&#]|<(?:\/|\!(?:--)?)?|[a-zA-Z][a-zA-Z0-9_\-:]*|[0-9]+|--)/,
// characters in strings that need escapement
nx = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/,
nxg = /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
// outer html token
ox = /[>&]|<[\/!]?|--/,
// star slash
lx = /\*\/|\/\*/,
// identifier
ix = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/,
// javascript url
jx = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i,
// url badness
ux = /&|\+|\u00AD|\.\.|\/\*|%[^;]|base64|url|expression|data|mailto/i,
// style
sx = /^\s*([{:#%.=,>+\[\]@()"';]|\*=?|\$=|\|=|\^=|~=|[a-zA-Z_][a-zA-Z0-9_\-]*|[0-9]+|<\/|\/\*)/,
ssx = /^\s*([@#!"'};:\-%.=,+\[\]()*_]|[a-zA-Z][a-zA-Z0-9._\-]*|\/\*?|\d+(?:\.\d+)?|<\/)/,
// attributes characters
qx = /[^a-zA-Z0-9+\-_\/ ]/,
// query characters for ids
dx = /[\[\]\/\\"'*<>.&:(){}+=#]/,
// catches /* falls through */ comments
ft = /^\s*\/\*\s*falls\sthrough\s*\*\/\s*$/,
rx = {
outer: hx,
html: hx,
style: sx,
styleproperty: ssx
};
function F() {} // Used by Object.create
function is_own(object, name) {
// The object.hasOwnProperty method fails when the property under consideration
// is named 'hasOwnProperty'. So we have to use this more convoluted form.
return Object.prototype.hasOwnProperty.call(object, name);
}
// Provide critical ES5 functions to ES3.
if (typeof Array.isArray !== 'function') {
Array.isArray = function (o) {
return Object.prototype.toString.apply(o) === '[object Array]';
};
}
if (typeof Object.create !== 'function') {
Object.create = function (o) {
F.prototype = o;
return new F();
};
}
if (typeof Object.keys !== 'function') {
Object.keys = function (o) {
var a = [], k;
for (k in o) {
if (is_own(o, k)) {
a.push(k);
}
}
return a;
};
}
// Non standard methods
if (typeof String.prototype.entityify !== 'function') {
String.prototype.entityify = function () {
return this
.replace(/&/g, '&')
.replace(/</g, '<')
.replace(/>/g, '>');
};
}
if (typeof String.prototype.isAlpha !== 'function') {
String.prototype.isAlpha = function () {
return (this >= 'a' && this <= 'z\uffff') ||
(this >= 'A' && this <= 'Z\uffff');
};
}
if (typeof String.prototype.isDigit !== 'function') {
String.prototype.isDigit = function () {
return (this >= '0' && this <= '9');
};
}
if (typeof String.prototype.supplant !== 'function') {
String.prototype.supplant = function (o) {
return this.replace(/\{([^{}]*)\}/g, function (a, b) {
var r = o[b];
return typeof r === 'string' || typeof r === 'number' ? r : a;
});
};
}
if (typeof String.prototype.name !== 'function') {
String.prototype.name = function () {
// If the string looks like an identifier, then we can return it as is.
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can simply slap some quotes around it.
// Otherwise we must also replace the offending characters with safe
// sequences.
if (ix.test(this)) {
return this;
}
if (nx.test(this)) {
return '"' + this.replace(nxg, function (a) {
var c = escapes[a];
if (c) {
return c;
}
return '\\u' + ('0000' + a.charCodeAt().toString(16)).slice(-4);
}) + '"';
}
return '"' + this + '"';
};
}
function combine(t, o) {
var n;
for (n in o) {
if (is_own(o, n)) {
t[n] = o[n];
}
}
}
function assume() {
if (option.safe)
return;
if (option.couch)
combine(predefined, couch);
if (option.rhino)
combine(predefined, rhino);
if (option.node)
combine(predefined, node);
if (option.devel)
combine(predefined, devel);
if (option.browser)
combine(predefined, browser);
if (option.jquery)
combine(predefined, jquery);
if (option.windows)
combine(predefined, windows);
if (option.widget)
combine(predefined, widget);
}
// Produce an error warning.
function quit(m, l, ch) {
throw {
name: 'JSHintError',
line: l,
character: ch,
message: m + " (" + Math.floor((l / lines.length) * 100) +
"% scanned)."
};
}
function warning(m, t, a, b, c, d) {
var ch, l, w;
t = t || nexttoken;
if (t.id === '(end)') { // `~
t = token;
}
l = t.line || 0;
ch = t.from || 0;
w = {
id: '(error)',
raw: m,
evidence: lines[l - 1] || '',
line: l,
character: ch,
a: a,
b: b,
c: c,
d: d
};
w.reason = m.supplant(w);
JSHINT.errors.push(w);
if (option.passfail) {
quit('Stopping. ', l, ch);
}
warnings += 1;
if (warnings >= option.maxerr) {
quit("Too many errors.", l, ch);
}
return w;
}
function warningAt(m, l, ch, a, b, c, d) {
return warning(m, {
line: l,
from: ch
}, a, b, c, d);
}
function error(m, t, a, b, c, d) {
var w = warning(m, t, a, b, c, d);
quit("Stopping, unable to continue.", w.line, w.character);
}
function errorAt(m, l, ch, a, b, c, d) {
return error(m, {
line: l,
from: ch
}, a, b, c, d);
}
// lexical analysis and token construction
var lex = (function lex() {
var character, from, line, s;
// Private lex methods
function nextLine() {
var at;
if (line >= lines.length) {
return false;
}
character = 1;
s = lines[line];
line += 1;
at = s.search(/ \t/);
if (at >= 0) {
warningAt("Mixed spaces and tabs.", line, at + 1);
}
s = s.replace(/\t/g, tab);
at = s.search(cx);
if (at >= 0) {
warningAt("Unsafe character.", line, at);
}
if (option.maxlen && option.maxlen < s.length) {
warningAt("Line too long.", line, s.length);
}
return true;
}
// Produce a token object. The token inherits from a syntax symbol.
function it(type, value) {
var i, t;
if (type === '(color)' || type === '(range)') {
t = {type: type};
} else if (type === '(punctuator)' ||
(type === '(identifier)' && is_own(syntax, value))) {
t = syntax[value] || syntax['(error)'];
} else {
t = syntax[type];
}
t = Object.create(t);
if (type === '(string)' || type === '(range)') {
if (jx.test(value)) {
warningAt("Script URL.", line, from);
}
}
if (type === '(identifier)') {
t.identifier = true;
if (value === '__iterator__' || value === '__proto__') {
errorAt("Reserved name '{a}'.",
line, from, value);
} else if (option.nomen &&
(value.charAt(0) === '_' ||
value.charAt(value.length - 1) === '_')) {
warningAt("Unexpected {a} in '{b}'.", line, from,
"dangling '_'", value);
}
}
t.value = value;
t.line = line;
t.character = character;
t.from = from;
i = t.id;
if (i !== '(endline)') {
prereg = i &&
(('(,=:[!&|?{};'.indexOf(i.charAt(i.length - 1)) >= 0) ||
i === 'return');
}
return t;
}
// Public lex methods
return {
init: function (source) {
if (typeof source === 'string') {
lines = source
.replace(/\r\n/g, '\n')
.replace(/\r/g, '\n')
.split('\n');
} else {
lines = source;
}
line = 0;
nextLine();
from = 1;
},
range: function (begin, end) {
var c, value = '';
from = character;
if (s.charAt(0) !== begin) {
errorAt("Expected '{a}' and instead saw '{b}'.",
line, character, begin, s.charAt(0));
}
for (;;) {
s = s.slice(1);
character += 1;
c = s.charAt(0);
switch (c) {
case '':
errorAt("Missing '{a}'.", line, character, c);
break;
case end:
s = s.slice(1);
character += 1;
return it('(range)', value);
case xquote:
case '\\':
warningAt("Unexpected '{a}'.", line, character, c);
}
value += c;