diff --git a/spark/src/main/java/com/nflabs/zeppelin/spark/SparkInterpreter.java b/spark/src/main/java/com/nflabs/zeppelin/spark/SparkInterpreter.java index faed295e..a2488a11 100644 --- a/spark/src/main/java/com/nflabs/zeppelin/spark/SparkInterpreter.java +++ b/spark/src/main/java/com/nflabs/zeppelin/spark/SparkInterpreter.java @@ -73,16 +73,16 @@ public class SparkInterpreter extends Interpreter { "spark", SparkInterpreter.class.getName(), new InterpreterPropertyBuilder() - .add("spark.app.name", "Zeppelin", "The name of spark application") + .add("spark.app.name", "Zeppelin", "The name of spark application.") .add("master", getSystemDefault("MASTER", "spark.master", "local[*]"), - "spark master uri. ex) spark://masterhost:7077") + "Spark master uri. ex) spark://masterhost:7077") .add("spark.executor.memory", getSystemDefault(null, "spark.executor.memory", "512m"), - "executor memory per worker instance. ex) 512m, 32g") + "Executor memory per worker instance. ex) 512m, 32g") .add("spark.cores.max", getSystemDefault(null, "spark.cores.max", ""), - "total number of cores to use. Empty value uses all available core") + "Total number of cores to use. Empty value uses all available core.") .add("args", "", "spark commandline args").build()); } diff --git a/spark/src/main/java/com/nflabs/zeppelin/spark/SparkSqlInterpreter.java b/spark/src/main/java/com/nflabs/zeppelin/spark/SparkSqlInterpreter.java index 2207090d..4f8cb77e 100644 --- a/spark/src/main/java/com/nflabs/zeppelin/spark/SparkSqlInterpreter.java +++ b/spark/src/main/java/com/nflabs/zeppelin/spark/SparkSqlInterpreter.java @@ -52,9 +52,9 @@ public class SparkSqlInterpreter extends Interpreter { "spark", SparkSqlInterpreter.class.getName(), new InterpreterPropertyBuilder() - .add("zeppelin.spark.maxResult", "10000", "Max number of SparkSQL result to display") + .add("zeppelin.spark.maxResult", "10000", "Max number of SparkSQL result to display.") .add("zeppelin.spark.useHiveContext", "false", - "use HiveContext instead of SQLContext if it is true") + "Use HiveContext instead of SQLContext if it is true.") .add("zeppelin.spark.concurrentSQL", "false", "Execute multiple SQL concurrently if set true.") .build()); diff --git a/zeppelin-server/src/main/java/com/nflabs/zeppelin/rest/InterpreterRestApi.java b/zeppelin-server/src/main/java/com/nflabs/zeppelin/rest/InterpreterRestApi.java index 38ec9c5a..0bdbfb0c 100644 --- a/zeppelin-server/src/main/java/com/nflabs/zeppelin/rest/InterpreterRestApi.java +++ b/zeppelin-server/src/main/java/com/nflabs/zeppelin/rest/InterpreterRestApi.java @@ -87,6 +87,23 @@ public Response newSettings(String message) throws InterpreterException, IOExcep return new JsonResponse(Status.CREATED, "").build(); } + @PUT + @Path("setting/{settingId}") + public Response updateSetting(String message, @PathParam("settingId") String settingId) { + logger.info("Update interpreterSetting {}", settingId); + try { + Properties p = gson.fromJson(message, Properties.class); + interpreterFactory.setPropertyAndRestart(settingId, p); + } catch (InterpreterException e) { + return new JsonResponse(Status.NOT_FOUND, e.getMessage(), e).build(); + } + InterpreterSetting setting = interpreterFactory.get(settingId); + if (setting == null) { + return new JsonResponse(Status.NOT_FOUND, "", settingId).build(); + } + return new JsonResponse(Status.OK, "", setting).build(); + } + @DELETE @Path("setting/{settingId}") @ApiOperation(httpMethod = "GET", value = "Remove interpreter setting") diff --git a/zeppelin-web/Gruntfile.js b/zeppelin-web/Gruntfile.js index 0b513f92..0bb2bccd 100644 --- a/zeppelin-web/Gruntfile.js +++ b/zeppelin-web/Gruntfile.js @@ -40,6 +40,13 @@ module.exports = function (grunt) { livereload: '<%= connect.options.livereload %>' } }, + scripts: { + files: ['<%= yeoman.app %>/scripts/ts/**/*.ts'], + tasks: ['typescript'], + options: { + spawn: false + } + }, jsTest: { files: ['test/spec/{,*/}*.js'], tasks: ['newer:jshint:test', 'karma'] @@ -348,9 +355,23 @@ module.exports = function (grunt) { configFile: 'test/karma.conf.js', singleRun: true } + }, + + typescript: { + base: { + src: ['<%= yeoman.app %>/typescripts/**/*.ts'], + dest: '<%= yeoman.app %>/scripts/', + options: { + module: 'amd', //or commonjs + target: 'es5', //or es3 + basePath: '<%= yeoman.app %>/typescripts/', + sourceMap: true, + declaration: true + } + } } - }); + }); grunt.registerTask('serve', 'Compile then start a connect web server', function (target) { if (target === 'dist') { @@ -359,8 +380,9 @@ module.exports = function (grunt) { grunt.task.run([ 'clean:server', + 'typescript', 'wiredep', - 'concurrent:server', + 'concurrent:dist', 'autoprefixer', 'connect:livereload', /*'newer:jshint'*/ @@ -375,6 +397,7 @@ module.exports = function (grunt) { grunt.registerTask('test', [ 'clean:server', + 'typescript', 'concurrent:test', 'autoprefixer', 'connect:test', @@ -383,6 +406,7 @@ module.exports = function (grunt) { grunt.registerTask('build', [ 'clean:dist', + 'typescript', 'wiredep', 'useminPrepare', 'concurrent:dist', diff --git a/zeppelin-web/README.md b/zeppelin-web/README.md index 4df6e4c7..ecda1b2b 100644 --- a/zeppelin-web/README.md +++ b/zeppelin-web/README.md @@ -4,11 +4,14 @@ This is a Zeppelin web frontend project. ## Compile Zeppelin web If you want to compile the WebApplication, you will have to simply run `mvn package`. -This will Download all the dependencies including node js and npm (you will find the binaries in the folder `zeppelin-web/node`). +This will Download all the dependencies including node js and npm +(you will find the binaries in the folder `zeppelin-web/node`). -We also provide some **helper script** for bower and grunt (you dont need to install them). +We also provide some **helper script** for bower and grunt +(you dont need to install them). -In case of the error `ECMDERR Failed to execute "git ls-remote --tags --heads git://xxxxx", exit code of #128` +In case of the error +`ECMDERR Failed to execute "git ls-remote --tags --heads git://xxxxx", exit code of #128` change your git config with `git config --global url."https://".insteadOf git://` @@ -20,7 +23,6 @@ Try to add to the `.bowerrc` file the following content: "https-proxy" : "http://:" ``` - and retry to build again. ## Contribute on Zeppelin Web @@ -28,16 +30,35 @@ If you wish to help us to contribute on Zeppelin Web, you will need to install s Here this is a good start to understand how zeppelin web is architectured. http://www.sitepoint.com/kickstart-your-angularjs-development-with-yeoman-grunt-and-bower/ +Also, Zeppelin uses Typescript http://www.typescriptlang.org/ to maintain +stable structure of javascript codes . +You can read a good article on using AngularJs with Typescript in the next link. +http://www.scottlogic.com/blog/2014/08/26/StrongTypingWithAngularJS.html + ### Run the application in dev mode ``./grunt serve`` ### Build the application `./grunt build` -### Add composents to Zeppelin Webapp +### Add components to Zeppelin Webapp * New controller : `yo angular:controller ` * New directive : `yo angular:directive ` * New service : `yo angular:service ` + +(Currently, adding components by Yeoman (yo) is broken, +because officially Yeoman doesn't support Typescript.) + +You can generate codes by manually installing yo and linking generator. +reference: https://github.com/yeoman/yeoman/blob/master/contributing.md + +generator supporting Typescript: +https://github.com/eggers/generator-angular + +command: +`yo angular:controller --typescript` + +(Need test if a generated codes works well.) ### Add plugin diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/ace.d.ts b/zeppelin-web/app/external/DefinitelyTyped/ace/ace.d.ts new file mode 100644 index 00000000..29fadf3b --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/ace.d.ts @@ -0,0 +1,2937 @@ +// Type definitions for Ace Ajax.org Cloud9 Editor +// Project: http://ace.ajax.org/ +// Definitions by: Diullei Gomes +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module AceAjax { + + export interface Delta { + action: string; + range: Range; + text: string; + lines: string[]; + } + + export interface EditorCommand { + + name:string; + + bindKey:any; + + exec:Function; + } + + export interface CommandManager { + + byName; + + commands; + + platform: string; + + addCommands(commands:EditorCommand[]); + + addCommand(command:EditorCommand); + + exec(name: string, editor: Editor, args: any); + } + + export interface Annotation { + + row: number; + + column: number; + + text: string; + + type: string; + } + + export interface TokenInfo { + + value: string; + } + + export interface Position { + + row: number; + + column: number; + } + + export interface KeyBinding { + + setDefaultHandler(kb); + + setKeyboardHandler(kb); + + addKeyboardHandler(kb, pos); + + removeKeyboardHandler(kb): boolean; + + getKeyboardHandler(): any; + + onCommandKey(e, hashId, keyCode); + + onTextInput(text); + } + var KeyBinding: { + new(editor: Editor): KeyBinding; + } + + export interface TextMode { + + getTokenizer(): any; + + toggleCommentLines(state, doc, startRow, endRow); + + getNextLineIndent (state, line, tab): string; + + checkOutdent(state, line, input): boolean; + + autoOutdent(state, doc, row); + + createWorker(session): any; + + createModeDelegates (mapping); + + transformAction(state, action, editor, session, param): any; + } + + //////////////// + /// Ace + //////////////// + + /** + * The main class required to set up an Ace instance in the browser. + **/ + export interface Ace { + + /** + * Provides access to require in packed noconflict mode + * @param moduleName + **/ + require(moduleName: string): any; + + /** + * Embeds the Ace editor into the DOM, at the element provided by `el`. + * @param el Either the id of an element, or the element itself + **/ + edit(el: string): Editor; + + /** + * Embeds the Ace editor into the DOM, at the element provided by `el`. + * @param el Either the id of an element, or the element itself + **/ + edit(el: HTMLElement): Editor; + + /** + * Creates a new [[EditSession]], and returns the associated [[Document]]. + * @param text {:textParam} + * @param mode {:modeParam} + **/ + createEditSession(text: Document, mode: TextMode): IEditSession; + + /** + * Creates a new [[EditSession]], and returns the associated [[Document]]. + * @param text {:textParam} + * @param mode {:modeParam} + **/ + createEditSession(text: string, mode: TextMode): IEditSession; + } + + //////////////// + /// Anchor + //////////////// + + /** + * Defines the floating pointer in the document. Whenever text is inserted or deleted before the cursor, the position of the cursor is updated. + **/ + export interface Anchor { + + on(event: string, fn: (e) => any); + + /** + * Returns an object identifying the `row` and `column` position of the current anchor. + **/ + getPosition(): Position; + + /** + * Returns the current document. + **/ + getDocument(): Document; + + /** + * Fires whenever the anchor position changes. + * Both of these objects have a `row` and `column` property corresponding to the position. + * Events that can trigger this function include [[Anchor.setPosition `setPosition()`]]. + * @param e An object containing information about the anchor position. It has two properties: + * - `old`: An object describing the old Anchor position + * - `value`: An object describing the new Anchor position + **/ + onChange(e: any); + + /** + * Sets the anchor position to the specified row and column. If `noClip` is `true`, the position is not clipped. + * @param row The row index to move the anchor to + * @param column The column index to move the anchor to + * @param noClip Identifies if you want the position to be clipped + **/ + setPosition(row: number, column: number, noClip: boolean); + + /** + * When called, the `'change'` event listener is removed. + **/ + detach(); + } + var Anchor: { + /** + * Creates a new `Anchor` and associates it with a document. + * @param doc The document to associate with the anchor + * @param row The starting row position + * @param column The starting column position + **/ + new(doc: Document, row: number, column: number): Anchor; + } + + //////////////////////////////// + /// BackgroundTokenizer + //////////////////////////////// + + /** + * Tokenizes the current [[Document `Document`]] in the background, and caches the tokenized rows for future use. + * If a certain row is changed, everything below that row is re-tokenized. + **/ + export interface BackgroundTokenizer { + + states: any[]; + + /** + * Sets a new tokenizer for this object. + * @param tokenizer The new tokenizer to use + **/ + setTokenizer(tokenizer: Tokenizer); + + /** + * Sets a new document to associate with this object. + * @param doc The new document to associate with + **/ + setDocument(doc: Document); + + /** + * Emits the `'update'` event. `firstRow` and `lastRow` are used to define the boundaries of the region to be updated. + * @param firstRow The starting row region + * @param lastRow The final row region + **/ + fireUpdateEvent(firstRow: number, lastRow: number); + + /** + * Starts tokenizing at the row indicated. + * @param startRow The row to start at + **/ + start(startRow: number); + + /** + * Stops tokenizing. + **/ + stop(); + + /** + * Gives list of tokens of the row. (tokens are cached) + * @param row The row to get tokens at + **/ + getTokens(row: number): TokenInfo[]; + + /** + * [Returns the state of tokenization at the end of a row.]{: #BackgroundTokenizer.getState} + * @param row The row to get state at + **/ + getState(row: number): string; + } + var BackgroundTokenizer: { + /** + * Creates a new `BackgroundTokenizer` object. + * @param tokenizer The tokenizer to use + * @param editor The editor to associate with + **/ + new(tokenizer: Tokenizer, editor: Editor): BackgroundTokenizer; + } + + //////////////// + /// Document + //////////////// + + /** + * Contains the text of the document. Document can be attached to several [[EditSession `EditSession`]]s. + * At its core, `Document`s are just an array of strings, with each row in the document matching up to the array index. + **/ + export interface Document { + + on(event: string, fn: (e) => any); + + /** + * Replaces all the lines in the current `Document` with the value of `text`. + * @param text The text to use + **/ + setValue(text: string); + + /** + * Returns all the lines in the document as a single string, split by the new line character. + **/ + getValue(): string; + + /** + * Creates a new `Anchor` to define a floating point in the document. + * @param row The row number to use + * @param column The column number to use + **/ + createAnchor(row: number, column: number); + + /** + * Returns the newline character that's being used, depending on the value of `newLineMode`. + **/ + getNewLineCharacter(): string; + + /** + * [Sets the new line mode.]{: #Document.setNewLineMode.desc} + * @param newLineMode [The newline mode to use; can be either `windows`, `unix`, or `auto`]{: #Document.setNewLineMode.param} + **/ + setNewLineMode(newLineMode: string); + + /** + * [Returns the type of newlines being used; either `windows`, `unix`, or `auto`]{: #Document.getNewLineMode} + **/ + getNewLineMode(): string; + + /** + * Returns `true` if `text` is a newline character (either `\r\n`, `\r`, or `\n`). + * @param text The text to check + **/ + isNewLine(text: string): boolean; + + /** + * Returns a verbatim copy of the given line as it is in the document + * @param row The row index to retrieve + **/ + getLine(row: number): string; + + /** + * Returns an array of strings of the rows between `firstRow` and `lastRow`. This function is inclusive of `lastRow`. + * @param firstRow The first row index to retrieve + * @param lastRow The final row index to retrieve + **/ + getLines(firstRow: number, lastRow: number): string[]; + + /** + * Returns all lines in the document as string array. Warning: The caller should not modify this array! + **/ + getAllLines(): string[]; + + /** + * Returns the number of rows in the document. + **/ + getLength(): number; + + /** + * [Given a range within the document, this function returns all the text within that range as a single string.]{: #Document.getTextRange.desc} + * @param range The range to work with + **/ + getTextRange(range: Range): string; + + /** + * Inserts a block of `text` and the indicated `position`. + * @param position The position to start inserting at + * @param text A chunk of text to insert + **/ + insert(position: Position, text: string): any; + + /** + * Inserts the elements in `lines` into the document, starting at the row index given by `row`. This method also triggers the `'change'` event. + * @param row The index of the row to insert at + * @param lines An array of strings + **/ + insertLines(row: number, lines: string[]): any; + + /** + * Inserts a new line into the document at the current row's `position`. This method also triggers the `'change'` event. + * @param position The position to insert at + **/ + insertNewLine(position: Position): any; + + /** + * Inserts `text` into the `position` at the current row. This method also triggers the `'change'` event. + * @param position The position to insert at + * @param text A chunk of text + **/ + insertInLine(position: any, text: string): any; + + /** + * Removes the `range` from the document. + * @param range A specified Range to remove + **/ + remove(range: Range): any; + + /** + * Removes the specified columns from the `row`. This method also triggers the `'change'` event. + * @param row The row to remove from + * @param startColumn The column to start removing at + * @param endColumn The column to stop removing at + **/ + removeInLine(row: number, startColumn: number, endColumn: number): any; + + /** + * Removes a range of full lines. This method also triggers the `'change'` event. + * @param firstRow The first row to be removed + * @param lastRow The last row to be removed + **/ + removeLines(firstRow: number, lastRow: number): string[]; + + /** + * Removes the new line between `row` and the row immediately following it. This method also triggers the `'change'` event. + * @param row The row to check + **/ + removeNewLine(row: number); + + /** + * Replaces a range in the document with the new `text`. + * @param range A specified Range to replace + * @param text The new text to use as a replacement + **/ + replace(range: Range, text: string): any; + + /** + * Applies all the changes previously accumulated. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`. + **/ + applyDeltas(deltas: Delta[]); + + /** + * Reverts any changes previously applied. These can be either `'includeText'`, `'insertLines'`, `'removeText'`, and `'removeLines'`. + **/ + revertDeltas(deltas: Delta[]); + + /** + * Converts an index position in a document to a `{row, column}` object. + * Index refers to the "absolute position" of a character in the document. For example: + * ```javascript + * var x = 0; // 10 characters, plus one for newline + * var y = -1; + * ``` + * Here, `y` is an index 15: 11 characters for the first row, and 5 characters until `y` in the second. + * @param index An index to convert + * @param startRow=0 The row from which to start the conversion + **/ + indexToPosition(index: number, startRow: number): Position; + + /** + * Converts the `{row, column}` position in a document to the character's index. + * Index refers to the "absolute position" of a character in the document. For example: + * ```javascript + * var x = 0; // 10 characters, plus one for newline + * var y = -1; + * ``` + * Here, `y` is an index 15: 11 characters for the first row, and 5 characters until `y` in the second. + * @param pos The `{row, column}` to convert + * @param startRow=0 The row from which to start the conversion + **/ + positionToIndex(pos: Position, startRow: number): number; + } + var Document: { + /** + * Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty. + * @param text The starting text + **/ + new(text?: string): Document; + /** + * Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty. + * @param text The starting text + **/ + new(text?: string[]): Document; + } + + //////////////////////////////// + /// EditSession + //////////////////////////////// + + /** + * Stores all the data about [[Editor `Editor`]] state providing easy way to change editors state. + * `EditSession` can be attached to only one [[Document `Document`]]. Same `Document` can be attached to several `EditSession`s. + **/ + export interface IEditSession { + + selection: Selection; + + bgTokenizer: BackgroundTokenizer; + + doc: Document; + + on(event: string, fn: (e) => any); + + findMatchingBracket(position: Position); + + addFold(text: string, range: Range); + + getFoldAt(row: number, column: number): any; + + removeFold(arg: any); + + expandFold(arg: any); + + unfold(arg1: any, arg2: boolean); + + screenToDocumentColumn(row: number, column: number); + + getFoldDisplayLine(foldLine: any, docRow: number, docColumn: number): any; + + getFoldsInRange(range: Range): any; + + highlight(text: string); + + /** + * Sets the `EditSession` to point to a new `Document`. If a `BackgroundTokenizer` exists, it also points to `doc`. + * @param doc The new `Document` to use + **/ + setDocument(doc: Document); + + /** + * Returns the `Document` associated with this session. + **/ + getDocument(): Document; + + /** + * undefined + * @param row The row to work with + **/ + $resetRowCache(row: number); + + /** + * Sets the session text. + * @param text The new text to place + **/ + setValue(text: string); + + setMode(mode: string); + + /** + * Returns the current [[Document `Document`]] as a string. + **/ + getValue(): string; + + /** + * Returns the string of the current selection. + **/ + getSelection(): Selection; + + /** + * {:BackgroundTokenizer.getState} + * @param row The row to start at + **/ + getState(row: number): string; + + /** + * Starts tokenizing at the row indicated. Returns a list of objects of the tokenized rows. + * @param row The row to start at + **/ + getTokens(row: number): TokenInfo[]; + + /** + * Returns an object indicating the token at the current row. The object has two properties: `index` and `start`. + * @param row The row number to retrieve from + * @param column The column number to retrieve from + **/ + getTokenAt(row: number, column: number): TokenInfo; + + /** + * Sets the undo manager. + * @param undoManager The new undo manager + **/ + setUndoManager(undoManager: UndoManager); + + /** + * Returns the current undo manager. + **/ + getUndoManager(): UndoManager; + + /** + * Returns the current value for tabs. If the user is using soft tabs, this will be a series of spaces (defined by [[EditSession.getTabSize `getTabSize()`]]); otherwise it's simply `'\t'`. + **/ + getTabString(): string; + + /** + * Pass `true` to enable the use of soft tabs. Soft tabs means you're using spaces instead of the tab character (`'\t'`). + * @param useSoftTabs Value indicating whether or not to use soft tabs + **/ + setUseSoftTabs(useSoftTabs: boolean); + + /** + * Returns `true` if soft tabs are being used, `false` otherwise. + **/ + getUseSoftTabs(): boolean; + + /** + * Set the number of spaces that define a soft tab; for example, passing in `4` transforms the soft tabs to be equivalent to four spaces. This function also emits the `changeTabSize` event. + * @param tabSize The new tab size + **/ + setTabSize(tabSize: number); + + /** + * Returns the current tab size. + **/ + getTabSize(): string; + + /** + * Returns `true` if the character at the position is a soft tab. + * @param position The position to check + **/ + isTabStop(position: any): boolean; + + /** + * Pass in `true` to enable overwrites in your session, or `false` to disable. + * If overwrites is enabled, any text you enter will type over any text after it. If the value of `overwrite` changes, this function also emites the `changeOverwrite` event. + * @param overwrite Defines wheter or not to set overwrites + **/ + setOverwrite(overwrite: boolean); + + /** + * Returns `true` if overwrites are enabled; `false` otherwise. + **/ + getOverwrite(): boolean; + + /** + * Sets the value of overwrite to the opposite of whatever it currently is. + **/ + toggleOverwrite(); + + /** + * Adds `className` to the `row`, to be used for CSS stylings and whatnot. + * @param row The row number + * @param className The class to add + **/ + addGutterDecoration(row: number, className: string); + + /** + * Removes `className` from the `row`. + * @param row The row number + * @param className The class to add + **/ + removeGutterDecoration(row: number, className: string); + + /** + * Returns an array of numbers, indicating which rows have breakpoints. + **/ + getBreakpoints(): number[]; + + /** + * Sets a breakpoint on every row number given by `rows`. This function also emites the `'changeBreakpoint'` event. + * @param rows An array of row indices + **/ + setBreakpoints(rows: any[]); + + /** + * Removes all breakpoints on the rows. This function also emites the `'changeBreakpoint'` event. + **/ + clearBreakpoints(); + + /** + * Sets a breakpoint on the row number given by `rows`. This function also emites the `'changeBreakpoint'` event. + * @param row A row index + * @param className Class of the breakpoint + **/ + setBreakpoint(row: number, className: string); + + /** + * Removes a breakpoint on the row number given by `rows`. This function also emites the `'changeBreakpoint'` event. + * @param row A row index + **/ + clearBreakpoint(row: number); + + /** + * Adds a new marker to the given `Range`. If `inFront` is `true`, a front marker is defined, and the `'changeFrontMarker'` event fires; otherwise, the `'changeBackMarker'` event fires. + * @param range Define the range of the marker + * @param clazz Set the CSS class for the marker + * @param type Identify the type of the marker + * @param inFront Set to `true` to establish a front marker + **/ + addMarker(range: Range, clazz: string, type: Function, inFront: boolean); + + /** + * Adds a new marker to the given `Range`. If `inFront` is `true`, a front marker is defined, and the `'changeFrontMarker'` event fires; otherwise, the `'changeBackMarker'` event fires. + * @param range Define the range of the marker + * @param clazz Set the CSS class for the marker + * @param type Identify the type of the marker + * @param inFront Set to `true` to establish a front marker + **/ + addMarker(range: Range, clazz: string, type: string, inFront: boolean); + + /** + * Adds a dynamic marker to the session. + * @param marker object with update method + * @param inFront Set to `true` to establish a front marker + **/ + addDynamicMarker(marker: any, inFront: boolean); + + /** + * Removes the marker with the specified ID. If this marker was in front, the `'changeFrontMarker'` event is emitted. If the marker was in the back, the `'changeBackMarker'` event is emitted. + * @param markerId A number representing a marker + **/ + removeMarker(markerId: number); + + /** + * Returns an array containing the IDs of all the markers, either front or back. + * @param inFront If `true`, indicates you only want front markers; `false` indicates only back markers + **/ + getMarkers(inFront: boolean): any[]; + + /** + * Sets annotations for the `EditSession`. This functions emits the `'changeAnnotation'` event. + * @param annotations A list of annotations + **/ + setAnnotations(annotations: Annotation[]); + + /** + * Returns the annotations for the `EditSession`. + **/ + getAnnotations(): any; + + /** + * Clears all the annotations for this session. This function also triggers the `'changeAnnotation'` event. + **/ + clearAnnotations(); + + /** + * If `text` contains either the newline (`\n`) or carriage-return ('\r') characters, `$autoNewLine` stores that value. + * @param text A block of text + **/ + $detectNewLine(text: string); + + /** + * Given a starting row and column, this method returns the `Range` of the first word boundary it finds. + * @param row The row to start at + * @param column The column to start at + **/ + getWordRange(row: number, column: number): Range; + + /** + * Gets the range of a word, including its right whitespace. + * @param row The row number to start from + * @param column The column number to start from + **/ + getAWordRange(row: number, column: number): any; + + /** + * {:Document.setNewLineMode.desc} + * @param newLineMode {:Document.setNewLineMode.param} + **/ + setNewLineMode(newLineMode: string); + + /** + * Returns the current new line mode. + **/ + getNewLineMode(): string; + + /** + * Identifies if you want to use a worker for the `EditSession`. + * @param useWorker Set to `true` to use a worker + **/ + setUseWorker(useWorker: boolean); + + /** + * Returns `true` if workers are being used. + **/ + getUseWorker(): boolean; + + /** + * Reloads all the tokens on the current session. This function calls [[BackgroundTokenizer.start `BackgroundTokenizer.start ()`]] to all the rows; it also emits the `'tokenizerUpdate'` event. + **/ + onReloadTokenizer(); + + /** + * Sets a new text mode for the `EditSession`. This method also emits the `'changeMode'` event. If a [[BackgroundTokenizer `BackgroundTokenizer`]] is set, the `'tokenizerUpdate'` event is also emitted. + * @param mode Set a new text mode + **/ + $mode(mode: TextMode); + + /** + * Returns the current text mode. + **/ + getMode(): TextMode; + + /** + * This function sets the scroll top value. It also emits the `'changeScrollTop'` event. + * @param scrollTop The new scroll top value + **/ + setScrollTop(scrollTop: number); + + /** + * [Returns the value of the distance between the top of the editor and the topmost part of the visible content.]{: #EditSession.getScrollTop} + **/ + getScrollTop(): number; + + /** + * [Sets the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.setScrollLeft} + **/ + setScrollLeft(); + + /** + * [Returns the value of the distance between the left of the editor and the leftmost part of the visible content.]{: #EditSession.getScrollLeft} + **/ + getScrollLeft(): number; + + /** + * Returns the width of the screen. + **/ + getScreenWidth(): number; + + /** + * Returns a verbatim copy of the given line as it is in the document + * @param row The row to retrieve from + **/ + getLine(row: number): string; + + /** + * Returns an array of strings of the rows between `firstRow` and `lastRow`. This function is inclusive of `lastRow`. + * @param firstRow The first row index to retrieve + * @param lastRow The final row index to retrieve + **/ + getLines(firstRow: number, lastRow: number): string[]; + + /** + * Returns the number of rows in the document. + **/ + getLength(): number; + + /** + * {:Document.getTextRange.desc} + * @param range The range to work with + **/ + getTextRange(range: Range): string; + + /** + * Inserts a block of `text` and the indicated `position`. + * @param position The position {row, column} to start inserting at + * @param text A chunk of text to insert + **/ + insert(position: Position, text: string): any; + + /** + * Removes the `range` from the document. + * @param range A specified Range to remove + **/ + remove(range: Range): any; + + /** + * Reverts previous changes to your document. + * @param deltas An array of previous changes + * @param dontSelect [If `true`, doesn't select the range of where the change occured]{: #dontSelect} + **/ + undoChanges(deltas: any[], dontSelect: boolean): Range; + + /** + * Re-implements a previously undone change to your document. + * @param deltas An array of previous changes + * @param dontSelect {:dontSelect} + **/ + redoChanges(deltas: any[], dontSelect: boolean): Range; + + /** + * Enables or disables highlighting of the range where an undo occured. + * @param enable If `true`, selects the range of the reinserted change + **/ + setUndoSelect(enable: boolean); + + /** + * Replaces a range in the document with the new `text`. + * @param range A specified Range to replace + * @param text The new text to use as a replacement + **/ + replace(range: Range, text: string): any; + + /** + * Moves a range of text from the given range to the given position. `toPosition` is an object that looks like this: + * ```json + * { row: newRowLocation, column: newColumnLocation } + * ``` + * @param fromRange The range of text you want moved within the document + * @param toPosition The location (row and column) where you want to move the text to + **/ + moveText(fromRange: Range, toPosition: any): Range; + + /** + * Indents all the rows, from `startRow` to `endRow` (inclusive), by prefixing each row with the token in `indentString`. + * If `indentString` contains the `'\t'` character, it's replaced by whatever is defined by [[EditSession.getTabString `getTabString()`]]. + * @param startRow Starting row + * @param endRow Ending row + * @param indentString The indent token + **/ + indentRows(startRow: number, endRow: number, indentString: string); + + /** + * Outdents all the rows defined by the `start` and `end` properties of `range`. + * @param range A range of rows + **/ + outdentRows(range: Range); + + /** + * Shifts all the lines in the document up one, starting from `firstRow` and ending at `lastRow`. + * @param firstRow The starting row to move up + * @param lastRow The final row to move up + **/ + moveLinesUp(firstRow: number, lastRow: number): number; + + /** + * Shifts all the lines in the document down one, starting from `firstRow` and ending at `lastRow`. + * @param firstRow The starting row to move down + * @param lastRow The final row to move down + **/ + moveLinesDown(firstRow: number, lastRow: number): number; + + /** + * Duplicates all the text between `firstRow` and `lastRow`. + * @param firstRow The starting row to duplicate + * @param lastRow The final row to duplicate + **/ + duplicateLines(firstRow: number, lastRow: number): number; + + /** + * Sets whether or not line wrapping is enabled. If `useWrapMode` is different than the current value, the `'changeWrapMode'` event is emitted. + * @param useWrapMode Enable (or disable) wrap mode + **/ + setUseWrapMode(useWrapMode: boolean); + + /** + * Returns `true` if wrap mode is being used; `false` otherwise. + **/ + getUseWrapMode(): boolean; + + /** + * Sets the boundaries of wrap. Either value can be `null` to have an unconstrained wrap, or, they can be the same number to pin the limit. If the wrap limits for `min` or `max` are different, this method also emits the `'changeWrapMode'` event. + * @param min The minimum wrap value (the left side wrap) + * @param max The maximum wrap value (the right side wrap) + **/ + setWrapLimitRange(min: number, max: number); + + /** + * This should generally only be called by the renderer when a resize is detected. + * @param desiredLimit The new wrap limit + **/ + adjustWrapLimit(desiredLimit: number): boolean; + + /** + * Returns the value of wrap limit. + **/ + getWrapLimit(): number; + + /** + * Returns an object that defines the minimum and maximum of the wrap limit; it looks something like this: + * { min: wrapLimitRange_min, max: wrapLimitRange_max } + **/ + getWrapLimitRange(): any; + + /** + * Given a string, returns an array of the display characters, including tabs and spaces. + * @param str The string to check + * @param offset The value to start at + **/ + $getDisplayTokens(str: string, offset: number); + + /** + * Calculates the width of the string `str` on the screen while assuming that the string starts at the first column on the screen. + * @param str The string to calculate the screen width of + * @param maxScreenColumn + * @param screenColumn + **/ + $getStringScreenWidth(str: string, maxScreenColumn: number, screenColumn: number): number[]; + + /** + * Returns number of screenrows in a wrapped line. + * @param row The row number to check + **/ + getRowLength(row: number): number; + + /** + * Returns the position (on screen) for the last character in the provided screen row. + * @param screenRow The screen row to check + **/ + getScreenLastRowColumn(screenRow: number): number; + + /** + * For the given document row and column, this returns the column position of the last screen row. + * @param docRow + * @param docColumn + **/ + getDocumentLastRowColumn(docRow: number, docColumn: number): number; + + /** + * For the given document row and column, this returns the document position of the last row. + * @param docRow + * @param docColumn + **/ + getDocumentLastRowColumnPosition(docRow: number, docColumn: number): number; + + /** + * For the given row, this returns the split data. + **/ + getRowSplitData(): string; + + /** + * The distance to the next tab stop at the specified screen column. + * @param screenColumn The screen column to check + **/ + getScreenTabSize(screenColumn: number): number; + + /** + * Converts characters coordinates on the screen to characters coordinates within the document. [This takes into account code folding, word wrap, tab size, and any other visual modifications.]{: #conversionConsiderations} + * @param screenRow The screen row to check + * @param screenColumn The screen column to check + **/ + screenToDocumentPosition(screenRow: number, screenColumn: number): any; + + /** + * Converts document coordinates to screen coordinates. {:conversionConsiderations} + * @param docRow The document row to check + * @param docColumn The document column to check + **/ + documentToScreenPosition(docRow: number, docColumn: number): any; + + /** + * For the given document row and column, returns the screen column. + * @param row + * @param docColumn + **/ + documentToScreenColumn(row: number, docColumn: number): number; + + /** + * For the given document row and column, returns the screen row. + * @param docRow + * @param docColumn + **/ + documentToScreenRow(docRow: number, docColumn: number); + + /** + * Returns the length of the screen. + **/ + getScreenLength(): number; + } + var EditSession: { + /** + * Sets up a new `EditSession` and associates it with the given `Document` and `TextMode`. + * @param text [If `text` is a `Document`, it associates the `EditSession` with it. Otherwise, a new `Document` is created, with the initial text]{: #textParam} + * @param mode [The inital language mode to use for the document]{: #modeParam} + **/ + new(text: string, mode?: TextMode): IEditSession; + + new(content: string, mode?: string): IEditSession; + + new (text: string[], mode?: string): IEditSession; + } + + //////////////////////////////// + /// Editor + //////////////////////////////// + + /** + * The main entry point into the Ace functionality. + * The `Editor` manages the [[EditSession]] (which manages [[Document]]s), as well as the [[VirtualRenderer]], which draws everything to the screen. + * Event sessions dealing with the mouse and keyboard are bubbled up from `Document` to the `Editor`, which decides what to do with them. + **/ + export interface Editor { + + inMultiSelectMode: boolean; + + selectMoreLines(n: number); + + onTextInput(text: string); + + onCommandKey(e, hashId, keyCode); + + commands: CommandManager; + + session: IEditSession; + + selection: Selection; + + renderer: VirtualRenderer; + + keyBinding: KeyBinding; + + container: HTMLElement; + + onSelectionChange(e); + + onChangeMode(e?); + + execCommand(command:string, args?: any); + + /** + * Sets a new key handler, such as "vim" or "windows". + * @param keyboardHandler The new key handler + **/ + setKeyboardHandler(keyboardHandler: string); + + /** + * Returns the keyboard handler, such as "vim" or "windows". + **/ + getKeyboardHandler(): string; + + /** + * Sets a new editsession to use. This method also emits the `'changeSession'` event. + * @param session The new session to use + **/ + setSession(session: IEditSession); + + /** + * Returns the current session being used. + **/ + getSession(): IEditSession; + + /** + * Sets the current document to `val`. + * @param val The new value to set for the document + * @param cursorPos Where to set the new value. `undefined` or 0 is selectAll, -1 is at the document start, and 1 is at the end + **/ + setValue(val: string, cursorPos?: number): string; + + /** + * Returns the current session's content. + **/ + getValue(): string; + + /** + * Returns the currently highlighted selection. + **/ + getSelection(): Selection; + + /** + * {:VirtualRenderer.onResize} + * @param force If `true`, recomputes the size, even if the height and width haven't changed + **/ + resize(force?: boolean); + + /** + * {:VirtualRenderer.setTheme} + * @param theme The path to a theme + **/ + setTheme(theme: string); + + /** + * {:VirtualRenderer.getTheme} + **/ + getTheme(): string; + + /** + * {:VirtualRenderer.setStyle} + * @param style A class name + **/ + setStyle(style: string); + + /** + * {:VirtualRenderer.unsetStyle} + **/ + unsetStyle(); + + /** + * Set a new font size (in pixels) for the editor text. + * @param size A font size ( _e.g._ "12px") + **/ + setFontSize(size: string); + + /** + * Brings the current `textInput` into focus. + **/ + focus(); + + /** + * Returns `true` if the current `textInput` is in focus. + **/ + isFocused(); + + /** + * Blurs the current `textInput`. + **/ + blur(); + + /** + * Emitted once the editor comes into focus. + **/ + onFocus(); + + /** + * Emitted once the editor has been blurred. + **/ + onBlur(); + + /** + * Emitted whenever the document is changed. + * @param e Contains a single property, `data`, which has the delta of changes + **/ + onDocumentChange(e: any); + + /** + * Emitted when the selection changes. + **/ + onCursorChange(); + + /** + * Returns the string of text currently highlighted. + **/ + getCopyText(): string; + + /** + * Called whenever a text "copy" happens. + **/ + onCopy(); + + /** + * Called whenever a text "cut" happens. + **/ + onCut(); + + /** + * Called whenever a text "paste" happens. + * @param text The pasted text + **/ + onPaste(text: string); + + /** + * Inserts `text` into wherever the cursor is pointing. + * @param text The new text to add + **/ + insert(text: string); + + /** + * Pass in `true` to enable overwrites in your session, or `false` to disable. If overwrites is enabled, any text you enter will type over any text after it. If the value of `overwrite` changes, this function also emites the `changeOverwrite` event. + * @param overwrite Defines wheter or not to set overwrites + **/ + setOverwrite(overwrite: boolean); + + /** + * Returns `true` if overwrites are enabled; `false` otherwise. + **/ + getOverwrite(): boolean; + + /** + * Sets the value of overwrite to the opposite of whatever it currently is. + **/ + toggleOverwrite(); + + /** + * Sets how fast the mouse scrolling should do. + * @param speed A value indicating the new speed (in milliseconds) + **/ + setScrollSpeed(speed: number); + + /** + * Returns the value indicating how fast the mouse scroll speed is (in milliseconds). + **/ + getScrollSpeed(): number; + + /** + * Sets the delay (in milliseconds) of the mouse drag. + * @param dragDelay A value indicating the new delay + **/ + setDragDelay(dragDelay: number); + + /** + * Returns the current mouse drag delay. + **/ + getDragDelay(): number; + + /** + * Indicates how selections should occur. + * By default, selections are set to "line". There are no other styles at the moment, + * although this code change in the future. + * This function also emits the `'changeSelectionStyle'` event. + * @param style The new selection style + **/ + setSelectionStyle(style: string); + + /** + * Returns the current selection style. + **/ + getSelectionStyle(): string; + + /** + * Determines whether or not the current line should be highlighted. + * @param shouldHighlight Set to `true` to highlight the current line + **/ + setHighlightActiveLine(shouldHighlight: boolean); + + /** + * Returns `true` if current lines are always highlighted. + **/ + getHighlightActiveLine(); + + /** + * Determines if the currently selected word should be highlighted. + * @param shouldHighlight Set to `true` to highlight the currently selected word + **/ + setHighlightSelectedWord(shouldHighlight: boolean); + + /** + * Returns `true` if currently highlighted words are to be highlighted. + **/ + getHighlightSelectedWord(): boolean; + + /** + * If `showInvisibiles` is set to `true`, invisible characters—like spaces or new lines—are show in the editor. + * @param showInvisibles Specifies whether or not to show invisible characters + **/ + setShowInvisibles(showInvisibles: boolean); + + /** + * Returns `true` if invisible characters are being shown. + **/ + getShowInvisibles(): boolean; + + /** + * If `showPrintMargin` is set to `true`, the print margin is shown in the editor. + * @param showPrintMargin Specifies whether or not to show the print margin + **/ + setShowPrintMargin(showPrintMargin: boolean); + + /** + * Returns `true` if the print margin is being shown. + **/ + getShowPrintMargin(): boolean; + + /** + * Sets the column defining where the print margin should be. + * @param showPrintMargin Specifies the new print margin + **/ + setPrintMarginColumn(showPrintMargin: number); + + /** + * Returns the column number of where the print margin is. + **/ + getPrintMarginColumn(): number; + + /** + * If `readOnly` is true, then the editor is set to read-only mode, and none of the content can change. + * @param readOnly Specifies whether the editor can be modified or not + **/ + setReadOnly(readOnly: boolean); + + /** + * Returns `true` if the editor is set to read-only mode. + **/ + getReadOnly(): boolean; + + /** + * Specifies whether to use behaviors or not. ["Behaviors" in this case is the auto-pairing of special characters, like quotation marks, parenthesis, or brackets.]{: #BehaviorsDef} + * @param enabled Enables or disables behaviors + **/ + setBehavioursEnabled(enabled: boolean); + + /** + * Returns `true` if the behaviors are currently enabled. {:BehaviorsDef} + **/ + getBehavioursEnabled(): boolean; + + /** + * Specifies whether to use wrapping behaviors or not, i.e. automatically wrapping the selection with characters such as brackets + * when such a character is typed in. + * @param enabled Enables or disables wrapping behaviors + **/ + setWrapBehavioursEnabled(enabled: boolean); + + /** + * Returns `true` if the wrapping behaviors are currently enabled. + **/ + getWrapBehavioursEnabled(); + + /** + * Indicates whether the fold widgets are shown or not. + * @param show Specifies whether the fold widgets are shown + **/ + setShowFoldWidgets(show: boolean); + + /** + * Returns `true` if the fold widgets are shown. + **/ + getShowFoldWidgets(); + + /** + * Removes words of text from the editor. A "word" is defined as a string of characters bookended by whitespace. + * @param dir The direction of the deletion to occur, either "left" or "right" + **/ + remove(dir: string); + + /** + * Removes the word directly to the right of the current selection. + **/ + removeWordRight(); + + /** + * Removes the word directly to the left of the current selection. + **/ + removeWordLeft(); + + /** + * Removes all the words to the left of the current selection, until the start of the line. + **/ + removeToLineStart(); + + /** + * Removes all the words to the right of the current selection, until the end of the line. + **/ + removeToLineEnd(); + + /** + * Splits the line at the current selection (by inserting an `'\n'`). + **/ + splitLine(); + + /** + * Transposes current line. + **/ + transposeLetters(); + + /** + * Converts the current selection entirely into lowercase. + **/ + toLowerCase(); + + /** + * Converts the current selection entirely into uppercase. + **/ + toUpperCase(); + + /** + * Inserts an indentation into the current cursor position or indents the selected lines. + **/ + indent(); + + /** + * Indents the current line. + **/ + blockIndent(); + + /** + * Outdents the current line. + **/ + blockOutdent(arg?: string); + + /** + * Given the currently selected range, this function either comments all the lines, or uncomments all of them. + **/ + toggleCommentLines(); + + /** + * Works like [[EditSession.getTokenAt]], except it returns a number. + **/ + getNumberAt(): number; + + /** + * If the character before the cursor is a number, this functions changes its value by `amount`. + * @param amount The value to change the numeral by (can be negative to decrease value) + **/ + modifyNumber(amount: number); + + /** + * Removes all the lines in the current selection + **/ + removeLines(); + + /** + * Shifts all the selected lines down one row. + **/ + moveLinesDown(): number; + + /** + * Shifts all the selected lines up one row. + **/ + moveLinesUp(): number; + + /** + * Moves a range of text from the given range to the given position. `toPosition` is an object that looks like this: + * ```json + * { row: newRowLocation, column: newColumnLocation } + * ``` + * @param fromRange The range of text you want moved within the document + * @param toPosition The location (row and column) where you want to move the text to + **/ + moveText(fromRange: Range, toPosition: any): Range; + + /** + * Copies all the selected lines up one row. + **/ + copyLinesUp(): number; + + /** + * Copies all the selected lines down one row. + **/ + copyLinesDown(): number; + + /** + * {:VirtualRenderer.getFirstVisibleRow} + **/ + getFirstVisibleRow(): number; + + /** + * {:VirtualRenderer.getLastVisibleRow} + **/ + getLastVisibleRow(): number; + + /** + * Indicates if the row is currently visible on the screen. + * @param row The row to check + **/ + isRowVisible(row: number): boolean; + + /** + * Indicates if the entire row is currently visible on the screen. + * @param row The row to check + **/ + isRowFullyVisible(row: number): boolean; + + /** + * Selects the text from the current position of the document until where a "page down" finishes. + **/ + selectPageDown(); + + /** + * Selects the text from the current position of the document until where a "page up" finishes. + **/ + selectPageUp(); + + /** + * Shifts the document to wherever "page down" is, as well as moving the cursor position. + **/ + gotoPageDown(); + + /** + * Shifts the document to wherever "page up" is, as well as moving the cursor position. + **/ + gotoPageUp(); + + /** + * Scrolls the document to wherever "page down" is, without changing the cursor position. + **/ + scrollPageDown(); + + /** + * Scrolls the document to wherever "page up" is, without changing the cursor position. + **/ + scrollPageUp(); + + /** + * Moves the editor to the specified row. + **/ + scrollToRow(); + + /** + * Scrolls to a line. If `center` is `true`, it puts the line in middle of screen (or attempts to). + * @param line The line to scroll to + * @param center If `true` + * @param animate If `true` animates scrolling + * @param callback Function to be called when the animation has finished + **/ + scrollToLine(line: number, center: boolean, animate: boolean, callback: Function); + + /** + * Attempts to center the current selection on the screen. + **/ + centerSelection(); + + /** + * Gets the current position of the cursor. + **/ + getCursorPosition(): Position; + + /** + * Returns the screen position of the cursor. + **/ + getCursorPositionScreen(): number; + + /** + * {:Selection.getRange} + **/ + getSelectionRange(): Range; + + /** + * Selects all the text in editor. + **/ + selectAll(); + + /** + * {:Selection.clearSelection} + **/ + clearSelection(); + + /** + * Moves the cursor to the specified row and column. Note that this does not de-select the current selection. + * @param row The new row number + * @param column The new column number + **/ + moveCursorTo(row: number, column?: number, animate?:boolean); + + /** + * Moves the cursor to the position indicated by `pos.row` and `pos.column`. + * @param position An object with two properties, row and column + **/ + moveCursorToPosition(position: Position); + + /** + * Moves the cursor's row and column to the next matching bracket. + **/ + jumpToMatching(); + + /** + * Moves the cursor to the specified line number, and also into the indiciated column. + * @param lineNumber The line number to go to + * @param column A column number to go to + * @param animate If `true` animates scolling + **/ + gotoLine(lineNumber: number, column?: number, animate?: boolean); + + /** + * Moves the cursor to the specified row and column. Note that this does de-select the current selection. + * @param row The new row number + * @param column The new column number + **/ + navigateTo(row: number, column: number); + + /** + * Moves the cursor up in the document the specified number of times. Note that this does de-select the current selection. + * @param times The number of times to change navigation + **/ + navigateUp(times?: number); + + /** + * Moves the cursor down in the document the specified number of times. Note that this does de-select the current selection. + * @param times The number of times to change navigation + **/ + navigateDown(times?: number); + + /** + * Moves the cursor left in the document the specified number of times. Note that this does de-select the current selection. + * @param times The number of times to change navigation + **/ + navigateLeft(times?: number); + + /** + * Moves the cursor right in the document the specified number of times. Note that this does de-select the current selection. + * @param times The number of times to change navigation + **/ + navigateRight(times: number); + + /** + * Moves the cursor to the start of the current line. Note that this does de-select the current selection. + **/ + navigateLineStart(); + + /** + * Moves the cursor to the end of the current line. Note that this does de-select the current selection. + **/ + navigateLineEnd(); + + /** + * Moves the cursor to the end of the current file. Note that this does de-select the current selection. + **/ + navigateFileEnd(); + + /** + * Moves the cursor to the start of the current file. Note that this does de-select the current selection. + **/ + navigateFileStart(); + + /** + * Moves the cursor to the word immediately to the right of the current position. Note that this does de-select the current selection. + **/ + navigateWordRight(); + + /** + * Moves the cursor to the word immediately to the left of the current position. Note that this does de-select the current selection. + **/ + navigateWordLeft(); + + /** + * Replaces the first occurance of `options.needle` with the value in `replacement`. + * @param replacement The text to replace with + * @param options The [[Search `Search`]] options to use + **/ + replace(replacement: string, options?: any); + + /** + * Replaces all occurances of `options.needle` with the value in `replacement`. + * @param replacement The text to replace with + * @param options The [[Search `Search`]] options to use + **/ + replaceAll(replacement: string, options?: any); + + /** + * {:Search.getOptions} For more information on `options`, see [[Search `Search`]]. + **/ + getLastSearchOptions(): any; + + /** + * Attempts to find `needle` within the document. For more information on `options`, see [[Search `Search`]]. + * @param needle The text to search for (optional) + * @param options An object defining various search properties + * @param animate If `true` animate scrolling + **/ + find(needle: string, options?: any, animate?: boolean); + + /** + * Performs another search for `needle` in the document. For more information on `options`, see [[Search `Search`]]. + * @param options search options + * @param animate If `true` animate scrolling + **/ + findNext(options?: any, animate?: boolean); + + /** + * Performs a search for `needle` backwards. For more information on `options`, see [[Search `Search`]]. + * @param options search options + * @param animate If `true` animate scrolling + **/ + findPrevious(options?: any, animate?: boolean); + + /** + * {:UndoManager.undo} + **/ + undo(); + + /** + * {:UndoManager.redo} + **/ + redo(); + + /** + * Cleans up the entire editor. + **/ + destroy(); + + } + + var Editor: { + /** + * Creates a new `Editor` object. + * @param renderer Associated `VirtualRenderer` that draws everything + * @param session The `EditSession` to refer to + **/ + new(renderer: VirtualRenderer, session?: IEditSession): Editor; + } + + //////////////////////////////// + /// PlaceHolder + //////////////////////////////// + + export interface PlaceHolder { + + on(event: string, fn: (e) => any); + + /** + * PlaceHolder.setup() + * TODO + **/ + setup(); + + /** + * PlaceHolder.showOtherMarkers() + * TODO + **/ + showOtherMarkers(); + + /** + * PlaceHolder.hideOtherMarkers() + * Hides all over markers in the [[EditSession `EditSession`]] that are not the currently selected one. + **/ + hideOtherMarkers(); + + /** + * PlaceHolder@onUpdate(e) + * Emitted when the place holder updates. + **/ + onUpdate(); + + /** + * PlaceHolder@onCursorChange(e) + * Emitted when the cursor changes. + **/ + onCursorChange(); + + /** + * PlaceHolder.detach() + * TODO + **/ + detach(); + + /** + * PlaceHolder.cancel() + * TODO + **/ + cancel(); + } + var PlaceHolder: { + /** + * - @param session (Document): The document to associate with the anchor + * - @param length (Number): The starting row position + * - @param pos (Number): The starting column position + * - @param others (String): + * - @param mainClass (String): + * - @param othersClass (String): + **/ + new (session: Document, length: number, pos: number, others: string, mainClass: string, othersClass: string): PlaceHolder; + + new (session: IEditSession, length: number, pos: Position, positions: Position[]): PlaceHolder; + } + + //////////////// + /// RangeList + //////////////// + + export interface IRangeList { + ranges: Range[]; + + pointIndex(pos: Position, startIndex?: number); + + addList(ranges: Range[]); + + add(ranges: Range); + + merge(): Range[]; + + substractPoint(pos: Position); + } + export var RangeList: { + new (): IRangeList; + } + + //////////////// + /// Range + //////////////// + + /** + * This object is used in various places to indicate a region within the editor. To better visualize how this works, imagine a rectangle. Each quadrant of the rectangle is analogus to a range, as ranges contain a starting row and starting column, and an ending row, and ending column. + **/ + export interface Range { + + startRow:number; + + startColumn:number; + + endRow:number; + + endColumn:number; + + start: Position; + + end: Position; + + isEmpty(): boolean; + + /** + * Returns `true` if and only if the starting row and column, and ending row and column, are equivalent to those given by `range`. + * @param range A range to check against + **/ + isEqual(range: Range); + + /** + * Returns a string containing the range's row and column information, given like this: + * ``` + * [start.row/start.column] -> [end.row/end.column] + * ``` + **/ + toString(); + + /** + * Returns `true` if the `row` and `column` provided are within the given range. This can better be expressed as returning `true` if: + * ```javascript + * this.start.row <= row <= this.end.row && + * this.start.column <= column <= this.end.column + * ``` + * @param row A row to check for + * @param column A column to check for + **/ + contains(row: number, column: number): boolean; + + /** + * Compares `this` range (A) with another range (B). + * @param range A range to compare with + **/ + compareRange(range: Range): number; + + /** + * Checks the row and column points of `p` with the row and column points of the calling range. + * @param p A point to compare with + **/ + comparePoint(p: Range): number; + + /** + * Checks the start and end points of `range` and compares them to the calling range. Returns `true` if the `range` is contained within the caller's range. + * @param range A range to compare with + **/ + containsRange(range: Range): boolean; + + /** + * Returns `true` if passed in `range` intersects with the one calling this method. + * @param range A range to compare with + **/ + intersects(range: Range): boolean; + + /** + * Returns `true` if the caller's ending row point is the same as `row`, and if the caller's ending column is the same as `column`. + * @param row A row point to compare with + * @param column A column point to compare with + **/ + isEnd(row: number, column: number): boolean; + + /** + * Returns `true` if the caller's starting row point is the same as `row`, and if the caller's starting column is the same as `column`. + * @param row A row point to compare with + * @param column A column point to compare with + **/ + isStart(row: number, column: number): boolean; + + /** + * Sets the starting row and column for the range. + * @param row A row point to set + * @param column A column point to set + **/ + setStart(row: number, column: number); + + /** + * Sets the starting row and column for the range. + * @param row A row point to set + * @param column A column point to set + **/ + setEnd(row: number, column: number); + + /** + * Returns `true` if the `row` and `column` are within the given range. + * @param row A row point to compare with + * @param column A column point to compare with + **/ + inside(row: number, column: number): boolean; + + /** + * Returns `true` if the `row` and `column` are within the given range's starting points. + * @param row A row point to compare with + * @param column A column point to compare with + **/ + insideStart(row: number, column: number): boolean; + + /** + * Returns `true` if the `row` and `column` are within the given range's ending points. + * @param row A row point to compare with + * @param column A column point to compare with + **/ + insideEnd(row: number, column: number): boolean; + + /** + * Checks the row and column points with the row and column points of the calling range. + * @param row A row point to compare with + * @param column A column point to compare with + **/ + compare(row: number, column: number): number; + + /** + * Checks the row and column points with the row and column points of the calling range. + * @param row A row point to compare with + * @param column A column point to compare with + **/ + compareStart(row: number, column: number): number; + + /** + * Checks the row and column points with the row and column points of the calling range. + * @param row A row point to compare with + * @param column A column point to compare with + **/ + compareEnd(row: number, column: number): number; + + /** + * Checks the row and column points with the row and column points of the calling range. + * @param row A row point to compare with + * @param column A column point to compare with + **/ + compareInside(row: number, column: number): number; + + /** + * Returns the part of the current `Range` that occurs within the boundaries of `firstRow` and `lastRow` as a new `Range` object. + * @param firstRow The starting row + * @param lastRow The ending row + **/ + clipRows(firstRow: number, lastRow: number): Range; + + /** + * Changes the row and column points for the calling range for both the starting and ending points. + * @param row A new row to extend to + * @param column A new column to extend to + **/ + extend(row: number, column: number): Range; + + /** + * Returns `true` if the range spans across multiple lines. + **/ + isMultiLine(): boolean; + + /** + * Returns a duplicate of the calling range. + **/ + clone(): Range; + + /** + * Returns a range containing the starting and ending rows of the original range, but with a column value of `0`. + **/ + collapseRows(): Range; + + /** + * Given the current `Range`, this function converts those starting and ending points into screen positions, and then returns a new `Range` object. + * @param session The `EditSession` to retrieve coordinates from + **/ + toScreenRange(session: IEditSession): Range; + + /** + * Creates and returns a new `Range` based on the row and column of the given parameters. + * @param start A starting point to use + * @param end An ending point to use + **/ + fromPoints(start: Range, end: Range): Range; + + } + /** + * Creates a new `Range` object with the given starting and ending row and column points. + * @param startRow The starting row + * @param startColumn The starting column + * @param endRow The ending row + * @param endColumn The ending column + **/ + var Range: { + fromPoints(pos1: Position, pos2: Position): Range; + new(startRow: number, startColumn: number, endRow: number, endColumn: number): Range; + } + + //////////////// + /// RenderLoop + //////////////// + + export interface RenderLoop { } + var RenderLoop: { + new(): RenderLoop; + } + + //////////////// + /// ScrollBar + //////////////// + + /** + * A set of methods for setting and retrieving the editor's scrollbar. + **/ + export interface ScrollBar { + + /** + * Emitted when the scroll bar, well, scrolls. + * @param e Contains one property, `"data"`, which indicates the current scroll top position + **/ + onScroll(e: any); + + /** + * Returns the width of the scroll bar. + **/ + getWidth(): number; + + /** + * Sets the height of the scroll bar, in pixels. + * @param height The new height + **/ + setHeight(height: number); + + /** + * Sets the inner height of the scroll bar, in pixels. + * @param height The new inner height + **/ + setInnerHeight(height: number); + + /** + * Sets the scroll top of the scroll bar. + * @param scrollTop The new scroll top + **/ + setScrollTop(scrollTop: number); + } + var ScrollBar: { + /** + * Creates a new `ScrollBar`. `parent` is the owner of the scroll bar. + * @param parent A DOM element + **/ + new(parent: HTMLElement): ScrollBar; + } + + //////////////// + /// Search + //////////////// + + /** + * A class designed to handle all sorts of text searches within a [[Document `Document`]]. + **/ + export interface Search { + + /** + * Sets the search options via the `options` parameter. + * @param options An object containing all the new search properties + **/ + set(options: any): Search; + + /** + * [Returns an object containing all the search options.]{: #Search.getOptions} + **/ + getOptions(): any; + + /** + * Sets the search options via the `options` parameter. + * @param An object containing all the search propertie + **/ + setOptions(An: any); + + /** + * Searches for `options.needle`. If found, this method returns the [[Range `Range`]] where the text first occurs. If `options.backwards` is `true`, the search goes backwards in the session. + * @param session The session to search with + **/ + find(session: IEditSession): Range; + + /** + * Searches for all occurances `options.needle`. If found, this method returns an array of [[Range `Range`s]] where the text first occurs. If `options.backwards` is `true`, the search goes backwards in the session. + * @param session The session to search with + **/ + findAll(session: IEditSession): Range[]; + + /** + * Searches for `options.needle` in `input`, and, if found, replaces it with `replacement`. + * @param input The text to search in + * @param replacement The replacing text + * + (String): If `options.regExp` is `true`, this function returns `input` with the replacement already made. Otherwise, this function just returns `replacement`.
+ * If `options.needle` was not found, this function returns `null`. + **/ + replace(input: string, replacement: string): string; + } + var Search: { + /** + * Creates a new `Search` object. The following search options are avaliable: + * - `needle`: The string or regular expression you're looking for + * - `backwards`: Whether to search backwards from where cursor currently is. Defaults to `false`. + * - `wrap`: Whether to wrap the search back to the beginning when it hits the end. Defaults to `false`. + * - `caseSensitive`: Whether the search ought to be case-sensitive. Defaults to `false`. + * - `wholeWord`: Whether the search matches only on whole words. Defaults to `false`. + * - `range`: The [[Range]] to search within. Set this to `null` for the whole document + * - `regExp`: Whether the search is a regular expression or not. Defaults to `false`. + * - `start`: The starting [[Range]] or cursor position to begin the search + * - `skipCurrent`: Whether or not to include the current line in the search. Default to `false`. + **/ + new(): Search; + } + + //////////////// + /// Search + //////////////// + + /** + * Contains the cursor position and the text selection of an edit session. + * The row/columns used in the selection are in document coordinates representing ths coordinates as thez appear in the document before applying soft wrap and folding. + **/ + export interface Selection { + + addEventListener(ev: string, callback: Function); + + moveCursorWordLeft(); + + moveCursorWordRight(); + + fromOrientedRange(range: Range); + + setSelectionRange(match); + + getAllRanges(): Range[]; + + on(event: string, fn: (e) => any); + + addRange(range: Range); + + /** + * Returns `true` if the selection is empty. + **/ + isEmpty(): boolean; + + /** + * Returns `true` if the selection is a multi-line. + **/ + isMultiLine(): boolean; + + /** + * Gets the current position of the cursor. + **/ + getCursor(): Position; + + /** + * Sets the row and column position of the anchor. This function also emits the `'changeSelection'` event. + * @param row The new row + * @param column The new column + **/ + setSelectionAnchor(row: number, column: number); + + /** + * Returns an object containing the `row` and `column` of the calling selection anchor. + **/ + getSelectionAnchor(): any; + + /** + * Returns an object containing the `row` and `column` of the calling selection lead. + **/ + getSelectionLead(): any; + + /** + * Shifts the selection up (or down, if [[Selection.isBackwards `isBackwards()`]] is true) the given number of columns. + * @param columns The number of columns to shift by + **/ + shiftSelection(columns: number); + + /** + * Returns `true` if the selection is going backwards in the document. + **/ + isBackwards(): boolean; + + /** + * [Returns the [[Range]] for the selected text.]{: #Selection.getRange} + **/ + getRange(): Range; + + /** + * [Empties the selection (by de-selecting it). This function also emits the `'changeSelection'` event.]{: #Selection.clearSelection} + **/ + clearSelection(); + + /** + * Selects all the text in the document. + **/ + selectAll(); + + /** + * Sets the selection to the provided range. + * @param range The range of text to select + * @param reverse Indicates if the range should go backwards (`true`) or not + **/ + setRange(range: Range, reverse: boolean); + + /** + * Moves the selection cursor to the indicated row and column. + * @param row The row to select to + * @param column The column to select to + **/ + selectTo(row: number, column: number); + + /** + * Moves the selection cursor to the row and column indicated by `pos`. + * @param pos An object containing the row and column + **/ + selectToPosition(pos: any); + + /** + * Moves the selection up one row. + **/ + selectUp(); + + /** + * Moves the selection down one row. + **/ + selectDown(); + + /** + * Moves the selection right one column. + **/ + selectRight(); + + /** + * Moves the selection left one column. + **/ + selectLeft(); + + /** + * Moves the selection to the beginning of the current line. + **/ + selectLineStart(); + + /** + * Moves the selection to the end of the current line. + **/ + selectLineEnd(); + + /** + * Moves the selection to the end of the file. + **/ + selectFileEnd(); + + /** + * Moves the selection to the start of the file. + **/ + selectFileStart(); + + /** + * Moves the selection to the first word on the right. + **/ + selectWordRight(); + + /** + * Moves the selection to the first word on the left. + **/ + selectWordLeft(); + + /** + * Moves the selection to highlight the entire word. + **/ + getWordRange(); + + /** + * Selects an entire word boundary. + **/ + selectWord(); + + /** + * Selects a word, including its right whitespace. + **/ + selectAWord(); + + /** + * Selects the entire line. + **/ + selectLine(); + + /** + * Moves the cursor up one row. + **/ + moveCursorUp(); + + /** + * Moves the cursor down one row. + **/ + moveCursorDown(); + + /** + * Moves the cursor left one column. + **/ + moveCursorLeft(); + + /** + * Moves the cursor right one column. + **/ + moveCursorRight(); + + /** + * Moves the cursor to the start of the line. + **/ + moveCursorLineStart(); + + /** + * Moves the cursor to the end of the line. + **/ + moveCursorLineEnd(); + + /** + * Moves the cursor to the end of the file. + **/ + moveCursorFileEnd(); + + /** + * Moves the cursor to the start of the file. + **/ + moveCursorFileStart(); + + /** + * Moves the cursor to the word on the right. + **/ + moveCursorLongWordRight(); + + /** + * Moves the cursor to the word on the left. + **/ + moveCursorLongWordLeft(); + + /** + * Moves the cursor to position indicated by the parameters. Negative numbers move the cursor backwards in the document. + * @param rows The number of rows to move by + * @param chars The number of characters to move by + **/ + moveCursorBy(rows: number, chars: number); + + /** + * Moves the selection to the position indicated by its `row` and `column`. + * @param position The position to move to + **/ + moveCursorToPosition(position: any); + + /** + * Moves the cursor to the row and column provided. [If `preventUpdateDesiredColumn` is `true`, then the cursor stays in the same column position as its original point.]{: #preventUpdateBoolDesc} + * @param row The row to move to + * @param column The column to move to + * @param keepDesiredColumn [If `true`, the cursor move does not respect the previous column]{: #preventUpdateBool} + **/ + moveCursorTo(row: number, column: number, keepDesiredColumn?: boolean); + + /** + * Moves the cursor to the screen position indicated by row and column. {:preventUpdateBoolDesc} + * @param row The row to move to + * @param column The column to move to + * @param keepDesiredColumn {:preventUpdateBool} + **/ + moveCursorToScreen(row: number, column: number, keepDesiredColumn: boolean); + } + var Selection: { + /** + * Creates a new `Selection` object. + * @param session The session to use + **/ + new(session: IEditSession): Selection; + } + + //////////////// + /// Split + //////////////// + + export interface Split { + + /** + * Returns the number of splits. + **/ + getSplits(): number; + + /** + * Returns the editor identified by the index `idx`. + * @param idx The index of the editor you want + **/ + getEditor(idx: number); + + /** + * Returns the current editor. + **/ + getCurrentEditor(): Editor; + + /** + * Focuses the current editor. + **/ + focus(); + + /** + * Blurs the current editor. + **/ + blur(); + + /** + * Sets a theme for each of the available editors. + * @param theme The name of the theme to set + **/ + setTheme(theme: string); + + /** + * Sets the keyboard handler for the editor. + * @param keybinding + **/ + setKeyboardHandler(keybinding: string); + + /** + * Executes `callback` on all of the available editors. + * @param callback A callback function to execute + * @param scope The default scope for the callback + **/ + forEach(callback: Function, scope: string); + + /** + * Sets the font size, in pixels, for all the available editors. + * @param size The new font size + **/ + setFontSize(size: number); + + /** + * Sets a new [[EditSession `EditSession`]] for the indicated editor. + * @param session The new edit session + * @param idx The editor's index you're interested in + **/ + setSession(session: IEditSession, idx: number); + + /** + * Returns the orientation. + **/ + getOrientation(): number; + + /** + * Sets the orientation. + * @param orientation The new orientation value + **/ + setOrientation(orientation: number); + + /** + * Resizes the editor. + **/ + resize(); + } + var Split: { + new(): Split; + } + + ////////////////// + /// TokenIterator + ////////////////// + + /** + * This class provides an essay way to treat the document as a stream of tokens, and provides methods to iterate over these tokens. + **/ + export interface TokenIterator { + + /** + * Tokenizes all the items from the current point to the row prior in the document. + **/ + stepBackward(): string[]; + + /** + * Tokenizes all the items from the current point until the next row in the document. If the current point is at the end of the file, this function returns `null`. Otherwise, it returns the tokenized string. + **/ + stepForward(): string; + + /** + * Returns the current tokenized string. + **/ + getCurrentToken(): TokenInfo; + + /** + * Returns the current row. + **/ + getCurrentTokenRow(): number; + + /** + * Returns the current column. + **/ + getCurrentTokenColumn(): number; + } + var TokenIterator: { + /** + * Creates a new token iterator object. The inital token index is set to the provided row and column coordinates. + * @param session The session to associate with + * @param initialRow The row to start the tokenizing at + * @param initialColumn The column to start the tokenizing at + **/ + new(session: IEditSession, initialRow: number, initialColumn: number): TokenIterator; + } + + ////////////////// + /// Tokenizer + ////////////////// + + + /** + * This class takes a set of highlighting rules, and creates a tokenizer out of them. For more information, see [the wiki on extending highlighters](https://github.com/ajaxorg/ace/wiki/Creating-or-Extending-an-Edit-Mode#wiki-extendingTheHighlighter). + **/ + export interface Tokenizer { + + /** + * Returns an object containing two properties: `tokens`, which contains all the tokens; and `state`, the current state. + **/ + getLineTokens(): any; + } + var Tokenizer: { + /** + * Constructs a new tokenizer based on the given rules and flags. + * @param rules The highlighting rules + * @param flag Any additional regular expression flags to pass (like "i" for case insensitive) + **/ + new(rules: any, flag: string): Tokenizer; + } + + ////////////////// + /// UndoManager + ////////////////// + + /** + * This object maintains the undo stack for an [[EditSession `EditSession`]]. + **/ + export interface UndoManager { + + /** + * Provides a means for implementing your own undo manager. `options` has one property, `args`, an [[Array `Array`]], with two elements: + * - `args[0]` is an array of deltas + * - `args[1]` is the document to associate with + * @param options Contains additional properties + **/ + execute(options: any); + + /** + * [Perform an undo operation on the document, reverting the last change.]{: #UndoManager.undo} + * @param dontSelect {:dontSelect} + **/ + undo(dontSelect?: boolean): Range; + + /** + * [Perform a redo operation on the document, reimplementing the last change.]{: #UndoManager.redo} + * @param dontSelect {:dontSelect} + **/ + redo(dontSelect: boolean); + + /** + * Destroys the stack of undo and redo redo operations. + **/ + reset(); + + /** + * Returns `true` if there are undo operations left to perform. + **/ + hasUndo(): boolean; + + /** + * Returns `true` if there are redo operations left to perform. + **/ + hasRedo(): boolean; + + } + var UndoManager: { + /** + * Resets the current undo state and creates a new `UndoManager`. + **/ + new(): UndoManager; + } + + //////////////////// + /// VirtualRenderer + //////////////////// + + /** + * The class that is responsible for drawing everything you see on the screen! + **/ + export interface VirtualRenderer { + + scroller: any; + + characterWidth: number; + + lineHeight: number; + + screenToTextCoordinates(left: number, top: number); + + /** + * Associates the renderer with an [[EditSession `EditSession`]]. + **/ + setSession(session: IEditSession); + + /** + * Triggers a partial update of the text, from the range given by the two parameters. + * @param firstRow The first row to update + * @param lastRow The last row to update + **/ + updateLines(firstRow: number, lastRow: number); + + /** + * Triggers a full update of the text, for all the rows. + **/ + updateText(); + + /** + * Triggers a full update of all the layers, for all the rows. + * @param force If `true`, forces the changes through + **/ + updateFull(force: boolean); + + /** + * Updates the font size. + **/ + updateFontSize(); + + /** + * [Triggers a resize of the editor.]{: #VirtualRenderer.onResize} + * @param force If `true`, recomputes the size, even if the height and width haven't changed + * @param gutterWidth The width of the gutter in pixels + * @param width The width of the editor in pixels + * @param height The hiehgt of the editor, in pixels + **/ + onResize(force: boolean, gutterWidth: number, width: number, height: number); + + /** + * Adjusts the wrap limit, which is the number of characters that can fit within the width of the edit area on screen. + **/ + adjustWrapLimit(); + + /** + * Identifies whether you want to have an animated scroll or not. + * @param shouldAnimate Set to `true` to show animated scrolls + **/ + setAnimatedScroll(shouldAnimate: boolean); + + /** + * Returns whether an animated scroll happens or not. + **/ + getAnimatedScroll(): boolean; + + /** + * Identifies whether you want to show invisible characters or not. + * @param showInvisibles Set to `true` to show invisibles + **/ + setShowInvisibles(showInvisibles: boolean); + + /** + * Returns whether invisible characters are being shown or not. + **/ + getShowInvisibles(): boolean; + + /** + * Identifies whether you want to show the print margin or not. + * @param showPrintMargin Set to `true` to show the print margin + **/ + setShowPrintMargin(showPrintMargin: boolean); + + /** + * Returns whether the print margin is being shown or not. + **/ + getShowPrintMargin(): boolean; + + /** + * Identifies whether you want to show the print margin column or not. + * @param showPrintMargin Set to `true` to show the print margin column + **/ + setPrintMarginColumn(showPrintMargin: boolean); + + /** + * Returns whether the print margin column is being shown or not. + **/ + getPrintMarginColumn(): boolean; + + /** + * Returns `true` if the gutter is being shown. + **/ + getShowGutter(): boolean; + + /** + * Identifies whether you want to show the gutter or not. + * @param show Set to `true` to show the gutter + **/ + setShowGutter(show: boolean); + + /** + * Returns the root element containing this renderer. + **/ + getContainerElement(): HTMLElement; + + /** + * Returns the element that the mouse events are attached to + **/ + getMouseEventTarget(): HTMLElement; + + /** + * Returns the element to which the hidden text area is added. + **/ + getTextAreaContainer(): HTMLElement; + + /** + * [Returns the index of the first visible row.]{: #VirtualRenderer.getFirstVisibleRow} + **/ + getFirstVisibleRow(): number; + + /** + * Returns the index of the first fully visible row. "Fully" here means that the characters in the row are not truncated; that the top and the bottom of the row are on the screen. + **/ + getFirstFullyVisibleRow(): number; + + /** + * Returns the index of the last fully visible row. "Fully" here means that the characters in the row are not truncated; that the top and the bottom of the row are on the screen. + **/ + getLastFullyVisibleRow(): number; + + /** + * [Returns the index of the last visible row.]{: #VirtualRenderer.getLastVisibleRow} + **/ + getLastVisibleRow(): number; + + /** + * Sets the padding for all the layers. + * @param padding A new padding value (in pixels) + **/ + setPadding(padding: number); + + /** + * Returns whether the horizontal scrollbar is set to be always visible. + **/ + getHScrollBarAlwaysVisible(): boolean; + + /** + * Identifies whether you want to show the horizontal scrollbar or not. + * @param alwaysVisible Set to `true` to make the horizontal scroll bar visible + **/ + setHScrollBarAlwaysVisible(alwaysVisible: boolean); + + /** + * Schedules an update to all the front markers in the document. + **/ + updateFrontMarkers(); + + /** + * Schedules an update to all the back markers in the document. + **/ + updateBackMarkers(); + + /** + * Deprecated; (moved to [[EditSession]]) + **/ + addGutterDecoration(); + + /** + * Deprecated; (moved to [[EditSession]]) + **/ + removeGutterDecoration(); + + /** + * Redraw breakpoints. + **/ + updateBreakpoints(); + + /** + * Sets annotations for the gutter. + * @param annotations An array containing annotations + **/ + setAnnotations(annotations: any[]); + + /** + * Updates the cursor icon. + **/ + updateCursor(); + + /** + * Hides the cursor icon. + **/ + hideCursor(); + + /** + * Shows the cursor icon. + **/ + showCursor(); + + /** + * Scrolls the cursor into the first visibile area of the editor + **/ + scrollCursorIntoView(); + + /** + * {:EditSession.getScrollTop} + **/ + getScrollTop(): number; + + /** + * {:EditSession.getScrollLeft} + **/ + getScrollLeft(): number; + + /** + * Returns the first visible row, regardless of whether it's fully visible or not. + **/ + getScrollTopRow(): number; + + /** + * Returns the last visible row, regardless of whether it's fully visible or not. + **/ + getScrollBottomRow(): number; + + /** + * Gracefully scrolls from the top of the editor to the row indicated. + * @param row A row id + **/ + scrollToRow(row: number); + + /** + * Gracefully scrolls the editor to the row indicated. + * @param line A line number + * @param center If `true`, centers the editor the to indicated line + * @param animate If `true` animates scrolling + * @param callback Function to be called after the animation has finished + **/ + scrollToLine(line: number, center: boolean, animate: boolean, callback: Function); + + /** + * Scrolls the editor to the y pixel indicated. + * @param scrollTop The position to scroll to + **/ + scrollToY(scrollTop: number): number; + + /** + * Scrolls the editor across the x-axis to the pixel indicated. + * @param scrollLeft The position to scroll to + **/ + scrollToX(scrollLeft: number): number; + + /** + * Scrolls the editor across both x- and y-axes. + * @param deltaX The x value to scroll by + * @param deltaY The y value to scroll by + **/ + scrollBy(deltaX: number, deltaY: number); + + /** + * Returns `true` if you can still scroll by either parameter; in other words, you haven't reached the end of the file or line. + * @param deltaX The x value to scroll by + * @param deltaY The y value to scroll by + **/ + isScrollableBy(deltaX: number, deltaY: number): boolean; + + /** + * Returns an object containing the `pageX` and `pageY` coordinates of the document position. + * @param row The document row position + * @param column The document column position + **/ + textToScreenCoordinates(row: number, column: number): any; + + /** + * Focuses the current container. + **/ + visualizeFocus(); + + /** + * Blurs the current container. + **/ + visualizeBlur(); + + /** + * undefined + * @param position + **/ + showComposition(position: number); + + /** + * Sets the inner text of the current composition to `text`. + * @param text A string of text to use + **/ + setCompositionText(text: string); + + /** + * Hides the current composition. + **/ + hideComposition(); + + /** + * [Sets a new theme for the editor. `theme` should exist, and be a directory path, like `ace/theme/textmate`.]{: #VirtualRenderer.setTheme} + * @param theme The path to a theme + **/ + setTheme(theme: string); + + /** + * [Returns the path of the current theme.]{: #VirtualRenderer.getTheme} + **/ + getTheme(): string; + + /** + * [Adds a new class, `style`, to the editor.]{: #VirtualRenderer.setStyle} + * @param style A class name + **/ + setStyle(style: string); + + /** + * [Removes the class `style` from the editor.]{: #VirtualRenderer.unsetStyle} + * @param style A class name + **/ + unsetStyle(style: string); + + /** + * Destroys the text and cursor layers for this renderer. + **/ + destroy(); + + } + var VirtualRenderer: { + /** + * Constructs a new `VirtualRenderer` within the `container` specified, applying the given `theme`. + * @param container The root element of the editor + * @param theme The starting theme + **/ + new(container: HTMLElement, theme?: string): VirtualRenderer; + } +} + +declare var ace: AceAjax.Ace; diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/ace.d.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/ace/ace.d.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/ace.d.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/all-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/ace/all-tests.ts new file mode 100644 index 00000000..80717ac5 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/all-tests.ts @@ -0,0 +1,26 @@ +/// + +var exports: any; +var assert: any; +var MockRenderer = null; +var JavaScriptMode = null; + +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// + + + diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/all-tests.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/ace/all-tests.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/all-tests.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-anchor-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-anchor-tests.ts new file mode 100644 index 00000000..08ca8f43 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-anchor-tests.ts @@ -0,0 +1,132 @@ +/// + +var assert: any; +var exports = { + + "test create anchor" : function() { + var doc = new AceAjax.Document("juhu"); + var anchor = new AceAjax.Anchor(doc, 0, 0); + + assert.position(anchor.getPosition(), 0, 0); + assert.equal(anchor.getDocument(), doc); + }, + + "test insert text in same row before cursor should move anchor column": function() { + var doc = new AceAjax.Document("juhu\nkinners"); + var anchor = new AceAjax.Anchor(doc, 1, 4); + + doc.insert({row: 1, column: 1}, "123"); + assert.position(anchor.getPosition(), 1, 7); + }, + + "test insert lines before cursor should move anchor row": function() { + var doc = new AceAjax.Document("juhu\nkinners"); + var anchor = new AceAjax.Anchor(doc, 1, 4); + + doc.insertLines(1, ["123", "456"]); + assert.position(anchor.getPosition(), 3, 4); + }, + + "test insert new line before cursor should move anchor column": function() { + var doc = new AceAjax.Document("juhu\nkinners"); + var anchor = new AceAjax.Anchor(doc, 1, 4); + + doc.insertNewLine({row: 0, column: 0}); + assert.position(anchor.getPosition(), 2, 4); + }, + + "test insert new line in anchor line before anchor should move anchor column and row": function() { + var doc = new AceAjax.Document("juhu\nkinners"); + var anchor = new AceAjax.Anchor(doc, 1, 4); + + doc.insertNewLine({row: 1, column: 2}); + assert.position(anchor.getPosition(), 2, 2); + }, + + "test delete text in anchor line before anchor should move anchor column": function() { + var doc = new AceAjax.Document("juhu\nkinners"); + var anchor = new AceAjax.Anchor(doc, 1, 4); + + doc.remove(new AceAjax.Range(1, 1, 1, 3)); + assert.position(anchor.getPosition(), 1, 2); + }, + + "test remove range which contains the anchor should move the anchor to the start of the range": function() { + var doc = new AceAjax.Document("juhu\nkinners"); + var anchor = new AceAjax.Anchor(doc, 0, 3); + + doc.remove(new AceAjax.Range(0, 1, 1, 3)); + assert.position(anchor.getPosition(), 0, 1); + }, + + "test delete character before the anchor should have no effect": function() { + var doc = new AceAjax.Document("juhu\nkinners"); + var anchor = new AceAjax.Anchor(doc, 1, 4); + + doc.remove(new AceAjax.Range(1, 4, 1, 5)); + assert.position(anchor.getPosition(), 1, 4); + }, + + "test delete lines in anchor line before anchor should move anchor row": function() { + var doc = new AceAjax.Document("juhu\n1\n2\nkinners"); + var anchor = new AceAjax.Anchor(doc, 3, 4); + + doc.removeLines(1, 2); + assert.position(anchor.getPosition(), 1, 4); + }, + + "test remove new line before the cursor": function() { + var doc = new AceAjax.Document("juhu\nkinners"); + var anchor = new AceAjax.Anchor(doc, 1, 4); + + doc.removeNewLine(0); + assert.position(anchor.getPosition(), 0, 8); + }, + + "test delete range which contains the anchor should move anchor to the end of the range": function() { + var doc = new AceAjax.Document("juhu\nkinners"); + var anchor = new AceAjax.Anchor(doc, 1, 4); + + doc.remove(new AceAjax.Range(0, 2, 1, 2)); + assert.position(anchor.getPosition(), 0, 4); + }, + + "test delete line which contains the anchor should move anchor to the end of the range": function() { + var doc = new AceAjax.Document("juhu\nkinners\n123"); + var anchor = new AceAjax.Anchor(doc, 1, 5); + + doc.removeLines(1, 1); + assert.position(anchor.getPosition(), 1, 0); + }, + + "test remove after the anchor should have no effect": function() { + var doc = new AceAjax.Document("juhu\nkinners\n123"); + var anchor = new AceAjax.Anchor(doc, 1, 2); + + doc.remove(new AceAjax.Range(1, 4, 2, 2)); + assert.position(anchor.getPosition(), 1, 2); + }, + + "test anchor changes triggered by document changes should emit change event": function(next) { + var doc = new AceAjax.Document("juhu\nkinners\n123"); + var anchor = new AceAjax.Anchor(doc, 1, 5); + + anchor.on("change", function(e) { + assert.position(anchor.getPosition(), 0, 0); + next(); + }); + + doc.remove(new AceAjax.Range(0, 0, 2, 1)); + }, + + "test only fire change event if position changes": function() { + var doc = new AceAjax.Document("juhu\nkinners\n123"); + var anchor = new AceAjax.Anchor(doc, 1, 5); + + anchor.on("change", function(e) { + assert.fail(); + }); + + doc.remove(new AceAjax.Range(2, 0, 2, 1)); + } +}; diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-anchor-tests.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-anchor-tests.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-anchor-tests.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-background_tokenizer-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-background_tokenizer-tests.ts new file mode 100644 index 00000000..8f54bae5 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-background_tokenizer-tests.ts @@ -0,0 +1,41 @@ +/// + +var assert: any; + +function forceTokenize(session) { + for (var i = 0, l = session.getLength(); i < l; i++) + session.getTokens(i) +} + +function testStates(session, states) { + for (var i = 0, l = session.getLength(); i < l; i++) + assert.equal(session.bgTokenizer.states[i], states[i]) + assert.ok(l == states.length) +} + +var exports = { + + "test background tokenizer update on session change": function() { + var doc = new AceAjax.EditSession([ + "/*", + "*/", + "var juhu" + ]); + doc.setMode("./mode/javascript") + + forceTokenize(doc) + testStates(doc, ["comment", "start", "start"]) + + doc.remove(new AceAjax.Range(0, 2, 1, 2)) + testStates(doc, [null, "start"]) + + forceTokenize(doc) + testStates(doc, ["comment", "comment"]) + + doc.insert({ row: 0, column: 2 }, "\n*/") + testStates(doc, [undefined, undefined, "comment"]) + + forceTokenize(doc) + testStates(doc, ["comment", "start", "start"]) + } +}; diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-background_tokenizer-tests.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-background_tokenizer-tests.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-background_tokenizer-tests.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-default-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-default-tests.ts new file mode 100644 index 00000000..f8a280c1 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-default-tests.ts @@ -0,0 +1,451 @@ +/// + +var assert: any; +var editor = ace.edit("editor"); +editor.setTheme("ace/theme/monokai"); +editor.getSession().setMode("ace/mode/javascript"); + +editor.setTheme("ace/theme/twilight"); + +editor.getSession().setMode("ace/mode/javascript"); + +editor.setValue("the new text here"); // or session.setValue +editor.getValue(); // or session.getValue + +editor.session.getTextRange(editor.getSelectionRange()); + +editor.insert("Something cool"); + +editor.selection.getCursor(); + +editor.gotoLine(123); + +editor.session.getLength(); + +editor.getSession().setTabSize(4); + +editor.getSession().setUseSoftTabs(true); + +document.getElementById('editor').style.fontSize = '12px'; + +editor.getSession().setUseWrapMode(true); + +editor.setHighlightActiveLine(false); + +editor.setShowPrintMargin(false); + +editor.setReadOnly(true); // false to make it editable + +editor.resize() + +editor.find('needle', { + backwards: false, + wrap: false, + caseSensitive: false, + wholeWord: false, + regExp: false +}); +editor.findNext(); +editor.findPrevious(); + +editor.find('foo'); +editor.replace('bar'); + +editor.replaceAll('bar'); + +editor.getSession().on('change', function (e) { +// e.type, etc +}); + +editor.getSession().selection.on('changeSelection', function (e) { +}); + +editor.getSession().selection.on('changeCursor', function (e) { +}); + +editor.commands.addCommand({ +name: 'myCommand', +bindKey: { win: 'Ctrl-M', mac: 'Command-M' }, +exec: function (editor) { +//... +}, +readOnly: true // false if this command should not apply in readOnly mode +}); + +editor.moveCursorTo(1, 1); +editor.removeLines(); + +editor.removeLines(); + +editor.removeLines(); + +editor.removeLines(); + +editor.moveCursorTo(1, 1); +editor.getSelection().selectDown(); + +editor.removeLines(); + +editor.removeLines(); + +editor.moveCursorTo(3, 0); + +editor.removeLines(); + +editor.removeLines(); + +editor.moveCursorTo(1, 3); +editor.getSelection().selectDown(); + +editor.indent(); + +var range = editor.getSelectionRange(); + +editor.moveCursorTo(1, 0); +editor.getSelection().selectDown(); + +editor.indent(); + +editor.moveCursorTo(0, 0); +editor.onTextInput("\n"); + +editor.moveCursorTo(0, 5); +editor.getSelection().selectDown(); +editor.getSelection().selectDown(); + +editor.blockOutdent(); + +editor.moveCursorTo(1, 1); +editor.removeLines(); + +var session = new AceAjax.EditSession(["a", "b", "c", "d"].join("\n")); + +assert.equal(session.toString(), "a\nc\nd"); +assert.position(editor.getCursorPosition(), 1, 0); + +editor.removeLines(); + +assert.equal(session.toString(), "a\nd"); +assert.position(editor.getCursorPosition(), 1, 0); + +editor.removeLines(); + +assert.equal(session.toString(), "a"); +assert.position(editor.getCursorPosition(), 0, 1); + +editor.removeLines(); + +assert.equal(session.toString(), ""); +assert.position(editor.getCursorPosition(), 0, 0); + +editor.moveCursorTo(1, 1); +editor.getSelection().selectDown(); + +editor.removeLines(); +assert.equal(session.toString(), "a\nd"); +assert.position(editor.getCursorPosition(), 1, 0); + + +editor.removeLines(); + +assert.equal(session.toString(), "b\nc"); +assert.position(editor.getCursorPosition(), 0, 0); + + +editor.moveCursorTo(3, 0); + +editor.removeLines(); +assert.equal(session.toString(), "a\nb\nc"); +assert.position(editor.getCursorPosition(), 2, 1); + +editor.removeLines(); +assert.equal(session.toString(), "a\nb"); +assert.position(editor.getCursorPosition(), 1, 1); + + +editor.moveCursorTo(1, 3); +editor.getSelection().selectDown(); + +editor.indent(); + +assert.equal(["a12345", " b12345", " c12345"].join("\n"), session.toString()); + +assert.position(editor.getCursorPosition(), 2, 7); + +range = editor.getSelectionRange(); +assert.position(range.start, 1, 7); +assert.position(range.end, 2, 7); + + +editor.moveCursorTo(1, 0); +editor.getSelection().selectDown(); + +editor.indent(); +assert.equal(["a12345", " b12345", "c12345"].join("\n"), session.toString()); + + +editor.moveCursorTo(0, 0); +editor.onTextInput("\n"); +assert.equal(["", "{"].join("\n"), session.toString()); + + +editor.moveCursorTo(0, 5); +editor.getSelection().selectDown(); +editor.getSelection().selectDown(); + +editor.blockOutdent(); +assert.equal(session.toString(), [" a12345", "b12345", " c12345"].join("\n")); + +assert.position(editor.getCursorPosition(), 2, 1); + +range = editor.getSelectionRange(); +assert.position(range.start, 0, 1); +assert.position(range.end, 2, 1); + +editor.blockOutdent(); +assert.equal(session.toString(), ["a12345", "b12345", "c12345"].join("\n")); + +range = editor.getSelectionRange(); +assert.position(range.start, 0, 0); +assert.position(range.end, 2, 0); + + +editor.moveCursorTo(0, 3); +editor.blockOutdent(" "); + +assert.equal(session.toString(), " 12"); +assert.position(editor.getCursorPosition(), 0, 0); + + +editor.moveCursorTo(0, 2); +editor.getSelection().selectDown(); +editor.toggleCommentLines(); + +assert.equal(["// abc", "//cde"].join("\n"), session.toString()); + +var selection = editor.getSelectionRange(); +assert.position(selection.start, 0, 4); +assert.position(selection.end, 1, 4); + + +editor.moveCursorTo(0, 1); +editor.getSelection().selectDown(); +editor.getSelection().selectRight(); +editor.getSelection().selectRight(); + +editor.toggleCommentLines(); + +assert.equal([" abc", "cde"].join("\n"), session.toString()); +assert.range(editor.getSelectionRange(), 0, 0, 1, 1); + + +editor.moveCursorTo(0, 0); +editor.getSelection().selectDown(); +editor.getSelection().selectDown(); + +editor.toggleCommentLines(); +editor.toggleCommentLines(); + +assert.equal([" abc", "cde", "fg"].join("\n"), session.toString()); + + +editor.moveCursorTo(0, 0); +editor.getSelection().selectDown(); + +editor.toggleCommentLines(); +assert.range(editor.getSelectionRange(), 0, 2, 1, 0); + + + +editor.moveCursorTo(1, 0); +editor.getSelection().selectUp(); + +editor.toggleCommentLines(); +assert.range(editor.getSelectionRange(), 0, 2, 1, 0); + + +editor.moveCursorTo(0, 1); +editor.getSelection().selectDown(); + +editor.moveLinesDown(); +assert.equal(["33", "11", "22", "44"].join("\n"), session.toString()); +assert.position(editor.getCursorPosition(), 1, 0); +assert.position(editor.getSelection().getSelectionAnchor(), 3, 0); +assert.position(editor.getSelection().getSelectionLead(), 1, 0); + +editor.moveLinesDown(); +assert.equal(["33", "44", "11", "22"].join("\n"), session.toString()); +assert.position(editor.getCursorPosition(), 2, 0); +assert.position(editor.getSelection().getSelectionAnchor(), 3, 2); +assert.position(editor.getSelection().getSelectionLead(), 2, 0); + +// moving again should have no effect +editor.moveLinesDown(); +assert.equal(["33", "44", "11", "22"].join("\n"), session.toString()); +assert.position(editor.getCursorPosition(), 2, 0); +assert.position(editor.getSelection().getSelectionAnchor(), 3, 2); +assert.position(editor.getSelection().getSelectionLead(), 2, 0); + + +editor.moveCursorTo(2, 1); +editor.getSelection().selectDown(); + +editor.moveLinesUp(); +assert.equal(session.toString(), ["11", "33", "44", "22"].join("\n")); +assert.position(editor.getCursorPosition(), 1, 0); +assert.position(editor.getSelection().getSelectionAnchor(), 3, 0); +assert.position(editor.getSelection().getSelectionLead(), 1, 0); + +editor.moveLinesUp(); +assert.equal(session.toString(), ["33", "44", "11", "22"].join("\n")); +assert.position(editor.getCursorPosition(), 0, 0); +assert.position(editor.getSelection().getSelectionAnchor(), 2, 0); +assert.position(editor.getSelection().getSelectionLead(), 0, 0); + + +editor.moveCursorTo(1, 1); +editor.clearSelection(); + +editor.moveLinesDown(); +assert.equal(["11", "33", "22", "44"].join("\n"), session.toString()); +assert.position(editor.getCursorPosition(), 2, 1); + +editor.clearSelection(); + +editor.moveLinesUp(); +assert.equal(["11", "22", "33", "44"].join("\n"), session.toString()); +assert.position(editor.getCursorPosition(), 1, 1); + + +editor.moveCursorTo(1, 1); +editor.getSelection().selectDown(); + +editor.copyLinesDown(); +assert.equal(["11", "22", "33", "22", "33", "44"].join("\n"), session.toString()); + +assert.position(editor.getCursorPosition(), 3, 0); +assert.position(editor.getSelection().getSelectionAnchor(), 5, 0); +assert.position(editor.getSelection().getSelectionLead(), 3, 0); + + +editor.moveCursorTo(1, 1); +editor.getSelection().selectDown(); + +editor.copyLinesUp(); +assert.equal(["11", "22", "33", "22", "33", "44"].join("\n"), session.toString()); + +assert.position(editor.getCursorPosition(), 1, 0); +assert.position(editor.getSelection().getSelectionAnchor(), 3, 0); +assert.position(editor.getSelection().getSelectionLead(), 1, 0); + + +session.setTabSize(2); +session.setUseSoftTabs(true); + +editor.onTextInput("\t"); +assert.equal(session.toString(), " "); + +session.setTabSize(5); +editor.onTextInput("\t"); +assert.equal(session.toString(), " "); + + +session.setUseSoftTabs(false); + +editor.onTextInput("\t"); +assert.equal(session.toString(), "\t"); + +editor.removeLines(); +var step1 = session.toString(); +assert.equal(step1, "222\n333"); + +editor.removeLines(); +var step2 = session.toString(); +assert.equal(step2, "333"); + +editor.removeLines(); +var step3 = session.toString(); +assert.equal(step3, ""); + +var undoManager = new AceAjax.UndoManager(); + +undoManager.undo(); +assert.equal(session.toString(), step2); + +undoManager.undo(); +assert.equal(session.toString(), step1); + +undoManager.undo(); +assert.equal(session.toString(), ""); + +undoManager.undo(); +assert.equal(session.toString(), ""); + +editor.moveCursorTo(1, 1); +editor.remove("left"); +assert.equal(session.toString(), "123\n56"); + +editor.moveCursorTo(1, 0); +editor.remove("left"); +assert.equal(session.toString(), "123456"); + +session.setUseSoftTabs(true); +session.setTabSize(4); + +editor.moveCursorTo(1, 8); +editor.remove("left"); +assert.equal(session.toString(), "123\n 456"); + +editor.moveCursorTo(1, 0); +editor.transposeLetters(); + +assert.equal(session.getValue(), ["123", "4567", "89"].join("\n")); + +editor.moveCursorTo(1, 2); +editor.transposeLetters(); + +assert.equal(session.getValue(), ["123", "4657", "89"].join("\n")); + +editor.moveCursorTo(1, 4); +editor.transposeLetters(); + +assert.equal(session.getValue(), ["123", "4576", "89"].join("\n")); + +editor.moveCursorTo(1, 1); +editor.getSelection().selectRight(); +editor.transposeLetters(); + +assert.equal(session.getValue(), ["123", "4567", "89"].join("\n")); + +editor.moveCursorTo(1, 2); +editor.transposeLetters(); +assert.position(editor.getCursorPosition(), 1, 3); + +editor.moveCursorTo(1, 2); +editor.removeToLineEnd(); +assert.equal(session.getValue(), ["123", "45", "89"].join("\n")); + +editor.moveCursorTo(1, 4); +editor.removeToLineEnd(); +assert.position(editor.getCursorPosition(), 1, 4); +assert.equal(session.getValue(), ["123", "456789"].join("\n")); + +editor.moveCursorTo(1, 0); +editor.getSelection().selectLineEnd(); +editor.toUpperCase() +assert.equal(session.getValue(), ["ajax", "DOT", "org"].join("\n")); + +editor.moveCursorTo(1, 0); +editor.toUpperCase() +assert.equal(session.getValue(), ["ajax", "DOT", "org"].join("\n")); +assert.position(editor.getCursorPosition(), 1, 0); + +editor.moveCursorTo(1, 0); +editor.getSelection().selectLineEnd(); +editor.toLowerCase() +assert.equal(session.getValue(), ["AJAX", "dot", "ORG"].join("\n")); + +editor.moveCursorTo(1, 0); +editor.toLowerCase() +assert.equal(session.getValue(), ["AJAX", "dot", "ORG"].join("\n")); +assert.position(editor.getCursorPosition(), 1, 0); diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-default-tests.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-default-tests.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-default-tests.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-document-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-document-tests.ts new file mode 100644 index 00000000..7fc342f7 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-document-tests.ts @@ -0,0 +1,255 @@ +/// + +var assert: any; +var exports = { + "test: insert text in line": function() { + var doc = new AceAjax.Document(["12", "34"]); + + var deltas = []; + doc.on("change", function (e) { deltas.push(e.data); }); + + doc.insert({ row: 0, column: 1 }, "juhu"); + assert.equal(doc.getValue(), ["1juhu2", "34"].join("\n")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["12", "34"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["1juhu2", "34"].join("\n")); + } , + + "test: insert new line": function() { + var doc = new AceAjax.Document(["12", "34"]); + + var deltas = []; + doc.on("change", function (e) { deltas.push(e.data); }); + + doc.insertNewLine({ row: 0, column: 1 }); + assert.equal(doc.getValue(), ["1", "2", "34"].join("\n")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["12", "34"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["1", "2", "34"].join("\n")); + } , + + "test: insert lines at the beginning": function() { + var doc = new AceAjax.Document(["12", "34"]); + + var deltas = []; + doc.on("change", function (e) { deltas.push(e.data); }); + + doc.insertLines(0, ["aa", "bb"]); + assert.equal(doc.getValue(), ["aa", "bb", "12", "34"].join("\n")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["12", "34"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["aa", "bb", "12", "34"].join("\n")); + } , + + "test: insert lines at the end": function() { + var doc = new AceAjax.Document(["12", "34"]); + + var deltas = []; + doc.on("change", function (e) { deltas.push(e.data); }); + + doc.insertLines(2, ["aa", "bb"]); + assert.equal(doc.getValue(), ["12", "34", "aa", "bb"].join("\n")); + } , + + "test: insert lines in the middle": function() { + var doc = new AceAjax.Document(["12", "34"]); + + var deltas = []; + doc.on("change", function (e) { deltas.push(e.data); }); + + doc.insertLines(1, ["aa", "bb"]); + assert.equal(doc.getValue(), ["12", "aa", "bb", "34"].join("\n")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["12", "34"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["12", "aa", "bb", "34"].join("\n")); + } , + + "test: insert multi line string at the start": function() { + var doc = new AceAjax.Document(["12", "34"]); + + var deltas = []; + doc.on("change", function (e) { deltas.push(e.data); }); + + doc.insert({ row: 0, column: 0 }, "aa\nbb\ncc"); + assert.equal(doc.getValue(), ["aa", "bb", "cc12", "34"].join("\n")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["12", "34"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["aa", "bb", "cc12", "34"].join("\n")); + } , + + "test: insert multi line string at the end": function() { + var doc = new AceAjax.Document(["12", "34"]); + + var deltas = []; + doc.on("change", function (e) { deltas.push(e.data); }); + + doc.insert({ row: 2, column: 0 }, "aa\nbb\ncc"); + assert.equal(doc.getValue(), ["12", "34aa", "bb", "cc"].join("\n")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["12", "34"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["12", "34aa", "bb", "cc"].join("\n")); + } , + + "test: insert multi line string in the middle": function() { + var doc = new AceAjax.Document(["12", "34"]); + + var deltas = []; + doc.on("change", function (e) { deltas.push(e.data); }); + + doc.insert({ row: 0, column: 1 }, "aa\nbb\ncc"); + assert.equal(doc.getValue(), ["1aa", "bb", "cc2", "34"].join("\n")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["12", "34"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["1aa", "bb", "cc2", "34"].join("\n")); + } , + + "test: delete in line": function() { + var doc = new AceAjax.Document(["1234", "5678"]); + + var deltas = []; + doc.on("change", function (e) { deltas.push(e.data); }); + + doc.remove(new AceAjax.Range(0, 1, 0, 3)); + assert.equal(doc.getValue(), ["14", "5678"].join("\n")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["1234", "5678"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["14", "5678"].join("\n")); + } , + + "test: delete new line": function() { + var doc = new AceAjax.Document(["1234", "5678"]); + + var deltas = []; + doc.on("change", function (e) { deltas.push(e.data); }); + + doc.remove(new AceAjax.Range(0, 4, 1, 0)); + assert.equal(doc.getValue(), ["12345678"].join("\n")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["1234", "5678"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["12345678"].join("\n")); + } , + + "test: delete multi line range line": function() { + var doc = new AceAjax.Document(["1234", "5678", "abcd"]); + + var deltas = []; + doc.on("change", function (e) { deltas.push(e.data); }); + + doc.remove(new AceAjax.Range(0, 2, 2, 2)); + assert.equal(doc.getValue(), ["12cd"].join("\n")); + + var d = deltas.concat(); + doc.revertDeltas(d); + assert.equal(doc.getValue(), ["1234", "5678", "abcd"].join("\n")); + + doc.applyDeltas(d); + assert.equal(doc.getValue(), ["12cd"].join("\n")); + } , + + "test: delete full lines": function() { + var doc = new AceAjax.Document(["1234", "5678", "abcd"]); + + var deltas = []; + doc.on("change", function (e) { deltas.push(e.data); }); + + doc.remove(new AceAjax.Range(1, 0, 3, 0)); + assert.equal(doc.getValue(), ["1234", ""].join("\n")); + } , + + "test: remove lines should return the removed lines": function() { + var doc = new AceAjax.Document(["1234", "5678", "abcd"]); + + var removed = doc.removeLines(1, 2); + assert.equal(removed.join("\n"), ["5678", "abcd"].join("\n")); + } , + + "test: should handle unix style new lines": function() { + var doc = new AceAjax.Document(["1", "2", "3"]); + assert.equal(doc.getValue(), ["1", "2", "3"].join("\n")); + } , + + "test: should handle windows style new lines": function() { + var doc = new AceAjax.Document(["1", "2", "3"].join("\r\n")); + + doc.setNewLineMode("unix"); + assert.equal(doc.getValue(), ["1", "2", "3"].join("\n")); + } , + + "test: set new line mode to 'windows' should use '\\r\\n' as new lines": function() { + var doc = new AceAjax.Document(["1", "2", "3"].join("\n")); + doc.setNewLineMode("windows"); + assert.equal(doc.getValue(), ["1", "2", "3"].join("\r\n")); + } , + + "test: set new line mode to 'unix' should use '\\n' as new lines": function() { + var doc = new AceAjax.Document(["1", "2", "3"].join("\r\n")); + + doc.setNewLineMode("unix"); + assert.equal(doc.getValue(), ["1", "2", "3"].join("\n")); + } , + + "test: set new line mode to 'auto' should detect the incoming nl type": function() { + var doc = new AceAjax.Document(["1", "2", "3"].join("\n")); + + doc.setNewLineMode("auto"); + assert.equal(doc.getValue(), ["1", "2", "3"].join("\n")); + + var doc = new AceAjax.Document(["1", "2", "3"].join("\r\n")); + + doc.setNewLineMode("auto"); + assert.equal(doc.getValue(), ["1", "2", "3"].join("\r\n")); + + doc.replace(new AceAjax.Range(0, 0, 2, 1), ["4", "5", "6"].join("\n")); + assert.equal(["4", "5", "6"].join("\n"), doc.getValue()); + } , + + "test: set value": function() { + var doc = new AceAjax.Document("1"); + assert.equal("1", doc.getValue()); + + doc.setValue(doc.getValue()); + assert.equal("1", doc.getValue()); + + var doc = new AceAjax.Document("1\n2"); + assert.equal("1\n2", doc.getValue()); + + doc.setValue(doc.getValue()); + assert.equal("1\n2", doc.getValue()); + } +}; \ No newline at end of file diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-document-tests.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-document-tests.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-document-tests.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-edit_session-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-edit_session-tests.ts new file mode 100644 index 00000000..caa2f172 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-edit_session-tests.ts @@ -0,0 +1,920 @@ +/// + +var lang: any; +var assert: any; + +function createFoldTestSession() { + var lines = [ + "function foo(items) {", + " for (var i=0; i>", [1, 2], 1); + } , + + "test get longest line": function() { + var session = new AceAjax.EditSession(["12"]); + session.setTabSize(4); + assert.equal(session.getScreenWidth(), 2); + + session.doc.insertNewLine({ row: 0, column: Infinity }); + session.doc.insertLines(1, ["123"]); + assert.equal(session.getScreenWidth(), 3); + + session.doc.insertNewLine({ row: 0, column: Infinity }); + session.doc.insertLines(1, ["\t\t"]); + + assert.equal(session.getScreenWidth(), 8); + + session.setTabSize(2); + assert.equal(session.getScreenWidth(), 4); + } , + + "test issue 83": function() { + var session = new AceAjax.EditSession(""); + var editor = new AceAjax.Editor(null, session); + var document = session.getDocument(); + + session.setUseWrapMode(true); + + document.insertLines(0, ["a", "b"]); + document.insertLines(2, ["c", "d"]); + document.removeLines(1, 2); + } , + + "test wrapMode init has to create wrapData array": function() { + var session = new AceAjax.EditSession("foo bar\nfoo bar"); + var editor = new AceAjax.Editor(null, session); + var document = session.getDocument(); + + session.setUseWrapMode(true); + session.setWrapLimitRange(3, 3); + session.adjustWrapLimit(80); + } , + + "test first line blank with wrap": function() { + var session = new AceAjax.EditSession("\nfoo"); + session.setUseWrapMode(true); + assert.equal(session.doc.getValue(), ["", "foo"].join("\n")); + } , + + "test first line blank with wrap 2": function() { + var session = new AceAjax.EditSession(""); + session.setUseWrapMode(true); + session.setValue("\nfoo"); + + assert.equal(session.doc.getValue(), ["", "foo"].join("\n")); + } , + + "test fold getFoldDisplayLine": function() { + var session = createFoldTestSession(); + function assertDisplayLine(foldLine, str) { + var line = session.getLine(foldLine.end.row); + var displayLine = + session.getFoldDisplayLine(foldLine, foldLine.end.row, line.length); + assert.equal(displayLine, str); + } + } , + + "test foldLine idxToPosition": function() { + var session = createFoldTestSession(); + + function assertIdx2Pos(foldLineIdx, idx, row, column) { + var foldLine = null; + assert.position(foldLine.idxToPosition(idx), row, column); + } + + // "function foo(items) {", + // " for (var i=0; i + +var assert: any; +var exports = { + + setUp: function(next) { + this.session1 = new AceAjax.EditSession(["abc", "def"]); + this.session2 = new AceAjax.EditSession(["ghi", "jkl"]); + + + var editor = new AceAjax.Editor(null); + next(); + } , + + "test: change document": function() { + var editor = new AceAjax.Editor(null); + + editor.setSession(this.session1); + assert.equal(editor.getSession(), this.session1); + + editor.setSession(this.session2); + assert.equal(editor.getSession(), this.session2); + } , + + "test: only changes to the new document should have effect": function () { + var editor = new AceAjax.Editor(null); + + var called = false; + editor.onDocumentChange = function () { + called = true; + }; + + editor.setSession(this.session1); + editor.setSession(this.session2); + + this.session1.duplicateLines(0, 0); + assert.notOk(called); + + this.session2.duplicateLines(0, 0); + assert.ok(called); + } , + + "test: should use cursor of new document": function () { + var editor = new AceAjax.Editor(null); + + this.session1.getSelection().moveCursorTo(0, 1); + this.session2.getSelection().moveCursorTo(1, 0); + + editor.setSession(this.session1); + assert.position(editor.getCursorPosition(), 0, 1); + + editor.setSession(this.session2); + assert.position(editor.getCursorPosition(), 1, 0); + } , + + "test: only changing the cursor of the new doc should not have an effect": function () { + var editor = new AceAjax.Editor(null); + + editor.onCursorChange = function () { + called = true; + }; + + editor.setSession(this.session1); + editor.setSession(this.session2); + assert.position(editor.getCursorPosition(), 0, 0); + + var called = false; + this.session1.getSelection().moveCursorTo(0, 1); + assert.position(editor.getCursorPosition(), 0, 0); + assert.notOk(called); + + this.session2.getSelection().moveCursorTo(1, 1); + assert.position(editor.getCursorPosition(), 1, 1); + assert.ok(called); + } , + + "test: should use selection of new document": function () { + var editor = new AceAjax.Editor(null); + + this.session1.getSelection().selectTo(0, 1); + this.session2.getSelection().selectTo(1, 0); + + editor.setSession(this.session1); + assert.position(editor.getSelection().getSelectionLead(), 0, 1); + + editor.setSession(this.session2); + assert.position(editor.getSelection().getSelectionLead(), 1, 0); + } , + + "test: only changing the selection of the new doc should not have an effect": function () { + var editor = new AceAjax.Editor(null); + + editor.onSelectionChange = function () { + called = true; + }; + + editor.setSession(this.session1); + editor.setSession(this.session2); + assert.position(editor.getSelection().getSelectionLead(), 0, 0); + + var called = false; + this.session1.getSelection().selectTo(0, 1); + assert.position(editor.getSelection().getSelectionLead(), 0, 0); + assert.notOk(called); + + this.session2.getSelection().selectTo(1, 1); + assert.position(editor.getSelection().getSelectionLead(), 1, 1); + assert.ok(called); + } , + + "test: should use mode of new document": function () { + var editor = new AceAjax.Editor(null); + + editor.onChangeMode = function () { + called = true; + }; + editor.setSession(this.session1); + editor.setSession(this.session2); + + var called = false; + this.session1.setMode(new Text()); + assert.notOk(called); + + this.session2.setMode(null); + assert.ok(called); + } , + + "test: should use stop worker of old document": function (next) { + var editor = new AceAjax.Editor(null); + + var self = this; + + // 1. Open an editor and set the session to CssMode + self.editor.setSession(self.session1); + self.session1.setMode(null); + + // 2. Add a line or two of valid CSS. + self.session1.setValue("DIV { color: red; }"); + + // 3. Clear the session value. + self.session1.setValue(""); + + // 4. Set the session to HtmlMode + self.session1.setMode(null); + + // 5. Try to type valid HTML + self.session1.insert({ row: 0, column: 0 }, ""); + + setTimeout(function () { + assert.equal(Object.keys(self.session1.getAnnotations()).length, 0); + next(); + }, 600); + } +}; \ No newline at end of file diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor1-tests.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor1-tests.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor1-tests.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor_highlight_selected_word-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor_highlight_selected_word-tests.ts new file mode 100644 index 00000000..e02f3236 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor_highlight_selected_word-tests.ts @@ -0,0 +1,217 @@ +/// + +var lipsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. " + + "Mauris at arcu mi, eu lobortis mauris. Quisque ut libero eget " + + "diam congue vehicula. Quisque ut odio ut mi aliquam tincidunt. " + + "Duis lacinia aliquam lorem eget eleifend. Morbi eget felis mi. " + + "Duis quam ligula, consequat vitae convallis volutpat, blandit " + + "nec neque. Nulla facilisi. Etiam suscipit lorem ac justo " + + "sollicitudin tristique. Phasellus ut posuere nunc. Aliquam " + + "scelerisque mollis felis non gravida. Vestibulum lacus sem, " + + "posuere non bibendum id, luctus non dolor. Aenean id metus " + + "lorem, vel dapibus est. Donec gravida feugiat augue nec " + + "accumsan.Lorem ipsum dolor sit amet, consectetur adipiscing " + + "elit. Nulla vulputate, velit vitae tincidunt congue, nunc " + + "augue accumsan velit, eu consequat turpis lectus ac orci. " + + "Pellentesque ornare dolor feugiat dui auctor eu varius nulla " + + "fermentum. Sed aliquam odio at velit lacinia vel fermentum " + + "felis sodales. In dignissim magna eget nunc lobortis non " + + "fringilla nibh ullamcorper. Donec facilisis malesuada elit " + + "at egestas. Etiam bibendum, diam vitae tempor aliquet, dui " + + "libero vehicula odio, eget bibendum mauris velit eu lorem.\n" + + "consectetur"; + +function callHighlighterUpdate(session: AceAjax.IEditSession, firstRow: number, lastRow: number) { + var rangeCount = 0; + var mockMarkerLayer = { drawSingleLineMarker: function () { rangeCount++; } } + return rangeCount; +} + +var assert: any; +var renderer: AceAjax.VirtualRenderer; + +var exports = { + setUp: function(next) { + var session = new AceAjax.EditSession(lipsum); + var editor = new AceAjax.Editor(renderer, session); + var selection = session.getSelection(); + next(); + } , + + "test: highlight selected words by default": function () { + var selection = session.getSelection(); + var session = new AceAjax.EditSession(lipsum); + var editor = new AceAjax.Editor(renderer, session); + + assert.equal(editor.getHighlightSelectedWord(), true); + } , + + "test: highlight a word": function () { + var selection = session.getSelection(); + var session = new AceAjax.EditSession(lipsum); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(0, 9); + selection.selectWord(); + + var highlighter = null; + assert.ok(highlighter != null); + + var range = selection.getRange(); + assert.equal(session.getTextRange(range), "ipsum"); + assert.equal(highlighter.cache.length, 0); + assert.equal(callHighlighterUpdate(session, 0, 0), 2); + } , + + "test: highlight a word and clear highlight": function () { + var selection = session.getSelection(); + var session = new AceAjax.EditSession(lipsum); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(0, 8); + selection.selectWord(); + + var range = selection.getRange(); + assert.equal(session.getTextRange(range), "ipsum"); + assert.equal(callHighlighterUpdate(session, 0, 0), 2); + + session.highlight(""); + assert.equal(callHighlighterUpdate(session, 0, 0), 0); + } , + + "test: highlight another word": function () { + var selection = session.getSelection(); + var session = new AceAjax.EditSession(lipsum); + var editor = new AceAjax.Editor(renderer, session); + + selection.moveCursorTo(0, 14); + selection.selectWord(); + + var range = selection.getRange(); + assert.equal(session.getTextRange(range), "dolor"); + assert.equal(callHighlighterUpdate(session, 0, 0), 4); + } , + + "test: no selection, no highlight": function () { + var selection = session.getSelection(); + var session = new AceAjax.EditSession(lipsum); + var editor = new AceAjax.Editor(renderer, session); + + selection.clearSelection(); + assert.equal(callHighlighterUpdate(session, 0, 0), 0); + } , + + "test: select a word, no highlight": function () { + var selection = session.getSelection(); + var session = new AceAjax.EditSession(lipsum); + var editor = new AceAjax.Editor(renderer, session); + + selection.moveCursorTo(0, 14); + selection.selectWord(); + + editor.setHighlightSelectedWord(false); + + var range = selection.getRange(); + assert.equal(session.getTextRange(range), "dolor"); + assert.equal(callHighlighterUpdate(session, 0, 0), 0); + } , + + "test: select a word with no matches": function () { + var selection = session.getSelection(); + var session = new AceAjax.EditSession(lipsum); + var editor = new AceAjax.Editor(renderer, session); + + editor.setHighlightSelectedWord(true); + + var currentOptions = this.search.getOptions(); + var newOptions = { + wrap: true, + wholeWord: true, + caseSensitive: true, + needle: "Mauris" + }; + this.search.set(newOptions); + + var match = this.search.find(session); + assert.notEqual(match, null, "found a match for 'Mauris'"); + + this.search.set(currentOptions); + + selection.setSelectionRange(match); + + assert.equal(session.getTextRange(match), "Mauris"); + assert.equal(callHighlighterUpdate(session, 0, 0), 1); + } , + + "test: partial word selection 1": function () { + var selection = session.getSelection(); + var session = new AceAjax.EditSession(lipsum); + var editor = new AceAjax.Editor(renderer, session); + + selection.moveCursorTo(0, 14); + selection.selectWord(); + selection.selectLeft(); + + var range = selection.getRange(); + assert.equal(session.getTextRange(range), "dolo"); + assert.equal(callHighlighterUpdate(session, 0, 0), 0); + } , + + "test: partial word selection 2": function () { + var selection = session.getSelection(); + var session = new AceAjax.EditSession(lipsum); + var editor = new AceAjax.Editor(renderer, session); + + selection.moveCursorTo(0, 13); + selection.selectWord(); + selection.selectRight(); + + var range = selection.getRange(); + assert.equal(session.getTextRange(range), "dolor "); + assert.equal(callHighlighterUpdate(session, 0, 0), 0); + } , + + "test: partial word selection 3": function () { + var selection = session.getSelection(); + var session = new AceAjax.EditSession(lipsum); + var editor = new AceAjax.Editor(renderer, session); + + selection.moveCursorTo(0, 14); + selection.selectWord(); + selection.selectLeft(); + selection.shiftSelection(1); + + var range = selection.getRange(); + assert.equal(session.getTextRange(range), "olor"); + assert.equal(callHighlighterUpdate(session, 0, 0), 0); + } , + + "test: select last word": function () { + var selection = session.getSelection(); + var session = new AceAjax.EditSession(lipsum); + var editor = new AceAjax.Editor(renderer, session); + + selection.moveCursorTo(0, 1); + + var currentOptions = this.search.getOptions(); + var newOptions = { + wrap: true, + wholeWord: true, + caseSensitive: true, + backwards: true, + needle: "consectetur" + }; + this.search.set(newOptions); + + var match = this.search.find(session); + assert.notEqual(match, null, "found a match for 'consectetur'"); + assert.position(match.start, 1, 0); + + this.search.set(currentOptions); + + selection.setSelectionRange(match); + + assert.equal(session.getTextRange(match), "consectetur"); + assert.equal(callHighlighterUpdate(session, 0, 1), 3); + } +}; diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor_highlight_selected_word-tests.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor_highlight_selected_word-tests.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor_highlight_selected_word-tests.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor_navigation-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor_navigation-tests.ts new file mode 100644 index 00000000..b68ae9b9 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor_navigation-tests.ts @@ -0,0 +1,119 @@ +/// + +var assert: any; +var renderer: AceAjax.VirtualRenderer; +var exports = { + createEditSession: function (rows, cols) { + var line = new Array(cols + 1).join("a"); + var text = new Array(rows).join(line + "\n") + line; + return new AceAjax.EditSession(text); + }, + + "test: navigate to end of file should scroll the last line into view": function () { + var doc = this.createEditSession(200, 10); + var editor = new AceAjax.Editor(renderer, doc); + + editor.navigateFileEnd(); + var cursor = editor.getCursorPosition(); + + assert.ok(editor.getFirstVisibleRow() <= cursor.row); + assert.ok(editor.getLastVisibleRow() >= cursor.row); + }, + + "test: navigate to start of file should scroll the first row into view": function () { + var doc = this.createEditSession(200, 10); + var editor = new AceAjax.Editor(renderer, doc); + + editor.moveCursorTo(editor.getLastVisibleRow() + 20); + editor.navigateFileStart(); + + assert.equal(editor.getFirstVisibleRow(), 0); + }, + + "test: goto hidden line should scroll the line into the middle of the viewport": function () { + var editor = new AceAjax.Editor(renderer, this.createEditSession(200, 5)); + + editor.navigateTo(0, 0); + editor.gotoLine(101); + assert.position(editor.getCursorPosition(), 100, 0); + assert.equal(editor.getFirstVisibleRow(), 89); + + editor.navigateTo(100, 0); + editor.gotoLine(11); + assert.position(editor.getCursorPosition(), 10, 0); + assert.equal(editor.getFirstVisibleRow(), 0); + + editor.navigateTo(100, 0); + editor.gotoLine(6); + assert.position(editor.getCursorPosition(), 5, 0); + assert.equal(0, editor.getFirstVisibleRow(), 0); + + editor.navigateTo(100, 0); + editor.gotoLine(1); + assert.position(editor.getCursorPosition(), 0, 0); + assert.equal(editor.getFirstVisibleRow(), 0); + + editor.navigateTo(0, 0); + editor.gotoLine(191); + assert.position(editor.getCursorPosition(), 190, 0); + assert.equal(editor.getFirstVisibleRow(), 179); + + editor.navigateTo(0, 0); + editor.gotoLine(196); + assert.position(editor.getCursorPosition(), 195, 0); + assert.equal(editor.getFirstVisibleRow(), 180); + }, + + "test: goto visible line should only move the cursor and not scroll": function () { + var editor = new AceAjax.Editor(renderer, this.createEditSession(200, 5)); + + editor.navigateTo(0, 0); + editor.gotoLine(12); + assert.position(editor.getCursorPosition(), 11, 0); + assert.equal(editor.getFirstVisibleRow(), 0); + + editor.navigateTo(30, 0); + editor.gotoLine(33); + assert.position(editor.getCursorPosition(), 32, 0); + assert.equal(editor.getFirstVisibleRow(), 30); + }, + + "test: navigate from the end of a long line down to a short line and back should maintain the curser column": function () { + var editor = new AceAjax.Editor(renderer, new AceAjax.EditSession(["123456", "1"])); + + editor.navigateTo(0, 6); + assert.position(editor.getCursorPosition(), 0, 6); + + editor.navigateDown(); + assert.position(editor.getCursorPosition(), 1, 1); + + editor.navigateUp(); + assert.position(editor.getCursorPosition(), 0, 6); + }, + + "test: reset desired column on navigate left or right": function () { + var editor = new AceAjax.Editor(renderer, new AceAjax.EditSession(["123456", "12"])); + + editor.navigateTo(0, 6); + assert.position(editor.getCursorPosition(), 0, 6); + + editor.navigateDown(); + assert.position(editor.getCursorPosition(), 1, 2); + + editor.navigateLeft(); + assert.position(editor.getCursorPosition(), 1, 1); + + editor.navigateUp(); + assert.position(editor.getCursorPosition(), 0, 1); + }, + + "test: typing text should update the desired column": function () { + var editor = new AceAjax.Editor(renderer, new AceAjax.EditSession(["1234", "1234567890"])); + + editor.navigateTo(0, 3); + editor.insert("juhu"); + + editor.navigateDown(); + assert.position(editor.getCursorPosition(), 1, 7); + } +}; \ No newline at end of file diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor_navigation-tests.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor_navigation-tests.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor_navigation-tests.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor_text_edit-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor_text_edit-tests.ts new file mode 100644 index 00000000..62318301 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor_text_edit-tests.ts @@ -0,0 +1,501 @@ +/// + +var assert: any; +var renderer: AceAjax.VirtualRenderer; +var mode: any; +var exports = { + "test: delete line from the middle": function () { + var session = new AceAjax.EditSession(["a", "b", "c", "d"].join("\n")); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(1, 1); + editor.removeLines(); + + assert.equal(session.toString(), "a\nc\nd"); + assert.position(editor.getCursorPosition(), 1, 0); + + editor.removeLines(); + + assert.equal(session.toString(), "a\nd"); + assert.position(editor.getCursorPosition(), 1, 0); + + editor.removeLines(); + + assert.equal(session.toString(), "a"); + assert.position(editor.getCursorPosition(), 0, 1); + + editor.removeLines(); + + assert.equal(session.toString(), ""); + assert.position(editor.getCursorPosition(), 0, 0); + }, + + "test: delete multiple selected lines": function () { + var session = new AceAjax.EditSession(["a", "b", "c", "d"].join("\n")); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(1, 1); + editor.getSelection().selectDown(); + + editor.removeLines(); + assert.equal(session.toString(), "a\nd"); + assert.position(editor.getCursorPosition(), 1, 0); + }, + + "test: delete first line": function () { + var session = new AceAjax.EditSession(["a", "b", "c"].join("\n")); + var editor = new AceAjax.Editor(renderer, session); + + editor.removeLines(); + + assert.equal(session.toString(), "b\nc"); + assert.position(editor.getCursorPosition(), 0, 0); + }, + + "test: delete last should also delete the new line of the previous line": function () { + var session = new AceAjax.EditSession(["a", "b", "c", ""].join("\n")); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(3, 0); + + editor.removeLines(); + assert.equal(session.toString(), "a\nb\nc"); + assert.position(editor.getCursorPosition(), 2, 1); + + editor.removeLines(); + assert.equal(session.toString(), "a\nb"); + assert.position(editor.getCursorPosition(), 1, 1); + }, + + "test: indent block": function () { + var session = new AceAjax.EditSession(["a12345", "b12345", "c12345"].join("\n")); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(1, 3); + editor.getSelection().selectDown(); + + editor.indent(); + + assert.equal(["a12345", " b12345", " c12345"].join("\n"), session.toString()); + + assert.position(editor.getCursorPosition(), 2, 7); + + var range = editor.getSelectionRange(); + assert.position(range.start, 1, 7); + assert.position(range.end, 2, 7); + }, + + "test: indent selected lines": function () { + var session = new AceAjax.EditSession(["a12345", "b12345", "c12345"].join("\n")); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(1, 0); + editor.getSelection().selectDown(); + + editor.indent(); + assert.equal(["a12345", " b12345", "c12345"].join("\n"), session.toString()); + }, + + "test: no auto indent if cursor is before the {": function () { + var session = new AceAjax.EditSession("{",mode); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(0, 0); + editor.onTextInput("\n"); + assert.equal(["", "{"].join("\n"), session.toString()); + }, + + "test: outdent block": function () { + var session = new AceAjax.EditSession([" a12345", " b12345", " c12345"].join("\n")); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(0, 5); + editor.getSelection().selectDown(); + editor.getSelection().selectDown(); + + editor.blockOutdent(); + assert.equal(session.toString(), [" a12345", "b12345", " c12345"].join("\n")); + + assert.position(editor.getCursorPosition(), 2, 1); + + var range = editor.getSelectionRange(); + assert.position(range.start, 0, 1); + assert.position(range.end, 2, 1); + + editor.blockOutdent(); + assert.equal(session.toString(), ["a12345", "b12345", "c12345"].join("\n")); + + var range = editor.getSelectionRange(); + assert.position(range.start, 0, 0); + assert.position(range.end, 2, 0); + }, + + "test: outent without a selection should update cursor": function () { + var session = new AceAjax.EditSession(" 12"); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(0, 3); + editor.blockOutdent(" "); + + assert.equal(session.toString(), " 12"); + assert.position(editor.getCursorPosition(), 0, 0); + }, + + "test: comment lines should perserve selection": function () { + var session = new AceAjax.EditSession([" abc", "cde"].join("\n"),mode); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(0, 2); + editor.getSelection().selectDown(); + editor.toggleCommentLines(); + + assert.equal(["// abc", "//cde"].join("\n"), session.toString()); + + var selection = editor.getSelectionRange(); + assert.position(selection.start, 0, 4); + assert.position(selection.end, 1, 4); + }, + + "test: uncomment lines should perserve selection": function () { + var session = new AceAjax.EditSession(["// abc", "//cde"].join("\n"),mode); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(0, 1); + editor.getSelection().selectDown(); + editor.getSelection().selectRight(); + editor.getSelection().selectRight(); + + editor.toggleCommentLines(); + + assert.equal([" abc", "cde"].join("\n"), session.toString()); + assert.range(editor.getSelectionRange(), 0, 0, 1, 1); + }, + + "test: toggle comment lines twice should return the original text": function () { + var session = new AceAjax.EditSession([" abc", "cde", "fg"], mode); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(0, 0); + editor.getSelection().selectDown(); + editor.getSelection().selectDown(); + + editor.toggleCommentLines(); + editor.toggleCommentLines(); + + assert.equal([" abc", "cde", "fg"].join("\n"), session.toString()); + }, + + + "test: comment lines - if the selection end is at the line start it should stay there": function () { + //select down + var session = new AceAjax.EditSession(["abc", "cde"].join("\n"),mode); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(0, 0); + editor.getSelection().selectDown(); + + editor.toggleCommentLines(); + assert.range(editor.getSelectionRange(), 0, 2, 1, 0); + + // select up + var session = new AceAjax.EditSession(["abc", "cde"].join("\n"),mode); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(1, 0); + editor.getSelection().selectUp(); + + editor.toggleCommentLines(); + assert.range(editor.getSelectionRange(), 0, 2, 1, 0); + }, + + "test: move lines down should select moved lines": function () { + var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n")); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(0, 1); + editor.getSelection().selectDown(); + + editor.moveLinesDown(); + assert.equal(["33", "11", "22", "44"].join("\n"), session.toString()); + assert.position(editor.getCursorPosition(), 1, 0); + assert.position(editor.getSelection().getSelectionAnchor(), 3, 0); + assert.position(editor.getSelection().getSelectionLead(), 1, 0); + + editor.moveLinesDown(); + assert.equal(["33", "44", "11", "22"].join("\n"), session.toString()); + assert.position(editor.getCursorPosition(), 2, 0); + assert.position(editor.getSelection().getSelectionAnchor(), 3, 2); + assert.position(editor.getSelection().getSelectionLead(), 2, 0); + + // moving again should have no effect + editor.moveLinesDown(); + assert.equal(["33", "44", "11", "22"].join("\n"), session.toString()); + assert.position(editor.getCursorPosition(), 2, 0); + assert.position(editor.getSelection().getSelectionAnchor(), 3, 2); + assert.position(editor.getSelection().getSelectionLead(), 2, 0); + }, + + "test: move lines up should select moved lines": function () { + var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n")); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(2, 1); + editor.getSelection().selectDown(); + + editor.moveLinesUp(); + assert.equal(session.toString(), ["11", "33", "44", "22"].join("\n")); + assert.position(editor.getCursorPosition(), 1, 0); + assert.position(editor.getSelection().getSelectionAnchor(), 3, 0); + assert.position(editor.getSelection().getSelectionLead(), 1, 0); + + editor.moveLinesUp(); + assert.equal(session.toString(), ["33", "44", "11", "22"].join("\n")); + assert.position(editor.getCursorPosition(), 0, 0); + assert.position(editor.getSelection().getSelectionAnchor(), 2, 0); + assert.position(editor.getSelection().getSelectionLead(), 0, 0); + }, + + "test: move line without active selection should not move cursor relative to the moved line": function () { + var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n")); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(1, 1); + editor.clearSelection(); + + editor.moveLinesDown(); + assert.equal(["11", "33", "22", "44"].join("\n"), session.toString()); + assert.position(editor.getCursorPosition(), 2, 1); + + editor.clearSelection(); + + editor.moveLinesUp(); + assert.equal(["11", "22", "33", "44"].join("\n"), session.toString()); + assert.position(editor.getCursorPosition(), 1, 1); + }, + + "test: copy lines down should select lines and place cursor at the selection start": function () { + var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n")); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(1, 1); + editor.getSelection().selectDown(); + + editor.copyLinesDown(); + assert.equal(["11", "22", "33", "22", "33", "44"].join("\n"), session.toString()); + + assert.position(editor.getCursorPosition(), 3, 0); + assert.position(editor.getSelection().getSelectionAnchor(), 5, 0); + assert.position(editor.getSelection().getSelectionLead(), 3, 0); + }, + + "test: copy lines up should select lines and place cursor at the selection start": function () { + var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n")); + var editor = new AceAjax.Editor(renderer, session); + + editor.moveCursorTo(1, 1); + editor.getSelection().selectDown(); + + editor.copyLinesUp(); + assert.equal(["11", "22", "33", "22", "33", "44"].join("\n"), session.toString()); + + assert.position(editor.getCursorPosition(), 1, 0); + assert.position(editor.getSelection().getSelectionAnchor(), 3, 0); + assert.position(editor.getSelection().getSelectionLead(), 1, 0); + }, + + "test: input a tab with soft tab should convert it to spaces": function () { + var session = new AceAjax.EditSession(""); + var editor = new AceAjax.Editor(renderer, session); + + session.setTabSize(2); + session.setUseSoftTabs(true); + + editor.onTextInput("\t"); + assert.equal(session.toString(), " "); + + session.setTabSize(5); + editor.onTextInput("\t"); + assert.equal(session.toString(), " "); + }, + + "test: input tab without soft tabs should keep the tab character": function () { + var session = new AceAjax.EditSession(""); + var editor = new AceAjax.Editor(renderer, session); + + session.setUseSoftTabs(false); + + editor.onTextInput("\t"); + assert.equal(session.toString(), "\t"); + }, + + "test: undo/redo for delete line": function () { + var session = new AceAjax.EditSession(["111", "222", "333"]); + var undoManager = new AceAjax.UndoManager(); + session.setUndoManager(undoManager); + + var initialText = session.toString(); + var editor = new AceAjax.Editor(renderer, session); + + editor.removeLines(); + var step1 = session.toString(); + assert.equal(step1, "222\n333"); + + editor.removeLines(); + var step2 = session.toString(); + assert.equal(step2, "333"); + + editor.removeLines(); + var step3 = session.toString(); + assert.equal(step3, ""); + + undoManager.undo(); + assert.equal(session.toString(), step2); + + undoManager.undo(); + assert.equal(session.toString(), step1); + + undoManager.undo(); + assert.equal(session.toString(), initialText); + + undoManager.undo(); + assert.equal(session.toString(), initialText); + }, + + "test: remove left should remove character left of the cursor": function () { + var session = new AceAjax.EditSession(["123", "456"]); + + var editor = new AceAjax.Editor(renderer, session); + editor.moveCursorTo(1, 1); + editor.remove("left"); + assert.equal(session.toString(), "123\n56"); + }, + + "test: remove left should remove line break if cursor is at line start": function () { + var session = new AceAjax.EditSession(["123", "456"]); + + var editor = new AceAjax.Editor(renderer, session); + editor.moveCursorTo(1, 0); + editor.remove("left"); + assert.equal(session.toString(), "123456"); + }, + + "test: remove left should remove tabsize spaces if cursor is on a tab stop and preceeded by spaces": function () { + var session = new AceAjax.EditSession(["123", " 456"]); + session.setUseSoftTabs(true); + session.setTabSize(4); + + var editor = new AceAjax.Editor(renderer, session); + editor.moveCursorTo(1, 8); + editor.remove("left"); + assert.equal(session.toString(), "123\n 456"); + }, + + "test: transpose at line start should be a noop": function () { + var session = new AceAjax.EditSession(["123", "4567", "89"]); + + var editor = new AceAjax.Editor(renderer, session); + editor.moveCursorTo(1, 0); + editor.transposeLetters(); + + assert.equal(session.getValue(), ["123", "4567", "89"].join("\n")); + }, + + "test: transpose in line should swap the charaters before and after the cursor": function () { + var session = new AceAjax.EditSession(["123", "4567", "89"]); + + var editor = new AceAjax.Editor(renderer, session); + editor.moveCursorTo(1, 2); + editor.transposeLetters(); + + assert.equal(session.getValue(), ["123", "4657", "89"].join("\n")); + }, + + "test: transpose at line end should swap the last two characters": function () { + var session = new AceAjax.EditSession(["123", "4567", "89"]); + + var editor = new AceAjax.Editor(renderer, session); + editor.moveCursorTo(1, 4); + editor.transposeLetters(); + + assert.equal(session.getValue(), ["123", "4576", "89"].join("\n")); + }, + + "test: transpose with non empty selection should be a noop": function () { + var session = new AceAjax.EditSession(["123", "4567", "89"]); + + var editor = new AceAjax.Editor(renderer, session); + editor.moveCursorTo(1, 1); + editor.getSelection().selectRight(); + editor.transposeLetters(); + + assert.equal(session.getValue(), ["123", "4567", "89"].join("\n")); + }, + + "test: transpose should move the cursor behind the last swapped character": function () { + var session = new AceAjax.EditSession(["123", "4567", "89"]); + + var editor = new AceAjax.Editor(renderer, session); + editor.moveCursorTo(1, 2); + editor.transposeLetters(); + assert.position(editor.getCursorPosition(), 1, 3); + }, + + "test: remove to line end": function () { + var session = new AceAjax.EditSession(["123", "4567", "89"]); + + var editor = new AceAjax.Editor(renderer, session); + editor.moveCursorTo(1, 2); + editor.removeToLineEnd(); + assert.equal(session.getValue(), ["123", "45", "89"].join("\n")); + }, + + "test: remove to line end at line end should remove the new line": function () { + var session = new AceAjax.EditSession(["123", "4567", "89"]); + + var editor = new AceAjax.Editor(renderer, session); + editor.moveCursorTo(1, 4); + editor.removeToLineEnd(); + assert.position(editor.getCursorPosition(), 1, 4); + assert.equal(session.getValue(), ["123", "456789"].join("\n")); + }, + + "test: transform selection to uppercase": function () { + var session = new AceAjax.EditSession(["ajax", "dot", "org"]); + + var editor = new AceAjax.Editor(renderer, session); + editor.moveCursorTo(1, 0); + editor.getSelection().selectLineEnd(); + editor.toUpperCase() + assert.equal(session.getValue(), ["ajax", "DOT", "org"].join("\n")); + }, + + "test: transform word to uppercase": function () { + var session = new AceAjax.EditSession(["ajax", "dot", "org"]); + + var editor = new AceAjax.Editor(renderer, session); + editor.moveCursorTo(1, 0); + editor.toUpperCase() + assert.equal(session.getValue(), ["ajax", "DOT", "org"].join("\n")); + assert.position(editor.getCursorPosition(), 1, 0); + }, + + "test: transform selection to lowercase": function () { + var session = new AceAjax.EditSession(["AJAX", "DOT", "ORG"]); + + var editor = new AceAjax.Editor(renderer, session); + editor.moveCursorTo(1, 0); + editor.getSelection().selectLineEnd(); + editor.toLowerCase() + assert.equal(session.getValue(), ["AJAX", "dot", "ORG"].join("\n")); + }, + + "test: transform word to lowercase": function () { + var session = new AceAjax.EditSession(["AJAX", "DOT", "ORG"]); + + var editor = new AceAjax.Editor(renderer, session); + editor.moveCursorTo(1, 0); + editor.toLowerCase() + assert.equal(session.getValue(), ["AJAX", "dot", "ORG"].join("\n")); + assert.position(editor.getCursorPosition(), 1, 0); + } +}; \ No newline at end of file diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor_text_edit-tests.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor_text_edit-tests.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-editor_text_edit-tests.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-multi_select-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-multi_select-tests.ts new file mode 100644 index 00000000..68c7d1af --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-multi_select-tests.ts @@ -0,0 +1,114 @@ +/// + +var assert: any; +var editor: any; +var renderer: any; +var exec = function (name?, times?, args?) { + do { + editor.commands.exec(name, editor, args); + } while (times-- > 1) +}; +var testRanges = function (str) { + assert.equal(editor.selection.getAllRanges() + "", str + ""); +} + +var exports = { + + name: "ACE multi_select.js", + + "test: multiselect editing": function() { + var doc = new AceAjax.EditSession([ + "w1.w2", + " wtt.w", + " wtt.w" + ]); + editor = new AceAjax.Editor(renderer, doc); + + editor.navigateFileEnd(); + exec("selectMoreBefore", 3); + assert.ok(editor.inMultiSelectMode); + assert.equal(editor.selection.getAllRanges().length, 4); + + var newLine = editor.session.getDocument().getNewLineCharacter(); + var copyText = "wwww".split("").join(newLine); + assert.equal(editor.getCopyText(), copyText); + exec("insertstring", 1, "a"); + exec("backspace", 2); + assert.equal(editor.session.getValue(), "w1.w2\ntt\ntt"); + assert.equal(editor.selection.getAllRanges().length, 4); + + exec("selectall"); + assert.ok(!editor.inMultiSelectMode); + //assert.equal(editor.selection.getAllRanges().length, 1); + } , + + "test: multiselect navigation": function() { + var doc = new AceAjax.EditSession([ + "w1.w2", + " wtt.w", + " wtt.we" + ]); + editor = new AceAjax.Editor(renderer, doc); + + editor.selectMoreLines(1); + testRanges("Range: [0/0] -> [0/0],Range: [1/0] -> [1/0]"); + assert.ok(editor.inMultiSelectMode); + + exec("golinedown"); + exec("gotolineend"); + testRanges("Range: [1/9] -> [1/9],Range: [2/10] -> [2/10]"); + exec("selectwordleft"); + + testRanges("Range: [1/8] -> [1/9],Range: [2/8] -> [2/10]"); + exec("golinedown", 2); + assert.ok(!editor.inMultiSelectMode); + } , + + "test: multiselect session change": function() { + var doc = new AceAjax.EditSession([ + "w1.w2", + " wtt.w", + " wtt.w" + ]); + editor = new AceAjax.Editor(renderer, doc); + + editor.selectMoreLines(1) + testRanges("Range: [0/0] -> [0/0],Range: [1/0] -> [1/0]"); + assert.ok(editor.inMultiSelectMode); + + var doc2 = new AceAjax.EditSession(["w1"]); + editor.setSession(doc2); + assert.ok(!editor.inMultiSelectMode); + + editor.setSession(doc); + assert.ok(editor.inMultiSelectMode); + } , + + "test: multiselect addRange": function() { + var doc = new AceAjax.EditSession([ + "w1.w2", + " wtt.w", + " wtt.w" + ]); + editor = new AceAjax.Editor(renderer, doc); + + var selection = editor.selection; + + var range1 = new AceAjax.Range(0, 2, 0, 4); + editor.selection.fromOrientedRange(range1); + + var range2 = new AceAjax.Range(0, 3, 0, 4); + selection.addRange(range2); + assert.ok(!editor.inMultiSelectMode); + assert.ok(range2.isEqual(editor.selection.getRange())); + + var range3 = new AceAjax.Range(0, 1, 0, 1); + selection.addRange(range3); + assert.ok(editor.inMultiSelectMode); + testRanges([range3, range2]); + + var range4 = new AceAjax.Range(0, 0, 4, 0); + selection.addRange(range4); + assert.ok(!editor.inMultiSelectMode); + } +}; diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-multi_select-tests.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-multi_select-tests.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-multi_select-tests.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-placeholder-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-placeholder-tests.ts new file mode 100644 index 00000000..b9693da3 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-placeholder-tests.ts @@ -0,0 +1,109 @@ +/// + +var assert: any; +var renderer: AceAjax.VirtualRenderer; +var mode: any; +var exports = { + + "test: simple at the end appending of text": function () { + var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode); + var editor = new AceAjax.Editor(renderer, session); + + new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]); + + editor.moveCursorTo(0, 5); + editor.insert('b'); + assert.equal(session.doc.getValue(), "var ab = 10;\nconsole.log(ab, ab);"); + editor.insert('cd'); + assert.equal(session.doc.getValue(), "var abcd = 10;\nconsole.log(abcd, abcd);"); + editor.remove('left'); + editor.remove('left'); + editor.remove('left'); + assert.equal(session.doc.getValue(), "var a = 10;\nconsole.log(a, a);"); + }, + + "test: inserting text outside placeholder": function () { + var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);\n", mode); + var editor = new AceAjax.Editor(renderer, session); + + new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]); + + editor.moveCursorTo(2, 0); + editor.insert('b'); + assert.equal(session.doc.getValue(), "var a = 10;\nconsole.log(a, a);\nb"); + }, + + "test: insertion at the beginning": function (next) { + var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode); + var editor = new AceAjax.Editor(renderer, session); + + var p = new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]); + + editor.moveCursorTo(0, 4); + editor.insert('$'); + assert.equal(session.doc.getValue(), "var $a = 10;\nconsole.log($a, $a);"); + editor.moveCursorTo(0, 4); + // Have to put this in a setTimeout because the anchor is only fixed later. + setTimeout(function () { + editor.insert('v'); + assert.equal(session.doc.getValue(), "var v$a = 10;\nconsole.log(v$a, v$a);"); + next(); + }, 10); + }, + + "test: detaching placeholder": function () { + var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode); + var editor = new AceAjax.Editor(renderer, session); + + var p = new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]); + + editor.moveCursorTo(0, 5); + editor.insert('b'); + assert.equal(session.doc.getValue(), "var ab = 10;\nconsole.log(ab, ab);"); + p.detach(); + editor.insert('cd'); + assert.equal(session.doc.getValue(), "var abcd = 10;\nconsole.log(ab, ab);"); + }, + + "test: events": function () { + var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode); + var editor = new AceAjax.Editor(renderer, session); + + var p = new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]); + var entered = false; + var left = false; + p.on("cursorEnter", function () { + entered = true; + }); + p.on("cursorLeave", function () { + left = true; + }); + + editor.moveCursorTo(0, 0); + editor.moveCursorTo(0, 4); + p.onCursorChange(); // Have to do this by hand because moveCursorTo doesn't trigger the event + assert.ok(entered); + editor.moveCursorTo(1, 0); + p.onCursorChange(); // Have to do this by hand because moveCursorTo doesn't trigger the event + assert.ok(left); + }, + + "test: cancel": function (next) { + var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode); + session.setUndoManager(new AceAjax.UndoManager()); + var editor = new AceAjax.Editor(renderer, session); + var p = new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]); + + editor.moveCursorTo(0, 5); + editor.insert('b'); + editor.insert('cd'); + editor.remove('left'); + assert.equal(session.doc.getValue(), "var abc = 10;\nconsole.log(abc, abc);"); + // Wait a little for the changes to enter the undo stack + setTimeout(function () { + p.cancel(); + assert.equal(session.doc.getValue(), "var a = 10;\nconsole.log(a, a);"); + next(); + }, 80); + } +}; diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-placeholder-tests.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-placeholder-tests.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-placeholder-tests.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-range-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-range-tests.ts new file mode 100644 index 00000000..8e560e8d --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-range-tests.ts @@ -0,0 +1,147 @@ +/// + +var assert: any; +var exports = { + + name: "ACE range.js", + + "test: create range": function () { + var range = new AceAjax.Range(1, 2, 3, 4); + + assert.equal(range.start.row, 1); + assert.equal(range.start.column, 2); + assert.equal(range.end.row, 3); + assert.equal(range.end.column, 4); + }, + + "test: create from points": function () { + var range = AceAjax.Range.fromPoints({ row: 1, column: 2 }, { row: 3, column: 4 }); + + assert.equal(range.start.row, 1); + assert.equal(range.start.column, 2); + assert.equal(range.end.row, 3); + assert.equal(range.end.column, 4); + }, + + "test: clip to rows": function () { + assert.range(new AceAjax.Range(0, 20, 100, 30).clipRows(10, 30), 10, 0, 31, 0); + assert.range(new AceAjax.Range(0, 20, 30, 10).clipRows(10, 30), 10, 0, 30, 10); + + var range = new AceAjax.Range(0, 20, 3, 10); + var range = range.clipRows(10, 30); + + assert.ok(range.isEmpty()); + assert.range(range, 10, 0, 10, 0); + }, + + "test: isEmpty": function () { + var range = new AceAjax.Range(1, 2, 1, 2); + assert.ok(range.isEmpty()); + + var range = new AceAjax.Range(1, 2, 1, 6); + assert.notOk(range.isEmpty()); + }, + + "test: is multi line": function () { + var range = new AceAjax.Range(1, 2, 1, 6); + assert.notOk(range.isMultiLine()); + + var range = new AceAjax.Range(1, 2, 2, 6); + assert.ok(range.isMultiLine()); + }, + + "test: clone": function () { + var range = new AceAjax.Range(1, 2, 3, 4); + var clone = range.clone(); + + assert.position(clone.start, 1, 2); + assert.position(clone.end, 3, 4); + + clone.start.column = 20; + assert.position(range.start, 1, 2); + + clone.end.column = 20; + assert.position(range.end, 3, 4); + }, + + "test: contains for multi line ranges": function () { + var range = new AceAjax.Range(1, 10, 5, 20); + + assert.ok(range.contains(1, 10)); + assert.ok(range.contains(2, 0)); + assert.ok(range.contains(3, 100)); + assert.ok(range.contains(5, 19)); + assert.ok(range.contains(5, 20)); + + assert.notOk(range.contains(1, 9)); + assert.notOk(range.contains(0, 0)); + assert.notOk(range.contains(5, 21)); + }, + + "test: contains for single line ranges": function () { + var range = new AceAjax.Range(1, 10, 1, 20); + + assert.ok(range.contains(1, 10)); + assert.ok(range.contains(1, 15)); + assert.ok(range.contains(1, 20)); + + assert.notOk(range.contains(0, 9)); + assert.notOk(range.contains(2, 9)); + assert.notOk(range.contains(1, 9)); + assert.notOk(range.contains(1, 21)); + }, + + "test: extend range": function () { + var range = new AceAjax.Range(2, 10, 2, 30); + + var range = range.extend(2, 5); + assert.range(range, 2, 5, 2, 30); + + var range = range.extend(2, 35); + assert.range(range, 2, 5, 2, 35); + + var range = range.extend(2, 15); + assert.range(range, 2, 5, 2, 35); + + var range = range.extend(1, 4); + assert.range(range, 1, 4, 2, 35); + + var range = range.extend(6, 10); + assert.range(range, 1, 4, 6, 10); + }, + + "test: collapse rows": function () { + var range = new AceAjax.Range(0, 2, 1, 2); + assert.range(range.collapseRows(), 0, 0, 1, 0); + + var range = new AceAjax.Range(2, 2, 3, 1); + assert.range(range.collapseRows(), 2, 0, 3, 0); + + var range = new AceAjax.Range(2, 2, 3, 0); + assert.range(range.collapseRows(), 2, 0, 2, 0); + + var range = new AceAjax.Range(2, 0, 2, 0); + assert.range(range.collapseRows(), 2, 0, 2, 0); + }, + + "test: to screen range": function () { + var session = new AceAjax.EditSession([ + "juhu", + "12\t\t34", + "ããa", + "\t\t34", + ]); + + var range = new AceAjax.Range(0, 0, 0, 3); + assert.range(range.toScreenRange(session), 0, 0, 0, 3); + + var range = new AceAjax.Range(1, 1, 1, 3); + assert.range(range.toScreenRange(session), 1, 1, 1, 4); + + var range = new AceAjax.Range(2, 1, 2, 2); + assert.range(range.toScreenRange(session), 2, 2, 2, 4); + + var range = new AceAjax.Range(3, 0, 3, 4); + assert.range(range.toScreenRange(session), 3, 0, 3, 10); + } +}; diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-range-tests.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-range-tests.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-range-tests.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-range_list-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-range_list-tests.ts new file mode 100644 index 00000000..3a531579 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-range_list-tests.ts @@ -0,0 +1,118 @@ +/// + +var assert: any; +function flatten(rangeList) { + var points = []; + rangeList.ranges.forEach(function (r) { + points.push(r.start.row, r.start.column, r.end.row, r.end.column) + }) + return points; +} +function testRangeList(rangeList, points) { + assert.equal("" + flatten(rangeList), "" + points); +} + +var exports = { + + name: "ACE range_list.js", + + "test: rangeList pointIndex": function() { + var rangeList = new AceAjax.RangeList(); + rangeList.ranges = [ + new AceAjax.Range(1, 2, 3, 4), + new AceAjax.Range(4, 2, 5, 4), + new AceAjax.Range(8, 8, 9, 9) + ]; + + assert.equal(rangeList.pointIndex({ row: 0, column: 1 }), -1); + assert.equal(rangeList.pointIndex({ row: 1, column: 2 }), 0); + assert.equal(rangeList.pointIndex({ row: 1, column: 3 }), 0); + assert.equal(rangeList.pointIndex({ row: 3, column: 4 }), 0); + assert.equal(rangeList.pointIndex({ row: 4, column: 1 }), -2); + assert.equal(rangeList.pointIndex({ row: 5, column: 1 }), 1); + assert.equal(rangeList.pointIndex({ row: 8, column: 9 }), 2); + assert.equal(rangeList.pointIndex({ row: 18, column: 9 }), -4); + } , + + "test: rangeList add": function() { + var rangeList = new AceAjax.RangeList(); + rangeList.addList([ + new AceAjax.Range(9, 0, 9, 1), + new AceAjax.Range(1, 2, 3, 4), + new AceAjax.Range(8, 8, 9, 9), + new AceAjax.Range(4, 2, 5, 4), + new AceAjax.Range(3, 20, 3, 24), + new AceAjax.Range(6, 6, 7, 7) + ]); + assert.equal(rangeList.ranges.length, 5); + + rangeList.add(new AceAjax.Range(1, 2, 3, 5)); + assert.range(rangeList.ranges[0], 1, 2, 3, 5); + assert.equal(rangeList.ranges.length, 5); + + rangeList.add(new AceAjax.Range(7, 7, 7, 7)); + assert.range(rangeList.ranges[3], 7, 7, 7, 7); + rangeList.add(new AceAjax.Range(7, 8, 7, 8)); + assert.range(rangeList.ranges[4], 7, 8, 7, 8); + } , + + "test: rangeList add empty": function() { + var rangeList = new AceAjax.RangeList(); + rangeList.addList([ + new AceAjax.Range(7, 10, 7, 10), + new AceAjax.Range(9, 10, 9, 10), + new AceAjax.Range(8, 10, 8, 10) + ]); + assert.equal(rangeList.ranges.length, 3); + + rangeList.add(new AceAjax.Range(9, 10, 9, 10)); + testRangeList(rangeList, [7, 10, 7, 10, 8, 10, 8, 10, 9, 10, 9, 10]); + } , + + "test: rangeList merge": function() { + var rangeList = new AceAjax.RangeList(); + rangeList.addList([ + new AceAjax.Range(1, 2, 3, 4), + new AceAjax.Range(4, 2, 5, 4), + new AceAjax.Range(6, 6, 7, 7), + new AceAjax.Range(8, 8, 9, 9) + ]); + var removed = []; + + assert.equal(rangeList.ranges.length, 4); + + rangeList.ranges[1].end.row = 7; + removed = rangeList.merge(); + assert.equal(removed.length, 1); + assert.range(rangeList.ranges[1], 4, 2, 7, 7); + assert.equal(rangeList.ranges.length, 3); + + rangeList.ranges[0].end.row = 10; + removed = rangeList.merge(); + assert.range(rangeList.ranges[0], 1, 2, 10, 4); + assert.equal(removed.length, 2); + assert.equal(rangeList.ranges.length, 1); + + rangeList.ranges.push(new AceAjax.Range(10, 10, 10, 10)); + rangeList.ranges.push(new AceAjax.Range(10, 10, 10, 10)); + removed = rangeList.merge(); + assert.equal(rangeList.ranges.length, 2); + } , + + "test: rangeList remove": function() { + var rangeList = new AceAjax.RangeList(); + var list = [ + new AceAjax.Range(1, 2, 3, 4), + new AceAjax.Range(4, 2, 5, 4), + new AceAjax.Range(6, 6, 7, 7), + new AceAjax.Range(8, 8, 9, 9) + ]; + rangeList.addList(list); + assert.equal(rangeList.ranges.length, 4); + rangeList.substractPoint({ row: 1, column: 2 }); + assert.equal(rangeList.ranges.length, 3); + rangeList.substractPoint({ row: 6, column: 7 }); + assert.equal(rangeList.ranges.length, 2); + } + +}; diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-range_list-tests.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-range_list-tests.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-range_list-tests.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-search-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-search-tests.ts new file mode 100644 index 00000000..14b53397 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-search-tests.ts @@ -0,0 +1,417 @@ +/// + +var assert: any; +var exports = { + "test: configure the search object": function () { + var search = new AceAjax.Search(); + search.set({ + needle: "juhu" + }); + }, + + "test: find simple text in document": function () { + var session = new AceAjax.EditSession(["juhu kinners 123", "456"]); + var search = new AceAjax.Search().set({ + needle: "kinners" + }); + + var range = search.find(session); + assert.position(range.start, 0, 5); + assert.position(range.end, 0, 12); + }, + + "test: find simple text in next line": function () { + var session = new AceAjax.EditSession(["abc", "juhu kinners 123", "456"]); + var search = new AceAjax.Search().set({ + needle: "kinners" + }); + + var range = search.find(session); + assert.position(range.start, 1, 5); + assert.position(range.end, 1, 12); + }, + + "test: find text starting at cursor position": function () { + var session = new AceAjax.EditSession(["juhu kinners", "juhu kinners 123"]); + session.getSelection().moveCursorTo(0, 6); + var search = new AceAjax.Search().set({ + needle: "kinners" + }); + + var range = search.find(session); + assert.position(range.start, 1, 5); + assert.position(range.end, 1, 12); + }, + + "test: wrap search is on by default": function () { + var session = new AceAjax.EditSession(["abc", "juhu kinners 123", "456"]); + session.getSelection().moveCursorTo(2, 1); + + var search = new AceAjax.Search().set({ + needle: "kinners" + }); + + assert.notEqual(search.find(session), null); + }, + + "test: wrap search should wrap at file end": function () { + var session = new AceAjax.EditSession(["abc", "juhu kinners 123", "456"]); + session.getSelection().moveCursorTo(2, 1); + + var search = new AceAjax.Search().set({ + needle: "kinners", + wrap: true + }); + + var range = search.find(session); + assert.position(range.start, 1, 5); + assert.position(range.end, 1, 12); + }, + + "test: wrap search should find needle even if it starts inside it": function () { + var session = new AceAjax.EditSession(["abc", "juhu kinners 123", "456"]); + session.getSelection().moveCursorTo(6, 1); + + var search = new AceAjax.Search().set({ + needle: "kinners", + wrap: true + }); + + var range = search.find(session); + assert.position(range.start, 1, 5); + assert.position(range.end, 1, 12); + }, + + "test: wrap search with no match should return 'null'": function () { + var session = new AceAjax.EditSession(["abc", "juhu kinners 123", "456"]); + session.getSelection().moveCursorTo(2, 1); + + var search = new AceAjax.Search().set({ + needle: "xyz", + wrap: true + }); + + assert.equal(search.find(session), null); + }, + + "test: case sensitive is by default off": function () { + var session = new AceAjax.EditSession(["abc", "juhu kinners 123", "456"]); + + var search = new AceAjax.Search().set({ + needle: "JUHU" + }); + + assert.range(search.find(session), 1, 0, 1, 4); + }, + + "test: case sensitive search": function () { + var session = new AceAjax.EditSession(["abc", "juhu kinners 123", "456"]); + + var search = new AceAjax.Search().set({ + needle: "KINNERS", + caseSensitive: true + }); + + var range = search.find(session); + assert.equal(range, null); + }, + + "test: whole word search should not match inside of words": function () { + var session = new AceAjax.EditSession(["juhukinners", "juhu kinners 123", "456"]); + + var search = new AceAjax.Search().set({ + needle: "kinners", + wholeWord: true + }); + + var range = search.find(session); + assert.position(range.start, 1, 5); + assert.position(range.end, 1, 12); + }, + + "test: find backwards": function () { + var session = new AceAjax.EditSession(["juhu juhu juhu juhu"]); + session.getSelection().moveCursorTo(0, 10); + var search = new AceAjax.Search().set({ + needle: "juhu", + backwards: true + }); + + var range = search.find(session); + assert.position(range.start, 0, 5); + assert.position(range.end, 0, 9); + }, + + "test: find in selection": function () { + var session = new AceAjax.EditSession(["juhu", "juhu", "juhu", "juhu"]); + session.getSelection().setSelectionAnchor(1, 0); + session.getSelection().selectTo(3, 5); + + var search = new AceAjax.Search().set({ + needle: "juhu", + wrap: true, + range: session.getSelection().getRange() + }); + + var range = search.find(session); + assert.position(range.start, 1, 0); + assert.position(range.end, 1, 4); + + search = new AceAjax.Search().set({ + needle: "juhu", + wrap: true, + range: session.getSelection().getRange() + }); + + session.getSelection().setSelectionAnchor(0, 2); + session.getSelection().selectTo(3, 2); + + var range = search.find(session); + assert.position(range.start, 1, 0); + assert.position(range.end, 1, 4); + }, + + "test: find backwards in selection": function () { + var session = new AceAjax.EditSession(["juhu", "juhu", "juhu", "juhu"]); + + session.getSelection().setSelectionAnchor(0, 2); + session.getSelection().selectTo(3, 2); + + var search = new AceAjax.Search().set({ + needle: "juhu", + wrap: true, + backwards: true, + range: session.getSelection().getRange() + }); + + var range = search.find(session); + assert.position(range.start, 2, 0); + assert.position(range.end, 2, 4); + + search = new AceAjax.Search().set({ + needle: "juhu", + wrap: true, + range: session.getSelection().getRange() + }); + + session.getSelection().setSelectionAnchor(0, 2); + session.getSelection().selectTo(1, 2); + + var range = search.find(session); + assert.position(range.start, 1, 0); + assert.position(range.end, 1, 4); + }, + + "test: edge case - match directly before the cursor": function () { + var session = new AceAjax.EditSession(["123", "123", "juhu"]); + + var search = new AceAjax.Search().set({ + needle: "juhu", + wrap: true + }); + + session.getSelection().moveCursorTo(2, 5); + + var range = search.find(session); + assert.position(range.start, 2, 0); + assert.position(range.end, 2, 4); + }, + + "test: edge case - match backwards directly after the cursor": function () { + var session = new AceAjax.EditSession(["123", "123", "juhu"]); + + var search = new AceAjax.Search().set({ + needle: "juhu", + wrap: true, + backwards: true + }); + + session.getSelection().moveCursorTo(2, 0); + + var range = search.find(session); + assert.position(range.start, 2, 0); + assert.position(range.end, 2, 4); + }, + + "test: find using a regular expression": function () { + var session = new AceAjax.EditSession(["abc123 123 cd", "abc"]); + + var search = new AceAjax.Search().set({ + needle: "\\d+", + regExp: true + }); + + var range = search.find(session); + assert.position(range.start, 0, 3); + assert.position(range.end, 0, 6); + }, + + "test: find using a regular expression and whole word": function () { + var session = new AceAjax.EditSession(["abc123 123 cd", "abc"]); + + var search = new AceAjax.Search().set({ + needle: "\\d+\\b", + regExp: true, + wholeWord: true + }); + + var range = search.find(session); + assert.position(range.start, 0, 7); + assert.position(range.end, 0, 10); + }, + + "test: use regular expressions with capture groups": function () { + var session = new AceAjax.EditSession([" ab: 12px", "

+ +var assert: any; +var exports = { + createSession: function (rows, cols) { + var line = new Array(cols + 1).join("a"); + var text = new Array(rows).join(line + "\n") + line; + return new AceAjax.EditSession(text); + }, + + "test: move cursor to end of file should place the cursor on last row and column": function () { + var session = this.createSession(200, 10); + var selection = session.getSelection(); + + selection.moveCursorFileEnd(); + assert.position(selection.getCursor(), 199, 10); + }, + + "test: moveCursor to start of file should place the cursor on the first row and column": function () { + var session = this.createSession(200, 10); + var selection = session.getSelection(); + + selection.moveCursorFileStart(); + assert.position(selection.getCursor(), 0, 0); + }, + + "test: move selection lead to end of file": function () { + var session = this.createSession(200, 10); + var selection = session.getSelection(); + + selection.moveCursorTo(100, 5); + selection.selectFileEnd(); + + var range = selection.getRange(); + + assert.position(range.start, 100, 5); + assert.position(range.end, 199, 10); + }, + + "test: move selection lead to start of file": function () { + var session = this.createSession(200, 10); + var selection = session.getSelection(); + + selection.moveCursorTo(100, 5); + selection.selectFileStart(); + + var range = selection.getRange(); + + assert.position(range.start, 0, 0); + assert.position(range.end, 100, 5); + }, + + "test: move cursor word right": function () { + var session = new AceAjax.EditSession([ + "ab", + " Juhu Kinners (abc, 12)", + " cde" + ].join("\n")); + + var selection = session.getSelection(); + + selection.moveCursorDown(); + assert.position(selection.getCursor(), 1, 0); + + selection.moveCursorWordRight(); + assert.position(selection.getCursor(), 1, 5); + + selection.moveCursorWordRight(); + assert.position(selection.getCursor(), 1, 13); + + selection.moveCursorWordRight(); + assert.position(selection.getCursor(), 1, 18); + + selection.moveCursorWordRight(); + assert.position(selection.getCursor(), 1, 22); + + // wrap line + selection.moveCursorWordRight(); + assert.position(selection.getCursor(), 2, 4); + + selection.moveCursorWordRight(); + assert.position(selection.getCursor(), 2, 4); + }, + + "test: select word right if cursor in word": function () { + var session = new AceAjax.EditSession("Juhu Kinners"); + var selection = session.getSelection(); + + selection.moveCursorTo(0, 2); + selection.moveCursorWordRight(); + + assert.position(selection.getCursor(), 0, 4); + }, + + "test: moveCursor word left": function () { + var session = new AceAjax.EditSession([ + "ab", + " Juhu Kinners (abc, 12)", + " cde" + ].join("\n")); + + var selection = session.getSelection(); + + selection.moveCursorDown(); + selection.moveCursorLineEnd(); + assert.position(selection.getCursor(), 1, 23); + + selection.moveCursorWordLeft(); + assert.position(selection.getCursor(), 1, 20); + + selection.moveCursorWordLeft(); + assert.position(selection.getCursor(), 1, 15); + + selection.moveCursorWordLeft(); + assert.position(selection.getCursor(), 1, 6); + + selection.moveCursorWordLeft(); + assert.position(selection.getCursor(), 1, 1); + + // wrap line + selection.moveCursorWordLeft(); + assert.position(selection.getCursor(), 0, 0); + + selection.moveCursorWordLeft(); + assert.position(selection.getCursor(), 0, 0); + }, + + "test: moveCursor word left with umlauts": function () { + var session = new AceAjax.EditSession(" Fuß Füße"); + + var selection = session.getSelection(); + selection.moveCursorTo(0, 9) + selection.moveCursorWordLeft(); + assert.position(selection.getCursor(), 0, 5); + + selection.moveCursorWordLeft(); + assert.position(selection.getCursor(), 0, 1); + }, + + "test: select word left if cursor in word": function () { + var session = new AceAjax.EditSession("Juhu Kinners"); + var selection = session.getSelection(); + + selection.moveCursorTo(0, 8); + + selection.moveCursorWordLeft(); + assert.position(selection.getCursor(), 0, 5); + }, + + "test: select word right and select": function () { + var session = new AceAjax.EditSession("Juhu Kinners"); + var selection = session.getSelection(); + + selection.moveCursorTo(0, 0); + selection.selectWordRight(); + + var range = selection.getRange(); + + assert.position(range.start, 0, 0); + assert.position(range.end, 0, 4); + }, + + "test: select word left and select": function () { + var session = new AceAjax.EditSession("Juhu Kinners"); + var selection = session.getSelection(); + + selection.moveCursorTo(0, 3); + selection.selectWordLeft(); + + var range = selection.getRange(); + + assert.position(range.start, 0, 0); + assert.position(range.end, 0, 3); + }, + + "test: select word with cursor in word should select the word": function () { + var session = new AceAjax.EditSession("Juhu Kinners 123"); + var selection = session.getSelection(); + + selection.moveCursorTo(0, 8); + selection.selectWord(); + + var range = selection.getRange(); + assert.position(range.start, 0, 5); + assert.position(range.end, 0, 12); + }, + + "test: select word with cursor in word including right whitespace should select the word": function () { + var session = new AceAjax.EditSession("Juhu Kinners 123"); + var selection = session.getSelection(); + + selection.moveCursorTo(0, 8); + selection.selectAWord(); + + var range = selection.getRange(); + assert.position(range.start, 0, 5); + assert.position(range.end, 0, 18); + }, + + "test: select word with cursor betwen white space and word should select the word": function () { + var session = new AceAjax.EditSession("Juhu Kinners"); + var selection = session.getSelection(); + + selection.moveCursorTo(0, 4); + selection.selectWord(); + + var range = selection.getRange(); + assert.position(range.start, 0, 0); + assert.position(range.end, 0, 4); + + selection.moveCursorTo(0, 5); + selection.selectWord(); + + var range = selection.getRange(); + assert.position(range.start, 0, 5); + assert.position(range.end, 0, 12); + }, + + "test: select word with cursor in white space should select white space": function () { + var session = new AceAjax.EditSession("Juhu Kinners"); + var selection = session.getSelection(); + + selection.moveCursorTo(0, 5); + selection.selectWord(); + + var range = selection.getRange(); + assert.position(range.start, 0, 4); + assert.position(range.end, 0, 6); + }, + + "test: moving cursor should fire a 'changeCursor' event": function () { + var session = new AceAjax.EditSession("Juhu Kinners"); + var selection = session.getSelection(); + + selection.moveCursorTo(0, 5); + + var called = false; + selection.addEventListener("changeCursor", function () { + called = true; + }); + + selection.moveCursorTo(0, 6); + assert.ok(called); + }, + + "test: calling setCursor with the same position should not fire an event": function () { + var session = new AceAjax.EditSession("Juhu Kinners"); + var selection = session.getSelection(); + + selection.moveCursorTo(0, 5); + + var called = false; + selection.addEventListener("changeCursor", function () { + called = true; + }); + + selection.moveCursorTo(0, 5); + assert.notOk(called); + }, + + "test: moveWordright should move past || and [": function () { + var session = new AceAjax.EditSession("||foo["); + var selection = session.getSelection(); + + // Move behind ||foo + selection.moveCursorWordRight(); + assert.position(selection.getCursor(), 0, 5); + + // Move behind [ + selection.moveCursorWordRight(); + assert.position(selection.getCursor(), 0, 6); + }, + + "test: moveWordLeft should move past || and [": function () { + var session = new AceAjax.EditSession("||foo["); + var selection = session.getSelection(); + + selection.moveCursorTo(0, 6); + + // Move behind [foo + selection.moveCursorWordLeft(); + assert.position(selection.getCursor(), 0, 2); + + // Move behind || + selection.moveCursorWordLeft(); + assert.position(selection.getCursor(), 0, 0); + }, + + "test: move cursor to line start should move cursor to end of the indentation first": function () { + var session = new AceAjax.EditSession("12\n Juhu\n12"); + var selection = session.getSelection(); + + selection.moveCursorTo(1, 6); + selection.moveCursorLineStart(); + + assert.position(selection.getCursor(), 1, 4); + }, + + "test: move cursor to line start when the cursor is at the end of the indentation should move cursor to column 0": function () { + var session = new AceAjax.EditSession("12\n Juhu\n12"); + var selection = session.getSelection(); + + selection.moveCursorTo(1, 4); + selection.moveCursorLineStart(); + + assert.position(selection.getCursor(), 1, 0); + }, + + "test: move cursor to line start when the cursor is at column 0 should move cursor to the end of the indentation": function () { + var session = new AceAjax.EditSession("12\n Juhu\n12"); + var selection = session.getSelection(); + + selection.moveCursorTo(1, 0); + selection.moveCursorLineStart(); + + assert.position(selection.getCursor(), 1, 4); + }, + + // Eclipse style + "test: move cursor to line start when the cursor is before the initial indentation should move cursor to the end of the indentation": function () { + var session = new AceAjax.EditSession("12\n Juhu\n12"); + var selection = session.getSelection(); + + selection.moveCursorTo(1, 2); + selection.moveCursorLineStart(); + + assert.position(selection.getCursor(), 1, 4); + }, + + "test go line up when in the middle of the first line should go to document start": function () { + var session = new AceAjax.EditSession("juhu kinners"); + var selection = session.getSelection(); + + selection.moveCursorTo(0, 4); + selection.moveCursorUp(); + + assert.position(selection.getCursor(), 0, 0); + }, + + "test: (wrap) go line up when in the middle of the first line should go to document start": function () { + var session = new AceAjax.EditSession("juhu kinners"); + session.setWrapLimitRange(5, 5); + session.adjustWrapLimit(80); + + var selection = session.getSelection(); + + selection.moveCursorTo(0, 4); + selection.moveCursorUp(); + + assert.position(selection.getCursor(), 0, 0); + }, + + + "test go line down when in the middle of the last line should go to document end": function () { + var session = new AceAjax.EditSession("juhu kinners"); + var selection = session.getSelection(); + + selection.moveCursorTo(0, 4); + selection.moveCursorDown(); + + assert.position(selection.getCursor(), 0, 12); + }, + + "test (wrap) go line down when in the middle of the last line should go to document end": function () { + var session = new AceAjax.EditSession("juhu kinners"); + session.setWrapLimitRange(8, 8); + session.adjustWrapLimit(80); + + var selection = session.getSelection(); + + selection.moveCursorTo(0, 10); + selection.moveCursorDown(); + + assert.position(selection.getCursor(), 0, 12); + }, + + "test go line up twice and then once down when in the second should go back to the previous column": function () { + var session = new AceAjax.EditSession("juhu\nkinners"); + var selection = session.getSelection(); + + selection.moveCursorTo(1, 4); + selection.moveCursorUp(); + selection.moveCursorUp(); + selection.moveCursorDown(); + + assert.position(selection.getCursor(), 1, 4); + }, + + "test (keyboard navigation) when curLine is not EOL and targetLine is all whitespace new column should be current column": function () { + var session = new AceAjax.EditSession("function (a) {\n\ + \n\ +}"); + var selection = session.getSelection(); + + selection.moveCursorTo(2, 0); + selection.moveCursorUp(); + + assert.position(selection.getCursor(), 1, 0); + }, + + "test (keyboard navigation) when curLine is EOL and targetLine is shorter dan current column, new column should be targetLine's EOL": function () { + var session = new AceAjax.EditSession("function (a) {\n\ + \n\ +}"); + var selection = session.getSelection(); + + selection.moveCursorTo(0, 14); + selection.moveCursorDown(); + + assert.position(selection.getCursor(), 1, 4); + } +}; diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-selection-tests.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-selection-tests.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-selection-tests.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-token_iterator-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-token_iterator-tests.ts new file mode 100644 index 00000000..892d781b --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-token_iterator-tests.ts @@ -0,0 +1,168 @@ +/// + +var assert: any; +var mode: any; +var exports = { + "test: token iterator initialization in JavaScript document": function () { + var lines = [ + "function foo(items) {", + " for (var i=0; i= 0; i--) + assert.equal(iterator.stepBackward(), tokens[i]); + assert.equal(iterator.stepBackward(), null); + assert.equal(iterator.getCurrentToken(), null); + }, + + "test: token iterator reports correct row and column": function () { + var lines = [ + "function foo(items) {", + " for (var i=0; i + +var assert: any; +var exports = { + "test: screen2text the column should be rounded to the next character edge": function () { + var el = document.createElement("div"); + + if (!el.getBoundingClientRect) { + console.log("Skipping test: This test only runs in the browser"); + return; + } + + el.style.left = "20px"; + el.style.top = "30px"; + el.style.width = "300px"; + el.style.height = "100px"; + document.body.appendChild(el); + + var renderer = new AceAjax.VirtualRenderer(el); + renderer.setPadding(0); + renderer.setSession(new AceAjax.EditSession("1234")); + + var r = renderer.scroller.getBoundingClientRect(); + function testPixelToText(x, y, row, column) { + assert.position(renderer.screenToTextCoordinates(x + r.left, y + r.top), row, column); + } + + renderer.characterWidth = 10; + renderer.lineHeight = 15; + + testPixelToText(4, 0, 0, 0); + testPixelToText(5, 0, 0, 1); + testPixelToText(9, 0, 0, 1); + testPixelToText(10, 0, 0, 1); + testPixelToText(14, 0, 0, 1); + testPixelToText(15, 0, 0, 2); + document.body.removeChild(el); + } + + // change tab size after setDocument (for text layer) +}; diff --git a/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-virtual_renderer-tests.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-virtual_renderer-tests.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/ace/tests/ace-virtual_renderer-tests.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/README.md b/zeppelin-web/app/external/DefinitelyTyped/angularjs/README.md new file mode 100644 index 00000000..510f304f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/README.md @@ -0,0 +1,230 @@ +# AngularJS Definitions Usage Notes + +## Referencing AngularJS definition files in your code + +To do that, simply add `/// ` at the top of your code. + +That will make available to your code all interfaces AngularJS' main module **ng** implements, as well as the **AUTO** module. + +If you are including other AngularJS' modules in your code, like **ngResource**, just like you needed to include the additional module implementation file in your code, _angular-resource.js_, you will also need to reference the definitions file related to that module. Your code would then have the following definitions files reference: + + /// + /// + +Having these modules in separated files is actually good because they sometimes either augment or modify some of **ng**'s interfaces, and thus those differences should only be available to you when you really need them. Also, it forces you to explicit what you're going to be using. + +The following extra definition files are available for referencing: + +* angular-resource.d.ts (for the **ngResource** module) +* angular-route.d.ts (for the **ngRoute** module) +* angular-cookies.d.ts (for the **ngCookies** module) +* angular-sanitize.d.ts (for the **ngSanitize** module) +* angular-mocks.d.ts (for the **ngMock** and **ngMockE2E** modules) + +(postfix with version number for specific verion, eg. angular-resource-1.0.d.ts) + +## The Angular Static + +The definitions declare the AngularJS static variable `angular` as ambient. That means that, after referencing the AngularJS definition, you will be able to get type checks and code assistance for the global `angular` member. + + +## Definitions modularized + +To avoid cluttering the list of suggestions as you type in your IDE, all interfaces reside in their respective module namespace: + +* `ng` for AngularJS' **ng** module +* `ng.auto` for **AUTO** +* `ng.cookies` for **ngCookies** +* `ng.mock` for **ngMock** +* `ng.resource` for **ngResource** +* `ng.route` for **ngRoute** +* `ng.sanitize` for **ngSanitize** + +**ngMockE2E** does not define a new namespace, but rather modifies some of **ng**'s interfaces. + +Bellow is an example of how to use the interfaces: +```ts +function MainController($scope: ng.IScope, $http: ng.IHttpService) { + // code assistance will now be available for $scope and $http +} +``` + +## Services and other injectables + +AngularJS makes vast use of what it calls "injectable" functions. To put it simple, in AngularJS you are constantly annotating your functions and constructors with their dependencies, services that are going to be provided as arguments automagically during invocation. + +All known services interfaces have been defined, and were named using the following convention: + +**I + 'ServiceName' + 'Service'** + +So, for instance, the **$parse** service has it's interface defined as **ng.IParseService**. + +Service providers, by the same logic, follow this convention: + +**I + 'ServiceName' + 'Provider'** + +The **$httpProvider**, thus, is defined by **ng.IHttpProvider**. + + +## A word on $scope and assigning new members + +TypeScript allows for static checking. Among other obvious things, that means you're gonna have to extend interfaces when you need to augment an object whose interface has been defined, because otherwise the compiler will see it as an error to try to assign a value to a unspecified member. + +Consider the following ordinary code: +```ts +function Controller($scope) { + $scope.$broadcast('myEvent'); + $scope.title = 'Yabadabadu'; +} +``` +That will not produce any compilation error because the compiler does not know the first thing about $scope to do any checking. For that same reason, you will not get any assistance either. + +Now consider this: +```ts +function Controller($scope: ng.IScope) { + $scope.$broadcast('myEvent'); + $scope.title = 'Yabadabadu'; +} +``` + +Now we annotated `$scope` with the interface `ng.IScope`. The compiler now knows that, among other members, `$scope` has a method called `$broadcast`. That interface, however, does not define a `title` property. The compiler will complain about it. + +Since you are augmenting the $scope object, you should let the compiler know what to expect then: +```ts +interface ICustomScope extends ng.IScope { + title: string; +} + +function Controller($scope: ICustomScope) { + $scope.$broadcast('myEvent'); + $scope.title = 'Yabadabadu'; +} +``` + +## Examples + +### Working with $resource +```ts +/// +/// + +// We have the option to define arguments for a custom resource +interface IArticleParameters { + id: number; +} + +interface IArticleResource extends ng.resource.IResource { + title: string; + text: string; + date: Date; + author: number; + + // Although all actions defined on IArticleResourceClass are avaiable with + // the '$' prefix, we have the choice to expose only what we will use + $publish(): IArticleResource; + $unpublish(): IArticleResource; +} + +// Let's define a custom resource +interface IArticleResourceClass extends ng.resource.IResourceClass { + // Overload get to accept our custom parameters + get(): ng.resource.IResource; + get(params: IArticleParameters, onSuccess: Function): IArticleResource; + + // Add our custom resource actions + publish(): IArticleResource; + publish(params: IArticleParameters): IArticleResource; + unpublish(params: IArticleParameters): IArticleResource; +} + +function MainController($resource: ng.resource.IResourceService) { + + // IntelliSense will provide IActionDescriptor interface and will validate + // your assignment against it + var publishDescriptor: ng.resource.IActionDescriptor; + publishDescriptor = { + method: 'GET', + isArray: false + }; + + // I could still create a descriptor without the interface... + var unpublishDescriptor = { + method: 'POST' + } + + // A call to the $resource service returns a IResourceClass. Since + // our own IArticleResourceClass defines 2 more actions, we cast the return + // value to make the compiler aware of that + var articleResource = $resource('/articles/:id', null, { + publish : publishDescriptor, + unpublish : unpublishDescriptor + }); + + // Now we can do this + articleResource.unpublish({ id: 1 }); + + // IResourceClass.get() will be automatically available here + var article: IArticleResource = articleResource.get({id: 1}, function success() { + // Again, default + custom action here... + article.title = 'New Title'; + article.$save(); + article.$publish(); + }); +} +``` + +### Working with $resource in angular-1.0 definitions +```ts +/// +/// + +// Let's define a custom resource +interface IArticleResourceClass extends ng.resource.IResourceClass { + publish: ng.resource.IActionCall; + unpublish: ng.resource.IActionCall; +} +interface IArticleResource extends ng.resource.IResource { + title: string; + text: string; + date: Date; + author: number; + $publish: ng.resource.IActionCall; + $unpublish: ng.resource.IActionCall; +} + +function MainController($resource: ng.resource.IResourceService) { + + // IntelliSense will provide IActionDescriptor interface and will validate + // your assignment against it + var publishDescriptor: ng.resource.IActionDescriptor; + publishDescriptor = { + method: 'GET', + isArray: false + }; + + // I could still create a descriptor without the interface... + var unpublishDescriptor = { + method: 'POST' + } + + // A call to the $resource service returns a IResourceClass. Since + // our own IArticleResourceClass defines 2 more actions, we cast the return + // value to make the compiler aware of that + var articles = $resource('/articles/:id', null, { + publish : publishDescriptor, + unpublish : unpublishDescriptor + }); + + // Now we can do this + articles.unpublish({ id: 1 }); + + // IResourceClass.get() will be automatically available here + var article = articles.get({id: 1}); + + // Again, default + custom action here... + article.title = 'New Title'; + article.$save(); + article.$publish(); + +} +``` diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-animate.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-animate.d.ts new file mode 100644 index 00000000..a01c93ef --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-animate.d.ts @@ -0,0 +1,116 @@ +// Type definitions for Angular JS 1.3 (ngAnimate module) +// Project: http://angularjs.org +// Definitions by: Michel Salib , Adi Dahiya +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + + +/////////////////////////////////////////////////////////////////////////////// +// ngAnimate module (angular-animate.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.animate { + + /////////////////////////////////////////////////////////////////////////// + // AnimateService + // see http://docs.angularjs.org/api/ngAnimate/service/$animate + /////////////////////////////////////////////////////////////////////////// + interface IAnimateService extends ng.IAnimateService { + /** + * Globally enables / disables animations. + * + * @param value If provided then set the animation on or off. + * @param element If provided then the element will be used to represent the enable/disable operation. + * @returns current animation state + */ + enabled(value?: boolean, element?: JQuery): boolean; + + /** + * Appends the element to the parentElement element that resides in the document and then runs the enter animation. + * + * @param element the element that will be the focus of the enter animation + * @param parentElement the parent element of the element that will be the focus of the enter animation + * @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation + * @returns the animation callback promise + */ + enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery): ng.IPromise; + + /** + * Runs the leave animation operation and, upon completion, removes the element from the DOM. + * + * @param element the element that will be the focus of the leave animation + * @returns the animation callback promise + */ + leave(element: JQuery): ng.IPromise; + + /** + * Fires the move DOM operation. Just before the animation starts, the animate service will either append + * it into the parentElement container or add the element directly after the afterElement element if present. + * Then the move animation will be run. + * + * @param element the element that will be the focus of the move animation + * @param parentElement the parent element of the element that will be the focus of the move animation + * @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation + * @returns the animation callback promise + */ + move(element: JQuery, parentElement: JQuery, afterElement?: JQuery): ng.IPromise; + + /** + * Triggers a custom animation event based off the className variable and then attaches the className + * value to the element as a CSS class. + * + * @param element the element that will be animated + * @param className the CSS class that will be added to the element and then animated + * @returns the animation callback promise + */ + addClass(element: JQuery, className: string): ng.IPromise; + + /** + * Triggers a custom animation event based off the className variable and then removes the CSS class + * provided by the className value from the element. + * + * @param element the element that will be animated + * @param className the CSS class that will be animated and then removed from the element + * @returns the animation callback promise + */ + removeClass(element: JQuery, className: string): ng.IPromise; + + /** + * Adds and/or removes the given CSS classes to and from the element. Once complete, the done() callback + * will be fired (if provided). + * + * @param element the element which will have its CSS classes changed removed from it + * @param add the CSS classes which will be added to the element + * @param remove the CSS class which will be removed from the element CSS classes have been set on the element + * @returns the animation callback promise + */ + setClass(element: JQuery, add: string, remove: string): ng.IPromise; + + /** + * Cancels the provided animation. + */ + cancel(animationPromise: ng.IPromise): void; + } + + /////////////////////////////////////////////////////////////////////////// + // AngularProvider + // see http://docs.angularjs.org/api/ngAnimate/provider/$animateProvider + /////////////////////////////////////////////////////////////////////////// + interface IAnimateProvider { + /** + * Registers a new injectable animation factory function. + * + * @param name The name of the animation. + * @param factory The factory function that will be executed to return the animation object. + */ + register(name: string, factory: () => ng.IAnimateCallbackObject): void; + + /** + * Gets and/or sets the CSS class expression that is checked when performing an animation. + * + * @param expression The className expression which will be checked against all animations. + * @returns The current CSS className expression value. If null then there is no expression value. + */ + classNameFilter(expression?: RegExp): RegExp; + } +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-cookies.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-cookies.d.ts new file mode 100644 index 00000000..0feffae8 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-cookies.d.ts @@ -0,0 +1,32 @@ +// Type definitions for Angular JS 1.3 (ngCookies module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +/////////////////////////////////////////////////////////////////////////////// +// ngCookies module (angular-cookies.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.cookies { + + /////////////////////////////////////////////////////////////////////////// + // CookieService + // see http://docs.angularjs.org/api/ngCookies.$cookies + /////////////////////////////////////////////////////////////////////////// + interface ICookiesService { + [index: string]: any; + } + + /////////////////////////////////////////////////////////////////////////// + // CookieStoreService + // see http://docs.angularjs.org/api/ngCookies.$cookieStore + /////////////////////////////////////////////////////////////////////////// + interface ICookieStoreService { + get(key: string): any; + put(key: string, value: any): void; + remove(key: string): void; + } + +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-mocks-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-mocks-tests.ts new file mode 100644 index 00000000..e9cd2164 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-mocks-tests.ts @@ -0,0 +1,305 @@ +/// + +/////////////////////////////////////// +// IAngularStatic +/////////////////////////////////////// +var angular: ng.IAngularStatic; +var mock: ng.IMockStatic; + +mock = angular.mock; + + +/////////////////////////////////////// +// IMockStatic +/////////////////////////////////////// +var date: Date; + +mock.dump({ key: 'value' }); + +mock.inject( + function () { return 1; }, + function () { return 2; } + ); + +mock.inject( + ['$rootScope', function ($rootScope: ng.IRootScopeService) { return 1; }]); + +// This overload is not documented on the website, but flows from +// how the injector works. +mock.inject( + ['$rootScope', function ($rootScope: ng.IRootScopeService) { return 1; }], + ['$rootScope', function ($rootScope: ng.IRootScopeService) { return 2; }]); + +mock.module('module1', 'module2'); +mock.module( + function () { return 1; }, + function () { return 2; } + ); +mock.module({ module1: function () { return 1; } }); + +date = mock.TzDate(-7, '2013-1-1T15:00:00Z'); +date = mock.TzDate(-8, 12345678); + + +/////////////////////////////////////// +// IExceptionHandlerProvider +/////////////////////////////////////// +var exceptionHandlerProvider: ng.IExceptionHandlerProvider; + +exceptionHandlerProvider.mode('log'); + + +/////////////////////////////////////// +// ITimeoutService +/////////////////////////////////////// +var timeoutService: ng.ITimeoutService; + +timeoutService.flush(); +timeoutService.flush(1234); +timeoutService.flushNext(); +timeoutService.flushNext(1234); +timeoutService.verifyNoPendingTasks(); + +//////////////////////////////////////// +// IIntervalService +//////////////////////////////////////// +var intervalService: ng.IIntervalService; +var intervalServiceTimeActuallyAdvanced: number; + +intervalServiceTimeActuallyAdvanced = intervalService.flush(); +intervalServiceTimeActuallyAdvanced = intervalService.flush(1234); + +/////////////////////////////////////// +// ILogService, ILogCall +/////////////////////////////////////// +var logService: ng.ILogService; +var logCall: ng.ILogCall; +var logs: string[]; + +logService.assertEmpty(); +logService.reset(); + +logCall = logService.debug; +logCall = logService.error; +logCall = logService.info; +logCall = logService.log; +logCall = logService.warn; + +logs = logCall.logs; + + +/////////////////////////////////////// +// IHttpBackendService +/////////////////////////////////////// +var httpBackendService: ng.IHttpBackendService; +var requestHandler: ng.mock.IRequestHandler; + +httpBackendService.flush(); +httpBackendService.flush(1234); +httpBackendService.resetExpectations(); +httpBackendService.verifyNoOutstandingExpectation(); +httpBackendService.verifyNoOutstandingRequest(); + +requestHandler = httpBackendService.expect('GET', 'http://test.local'); +requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data'); +requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data', function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/); +requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/); +requestHandler = httpBackendService.expect('GET', /test.local/, 'response data'); +requestHandler = httpBackendService.expect('GET', /test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, 'response data', function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/, /response data/); +requestHandler = httpBackendService.expect('GET', /test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, /response data/, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; }); + +requestHandler = httpBackendService.expectDELETE('http://test.local'); +requestHandler = httpBackendService.expectDELETE('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.expectDELETE(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.expectGET('http://test.local'); +requestHandler = httpBackendService.expectGET('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.expectGET(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.expectHEAD('http://test.local'); +requestHandler = httpBackendService.expectHEAD('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.expectHEAD(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.expectJSONP('http://test.local'); +requestHandler = httpBackendService.expectJSONP(/test.local/); + +requestHandler = httpBackendService.expectPATCH('http://test.local'); +requestHandler = httpBackendService.expectPATCH('http://test.local', 'response data'); +requestHandler = httpBackendService.expectPATCH('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPATCH('http://test.local', /response data/); +requestHandler = httpBackendService.expectPATCH('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPATCH('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.expectPATCH('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/); +requestHandler = httpBackendService.expectPATCH(/test.local/, 'response data'); +requestHandler = httpBackendService.expectPATCH(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/, /response data/); +requestHandler = httpBackendService.expectPATCH(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.expectPOST('http://test.local'); +requestHandler = httpBackendService.expectPOST('http://test.local', 'response data'); +requestHandler = httpBackendService.expectPOST('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPOST('http://test.local', /response data/); +requestHandler = httpBackendService.expectPOST('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPOST('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPOST('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPOST('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.expectPOST('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/); +requestHandler = httpBackendService.expectPOST(/test.local/, 'response data'); +requestHandler = httpBackendService.expectPOST(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/, /response data/); +requestHandler = httpBackendService.expectPOST(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.expectPUT('http://test.local'); +requestHandler = httpBackendService.expectPUT('http://test.local', 'response data'); +requestHandler = httpBackendService.expectPUT('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPUT('http://test.local', /response data/); +requestHandler = httpBackendService.expectPUT('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPUT('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPUT('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPUT('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.expectPUT('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/); +requestHandler = httpBackendService.expectPUT(/test.local/, 'response data'); +requestHandler = httpBackendService.expectPUT(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/, /response data/); +requestHandler = httpBackendService.expectPUT(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.when('GET', 'http://test.local'); +requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data'); +requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data', function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/); +requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/); +requestHandler = httpBackendService.when('GET', /test.local/, 'response data'); +requestHandler = httpBackendService.when('GET', /test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, 'response data', function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/, /response data/); +requestHandler = httpBackendService.when('GET', /test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, /response data/, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; }); + +requestHandler = httpBackendService.whenDELETE('http://test.local'); +requestHandler = httpBackendService.whenDELETE('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.whenDELETE(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.whenGET('http://test.local'); +requestHandler = httpBackendService.whenGET('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.whenGET(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.whenHEAD('http://test.local'); +requestHandler = httpBackendService.whenHEAD('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.whenHEAD(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.whenJSONP('http://test.local'); +requestHandler = httpBackendService.whenJSONP(/test.local/); + +requestHandler = httpBackendService.whenPATCH('http://test.local'); +requestHandler = httpBackendService.whenPATCH('http://test.local', 'response data'); +requestHandler = httpBackendService.whenPATCH('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPATCH('http://test.local', /response data/); +requestHandler = httpBackendService.whenPATCH('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPATCH('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.whenPATCH('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/); +requestHandler = httpBackendService.whenPATCH(/test.local/, 'response data'); +requestHandler = httpBackendService.whenPATCH(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/); +requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.whenPOST('http://test.local'); +requestHandler = httpBackendService.whenPOST('http://test.local', 'response data'); +requestHandler = httpBackendService.whenPOST('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPOST('http://test.local', /response data/); +requestHandler = httpBackendService.whenPOST('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPOST('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPOST('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPOST('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.whenPOST('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/); +requestHandler = httpBackendService.whenPOST(/test.local/, 'response data'); +requestHandler = httpBackendService.whenPOST(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/, /response data/); +requestHandler = httpBackendService.whenPOST(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.whenPUT('http://test.local'); +requestHandler = httpBackendService.whenPUT('http://test.local', 'response data'); +requestHandler = httpBackendService.whenPUT('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPUT('http://test.local', /response data/); +requestHandler = httpBackendService.whenPUT('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPUT('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPUT('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPUT('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.whenPUT('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/); +requestHandler = httpBackendService.whenPUT(/test.local/, 'response data'); +requestHandler = httpBackendService.whenPUT(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/, /response data/); +requestHandler = httpBackendService.whenPUT(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' }, { header: 'value' }); + + +/////////////////////////////////////// +// IRequestHandler +/////////////////////////////////////// +requestHandler.passThrough(); +requestHandler.respond(function () { }); +requestHandler.respond({ key: 'value' }); +requestHandler.respond({ key: 'value' }, { header: 'value' }); +requestHandler.respond(404); +requestHandler.respond(404, { key: 'value' }); +requestHandler.respond(404, { key: 'value' }, { header: 'value' }); diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-mocks.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-mocks.d.ts new file mode 100644 index 00000000..87707112 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-mocks.d.ts @@ -0,0 +1,226 @@ +// Type definitions for Angular JS 1.3 (ngMock, ngMockE2E module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +/////////////////////////////////////////////////////////////////////////////// +// functions attached to global object (window) +/////////////////////////////////////////////////////////////////////////////// +declare var module: (...modules: any[]) => any; +declare var inject: (...fns: Function[]) => any; + +/////////////////////////////////////////////////////////////////////////////// +// ngMock module (angular-mocks.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng { + + /////////////////////////////////////////////////////////////////////////// + // AngularStatic + // We reopen it to add the MockStatic definition + /////////////////////////////////////////////////////////////////////////// + interface IAngularStatic { + mock: IMockStatic; + } + + interface IMockStatic { + // see http://docs.angularjs.org/api/angular.mock.dump + dump(obj: any): string; + + // see http://docs.angularjs.org/api/angular.mock.inject + inject(...fns: Function[]): any; + inject(...inlineAnnotatedConstructor: any[]): any; // this overload is undocumented, but works + + // see http://docs.angularjs.org/api/angular.mock.module + module(...modules: any[]): any; + + // see http://docs.angularjs.org/api/angular.mock.TzDate + TzDate(offset: number, timestamp: number): Date; + TzDate(offset: number, timestamp: string): Date; + } + + /////////////////////////////////////////////////////////////////////////// + // ExceptionHandlerService + // see http://docs.angularjs.org/api/ngMock.$exceptionHandler + // see http://docs.angularjs.org/api/ngMock.$exceptionHandlerProvider + /////////////////////////////////////////////////////////////////////////// + interface IExceptionHandlerProvider extends IServiceProvider { + mode(mode: string): void; + } + + /////////////////////////////////////////////////////////////////////////// + // TimeoutService + // see http://docs.angularjs.org/api/ngMock.$timeout + // Augments the original service + /////////////////////////////////////////////////////////////////////////// + interface ITimeoutService { + flush(delay?: number): void; + flushNext(expectedDelay?: number): void; + verifyNoPendingTasks(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // IntervalService + // see http://docs.angularjs.org/api/ngMock.$interval + // Augments the original service + /////////////////////////////////////////////////////////////////////////// + interface IIntervalService { + flush(millis?: number): number; + } + + /////////////////////////////////////////////////////////////////////////// + // LogService + // see http://docs.angularjs.org/api/ngMock.$log + // Augments the original service + /////////////////////////////////////////////////////////////////////////// + interface ILogService { + assertEmpty(): void; + reset(): void; + } + + interface ILogCall { + logs: string[]; + } + + /////////////////////////////////////////////////////////////////////////// + // HttpBackendService + // see http://docs.angularjs.org/api/ngMock.$httpBackend + /////////////////////////////////////////////////////////////////////////// + interface IHttpBackendService { + flush(count?: number): void; + resetExpectations(): void; + verifyNoOutstandingExpectation(): void; + verifyNoOutstandingRequest(): void; + + expect(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + + expectDELETE(url: string, headers?: Object): mock.IRequestHandler; + expectDELETE(url: RegExp, headers?: Object): mock.IRequestHandler; + expectGET(url: string, headers?: Object): mock.IRequestHandler; + expectGET(url: RegExp, headers?: Object): mock.IRequestHandler; + expectHEAD(url: string, headers?: Object): mock.IRequestHandler; + expectHEAD(url: RegExp, headers?: Object): mock.IRequestHandler; + expectJSONP(url: string): mock.IRequestHandler; + expectJSONP(url: RegExp): mock.IRequestHandler; + + expectPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler; + expectPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + expectPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler; + expectPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + expectPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler; + expectPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + when(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenDELETE(url: string, headers?: Object): mock.IRequestHandler; + whenDELETE(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + whenDELETE(url: RegExp, headers?: Object): mock.IRequestHandler; + whenDELETE(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenGET(url: string, headers?: Object): mock.IRequestHandler; + whenGET(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + whenGET(url: RegExp, headers?: Object): mock.IRequestHandler; + whenGET(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenHEAD(url: string, headers?: Object): mock.IRequestHandler; + whenHEAD(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + whenHEAD(url: RegExp, headers?: Object): mock.IRequestHandler; + whenHEAD(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenJSONP(url: string): mock.IRequestHandler; + whenJSONP(url: RegExp): mock.IRequestHandler; + + whenPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler; + whenPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + whenPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler; + whenPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + whenPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler; + whenPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + } + + export module mock { + + // returned interface by the the mocked HttpBackendService expect/when methods + interface IRequestHandler { + respond(func: Function): void; + respond(status: number, data?: any, headers?: any): void; + respond(data: any, headers?: any): void; + + // Available wehn ngMockE2E is loaded + passThrough(): void; + } + + } + +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-resource-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-resource-tests.ts new file mode 100644 index 00000000..c80cc662 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-resource-tests.ts @@ -0,0 +1,138 @@ +/// + +interface IMyResource extends ng.resource.IResource { }; +interface IMyResourceClass extends ng.resource.IResourceClass { }; + +/////////////////////////////////////// +// IActionDescriptor +/////////////////////////////////////// +var actionDescriptor: ng.resource.IActionDescriptor; + +actionDescriptor.headers = { header: 'value' }; +actionDescriptor.isArray = true; +actionDescriptor.method = 'method action'; +actionDescriptor.params = { key: 'value' }; + + +/////////////////////////////////////// +// IResourceClass +/////////////////////////////////////// +var resourceClass: IMyResourceClass; +var resource: IMyResource; +var resourceArray: ng.resource.IResourceArray; + +resource = resourceClass.delete(); +resource = resourceClass.delete({ key: 'value' }); +resource = resourceClass.delete({ key: 'value' }, function () { }); +resource = resourceClass.delete(function () { }); +resource = resourceClass.delete(function () { }, function () { }); +resource = resourceClass.delete({ key: 'value' }, { key: 'value' }); +resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }); +resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }, function () { }); +resource.$promise.then(function(data: IMyResource) {}); + +resource = resourceClass.get(); +resource = resourceClass.get({ key: 'value' }); +resource = resourceClass.get({ key: 'value' }, function () { }); +resource = resourceClass.get(function () { }); +resource = resourceClass.get(function () { }, function () { }); +resource = resourceClass.get({ key: 'value' }, { key: 'value' }); +resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { }); +resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + +resourceArray = resourceClass.query(); +resourceArray = resourceClass.query({ key: 'value' }); +resourceArray = resourceClass.query({ key: 'value' }, function () { }); +resourceArray = resourceClass.query(function () { }); +resourceArray = resourceClass.query(function () { }, function () { }); +resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }); +resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { }); +resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { }, function () { }); +resourceArray.push(resource); +resourceArray.$promise.then(function(data: ng.resource.IResourceArray) {}); + +resource = resourceClass.remove(); +resource = resourceClass.remove({ key: 'value' }); +resource = resourceClass.remove({ key: 'value' }, function () { }); +resource = resourceClass.remove(function () { }); +resource = resourceClass.remove(function () { }, function () { }); +resource = resourceClass.remove({ key: 'value' }, { key: 'value' }); +resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { }); +resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + +resource = resourceClass.save(); +resource = resourceClass.save({ key: 'value' }); +resource = resourceClass.save({ key: 'value' }, function () { }); +resource = resourceClass.save(function () { }); +resource = resourceClass.save(function () { }, function () { }); +resource = resourceClass.save({ key: 'value' }, { key: 'value' }); +resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { }); +resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + +/////////////////////////////////////// +// IResource +/////////////////////////////////////// + +var promise : ng.IPromise; +var arrayPromise : ng.IPromise; + +promise = resource.$delete(); +promise = resource.$delete({ key: 'value' }); +promise = resource.$delete({ key: 'value' }, function () { }); +promise = resource.$delete(function () { }); +promise = resource.$delete(function () { }, function () { }); +promise = resource.$delete({ key: 'value' }, function () { }, function () { }); +promise.then(function(data: IMyResource) {}); + +promise = resource.$get(); +promise = resource.$get({ key: 'value' }); +promise = resource.$get({ key: 'value' }, function () { }); +promise = resource.$get(function () { }); +promise = resource.$get(function () { }, function () { }); +promise = resource.$get({ key: 'value' }, function () { }, function () { }); + +arrayPromise = resourceArray[0].$query(); +arrayPromise = resourceArray[0].$query({ key: 'value' }); +arrayPromise = resourceArray[0].$query({ key: 'value' }, function () { }); +arrayPromise = resourceArray[0].$query(function () { }); +arrayPromise = resourceArray[0].$query(function () { }, function () { }); +arrayPromise = resourceArray[0].$query({ key: 'value' }, function () { }, function () { }); +arrayPromise.then(function(data: ng.resource.IResourceArray) {}); + +promise = resource.$remove(); +promise = resource.$remove({ key: 'value' }); +promise = resource.$remove({ key: 'value' }, function () { }); +promise = resource.$remove(function () { }); +promise = resource.$remove(function () { }, function () { }); +promise = resource.$remove({ key: 'value' }, function () { }, function () { }); + +promise = resource.$save(); +promise = resource.$save({ key: 'value' }); +promise = resource.$save({ key: 'value' }, function () { }); +promise = resource.$save(function () { }); +promise = resource.$save(function () { }, function () { }); +promise = resource.$save({ key: 'value' }, function () { }, function () { }); + +/////////////////////////////////////// +// IResourceService +/////////////////////////////////////// +var resourceService: ng.resource.IResourceService; +resourceClass = resourceService('test'); +resourceClass = resourceService('test'); +resourceClass = resourceService('test'); + +/////////////////////////////////////// +// IModule +/////////////////////////////////////// +var mod: ng.IModule; +var resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction; +var resourceService: ng.resource.IResourceService; + +resourceClass = resourceServiceFactoryFunction(resourceService); + +resourceServiceFactoryFunction = function (resourceService: ng.resource.IResourceService) { return resourceClass; }; +mod = mod.factory('factory name', resourceServiceFactoryFunction); + +/////////////////////////////////////// +// IResource +/////////////////////////////////////// \ No newline at end of file diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-resource.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-resource.d.ts new file mode 100644 index 00000000..ed08c77d --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-resource.d.ts @@ -0,0 +1,162 @@ +// Type definitions for Angular JS 1.3 (ngResource module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar , Michael Jess +// Definitions: https://github.com/daptiv/DefinitelyTyped + +/// + + +/////////////////////////////////////////////////////////////////////////////// +// ngResource module (angular-resource.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.resource { + + /** + * Currently supported options for the $resource factory options argument. + */ + interface IResourceOptions { + /** + * If true then the trailing slashes from any calculated URL will be stripped (defaults to true) + */ + stripTrailingSlashes?: boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // ResourceService + // see http://docs.angularjs.org/api/ngResource.$resource + // Most part of the following definitions were achieved by analyzing the + // actual implementation, since the documentation doesn't seem to cover + // that deeply. + /////////////////////////////////////////////////////////////////////////// + interface IResourceService { + (url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actions?: any, options?: IResourceOptions): IResourceClass>; + (url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actions?: any, options?: IResourceOptions): U; + (url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actions?: any, options?: IResourceOptions): IResourceClass; + } + + // Just a reference to facilitate describing new actions + interface IActionDescriptor { + method: string; + isArray?: boolean; + params?: any; + headers?: any; + } + + // Baseclass for everyresource with default actions. + // If you define your new actions for the resource, you will need + // to extend this interface and typecast the ResourceClass to it. + // + // In case of passing the first argument as anything but a function, + // it's gonna be considered data if the action method is POST, PUT or + // PATCH (in other words, methods with body). Otherwise, it's going + // to be considered as parameters to the request. + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L461-L465 + // + // Only those methods with an HTTP body do have 'data' as first parameter: + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L463 + // More specifically, those methods are POST, PUT and PATCH: + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L432 + // + // Also, static calls always return the IResource (or IResourceArray) retrieved + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L549 + interface IResourceClass { + new(dataOrParams? : any) : T; + get(): T; + get(params: Object): T; + get(success: Function, error?: Function): T; + get(params: Object, success: Function, error?: Function): T; + get(params: Object, data: Object, success?: Function, error?: Function): T; + + query(): IResourceArray; + query(params: Object): IResourceArray; + query(success: Function, error?: Function): IResourceArray; + query(params: Object, success: Function, error?: Function): IResourceArray; + query(params: Object, data: Object, success?: Function, error?: Function): IResourceArray; + + save(): T; + save(data: Object): T; + save(success: Function, error?: Function): T; + save(data: Object, success: Function, error?: Function): T; + save(params: Object, data: Object, success?: Function, error?: Function): T; + + remove(): T; + remove(params: Object): T; + remove(success: Function, error?: Function): T; + remove(params: Object, success: Function, error?: Function): T; + remove(params: Object, data: Object, success?: Function, error?: Function): T; + + delete(): T; + delete(params: Object): T; + delete(success: Function, error?: Function): T; + delete(params: Object, success: Function, error?: Function): T; + delete(params: Object, data: Object, success?: Function, error?: Function): T; + } + + // Instance calls always return the the promise of the request which retrieved the object + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L546 + interface IResource { + $get(): ng.IPromise; + $get(params?: Object, success?: Function, error?: Function): ng.IPromise; + $get(success: Function, error?: Function): ng.IPromise; + + $query(): ng.IPromise>; + $query(params?: Object, success?: Function, error?: Function): ng.IPromise>; + $query(success: Function, error?: Function): ng.IPromise>; + + $save(): ng.IPromise; + $save(params?: Object, success?: Function, error?: Function): ng.IPromise; + $save(success: Function, error?: Function): ng.IPromise; + + $remove(): ng.IPromise; + $remove(params?: Object, success?: Function, error?: Function): ng.IPromise; + $remove(success: Function, error?: Function): ng.IPromise; + + $delete(): ng.IPromise; + $delete(params?: Object, success?: Function, error?: Function): ng.IPromise; + $delete(success: Function, error?: Function): ng.IPromise; + + /** the promise of the original server interaction that created this instance. **/ + $promise : ng.IPromise; + $resolved : boolean; + } + + /** + * Really just a regular Array object with $promise and $resolve attached to it + */ + interface IResourceArray extends Array { + /** the promise of the original server interaction that created this collection. **/ + $promise : ng.IPromise>; + $resolved : boolean; + } + + /** when creating a resource factory via IModule.factory */ + interface IResourceServiceFactoryFunction { + ($resource: ng.resource.IResourceService): IResourceClass; + >($resource: ng.resource.IResourceService): U; + } +} + +/** extensions to base ng based on using angular-resource */ +declare module ng { + + interface IModule { + /** creating a resource service factory */ + factory(name: string, resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction): IModule; + } +} + +interface Array +{ + /** the promise of the original server interaction that created this collection. **/ + $promise : ng.IPromise>; + $resolved : boolean; +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-route-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-route-tests.ts new file mode 100644 index 00000000..3607b6f1 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-route-tests.ts @@ -0,0 +1,36 @@ +/// + +/** + * @license HTTP Auth Interceptor Module for AngularJS + * (c) 2013 Jonathan Park @ Daptiv Solutions Inc + * License: MIT + */ + +declare var $routeProvider: ng.route.IRouteProvider; +$routeProvider + .when('/projects/:projectId/dashboard', { + controller: 'I am a string', + templateUrl: "So am I", + caseInsensitiveMatch: true, + reloadOnSearch: false + }) + .when('/projects/:projectId/dashboard2', { + controller: function () { + //Look at me - I'm a function! + }, + template: function ($routeParams?: ng.route.IRouteParamsService) { + return "I return a string" + } + }) + .when('/projects/:projectId/dashboard3', { + controllerAs: 'I am a string', + template: "Yup. String" + }) + .when('/projects/:projectId/dashboard4', { + controller: 'I am a string', + templateUrl: function ($routeParams?: ng.route.IRouteParamsService) { + return "I return a string" + } + }) + .otherwise({ redirectTo: '/' }) + .otherwise({ redirectTo: ($routeParams?: ng.route.IRouteParamsService, $locationPath?: string, $locationSearch?: any) => "" }); diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-route.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-route.d.ts new file mode 100644 index 00000000..936b4258 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-route.d.ts @@ -0,0 +1,137 @@ +// Type definitions for Angular JS 1.3 (ngRoute module) +// Project: http://angularjs.org +// Definitions by: Jonathan Park +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + + +/////////////////////////////////////////////////////////////////////////////// +// ngRoute module (angular-route.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.route { + + /////////////////////////////////////////////////////////////////////////// + // RouteParamsService + // see http://docs.angularjs.org/api/ngRoute.$routeParams + /////////////////////////////////////////////////////////////////////////// + interface IRouteParamsService { + [key: string]: any; + } + + /////////////////////////////////////////////////////////////////////////// + // RouteService + // see http://docs.angularjs.org/api/ngRoute.$route + // see http://docs.angularjs.org/api/ngRoute.$routeProvider + /////////////////////////////////////////////////////////////////////////// + interface IRouteService { + reload(): void; + routes: any; + + // May not always be available. For instance, current will not be available + // to a controller that was not initialized as a result of a route maching. + current?: ICurrentRoute; + } + + + /** + * see http://docs.angularjs.org/api/ngRoute/provider/$routeProvider#when for API documentation + */ + interface IRoute { + /** + * {(string|function()=} + * Controller fn that should be associated with newly created scope or the name of a registered controller if passed as a string. + */ + controller?: string|Function; + /** + * A controller alias name. If present the controller will be published to scope under the controllerAs name. + */ + controllerAs?: string; + /** + * Undocumented? + */ + name?: string; + /** + * {string=|function()=} + * Html template as a string or a function that returns an html template as a string which should be used by ngView or ngInclude directives. This property takes precedence over templateUrl. + * + * If template is a function, it will be called with the following parameters: + * + * {Array.} - route parameters extracted from the current $location.path() by applying the current route + */ + template?: string|{($routeParams?: ng.route.IRouteParamsService) : string;} + /** + * {string=|function()=} + * Path or function that returns a path to an html template that should be used by ngView. + * + * If templateUrl is a function, it will be called with the following parameters: + * + * {Array.} - route parameters extracted from the current $location.path() by applying the current route + */ + templateUrl?: string|{ ($routeParams?: ng.route.IRouteParamsService): string; } + /** + * {Object.=} - An optional map of dependencies which should be injected into the controller. If any of these dependencies are promises, the router will wait for them all to be resolved or one to be rejected before the controller is instantiated. If all the promises are resolved successfully, the values of the resolved promises are injected and $routeChangeSuccess event is fired. If any of the promises are rejected the $routeChangeError event is fired. The map object is: + * + * - key - {string}: a name of a dependency to be injected into the controller. + * - factory - {string|function}: If string then it is an alias for a service. Otherwise if function, then it is injected and the return value is treated as the dependency. If the result is a promise, it is resolved before its value is injected into the controller. Be aware that ngRoute.$routeParams will still refer to the previous route within these resolve functions. Use $route.current.params to access the new route parameters, instead. + */ + resolve?: {[key: string]: any}; + /** + * {(string|function())=} + * Value to update $location path with and trigger route redirection. + * + * If redirectTo is a function, it will be called with the following parameters: + * + * - {Object.} - route parameters extracted from the current $location.path() by applying the current route templateUrl. + * - {string} - current $location.path() + * - {Object} - current $location.search() + * - The custom redirectTo function is expected to return a string which will be used to update $location.path() and $location.search(). + */ + redirectTo?: string|{($routeParams?: ng.route.IRouteParamsService, $locationPath?: string, $locationSearch?: any) : string}; + /** + * Reload route when only $location.search() or $location.hash() changes. + * + * This option defaults to true. If the option is set to false and url in the browser changes, then $routeUpdate event is broadcasted on the root scope. + */ + reloadOnSearch?: boolean; + /** + * Match routes without being case sensitive + * + * This option defaults to false. If the option is set to true, then the particular route can be matched without being case sensitive + */ + caseInsensitiveMatch?: boolean; + } + + // see http://docs.angularjs.org/api/ng.$route#current + interface ICurrentRoute extends IRoute { + locals: { + $scope: IScope; + $template: string; + }; + + params: any; + } + + interface IRouteProvider extends IServiceProvider { + /** + * Sets route definition that will be used on route change when no other route definition is matched. + * + * @params Mapping information to be assigned to $route.current. + */ + otherwise(params: IRoute): IRouteProvider; + /** + * Adds a new route definition to the $route service. + * + * @param path Route path (matched against $location.path). If $location.path contains redundant trailing slash or is missing one, the route will still match and the $location.path will be updated to add or drop the trailing slash to exactly match the route definition. + * + * - path can contain named groups starting with a colon: e.g. :name. All characters up to the next slash are matched and stored in $routeParams under the given name when the route matches. + * - path can contain named groups starting with a colon and ending with a star: e.g.:name*. All characters are eagerly stored in $routeParams under the given name when the route matches. + * - path can contain optional named groups with a question mark: e.g.:name?. + * + * For example, routes like /color/:color/largecode/:largecode*\/edit will match /color/brown/largecode/code/with/slashes/edit and extract: color: brown and largecode: code/with/slashes. + * + * @param route Mapping information to be assigned to $route.current on route match. + */ + when(path: string, route: IRoute): IRouteProvider; + } +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-sanitize-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-sanitize-tests.ts new file mode 100644 index 00000000..d065392c --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-sanitize-tests.ts @@ -0,0 +1,10 @@ +/// + +var shouldBeString: string; + +declare var $sanitizeService: ng.sanitize.ISanitizeService; +shouldBeString = $sanitizeService(shouldBeString); + +declare var $linky: ng.sanitize.filter.ILinky; +shouldBeString = $linky(shouldBeString); +shouldBeString = $linky(shouldBeString, shouldBeString); diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-sanitize.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-sanitize.d.ts new file mode 100644 index 00000000..6fde0bae --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-sanitize.d.ts @@ -0,0 +1,35 @@ +// Type definitions for Angular JS 1.3 (ngSanitize module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +/////////////////////////////////////////////////////////////////////////////// +// ngSanitize module (angular-sanitize.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.sanitize { + + /////////////////////////////////////////////////////////////////////////// + // SanitizeService + // see http://docs.angularjs.org/api/ngSanitize.$sanitize + /////////////////////////////////////////////////////////////////////////// + interface ISanitizeService { + (html: string): string; + } + + /////////////////////////////////////////////////////////////////////////// + // Filters included with the ngSanitize + // see https://github.com/angular/angular.js/tree/v1.2.0/src/ngSanitize/filter + /////////////////////////////////////////////////////////////////////////// + export module filter { + + // Finds links in text input and turns them into html links. + // Supports http/https/ftp/mailto and plain email address links. + // see http://code.angularjs.org/1.2.0/docs/api/ngSanitize.filter:linky + interface ILinky { + (text: string, target?: string): string; + } + } +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-tests.ts new file mode 100644 index 00000000..628b6d1d --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular-tests.ts @@ -0,0 +1,702 @@ +/// + +// issue: https://github.com/borisyankov/DefinitelyTyped/issues/369 +// https://github.com/witoldsz/angular-http-auth/blob/master/src/angular-http-auth.js +/** + * @license HTTP Auth Interceptor Module for AngularJS + * (c) 2012 Witold Szczerba + * License: MIT + */ + +class AuthService { + /** + * Holds all the requests which failed due to 401 response, + * so they can be re-requested in future, once login is completed. + */ + buffer: { config: ng.IRequestConfig; deferred: ng.IDeferred; }[] = []; + + /** + * Required by HTTP interceptor. + * Function is attached to provider to be invisible for regular users of this service. + */ + pushToBuffer = function(config: ng.IRequestConfig, deferred: ng.IDeferred) { + this.buffer.push({ + config: config, + deferred: deferred + }); + } + + $get = [ + '$rootScope', '$injector', function($rootScope: ng.IScope, $injector: ng.auto.IInjectorService) { + var $http: ng.IHttpService; //initialized later because of circular dependency problem + function retry(config: ng.IRequestConfig, deferred: ng.IDeferred) { + $http = $http || $injector.get('$http'); + $http(config).then(function (response) { + deferred.resolve(response); + }); + } + function retryAll() { + for (var i = 0; i < this.buffer.length; ++i) { + retry(this.buffer[i].config, this.buffer[i].deferred); + } + this.buffer = []; + } + + return { + loginConfirmed: function () { + $rootScope.$broadcast('event:auth-loginConfirmed'); + retryAll(); + } + } + } + ]; +} + +angular.module('http-auth-interceptor', []) + + .provider('authService', AuthService) + +/** + * $http interceptor. + * On 401 response - it stores the request and broadcasts 'event:angular-auth-loginRequired'. + */ + .config(['$httpProvider', 'authServiceProvider', function ($httpProvider: ng.IHttpProvider, authServiceProvider: any) { + + var interceptor = ['$rootScope', '$q', function ($rootScope: ng.IScope, $q: ng.IQService) { + function success(response: ng.IHttpPromiseCallbackArg) { + return response; + } + + function error(response: ng.IHttpPromiseCallbackArg) { + if (response.status === 401) { + var deferred = $q.defer(); + authServiceProvider.pushToBuffer(response.config, deferred); + $rootScope.$broadcast('event:auth-loginRequired'); + return deferred.promise; + } + // otherwise + return $q.reject(response); + } + + return function (promise: ng.IHttpPromise) { + return promise.then(success, error); + } + + }]; + $httpProvider.interceptors.push(interceptor); + }]); + + +module HttpAndRegularPromiseTests { + interface Person { + firstName: string; + lastName: string; + } + + interface ExpectedResponse extends Person { } + + interface SomeControllerScope extends ng.IScope { + person: Person; + theAnswer: number; + letters: string[]; + snack: string; + nothing?: string; + } + + var someController: Function = ($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) => { + $http.get("http://somewhere/some/resource") + .success((data: ExpectedResponse) => { + $scope.person = data; + }); + + $http.get("http://somewhere/some/resource") + .then((response: ng.IHttpPromiseCallbackArg) => { + // typing lost, so something like + // var i: number = response.data + // would type check + $scope.person = response.data; + }); + + $http.get("http://somewhere/some/resource") + .then((response: ng.IHttpPromiseCallbackArg) => { + // typing lost, so something like + // var i: number = response.data + // would NOT type check + $scope.person = response.data; + }); + + var aPromise: ng.IPromise = $q.when({ firstName: "Jack", lastName: "Sparrow" }); + aPromise.then((person: Person) => { + $scope.person = person; + }); + + var bPromise: ng.IPromise = $q.when(42); + bPromise.then((answer: number) => { + $scope.theAnswer = answer; + }); + + var cPromise: ng.IPromise = $q.when(["a", "b", "c"]); + cPromise.then((letters: string[]) => { + $scope.letters = letters; + }); + + // When $q.when is passed an IPromise, it returns an IPromise + var dPromise: ng.IPromise = $q.when($q.when("ALBATROSS!")); + dPromise.then((snack: string) => { + $scope.snack = snack; + }); + + // $q.when may be called without arguments + var ePromise: ng.IPromise = $q.when(); + ePromise.then(() => { + $scope.nothing = "really nothing"; + }); + } + + // Test that we can pass around a type-checked success/error Promise Callback + var anotherController: Function = ($scope: SomeControllerScope, $http: + ng.IHttpService, $q: ng.IQService) => { + + var buildFooData: Function = () => 42; + + var doFoo: Function = (callback: ng.IHttpPromiseCallback) => { + $http.get('/foo', buildFooData()) + .success(callback); + } + + doFoo((data: any) => console.log(data)); + } +} + +// Test for AngularJS Syntax + +module My.Namespace { + export var x: any; // need to export something for module to kick in +} + +// IModule Registering Test +var mod = angular.module('tests', []); +mod.controller('name', function ($scope: ng.IScope) { }) +mod.controller('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.controller(My.Namespace); +mod.directive('name', function ($scope: ng.IScope) { }) +mod.directive('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.directive(My.Namespace); +mod.factory('name', function ($scope: ng.IScope) { }) +mod.factory('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.factory(My.Namespace); +mod.filter('name', function ($scope: ng.IScope) { }) +mod.filter('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.filter(My.Namespace); +mod.provider('name', function ($scope: ng.IScope) { return { $get: () => { } } }) +mod.provider('name', TestProvider); +mod.provider('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.provider(My.Namespace); +mod.service('name', function ($scope: ng.IScope) { }) +mod.service('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.service(My.Namespace); +mod.constant('name', 23); +mod.constant('name', "23"); +mod.constant(My.Namespace); +mod.value('name', 23); +mod.value('name', "23"); +mod.value(My.Namespace); + +class TestProvider implements ng.IServiceProvider { + constructor(private $scope: ng.IScope) { + } + + $get() { + } +} + +// Promise signature tests +var foo: ng.IPromise; +foo.then((x) => { + // x is inferred to be a number + return "asdf"; +}).then((x) => { + // x is inferred to be string + x.length; + return 123; +}).then((x) => { + // x is infered to be a number + x.toFixed(); + return; +}).then((x) => { + // x is infered to be void + // Typescript will prevent you to actually use x as a local variable + // Try object: + return { a: 123 }; +}).then((x) => { + // Object is inferred here + x.a = 123; + //Try a promise + var y: ng.IPromise; + return y; +}).then((x) => { + // x is infered to be a number, which is the resolved value of a promise + x.toFixed(); +}); + + +var httpFoo: ng.IHttpPromise; +httpFoo.then((x) => { + // When returning a promise the generic type must be inferred. + var innerPromise : ng.IPromise; + return innerPromise; +}).then((x) => { + // must still be number. + x.toFixed(); +}); + +httpFoo.success((data, status, headers, config) => { + var h = headers("test"); + h.charAt(0); + var hs = headers(); + hs["content-type"].charAt(1); +}); + +function test_angular_forEach() { + var values: { [key: string]: string } = { name: 'misko', gender: 'male' }; + var log: string[] = []; + angular.forEach(values, function (value, key) { + this.push(key + ': ' + value); + }, log); + //expect(log).toEqual(['name: misko', 'gender: male']); +} + +// angular.element() tests +var element = angular.element("div.myApp"); +var scope: ng.IScope = element.scope(); +var isolateScope: ng.IScope = element.isolateScope(); + + + +function test_IAttributes(attributes: ng.IAttributes){ + return attributes; +} + +test_IAttributes({ + $addClass: function (classVal){}, + $removeClass: function(classVal){}, + $set: function(key, value){}, + $observe: function(name, fn){ + return fn; + }, + $attr: {} +}); + +class SampleDirective implements ng.IDirective { + public restrict = 'A'; + name = 'doh'; + + compile(templateElement: ng.IAugmentedJQuery) { + return { + post: this.link + }; + } + + static instance():ng.IDirective { + return new SampleDirective(); + } + + link(scope: ng.IScope) { + + } +} + +class SampleDirective2 implements ng.IDirective { + public restrict = 'EAC'; + + compile(templateElement: ng.IAugmentedJQuery) { + return { + pre: this.link + }; + } + + static instance():ng.IDirective { + return new SampleDirective2(); + } + + link(scope: ng.IScope) { + + } +} + +angular.module('SameplDirective', []).directive('sampleDirective', SampleDirective.instance).directive('sameplDirective2', SampleDirective2.instance); + +angular.module('AnotherSampleDirective', []).directive('myDirective', ['$interpolate', '$q', ($interpolate: ng.IInterpolateService, $q: ng.IQService) => { + return { + restrict: 'A', + link: (scope: ng.IScope, el: ng.IAugmentedJQuery, attr: ng.IAttributes) => { + $interpolate(attr['test'])(scope); + $interpolate('', true)(scope); + $interpolate('', true, 'html')(scope); + $interpolate('', true, 'html', true)(scope); + var defer = $q.defer(); + defer.reject(); + defer.resolve(); + defer.promise.then(function(d) { + return d; + }).then(function(): any { + return null; + }, function(): any { + return null; + }) + .catch((): any => { + return null; + }) + .finally((): any => { + return null; + }); + var promise = new $q((resolve) => { + resolve(); + }); + + promise = new $q((resolve, reject) => { + reject(); + resolve(true); + }); + + promise = new $q((resolver, reject) => { + resolver(true); + reject(false); + }); + } + }; +}]); + +// test from https://docs.angularjs.org/guide/directive +angular.module('docsSimpleDirective', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .directive('myCustomer', function() { + return { + template: 'Name: {{customer.name}} Address: {{customer.address}}' + }; + }); + +angular.module('docsTemplateUrlDirective', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .directive('myCustomer', function() { + return { + templateUrl: 'my-customer.html' + }; + }); + +angular.module('docsRestrictDirective', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + templateUrl: 'my-customer.html' + }; + }); + +angular.module('docsScopeProblemExample', []) + .controller('NaomiController', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .controller('IgorController', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Igor', + address: '123 Somewhere' + }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + templateUrl: 'my-customer.html' + }; + }); + +angular.module('docsIsolateScopeDirective', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' }; + $scope.igor = { name: 'Igor', address: '123 Somewhere' }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + scope: { + customerInfo: '=info' + }, + templateUrl: 'my-customer-iso.html' + }; + }); + +angular.module('docsIsolationExample', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' }; + $scope.vojta = { name: 'Vojta', address: '3456 Somewhere Else' }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + scope: { + customerInfo: '=info' + }, + templateUrl: 'my-customer-plus-vojta.html' + }; + }); + +angular.module('docsTimeDirective', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.format = 'M/d/yy h:mm:ss a'; + }]) + .directive('myCurrentTime', ['$interval', 'dateFilter', function($interval: any, dateFilter: any) { + + return { + link: function(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs:ng.IAttributes) { + var format: any, + timeoutId: any; + + function updateTime() { + element.text(dateFilter(new Date(), format)); + } + + scope.$watch(attrs['myCurrentTime'], function (value: any) { + format = value; + updateTime(); + }); + + element.on('$destroy', function () { + $interval.cancel(timeoutId); + }); + + // start the UI update process; save the timeoutId for canceling + timeoutId = $interval(function () { + updateTime(); // update DOM + }, 1000); + } + }; + }]); + +angular.module('docsTransclusionDirective', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.name = 'Tobias'; + }]) + .directive('myDialog', function() { + return { + restrict: 'E', + transclude: true, + templateUrl: 'my-dialog.html' + }; + }); + +angular.module('docsTransclusionExample', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.name = 'Tobias'; + }]) + .directive('myDialog', function() { + return { + restrict: 'E', + transclude: true, + scope: {}, + templateUrl: 'my-dialog.html', + link: function (scope: ng.IScope, element: ng.IAugmentedJQuery) { + scope['name'] = 'Jeff'; + } + }; + }); + +angular.module('docsIsoFnBindExample', []) + .controller('Controller', ['$scope', '$timeout', function($scope: any, $timeout: any) { + $scope.name = 'Tobias'; + $scope.hideDialog = function () { + $scope.dialogIsHidden = true; + $timeout(function () { + $scope.dialogIsHidden = false; + }, 2000); + }; + }]) + .directive('myDialog', function() { + return { + restrict: 'E', + transclude: true, + scope: { + 'close': '&onClose' + }, + templateUrl: 'my-dialog-close.html' + }; + }); + +angular.module('dragModule', []) + .directive('myDraggable', ['$document', function($document: any) { + return function(scope: any, element: any, attr: any) { + var startX = 0, startY = 0, x = 0, y = 0; + + element.css({ + position: 'relative', + border: '1px solid red', + backgroundColor: 'lightgrey', + cursor: 'pointer' + }); + + element.on('mousedown', function(event: any) { + // Prevent default dragging of selected content + event.preventDefault(); + startX = event.pageX - x; + startY = event.pageY - y; + $document.on('mousemove', mousemove); + $document.on('mouseup', mouseup); + }); + + function mousemove(event: any) { + y = event.pageY - startY; + x = event.pageX - startX; + element.css({ + top: y + 'px', + left: x + 'px' + }); + } + + function mouseup() { + $document.off('mousemove', mousemove); + $document.off('mouseup', mouseup); + } + }; + }]); + +angular.module('docsTabsExample', []) + .directive('myTabs', function() { + return { + restrict: 'E', + transclude: true, + scope: {}, + controller: function($scope: ng.IScope) { + var panes: any = $scope['panes'] = []; + + $scope['select'] = function(pane: any) { + angular.forEach(panes, function(pane: any) { + pane.selected = false; + }); + pane.selected = true; + }; + + this.addPane = function(pane: any) { + if (panes.length === 0) { + $scope['select'](pane); + } + panes.push(pane); + }; + }, + templateUrl: 'my-tabs.html' + }; + }) + .directive('myPane', function() { + return { + require: '^myTabs', + restrict: 'E', + transclude: true, + scope: { + title: '@' + }, + link: function(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, tabsCtrl: any) { + tabsCtrl.addPane(scope); + }, + templateUrl: 'my-pane.html' + }; + }); + +interface copyExampleUser { + name?: string; + email?: string; + gender?: string; +} + +interface copyExampleScope { + + user: copyExampleUser; + master: copyExampleUser; + update: (copyExampleUser: copyExampleUser) => any; + reset: () => any; +} + +angular.module('copyExample', []) + .controller('ExampleController', ['$scope', function ($scope: copyExampleScope) { + $scope.master = { }; + + $scope.update = function (user) { + // Example with 1 argument + $scope.master = angular.copy(user); + }; + + $scope.reset = function () { + // Example with 2 arguments + angular.copy($scope.master, $scope.user); + }; + + $scope.reset(); + }]); + +module locationTests { + + var $location: ng.ILocationService; + + /* + * From https://docs.angularjs.org/api/ng/service/$location + */ + + // given url http://example.com/#/some/path?foo=bar&baz=xoxo + var searchObject = $location.search(); + // => {foo: 'bar', baz: 'xoxo'} + + + // set foo to 'yipee' + $location.search('foo', 'yipee'); + // => $location + + // set foo to 5 + $location.search('foo', 5); + // => $location + + /* + * From: https://docs.angularjs.org/guide/$location + */ + + // in browser with HTML5 history support: + // open http://example.com/#!/a -> rewrite to http://example.com/a + // (replacing the http://example.com/#!/a history record) + $location.path() == '/a' + + $location.path('/foo'); + $location.absUrl() == 'http://example.com/foo' + + $location.search() == {} + $location.search({ a: 'b', c: true }); + $location.absUrl() == 'http://example.com/foo?a=b&c' + + $location.path('/new').search('x=y'); + $location.url() == 'new?x=y' + $location.absUrl() == 'http://example.com/new?x=y' + + // in browser without html5 history support: + // open http://example.com/new?x=y -> redirect to http://example.com/#!/new?x=y + // (again replacing the http://example.com/new?x=y history item) + $location.path() == '/new' + $location.search() == { x: 'y' } + + $location.path('/foo/bar'); + $location.path() == '/foo/bar' + $location.url() == '/foo/bar?x=y' + $location.absUrl() == 'http://example.com/#!/foo/bar?x=y' +} \ No newline at end of file diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular.d.ts new file mode 100755 index 00000000..f9ebda12 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/angular.d.ts @@ -0,0 +1,1535 @@ +// Type definitions for Angular JS 1.3+ +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +declare var angular: ng.IAngularStatic; + +// Support for painless dependency injection +interface Function { + $inject?: string[]; +} + +// Support AMD require +declare module 'angular' { + export = angular; +} + +/////////////////////////////////////////////////////////////////////////////// +// ng module (angular.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng { + + // not directly implemented, but ensures that constructed class implements $get + interface IServiceProviderClass { + new (...args: any[]): IServiceProvider; + } + + interface IServiceProviderFactory { + (...args: any[]): IServiceProvider; + } + + // All service providers extend this interface + interface IServiceProvider { + $get: any; + } + + interface IAngularBootstrapConfig { + strictDi?: boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // AngularStatic + // see http://docs.angularjs.org/api + /////////////////////////////////////////////////////////////////////////// + interface IAngularStatic { + bind(context: any, fn: Function, ...args: any[]): Function; + + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: string, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: string, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: string, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: JQuery, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: JQuery, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: JQuery, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: Element, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: Element, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: Element, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: Document, modules?: string, config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: Document, modules?: Function, config?: IAngularBootstrapConfig): auto.IInjectorService; + /** + * Use this function to manually start up angular application. + * + * @param element DOM element which is the root of angular application. + * @param modules An array of modules to load into the application. + * Each item in the array should be the name of a predefined module or a (DI annotated) + * function that will be invoked by the injector as a run block. + * @param config an object for defining configuration options for the application. The following keys are supported: + * - `strictDi`: disable automatic function annotation for the application. This is meant to assist in finding bugs which break minified code. + */ + bootstrap(element: Document, modules?: string[], config?: IAngularBootstrapConfig): auto.IInjectorService; + + /** + * Creates a deep copy of source, which should be an object or an array. + * + * - If no destination is supplied, a copy of the object or array is created. + * - If a destination is provided, all of its elements (for array) or properties (for objects) are deleted and then all elements/properties from the source are copied to it. + * - If source is not an object or array (inc. null and undefined), source is returned. + * - If source is identical to 'destination' an exception will be thrown. + * + * @param source The source that will be used to make a copy. Can be any type, including primitives, null, and undefined. + * @param destination Destination into which the source is copied. If provided, must be of the same type as source. + */ + copy(source: T, destination?: T): T; + + /** + * Wraps a raw DOM element or HTML string as a jQuery element. + * + * If jQuery is available, angular.element is an alias for the jQuery function. If jQuery is not available, angular.element delegates to Angular's built-in subset of jQuery, called "jQuery lite" or "jqLite." + */ + element: IAugmentedJQueryStatic; + equals(value1: any, value2: any): boolean; + extend(destination: any, ...sources: any[]): any; + + /** + * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional. + * + * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method. + * + * @param obj Object to iterate over. + * @param iterator Iterator function. + * @param context Object to become context (this) for the iterator function. + */ + forEach(obj: T[], iterator: (value: T, key: number) => any, context?: any): any; + /** + * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional. + * + * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method. + * + * @param obj Object to iterate over. + * @param iterator Iterator function. + * @param context Object to become context (this) for the iterator function. + */ + forEach(obj: { [index: string]: T; }, iterator: (value: T, key: string) => any, context?: any): any; + /** + * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional. + * + * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method. + * + * @param obj Object to iterate over. + * @param iterator Iterator function. + * @param context Object to become context (this) for the iterator function. + */ + forEach(obj: any, iterator: (value: any, key: any) => any, context?: any): any; + + fromJson(json: string): any; + identity(arg?: any): any; + injector(modules?: any[]): auto.IInjectorService; + isArray(value: any): boolean; + isDate(value: any): boolean; + isDefined(value: any): boolean; + isElement(value: any): boolean; + isFunction(value: any): boolean; + isNumber(value: any): boolean; + isObject(value: any): boolean; + isString(value: any): boolean; + isUndefined(value: any): boolean; + lowercase(str: string): string; + + /** + * The angular.module is a global place for creating, registering and retrieving Angular modules. All modules (angular core or 3rd party) that should be available to an application must be registered using this mechanism. + * + * When passed two or more arguments, a new module is created. If passed only one argument, an existing module (the name passed as the first argument to module) is retrieved. + * + * @param name The name of the module to create or retrieve. + * @param requires The names of modules this module depends on. If specified then new module is being created. If unspecified then the module is being retrieved for further configuration. + * @param configFn Optional configuration function for the module. + */ + module( + name: string, + requires?: string[], + configFn?: Function): IModule; + + noop(...args: any[]): void; + reloadWithDebugInfo(): void; + toJson(obj: any, pretty?: boolean): string; + uppercase(str: string): string; + version: { + full: string; + major: number; + minor: number; + dot: number; + codeName: string; + }; + } + + /////////////////////////////////////////////////////////////////////////// + // Module + // see http://docs.angularjs.org/api/angular.Module + /////////////////////////////////////////////////////////////////////////// + interface IModule { + animation(name: string, animationFactory: Function): IModule; + animation(name: string, inlineAnnotatedFunction: any[]): IModule; + animation(object: Object): IModule; + /** + * Use this method to register work which needs to be performed on module loading. + * + * @param configFn Execute this function on module load. Useful for service configuration. + */ + config(configFn: Function): IModule; + /** + * Use this method to register work which needs to be performed on module loading. + * + * @param inlineAnnotatedFunction Execute this function on module load. Useful for service configuration. + */ + config(inlineAnnotatedFunction: any[]): IModule; + /** + * Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator. + * + * @param name The name of the constant. + * @param value The constant value. + */ + constant(name: string, value: any): IModule; + constant(object: Object): IModule; + /** + * The $controller service is used by Angular to create new controllers. + * + * This provider allows controller registration via the register method. + * + * @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors. + * @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation). + */ + controller(name: string, controllerConstructor: Function): IModule; + /** + * The $controller service is used by Angular to create new controllers. + * + * This provider allows controller registration via the register method. + * + * @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors. + * @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation). + */ + controller(name: string, inlineAnnotatedConstructor: any[]): IModule; + controller(object: Object): IModule; + /** + * Register a new directive with the compiler. + * + * @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind) + * @param directiveFactory An injectable directive factory function. + */ + directive(name: string, directiveFactory: IDirectiveFactory): IModule; + /** + * Register a new directive with the compiler. + * + * @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind) + * @param directiveFactory An injectable directive factory function. + */ + directive(name: string, inlineAnnotatedFunction: any[]): IModule; + directive(object: Object): IModule; + /** + * Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider. + * + * @param name The name of the instance. + * @param $getFn The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}). + */ + factory(name: string, $getFn: Function): IModule; + /** + * Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider. + * + * @param name The name of the instance. + * @param inlineAnnotatedFunction The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}). + */ + factory(name: string, inlineAnnotatedFunction: any[]): IModule; + factory(object: Object): IModule; + filter(name: string, filterFactoryFunction: Function): IModule; + filter(name: string, inlineAnnotatedFunction: any[]): IModule; + filter(object: Object): IModule; + provider(name: string, serviceProviderFactory: IServiceProviderFactory): IModule; + provider(name: string, serviceProviderConstructor: IServiceProviderClass): IModule; + provider(name: string, inlineAnnotatedConstructor: any[]): IModule; + provider(name: string, providerObject: IServiceProvider): IModule; + provider(object: Object): IModule; + /** + * Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests. + */ + run(initializationFunction: Function): IModule; + /** + * Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests. + */ + run(inlineAnnotatedFunction: any[]): IModule; + service(name: string, serviceConstructor: Function): IModule; + service(name: string, inlineAnnotatedConstructor: any[]): IModule; + service(object: Object): IModule; + /** + * Register a value service with the $injector, such as a string, a number, an array, an object or a function. This is short for registering a service where its provider's $get property is a factory function that takes no arguments and returns the value service. + + Value services are similar to constant services, except that they cannot be injected into a module configuration function (see config) but they can be overridden by an Angular decorator. + * + * @param name The name of the instance. + * @param value The value. + */ + value(name: string, value: any): IModule; + value(object: Object): IModule; + + // Properties + name: string; + requires: string[]; + } + + /////////////////////////////////////////////////////////////////////////// + // Attributes + // see http://docs.angularjs.org/api/ng.$compile.directive.Attributes + /////////////////////////////////////////////////////////////////////////// + interface IAttributes { + /** + * this is necessary to be able to access the scoped attributes. it's not very elegant + * because you have to use attrs['foo'] instead of attrs.foo but I don't know of a better way + * this should really be limited to return string but it creates this problem: http://stackoverflow.com/q/17201854/165656 + */ + [name: string]: any; + + /** + * Adds the CSS class value specified by the classVal parameter to the + * element. If animations are enabled then an animation will be triggered + * for the class addition. + */ + $addClass(classVal: string): void; + + /** + * Removes the CSS class value specified by the classVal parameter from the + * element. If animations are enabled then an animation will be triggered for + * the class removal. + */ + $removeClass(classVal: string): void; + + /** + * Set DOM element attribute value. + */ + $set(key: string, value: any): void; + + /** + * Observes an interpolated attribute. + * The observer function will be invoked once during the next $digest + * following compilation. The observer is then invoked whenever the + * interpolated value changes. + */ + $observe(name: string, fn: (value?: any) => any): Function; + + /** + * A map of DOM element attribute names to the normalized name. This is needed + * to do reverse lookup from normalized name back to actual name. + */ + $attr: Object; + } + + /** + * form.FormController - type in module ng + * see https://docs.angularjs.org/api/ng/type/form.FormController + */ + interface IFormController { + + /** + * Indexer which should return ng.INgModelController for most properties but cannot because of "All named properties must be assignable to string indexer type" constraint - see https://github.com/Microsoft/TypeScript/issues/272 + */ + [name: string]: any; + + $pristine: boolean; + $dirty: boolean; + $valid: boolean; + $invalid: boolean; + $submitted: boolean; + $error: any; + $addControl(control: ng.INgModelController): void; + $removeControl(control: ng.INgModelController): void; + $setValidity(validationErrorKey: string, isValid: boolean, control: ng.INgModelController): void; + $setDirty(): void; + $setPristine(): void; + $commitViewValue(): void; + $rollbackViewValue(): void; + $setSubmitted(): void; + $setUntouched(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // NgModelController + // see http://docs.angularjs.org/api/ng.directive:ngModel.NgModelController + /////////////////////////////////////////////////////////////////////////// + interface INgModelController { + $render(): void; + $setValidity(validationErrorKey: string, isValid: boolean): void; + // Documentation states viewValue and modelValue to be a string but other + // types do work and it's common to use them. + $setViewValue(value: any, trigger?: string): void; + $setPristine(): void; + $validate(): void; + $setTouched(): void; + $setUntouched(): void; + $rollbackViewValue(): void; + $commitViewValue(): void; + $isEmpty(value: any): boolean; + + $viewValue: any; + + $modelValue: any; + + $parsers: IModelParser[]; + $formatters: IModelFormatter[]; + $viewChangeListeners: IModelViewChangeListener[]; + $error: any; + $name: string; + + $touched: boolean; + $untouched: boolean; + + $validators: IModelValidators; + $asyncValidators: IAsyncModelValidators; + + $pending: any; + $pristine: boolean; + $dirty: boolean; + $valid: boolean; + $invalid: boolean; + } + + interface IModelValidators { + [index: string]: (...args: any[]) => boolean; + } + + interface IAsyncModelValidators { + [index: string]: (...args: any[]) => ng.IPromise; + } + + interface IModelParser { + (value: any): any; + } + + interface IModelFormatter { + (value: any): any; + } + + interface IModelViewChangeListener { + (): void; + } + + /** + * $rootScope - $rootScopeProvider - service in module ng + * see https://docs.angularjs.org/api/ng/type/$rootScope.Scope and https://docs.angularjs.org/api/ng/service/$rootScope + */ + interface IRootScopeService { + [index: string]: any; + + $apply(): any; + $apply(exp: string): any; + $apply(exp: (scope: IScope) => any): any; + + $applyAsync(): any; + $applyAsync(exp: string): any; + $applyAsync(exp: (scope: IScope) => any): any; + + $broadcast(name: string, ...args: any[]): IAngularEvent; + $destroy(): void; + $digest(): void; + $emit(name: string, ...args: any[]): IAngularEvent; + + $eval(): any; + $eval(expression: string, locals?: Object): any; + $eval(expression: (scope: IScope) => any, locals?: Object): any; + + $evalAsync(): void; + $evalAsync(expression: string): void; + $evalAsync(expression: (scope: IScope) => any): void; + + // Defaults to false by the implementation checking strategy + $new(isolate?: boolean, parent?: IScope): IScope; + + /** + * Listens on events of a given type. See $emit for discussion of event life cycle. + * + * The event listener function format is: function(event, args...). + * + * @param name Event name to listen on. + * @param listener Function to call when the event is emitted. + */ + $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function; + + $watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function; + $watch(watchExpression: string, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function; + $watch(watchExpression: (scope: IScope) => any, listener?: string, objectEquality?: boolean): Function; + $watch(watchExpression: (scope: IScope) => any, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function; + + $watchCollection(watchExpression: string, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; + $watchCollection(watchExpression: (scope: IScope) => any, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; + + $watchGroup(watchExpressions: any[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; + $watchGroup(watchExpressions: { (scope: IScope): any }[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; + + $parent: IScope; + $root: IRootScopeService; + $id: number; + + // Hidden members + $$isolateBindings: any; + $$phase: any; + } + + interface IScope extends IRootScopeService { } + + interface IAngularEvent { + /** + * the scope on which the event was $emit-ed or $broadcast-ed. + */ + targetScope: IScope; + /** + * the scope that is currently handling the event. Once the event propagates through the scope hierarchy, this property is set to null. + */ + currentScope: IScope; + /** + * name of the event. + */ + name: string; + /** + * calling stopPropagation function will cancel further event propagation (available only for events that were $emit-ed). + */ + stopPropagation?: Function; + /** + * calling preventDefault sets defaultPrevented flag to true. + */ + preventDefault: Function; + /** + * true if preventDefault was called. + */ + defaultPrevented: boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // WindowService + // see http://docs.angularjs.org/api/ng.$window + /////////////////////////////////////////////////////////////////////////// + interface IWindowService extends Window { + [key: string]: any; + } + + /////////////////////////////////////////////////////////////////////////// + // BrowserService + // TODO undocumented, so we need to get it from the source code + /////////////////////////////////////////////////////////////////////////// + interface IBrowserService { + [key: string]: any; + } + + /////////////////////////////////////////////////////////////////////////// + // TimeoutService + // see http://docs.angularjs.org/api/ng.$timeout + /////////////////////////////////////////////////////////////////////////// + interface ITimeoutService { + (func: Function, delay?: number, invokeApply?: boolean): IPromise; + cancel(promise: IPromise): boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // IntervalService + // see http://docs.angularjs.org/api/ng.$interval + /////////////////////////////////////////////////////////////////////////// + interface IIntervalService { + (func: Function, delay: number, count?: number, invokeApply?: boolean): IPromise; + cancel(promise: IPromise): boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // AngularProvider + // see http://docs.angularjs.org/api/ng/provider/$animateProvider + /////////////////////////////////////////////////////////////////////////// + interface IAnimateProvider { + /** + * Registers a new injectable animation factory function. + * + * @param name The name of the animation. + * @param factory The factory function that will be executed to return the animation object. + */ + register(name: string, factory: () => IAnimateCallbackObject): void; + + /** + * Gets and/or sets the CSS class expression that is checked when performing an animation. + * + * @param expression The className expression which will be checked against all animations. + * @returns The current CSS className expression value. If null then there is no expression value. + */ + classNameFilter(expression?: RegExp): RegExp; + } + + /** + * The animation object which contains callback functions for each event that is expected to be animated. + */ + interface IAnimateCallbackObject { + eventFn(element: Node, doneFn: () => void): Function; + } + + /////////////////////////////////////////////////////////////////////////// + // FilterService + // see http://docs.angularjs.org/api/ng.$filter + // see http://docs.angularjs.org/api/ng.$filterProvider + /////////////////////////////////////////////////////////////////////////// + interface IFilterService { + (name: string): Function; + } + + interface IFilterProvider extends IServiceProvider { + register(name: string, filterFactory: Function): IServiceProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // LocaleService + // see http://docs.angularjs.org/api/ng.$locale + /////////////////////////////////////////////////////////////////////////// + interface ILocaleService { + id: string; + + // These are not documented + // Check angular's i18n files for exemples + NUMBER_FORMATS: ILocaleNumberFormatDescriptor; + DATETIME_FORMATS: ILocaleDateTimeFormatDescriptor; + pluralCat: (num: any) => string; + } + + interface ILocaleNumberFormatDescriptor { + DECIMAL_SEP: string; + GROUP_SEP: string; + PATTERNS: ILocaleNumberPatternDescriptor[]; + CURRENCY_SYM: string; + } + + interface ILocaleNumberPatternDescriptor { + minInt: number; + minFrac: number; + maxFrac: number; + posPre: string; + posSuf: string; + negPre: string; + negSuf: string; + gSize: number; + lgSize: number; + } + + interface ILocaleDateTimeFormatDescriptor { + MONTH: string[]; + SHORTMONTH: string[]; + DAY: string[]; + SHORTDAY: string[]; + AMPMS: string[]; + medium: string; + short: string; + fullDate: string; + longDate: string; + mediumDate: string; + shortDate: string; + mediumTime: string; + shortTime: string; + } + + /////////////////////////////////////////////////////////////////////////// + // LogService + // see http://docs.angularjs.org/api/ng.$log + // see http://docs.angularjs.org/api/ng.$logProvider + /////////////////////////////////////////////////////////////////////////// + interface ILogService { + debug: ILogCall; + error: ILogCall; + info: ILogCall; + log: ILogCall; + warn: ILogCall; + } + + interface ILogProvider { + debugEnabled(): boolean; + debugEnabled(enabled: boolean): ILogProvider; + } + + // We define this as separate interface so we can reopen it later for + // the ngMock module. + interface ILogCall { + (...args: any[]): void; + } + + /////////////////////////////////////////////////////////////////////////// + // ParseService + // see http://docs.angularjs.org/api/ng.$parse + // see http://docs.angularjs.org/api/ng.$parseProvider + /////////////////////////////////////////////////////////////////////////// + interface IParseService { + (expression: string): ICompiledExpression; + } + + interface IParseProvider { + logPromiseWarnings(): boolean; + logPromiseWarnings(value: boolean): IParseProvider; + + unwrapPromises(): boolean; + unwrapPromises(value: boolean): IParseProvider; + } + + interface ICompiledExpression { + (context: any, locals?: any): any; + + // If value is not provided, undefined is gonna be used since the implementation + // does not check the parameter. Let's force a value for consistency. If consumer + // whants to undefine it, pass the undefined value explicitly. + assign(context: any, value: any): any; + } + + /** + * $location - $locationProvider - service in module ng + * see https://docs.angularjs.org/api/ng/service/$location + */ + interface ILocationService { + absUrl(): string; + hash(): string; + hash(newHash: string): ILocationService; + host(): string; + + /** + * Return path of current url + */ + path(): string; + + /** + * Change path when called with parameter and return $location. + * Note: Path should always begin with forward slash (/), this method will add the forward slash if it is missing. + * + * @param path New path + */ + path(path: string): ILocationService; + + port(): number; + protocol(): string; + replace(): ILocationService; + + /** + * Return search part (as object) of current url + */ + search(): any; + + /** + * Change search part when called with parameter and return $location. + * + * @param search When called with a single argument the method acts as a setter, setting the search component of $location to the specified value. + * + * If the argument is a hash object containing an array of values, these values will be encoded as duplicate search parameters in the url. + */ + search(search: any): ILocationService; + + /** + * Change search part when called with parameter and return $location. + * + * @param search New search params + * @param paramValue If search is a string or a Number, then paramValue will override only a single search property. If paramValue is null, the property specified via the first argument will be deleted. If paramValue is an array, it will override the property of the search component of $location specified via the first argument. If paramValue is true, the property specified via the first argument will be added with no value nor trailing equal sign. + */ + search(search: string, paramValue: string|number|string[]|boolean): ILocationService; + + state(): any; + state(state: any): ILocationService; + url(): string; + url(url: string): ILocationService; + } + + interface ILocationProvider extends IServiceProvider { + hashPrefix(): string; + hashPrefix(prefix: string): ILocationProvider; + html5Mode(): boolean; + + // Documentation states that parameter is string, but + // implementation tests it as boolean, which makes more sense + // since this is a toggler + html5Mode(active: boolean): ILocationProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // DocumentService + // see http://docs.angularjs.org/api/ng.$document + /////////////////////////////////////////////////////////////////////////// + interface IDocumentService extends IAugmentedJQuery {} + + /////////////////////////////////////////////////////////////////////////// + // ExceptionHandlerService + // see http://docs.angularjs.org/api/ng.$exceptionHandler + /////////////////////////////////////////////////////////////////////////// + interface IExceptionHandlerService { + (exception: Error, cause?: string): void; + } + + /////////////////////////////////////////////////////////////////////////// + // RootElementService + // see http://docs.angularjs.org/api/ng.$rootElement + /////////////////////////////////////////////////////////////////////////// + interface IRootElementService extends JQuery {} + + interface IQResolveReject { + (): void; + (value: T): void; + } + /** + * $q - service in module ng + * A promise/deferred implementation inspired by Kris Kowal's Q. + * See http://docs.angularjs.org/api/ng/service/$q + */ + interface IQService { + new (resolver: (resolve: IQResolveReject) => any): IPromise; + new (resolver: (resolve: IQResolveReject, reject: IQResolveReject) => any): IPromise; + new (resolver: (resolve: IQResolveReject, reject: IQResolveReject) => any): IPromise; + + /** + * Combines multiple promises into a single promise that is resolved when all of the input promises are resolved. + * + * Returns a single promise that will be resolved with an array/hash of values, each value corresponding to the promise at the same index/key in the promises array/hash. If any of the promises is resolved with a rejection, this resulting promise will be rejected with the same rejection value. + * + * @param promises An array or hash of promises. + */ + all(promises: IPromise[]|{ [id: string]: IPromise; }): IPromise; + /** + * Creates a Deferred object which represents a task which will finish in the future. + */ + defer(): IDeferred; + /** + * Creates a promise that is resolved as rejected with the specified reason. This api should be used to forward rejection in a chain of promises. If you are dealing with the last promise in a promise chain, you don't need to worry about it. + * + * When comparing deferreds/promises to the familiar behavior of try/catch/throw, think of reject as the throw keyword in JavaScript. This also means that if you "catch" an error via a promise error callback and you want to forward the error to the promise derived from the current promise, you have to "rethrow" the error by returning a rejection constructed via reject. + * + * @param reason Constant, message, exception or an object representing the rejection reason. + */ + reject(reason?: any): IPromise; + /** + * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted. + * + * @param value Value or a promise + */ + when(value: IPromise|T): IPromise; + /** + * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted. + * + * @param value Value or a promise + */ + when(): IPromise; + } + + interface IPromise { + /** + * Regardless of when the promise was or will be resolved or rejected, then calls one of the success or error callbacks asynchronously as soon as the result is available. The callbacks are called with a single argument: the result or rejection reason. Additionally, the notify callback may be called zero or more times to provide a progress indication, before the promise is resolved or rejected. + * + * This method returns a new promise which is resolved or rejected via the return value of the successCallback, errorCallback. It also notifies via the return value of the notifyCallback method. The promise can not be resolved or rejected from the notifyCallback method. + */ + then(successCallback: (promiseValue: T) => IHttpPromise|IPromise|TResult, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise; + + /** + * Shorthand for promise.then(null, errorCallback) + */ + catch(onRejected: (reason: any) => IHttpPromise|IPromise|TResult): IPromise; + + /** + * Allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful to release resources or do some clean-up that needs to be done whether the promise was rejected or resolved. See the full specification for more information. + * + * Because finally is a reserved word in JavaScript and reserved keywords are not supported as property names by ES3, you'll need to invoke the method like promise['finally'](callback) to make your code IE8 and Android 2.x compatible. + */ + finally(finallyCallback: () => any): IPromise; + } + + interface IDeferred { + resolve(value?: T): void; + reject(reason?: any): void; + notify(state?: any): void; + promise: IPromise; + } + + /////////////////////////////////////////////////////////////////////////// + // AnchorScrollService + // see http://docs.angularjs.org/api/ng.$anchorScroll + /////////////////////////////////////////////////////////////////////////// + interface IAnchorScrollService { + (): void; + yOffset: any; + } + + interface IAnchorScrollProvider extends IServiceProvider { + disableAutoScrolling(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // CacheFactoryService + // see http://docs.angularjs.org/api/ng.$cacheFactory + /////////////////////////////////////////////////////////////////////////// + interface ICacheFactoryService { + // Lets not foce the optionsMap to have the capacity member. Even though + // it's the ONLY option considered by the implementation today, a consumer + // might find it useful to associate some other options to the cache object. + //(cacheId: string, optionsMap?: { capacity: number; }): CacheObject; + (cacheId: string, optionsMap?: { capacity: number; }): ICacheObject; + + // Methods bellow are not documented + info(): any; + get(cacheId: string): ICacheObject; + } + + interface ICacheObject { + info(): { + id: string; + size: number; + + // Not garanteed to have, since it's a non-mandatory option + //capacity: number; + }; + put(key: string, value?: any): void; + get(key: string): any; + remove(key: string): void; + removeAll(): void; + destroy(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // CompileService + // see http://docs.angularjs.org/api/ng.$compile + // see http://docs.angularjs.org/api/ng.$compileProvider + /////////////////////////////////////////////////////////////////////////// + interface ICompileService { + (element: string, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction; + (element: Element, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction; + (element: JQuery, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction; + } + + interface ICompileProvider extends IServiceProvider { + directive(name: string, directiveFactory: Function): ICompileProvider; + + // Undocumented, but it is there... + directive(directivesMap: any): ICompileProvider; + + aHrefSanitizationWhitelist(): RegExp; + aHrefSanitizationWhitelist(regexp: RegExp): ICompileProvider; + + imgSrcSanitizationWhitelist(): RegExp; + imgSrcSanitizationWhitelist(regexp: RegExp): ICompileProvider; + + debugInfoEnabled(enabled?: boolean): any; + } + + interface ICloneAttachFunction { + // Let's hint but not force cloneAttachFn's signature + (clonedElement?: JQuery, scope?: IScope): any; + } + + // This corresponds to the "publicLinkFn" returned by $compile. + interface ITemplateLinkingFunction { + (scope: IScope, cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery; + } + + // This corresponds to $transclude (and also the transclude function passed to link). + interface ITranscludeFunction { + // If the scope is provided, then the cloneAttachFn must be as well. + (scope: IScope, cloneAttachFn: ICloneAttachFunction): IAugmentedJQuery; + // If one argument is provided, then it's assumed to be the cloneAttachFn. + (cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery; + } + + /////////////////////////////////////////////////////////////////////////// + // ControllerService + // see http://docs.angularjs.org/api/ng.$controller + // see http://docs.angularjs.org/api/ng.$controllerProvider + /////////////////////////////////////////////////////////////////////////// + interface IControllerService { + // Although the documentation doesn't state this, locals are optional + (controllerConstructor: Function, locals?: any): any; + (controllerName: string, locals?: any): any; + } + + interface IControllerProvider extends IServiceProvider { + register(name: string, controllerConstructor: Function): void; + register(name: string, dependencyAnnotatedConstructor: any[]): void; + allowGlobals(): void; + } + + /** + * HttpService + * see http://docs.angularjs.org/api/ng/service/$http + */ + interface IHttpService { + /** + * Object describing the request to be made and how it should be processed. + */ + (config: IRequestConfig): IHttpPromise; + + /** + * Shortcut method to perform GET request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param config Optional configuration object + */ + get(url: string, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform DELETE request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param config Optional configuration object + */ + delete(url: string, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform HEAD request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param config Optional configuration object + */ + head(url: string, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform JSONP request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param config Optional configuration object + */ + jsonp(url: string, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform POST request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param data Request content + * @param config Optional configuration object + */ + post(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform PUT request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param data Request content + * @param config Optional configuration object + */ + put(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Runtime equivalent of the $httpProvider.defaults property. Allows configuration of default headers, withCredentials as well as request and response transformations. + */ + defaults: IRequestConfig; + + /** + * Array of config objects for currently pending requests. This is primarily meant to be used for debugging purposes. + */ + pendingRequests: any[]; + } + + /** + * Object describing the request to be made and how it should be processed. + * see http://docs.angularjs.org/api/ng/service/$http#usage + */ + interface IRequestShortcutConfig { + /** + * {Object.} + * Map of strings or objects which will be turned to ?key1=value1&key2=value2 after the url. If the value is not a string, it will be JSONified. + */ + params?: any; + + /** + * Map of strings or functions which return strings representing HTTP headers to send to the server. If the return value of a function is null, the header will not be sent. + */ + headers?: any; + + /** + * Name of HTTP header to populate with the XSRF token. + */ + xsrfHeaderName?: string; + + /** + * Name of cookie containing the XSRF token. + */ + xsrfCookieName?: string; + + /** + * {boolean|Cache} + * If true, a default $http cache will be used to cache the GET request, otherwise if a cache instance built with $cacheFactory, this cache will be used for caching. + */ + cache?: any; + + /** + * whether to to set the withCredentials flag on the XHR object. See [requests with credentials]https://developer.mozilla.org/en/http_access_control#section_5 for more information. + */ + withCredentials?: boolean; + + /** + * {string|Object} + * Data to be sent as the request message data. + */ + data?: any; + + /** + * {function(data, headersGetter)|Array.} + * Transform function or an array of such functions. The transform function takes the http request body and headers and returns its transformed (typically serialized) version. + */ + transformRequest?: any; + + /** + * {function(data, headersGetter)|Array.} + * Transform function or an array of such functions. The transform function takes the http response body and headers and returns its transformed (typically deserialized) version. + */ + transformResponse?: any; + + /** + * {number|Promise} + * Timeout in milliseconds, or promise that should abort the request when resolved. + */ + timeout?: any; + + /** + * See requestType. + */ + responseType?: string; + } + + /** + * Object describing the request to be made and how it should be processed. + * see http://docs.angularjs.org/api/ng/service/$http#usage + */ + interface IRequestConfig extends IRequestShortcutConfig { + /** + * HTTP method (e.g. 'GET', 'POST', etc) + */ + method: string; + /** + * Absolute or relative URL of the resource that is being requested. + */ + url: string; + } + + interface IHttpHeadersGetter { + (): { [name: string]: string; }; + (headerName: string): string; + } + + interface IHttpPromiseCallback { + (data: T, status: number, headers: IHttpHeadersGetter, config: IRequestConfig): void; + } + + interface IHttpPromiseCallbackArg { + data?: T; + status?: number; + headers?: (headerName: string) => string; + config?: IRequestConfig; + statusText?: string; + } + + interface IHttpPromise extends IPromise { + success(callback: IHttpPromiseCallback): IHttpPromise; + error(callback: IHttpPromiseCallback): IHttpPromise; + then(successCallback: (response: IHttpPromiseCallbackArg) => IPromise|TResult, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise; + } + + /** + * Object that controls the defaults for $http provider + * https://docs.angularjs.org/api/ng/service/$http#defaults + */ + interface IHttpProviderDefaults { + xsrfCookieName?: string; + xsrfHeaderName?: string; + withCredentials?: boolean; + headers?: { + common?: any; + post?: any; + put?: any; + patch?: any; + } + } + + interface IHttpProvider extends IServiceProvider { + defaults: IHttpProviderDefaults; + interceptors: any[]; + useApplyAsync(): boolean; + useApplyAsync(value: boolean): IHttpProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // HttpBackendService + // see http://docs.angularjs.org/api/ng.$httpBackend + // You should never need to use this service directly. + /////////////////////////////////////////////////////////////////////////// + interface IHttpBackendService { + // XXX Perhaps define callback signature in the future + (method: string, url: string, post?: any, callback?: Function, headers?: any, timeout?: number, withCredentials?: boolean): void; + } + + /////////////////////////////////////////////////////////////////////////// + // InterpolateService + // see http://docs.angularjs.org/api/ng.$interpolate + // see http://docs.angularjs.org/api/ng.$interpolateProvider + /////////////////////////////////////////////////////////////////////////// + interface IInterpolateService { + (text: string, mustHaveExpression?: boolean, trustedContext?: string, allOrNothing?: boolean): IInterpolationFunction; + endSymbol(): string; + startSymbol(): string; + } + + interface IInterpolationFunction { + (context: any): string; + } + + interface IInterpolateProvider extends IServiceProvider { + startSymbol(): string; + startSymbol(value: string): IInterpolateProvider; + endSymbol(): string; + endSymbol(value: string): IInterpolateProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // TemplateCacheService + // see http://docs.angularjs.org/api/ng.$templateCache + /////////////////////////////////////////////////////////////////////////// + interface ITemplateCacheService extends ICacheObject {} + + /////////////////////////////////////////////////////////////////////////// + // SCEService + // see http://docs.angularjs.org/api/ng.$sce + /////////////////////////////////////////////////////////////////////////// + interface ISCEService { + getTrusted(type: string, mayBeTrusted: any): any; + getTrustedCss(value: any): any; + getTrustedHtml(value: any): any; + getTrustedJs(value: any): any; + getTrustedResourceUrl(value: any): any; + getTrustedUrl(value: any): any; + parse(type: string, expression: string): (context: any, locals: any) => any; + parseAsCss(expression: string): (context: any, locals: any) => any; + parseAsHtml(expression: string): (context: any, locals: any) => any; + parseAsJs(expression: string): (context: any, locals: any) => any; + parseAsResourceUrl(expression: string): (context: any, locals: any) => any; + parseAsUrl(expression: string): (context: any, locals: any) => any; + trustAs(type: string, value: any): any; + trustAsHtml(value: any): any; + trustAsJs(value: any): any; + trustAsResourceUrl(value: any): any; + trustAsUrl(value: any): any; + isEnabled(): boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // SCEProvider + // see http://docs.angularjs.org/api/ng.$sceProvider + /////////////////////////////////////////////////////////////////////////// + interface ISCEProvider extends IServiceProvider { + enabled(value: boolean): void; + } + + /////////////////////////////////////////////////////////////////////////// + // SCEDelegateService + // see http://docs.angularjs.org/api/ng.$sceDelegate + /////////////////////////////////////////////////////////////////////////// + interface ISCEDelegateService { + getTrusted(type: string, mayBeTrusted: any): any; + trustAs(type: string, value: any): any; + valueOf(value: any): any; + } + + + /////////////////////////////////////////////////////////////////////////// + // SCEDelegateProvider + // see http://docs.angularjs.org/api/ng.$sceDelegateProvider + /////////////////////////////////////////////////////////////////////////// + interface ISCEDelegateProvider extends IServiceProvider { + resourceUrlBlacklist(blacklist: any[]): void; + resourceUrlWhitelist(whitelist: any[]): void; + } + + /** + * $templateRequest service + * see http://docs.angularjs.org/api/ng/service/$templateRequest + */ + interface ITemplateRequestService { + /** + * Downloads a template using $http and, upon success, stores the + * contents inside of $templateCache. + * + * If the HTTP request fails or the response data of the HTTP request is + * empty then a $compile error will be thrown (unless + * {ignoreRequestError} is set to true). + * + * @param tpl The template URL. + * @param ignoreRequestError Whether or not to ignore the exception + * when the request fails or the template is + * empty. + * + * @return A promise whose value is the template content. + */ + (tpl: string, ignoreRequestError?: boolean): IPromise; + /** + * total amount of pending template requests being downloaded. + * @type {number} + */ + totalPendingRequests: number; + } + + /////////////////////////////////////////////////////////////////////////// + // Directive + // see http://docs.angularjs.org/api/ng.$compileProvider#directive + // and http://docs.angularjs.org/guide/directive + /////////////////////////////////////////////////////////////////////////// + + interface IDirectiveFactory { + (...args: any[]): IDirective; + } + + interface IDirectiveLinkFn { + ( + scope: IScope, + instanceElement: IAugmentedJQuery, + instanceAttributes: IAttributes, + controller: any, + transclude: ITranscludeFunction + ): void; + } + + interface IDirectivePrePost { + pre?: IDirectiveLinkFn; + post?: IDirectiveLinkFn; + } + + interface IDirectiveCompileFn { + ( + templateElement: IAugmentedJQuery, + templateAttributes: IAttributes, + transclude: ITranscludeFunction + ): IDirectivePrePost; + } + + interface IDirective { + compile?: IDirectiveCompileFn; + controller?: any; + controllerAs?: string; + bindToController?: boolean; + link?: IDirectiveLinkFn; + name?: string; + priority?: number; + replace?: boolean; + require?: any; + restrict?: string; + scope?: any; + template?: any; + templateUrl?: any; + terminal?: boolean; + transclude?: any; + } + + /** + * angular.element + * when calling angular.element, angular returns a jQuery object, + * augmented with additional methods like e.g. scope. + * see: http://docs.angularjs.org/api/angular.element + */ + interface IAugmentedJQueryStatic extends JQueryStatic { + (selector: string, context?: any): IAugmentedJQuery; + (element: Element): IAugmentedJQuery; + (object: {}): IAugmentedJQuery; + (elementArray: Element[]): IAugmentedJQuery; + (object: JQuery): IAugmentedJQuery; + (func: Function): IAugmentedJQuery; + (array: any[]): IAugmentedJQuery; + (): IAugmentedJQuery; + } + + interface IAugmentedJQuery extends JQuery { + // TODO: events, how to define? + //$destroy + + find(selector: string): IAugmentedJQuery; + find(element: any): IAugmentedJQuery; + find(obj: JQuery): IAugmentedJQuery; + controller(): any; + controller(name: string): any; + injector(): any; + scope(): IScope; + isolateScope(): IScope; + + inheritedData(key: string, value: any): JQuery; + inheritedData(obj: { [key: string]: any; }): JQuery; + inheritedData(key?: string): any; + } + + /////////////////////////////////////////////////////////////////////// + // AnimateService + // see http://docs.angularjs.org/api/ng.$animate + /////////////////////////////////////////////////////////////////////// + interface IAnimateService { + addClass(element: JQuery, className: string, done?: Function): void; + enter(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void; + leave(element: JQuery, done?: Function): void; + move(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void; + removeClass(element: JQuery, className: string, done?: Function): void; + } + + /////////////////////////////////////////////////////////////////////////// + // AUTO module (angular.js) + /////////////////////////////////////////////////////////////////////////// + export module auto { + + /////////////////////////////////////////////////////////////////////// + // InjectorService + // see http://docs.angularjs.org/api/AUTO.$injector + /////////////////////////////////////////////////////////////////////// + interface IInjectorService { + annotate(fn: Function): string[]; + annotate(inlineAnnotatedFunction: any[]): string[]; + get(name: string): any; + has(name: string): boolean; + instantiate(typeConstructor: Function, locals?: any): any; + invoke(inlineAnnotatedFunction: any[]): any; + invoke(func: Function, context?: any, locals?: any): any; + } + + /////////////////////////////////////////////////////////////////////// + // ProvideService + // see http://docs.angularjs.org/api/AUTO.$provide + /////////////////////////////////////////////////////////////////////// + interface IProvideService { + // Documentation says it returns the registered instance, but actual + // implementation does not return anything. + // constant(name: string, value: any): any; + /** + * Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator. + * + * @param name The name of the constant. + * @param value The constant value. + */ + constant(name: string, value: any): void; + + /** + * Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service. + * + * @param name The name of the service to decorate. + * @param decorator This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments: + * + * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to. + */ + decorator(name: string, decorator: Function): void; + /** + * Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service. + * + * @param name The name of the service to decorate. + * @param inlineAnnotatedFunction This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments: + * + * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to. + */ + decorator(name: string, inlineAnnotatedFunction: any[]): void; + factory(name: string, serviceFactoryFunction: Function): ng.IServiceProvider; + factory(name: string, inlineAnnotatedFunction: any[]): ng.IServiceProvider; + provider(name: string, provider: ng.IServiceProvider): ng.IServiceProvider; + provider(name: string, serviceProviderConstructor: Function): ng.IServiceProvider; + service(name: string, constructor: Function): ng.IServiceProvider; + value(name: string, value: any): ng.IServiceProvider; + } + + } +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-1.0-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-1.0-tests.ts new file mode 100644 index 00000000..dc4dbcee --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-1.0-tests.ts @@ -0,0 +1,219 @@ +/// + +// issue: https://github.com/borisyankov/DefinitelyTyped/issues/369 +https://github.com/witoldsz/angular-http-auth/blob/master/src/angular-http-auth.js +/** + * @license HTTP Auth Interceptor Module for AngularJS + * (c) 2012 Witold Szczerba + * License: MIT + */ +angular.module('http-auth-interceptor', []) + + .provider('authService', function () { + /** + * Holds all the requests which failed due to 401 response, + * so they can be re-requested in future, once login is completed. + */ + var buffer = []; + + /** + * Required by HTTP interceptor. + * Function is attached to provider to be invisible for regular users of this service. + */ + this.pushToBuffer = function (config: ng.IRequestConfig, deferred: ng.IDeferred) { + buffer.push({ + config: config, + deferred: deferred + }); + } + + this.$get = ['$rootScope', '$injector', function ($rootScope: ng.IScope, $injector: ng.auto.IInjectorService) { + var $http: ng.IHttpService; //initialized later because of circular dependency problem + function retry(config: ng.IRequestConfig, deferred: ng.IDeferred) { + $http = $http || $injector.get('$http'); + $http(config).then(function (response) { + deferred.resolve(response); + }); + } + function retryAll() { + for (var i = 0; i < buffer.length; ++i) { + retry(buffer[i].config, buffer[i].deferred); + } + buffer = []; + } + + return { + loginConfirmed: function () { + $rootScope.$broadcast('event:auth-loginConfirmed'); + retryAll(); + } + } + }] + }) + +/** + * $http interceptor. + * On 401 response - it stores the request and broadcasts 'event:angular-auth-loginRequired'. + */ + .config(['$httpProvider', 'authServiceProvider', function ($httpProvider: ng.IHttpProvider, authServiceProvider) { + + var interceptor = ['$rootScope', '$q', function ($rootScope: ng.IScope, $q: ng.IQService) { + function success(response: ng.IHttpPromiseCallbackArg) { + return response; + } + + function error(response: ng.IHttpPromiseCallbackArg) { + if (response.status === 401) { + var deferred = $q.defer(); + authServiceProvider.pushToBuffer(response.config, deferred); + $rootScope.$broadcast('event:auth-loginRequired'); + return deferred.promise; + } + // otherwise + return $q.reject(response); + } + + return function (promise: ng.IHttpPromise) { + return promise.then(success, error); + } + + }]; + $httpProvider.responseInterceptors.push(interceptor); + }]); + + +module HttpAndRegularPromiseTests { + interface Person { + firstName: string; + lastName: string; + } + + interface ExpectedResponse extends Person { } + + interface SomeControllerScope extends ng.IScope { + person: Person; + theAnswer: number; + letters: string[]; + } + + var someController: Function = ($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) => { + $http.get("http://somewhere/some/resource") + .success((data: ExpectedResponse) => { + $scope.person = data; + }); + + $http.get("http://somewhere/some/resource") + .then((response: ng.IHttpPromiseCallbackArg) => { + // typing lost, so something like + // var i: number = response.data + // would type check + $scope.person = response.data; + }); + + $http.get("http://somewhere/some/resource") + .then((response: ng.IHttpPromiseCallbackArg) => { + // typing lost, so something like + // var i: number = response.data + // would NOT type check + $scope.person = response.data; + }); + + var aPromise: ng.IPromise = $q.when({ firstName: "Jack", lastName: "Sparrow" }); + aPromise.then((person: Person) => { + $scope.person = person; + }); + + var bPromise: ng.IPromise = $q.when(42); + bPromise.then((answer: number) => { + $scope.theAnswer = answer; + }); + + var cPromise: ng.IPromise = $q.when(["a", "b", "c"]); + cPromise.then((letters: string[]) => { + $scope.letters = letters; + }); + } + + // Test that we can pass around a type-checked success/error Promise Callback + var anotherController: Function = ($scope: SomeControllerScope, $http: + ng.IHttpService, $q: ng.IQService) => { + + var buildFooData: Function = () => 42; + + var doFoo: Function = (callback: ng.IHttpPromiseCallback) => { + $http.get('/foo', buildFooData()) + .success(callback); + } + + doFoo((data) => console.log(data)); + } +} + +// Test for AngularJS Syntax + +module My.Namespace { + export var x; // need to export something for module to kick in +} + +// IModule Registering Test +var mod = angular.module('tests', []); +mod.controller('name', function ($scope: ng.IScope) { }) +mod.controller('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.controller(My.Namespace); +mod.directive('name', function ($scope: ng.IScope) { }) +mod.directive('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.directive(My.Namespace); +mod.factory('name', function ($scope: ng.IScope) { }) +mod.factory('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.factory(My.Namespace); +mod.filter('name', function ($scope: ng.IScope) { }) +mod.filter('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.filter(My.Namespace); +mod.provider('name', function ($scope: ng.IScope) { }) +mod.provider('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.provider(My.Namespace); +mod.service('name', function ($scope: ng.IScope) { }) +mod.service('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.service(My.Namespace); +mod.constant('name', 23); +mod.constant('name', "23"); +mod.constant(My.Namespace); +mod.value('name', 23); +mod.value('name', "23"); +mod.value(My.Namespace); + +// Promise signature tests +var foo: ng.IPromise; +foo.then((x) => { + // x is inferred to be a number + return "asdf"; +}).then((x) => { + // x is inferred to be string + x.length; + return 123; +}).then((x) => { + // x is infered to be a number + x.toFixed(); + return; +}).then((x) => { + // x is infered to be void + // Typescript will prevent you to actually use x as a local variable + // Try object: + return { a: 123 }; +}).then((x) => { + // Object is inferred here + x.a = 123; + //Try a promise + var y: ng.IPromise; + return y; +}).then((x) => { + // x is infered to be a number, which is the resolved value of a promise + x.toFixed(); +}); + + +// angular.element() tests +var element = angular.element("div.myApp"); +var scope: ng.IScope = element.scope(); + + diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-1.0-tests.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-1.0-tests.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-1.0-tests.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-1.0.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-1.0.d.ts new file mode 100644 index 00000000..be38898d --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-1.0.d.ts @@ -0,0 +1,760 @@ +// Type definitions for Angular JS 1.0 +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +declare var angular: ng.IAngularStatic; + +// Support for painless dependency injection +interface Function { + $inject:string[]; +} + +/////////////////////////////////////////////////////////////////////////////// +// ng module (angular.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng { + + // All service providers extend this interface + interface IServiceProvider { + $get(): any; + } + + /////////////////////////////////////////////////////////////////////////// + // AngularStatic + // see http://docs.angularjs.org/api + /////////////////////////////////////////////////////////////////////////// + interface IAngularStatic { + bind(context: any, fn: Function, ...args: any[]): Function; + bootstrap(element: string, modules?: any[]): auto.IInjectorService; + bootstrap(element: JQuery, modules?: any[]): auto.IInjectorService; + bootstrap(element: Element, modules?: any[]): auto.IInjectorService; + bootstrap(element: Document, modules?: any[]): auto.IInjectorService; + copy(source: any, destination?: any): any; + element: IAugmentedJQueryStatic; + equals(value1: any, value2: any): boolean; + extend(destination: any, ...sources: any[]): any; + forEach(obj: any, iterator: (value: any, key: any) => any, context?: any): any; + fromJson(json: string): any; + identity(arg?: any): any; + injector(modules?: any[]): auto.IInjectorService; + isArray(value: any): boolean; + isDate(value: any): boolean; + isDefined(value: any): boolean; + isElement(value: any): boolean; + isFunction(value: any): boolean; + isNumber(value: any): boolean; + isObject(value: any): boolean; + isString(value: any): boolean; + isUndefined(value: any): boolean; + lowercase(str: string): string; + /** construct your angular application + official docs: Interface for configuring angular modules. + see: http://docs.angularjs.org/api/angular.Module + */ + module( + /** name of your module you want to create */ + name: string, + /** name of modules yours depends on */ + requires?: string[], + configFunction?: any): IModule; + noop(...args: any[]): void; + toJson(obj: any, pretty?: boolean): string; + uppercase(str: string): string; + version: { + full: string; + major: number; + minor: number; + dot: number; + codename: string; + }; + } + + /////////////////////////////////////////////////////////////////////////// + // Module + // see http://docs.angularjs.org/api/angular.Module + /////////////////////////////////////////////////////////////////////////// + interface IModule { + animation(name: string, animationFactory: Function): IModule; + animation(name: string, inlineAnnotadedFunction: any[]): IModule; + animation(object: Object): IModule; + /** configure existing services. + Use this method to register work which needs to be performed on module loading + */ + config(configFn: Function): IModule; + /** configure existing services. + Use this method to register work which needs to be performed on module loading + */ + config(inlineAnnotadedFunction: any[]): IModule; + constant(name: string, value: any): IModule; + constant(object: Object): IModule; + controller(name: string, controllerConstructor: Function): IModule; + controller(name: string, inlineAnnotadedConstructor: any[]): IModule; + controller(object : Object): IModule; + directive(name: string, directiveFactory: (...params:any[])=> IDirective): IModule; + directive(name: string, inlineAnnotadedFunction: any[]): IModule; + directive(object: Object): IModule; + factory(name: string, serviceFactoryFunction: Function): IModule; + factory(name: string, inlineAnnotadedFunction: any[]): IModule; + factory(object: Object): IModule; + filter(name: string, filterFactoryFunction: Function): IModule; + filter(name: string, inlineAnnotadedFunction: any[]): IModule; + filter(object: Object): IModule; + provider(name: string, serviceProviderConstructor: Function): IModule; + provider(name: string, inlineAnnotadedConstructor: any[]): IModule; + provider(object: Object): IModule; + run(initializationFunction: Function): IModule; + run(inlineAnnotadedFunction: any[]): IModule; + service(name: string, serviceConstructor: Function): IModule; + service(name: string, inlineAnnotadedConstructor: any[]): IModule; + service(object: Object): IModule; + value(name: string, value: any): IModule; + value(object: Object): IModule; + + // Properties + name: string; + requires: string[]; + } + + /////////////////////////////////////////////////////////////////////////// + // Attributes + // see http://docs.angularjs.org/api/ng.$compile.directive.Attributes + /////////////////////////////////////////////////////////////////////////// + interface IAttributes { + $set(name: string, value: any): void; + $observe(name: string, fn:(value?:any)=>any):void; + $attr: any; + } + + /////////////////////////////////////////////////////////////////////////// + // FormController + // see http://docs.angularjs.org/api/ng.directive:form.FormController + /////////////////////////////////////////////////////////////////////////// + interface IFormController { + $pristine: boolean; + $dirty: boolean; + $valid: boolean; + $invalid: boolean; + $error: any; + $setDirty(): void; + $setPristine(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // NgModelController + // see http://docs.angularjs.org/api/ng.directive:ngModel.NgModelController + /////////////////////////////////////////////////////////////////////////// + interface INgModelController { + $render(): void; + $setValidity(validationErrorKey: string, isValid: boolean): void; + $setViewValue(value: string): void; + + // XXX Not sure about the types here. Documentation states it's a string, but + // I've seen it receiving other types throughout the code. + // Falling back to any for now. + $viewValue: any; + + // XXX Same as avove + $modelValue: any; + + $parsers: IModelParser[]; + $formatters: IModelFormatter[]; + $error: any; + $pristine: boolean; + $dirty: boolean; + $valid: boolean; + $invalid: boolean; + } + + interface IModelParser { + (value: any): any; + } + + interface IModelFormatter { + (value: any): any; + } + + /////////////////////////////////////////////////////////////////////////// + // Scope + // see http://docs.angularjs.org/api/ng.$rootScope.Scope + /////////////////////////////////////////////////////////////////////////// + interface IScope { + $apply(): any; + $apply(exp: string): any; + $apply(exp: (scope: IScope) => any): any; + + $broadcast(name: string, ...args: any[]): IAngularEvent; + $destroy(): void; + $digest(): void; + $emit(name: string, ...args: any[]): IAngularEvent; + + // Documentation says exp is optional, but actual implementaton counts on it + $eval(expression: string): any; + $eval(expression: (scope: IScope) => any): any; + + // Documentation says exp is optional, but actual implementaton counts on it + $evalAsync(expression: string): void; + $evalAsync(expression: (scope: IScope) => any): void; + + // Defaults to false by the implementation checking strategy + $new(isolate?: boolean): IScope; + + $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function; + + $watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function; + $watch(watchExpression: string, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function; + $watch(watchExpression: (scope: IScope) => any, listener?: string, objectEquality?: boolean): Function; + $watch(watchExpression: (scope: IScope) => any, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function; + + $watchCollection(watchExpression: string, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; + $watchCollection(watchExpression: (scope: IScope) => any, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; + + $parent: IScope; + + $id: number; + + // Hidden members + $$isolateBindings: any; + $$phase: any; + } + + interface IAngularEvent { + targetScope: IScope; + currentScope: IScope; + name: string; + preventDefault: Function; + defaultPrevented: boolean; + + // Available only events that were $emit-ted + stopPropagation?: Function; + } + + /////////////////////////////////////////////////////////////////////////// + // WindowService + // see http://docs.angularjs.org/api/ng.$window + /////////////////////////////////////////////////////////////////////////// + interface IWindowService extends Window {} + + /////////////////////////////////////////////////////////////////////////// + // BrowserService + // TODO undocumented, so we need to get it from the source code + /////////////////////////////////////////////////////////////////////////// + interface IBrowserService {} + + /////////////////////////////////////////////////////////////////////////// + // TimeoutService + // see http://docs.angularjs.org/api/ng.$timeout + /////////////////////////////////////////////////////////////////////////// + interface ITimeoutService { + (func: Function, delay?: number, invokeApply?: boolean): IPromise; + cancel(promise: IPromise): boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // FilterService + // see http://docs.angularjs.org/api/ng.$filter + // see http://docs.angularjs.org/api/ng.$filterProvider + /////////////////////////////////////////////////////////////////////////// + interface IFilterService { + (name: string): Function; + } + + interface IFilterProvider extends IServiceProvider { + register(name: string, filterFactory: Function): IServiceProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // LocaleService + // see http://docs.angularjs.org/api/ng.$locale + /////////////////////////////////////////////////////////////////////////// + interface ILocaleService { + id: string; + + // These are not documented + // Check angular's i18n files for exemples + NUMBER_FORMATS: ILocaleNumberFormatDescriptor; + DATETIME_FORMATS: ILocaleDateTimeFormatDescriptor; + pluralCat: (num: any) => string; + } + + interface ILocaleNumberFormatDescriptor { + DECIMAL_SEP: string; + GROUP_SEP: string; + PATTERNS: ILocaleNumberPatternDescriptor[]; + CURRENCY_SYM: string; + } + + interface ILocaleNumberPatternDescriptor { + minInt: number; + minFrac: number; + maxFrac: number; + posPre: string; + posSuf: string; + negPre: string; + negSuf: string; + gSize: number; + lgSize: number; + } + + interface ILocaleDateTimeFormatDescriptor { + MONTH: string[]; + SHORTMONTH: string[]; + DAY: string[]; + SHORTDAY: string[]; + AMPMS: string[]; + medium: string; + short: string; + fullDate: string; + longDate: string; + mediumDate: string; + shortDate: string; + mediumTime: string; + shortTime: string; + } + + /////////////////////////////////////////////////////////////////////////// + // LogService + // see http://docs.angularjs.org/api/ng.$log + /////////////////////////////////////////////////////////////////////////// + interface ILogService { + debug: ILogCall; + error: ILogCall; + info: ILogCall; + log: ILogCall; + warn: ILogCall; + } + + // We define this as separete interface so we can reopen it later for + // the ngMock module. + interface ILogCall { + (...args: any[]): void; + } + + /////////////////////////////////////////////////////////////////////////// + // ParseService + // see http://docs.angularjs.org/api/ng.$parse + /////////////////////////////////////////////////////////////////////////// + interface IParseService { + (expression: string): ICompiledExpression; + } + + interface ICompiledExpression { + (context: any, locals?: any): any; + + // If value is not provided, undefined is gonna be used since the implementation + // does not check the parameter. Let's force a value for consistency. If consumer + // whants to undefine it, pass the undefined value explicitly. + assign(context: any, value: any): any; + } + + /////////////////////////////////////////////////////////////////////////// + // LocationService + // see http://docs.angularjs.org/api/ng.$location + // see http://docs.angularjs.org/api/ng.$locationProvider + // see http://docs.angularjs.org/guide/dev_guide.services.$location + /////////////////////////////////////////////////////////////////////////// + interface ILocationService { + absUrl(): string; + hash(): string; + hash(newHash: string): ILocationService; + host(): string; + path(): string; + path(newPath: string): ILocationService; + port(): number; + protocol(): string; + replace(): ILocationService; + search(): any; + search(parametersMap: any): ILocationService; + search(parameter: string, parameterValue: any): ILocationService; + url(): string; + url(url: string): ILocationService; + } + + interface ILocationProvider extends IServiceProvider { + hashPrefix(): string; + hashPrefix(prefix: string): ILocationProvider; + html5Mode(): boolean; + + // Documentation states that parameter is string, but + // implementation tests it as boolean, which makes more sense + // since this is a toggler + html5Mode(active: boolean): ILocationProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // DocumentService + // see http://docs.angularjs.org/api/ng.$document + /////////////////////////////////////////////////////////////////////////// + interface IDocumentService extends Document {} + + /////////////////////////////////////////////////////////////////////////// + // ExceptionHandlerService + // see http://docs.angularjs.org/api/ng.$exceptionHandler + /////////////////////////////////////////////////////////////////////////// + interface IExceptionHandlerService { + (exception: Error, cause?: string): void; + } + + /////////////////////////////////////////////////////////////////////////// + // RootElementService + // see http://docs.angularjs.org/api/ng.$rootElement + /////////////////////////////////////////////////////////////////////////// + interface IRootElementService extends JQuery {} + + /////////////////////////////////////////////////////////////////////////// + // QService + // see http://docs.angularjs.org/api/ng.$q + /////////////////////////////////////////////////////////////////////////// + interface IQService { + all(promises: IPromise[]): IPromise; + defer(): IDeferred; + reject(reason?: any): IPromise; + when(value: T): IPromise; + } + + interface IPromise { + then(successCallback: (promiseValue: T) => IHttpPromise, errorCallback?: (reason: any) => any): IPromise; + then(successCallback: (promiseValue: T) => IPromise, errorCallback?: (reason: any) => any): IPromise; + then(successCallback: (promiseValue: T) => TResult, errorCallback?: (reason: any) => TResult): IPromise; + } + + interface IDeferred { + resolve(value?: T): void; + reject(reason?: any): void; + promise: IPromise; + } + + /////////////////////////////////////////////////////////////////////////// + // AnchorScrollService + // see http://docs.angularjs.org/api/ng.$anchorScroll + /////////////////////////////////////////////////////////////////////////// + interface IAnchorScrollService { + (): void; + } + + interface IAnchorScrollProvider extends IServiceProvider { + disableAutoScrolling(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // CacheFactoryService + // see http://docs.angularjs.org/api/ng.$cacheFactory + /////////////////////////////////////////////////////////////////////////// + interface ICacheFactoryService { + // Lets not foce the optionsMap to have the capacity member. Even though + // it's the ONLY option considered by the implementation today, a consumer + // might find it useful to associate some other options to the cache object. + //(cacheId: string, optionsMap?: { capacity: number; }): CacheObject; + (cacheId: string, optionsMap?: { capacity: number; }): ICacheObject; + + // Methods bellow are not documented + info(): any; + get (cacheId: string): ICacheObject; + } + + interface ICacheObject { + info(): { + id: string; + size: number; + + // Not garanteed to have, since it's a non-mandatory option + //capacity: number; + }; + put(key: string, value?: any): void; + get (key: string): any; + remove(key: string): void; + removeAll(): void; + destroy(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // CompileService + // see http://docs.angularjs.org/api/ng.$compile + // see http://docs.angularjs.org/api/ng.$compileProvider + /////////////////////////////////////////////////////////////////////////// + interface ICompileService { + (element: string, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction; + (element: Element, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction; + (element: JQuery, transclude?: ITemplateLinkingFunction, maxPriority?: number): ITemplateLinkingFunction; + } + + interface ICompileProvider extends IServiceProvider { + directive(name: string, directiveFactory: Function): ICompileProvider; + + // Undocumented, but it is there... + directive(directivesMap: any): ICompileProvider; + } + + interface ITemplateLinkingFunction { + // Let's hint but not force cloneAttachFn's signature + (scope: IScope, cloneAttachFn?: (clonedElement?: JQuery, scope?: IScope) => any): JQuery; + } + + /////////////////////////////////////////////////////////////////////////// + // ControllerService + // see http://docs.angularjs.org/api/ng.$controller + // see http://docs.angularjs.org/api/ng.$controllerProvider + /////////////////////////////////////////////////////////////////////////// + interface IControllerService { + // Although the documentation doesn't state this, locals are optional + (controllerConstructor: Function, locals?: any): any; + (controllerName: string, locals?: any): any; + } + + interface IControllerProvider extends IServiceProvider { + register(name: string, controllerConstructor: Function): void; + register(name: string, dependencyAnnotadedConstructor: any[]): void; + } + + /////////////////////////////////////////////////////////////////////////// + // HttpService + // see http://docs.angularjs.org/api/ng.$http + /////////////////////////////////////////////////////////////////////////// + interface IHttpService { + // At least moethod and url must be provided... + (config: IRequestConfig): IHttpPromise; + get (url: string, RequestConfig?: any): IHttpPromise; + delete (url: string, RequestConfig?: any): IHttpPromise; + head(url: string, RequestConfig?: any): IHttpPromise; + jsonp(url: string, RequestConfig?: any): IHttpPromise; + post(url: string, data: any, RequestConfig?: any): IHttpPromise; + put(url: string, data: any, RequestConfig?: any): IHttpPromise; + defaults: IRequestConfig; + + // For debugging, BUT it is documented as public, so... + pendingRequests: any[]; + } + + // This is just for hinting. + // Some opetions might not be available depending on the request. + // see http://docs.angularjs.org/api/ng.$http#Usage for options explanations + interface IRequestConfig { + method: string; + url: string; + params?: any; + + // XXX it has it's own structure... perhaps we should define it in the future + headers?: any; + + cache?: any; + timeout?: number; + withCredentials?: boolean; + + // These accept multiple types, so let's defile them as any + data?: any; + transformRequest?: any; + transformResponse?: any; + } + + interface IHttpPromiseCallback { + (data: T, status: number, headers: (headerName: string) => string, config: IRequestConfig): void; + } + + interface IHttpPromiseCallbackArg { + data?: T; + status?: number; + headers?: (headerName: string) => string; + config?: IRequestConfig; + } + + interface IHttpPromise extends IPromise { + success(callback: IHttpPromiseCallback): IHttpPromise; + error(callback: IHttpPromiseCallback): IHttpPromise; + then(successCallback: (response: IHttpPromiseCallbackArg) => TResult, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise; + then(successCallback: (response: IHttpPromiseCallbackArg) => IPromise, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise; + } + + interface IHttpProvider extends IServiceProvider { + defaults: IRequestConfig; + interceptors: any[]; + responseInterceptors: any[]; + } + + /////////////////////////////////////////////////////////////////////////// + // HttpBackendService + // see http://docs.angularjs.org/api/ng.$httpBackend + // You should never need to use this service directly. + /////////////////////////////////////////////////////////////////////////// + interface IHttpBackendService { + // XXX Perhaps define callback signature in the future + (method: string, url: string, post?: any, callback?: Function, headers?: any, timeout?: number, withCredentials?: boolean): void; + } + + /////////////////////////////////////////////////////////////////////////// + // InterpolateService + // see http://docs.angularjs.org/api/ng.$interpolate + // see http://docs.angularjs.org/api/ng.$interpolateProvider + /////////////////////////////////////////////////////////////////////////// + interface IInterpolateService { + (text: string, mustHaveExpression?: boolean): IInterpolationFunction; + endSymbol(): string; + startSymbol(): string; + } + + interface IInterpolationFunction { + (context: any): string; + } + + interface IInterpolateProvider extends IServiceProvider { + startSymbol(): string; + startSymbol(value: string): IInterpolateProvider; + endSymbol(): string; + endSymbol(value: string): IInterpolateProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // RouteParamsService + // see http://docs.angularjs.org/api/ng.$routeParams + /////////////////////////////////////////////////////////////////////////// + interface IRouteParamsService {} + + /////////////////////////////////////////////////////////////////////////// + // TemplateCacheService + // see http://docs.angularjs.org/api/ng.$templateCache + /////////////////////////////////////////////////////////////////////////// + interface ITemplateCacheService extends ICacheObject {} + + /////////////////////////////////////////////////////////////////////////// + // RootScopeService + // see http://docs.angularjs.org/api/ng.$rootScope + /////////////////////////////////////////////////////////////////////////// + interface IRootScopeService extends IScope {} + + /////////////////////////////////////////////////////////////////////////// + // RouteService + // see http://docs.angularjs.org/api/ng.$route + // see http://docs.angularjs.org/api/ng.$routeProvider + /////////////////////////////////////////////////////////////////////////// + interface IRouteService { + reload(): void; + routes: any; + + // May not always be available. For instance, current will not be available + // to a controller that was not initialized as a result of a route maching. + current?: ICurrentRoute; + } + + // see http://docs.angularjs.org/api/ng.$routeProvider#when for options explanations + interface IRoute { + controller?: any; + name?: string; + template?: string; + templateUrl?: any; + resolve?: any; + redirectTo?: any; + reloadOnSearch?: boolean; + } + + // see http://docs.angularjs.org/api/ng.$route#current + interface ICurrentRoute extends IRoute { + locals: { + $scope: IScope; + $template: string; + }; + + params: any; + } + + interface IRouteProvider extends IServiceProvider { + otherwise(params: any): IRouteProvider; + when(path: string, route: IRoute): IRouteProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // Directive + // see http://docs.angularjs.org/api/ng.$compileProvider#directive + // and http://docs.angularjs.org/guide/directive + /////////////////////////////////////////////////////////////////////////// + + interface IDirective{ + priority?: number; + template?: any; + templateUrl?: any; + replace?: boolean; + transclude?: any; + restrict?: string; + scope?: any; + link?: Function; + compile?: Function; + controller?: any; + } + + /////////////////////////////////////////////////////////////////////////// + // angular.element + // when calling angular.element, angular returns a jQuery object, + // augmented with additional methods like e.g. scope. + // see: http://docs.angularjs.org/api/angular.element + /////////////////////////////////////////////////////////////////////////// + interface IAugmentedJQueryStatic extends JQueryStatic { + (selector: string, context?: any): IAugmentedJQuery; + (element: Element): IAugmentedJQuery; + (object: {}): IAugmentedJQuery; + (elementArray: Element[]): IAugmentedJQuery; + (object: JQuery): IAugmentedJQuery; + (func: Function): IAugmentedJQuery; + (array: any[]): IAugmentedJQuery; + (): IAugmentedJQuery; + } + + interface IAugmentedJQuery extends JQuery { + // TODO: events, how to define? + //$destroy + + find(selector: string): IAugmentedJQuery; + find(element: any): IAugmentedJQuery; + find(obj: JQuery): IAugmentedJQuery; + + controller(name: string): any; + injector(): any; + scope(): IScope; + + inheritedData(key: string, value: any): JQuery; + inheritedData(obj: { [key: string]: any; }): JQuery; + inheritedData(key?: string): any; + + + } + + + /////////////////////////////////////////////////////////////////////////// + // AUTO module (angular.js) + /////////////////////////////////////////////////////////////////////////// + export module auto { + + /////////////////////////////////////////////////////////////////////// + // InjectorService + // see http://docs.angularjs.org/api/AUTO.$injector + /////////////////////////////////////////////////////////////////////// + interface IInjectorService { + annotate(fn: Function): string[]; + annotate(inlineAnnotadedFunction: any[]): string[]; + get (name: string): any; + instantiate(typeConstructor: Function, locals?: any): any; + invoke(func: Function, context?: any, locals?: any): any; + } + + /////////////////////////////////////////////////////////////////////// + // ProvideService + // see http://docs.angularjs.org/api/AUTO.$provide + /////////////////////////////////////////////////////////////////////// + interface IProvideService { + // Documentation says it returns the registered instance, but actual + // implementation does not return anything. + // constant(name: string, value: any): any; + constant(name: string, value: any): void; + + decorator(name: string, decorator: Function): void; + decorator(name: string, decoratorInline: any[]): void; + factory(name: string, serviceFactoryFunction: Function): ng.IServiceProvider; + provider(name: string, provider: ng.IServiceProvider): ng.IServiceProvider; + provider(name: string, serviceProviderConstructor: Function): ng.IServiceProvider; + service(name: string, constructor: Function): ng.IServiceProvider; + value(name: string, value: any): ng.IServiceProvider; + } + + } + +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-1.2-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-1.2-tests.ts new file mode 100644 index 00000000..d0f60609 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-1.2-tests.ts @@ -0,0 +1,571 @@ +/// + +// issue: https://github.com/borisyankov/DefinitelyTyped/issues/369 +// https://github.com/witoldsz/angular-http-auth/blob/master/src/angular-http-auth.js +/** + * @license HTTP Auth Interceptor Module for AngularJS + * (c) 2012 Witold Szczerba + * License: MIT + */ + +class AuthService { + /** + * Holds all the requests which failed due to 401 response, + * so they can be re-requested in future, once login is completed. + */ + buffer: { config: ng.IRequestConfig; deferred: ng.IDeferred; }[] = []; + + /** + * Required by HTTP interceptor. + * Function is attached to provider to be invisible for regular users of this service. + */ + pushToBuffer = function(config: ng.IRequestConfig, deferred: ng.IDeferred) { + this.buffer.push({ + config: config, + deferred: deferred + }); + } + + $get = [ + '$rootScope', '$injector', function($rootScope: ng.IScope, $injector: ng.auto.IInjectorService) { + var $http: ng.IHttpService; //initialized later because of circular dependency problem + function retry(config: ng.IRequestConfig, deferred: ng.IDeferred) { + $http = $http || $injector.get('$http'); + $http(config).then(function (response) { + deferred.resolve(response); + }); + } + function retryAll() { + for (var i = 0; i < this.buffer.length; ++i) { + retry(this.buffer[i].config, this.buffer[i].deferred); + } + this.buffer = []; + } + + return { + loginConfirmed: function () { + $rootScope.$broadcast('event:auth-loginConfirmed'); + retryAll(); + } + } + } + ]; +} + +angular.module('http-auth-interceptor', []) + + .provider('authService', AuthService) + +/** + * $http interceptor. + * On 401 response - it stores the request and broadcasts 'event:angular-auth-loginRequired'. + */ + .config(['$httpProvider', 'authServiceProvider', function ($httpProvider: ng.IHttpProvider, authServiceProvider: any) { + + var interceptor = ['$rootScope', '$q', function ($rootScope: ng.IScope, $q: ng.IQService) { + function success(response: ng.IHttpPromiseCallbackArg) { + return response; + } + + function error(response: ng.IHttpPromiseCallbackArg) { + if (response.status === 401) { + var deferred = $q.defer(); + authServiceProvider.pushToBuffer(response.config, deferred); + $rootScope.$broadcast('event:auth-loginRequired'); + return deferred.promise; + } + // otherwise + return $q.reject(response); + } + + return function (promise: ng.IHttpPromise) { + return promise.then(success, error); + } + + }]; + $httpProvider.responseInterceptors.push(interceptor); + }]); + + +module HttpAndRegularPromiseTests { + interface Person { + firstName: string; + lastName: string; + } + + interface ExpectedResponse extends Person { } + + interface SomeControllerScope extends ng.IScope { + person: Person; + theAnswer: number; + letters: string[]; + snack: string; + nothing?: string; + } + + var someController: Function = ($scope: SomeControllerScope, $http: ng.IHttpService, $q: ng.IQService) => { + $http.get("http://somewhere/some/resource") + .success((data: ExpectedResponse) => { + $scope.person = data; + }); + + $http.get("http://somewhere/some/resource") + .then((response: ng.IHttpPromiseCallbackArg) => { + // typing lost, so something like + // var i: number = response.data + // would type check + $scope.person = response.data; + }); + + $http.get("http://somewhere/some/resource") + .then((response: ng.IHttpPromiseCallbackArg) => { + // typing lost, so something like + // var i: number = response.data + // would NOT type check + $scope.person = response.data; + }); + + var aPromise: ng.IPromise = $q.when({ firstName: "Jack", lastName: "Sparrow" }); + aPromise.then((person: Person) => { + $scope.person = person; + }); + + var bPromise: ng.IPromise = $q.when(42); + bPromise.then((answer: number) => { + $scope.theAnswer = answer; + }); + + var cPromise: ng.IPromise = $q.when(["a", "b", "c"]); + cPromise.then((letters: string[]) => { + $scope.letters = letters; + }); + + // When $q.when is passed an IPromise, it returns an IPromise + var dPromise: ng.IPromise = $q.when($q.when("ALBATROSS!")); + dPromise.then((snack: string) => { + $scope.snack = snack; + }); + + // $q.when may be called without arguments + var ePromise: ng.IPromise = $q.when(); + ePromise.then(() => { + $scope.nothing = "really nothing"; + }); + } + + // Test that we can pass around a type-checked success/error Promise Callback + var anotherController: Function = ($scope: SomeControllerScope, $http: + ng.IHttpService, $q: ng.IQService) => { + + var buildFooData: Function = () => 42; + + var doFoo: Function = (callback: ng.IHttpPromiseCallback) => { + $http.get('/foo', buildFooData()) + .success(callback); + } + + doFoo((data: any) => console.log(data)); + } +} + +// Test for AngularJS Syntax + +module My.Namespace { + export var x: any; // need to export something for module to kick in +} + +// IModule Registering Test +var mod = angular.module('tests', []); +mod.controller('name', function ($scope: ng.IScope) { }) +mod.controller('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.controller(My.Namespace); +mod.directive('name', function ($scope: ng.IScope) { }) +mod.directive('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.directive(My.Namespace); +mod.factory('name', function ($scope: ng.IScope) { }) +mod.factory('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.factory(My.Namespace); +mod.filter('name', function ($scope: ng.IScope) { }) +mod.filter('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.filter(My.Namespace); +mod.provider('name', function ($scope: ng.IScope) { return { $get: () => { } } }) +mod.provider('name', TestProvider); +mod.provider('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.provider(My.Namespace); +mod.service('name', function ($scope: ng.IScope) { }) +mod.service('name', ['$scope', function ($scope: ng.IScope) { }]) +mod.service(My.Namespace); +mod.constant('name', 23); +mod.constant('name', "23"); +mod.constant(My.Namespace); +mod.value('name', 23); +mod.value('name', "23"); +mod.value(My.Namespace); + +class TestProvider implements ng.IServiceProvider { + constructor(private $scope: ng.IScope) { + } + + $get() { + } +} + +// Promise signature tests +var foo: ng.IPromise; +foo.then((x) => { + // x is inferred to be a number + return "asdf"; +}).then((x) => { + // x is inferred to be string + x.length; + return 123; +}).then((x) => { + // x is infered to be a number + x.toFixed(); + return; +}).then((x) => { + // x is infered to be void + // Typescript will prevent you to actually use x as a local variable + // Try object: + return { a: 123 }; +}).then((x) => { + // Object is inferred here + x.a = 123; + //Try a promise + var y: ng.IPromise; + return y; +}).then((x) => { + // x is infered to be a number, which is the resolved value of a promise + x.toFixed(); +}); + + +var httpFoo: ng.IHttpPromise; +httpFoo.then((x) => { + // When returning a promise the generic type must be inferred. + var innerPromise : ng.IPromise; + return innerPromise; +}).then((x) => { + // must still be number. + x.toFixed(); +}); + + +function test_angular_forEach() { + var values: { [key: string]: string } = { name: 'misko', gender: 'male' }; + var log: string[] = []; + angular.forEach(values, function (value, key) { + this.push(key + ': ' + value); + }, log); + //expect(log).toEqual(['name: misko', 'gender: male']); +} + +// angular.element() tests +var element = angular.element("div.myApp"); +var scope: ng.IScope = element.scope(); +var isolateScope: ng.IScope = element.isolateScope(); + + + +function test_IAttributes(attributes: ng.IAttributes){ + return attributes; +} + +test_IAttributes({ + $addClass: function (classVal){}, + $removeClass: function(classVal){}, + $set: function(key, value){}, + $observe: function(name, fn){ + return fn; + }, + $attr: {} +}); + +class SampleDirective implements ng.IDirective { + public restrict = 'A'; + name = 'doh'; + + compile(templateElement: ng.IAugmentedJQuery) { + return { + post: this.link + }; + } + + static instance():ng.IDirective { + return new SampleDirective(); + } + + link(scope: ng.IScope) { + + } +} + +class SampleDirective2 implements ng.IDirective { + public restrict = 'EAC'; + + compile(templateElement: ng.IAugmentedJQuery) { + return { + pre: this.link + }; + } + + static instance():ng.IDirective { + return new SampleDirective2(); + } + + link(scope: ng.IScope) { + + } +} + +angular.module('SameplDirective', []).directive('sampleDirective', SampleDirective.instance).directive('sameplDirective2', SampleDirective2.instance); + +// test from https://docs.angularjs.org/guide/directive +angular.module('docsSimpleDirective', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .directive('myCustomer', function() { + return { + template: 'Name: {{customer.name}} Address: {{customer.address}}' + }; + }); + +angular.module('docsTemplateUrlDirective', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .directive('myCustomer', function() { + return { + templateUrl: 'my-customer.html' + }; + }); + +angular.module('docsRestrictDirective', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + templateUrl: 'my-customer.html' + }; + }); + +angular.module('docsScopeProblemExample', []) + .controller('NaomiController', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Naomi', + address: '1600 Amphitheatre' + }; + }]) + .controller('IgorController', ['$scope', function($scope: any) { + $scope.customer = { + name: 'Igor', + address: '123 Somewhere' + }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + templateUrl: 'my-customer.html' + }; + }); + +angular.module('docsIsolateScopeDirective', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' }; + $scope.igor = { name: 'Igor', address: '123 Somewhere' }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + scope: { + customerInfo: '=info' + }, + templateUrl: 'my-customer-iso.html' + }; + }); + +angular.module('docsIsolationExample', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.naomi = { name: 'Naomi', address: '1600 Amphitheatre' }; + $scope.vojta = { name: 'Vojta', address: '3456 Somewhere Else' }; + }]) + .directive('myCustomer', function() { + return { + restrict: 'E', + scope: { + customerInfo: '=info' + }, + templateUrl: 'my-customer-plus-vojta.html' + }; + }); + +angular.module('docsTimeDirective', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.format = 'M/d/yy h:mm:ss a'; + }]) + .directive('myCurrentTime', ['$interval', 'dateFilter', function($interval: any, dateFilter: any) { + + return { + link: function(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs:ng.IAttributes) { + var format: any, + timeoutId: any; + + function updateTime() { + element.text(dateFilter(new Date(), format)); + } + + scope.$watch(attrs['myCurrentTime'], function (value: any) { + format = value; + updateTime(); + }); + + element.on('$destroy', function () { + $interval.cancel(timeoutId); + }); + + // start the UI update process; save the timeoutId for canceling + timeoutId = $interval(function () { + updateTime(); // update DOM + }, 1000); + } + }; + }]); + +angular.module('docsTransclusionDirective', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.name = 'Tobias'; + }]) + .directive('myDialog', function() { + return { + restrict: 'E', + transclude: true, + templateUrl: 'my-dialog.html' + }; + }); + +angular.module('docsTransclusionExample', []) + .controller('Controller', ['$scope', function($scope: any) { + $scope.name = 'Tobias'; + }]) + .directive('myDialog', function() { + return { + restrict: 'E', + transclude: true, + scope: {}, + templateUrl: 'my-dialog.html', + link: function (scope: ng.IScope, element: ng.IAugmentedJQuery) { + scope['name'] = 'Jeff'; + } + }; + }); + +angular.module('docsIsoFnBindExample', []) + .controller('Controller', ['$scope', '$timeout', function($scope: any, $timeout: any) { + $scope.name = 'Tobias'; + $scope.hideDialog = function () { + $scope.dialogIsHidden = true; + $timeout(function () { + $scope.dialogIsHidden = false; + }, 2000); + }; + }]) + .directive('myDialog', function() { + return { + restrict: 'E', + transclude: true, + scope: { + 'close': '&onClose' + }, + templateUrl: 'my-dialog-close.html' + }; + }); + +angular.module('dragModule', []) + .directive('myDraggable', ['$document', function($document: any) { + return function(scope: any, element: any, attr: any) { + var startX = 0, startY = 0, x = 0, y = 0; + + element.css({ + position: 'relative', + border: '1px solid red', + backgroundColor: 'lightgrey', + cursor: 'pointer' + }); + + element.on('mousedown', function(event: any) { + // Prevent default dragging of selected content + event.preventDefault(); + startX = event.pageX - x; + startY = event.pageY - y; + $document.on('mousemove', mousemove); + $document.on('mouseup', mouseup); + }); + + function mousemove(event: any) { + y = event.pageY - startY; + x = event.pageX - startX; + element.css({ + top: y + 'px', + left: x + 'px' + }); + } + + function mouseup() { + $document.off('mousemove', mousemove); + $document.off('mouseup', mouseup); + } + }; + }]); + +angular.module('docsTabsExample', []) + .directive('myTabs', function() { + return { + restrict: 'E', + transclude: true, + scope: {}, + controller: function($scope: ng.IScope) { + var panes: any = $scope['panes'] = []; + + $scope['select'] = function(pane: any) { + angular.forEach(panes, function(pane: any) { + pane.selected = false; + }); + pane.selected = true; + }; + + this.addPane = function(pane: any) { + if (panes.length === 0) { + $scope['select'](pane); + } + panes.push(pane); + }; + }, + templateUrl: 'my-tabs.html' + }; + }) + .directive('myPane', function() { + return { + require: '^myTabs', + restrict: 'E', + transclude: true, + scope: { + title: '@' + }, + link: function(scope: ng.IScope, element: ng.IAugmentedJQuery, attrs: ng.IAttributes, tabsCtrl: any) { + tabsCtrl.addPane(scope); + }, + templateUrl: 'my-pane.html' + }; + }); diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-1.2.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-1.2.d.ts new file mode 100644 index 00000000..fb21b030 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-1.2.d.ts @@ -0,0 +1,1189 @@ +// Type definitions for Angular JS 1.2+ +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +declare var angular: ng.IAngularStatic; + +// Support for painless dependency injection +interface Function { + $inject?: string[]; +} + +/////////////////////////////////////////////////////////////////////////////// +// ng module (angular.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng { + + // not directly implemented, but ensures that constructed class implements $get + interface IServiceProviderClass { + new(...args: any[]): IServiceProvider; + } + + interface IServiceProviderFactory { + (...args: any[]): IServiceProvider; + } + + // All service providers extend this interface + interface IServiceProvider { + $get: any; + } + + /////////////////////////////////////////////////////////////////////////// + // AngularStatic + // see http://docs.angularjs.org/api + /////////////////////////////////////////////////////////////////////////// + interface IAngularStatic { + bind(context: any, fn: Function, ...args: any[]): Function; + bootstrap(element: string, modules?: any[]): auto.IInjectorService; + bootstrap(element: JQuery, modules?: any[]): auto.IInjectorService; + bootstrap(element: Element, modules?: any[]): auto.IInjectorService; + bootstrap(element: Document, modules?: any[]): auto.IInjectorService; + copy(source: any, destination?: any): any; + element: IAugmentedJQueryStatic; + equals(value1: any, value2: any): boolean; + extend(destination: any, ...sources: any[]): any; + + /** + * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional. + * + * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method. + * + * @param obj Object to iterate over. + * @param iterator Iterator function. + * @param context Object to become context (this) for the iterator function. + */ + forEach(obj: T[], iterator: (value: T, key: number) => any, context?: any): any; + /** + * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional. + * + * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method. + * + * @param obj Object to iterate over. + * @param iterator Iterator function. + * @param context Object to become context (this) for the iterator function. + */ + forEach(obj: { [index: string]: T; }, iterator: (value: T, key: string) => any, context?: any): any; + /** + * Invokes the iterator function once for each item in obj collection, which can be either an object or an array. The iterator function is invoked with iterator(value, key), where value is the value of an object property or an array element and key is the object property key or array element index. Specifying a context for the function is optional. + * + * It is worth noting that .forEach does not iterate over inherited properties because it filters using the hasOwnProperty method. + * + * @param obj Object to iterate over. + * @param iterator Iterator function. + * @param context Object to become context (this) for the iterator function. + */ + forEach(obj: any, iterator: (value: any, key: any) => any, context?: any): any; + + fromJson(json: string): any; + identity(arg?: any): any; + injector(modules?: any[]): auto.IInjectorService; + isArray(value: any): boolean; + isDate(value: any): boolean; + isDefined(value: any): boolean; + isElement(value: any): boolean; + isFunction(value: any): boolean; + isNumber(value: any): boolean; + isObject(value: any): boolean; + isString(value: any): boolean; + isUndefined(value: any): boolean; + lowercase(str: string): string; + + /** + * The angular.module is a global place for creating, registering and retrieving Angular modules. All modules (angular core or 3rd party) that should be available to an application must be registered using this mechanism. + * + * When passed two or more arguments, a new module is created. If passed only one argument, an existing module (the name passed as the first argument to module) is retrieved. + * + * @param name The name of the module to create or retrieve. + * @param requires The names of modules this module depends on. If specified then new module is being created. If unspecified then the module is being retrieved for further configuration. + * @param configFn Optional configuration function for the module. + */ + module( + name: string, + requires?: string[], + configFn?: Function): IModule; + + noop(...args: any[]): void; + toJson(obj: any, pretty?: boolean): string; + uppercase(str: string): string; + version: { + full: string; + major: number; + minor: number; + dot: number; + codename: string; + }; + } + + /////////////////////////////////////////////////////////////////////////// + // Module + // see http://docs.angularjs.org/api/angular.Module + /////////////////////////////////////////////////////////////////////////// + interface IModule { + animation(name: string, animationFactory: Function): IModule; + animation(name: string, inlineAnnotatedFunction: any[]): IModule; + animation(object: Object): IModule; + /** + * Use this method to register work which needs to be performed on module loading. + * + * @param configFn Execute this function on module load. Useful for service configuration. + */ + config(configFn: Function): IModule; + /** + * Use this method to register work which needs to be performed on module loading. + * + * @param inlineAnnotatedFunction Execute this function on module load. Useful for service configuration. + */ + config(inlineAnnotatedFunction: any[]): IModule; + /** + * Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator. + * + * @param name The name of the constant. + * @param value The constant value. + */ + constant(name: string, value: any): IModule; + constant(object: Object): IModule; + /** + * The $controller service is used by Angular to create new controllers. + * + * This provider allows controller registration via the register method. + * + * @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors. + * @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation). + */ + controller(name: string, controllerConstructor: Function): IModule; + /** + * The $controller service is used by Angular to create new controllers. + * + * This provider allows controller registration via the register method. + * + * @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors. + * @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation). + */ + controller(name: string, inlineAnnotatedConstructor: any[]): IModule; + controller(object : Object): IModule; + directive(name: string, directiveFactory: IDirectiveFactory): IModule; + directive(name: string, inlineAnnotatedFunction: any[]): IModule; + directive(object: Object): IModule; + /** + * Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider. + * + * @param name The name of the instance. + * @param $getFn The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}). + */ + factory(name: string, $getFn: Function): IModule; + /** + * Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider. + * + * @param name The name of the instance. + * @param inlineAnnotatedFunction The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}). + */ + factory(name: string, inlineAnnotatedFunction: any[]): IModule; + factory(object: Object): IModule; + filter(name: string, filterFactoryFunction: Function): IModule; + filter(name: string, inlineAnnotatedFunction: any[]): IModule; + filter(object: Object): IModule; + provider(name: string, serviceProviderFactory: IServiceProviderFactory): IModule; + provider(name: string, serviceProviderConstructor: IServiceProviderClass): IModule; + provider(name: string, inlineAnnotatedConstructor: any[]): IModule; + provider(name: string, providerObject: IServiceProvider): IModule; + provider(object: Object): IModule; + /** + * Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests. + */ + run(initializationFunction: Function): IModule; + /** + * Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests. + */ + run(inlineAnnotatedFunction: any[]): IModule; + service(name: string, serviceConstructor: Function): IModule; + service(name: string, inlineAnnotatedConstructor: any[]): IModule; + service(object: Object): IModule; + /** + * Register a value service with the $injector, such as a string, a number, an array, an object or a function. This is short for registering a service where its provider's $get property is a factory function that takes no arguments and returns the value service. + + Value services are similar to constant services, except that they cannot be injected into a module configuration function (see config) but they can be overridden by an Angular decorator. + * + * @param name The name of the instance. + * @param value The value. + */ + value(name: string, value: any): IModule; + value(object: Object): IModule; + + // Properties + name: string; + requires: string[]; + } + + /////////////////////////////////////////////////////////////////////////// + // Attributes + // see http://docs.angularjs.org/api/ng.$compile.directive.Attributes + /////////////////////////////////////////////////////////////////////////// + interface IAttributes { + // this is necessary to be able to access the scoped attributes. it's not very elegant + // because you have to use attrs['foo'] instead of attrs.foo but I don't know of a better way + // this should really be limited to return string but it creates this problem: http://stackoverflow.com/q/17201854/165656 + [name: string]: any; + + // Adds the CSS class value specified by the classVal parameter to the + // element. If animations are enabled then an animation will be triggered + // for the class addition. + $addClass(classVal: string): void; + + // Removes the CSS class value specified by the classVal parameter from the + // element. If animations are enabled then an animation will be triggered for + // the class removal. + $removeClass(classVal: string): void; + + // Set DOM element attribute value. + $set(key: string, value: any): void; + + // Observes an interpolated attribute. + // The observer function will be invoked once during the next $digest + // following compilation. The observer is then invoked whenever the + // interpolated value changes. + $observe(name: string, fn:(value?:any)=>any): Function; + + // A map of DOM element attribute names to the normalized name. This is needed + // to do reverse lookup from normalized name back to actual name. + $attr: Object; + } + + /** + * form.FormController - type in module ng + * see https://docs.angularjs.org/api/ng/type/form.FormController + */ + interface IFormController { + + /** + * Indexer which should return ng.INgModelController for most properties but cannot because of "All named properties must be assignable to string indexer type" constraint - see https://github.com/Microsoft/TypeScript/issues/272 + */ + [name: string]: any; + + $pristine: boolean; + $dirty: boolean; + $valid: boolean; + $invalid: boolean; + $error: any; + $addControl(control: ng.INgModelController): void; + $removeControl(control: ng.INgModelController): void; + $setValidity(validationErrorKey: string, isValid: boolean, control: ng.INgModelController): void; + $setDirty(): void; + $setPristine(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // NgModelController + // see http://docs.angularjs.org/api/ng.directive:ngModel.NgModelController + /////////////////////////////////////////////////////////////////////////// + interface INgModelController { + $render(): void; + $setValidity(validationErrorKey: string, isValid: boolean): void; + // Documentation states viewValue and modelValue to be a string but other + // types do work and it's common to use them. + $setViewValue(value: any): void; + $viewValue: any; + + $modelValue: any; + + $parsers: IModelParser[]; + $formatters: IModelFormatter[]; + $viewChangeListeners: IModelViewChangeListener[]; + $error: any; + $pristine: boolean; + $dirty: boolean; + $valid: boolean; + $invalid: boolean; + } + + interface IModelParser { + (value: any): any; + } + + interface IModelFormatter { + (value: any): any; + } + + interface IModelViewChangeListener { + (): void; + } + + /////////////////////////////////////////////////////////////////////////// + // Scope and RootScope + // see https://docs.angularjs.org/api/ng/type/$rootScope.Scope and http://docs.angularjs.org/api/ng.$rootScope + /////////////////////////////////////////////////////////////////////////// + interface IRootScopeService { + $apply(): any; + $apply(exp: string): any; + $apply(exp: (scope: IScope) => any): any; + + $broadcast(name: string, ...args: any[]): IAngularEvent; + $destroy(): void; + $digest(): void; + $emit(name: string, ...args: any[]): IAngularEvent; + + // Documentation says exp is optional, but actual implementaton counts on it + $eval(expression: string, args?: Object): any; + $eval(expression: (scope: IScope) => any, args?: Object): any; + + // Documentation says exp is optional, but actual implementaton counts on it + $evalAsync(expression: string): void; + $evalAsync(expression: (scope: IScope) => any): void; + + // Defaults to false by the implementation checking strategy + $new(isolate?: boolean): IScope; + + $on(name: string, listener: (event: IAngularEvent, ...args: any[]) => any): Function; + + $watch(watchExpression: string, listener?: string, objectEquality?: boolean): Function; + $watch(watchExpression: string, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function; + $watch(watchExpression: (scope: IScope) => any, listener?: string, objectEquality?: boolean): Function; + $watch(watchExpression: (scope: IScope) => any, listener?: (newValue: any, oldValue: any, scope: IScope) => any, objectEquality?: boolean): Function; + + $watchCollection(watchExpression: string, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; + $watchCollection(watchExpression: (scope: IScope) => any, listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; + + $watchGroup(watchExpressions: any[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; + $watchGroup(watchExpressions: {(scope: IScope) : any}[], listener: (newValue: any, oldValue: any, scope: IScope) => any): Function; + + $parent: IScope; + + $root: IRootScopeService; + this: IRootScopeService; + + $id: string; + + // Hidden members + $$isolateBindings: any; + $$phase: any; + } + + interface IScope extends IRootScopeService { + [index: string]: any; + } + + interface IAngularEvent { + targetScope: IScope; + currentScope: IScope; + name: string; + preventDefault: Function; + defaultPrevented: boolean; + + // Available only events that were $emit-ted + stopPropagation?: Function; + } + + /////////////////////////////////////////////////////////////////////////// + // WindowService + // see http://docs.angularjs.org/api/ng.$window + /////////////////////////////////////////////////////////////////////////// + interface IWindowService extends Window { + [key: string]: any; + } + + /////////////////////////////////////////////////////////////////////////// + // BrowserService + // TODO undocumented, so we need to get it from the source code + /////////////////////////////////////////////////////////////////////////// + interface IBrowserService { + [key: string]: any; + } + + /////////////////////////////////////////////////////////////////////////// + // TimeoutService + // see http://docs.angularjs.org/api/ng.$timeout + /////////////////////////////////////////////////////////////////////////// + interface ITimeoutService { + (func: Function, delay?: number, invokeApply?: boolean): IPromise; + cancel(promise: IPromise): boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // IntervalService + // see http://docs.angularjs.org/api/ng.$interval + /////////////////////////////////////////////////////////////////////////// + interface IIntervalService { + (func: Function, delay: number, count?: number, invokeApply?: boolean): IPromise; + cancel(promise: IPromise): boolean; + } + + /** + * The animation object which contains callback functions for each event that is expected to be animated. + */ + interface IAnimateCallbackObject { + eventFn(element: Node, doneFn: () => void): Function; + } + + /////////////////////////////////////////////////////////////////////////// + // FilterService + // see http://docs.angularjs.org/api/ng.$filter + // see http://docs.angularjs.org/api/ng.$filterProvider + /////////////////////////////////////////////////////////////////////////// + interface IFilterService { + (name: string): Function; + } + + interface IFilterProvider extends IServiceProvider { + register(name: string, filterFactory: Function): IServiceProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // LocaleService + // see http://docs.angularjs.org/api/ng.$locale + /////////////////////////////////////////////////////////////////////////// + interface ILocaleService { + id: string; + + // These are not documented + // Check angular's i18n files for exemples + NUMBER_FORMATS: ILocaleNumberFormatDescriptor; + DATETIME_FORMATS: ILocaleDateTimeFormatDescriptor; + pluralCat: (num: any) => string; + } + + interface ILocaleNumberFormatDescriptor { + DECIMAL_SEP: string; + GROUP_SEP: string; + PATTERNS: ILocaleNumberPatternDescriptor[]; + CURRENCY_SYM: string; + } + + interface ILocaleNumberPatternDescriptor { + minInt: number; + minFrac: number; + maxFrac: number; + posPre: string; + posSuf: string; + negPre: string; + negSuf: string; + gSize: number; + lgSize: number; + } + + interface ILocaleDateTimeFormatDescriptor { + MONTH: string[]; + SHORTMONTH: string[]; + DAY: string[]; + SHORTDAY: string[]; + AMPMS: string[]; + medium: string; + short: string; + fullDate: string; + longDate: string; + mediumDate: string; + shortDate: string; + mediumTime: string; + shortTime: string; + } + + /////////////////////////////////////////////////////////////////////////// + // LogService + // see http://docs.angularjs.org/api/ng.$log + // see http://docs.angularjs.org/api/ng.$logProvider + /////////////////////////////////////////////////////////////////////////// + interface ILogService { + debug: ILogCall; + error: ILogCall; + info: ILogCall; + log: ILogCall; + warn: ILogCall; + } + + interface ILogProvider { + debugEnabled(enabled: boolean): ILogProvider; + debugEnabled(): boolean; + } + + // We define this as separete interface so we can reopen it later for + // the ngMock module. + interface ILogCall { + (...args: any[]): void; + } + + /////////////////////////////////////////////////////////////////////////// + // ParseService + // see http://docs.angularjs.org/api/ng.$parse + // see http://docs.angularjs.org/api/ng.$parseProvider + /////////////////////////////////////////////////////////////////////////// + interface IParseService { + (expression: string): ICompiledExpression; + } + + interface IParseProvider { + logPromiseWarnings(): boolean; + logPromiseWarnings(value: boolean): IParseProvider; + + unwrapPromises(): boolean; + unwrapPromises(value: boolean): IParseProvider; + } + + interface ICompiledExpression { + (context: any, locals?: any): any; + + // If value is not provided, undefined is gonna be used since the implementation + // does not check the parameter. Let's force a value for consistency. If consumer + // whants to undefine it, pass the undefined value explicitly. + assign(context: any, value: any): any; + } + + /////////////////////////////////////////////////////////////////////////// + // LocationService + // see http://docs.angularjs.org/api/ng.$location + // see http://docs.angularjs.org/api/ng.$locationProvider + // see http://docs.angularjs.org/guide/dev_guide.services.$location + /////////////////////////////////////////////////////////////////////////// + interface ILocationService { + absUrl(): string; + hash(): string; + hash(newHash: string): ILocationService; + host(): string; + path(): string; + path(newPath: string): ILocationService; + port(): number; + protocol(): string; + replace(): ILocationService; + search(): any; + search(parametersMap: any): ILocationService; + search(parameter: string, parameterValue: any): ILocationService; + url(): string; + url(url: string): ILocationService; + } + + interface ILocationProvider extends IServiceProvider { + hashPrefix(): string; + hashPrefix(prefix: string): ILocationProvider; + html5Mode(): boolean; + + // Documentation states that parameter is string, but + // implementation tests it as boolean, which makes more sense + // since this is a toggler + html5Mode(active: boolean): ILocationProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // DocumentService + // see http://docs.angularjs.org/api/ng.$document + /////////////////////////////////////////////////////////////////////////// + interface IDocumentService extends IAugmentedJQuery {} + + /////////////////////////////////////////////////////////////////////////// + // ExceptionHandlerService + // see http://docs.angularjs.org/api/ng.$exceptionHandler + /////////////////////////////////////////////////////////////////////////// + interface IExceptionHandlerService { + (exception: Error, cause?: string): void; + } + + /////////////////////////////////////////////////////////////////////////// + // RootElementService + // see http://docs.angularjs.org/api/ng.$rootElement + /////////////////////////////////////////////////////////////////////////// + interface IRootElementService extends JQuery {} + + /** + * $q - service in module ng + * A promise/deferred implementation inspired by Kris Kowal's Q. + * See http://docs.angularjs.org/api/ng/service/$q + */ + interface IQService { + /** + * Combines multiple promises into a single promise that is resolved when all of the input promises are resolved. + * + * Returns a single promise that will be resolved with an array/hash of values, each value corresponding to the promise at the same index/key in the promises array/hash. If any of the promises is resolved with a rejection, this resulting promise will be rejected with the same rejection value. + * + * @param promises An array or hash of promises. + */ + all(promises: IPromise[]): IPromise; + /** + * Combines multiple promises into a single promise that is resolved when all of the input promises are resolved. + * + * Returns a single promise that will be resolved with an array/hash of values, each value corresponding to the promise at the same index/key in the promises array/hash. If any of the promises is resolved with a rejection, this resulting promise will be rejected with the same rejection value. + * + * @param promises An array or hash of promises. + */ + all(promises: { [id: string]: IPromise; }): IPromise<{ [id: string]: any }>; + /** + * Creates a Deferred object which represents a task which will finish in the future. + */ + defer(): IDeferred; + /** + * Creates a promise that is resolved as rejected with the specified reason. This api should be used to forward rejection in a chain of promises. If you are dealing with the last promise in a promise chain, you don't need to worry about it. + * + * When comparing deferreds/promises to the familiar behavior of try/catch/throw, think of reject as the throw keyword in JavaScript. This also means that if you "catch" an error via a promise error callback and you want to forward the error to the promise derived from the current promise, you have to "rethrow" the error by returning a rejection constructed via reject. + * + * @param reason Constant, message, exception or an object representing the rejection reason. + */ + reject(reason?: any): IPromise; + /** + * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted. + * + * @param value Value or a promise + */ + when(value: IPromise): IPromise; + /** + * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted. + * + * @param value Value or a promise + */ + when(value: T): IPromise; + /** + * Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted. + * + * @param value Value or a promise + */ + when(): IPromise; + } + + interface IPromise { + then(successCallback: (promiseValue: T) => IHttpPromise, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise; + then(successCallback: (promiseValue: T) => IPromise, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise; + then(successCallback: (promiseValue: T) => TResult, errorCallback?: (reason: any) => TResult, notifyCallback?: (state: any) => any): IPromise; + + + catch(onRejected: (reason: any) => IHttpPromise): IPromise; + catch(onRejected: (reason: any) => IPromise): IPromise; + catch(onRejected: (reason: any) => TResult): IPromise; + + finally(finallyCallback: ()=>any):IPromise; + } + + interface IDeferred { + resolve(value?: T): void; + reject(reason?: any): void; + notify(state?:any): void; + promise: IPromise; + } + + /////////////////////////////////////////////////////////////////////////// + // AnchorScrollService + // see http://docs.angularjs.org/api/ng.$anchorScroll + /////////////////////////////////////////////////////////////////////////// + interface IAnchorScrollService { + (): void; + } + + interface IAnchorScrollProvider extends IServiceProvider { + disableAutoScrolling(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // CacheFactoryService + // see http://docs.angularjs.org/api/ng.$cacheFactory + /////////////////////////////////////////////////////////////////////////// + interface ICacheFactoryService { + // Lets not foce the optionsMap to have the capacity member. Even though + // it's the ONLY option considered by the implementation today, a consumer + // might find it useful to associate some other options to the cache object. + //(cacheId: string, optionsMap?: { capacity: number; }): CacheObject; + (cacheId: string, optionsMap?: { capacity: number; }): ICacheObject; + + // Methods bellow are not documented + info(): any; + get (cacheId: string): ICacheObject; + } + + interface ICacheObject { + info(): { + id: string; + size: number; + + // Not garanteed to have, since it's a non-mandatory option + //capacity: number; + }; + put(key: string, value?: any): void; + get (key: string): any; + remove(key: string): void; + removeAll(): void; + destroy(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // CompileService + // see http://docs.angularjs.org/api/ng.$compile + // see http://docs.angularjs.org/api/ng.$compileProvider + /////////////////////////////////////////////////////////////////////////// + interface ICompileService { + (element: string, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction; + (element: Element, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction; + (element: JQuery, transclude?: ITranscludeFunction, maxPriority?: number): ITemplateLinkingFunction; + } + + interface ICompileProvider extends IServiceProvider { + directive(name: string, directiveFactory: Function): ICompileProvider; + + // Undocumented, but it is there... + directive(directivesMap: any): ICompileProvider; + + aHrefSanitizationWhitelist(): RegExp; + aHrefSanitizationWhitelist(regexp: RegExp): ICompileProvider; + + imgSrcSanitizationWhitelist(): RegExp; + imgSrcSanitizationWhitelist(regexp: RegExp): ICompileProvider; + } + + interface ICloneAttachFunction { + // Let's hint but not force cloneAttachFn's signature + (clonedElement?: JQuery, scope?: IScope): any; + } + + // This corresponds to the "publicLinkFn" returned by $compile. + interface ITemplateLinkingFunction { + (scope: IScope, cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery; + } + + // This corresponds to $transclude (and also the transclude function passed to link). + interface ITranscludeFunction { + // If the scope is provided, then the cloneAttachFn must be as well. + (scope: IScope, cloneAttachFn: ICloneAttachFunction): IAugmentedJQuery; + // If one argument is provided, then it's assumed to be the cloneAttachFn. + (cloneAttachFn?: ICloneAttachFunction): IAugmentedJQuery; + } + + /////////////////////////////////////////////////////////////////////////// + // ControllerService + // see http://docs.angularjs.org/api/ng.$controller + // see http://docs.angularjs.org/api/ng.$controllerProvider + /////////////////////////////////////////////////////////////////////////// + interface IControllerService { + // Although the documentation doesn't state this, locals are optional + (controllerConstructor: Function, locals?: any): any; + (controllerName: string, locals?: any): any; + } + + interface IControllerProvider extends IServiceProvider { + register(name: string, controllerConstructor: Function): void; + register(name: string, dependencyAnnotatedConstructor: any[]): void; + } + + /** + * HttpService + * see http://docs.angularjs.org/api/ng/service/$http + */ + interface IHttpService { + /** + * Object describing the request to be made and how it should be processed. + */ + (config: IRequestConfig): IHttpPromise; + + /** + * Shortcut method to perform GET request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param config Optional configuration object + */ + get(url: string, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform DELETE request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param config Optional configuration object + */ + delete(url: string, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform HEAD request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param config Optional configuration object + */ + head(url: string, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform JSONP request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param config Optional configuration object + */ + jsonp(url: string, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform POST request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param data Request content + * @param config Optional configuration object + */ + post(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Shortcut method to perform PUT request. + * + * @param url Relative or absolute URL specifying the destination of the request + * @param data Request content + * @param config Optional configuration object + */ + put(url: string, data: any, config?: IRequestShortcutConfig): IHttpPromise; + + /** + * Runtime equivalent of the $httpProvider.defaults property. Allows configuration of default headers, withCredentials as well as request and response transformations. + */ + defaults: IRequestConfig; + + /** + * Array of config objects for currently pending requests. This is primarily meant to be used for debugging purposes. + */ + pendingRequests: any[]; + } + + /** + * Object describing the request to be made and how it should be processed. + * see http://docs.angularjs.org/api/ng/service/$http#usage + */ + interface IRequestShortcutConfig { + /** + * {Object.} + * Map of strings or objects which will be turned to ?key1=value1&key2=value2 after the url. If the value is not a string, it will be JSONified. + */ + params?: any; + + /** + * Map of strings or functions which return strings representing HTTP headers to send to the server. If the return value of a function is null, the header will not be sent. + */ + headers?: any; + + /** + * Name of HTTP header to populate with the XSRF token. + */ + xsrfHeaderName?: string; + + /** + * Name of cookie containing the XSRF token. + */ + xsrfCookieName?: string; + + /** + * {boolean|Cache} + * If true, a default $http cache will be used to cache the GET request, otherwise if a cache instance built with $cacheFactory, this cache will be used for caching. + */ + cache?: any; + + /** + * whether to to set the withCredentials flag on the XHR object. See [requests with credentials]https://developer.mozilla.org/en/http_access_control#section_5 for more information. + */ + withCredentials?: boolean; + + /** + * {string|Object} + * Data to be sent as the request message data. + */ + data?: any; + + /** + * {function(data, headersGetter)|Array.} + * Transform function or an array of such functions. The transform function takes the http request body and headers and returns its transformed (typically serialized) version. + */ + transformRequest?: any; + + /** + * {function(data, headersGetter)|Array.} + * Transform function or an array of such functions. The transform function takes the http response body and headers and returns its transformed (typically deserialized) version. + */ + transformResponse?: any; + + /** + * {number|Promise} + * Timeout in milliseconds, or promise that should abort the request when resolved. + */ + timeout?: any; + + /** + * See requestType. + */ + responseType?: string; + } + + /** + * Object describing the request to be made and how it should be processed. + * see http://docs.angularjs.org/api/ng/service/$http#usage + */ + interface IRequestConfig extends IRequestShortcutConfig { + /** + * HTTP method (e.g. 'GET', 'POST', etc) + */ + method: string; + /** + * Absolute or relative URL of the resource that is being requested. + */ + url: string; + } + + interface IHttpPromiseCallback { + (data: T, status: number, headers: (headerName: string) => string, config: IRequestConfig): void; + } + + interface IHttpPromiseCallbackArg { + data?: T; + status?: number; + headers?: (headerName: string) => string; + config?: IRequestConfig; + statusText?: string; + } + + interface IHttpPromise extends IPromise { + success(callback: IHttpPromiseCallback): IHttpPromise; + error(callback: IHttpPromiseCallback): IHttpPromise; + then(successCallback: (response: IHttpPromiseCallbackArg) => IPromise, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise; + then(successCallback: (response: IHttpPromiseCallbackArg) => TResult, errorCallback?: (response: IHttpPromiseCallbackArg) => any): IPromise; + } + + interface IHttpProvider extends IServiceProvider { + defaults: IRequestConfig; + interceptors: any[]; + responseInterceptors: any[]; + } + + /////////////////////////////////////////////////////////////////////////// + // HttpBackendService + // see http://docs.angularjs.org/api/ng.$httpBackend + // You should never need to use this service directly. + /////////////////////////////////////////////////////////////////////////// + interface IHttpBackendService { + // XXX Perhaps define callback signature in the future + (method: string, url: string, post?: any, callback?: Function, headers?: any, timeout?: number, withCredentials?: boolean): void; + } + + /////////////////////////////////////////////////////////////////////////// + // InterpolateService + // see http://docs.angularjs.org/api/ng.$interpolate + // see http://docs.angularjs.org/api/ng.$interpolateProvider + /////////////////////////////////////////////////////////////////////////// + interface IInterpolateService { + (text: string, mustHaveExpression?: boolean): IInterpolationFunction; + endSymbol(): string; + startSymbol(): string; + } + + interface IInterpolationFunction { + (context: any): string; + } + + interface IInterpolateProvider extends IServiceProvider { + startSymbol(): string; + startSymbol(value: string): IInterpolateProvider; + endSymbol(): string; + endSymbol(value: string): IInterpolateProvider; + } + + /////////////////////////////////////////////////////////////////////////// + // TemplateCacheService + // see http://docs.angularjs.org/api/ng.$templateCache + /////////////////////////////////////////////////////////////////////////// + interface ITemplateCacheService extends ICacheObject {} + + /////////////////////////////////////////////////////////////////////////// + // SCEService + // see http://docs.angularjs.org/api/ng.$sce + /////////////////////////////////////////////////////////////////////////// + interface ISCEService { + getTrusted(type: string, mayBeTrusted: any): any; + getTrustedCss(value: any): any; + getTrustedHtml(value: any): any; + getTrustedJs(value: any): any; + getTrustedResourceUrl(value: any): any; + getTrustedUrl(value: any): any; + parse(type: string, expression: string): (context: any, locals: any) => any; + parseAsCss(expression: string): (context: any, locals: any) => any; + parseAsHtml(expression: string): (context: any, locals: any) => any; + parseAsJs(expression: string): (context: any, locals: any) => any; + parseAsResourceUrl(expression: string): (context: any, locals: any) => any; + parseAsUrl(expression: string): (context: any, locals: any) => any; + trustAs(type: string, value: any): any; + trustAsHtml(value: any): any; + trustAsJs(value: any): any; + trustAsResourceUrl(value: any): any; + trustAsUrl(value: any): any; + isEnabled(): boolean; + } + + /////////////////////////////////////////////////////////////////////////// + // SCEProvider + // see http://docs.angularjs.org/api/ng.$sceProvider + /////////////////////////////////////////////////////////////////////////// + interface ISCEProvider extends IServiceProvider { + enabled(value: boolean): void; + } + + /////////////////////////////////////////////////////////////////////////// + // SCEDelegateService + // see http://docs.angularjs.org/api/ng.$sceDelegate + /////////////////////////////////////////////////////////////////////////// + interface ISCEDelegateService { + getTrusted(type: string, mayBeTrusted: any): any; + trustAs(type: string, value: any): any; + valueOf(value: any): any; + } + + + /////////////////////////////////////////////////////////////////////////// + // SCEDelegateProvider + // see http://docs.angularjs.org/api/ng.$sceDelegateProvider + /////////////////////////////////////////////////////////////////////////// + interface ISCEDelegateProvider extends IServiceProvider { + resourceUrlBlacklist(blacklist: any[]): void; + resourceUrlWhitelist(whitelist: any[]): void; + } + + /////////////////////////////////////////////////////////////////////////// + // Directive + // see http://docs.angularjs.org/api/ng.$compileProvider#directive + // and http://docs.angularjs.org/guide/directive + /////////////////////////////////////////////////////////////////////////// + + interface IDirectiveFactory { + (...args: any[]): IDirective; + } + + interface IDirectiveLinkFn { + ( + scope: IScope, + instanceElement: IAugmentedJQuery, + instanceAttributes: IAttributes, + controller: any, + transclude: ITranscludeFunction + ): void; + } + + interface IDirectivePrePost { + pre?: IDirectiveLinkFn; + post?: IDirectiveLinkFn; + } + + interface IDirectiveCompileFn { + ( + templateElement: IAugmentedJQuery, + templateAttributes: IAttributes, + transclude: ITranscludeFunction + ): IDirectivePrePost; + } + + interface IDirective { + compile?: IDirectiveCompileFn; + controller?: any; + controllerAs?: string; + link?: IDirectiveLinkFn; + name?: string; + priority?: number; + replace?: boolean; + require?: any; + restrict?: string; + scope?: any; + template?: any; + templateUrl?: any; + terminal?: boolean; + transclude?: any; + } + + /////////////////////////////////////////////////////////////////////////// + // angular.element + // when calling angular.element, angular returns a jQuery object, + // augmented with additional methods like e.g. scope. + // see: http://docs.angularjs.org/api/angular.element + /////////////////////////////////////////////////////////////////////////// + interface IAugmentedJQueryStatic extends JQueryStatic { + (selector: string, context?: any): IAugmentedJQuery; + (element: Element): IAugmentedJQuery; + (object: {}): IAugmentedJQuery; + (elementArray: Element[]): IAugmentedJQuery; + (object: JQuery): IAugmentedJQuery; + (func: Function): IAugmentedJQuery; + (array: any[]): IAugmentedJQuery; + (): IAugmentedJQuery; + } + + interface IAugmentedJQuery extends JQuery { + // TODO: events, how to define? + //$destroy + + find(selector: string): IAugmentedJQuery; + find(element: any): IAugmentedJQuery; + find(obj: JQuery): IAugmentedJQuery; + + controller(name: string): any; + injector(): any; + scope(): IScope; + isolateScope(): IScope; + + inheritedData(key: string, value: any): JQuery; + inheritedData(obj: { [key: string]: any; }): JQuery; + inheritedData(key?: string): any; + } + + /////////////////////////////////////////////////////////////////////// + // AnimateService + // see http://docs.angularjs.org/api/ng.$animate + /////////////////////////////////////////////////////////////////////// + interface IAnimateService { + addClass(element: JQuery, className: string, done?: Function): void; + enter(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void; + leave(element: JQuery, done?: Function): void; + move(element: JQuery, parent: JQuery, after: JQuery, done?: Function): void; + removeClass(element: JQuery, className: string, done?: Function): void; + } + + /////////////////////////////////////////////////////////////////////////// + // AUTO module (angular.js) + /////////////////////////////////////////////////////////////////////////// + export module auto { + + /////////////////////////////////////////////////////////////////////// + // InjectorService + // see http://docs.angularjs.org/api/AUTO.$injector + /////////////////////////////////////////////////////////////////////// + interface IInjectorService { + annotate(fn: Function): string[]; + annotate(inlineAnnotatedFunction: any[]): string[]; + get(name: string): any; + has(name: string): boolean; + instantiate(typeConstructor: Function, locals?: any): any; + invoke(inlineAnnotatedFunction: any[]): any; + invoke(func: Function, context?: any, locals?: any): any; + } + + /////////////////////////////////////////////////////////////////////// + // ProvideService + // see http://docs.angularjs.org/api/AUTO.$provide + /////////////////////////////////////////////////////////////////////// + interface IProvideService { + // Documentation says it returns the registered instance, but actual + // implementation does not return anything. + // constant(name: string, value: any): any; + /** + * Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator. + * + * @param name The name of the constant. + * @param value The constant value. + */ + constant(name: string, value: any): void; + + /** + * Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service. + * + * @param name The name of the service to decorate. + * @param decorator This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments: + * + * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to. + */ + decorator(name: string, decorator: Function): void; + /** + * Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service. + * + * @param name The name of the service to decorate. + * @param inlineAnnotatedFunction This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments: + * + * $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to. + */ + decorator(name: string, inlineAnnotatedFunction: any[]): void; + factory(name: string, serviceFactoryFunction: Function): ng.IServiceProvider; + factory(name: string, inlineAnnotatedFunction: any[]): ng.IServiceProvider; + provider(name: string, provider: ng.IServiceProvider): ng.IServiceProvider; + provider(name: string, serviceProviderConstructor: Function): ng.IServiceProvider; + service(name: string, constructor: Function): ng.IServiceProvider; + value(name: string, value: any): ng.IServiceProvider; + } + + } +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-animate-1.2.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-animate-1.2.d.ts new file mode 100644 index 00000000..307e5076 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-animate-1.2.d.ts @@ -0,0 +1,110 @@ +// Type definitions for Angular JS 1.2 (ngAnimate module) +// Project: http://angularjs.org +// Definitions by: Michel Salib , Adi Dahiya +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +/////////////////////////////////////////////////////////////////////////////// +// ngAnimate module (angular-animate.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.animate { + + /////////////////////////////////////////////////////////////////////////// + // AnimateService + // see https://code.angularjs.org/1.2.26/docs/api/ngAnimate/service/$animate + /////////////////////////////////////////////////////////////////////////// + interface IAnimateService extends ng.IAnimateService { + /** + * Globally enables / disables animations. + * + * @param value If provided then set the animation on or off. + * @param element If provided then the element will be used to represent the enable/disable operation. + * @returns current animation state + */ + enabled(value?: boolean, element?: JQuery): boolean; + + /** + * Appends the element to the parentElement element that resides in the document and then runs the enter animation. + * + * @param element the element that will be the focus of the enter animation + * @param parentElement the parent element of the element that will be the focus of the enter animation + * @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation + * @param doneCallback the callback function that will be called once the animation is complete + */ + enter(element: JQuery, parentElement: JQuery, afterElement?: JQuery, doneCallback?: () => void): void; + + /** + * Runs the leave animation operation and, upon completion, removes the element from the DOM. + * + * @param element the element that will be the focus of the leave animation + * @param doneCallback the callback function that will be called once the animation is complete + */ + leave(element: JQuery, doneCallback?: () => void): void; + + /** + * Fires the move DOM operation. Just before the animation starts, the animate service will either append + * it into the parentElement container or add the element directly after the afterElement element if present. + * Then the move animation will be run. + * + * @param element the element that will be the focus of the move animation + * @param parentElement the parent element of the element that will be the focus of the move animation + * @param afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation + * @param doneCallback the callback function that will be called once the animation is complete + */ + move(element: JQuery, parentElement: JQuery, afterElement?: JQuery, doneCallback?: () => void): void; + + /** + * Triggers a custom animation event based off the className variable and then attaches the className + * value to the element as a CSS class. + * + * @param element the element that will be animated + * @param className the CSS class that will be added to the element and then animated + * @param doneCallback the callback function that will be called once the animation is complete + */ + addClass(element: JQuery, className: string, doneCallback?: () => void): void; + + /** + * Triggers a custom animation event based off the className variable and then removes the CSS class + * provided by the className value from the element. + * + * @param element the element that will be animated + * @param className the CSS class that will be animated and then removed from the element + * @param doneCallback the callback function that will be called once the animation is complete + */ + removeClass(element: JQuery, className: string, doneCallback?: () => void): void; + + /** + * Adds and/or removes the given CSS classes to and from the element. Once complete, the done() callback + * will be fired (if provided). + * + * @param element the element which will have its CSS classes changed removed from it + * @param add the CSS classes which will be added to the element + * @param remove the CSS class which will be removed from the element CSS classes have been set on the element + * @param doneCallback done the callback function (if provided) that will be fired after the CSS classes have been set on the element + */ + setClass(element: JQuery, add: string, remove: string, doneCallback?: () => void): void; + } + + /////////////////////////////////////////////////////////////////////////// + // AngularProvider + // see https://code.angularjs.org/1.2.26/docs/api/ngAnimate/provider/$animateProvider + /////////////////////////////////////////////////////////////////////////// + interface IAnimateProvider { + /** + * Registers a new injectable animation factory function. + * + * @param name The name of the animation. + * @param factory The factory function that will be executed to return the animation object. + */ + register(name: string, factory: () => ng.IAnimateCallbackObject): void; + + /** + * Gets and/or sets the CSS class expression that is checked when performing an animation. + * + * @param expression The className expression which will be checked against all animations. + * @returns The current CSS className expression value. If null then there is no expression value. + */ + classNameFilter(expression?: RegExp): RegExp; + } +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-cookies-1.0.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-cookies-1.0.d.ts new file mode 100644 index 00000000..b451dc43 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-cookies-1.0.d.ts @@ -0,0 +1,30 @@ +/// Type definitions for Angular JS 1.0 (ngCookies module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +/////////////////////////////////////////////////////////////////////////////// +// ngCookies module (angular-cookies.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.cookies { + + /////////////////////////////////////////////////////////////////////////// + // CookieService + // see http://docs.angularjs.org/api/ngCookies.$cookies + /////////////////////////////////////////////////////////////////////////// + interface ICookiesService {} + + /////////////////////////////////////////////////////////////////////////// + // CookieStoreService + // see http://docs.angularjs.org/api/ngCookies.$cookieStore + /////////////////////////////////////////////////////////////////////////// + interface ICookieStoreService { + get(key: string): any; + put(key: string, value: any): void; + remove(key: string): void; + } + +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-cookies-1.2.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-cookies-1.2.d.ts new file mode 100644 index 00000000..c5ff512e --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-cookies-1.2.d.ts @@ -0,0 +1,43 @@ +// Type definitions for Angular JS 1.2 (ngCookies module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +/////////////////////////////////////////////////////////////////////////////// +// ngCookies module (angular-cookies.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.cookies { + + /////////////////////////////////////////////////////////////////////////// + // CookieService + // see https://code.angularjs.org/1.2.26/docs/api/ngCookies/service/$cookies + /////////////////////////////////////////////////////////////////////////// + interface ICookiesService {} + + /////////////////////////////////////////////////////////////////////////// + // CookieStoreService + // see https://code.angularjs.org/1.2.26/docs/api/ngCookies/service/$cookieStore + /////////////////////////////////////////////////////////////////////////// + interface ICookieStoreService { + /** + * Returns the value of given cookie key + * @param key Id to use for lookup + */ + get(key: string): any; + /** + * Sets a value for given cookie key + * @param key Id for the value + * @param value Value to be stored + */ + put(key: string, value: any): void; + /** + * Remove given cookie + * @param key Id of the key-value pair to delete + */ + remove(key: string): void; + } + +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-mocks-1.0.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-mocks-1.0.d.ts new file mode 100644 index 00000000..56f78092 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-mocks-1.0.d.ts @@ -0,0 +1,150 @@ +// Type definitions for Angular JS 1.0 (ngMock, ngMockE2E module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +/////////////////////////////////////////////////////////////////////////////// +// functions attached to global object (window) +/////////////////////////////////////////////////////////////////////////////// +declare var module: (...modules: any[]) => any; +declare var inject: (...fns: Function[]) => any; + +/////////////////////////////////////////////////////////////////////////////// +// ngMock module (angular-mocks.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng { + + /////////////////////////////////////////////////////////////////////////// + // AngularStatic + // We reopen it to add the MockStatic definition + /////////////////////////////////////////////////////////////////////////// + interface IAngularStatic { + mock: IMockStatic; + } + + interface IMockStatic { + // see http://docs.angularjs.org/api/angular.mock.debug + debug(obj: any): string; + + // see http://docs.angularjs.org/api/angular.mock.inject + inject(...fns: Function[]): any; + + // see http://docs.angularjs.org/api/angular.mock.module + module(...modules: any[]): any; + + // see http://docs.angularjs.org/api/angular.mock.TzDate + TzDate(offset: number, timestamp: number): Date; + TzDate(offset: number, timestamp: string): Date; + } + + /////////////////////////////////////////////////////////////////////////// + // ExceptionHandlerService + // see http://docs.angularjs.org/api/ngMock.$exceptionHandler + // see http://docs.angularjs.org/api/ngMock.$exceptionHandlerProvider + /////////////////////////////////////////////////////////////////////////// + interface IExceptionHandlerProvider extends IServiceProvider { + mode(mode: string): void; + } + + /////////////////////////////////////////////////////////////////////////// + // TimeoutService + // see http://docs.angularjs.org/api/ngMock.$timeout + // Augments the original service + /////////////////////////////////////////////////////////////////////////// + interface ITimeoutService { + flush(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // LogService + // see http://docs.angularjs.org/api/ngMock.$log + // Augments the original service + /////////////////////////////////////////////////////////////////////////// + interface ILogService { + assertEmpty(): void; + reset(): void; + } + + interface LogCall { + logs: string[]; + } + + /////////////////////////////////////////////////////////////////////////// + // HttpBackendService + // see http://docs.angularjs.org/api/ngMock.$httpBackend + /////////////////////////////////////////////////////////////////////////// + interface IHttpBackendService { + flush(count?: number): void; + resetExpectations(): void; + verifyNoOutstandingExpectation(): void; + verifyNoOutstandingRequest(): void; + + expect(method: string, url: string, data?: any, headers?: any): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: any, headers?: any): mock.IRequestHandler; + expect(method: RegExp, url: string, data?: any, headers?: any): mock.IRequestHandler; + expect(method: RegExp, url: RegExp, data?: any, headers?: any): mock.IRequestHandler; + + when(method: string, url: string, data?: string, headers?: any): mock.IRequestHandler; + when(method: string, url: RegExp, data?: string, headers?: any): mock.IRequestHandler; + when(method: string, url: string, data?: RegExp, headers?: any): mock.IRequestHandler; + when(method: string, url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler; + when(method: RegExp, url: string, data?: string, headers?: any): mock.IRequestHandler; + when(method: RegExp, url: RegExp, data?: string, headers?: any): mock.IRequestHandler; + when(method: RegExp, url: string, data?: RegExp, headers?: any): mock.IRequestHandler; + when(method: RegExp, url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler; + + expectDELETE(url: string, headers?: any): mock.IRequestHandler; + expectDELETE(url: RegExp, headers?: any): mock.IRequestHandler; + expectGET(url: string, headers?: any): mock.IRequestHandler; + expectGET(url: RegExp, headers?: any): mock.IRequestHandler; + expectHEAD(url: string, headers?: any): mock.IRequestHandler; + expectHEAD(url: RegExp, headers?: any): mock.IRequestHandler; + expectJSONP(url: string): mock.IRequestHandler; + expectJSONP(url: RegExp): mock.IRequestHandler; + expectPATCH(url: string, data?: any, headers?: any): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: any, headers?: any): mock.IRequestHandler; + expectPOST(url: string, data?: any, headers?: any): mock.IRequestHandler; + expectPOST(url: RegExp, data?: any, headers?: any): mock.IRequestHandler; + expectPUT(url: string, data?: any, headers?: any): mock.IRequestHandler; + expectPUT(url: RegExp, data?: any, headers?: any): mock.IRequestHandler; + + whenDELETE(url: string, headers?: any): mock.IRequestHandler; + whenDELETE(url: RegExp, headers?: any): mock.IRequestHandler; + whenGET(url: string, headers?: any): mock.IRequestHandler; + whenGET(url: RegExp, headers?: any): mock.IRequestHandler; + whenHEAD(url: string, headers?: any): mock.IRequestHandler; + whenHEAD(url: RegExp, headers?: any): mock.IRequestHandler; + whenJSONP(url: string): mock.IRequestHandler; + whenJSONP(url: RegExp): mock.IRequestHandler; + whenPATCH(url: string, data?: string, headers?: any): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: string, headers?: any): mock.IRequestHandler; + whenPATCH(url: string, data?: RegExp, headers?: any): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler; + whenPOST(url: string, data?: string, headers?: any): mock.IRequestHandler; + whenPOST(url: RegExp, data?: string, headers?: any): mock.IRequestHandler; + whenPOST(url: string, data?: RegExp, headers?: any): mock.IRequestHandler; + whenPOST(url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler; + whenPUT(url: string, data?: string, headers?: any): mock.IRequestHandler; + whenPUT(url: RegExp, data?: string, headers?: any): mock.IRequestHandler; + whenPUT(url: string, data?: RegExp, headers?: any): mock.IRequestHandler; + whenPUT(url: RegExp, data?: RegExp, headers?: any): mock.IRequestHandler; + } + + export module mock { + + // returned interface by the the mocked HttpBackendService expect/when methods + interface IRequestHandler { + respond(func: Function): void; + respond(status: number, data?: any, headers?: any): void; + respond(data: any, headers?: any): void; + + // Available wehn ngMockE2E is loaded + passThrough(): void; + } + + } + +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-mocks-1.2-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-mocks-1.2-tests.ts new file mode 100644 index 00000000..6f359a67 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-mocks-1.2-tests.ts @@ -0,0 +1,305 @@ +/// + +/////////////////////////////////////// +// IAngularStatic +/////////////////////////////////////// +var angular: ng.IAngularStatic; +var mock: ng.IMockStatic; + +mock = angular.mock; + + +/////////////////////////////////////// +// IMockStatic +/////////////////////////////////////// +var date: Date; + +mock.dump({ key: 'value' }); + +mock.inject( + function () { return 1; }, + function () { return 2; } + ); + +mock.inject( + ['$rootScope', function ($rootScope: ng.IRootScopeService) { return 1; }]); + +// This overload is not documented on the website, but flows from +// how the injector works. +mock.inject( + ['$rootScope', function ($rootScope: ng.IRootScopeService) { return 1; }], + ['$rootScope', function ($rootScope: ng.IRootScopeService) { return 2; }]); + +mock.module('module1', 'module2'); +mock.module( + function () { return 1; }, + function () { return 2; } + ); +mock.module({ module1: function () { return 1; } }); + +date = mock.TzDate(-7, '2013-1-1T15:00:00Z'); +date = mock.TzDate(-8, 12345678); + + +/////////////////////////////////////// +// IExceptionHandlerProvider +/////////////////////////////////////// +var exceptionHandlerProvider: ng.IExceptionHandlerProvider; + +exceptionHandlerProvider.mode('log'); + + +/////////////////////////////////////// +// ITimeoutService +/////////////////////////////////////// +var timeoutService: ng.ITimeoutService; + +timeoutService.flush(); +timeoutService.flush(1234); +timeoutService.flushNext(); +timeoutService.flushNext(1234); +timeoutService.verifyNoPendingTasks(); + +//////////////////////////////////////// +// IIntervalService +//////////////////////////////////////// +var intervalService: ng.IIntervalService; +var intervalServiceTimeActuallyAdvanced: number; + +intervalServiceTimeActuallyAdvanced = intervalService.flush(); +intervalServiceTimeActuallyAdvanced = intervalService.flush(1234); + +/////////////////////////////////////// +// ILogService, ILogCall +/////////////////////////////////////// +var logService: ng.ILogService; +var logCall: ng.ILogCall; +var logs: string[]; + +logService.assertEmpty(); +logService.reset(); + +logCall = logService.debug; +logCall = logService.error; +logCall = logService.info; +logCall = logService.log; +logCall = logService.warn; + +logs = logCall.logs; + + +/////////////////////////////////////// +// IHttpBackendService +/////////////////////////////////////// +var httpBackendService: ng.IHttpBackendService; +var requestHandler: ng.mock.IRequestHandler; + +httpBackendService.flush(); +httpBackendService.flush(1234); +httpBackendService.resetExpectations(); +httpBackendService.verifyNoOutstandingExpectation(); +httpBackendService.verifyNoOutstandingRequest(); + +requestHandler = httpBackendService.expect('GET', 'http://test.local'); +requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data'); +requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', 'response data', function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/); +requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', /response data/, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', 'http://test.local', { key: 'value' }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/); +requestHandler = httpBackendService.expect('GET', /test.local/, 'response data'); +requestHandler = httpBackendService.expect('GET', /test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, 'response data', function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/, /response data/); +requestHandler = httpBackendService.expect('GET', /test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, /response data/, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expect('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; }); + +requestHandler = httpBackendService.expectDELETE('http://test.local'); +requestHandler = httpBackendService.expectDELETE('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.expectDELETE(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.expectGET('http://test.local'); +requestHandler = httpBackendService.expectGET('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.expectGET(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.expectHEAD('http://test.local'); +requestHandler = httpBackendService.expectHEAD('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.expectHEAD(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.expectJSONP('http://test.local'); +requestHandler = httpBackendService.expectJSONP(/test.local/); + +requestHandler = httpBackendService.expectPATCH('http://test.local'); +requestHandler = httpBackendService.expectPATCH('http://test.local', 'response data'); +requestHandler = httpBackendService.expectPATCH('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPATCH('http://test.local', /response data/); +requestHandler = httpBackendService.expectPATCH('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPATCH('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.expectPATCH('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/); +requestHandler = httpBackendService.expectPATCH(/test.local/, 'response data'); +requestHandler = httpBackendService.expectPATCH(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/, /response data/); +requestHandler = httpBackendService.expectPATCH(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.expectPATCH(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.expectPOST('http://test.local'); +requestHandler = httpBackendService.expectPOST('http://test.local', 'response data'); +requestHandler = httpBackendService.expectPOST('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPOST('http://test.local', /response data/); +requestHandler = httpBackendService.expectPOST('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPOST('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPOST('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPOST('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.expectPOST('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/); +requestHandler = httpBackendService.expectPOST(/test.local/, 'response data'); +requestHandler = httpBackendService.expectPOST(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/, /response data/); +requestHandler = httpBackendService.expectPOST(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.expectPOST(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.expectPUT('http://test.local'); +requestHandler = httpBackendService.expectPUT('http://test.local', 'response data'); +requestHandler = httpBackendService.expectPUT('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPUT('http://test.local', /response data/); +requestHandler = httpBackendService.expectPUT('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPUT('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPUT('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPUT('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.expectPUT('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/); +requestHandler = httpBackendService.expectPUT(/test.local/, 'response data'); +requestHandler = httpBackendService.expectPUT(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/, /response data/); +requestHandler = httpBackendService.expectPUT(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.expectPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.expectPUT(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.when('GET', 'http://test.local'); +requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data'); +requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', 'response data', function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/); +requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', /response data/, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.when('GET', 'http://test.local', { key: 'value' }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/); +requestHandler = httpBackendService.when('GET', /test.local/, 'response data'); +requestHandler = httpBackendService.when('GET', /test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, 'response data', function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/, /response data/); +requestHandler = httpBackendService.when('GET', /test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, /response data/, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, function (data: string): boolean { return true; }, function (headers: Object): boolean { return true; }); +requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.when('GET', /test.local/, { key: 'value' }, function (headers: Object): boolean { return true; }); + +requestHandler = httpBackendService.whenDELETE('http://test.local'); +requestHandler = httpBackendService.whenDELETE('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.whenDELETE(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.whenGET('http://test.local'); +requestHandler = httpBackendService.whenGET('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.whenGET(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.whenHEAD('http://test.local'); +requestHandler = httpBackendService.whenHEAD('http://test.local', { header: 'value' }); +requestHandler = httpBackendService.whenHEAD(/test.local/, { header: 'value' }); +requestHandler = httpBackendService.whenJSONP('http://test.local'); +requestHandler = httpBackendService.whenJSONP(/test.local/); + +requestHandler = httpBackendService.whenPATCH('http://test.local'); +requestHandler = httpBackendService.whenPATCH('http://test.local', 'response data'); +requestHandler = httpBackendService.whenPATCH('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPATCH('http://test.local', /response data/); +requestHandler = httpBackendService.whenPATCH('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPATCH('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.whenPATCH('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/); +requestHandler = httpBackendService.whenPATCH(/test.local/, 'response data'); +requestHandler = httpBackendService.whenPATCH(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/); +requestHandler = httpBackendService.whenPATCH(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPATCH(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.whenPATCH(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.whenPOST('http://test.local'); +requestHandler = httpBackendService.whenPOST('http://test.local', 'response data'); +requestHandler = httpBackendService.whenPOST('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPOST('http://test.local', /response data/); +requestHandler = httpBackendService.whenPOST('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPOST('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPOST('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPOST('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.whenPOST('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/); +requestHandler = httpBackendService.whenPOST(/test.local/, 'response data'); +requestHandler = httpBackendService.whenPOST(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/, /response data/); +requestHandler = httpBackendService.whenPOST(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPOST(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.whenPOST(/test.local/, { key: 'value' }, { header: 'value' }); + +requestHandler = httpBackendService.whenPUT('http://test.local'); +requestHandler = httpBackendService.whenPUT('http://test.local', 'response data'); +requestHandler = httpBackendService.whenPUT('http://test.local', 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPUT('http://test.local', /response data/); +requestHandler = httpBackendService.whenPUT('http://test.local', /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPUT('http://test.local', function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPUT('http://test.local', function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPUT('http://test.local', { key: 'value' }); +requestHandler = httpBackendService.whenPUT('http://test.local', { key: 'value' }, { header: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/); +requestHandler = httpBackendService.whenPUT(/test.local/, 'response data'); +requestHandler = httpBackendService.whenPUT(/test.local/, 'response data', { header: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/, /response data/); +requestHandler = httpBackendService.whenPUT(/test.local/, /response data/, { header: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string): boolean { return true; }); +requestHandler = httpBackendService.whenPUT(/test.local/, function (data: string): boolean { return true; }, { header: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' }); +requestHandler = httpBackendService.whenPUT(/test.local/, { key: 'value' }, { header: 'value' }); + + +/////////////////////////////////////// +// IRequestHandler +/////////////////////////////////////// +requestHandler.passThrough(); +requestHandler.respond(function () { }); +requestHandler.respond({ key: 'value' }); +requestHandler.respond({ key: 'value' }, { header: 'value' }); +requestHandler.respond(404); +requestHandler.respond(404, { key: 'value' }); +requestHandler.respond(404, { key: 'value' }, { header: 'value' }); diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-mocks-1.2.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-mocks-1.2.d.ts new file mode 100644 index 00000000..e9b0dc8d --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-mocks-1.2.d.ts @@ -0,0 +1,226 @@ +// Type definitions for Angular JS 1.2 (ngMock, ngMockE2E module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +/////////////////////////////////////////////////////////////////////////////// +// functions attached to global object (window) +/////////////////////////////////////////////////////////////////////////////// +declare var module: (...modules: any[]) => any; +declare var inject: (...fns: Function[]) => any; + +/////////////////////////////////////////////////////////////////////////////// +// ngMock module (angular-mocks.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng { + + /////////////////////////////////////////////////////////////////////////// + // AngularStatic + // We reopen it to add the MockStatic definition + /////////////////////////////////////////////////////////////////////////// + interface IAngularStatic { + mock: IMockStatic; + } + + interface IMockStatic { + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/function/angular.mock.dump + dump(obj: any): string; + + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/function/angular.mock.inject + inject(...fns: Function[]): any; + inject(...inlineAnnotatedConstructor: any[]): any; // this overload is undocumented, but works + + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/function/angular.mock.module + module(...modules: any[]): any; + + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/type/angular.mock.TzDate + TzDate(offset: number, timestamp: number): Date; + TzDate(offset: number, timestamp: string): Date; + } + + /////////////////////////////////////////////////////////////////////////// + // ExceptionHandlerService + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$exceptionHandler + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/provider/$exceptionHandlerProvider + /////////////////////////////////////////////////////////////////////////// + interface IExceptionHandlerProvider extends IServiceProvider { + mode(mode: string): void; + } + + /////////////////////////////////////////////////////////////////////////// + // TimeoutService + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$timeout + // Augments the original service + /////////////////////////////////////////////////////////////////////////// + interface ITimeoutService { + flush(delay?: number): void; + flushNext(expectedDelay?: number): void; + verifyNoPendingTasks(): void; + } + + /////////////////////////////////////////////////////////////////////////// + // IntervalService + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$interval + // Augments the original service + /////////////////////////////////////////////////////////////////////////// + interface IIntervalService { + flush(millis?: number): number; + } + + /////////////////////////////////////////////////////////////////////////// + // LogService + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$log + // Augments the original service + /////////////////////////////////////////////////////////////////////////// + interface ILogService { + assertEmpty(): void; + reset(): void; + } + + interface ILogCall { + logs: string[]; + } + + /////////////////////////////////////////////////////////////////////////// + // HttpBackendService + // see https://code.angularjs.org/1.2.26/docs/api/ngMock/service/$httpBackend + /////////////////////////////////////////////////////////////////////////// + interface IHttpBackendService { + flush(count?: number): void; + resetExpectations(): void; + verifyNoOutstandingExpectation(): void; + verifyNoOutstandingRequest(): void; + + expect(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expect(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + expect(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + + expectDELETE(url: string, headers?: Object): mock.IRequestHandler; + expectDELETE(url: RegExp, headers?: Object): mock.IRequestHandler; + expectGET(url: string, headers?: Object): mock.IRequestHandler; + expectGET(url: RegExp, headers?: Object): mock.IRequestHandler; + expectHEAD(url: string, headers?: Object): mock.IRequestHandler; + expectHEAD(url: RegExp, headers?: Object): mock.IRequestHandler; + expectJSONP(url: string): mock.IRequestHandler; + expectJSONP(url: RegExp): mock.IRequestHandler; + + expectPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler; + expectPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + expectPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler; + expectPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + expectPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler; + expectPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + expectPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + when(method: string, url: string, data?: string, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: string, data?: Object, headers?: Object): mock.IRequestHandler; + when(method: string, url: string, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: (data: string) => boolean, headers?: (object: Object) => boolean): mock.IRequestHandler; + when(method: string, url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + when(method: string, url: RegExp, data?: Object, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenDELETE(url: string, headers?: Object): mock.IRequestHandler; + whenDELETE(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + whenDELETE(url: RegExp, headers?: Object): mock.IRequestHandler; + whenDELETE(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenGET(url: string, headers?: Object): mock.IRequestHandler; + whenGET(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + whenGET(url: RegExp, headers?: Object): mock.IRequestHandler; + whenGET(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenHEAD(url: string, headers?: Object): mock.IRequestHandler; + whenHEAD(url: string, headers?: (object: Object) => boolean): mock.IRequestHandler; + whenHEAD(url: RegExp, headers?: Object): mock.IRequestHandler; + whenHEAD(url: RegExp, headers?: (object: Object) => boolean): mock.IRequestHandler; + + whenJSONP(url: string): mock.IRequestHandler; + whenJSONP(url: RegExp): mock.IRequestHandler; + + whenPATCH(url: string, data?: string, headers?: Object): mock.IRequestHandler; + whenPATCH(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPATCH(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPATCH(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPATCH(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + whenPOST(url: string, data?: string, headers?: Object): mock.IRequestHandler; + whenPOST(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPOST(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPOST(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPOST(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + + whenPUT(url: string, data?: string, headers?: Object): mock.IRequestHandler; + whenPUT(url: string, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPUT(url: string, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPUT(url: string, data?: Object, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: string, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: RegExp, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: (data: string) => boolean, headers?: Object): mock.IRequestHandler; + whenPUT(url: RegExp, data?: Object, headers?: Object): mock.IRequestHandler; + } + + export module mock { + + // returned interface by the the mocked HttpBackendService expect/when methods + interface IRequestHandler { + respond(func: Function): void; + respond(status: number, data?: any, headers?: any): void; + respond(data: any, headers?: any): void; + + // Available wehn ngMockE2E is loaded + passThrough(): void; + } + + } + +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-resource-1.0.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-resource-1.0.d.ts new file mode 100644 index 00000000..82537928 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-resource-1.0.d.ts @@ -0,0 +1,82 @@ +// Type definitions for Angular JS 1.0 (ngResource module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + + +/////////////////////////////////////////////////////////////////////////////// +// ngResource module (angular-resource.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.resource { + + /////////////////////////////////////////////////////////////////////////// + // ResourceService + // see http://docs.angularjs.org/api/ngResource.$resource + // Most part of the following definitions were achieved by analyzing the + // actual implementation, since the documentation doesn't seem to cover + // that deeply. + /////////////////////////////////////////////////////////////////////////// + interface IResourceService { + (url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actionDescriptors?: any): IResourceClass; + } + + // Just a reference to facilitate describing new actions + interface IActionDescriptor { + method: string; + isArray?: boolean; + params?: any; + headers?: any; + } + + // Baseclass for everyresource with default actions. + // If you define your new actions for the resource, you will need + // to extend this interface and typecast the ResourceClass to it. + interface IResourceClass { + get: IActionCall; + save: IActionCall; + query: IActionCall; + remove: IActionCall; + delete: IActionCall; + } + + // In case of passing the first argument as anything but a function, + // it's gonna be considered data if the action method is POST, PUT or + // PATCH (in other words, methods with body). Otherwise, it's going + // to be considered as parameters to the request. + interface IActionCall { + (): IResource; + (dataOrParams: any): IResource; + (dataOrParams: any, success: Function): IResource; + (success: Function, error?: Function): IResource; + (params: any, data: any, success?: Function, error?: Function): IResource; + } + + interface IResource { + $save: IActionCall; + $remove: IActionCall; + $delete: IActionCall; + + // No documented, but they are there, just as any custom action will be + $query: IActionCall; + $get: IActionCall; + } + + /** when creating a resource factory via IModule.factory */ + interface IResourceServiceFactoryFunction { + ($resource: ng.resource.IResourceService): ng.resource.IResourceClass; + } +} + +/** extensions to base ng based on using angular-resource */ +declare module ng { + + interface IModule { + /** creating a resource service factory */ + factory(name: string, resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction): IModule; + } +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-resource-1.2-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-resource-1.2-tests.ts new file mode 100644 index 00000000..ca970f5c --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-resource-1.2-tests.ts @@ -0,0 +1,138 @@ +/// + +interface IMyResource extends ng.resource.IResource { }; +interface IMyResourceClass extends ng.resource.IResourceClass { }; + +/////////////////////////////////////// +// IActionDescriptor +/////////////////////////////////////// +var actionDescriptor: ng.resource.IActionDescriptor; + +actionDescriptor.headers = { header: 'value' }; +actionDescriptor.isArray = true; +actionDescriptor.method = 'method action'; +actionDescriptor.params = { key: 'value' }; + + +/////////////////////////////////////// +// IResourceClass +/////////////////////////////////////// +var resourceClass: IMyResourceClass; +var resource: IMyResource; +var resourceArray: ng.resource.IResourceArray; + +resource = resourceClass.delete(); +resource = resourceClass.delete({ key: 'value' }); +resource = resourceClass.delete({ key: 'value' }, function () { }); +resource = resourceClass.delete(function () { }); +resource = resourceClass.delete(function () { }, function () { }); +resource = resourceClass.delete({ key: 'value' }, { key: 'value' }); +resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }); +resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }, function () { }); +resource.$promise.then(function(data: IMyResource) {}); + +resource = resourceClass.get(); +resource = resourceClass.get({ key: 'value' }); +resource = resourceClass.get({ key: 'value' }, function () { }); +resource = resourceClass.get(function () { }); +resource = resourceClass.get(function () { }, function () { }); +resource = resourceClass.get({ key: 'value' }, { key: 'value' }); +resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { }); +resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + +resourceArray = resourceClass.query(); +resourceArray = resourceClass.query({ key: 'value' }); +resourceArray = resourceClass.query({ key: 'value' }, function () { }); +resourceArray = resourceClass.query(function () { }); +resourceArray = resourceClass.query(function () { }, function () { }); +resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }); +resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { }); +resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { }, function () { }); +resourceArray.push(resource); +resourceArray.$promise.then(function(data: ng.resource.IResourceArray) {}); + +resource = resourceClass.remove(); +resource = resourceClass.remove({ key: 'value' }); +resource = resourceClass.remove({ key: 'value' }, function () { }); +resource = resourceClass.remove(function () { }); +resource = resourceClass.remove(function () { }, function () { }); +resource = resourceClass.remove({ key: 'value' }, { key: 'value' }); +resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { }); +resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + +resource = resourceClass.save(); +resource = resourceClass.save({ key: 'value' }); +resource = resourceClass.save({ key: 'value' }, function () { }); +resource = resourceClass.save(function () { }); +resource = resourceClass.save(function () { }, function () { }); +resource = resourceClass.save({ key: 'value' }, { key: 'value' }); +resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { }); +resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + +/////////////////////////////////////// +// IResource +/////////////////////////////////////// + +var promise : ng.IPromise; +var arrayPromise : ng.IPromise; + +promise = resource.$delete(); +promise = resource.$delete({ key: 'value' }); +promise = resource.$delete({ key: 'value' }, function () { }); +promise = resource.$delete(function () { }); +promise = resource.$delete(function () { }, function () { }); +promise = resource.$delete({ key: 'value' }, function () { }, function () { }); +promise.then(function(data: IMyResource) {}); + +promise = resource.$get(); +promise = resource.$get({ key: 'value' }); +promise = resource.$get({ key: 'value' }, function () { }); +promise = resource.$get(function () { }); +promise = resource.$get(function () { }, function () { }); +promise = resource.$get({ key: 'value' }, function () { }, function () { }); + +arrayPromise = resourceArray[0].$query(); +arrayPromise = resourceArray[0].$query({ key: 'value' }); +arrayPromise = resourceArray[0].$query({ key: 'value' }, function () { }); +arrayPromise = resourceArray[0].$query(function () { }); +arrayPromise = resourceArray[0].$query(function () { }, function () { }); +arrayPromise = resourceArray[0].$query({ key: 'value' }, function () { }, function () { }); +arrayPromise.then(function(data: ng.resource.IResourceArray) {}); + +promise = resource.$remove(); +promise = resource.$remove({ key: 'value' }); +promise = resource.$remove({ key: 'value' }, function () { }); +promise = resource.$remove(function () { }); +promise = resource.$remove(function () { }, function () { }); +promise = resource.$remove({ key: 'value' }, function () { }, function () { }); + +promise = resource.$save(); +promise = resource.$save({ key: 'value' }); +promise = resource.$save({ key: 'value' }, function () { }); +promise = resource.$save(function () { }); +promise = resource.$save(function () { }, function () { }); +promise = resource.$save({ key: 'value' }, function () { }, function () { }); + +/////////////////////////////////////// +// IResourceService +/////////////////////////////////////// +var resourceService: ng.resource.IResourceService; +resourceClass = resourceService('test'); +resourceClass = resourceService('test'); +resourceClass = resourceService('test'); + +/////////////////////////////////////// +// IModule +/////////////////////////////////////// +var mod: ng.IModule; +var resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction; +var resourceService: ng.resource.IResourceService; + +resourceClass = resourceServiceFactoryFunction(resourceService); + +resourceServiceFactoryFunction = function (resourceService: ng.resource.IResourceService) { return resourceClass; }; +mod = mod.factory('factory name', resourceServiceFactoryFunction); + +/////////////////////////////////////// +// IResource +/////////////////////////////////////// \ No newline at end of file diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-resource-1.2.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-resource-1.2.d.ts new file mode 100644 index 00000000..f3c3fbe6 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-resource-1.2.d.ts @@ -0,0 +1,152 @@ +// Type definitions for Angular JS 1.2 (ngResource module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar , Michael Jess +// Definitions: https://github.com/daptiv/DefinitelyTyped + +/// + + +/////////////////////////////////////////////////////////////////////////////// +// ngResource module (angular-resource.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.resource { + + /////////////////////////////////////////////////////////////////////////// + // ResourceService + // see https://code.angularjs.org/1.2.26/docs/api/ngResource/service/$resource + // Most of the following definitions were achieved by analyzing the + // actual implementation, since the documentation doesn't seem to cover + // that deeply. + /////////////////////////////////////////////////////////////////////////// + interface IResourceService { + (url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actionDescriptors?: any): IResourceClass>; + (url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actionDescriptors?: any): U; + (url: string, paramDefaults?: any, + /** example: {update: { method: 'PUT' }, delete: deleteDescriptor } + where deleteDescriptor : IActionDescriptor */ + actionDescriptors?: any): IResourceClass; + } + + // Just a reference to facilitate describing new actions + interface IActionDescriptor { + method: string; + isArray?: boolean; + params?: any; + headers?: any; + } + + // Baseclass for everyresource with default actions. + // If you define your new actions for the resource, you will need + // to extend this interface and typecast the ResourceClass to it. + // + // In case of passing the first argument as anything but a function, + // it's gonna be considered data if the action method is POST, PUT or + // PATCH (in other words, methods with body). Otherwise, it's going + // to be considered as parameters to the request. + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L461-L465 + // + // Only those methods with an HTTP body do have 'data' as first parameter: + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L463 + // More specifically, those methods are POST, PUT and PATCH: + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L432 + // + // Also, static calls always return the IResource (or IResourceArray) retrieved + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L549 + interface IResourceClass { + new(dataOrParams? : any) : T; + get(): T; + get(params: Object): T; + get(success: Function, error?: Function): T; + get(params: Object, success: Function, error?: Function): T; + get(params: Object, data: Object, success?: Function, error?: Function): T; + + query(): IResourceArray; + query(params: Object): IResourceArray; + query(success: Function, error?: Function): IResourceArray; + query(params: Object, success: Function, error?: Function): IResourceArray; + query(params: Object, data: Object, success?: Function, error?: Function): IResourceArray; + + save(): T; + save(data: Object): T; + save(success: Function, error?: Function): T; + save(data: Object, success: Function, error?: Function): T; + save(params: Object, data: Object, success?: Function, error?: Function): T; + + remove(): T; + remove(params: Object): T; + remove(success: Function, error?: Function): T; + remove(params: Object, success: Function, error?: Function): T; + remove(params: Object, data: Object, success?: Function, error?: Function): T; + + delete(): T; + delete(params: Object): T; + delete(success: Function, error?: Function): T; + delete(params: Object, success: Function, error?: Function): T; + delete(params: Object, data: Object, success?: Function, error?: Function): T; + } + + // Instance calls always return the the promise of the request which retrieved the object + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L546 + interface IResource { + $get(): ng.IPromise; + $get(params?: Object, success?: Function, error?: Function): ng.IPromise; + $get(success: Function, error?: Function): ng.IPromise; + + $query(): ng.IPromise>; + $query(params?: Object, success?: Function, error?: Function): ng.IPromise>; + $query(success: Function, error?: Function): ng.IPromise>; + + $save(): ng.IPromise; + $save(params?: Object, success?: Function, error?: Function): ng.IPromise; + $save(success: Function, error?: Function): ng.IPromise; + + $remove(): ng.IPromise; + $remove(params?: Object, success?: Function, error?: Function): ng.IPromise; + $remove(success: Function, error?: Function): ng.IPromise; + + $delete(): ng.IPromise; + $delete(params?: Object, success?: Function, error?: Function): ng.IPromise; + $delete(success: Function, error?: Function): ng.IPromise; + + /** the promise of the original server interaction that created this instance. **/ + $promise : ng.IPromise; + $resolved : boolean; + } + + /** + * Really just a regular Array object with $promise and $resolve attached to it + */ + interface IResourceArray extends Array { + /** the promise of the original server interaction that created this collection. **/ + $promise : ng.IPromise>; + $resolved : boolean; + } + + /** when creating a resource factory via IModule.factory */ + interface IResourceServiceFactoryFunction { + ($resource: ng.resource.IResourceService): IResourceClass; + >($resource: ng.resource.IResourceService): U; + } +} + +/** extensions to base ng based on using angular-resource */ +declare module ng { + + interface IModule { + /** creating a resource service factory */ + factory(name: string, resourceServiceFactoryFunction: ng.resource.IResourceServiceFactoryFunction): IModule; + } +} + +interface Array +{ + /** the promise of the original server interaction that created this collection. **/ + $promise : ng.IPromise>; + $resolved : boolean; +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-route-1.2-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-route-1.2-tests.ts new file mode 100644 index 00000000..0b82110e --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-route-1.2-tests.ts @@ -0,0 +1,17 @@ +/// + +/** + * @license HTTP Auth Interceptor Module for AngularJS + * (c) 2013 Jonathan Park @ Daptiv Solutions Inc + * License: MIT + */ + +declare var $routeProvider: ng.route.IRouteProvider; +$routeProvider + .when('/projects/:projectId/dashboard',{ + controller: '', + templateUrl: '', + caseInsensitiveMatch: true, + reloadOnSearch: false + }) + .otherwise({redirectTo: '/'}); diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-route-1.2.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-route-1.2.d.ts new file mode 100644 index 00000000..7afd4af5 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-route-1.2.d.ts @@ -0,0 +1,145 @@ +// Type definitions for Angular JS 1.2 (ngRoute module) +// Project: http://angularjs.org +// Definitions by: Jonathan Park +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + + +/////////////////////////////////////////////////////////////////////////////// +// ngRoute module (angular-route.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.route { + + /////////////////////////////////////////////////////////////////////////// + // RouteParamsService + // see https://code.angularjs.org/1.2.26/docs/api/ngRoute/service/$routeParams + /////////////////////////////////////////////////////////////////////////// + interface IRouteParamsService { + [key: string]: any; + } + + /////////////////////////////////////////////////////////////////////////// + // RouteService + // see https://code.angularjs.org/1.2.26/docs/api/ngRoute/service/$route + // see https://code.angularjs.org/1.2.26/docs/api/ngRoute/provider/$routeProvider + /////////////////////////////////////////////////////////////////////////// + interface IRouteService { + /** + * Causes $route service to reload the current route even if $location hasn't changed. + * As a result of that, ngView creates new scope, reinstantiates the controller. + */ + reload(): void; + + /** + * Object with all route configuration Objects as its properties. + */ + routes: any; + + // May not always be available. For instance, current will not be available + // to a controller that was not initialized as a result of a route maching. + current?: ICurrentRoute; + } + + + /** + * see https://code.angularjs.org/1.2.26/docs/api/ngRoute/provider/$routeProvider#when for API documentation + */ + interface IRoute { + /** + * {(string|function()=} + * Controller fn that should be associated with newly created scope or the name of a registered controller if passed as a string. + */ + controller?: any; + /** + * A controller alias name. If present the controller will be published to scope under the controllerAs name. + */ + controllerAs?: string; + /** + * Undocumented? + */ + name?: string; + /** + * {string=|function()=} + * Html template as a string or a function that returns an html template as a string which should be used by ngView or ngInclude directives. This property takes precedence over templateUrl. + * + * If template is a function, it will be called with the following parameters: + * + * {Array.} - route parameters extracted from the current $location.path() by applying the current route + */ + template?: string; + /** + * {string=|function()=} + * Path or function that returns a path to an html template that should be used by ngView. + * + * If templateUrl is a function, it will be called with the following parameters: + * + * {Array.} - route parameters extracted from the current $location.path() by applying the current route + */ + templateUrl?: any; + /** + * {Object.=} - An optional map of dependencies which should be injected into the controller. If any of these dependencies are promises, the router will wait for them all to be resolved or one to be rejected before the controller is instantiated. If all the promises are resolved successfully, the values of the resolved promises are injected and $routeChangeSuccess event is fired. If any of the promises are rejected the $routeChangeError event is fired. The map object is: + * + * - key - {string}: a name of a dependency to be injected into the controller. + * - factory - {string|function}: If string then it is an alias for a service. Otherwise if function, then it is injected and the return value is treated as the dependency. If the result is a promise, it is resolved before its value is injected into the controller. Be aware that ngRoute.$routeParams will still refer to the previous route within these resolve functions. Use $route.current.params to access the new route parameters, instead. + */ + resolve?: {[key: string]: any}; + /** + * {(string|function())=} + * Value to update $location path with and trigger route redirection. + * + * If redirectTo is a function, it will be called with the following parameters: + * + * - {Object.} - route parameters extracted from the current $location.path() by applying the current route templateUrl. + * - {string} - current $location.path() + * - {Object} - current $location.search() + * - The custom redirectTo function is expected to return a string which will be used to update $location.path() and $location.search(). + */ + redirectTo?: any; + /** + * Reload route when only $location.search() or $location.hash() changes. + * + * This option defaults to true. If the option is set to false and url in the browser changes, then $routeUpdate event is broadcasted on the root scope. + */ + reloadOnSearch?: boolean; + /** + * Match routes without being case sensitive + * + * This option defaults to false. If the option is set to true, then the particular route can be matched without being case sensitive + */ + caseInsensitiveMatch?: boolean; + } + + // see https://code.angularjs.org/1.2.26/docs/api/ngRoute/service/$route#current + interface ICurrentRoute extends IRoute { + locals: { + $scope: IScope; + $template: string; + }; + + params: any; + } + + interface IRouteProvider extends IServiceProvider { + /** + * Sets route definition that will be used on route change when no other route definition is matched. + * + * @params Mapping information to be assigned to $route.current. + */ + otherwise(params: IRoute): IRouteProvider; + /** + * Adds a new route definition to the $route service. + * + * @param path Route path (matched against $location.path). If $location.path contains redundant trailing slash or is missing one, the route will still match and the $location.path will be updated to add or drop the trailing slash to exactly match the route definition. + * + * - path can contain named groups starting with a colon: e.g. :name. All characters up to the next slash are matched and stored in $routeParams under the given name when the route matches. + * - path can contain named groups starting with a colon and ending with a star: e.g.:name*. All characters are eagerly stored in $routeParams under the given name when the route matches. + * - path can contain optional named groups with a question mark: e.g.:name?. + * + * For example, routes like /color/:color/largecode/:largecode*\/edit will match /color/brown/largecode/code/with/slashes/edit and extract: color: brown and largecode: code/with/slashes. + * + * @param route Mapping information to be assigned to $route.current on route match. + */ + when(path: string, route: IRoute): IRouteProvider; + } +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-sanitize-1.0.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-sanitize-1.0.d.ts new file mode 100644 index 00000000..4d9fc4c6 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-sanitize-1.0.d.ts @@ -0,0 +1,22 @@ +// Type definitions for Angular JS 1.0 (ngSanitize module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +/////////////////////////////////////////////////////////////////////////////// +// ngSanitize module (angular-sanitize.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.sanitize { + + /////////////////////////////////////////////////////////////////////////// + // SanitizeService + // see http://docs.angularjs.org/api/ngSanitize.$sanitize + /////////////////////////////////////////////////////////////////////////// + interface ISanitizeService { + (html: string): string; + } + +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-sanitize-1.2-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-sanitize-1.2-tests.ts new file mode 100644 index 00000000..853bbf34 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-sanitize-1.2-tests.ts @@ -0,0 +1,10 @@ +/// + +var shouldBeString: string; + +declare var $sanitizeService: ng.sanitize.ISanitizeService; +shouldBeString = $sanitizeService(shouldBeString); + +declare var $linky: ng.sanitize.filter.ILinky; +shouldBeString = $linky(shouldBeString); +shouldBeString = $linky(shouldBeString, shouldBeString); diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-sanitize-1.2.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-sanitize-1.2.d.ts new file mode 100644 index 00000000..4c6805c9 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-sanitize-1.2.d.ts @@ -0,0 +1,35 @@ +// Type definitions for Angular JS 1.2 (ngSanitize module) +// Project: http://angularjs.org +// Definitions by: Diego Vilar +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +/////////////////////////////////////////////////////////////////////////////// +// ngSanitize module (angular-sanitize.js) +/////////////////////////////////////////////////////////////////////////////// +declare module ng.sanitize { + + /////////////////////////////////////////////////////////////////////////// + // SanitizeService + // see https://code.angularjs.org/1.2.26/docs/api/ngSanitize/service/$sanitize + /////////////////////////////////////////////////////////////////////////// + interface ISanitizeService { + (html: string): string; + } + + /////////////////////////////////////////////////////////////////////////// + // Filters included with the ngSanitize + // see https://code.angularjs.org/1.2.26/docs/api/ngSanitize/filter + /////////////////////////////////////////////////////////////////////////// + export module filter { + + // Finds links in text input and turns them into html links. + // Supports http/https/ftp/mailto and plain email address links. + // see https://code.angularjs.org/1.2.26/docs/api/ngSanitize/filter/linky + interface ILinky { + (text: string, target?: string): string; + } + } +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-scenario-1.0.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-scenario-1.0.d.ts new file mode 100644 index 00000000..a44b7909 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-scenario-1.0.d.ts @@ -0,0 +1,155 @@ +// Type definitions for Angular Scenario Testing 1.0 (ngScenario module) +// Project: [http://angularjs.org] +// Definitions by: [RomanoLindano] +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module angularScenario { + export interface AngularModel { + scenario: any; + } + + export interface RunFunction { + (functionToRun: any): any; + } + export interface RunFunctionWithDescription { + (description: string, functionToRun: any): any; + } + + export interface PauseFunction { + (): any; + } + + export interface SleepFunction { + (seconds: number): any; + } + + export interface Future { + } + + export interface testWindow { + href(): Future; + path(): Future; + search(): Future; + hash(): Future; + } + + export interface testLocation { + url(): Future; + path(): Future; + search(): Future; + hash(): Future; + } + + export interface Browser { + navigateTo(url: string): void; + navigateTo(urlDescription: string, urlFunction: () => string): void; + reload(): void; + window(): testWindow; + location(): testLocation; + } + + export interface Matchers { + toEqual(value: any): void; + toBe(value: any): void; + toBeDefined(): void; + toBeTruthy(): void; + toBeFalsy(): void; + toMatch(regularExpression: any): void; + toBeNull(): void; + toContain(value: any): void; + toBeLessThan(value: any): void; + toBeGreaterThan(value: any): void; + } + + export interface CustomMatchers extends Matchers{ + } + + export interface Expect extends CustomMatchers { + not(): angularScenario.CustomMatchers; + } + + export interface UsingFunction { + (selector: string, selectorDescription?: string): void; + } + + export interface BindingFunction { + (bracketBindingExpression: string): Future; + } + + export interface Input { + enter(value: any); + check(): any; + select(radioButtonValue: any): any; + val(): Future; + } + + export interface Repeater { + count(): Future; + row(index: number): Future; + column(ngBindingExpression: string): Future; + } + + export interface Select { + option(value: any): any; + option(...listOfValues: any[]): any; + } + + export interface Element { + count(): Future; + click(): any; + query(callback: (selectedDOMElements: any[], callbackWhenDone: (objNull: any, futureValue: any) => any) =>any): any; + val(): Future; + text(): Future; + html(): Future; + height(): Future; + innerHeight(): Future; + outerHeight(): Future; + width(): Future; + innerWidth(): Future; + outerWidth(): Future; + position(): Future; + scrollLeft(): Future; + scrollTop(): Future; + offset(): Future; + + val(value: any): void; + text(value: any): void; + html(value: any): void; + height(value: any): void; + innerHeight(value: any): void; + outerHeight(value: any): void; + width(value: any): void; + innerWidth(value: any): void; + outerWidth(value: any): void; + position(value: any): void; + scrollLeft(value: any): void; + scrollTop(value: any): void; + offset(value: any): void; + + attr(key: any): Future; + prop(key: any): Future; + css(key: any): Future; + + attr(key: any, value: any): void; + prop(key: any, value: any): void; + css(key: any, value: any): void; + } +} + +declare var describe: angularScenario.RunFunctionWithDescription; +declare var xdescribe: angularScenario.RunFunctionWithDescription; +declare var beforeEach: angularScenario.RunFunction; +declare var afterEach: angularScenario.RunFunction; +declare var it: angularScenario.RunFunctionWithDescription; +declare var xit: angularScenario.RunFunctionWithDescription; +declare var pause: angularScenario.PauseFunction; +declare var sleep: angularScenario.SleepFunction; +declare function browser(): angularScenario.Browser; +declare function expect(expectation: angularScenario.Future): angularScenario.Expect; +declare var using: angularScenario.UsingFunction; +declare var binding: angularScenario.BindingFunction; +declare function input(ngModelBinding: string): angularScenario.Input; +declare function repeater(selector: string, repeaterDescription?: string): angularScenario.Repeater; +declare function select(ngModelBinding: string): angularScenario.Select; +declare function element(selector: string, elementDescription?: string): angularScenario.Element; +declare var angular: angularScenario.AngularModel; diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-scenario-1.0.d.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-scenario-1.0.d.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-scenario-1.0.d.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-scenario-1.2.d.ts b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-scenario-1.2.d.ts new file mode 100644 index 00000000..9e72db89 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/angularjs/legacy/angular-scenario-1.2.d.ts @@ -0,0 +1,166 @@ +// Type definitions for Angular Scenario Testing 1.2 (ngScenario module) +// Project: http://angularjs.org +// Definitions by: RomanoLindano +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module ng { + export interface IAngularStatic { + scenario: any; + } +} + +declare module angularScenario { + + export interface RunFunction { + (functionToRun: any): any; + } + export interface RunFunctionWithDescription { + (description: string, functionToRun: any): any; + } + + export interface PauseFunction { + (): any; + } + + export interface SleepFunction { + (seconds: number): any; + } + + export interface Future { + } + + export interface testWindow { + href(): Future; + path(): Future; + search(): Future; + hash(): Future; + } + + export interface testLocation { + url(): Future; + path(): Future; + search(): Future; + hash(): Future; + } + + export interface Browser { + navigateTo(url: string): void; + navigateTo(urlDescription: string, urlFunction: () => string): void; + reload(): void; + window(): testWindow; + location(): testLocation; + } + + export interface Matchers { + toEqual(value: any): void; + toBe(value: any): void; + toBeDefined(): void; + toBeTruthy(): void; + toBeFalsy(): void; + toMatch(regularExpression: any): void; + toBeNull(): void; + toContain(value: any): void; + toBeLessThan(value: any): void; + toBeGreaterThan(value: any): void; + } + + export interface CustomMatchers extends Matchers { + } + + export interface Expect extends CustomMatchers { + not(): angularScenario.CustomMatchers; + } + + export interface UsingFunction { + (selector: string, selectorDescription?: string): void; + } + + export interface BindingFunction { + (bracketBindingExpression: string): Future; + } + + export interface Input { + enter(value: any): any; + check(): any; + select(radioButtonValue: any): any; + val(): Future; + } + + export interface Repeater { + count(): Future; + row(index: number): Future; + column(ngBindingExpression: string): Future; + } + + export interface Select { + option(value: any): any; + option(...listOfValues: any[]): any; + } + + export interface Element { + count(): Future; + click(): any; + dblclick(): any; + mouseover(): any; + mousedown(): any; + mouseup(): any; + query(callback: (selectedDOMElements: JQuery, callbackWhenDone: (objNull: any, futureValue: any) => any) => any): any; + val(): Future; + text(): Future; + html(): Future; + height(): Future; + innerHeight(): Future; + outerHeight(): Future; + width(): Future; + innerWidth(): Future; + outerWidth(): Future; + position(): Future; + scrollLeft(): Future; + scrollTop(): Future; + offset(): Future; + + val(value: any): void; + text(value: any): void; + html(value: any): void; + height(value: any): void; + innerHeight(value: any): void; + outerHeight(value: any): void; + width(value: any): void; + innerWidth(value: any): void; + outerWidth(value: any): void; + position(value: any): void; + scrollLeft(value: any): void; + scrollTop(value: any): void; + offset(value: any): void; + + attr(key: any): Future; + prop(key: any): Future; + css(key: any): Future; + + attr(key: any, value: any): void; + prop(key: any, value: any): void; + css(key: any, value: any): void; + } +} + +declare var describe: angularScenario.RunFunctionWithDescription; +declare var ddescribe: angularScenario.RunFunctionWithDescription; +declare var xdescribe: angularScenario.RunFunctionWithDescription; +declare var beforeEach: angularScenario.RunFunction; +declare var afterEach: angularScenario.RunFunction; +declare var it: angularScenario.RunFunctionWithDescription; +declare var iit: angularScenario.RunFunctionWithDescription; +declare var xit: angularScenario.RunFunctionWithDescription; +declare var pause: angularScenario.PauseFunction; +declare var sleep: angularScenario.SleepFunction; +declare function browser(): angularScenario.Browser; +declare function expect(expectation: angularScenario.Future): angularScenario.Expect; +declare var using: angularScenario.UsingFunction; +declare var binding: angularScenario.BindingFunction; +declare function input(ngModelBinding: string): angularScenario.Input; +declare function repeater(selector: string, repeaterDescription?: string): angularScenario.Repeater; +declare function select(ngModelBinding: string): angularScenario.Select; +declare function element(selector: string, elementDescription?: string): angularScenario.Element; +declare var angular: ng.IAngularStatic; diff --git a/zeppelin-web/app/external/DefinitelyTyped/bootstrap/bootstrap-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/bootstrap/bootstrap-tests.ts new file mode 100644 index 00000000..71698101 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/bootstrap/bootstrap-tests.ts @@ -0,0 +1,45 @@ +/// +/// + +$('body').off('.data-api'); +$('body').off('.alert.data-api'); + +$(".btn.danger").button("toggle").addClass("fat"); +$("#myModal").modal(); +$("#myModal").modal({ keyboard: false }); +$("#myModal").modal('show'); + +$('#myModal').on('show', (e) => e.preventDefault()); + +$('#myModal').modal({ keyboard: false }); +$('#myModal').modal('toggle'); + +$('.dropdown-toggle').dropdown(); + +$('#navbar').scrollspy(); + +$('#element').tooltip('show'); + +$('#element').popover('show'); + +$(".alert").alert(); +$(".alert").alert('close'); + +$('.nav-tabs').button(); +$().button('toggle'); + +$(".collapse").collapse(); + +$('#myCollapsible').collapse({ toggle: false }); + +$('.carousel').carousel(); +$('.carousel').carousel({ interval: 2000 }); + +$('.typeahead').typeahead({ + matcher: item => true, + sorter: (items: any[]) => items, + updater: item => item, + highlighter: item => "" +}); + +$('#navbar').affix(); \ No newline at end of file diff --git a/zeppelin-web/app/external/DefinitelyTyped/bootstrap/bootstrap.d.ts b/zeppelin-web/app/external/DefinitelyTyped/bootstrap/bootstrap.d.ts new file mode 100644 index 00000000..b9fe9cd5 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/bootstrap/bootstrap.d.ts @@ -0,0 +1,112 @@ +// Type definitions for Bootstrap 2.2 +// Project: http://twitter.github.com/bootstrap/ +// Definitions by: Boris Yankov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +/// + +interface ModalOptions { + backdrop?: boolean; + keyboard?: boolean; + show?: boolean; + remote?: string; +} + +interface ModalOptionsBackdropString { + backdrop?: string; // for "static" + keyboard?: boolean; + show?: boolean; + remote?: string; +} + +interface ScrollSpyOptions { + offset?: number; +} + +interface TooltipOptions { + animation?: boolean; + html?: boolean; + placement?: any; + selector?: string; + title?: any; + trigger?: string; + delay?: any; + container?: any; +} + +interface PopoverOptions { + animation?: boolean; + html?: boolean; + placement?: any; + selector?: string; + trigger?: string; + title?: any; + content?: any; + delay?: any; + container?: any; +} + +interface CollapseOptions { + parent?: any; + toggle?: boolean; +} + +interface CarouselOptions { + interval?: number; + pause?: string; +} + +interface TypeaheadOptions { + source?: any; + items?: number; + minLength?: number; + matcher?: (item: any) => boolean; + sorter?: (items: any[]) => any[]; + updater?: (item: any) => any; + highlighter?: (item: any) => string; +} + +interface AffixOptions { + offset?: any; +} + +interface JQuery { + modal(options?: ModalOptions): JQuery; + modal(options?: ModalOptionsBackdropString): JQuery; + modal(command: string): JQuery; + + dropdown(): JQuery; + dropdown(command: string): JQuery; + + scrollspy(command: string): JQuery; + scrollspy(options?: ScrollSpyOptions): JQuery; + + tab(): JQuery; + tab(command: string): JQuery; + + tooltip(options?: TooltipOptions): JQuery; + tooltip(command: string): JQuery; + + popover(options?: PopoverOptions): JQuery; + popover(command: string): JQuery; + + alert(): JQuery; + alert(command: string): JQuery; + + button(): JQuery; + button(command: string): JQuery; + + collapse(options?: CollapseOptions): JQuery; + collapse(command: string): JQuery; + + carousel(options?: CarouselOptions): JQuery; + carousel(command: string): JQuery; + + typeahead(options?: TypeaheadOptions): JQuery; + + affix(options?: AffixOptions): JQuery; +} + +declare module "bootstrap" { +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/d3/d3-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/d3/d3-tests.ts new file mode 100644 index 00000000..1a2b5f1c --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/d3/d3-tests.ts @@ -0,0 +1,2628 @@ +/// + +//Example from http://bl.ocks.org/3887235 +function testPieChart() { + var width = 960, + height = 500, + radius = Math.min(width, height) / 2; + + var color = d3.scale.ordinal() + .range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]); + + var arc = d3.svg.arc() + .outerRadius(radius - 10) + .innerRadius(0); + + var pie = d3.layout.pie() + .sort(null) + .value(function (d) { return d.population; }); + + var svg = d3.select("body").append("svg") + .attr("width", width) + .attr("height", height) + .append("g") + .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"); + + d3.csv("data.csv", function (error, data) { + + data.forEach(function (d) { + d.population = +d.population; + }); + + var g = svg.selectAll(".arc") + .data(pie(data)) + .enter().append("g") + .attr("class", "arc"); + + g.append("path") + .attr("d", arc) + .style("fill", function (d) { return color(d.data.age); }); + + g.append("text") + .attr("transform", function (d) { return "translate(" + arc.centroid(d) + ")"; }) + .attr("dy", ".35em") + .style("text-anchor", "middle") + .text(function (d) { return d.data.age; }); + + }); +} + +//Example from http://bl.ocks.org/3887051 +interface GroupedData { + State: string; + ages: Array<{ name: string; value: number;}>; +} +function groupedBarChart() { + var margin = { top: 20, right: 20, bottom: 30, left: 40 }, + width = 960 - margin.left - margin.right, + height = 500 - margin.top - margin.bottom; + + var x0 = d3.scale.ordinal() + .rangeRoundBands([0, width], .1); + + var x1 = d3.scale.ordinal(); + + var y = d3.scale.linear() + .range([height, 0]); + + var color = d3.scale.ordinal() + .range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]); + + var xAxis = d3.svg.axis() + .scale(x0) + .orient("bottom"); + + var yAxis = d3.svg.axis() + .scale(y) + .orient("left") + .tickFormat(d3.format(".2s")); + + var svg = d3.select("body").append("svg") + .attr("width", width + margin.left + margin.right) + .attr("height", height + margin.top + margin.bottom) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + + d3.csv("data.csv", function (error, data: Array) { + var ageNames = d3.keys(data[0]).filter(function (key) { return key !== "State"; }); + + data.forEach(function (d) { + d.ages = ageNames.map(function (name) { return { name: name, value: +d[name] }; }); + }); + + x0.domain(data.map(function (d) { return d.State; })); + x1.domain(ageNames).rangeRoundBands([0, x0.rangeBand()]); + y.domain([0, d3.max(data, function (d) { return d3.max(d.ages, function (d) { return d.value; }); })]); + + svg.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height + ")") + .call(xAxis); + + svg.append("g") + .attr("class", "y axis") + .call(yAxis) + .append("text") + .attr("transform", "rotate(-90)") + .attr("y", 6) + .attr("dy", ".71em") + .style("text-anchor", "end") + .text("Population"); + + var state = svg.selectAll(".state") + .data(data) + .enter().append("g") + .attr("class", "g") + .attr("transform", function (d) { return "translate(" + x0(d.State) + ",0)"; }); + + state.selectAll("rect") + .data(function (d) { return d.ages; }) + .enter().append("rect") + .attr("width", x1.rangeBand()) + .attr("x", function (d) { return x1(d.name); }) + .attr("y", function (d) { return y(d.value); }) + .attr("height", function (d) { return height - y(d.value); }) + .style("fill", function (d) { return color(d.name); }); + + var legend = svg.selectAll(".legend") + .data(ageNames.reverse()) + .enter().append("g") + .attr("class", "legend") + .attr("transform", function (d, i) { return "translate(0," + i * 20 + ")"; }); + + legend.append("rect") + .attr("x", width - 18) + .attr("width", 18) + .attr("height", 18) + .style("fill", color); + + legend.append("text") + .attr("x", width - 24) + .attr("y", 9) + .attr("dy", ".35em") + .style("text-anchor", "end") + .text(function (d) { return d; }); + + }); +} + +//Example from http://bl.ocks.org/3886208 +function stackedBarChart() { + var margin = { top: 20, right: 20, bottom: 30, left: 40 }, + width = 960 - margin.left - margin.right, + height = 500 - margin.top - margin.bottom; + + var x = d3.scale.ordinal() + .rangeRoundBands([0, width], .1); + + var y = d3.scale.linear() + .rangeRound([height, 0]); + + var color = d3.scale.ordinal() + .range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]); + + var xAxis = d3.svg.axis() + .scale(x) + .orient("bottom"); + + var yAxis = d3.svg.axis() + .scale(y) + .orient("left") + .tickFormat(d3.format(".2s")); + + var svg = d3.select("body").append("svg") + .attr("width", width + margin.left + margin.right) + .attr("height", height + margin.top + margin.bottom) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + + d3.csv("data.csv", function (error, data) { + color.domain(d3.keys(data[0]).filter(function (key) { return key !== "State"; })); + + data.forEach(function (d) { + var y0 = 0; + d.ages = color.domain().map(function (name) { return { name: name, y0: y0, y1: y0 += +d[name] }; }); + d.total = d.ages[d.ages.length - 1].y1; + }); + + data.sort(function (a, b) { return b.total - a.total; }); + + x.domain(data.map(function (d) { return d.State; })); + y.domain([0, d3.max(data, function (d) { return d.total; })]); + + svg.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height + ")") + .call(xAxis); + + svg.append("g") + .attr("class", "y axis") + .call(yAxis) + .append("text") + .attr("transform", "rotate(-90)") + .attr("y", 6) + .attr("dy", ".71em") + .style("text-anchor", "end") + .text("Population"); + + var state = svg.selectAll(".state") + .data(data) + .enter().append("g") + .attr("class", "g") + .attr("transform", function (d) { return "translate(" + x(d.State) + ",0)"; }); + + state.selectAll("rect") + .data(function (d) { return d.ages; }) + .enter().append("rect") + .attr("width", x.rangeBand()) + .attr("y", function (d) { return y(d.y1); }) + .attr("height", function (d) { return y(d.y0) - y(d.y1); }) + .style("fill", function (d) { return color(d.name); }); + + var legend = svg.selectAll(".legend") + .data(color.domain().reverse()) + .enter().append("g") + .attr("class", "legend") + .attr("transform", function (d, i) { return "translate(0," + i * 20 + ")"; }); + + legend.append("rect") + .attr("x", width - 18) + .attr("width", 18) + .attr("height", 18) + .style("fill", color); + + legend.append("text") + .attr("x", width - 24) + .attr("y", 9) + .attr("dy", ".35em") + .style("text-anchor", "end") + .text(function (d) { return d; }); + + }); +} + +// example from http://bl.ocks.org/3886394 +function normalizedBarChart() { + var margin = { top: 20, right: 100, bottom: 30, left: 40 }, + width = 960 - margin.left - margin.right, + height = 500 - margin.top - margin.bottom; + + var x = d3.scale.ordinal() + .rangeRoundBands([0, width], .1); + + var y = d3.scale.linear() + .rangeRound([height, 0]); + + var color = d3.scale.ordinal() + .range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]); + + var xAxis = d3.svg.axis() + .scale(x) + .orient("bottom"); + + var yAxis = d3.svg.axis() + .scale(y) + .orient("left") + .tickFormat(d3.format(".0%")); + + var svg = d3.select("body").append("svg") + .attr("width", width + margin.left + margin.right) + .attr("height", height + margin.top + margin.bottom) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + + d3.csv("data.csv", function (error, data) { + color.domain(d3.keys(data[0]).filter(function (key) { return key !== "State"; })); + + data.forEach(function (d) { + var y0 = 0; + d.ages = color.domain().map(function (name) { return { name: name, y0: y0, y1: y0 += +d[name] }; }); + d.ages.forEach(function (d) { d.y0 /= y0; d.y1 /= y0; }); + }); + + data.sort(function (a, b) { return b.ages[0].y1 - a.ages[0].y1; }); + + x.domain(data.map(function (d) { return d.State; })); + + svg.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height + ")") + .call(xAxis); + + svg.append("g") + .attr("class", "y axis") + .call(yAxis); + + var state = svg.selectAll(".state") + .data(data) + .enter().append("g") + .attr("class", "state") + .attr("transform", function (d) { return "translate(" + x(d.State) + ",0)"; }); + + state.selectAll("rect") + .data(function (d) { return d.ages; }) + .enter().append("rect") + .attr("width", x.rangeBand()) + .attr("y", function (d) { return y(d.y1); }) + .attr("height", function (d) { return y(d.y0) - y(d.y1); }) + .style("fill", function (d) { return color(d.name); }); + + var legend = svg.select(".state:last-child").selectAll(".legend") + .data(function (d) { return d.ages; }) + .enter().append("g") + .attr("class", "legend") + .attr("transform", function (d) { return "translate(" + x.rangeBand() / 2 + "," + y((d.y0 + d.y1) / 2) + ")"; }); + + legend.append("line") + .attr("x2", 10); + + legend.append("text") + .attr("x", 13) + .attr("dy", ".35em") + .text(function (d) { return d.name; }); + + }); +} + +// example from http://bl.ocks.org/3885705 +function sortablebarChart() { + var margin = { top: 20, right: 20, bottom: 30, left: 40 }, + width = 960 - margin.left - margin.right, + height = 500 - margin.top - margin.bottom; + + var formatPercent = d3.format(".0%"); + + var x = d3.scale.ordinal() + .rangeRoundBands([0, width], .1, 1); + + var y = d3.scale.linear() + .range([height, 0]); + + var xAxis = d3.svg.axis() + .scale(x) + .orient("bottom"); + + var yAxis = d3.svg.axis() + .scale(y) + .orient("left") + .tickFormat(formatPercent); + + var svg = d3.select("body").append("svg") + .attr("width", width + margin.left + margin.right) + .attr("height", height + margin.top + margin.bottom) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + + d3.tsv("data.tsv", function (error, data) { + + data.forEach(function (d) { + d.frequency = +d.frequency; + }); + + x.domain(data.map(function (d) { return d.letter; })); + y.domain([0, d3.max(data, function (d) { return d.frequency; })]); + + svg.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height + ")") + .call(xAxis); + + svg.append("g") + .attr("class", "y axis") + .call(yAxis) + .append("text") + .attr("transform", "rotate(-90)") + .attr("y", 6) + .attr("dy", ".71em") + .style("text-anchor", "end") + .text("Frequency"); + + svg.selectAll(".bar") + .data(data) + .enter().append("rect") + .attr("class", "bar") + .attr("x", function (d) { return x(d.letter); }) + .attr("width", x.rangeBand()) + .attr("y", function (d) { return y(d.frequency); }) + .attr("height", function (d) { return height - y(d.frequency); }); + + d3.select("input").on("change", change); + + var sortTimeout = setTimeout(function () { + d3.select("input").property("checked", true).each(change); + }, 2000); + + function change() { + clearTimeout(sortTimeout); + + var x0 = x.domain(data.sort(this.checked + ? function (a, b) { return b.frequency - a.frequency; } + : function (a, b) { return d3.ascending(a.letter, b.letter); }) + .map(function (d) { return d.letter; })) + .copy(); + + var transition = svg.transition().duration(750), + delay = function (d, i) { return i * 50; }; + + transition.selectAll(".bar") + .delay(delay) + .attr("x", function (d) { return x0(d.letter); }); + + transition.select(".x.axis") + .call(xAxis) + .selectAll("g") + .delay(delay); + } + }); +} + +//example from http://bl.ocks.org/4063318 +function callenderView() { + var width = 960, + height = 136, + cellSize = 17; // cell size + + var day = d3.time.format("%w"), + week = d3.time.format("%U"), + percent = d3.format(".1%"), + format = d3.time.format("%Y-%m-%d"); + + var color = d3.scale.quantize() + .domain([-.05, .05]) + .range(d3.range(11).map(function (d) { return "q" + d + "-11"; })); + + var svg = d3.select("body").selectAll("svg") + .data(d3.range(1990, 2011)) + .enter().append("svg") + .attr("width", width) + .attr("height", height) + .attr("class", "RdYlGn") + .append("g") + .attr("transform", "translate(" + ((width - cellSize * 53) / 2) + "," + (height - cellSize * 7 - 1) + ")"); + + svg.append("text") + .attr("transform", "translate(-6," + cellSize * 3.5 + ")rotate(-90)") + .style("text-anchor", "middle") + .text(function (d) { return d; }); + + var rect = svg.selectAll(".day") + .data(function (d) { return d3.time.days(new Date(d, 0, 1), new Date(d + 1, 0, 1)); }) + .enter().append("rect") + .attr("class", "day") + .attr("width", cellSize) + .attr("height", cellSize) + .attr("x", function (d) { return parseInt(week(d)) * cellSize; }) + .attr("y", function (d) { return parseInt(day(d)) * cellSize; }) + .datum(format); + + rect.append("title") + .text(function (d) { return d; }); + + svg.selectAll(".month") + .data(function (d) { return d3.time.months(new Date(d, 0, 1), new Date(d + 1, 0, 1)); }) + .enter().append("path") + .attr("class", "month") + .attr("d", monthPath); + + d3.csv("dji.csv", function (error, csv) { + var data = d3.nest() + .key(function (d) { return d.Date; }) + .rollup(function (d) { return (d[0].Close - d[0].Open) / d[0].Open; }) + .map(csv); + + rect.filter(function (d) { return d in data; }) + .attr("class", function (d) { return "day " + color(data[d]); }) + .select("title") + .text(function (d) { return d + ": " + percent(data[d]); }); + }); + + function monthPath(t0) { + var t1 = new Date(t0.getFullYear(), t0.getMonth() + 1, 0), + d0 = +day(t0), w0 = +week(t0), + d1 = +day(t1), w1 = +week(t1); + return "M" + (w0 + 1) * cellSize + "," + d0 * cellSize + + "H" + w0 * cellSize + "V" + 7 * cellSize + + "H" + w1 * cellSize + "V" + (d1 + 1) * cellSize + + "H" + (w1 + 1) * cellSize + "V" + 0 + + "H" + (w0 + 1) * cellSize + "Z"; + } + + d3.select(self.frameElement).style("height", "2910px"); +} + +// example from http://bl.ocks.org/3883245 +function lineChart() { + var margin = { top: 20, right: 20, bottom: 30, left: 50 }, + width = 960 - margin.left - margin.right, + height = 500 - margin.top - margin.bottom; + + var parseDate = d3.time.format("%d-%b-%y").parse; + + var x = d3.time.scale() + .range([0, width]); + + var y = d3.scale.linear() + .range([height, 0]); + + var xAxis = d3.svg.axis() + .scale(x) + .orient("bottom"); + + var yAxis = d3.svg.axis() + .scale(y) + .orient("left"); + + var line = d3.svg.line() + .x(function (d) { return x(d.date); }) + .y(function (d) { return y(d.close); }); + + var svg = d3.select("body").append("svg") + .attr("width", width + margin.left + margin.right) + .attr("height", height + margin.top + margin.bottom) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + + d3.tsv("data.tsv", function (error, data) { + data.forEach(function (d) { + d.date = parseDate(d.date); + d.close = +d.close; + }); + + x.domain(d3.extent(data, function (d) { return d.date; })); + y.domain(d3.extent(data, function (d) { return d.close; })); + + svg.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height + ")") + .call(xAxis); + + svg.append("g") + .attr("class", "y axis") + .call(yAxis) + .append("text") + .attr("transform", "rotate(-90)") + .attr("y", 6) + .attr("dy", ".71em") + .style("text-anchor", "end") + .text("Price ($)"); + + svg.append("path") + .datum(data) + .attr("class", "line") + .attr("d", line); + }); +} + +//example from http://bl.ocks.org/3884914 +function bivariateAreaChart() { + var margin = { top: 20, right: 20, bottom: 30, left: 50 }, + width = 960 - margin.left - margin.right, + height = 500 - margin.top - margin.bottom; + + var parseDate = d3.time.format("%Y%m%d").parse; + + var x = d3.time.scale() + .range([0, width]); + + var y = d3.scale.linear() + .range([height, 0]); + + var xAxis = d3.svg.axis() + .scale(x) + .orient("bottom"); + + var yAxis = d3.svg.axis() + .scale(y) + .orient("left"); + + var area = d3.svg.area() + .x(function (d) { return x(d.date); }) + .y0(function (d) { return y(d.low); }) + .y1(function (d) { return y(d.high); }); + + var svg = d3.select("body").append("svg") + .attr("width", width + margin.left + margin.right) + .attr("height", height + margin.top + margin.bottom) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + + d3.tsv("data.tsv", function (error, data) { + data.forEach(function (d) { + d.date = parseDate(d.date); + d.low = +d.low; + d.high = +d.high; + }); + + x.domain(d3.extent(data, function (d) { return d.date; })); + y.domain([d3.min(data, function (d) { return d.low; }), d3.max(data, function (d) { return d.high; })]); + + svg.append("path") + .datum(data) + .attr("class", "area") + .attr("d", area); + + svg.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height + ")") + .call(xAxis); + + svg.append("g") + .attr("class", "y axis") + .call(yAxis) + .append("text") + .attr("transform", "rotate(-90)") + .attr("y", 6) + .attr("dy", ".71em") + .style("text-anchor", "end") + .text("Temperature (ºF)"); + }); +} + +//Example from http://bl.ocks.org/mbostock/1557377 +function dragMultiples() { + var width = 238, + height = 123, + radius = 20; + + var drag = d3.behavior.drag() + .origin(Object) + .on("drag", dragmove); + + var svg = d3.select("body").selectAll("svg") + .data(d3.range(16).map(function () { return { x: width / 2, y: height / 2 }; })) + .enter().append("svg") + .attr("width", width) + .attr("height", height); + + svg.append("circle") + .attr("r", radius) + .attr("cx", function (d) { return d.x; }) + .attr("cy", function (d) { return d.y; }) + .call(drag); + + function dragmove(d) { + d3.select(this) + .attr("cx", d.x = Math.max(radius, Math.min(width - radius, d3.event.x))) + .attr("cy", d.y = Math.max(radius, Math.min(height - radius, d3.event.y))); + } +} + +//Example from http://bl.ocks.org/mbostock/3892919 +function panAndZoom() { + var margin = { top: 20, right: 20, bottom: 30, left: 40 }, + width = 960 - margin.left - margin.right, + height = 500 - margin.top - margin.bottom; + + var x = d3.scale.linear() + .domain([-width / 2, width / 2]) + .range([0, width]); + + var y = d3.scale.linear() + .domain([-height / 2, height / 2]) + .range([height, 0]); + + var xAxis = d3.svg.axis() + .scale(x) + .orient("bottom") + .tickSize(-height); + + var yAxis = d3.svg.axis() + .scale(y) + .orient("left") + .ticks(5) + .tickSize(-width); + + var zoom = d3.behavior.zoom() + .x(x) + .y(y) + .scaleExtent([1, 10]) + .on("zoom", zoomed); + + var svg = d3.select("body").append("svg") + .attr("width", width + margin.left + margin.right) + .attr("height", height + margin.top + margin.bottom) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")") + .call(zoom); + + svg.append("rect") + .attr("width", width) + .attr("height", height); + + svg.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height + ")") + .call(xAxis); + + svg.append("g") + .attr("class", "y axis") + .call(yAxis); + + function zoomed() { + svg.select(".x.axis").call(xAxis); + svg.select(".y.axis").call(yAxis); + } +} + +//Example from http://bl.ocks.org/mbostock/1125997 +function chainedTransitions() { + var w = 960, + h = 500, + y = d3.scale.ordinal().domain(d3.range(50)).rangePoints([20, h - 20]), + t = Date.now(); + + var svg = d3.select("body").append("svg:svg") + .attr("width", w) + .attr("height", h); + + var circle = svg.selectAll("circle") + .data(y.domain()) + .enter().append("svg:circle") + .attr("r", 16) + .attr("cx", 20) + .attr("cy", y) + .each(slide(20, w - 20)); + + function slide(x0, x1) { + t += 50; + return function() { + d3.select(this).transition() + .duration(t - Date.now()) + .attr("cx", x1) + .each("end", slide(x1, x0)); + }; + } +} + +//Example from http://bl.ocks.org/mbostock/4062085 +interface PyramidData { + people: number; + year: number; + age: number; +} +function populationPyramid() { + var margin = { top: 20, right: 40, bottom: 30, left: 20 }, + width = 960 - margin.left - margin.right, + height = 500 - margin.top - margin.bottom, + barWidth = Math.floor(width / 19) - 1; + + var x = d3.scale.linear() + .range([barWidth / 2, width - barWidth / 2]); + + var y = d3.scale.linear() + .range([height, 0]); + + var yAxis = d3.svg.axis() + .scale(y) + .orient("right") + .tickSize(-width) + .tickFormat(function (d) { return Math.round(d / 1e6) + "M"; } ); + + // An SVG element with a bottom-right origin. + var svg = d3.select("body").append("svg") + .attr("width", width + margin.left + margin.right) + .attr("height", height + margin.top + margin.bottom) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + + // A sliding container to hold the bars by birthyear. + var birthyears = svg.append("g") + .attr("class", "birthyears"); + + // A label for the current year. + var title = svg.append("text") + .attr("class", "title") + .attr("dy", ".71em") + .text(2000); + + d3.csv("population.csv", function (error, data: Array) { + + // Convert strings to numbers. + data.forEach(function (d) { + d.people = +d.people; + d.year = +d.year; + d.age = +d.age; + } ); + + // Compute the extent of the data set in age and years. + var age1 = d3.max(data, function (d) { return d.age; } ), + year0 = d3.min(data, function (d) { return d.year; } ), + year1 = d3.max(data, function (d) { return d.year; } ), + year = year1; + + // Update the scale domains. + x.domain([year1 - age1, year1]); + y.domain([0, d3.max(data, function (d) { return d.people; } )]); + + // Produce a map from year and birthyear to [male, female]. + data = d3.nest() + .key(function (d) { return d.year; } ) + .key(function (d) { return '' + (d.year - d.age); } ) + .rollup(function (v) { return v.map(function (d) { return d.people; } ); } ) + .map(data); + + // Add an axis to show the population values. + svg.append("g") + .attr("class", "y axis") + .attr("transform", "translate(" + width + ",0)") + .call(yAxis) + .selectAll("g") + .filter(function (value) { return !value; } ) + .classed("zero", true); + + // Add labeled rects for each birthyear (so that no enter or exit is required). + var birthyear = birthyears.selectAll(".birthyear") + .data(d3.range(year0 - age1, year1 + 1, 5)) + .enter().append("g") + .attr("class", "birthyear") + .attr("transform", function (birthyear) { return "translate(" + x(birthyear) + ",0)"; } ); + + birthyear.selectAll("rect") + .data(function (birthyear) { return data[year][birthyear] || [0, 0]; } ) + .enter().append("rect") + .attr("x", -barWidth / 2) + .attr("width", barWidth) + .attr("y", y) + .attr("height", function (value) { return height - y(value); } ); + + // Add labels to show birthyear. + birthyear.append("text") + .attr("y", height - 4) + .text(function (birthyear) { return birthyear; } ); + + // Add labels to show age (separate; not animated). + svg.selectAll(".age") + .data(d3.range(0, age1 + 1, 5)) + .enter().append("text") + .attr("class", "age") + .attr("x", function (age) { return x(year - age); } ) + .attr("y", height + 4) + .attr("dy", ".71em") + .text(function (age) { return age; } ); + + // Allow the arrow keys to change the displayed year. + window.focus(); + d3.select(window).on("keydown", function () { + switch (d3.event.keyCode) { + case 37: year = Math.max(year0, year - 10); break; + case 39: year = Math.min(year1, year + 10); break; + } + update(); + } ); + + function update() { + if (!(year in data)) return; + title.text(year); + + birthyears.transition() + .duration(750) + .attr("transform", "translate(" + (x(year1) - x(year)) + ",0)"); + + birthyear.selectAll("rect") + .data(function (birthyear) { return data[year][birthyear] || [0, 0]; } ) + .transition() + .duration(750) + .attr("y", y) + .attr("height", function (value) { return height - y(value); } ); + } + } ); +} + +//Example from http://bl.ocks.org/MoritzStefaner/1377729 +function forcedBasedLabelPlacemant() { + var w = 960, h = 500; + + var labelDistance = 0; + + var vis = d3.select("body").append("svg:svg").attr("width", w).attr("height", h); + + var nodes = []; + var labelAnchors = []; + var labelAnchorLinks = []; + var links = []; + + for (var i = 0; i < 30; i++) { + var nodeLabel = { + label: "node " + i + }; + nodes.push(nodeLabel); + labelAnchors.push({ + node: nodeLabel + }); + labelAnchors.push({ + node: nodeLabel + }); + }; + + for (var i = 0; i < nodes.length; i++) { + for (var j = 0; j < i; j++) { + if (Math.random() > .95) + links.push({ + source: i, + target: j, + weight: Math.random() + }); + } + labelAnchorLinks.push({ + source: i * 2, + target: i * 2 + 1, + weight: 1 + }); + }; + + var force = d3.layout.force().size([w, h]).nodes(nodes).links(links).gravity(1).linkDistance(50).charge(-3000).linkStrength(function (x) { + return x.weight * 10 + } ); + + + force.start(); + + var force2 = d3.layout.force().nodes(labelAnchors).links(labelAnchorLinks).gravity(0).linkDistance(0).linkStrength(8).charge(-100).size([w, h]); + force2.start(); + + var link = vis.selectAll("line.link").data(links).enter().append("svg:line").attr("class", "link").style("stroke", "#CCC"); + + var node = vis.selectAll("g.node").data(force.nodes()).enter().append("svg:g").attr("class", "node"); + node.append("svg:circle").attr("r", 5).style("fill", "#555").style("stroke", "#FFF").style("stroke-width", 3); + node.call(force.drag); + + + var anchorLink = vis.selectAll("line.anchorLink").data(labelAnchorLinks)//.enter().append("svg:line").attr("class", "anchorLink").style("stroke", "#999"); + + var anchorNode = vis.selectAll("g.anchorNode").data(force2.nodes()).enter().append("svg:g").attr("class", "anchorNode"); + anchorNode.append("svg:circle").attr("r", 0).style("fill", "#FFF"); + anchorNode.append("svg:text").text(function (d, i) { + return i % 2 == 0 ? "" : d.node.label + } ).style("fill", "#555").style("font-family", "Arial").style("font-size", 12); + + var updateLink = function () { + this.attr("x1", function (d) { + return d.source.x; + } ).attr("y1", function (d) { + return d.source.y; + } ).attr("x2", function (d) { + return d.target.x; + } ).attr("y2", function (d) { + return d.target.y; + } ); + + } + + var updateNode = function () { + this.attr("transform", function (d) { + return "translate(" + d.x + "," + d.y + ")"; + } ); + + } + + force.on("tick", function () { + + force2.start(); + + node.call(updateNode); + + anchorNode.each(function (d, i) { + if (i % 2 == 0) { + d.x = d.node.x; + d.y = d.node.y; + } else { + var b = this.childNodes[1].getBBox(); + + var diffX = d.x - d.node.x; + var diffY = d.y - d.node.y; + + var dist = Math.sqrt(diffX * diffX + diffY * diffY); + + var shiftX = b.width * (diffX - dist) / (dist * 2); + shiftX = Math.max(-b.width, Math.min(0, shiftX)); + var shiftY = 5; + this.childNodes[1].setAttribute("transform", "translate(" + shiftX + "," + shiftY + ")"); + } + } ); + + + anchorNode.call(updateNode); + + link.call(updateLink); + anchorLink.call(updateLink); + + } ); +} + +//Example from http://bl.ocks.org/mbostock/1125997 +function forceCollapsable() { + var w = 1280, + h = 800, + node, + link, + root; + + var force = d3.layout.force() + .on("tick", tick) + .charge(function (d) { return d._children ? -d.size / 100 : -30; } ) + .linkDistance(function (d) { return d.target._children ? 80 : 30; } ) + .size([w, h - 160]); + + var vis = d3.select("body").append("svg:svg") + .attr("width", w) + .attr("height", h); + + d3.json("flare.json", function (json) { + root = json; + root.fixed = true; + root.x = w / 2; + root.y = h / 2 - 80; + update(); + } ); + + function update() { + var nodes = flatten(root), + links = d3.layout.tree().links(nodes); + + // Restart the force layout. + force + .nodes(nodes) + .links(links) + .start(); + + // Update the links… + link = vis.selectAll("line.link") + .data(links, function (d) { return d.target.id; } ); + + // Enter any new links. + link.enter().insert("svg:line", ".node") + .attr("class", "link") + .attr("x1", function (d) { return d.source.x; } ) + .attr("y1", function (d) { return d.source.y; } ) + .attr("x2", function (d) { return d.target.x; } ) + .attr("y2", function (d) { return d.target.y; } ); + + // Exit any old links. + link.exit().remove(); + + // Update the nodes… + node = vis.selectAll("circle.node") + .data(nodes, function (d) { return d.id; } ) + .style("fill", color); + + node.transition() + .attr("r", function (d) { return d.children ? 4.5 : Math.sqrt(d.size) / 10; } ); + + // Enter any new nodes. + node.enter().append("svg:circle") + .attr("class", "node") + .attr("cx", function (d) { return d.x; } ) + .attr("cy", function (d) { return d.y; } ) + .attr("r", function (d) { return d.children ? 4.5 : Math.sqrt(d.size) / 10; } ) + .style("fill", color) + .on("click", click) + .call(force.drag); + + // Exit any old nodes. + node.exit().remove(); + } + + function tick() { + link.attr("x1", function (d) { return d.source.x; } ) + .attr("y1", function (d) { return d.source.y; } ) + .attr("x2", function (d) { return d.target.x; } ) + .attr("y2", function (d) { return d.target.y; } ); + + node.attr("cx", function (d) { return d.x; } ) + .attr("cy", function (d) { return d.y; } ); + } + + // Color leaf nodes orange, and packages white or blue. + function color(d) { + return d._children ? "#3182bd" : d.children ? "#c6dbef" : "#fd8d3c"; + } + + // Toggle children on click. + function click(d) { + if (d.children) { + d._children = d.children; + d.children = null; + } else { + d.children = d._children; + d._children = null; + } + update(); + } + + // Returns a list of all nodes under the root. + function flatten(root) { + var nodes = [], i = 0; + + function recurse(node) { + if (node.children) node.size = node.children.reduce(function (p, v) { return p + recurse(v); } , 0); + if (!node.id) node.id = ++i; + nodes.push(node); + return node.size; + } + + root.size = recurse(root); + return nodes; + } +} + +//Example from http://bl.ocks.org/mbostock/3757110 +function azimuthalEquidistant() { + var width = 960, + height = 960; + var topojson: any; + + var projection = d3.geo.azimuthalEquidistant() + .scale(150) + .translate([width / 2, height / 2]) + .clipAngle(180 - 1e-3) + .precision(.1); + + var path = d3.geo.path() + .projection(projection); + + var graticule = d3.geo.graticule(); + + var svg = d3.select("body").append("svg") + .attr("width", width) + .attr("height", height); + + svg.append("defs").append("path") + .datum({ type: "Sphere" }) + .attr("id", "sphere") + .attr("d", path); + + svg.append("use") + .attr("class", "stroke") + .attr("xlink:href", "#sphere"); + + svg.append("use") + .attr("class", "fill") + .attr("xlink:href", "#sphere"); + + svg.append("path") + .datum(graticule) + .attr("class", "graticule") + .attr("d", path); + + d3.json("/mbostock/raw/4090846/world-50m.json", function (error, world) { + svg.insert("path", ".graticule") + .datum(topojson.feature(world, world.objects.land)) + .attr("class", "land") + .attr("d", path); + + svg.insert("path", ".graticule") + .datum(topojson.mesh(world, world.objects.countries, function (a, b) { return a !== b; } )) + .attr("class", "boundary") + .attr("d", path); + } ); + + d3.select(self.frameElement).style("height", height + "px"); +} + +//Example from http://bl.ocks.org/mbostock/4060366 +function voronoiTesselation() { + var width = 960, + height = 500; + + var vertices = >d3.range(100).map(function (d) { + return [Math.random() * width, Math.random() * height]; + } ); + + var voronoi = d3.geom.voronoi() + .clipExtent([[0, 0], [width, height]]); + + var svg = d3.select("body").append("svg") + .attr("width", width) + .attr("height", height) + .attr("class", "PiYG") + .on("mousemove", function () { vertices[0] = d3.mouse(this); redraw(); } ); + + var path = svg.append("g").selectAll("path"); + + svg.selectAll("circle") + .data(vertices.slice(1)) + .enter().append("circle") + .attr("transform", function (d) { return "translate(" + d + ")"; } ) + .attr("r", 2); + + redraw(); + + function redraw() { + path = path.data(voronoi(vertices).map(function (d) { return "M" + d.join("L") + "Z"; } ), String); + path.exit().remove(); + path.enter().append("path").attr("class", function (d, i) { return "q" + (i % 9) + "-9"; } ).attr("d", String); + path.order(); + } +} + +// Example from https://gist.github.com/christophermanning/1734663 +function forceDirectedVoronoi() { + var w = window.innerWidth > 960 ? 960 : (window.innerWidth || 960), + h = window.innerHeight > 500 ? 500 : (window.innerHeight || 500), + radius = 5.25, + links = [], + simulate = true, + zoomToAdd = true, + color = d3.scale.quantize().domain([10000, 7250]).range(["#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]) + + var numVertices = (w*h) / 3000; + var vertices = d3.range(numVertices).map(function(i) { + var angle = radius * (i+10); + return {x: angle*Math.cos(angle)+(w/2), y: angle*Math.sin(angle)+(h/2)}; + }); + var d3_geom_voronoi = d3.geom.voronoi() + .x(function(d) { return d.x; }) + .y(function(d) { return d.y; }) + var prevEventScale = 1; + var zoom = d3.behavior.zoom().on("zoom", function(d,i) { + if (zoomToAdd){ + if (d3.event.scale > prevEventScale) { + var angle = radius * vertices.length; + vertices.push({x: angle*Math.cos(angle)+(w/2), y: angle*Math.sin(angle)+(h/2)}) + } else if (vertices.length > 2 && d3.event.scale != prevEventScale) { + vertices.pop(); + } + force.nodes(vertices).start() + } else { + if (d3.event.scale > prevEventScale) { + radius+= .01 + } else { + radius -= .01 + } + vertices.forEach(function(d, i) { + var angle = radius * (i+10); + vertices[i] = {x: angle*Math.cos(angle)+(w/2), y: angle*Math.sin(angle)+(h/2)}; + }); + force.nodes(vertices).start() + } + prevEventScale = d3.event.scale; + }); + + d3.select(window) + .on("keydown", function() { + // shift + if(d3.event.keyCode == 16) { + zoomToAdd = false + } + + // s + if(d3.event.keyCode == 83) { + simulate = !simulate + if(simulate) { + force.start() + } else { + force.stop() + } + } + }) + .on("keyup", function() { + zoomToAdd = true + }) + + var svg = d3.select("#chart") + .append("svg") + .attr("width", w) + .attr("height", h) + .call(zoom) + + var force = d3.layout.force() + .charge(-300) + .size([w, h]) + .on("tick", update); + + force.nodes(vertices).start(); + + var circle = svg.selectAll("circle"); + var path = svg.selectAll("path"); + var link = svg.selectAll("line"); + + function update() { + path = path.data(d3_geom_voronoi(vertices)); + path.enter().append("path") + // drag node by dragging cell + .call(d3.behavior.drag() + .on("drag", function(d, i) { + vertices[i] = {x: vertices[i].x + d3.event.dx, y: vertices[i].y + d3.event.dy} + }) + ) + .style("fill", function(d, i) { return color(0) }) + path.attr("d", function(d) { return "M" + d.join("L") + "Z"; }) + .transition().duration(150).style("fill", function(d, i) { return color(d3.geom.polygon(d).area()) }) + path.exit().remove(); + + circle = circle.data(vertices) + circle.enter().append("circle") + .attr("r", 0) + .transition().duration(1000).attr("r", 5); + circle.attr("cx", function(d) { return d.x; }) + .attr("cy", function(d) { return d.y; }); + circle.exit().transition().attr("r", 0).remove(); + + link = link.data(d3_geom_voronoi.links(vertices)) + link.enter().append("line") + link.attr("x1", function(d) { return d.source.x; }) + .attr("y1", function(d) { return d.source.y; }) + .attr("x2", function(d) { return d.target.x; }) + .attr("y2", function(d) { return d.target.y; }) + + link.exit().remove() + + if(!simulate) force.stop() + } +} + +//Example from http://bl.ocks.org/mbostock/4341156 +function delaunayTesselation() { + var width = 960, + height = 500; + + var vertices = >d3.range(100).map(function (d) { + return [Math.random() * width, Math.random() * height]; + } ); + + var svg = d3.select("body").append("svg") + .attr("width", width) + .attr("height", height) + .attr("class", "PiYG") + .on("mousemove", function () { vertices[0] = d3.mouse(this); redraw(); } ); + + var path = svg.append("g").selectAll("path"); + + svg.selectAll("circle") + .data(vertices.slice(1)) + .enter().append("circle") + .attr("transform", function (d) { return "translate(" + d + ")"; } ) + .attr("r", 2); + + redraw(); + + function redraw() { + path = path.data(d3.geom.delaunay(vertices).map(function (d) { return "M" + d.join("L") + "Z"; } ), String); + path.exit().remove(); + path.enter().append("path").attr("class", function (d, i) { return "q" + (i % 9) + "-9"; } ).attr("d", String); + } +} + +//Example from http://bl.ocks.org/mbostock/4343214 +function quadtree() { + var width = 960, + height = 500; + + var data = d3.range(5000).map(function () { + return { x: Math.random() * width, y: Math.random() * width }; + } ); + + var quadtree = d3.geom.quadtree(data, -1, -1, width + 1, height + 1); + + var brush = d3.svg.brush() + .x(d3.scale.identity().domain([0, width])) + .y(d3.scale.identity().domain([0, height])) + .on("brush", brushed) + .extent([[100, 100], [200, 200]]); + + var svg = d3.select("body").append("svg") + .attr("width", width) + .attr("height", height); + + svg.selectAll(".node") + .data(nodes(quadtree)) + .enter().append("rect") + .attr("class", "node") + .attr("x", function (d) { return d.x; } ) + .attr("y", function (d) { return d.y; } ) + .attr("width", function (d) { return d.width; } ) + .attr("height", function (d) { return d.height; } ); + + var point = svg.selectAll(".point") + .data(data) + .enter().append("circle") + .attr("class", "point") + .attr("cx", function (d) { return d.x; } ) + .attr("cy", function (d) { return d.y; } ) + .attr("r", 4); + + svg.append("g") + .attr("class", "brush") + .call(brush); + + brushed(); + + function brushed() { + var extent = brush.extent(); + point.each(function (d) { d.scanned = d.selected = false; } ); + search(quadtree, extent[0][0], extent[0][1], extent[1][0], extent[1][1]); + point.classed("scanned", function (d) { return d.scanned; } ); + point.classed("selected", function (d) { return d.selected; } ); + } + + // Collapse the quadtree into an array of rectangles. + function nodes(quadtree) { + var nodes = []; + quadtree.visit(function (node, x1, y1, x2, y2) { + nodes.push({ x: x1, y: y1, width: x2 - x1, height: y2 - y1 }); + } ); + return nodes; + } + + // Find the nodes within the specified rectangle. + function search(quadtree, x0, y0, x3, y3) { + quadtree.visit(function (node, x1, y1, x2, y2) { + var p = node.point; + if (p) { + p.scanned = true; + p.selected = (p.x >= x0) && (p.x < x3) && (p.y >= y0) && (p.y < y3); + } + return x1 >= x3 || y1 >= y3 || x2 < x0 || y2 < y0; + } ); + } +} + +//Example from http://bl.ocks.org/mbostock/4341699 +function convexHull() { + var width = 960, + height = 500; + + var randomX = d3.random.normal(width / 2, 60), + randomY = d3.random.normal(height / 2, 60), + vertices = d3.range(100).map(function () { return [randomX(), randomY()]; } ); + + var svg = d3.select("body").append("svg") + .attr("width", width) + .attr("height", height) + .on("mousemove", function () { vertices[0] = d3.mouse(this); redraw(); } ) + .on("click", function () { vertices.push(d3.mouse(this)); redraw(); } ); + + svg.append("rect") + .attr("width", width) + .attr("height", height); + + var hull = svg.append("path") + .attr("class", "hull"); + + var circle = svg.selectAll("circle"); + + redraw(); + + function redraw() { + hull.datum(d3.geom.hull(vertices)).attr("d", function (d) { return "M" + d.join("L") + "Z"; } ); + circle = circle.data(vertices); + circle.enter().append("circle").attr("r", 3); + circle.attr("transform", function (d) { return "translate(" + d + ")"; } ); + } +} + +// example from http://bl.ocks.org/mbostock/1044242 +function hierarchicalEdgeBundling() { + var diameter = 960, + radius = diameter / 2, + innerRadius = radius - 120; + + var cluster = d3.layout.cluster() + .size([360, innerRadius]) + .sort(null) + .value(function (d) { return d.size; } ); + + var bundle = d3.layout.bundle(); + + var line = d3.svg.line.radial() + .interpolate("bundle") + .tension(.85) + .radius(function (d) { return d.y; } ) + .angle(function (d) { return d.x / 180 * Math.PI; } ); + + var svg = d3.select("body").append("svg") + .attr("width", diameter) + .attr("height", diameter) + .append("g") + .attr("transform", "translate(" + radius + "," + radius + ")"); + + d3.json("readme-flare-imports.json", function (error, classes) { + var nodes = cluster.nodes(packages.root(classes)), + links = packages.imports(nodes); + + svg.selectAll(".link") + .data(bundle(links)) + .enter().append("path") + .attr("class", "link") + .attr("d", line); + + svg.selectAll(".node") + .data(nodes.filter(function (n) { return !n.children; } )) + .enter().append("g") + .attr("class", "node") + .attr("transform", function (d) { return "rotate(" + (d.x - 90) + ")translate(" + d.y + ")"; } ) + .append("text") + .attr("dx", function (d) { return d.x < 180 ? 8 : -8; } ) + .attr("dy", ".31em") + .attr("text-anchor", function (d) { return d.x < 180 ? "start" : "end"; } ) + .attr("transform", function (d) { return d.x < 180 ? null : "rotate(180)"; } ) + .text(function (d) { return d.key; } ); + } ); + + d3.select(self.frameElement).style("height", diameter + "px"); + + var packages = { + + // Lazily construct the package hierarchy from class names. + root: function (classes) { + var map = {}; + + function find(name, data?) { + var node = map[name], i; + if (!node) { + node = map[name] = data || { name: name, children: [] }; + if (name.length) { + node.parent = find(name.substring(0, i = name.lastIndexOf("."))); + node.parent.children.push(node); + node.key = name.substring(i + 1); + } + } + return node; + } + + classes.forEach(function (d) { + find(d.name, d); + } ); + + return map[""]; + } , + + // Return a list of imports for the given array of nodes. + imports: function (nodes) { + var map = {}, + imports = []; + + // Compute a map from name to node. + nodes.forEach(function (d) { + map[d.name] = d; + } ); + + // For each import, construct a link from the source to target node. + nodes.forEach(function (d) { + if (d.imports) d.imports.forEach(function (i) { + imports.push({ source: map[d.name], target: map[i] }); + } ); + } ); + + return imports; + } + }; +} + +// example from http://bl.ocks.org/mbostock/1123639 +function roundedRectangles() { + var mouse = [480, 250], + count = 0; + + var svg = d3.select("body").append("svg:svg") + .attr("width", 960) + .attr("height", 500); + + var g = svg.selectAll("g") + .data(d3.range(25)) + .enter().append("svg:g") + .attr("transform", "translate(" + mouse + ")"); + + g.append("svg:rect") + .attr("rx", 6) + .attr("ry", 6) + .attr("x", -12.5) + .attr("y", -12.5) + .attr("width", 25) + .attr("height", 25) + .attr("transform", function (d, i) { return "scale(" + (1 - d / 25) * 20 + ")"; } ) + .style("fill", d3.scale.category20c()); + + g.map(function (d) { + return { center: [0, 0], angle: 0 }; + } ); + + svg.on("mousemove", function () { + mouse = d3.mouse(this); + } ); + + d3.timer(function () { + count++; + g.attr("transform", function (d, i) { + d.center[0] += (mouse[0] - d.center[0]) / (i + 5); + d.center[1] += (mouse[1] - d.center[1]) / (i + 5); + d.angle += Math.sin((count + i) / 10) * 7; + return "translate(" + d.center + ")rotate(" + d.angle + ")"; + } ); + return true; + } ); +} + +// example from http://bl.ocks.org/mbostock/4060954 +function streamGraph() { + var n = 20, // number of layers + m = 200, // number of samples per layer + stack = d3.layout.stack().offset("wiggle"), + layers0 = stack(d3.range(n).map(function () { return bumpLayer(m); })), + layers1 = stack(d3.range(n).map(function () { return bumpLayer(m); })); + + var width = 960, + height = 500; + + var x = d3.scale.linear() + .domain([0, m - 1]) + .range([0, width]); + + var y = d3.scale.linear() + .domain([0, d3.max(layers0.concat(layers1), function (layer) { return d3.max(layer, function (d) { return d.y0 + d.y; }); })]) + .range([height, 0]); + + var color = d3.scale.linear() + .range(["#aad", "#556"]); + + var area = d3.svg.area() + .x(function (d) { return x(d.x); }) + .y0(function (d) { return y(d.y0); }) + .y1(function (d) { return y(d.y0 + d.y); }); + + var svg = d3.select("body").append("svg") + .attr("width", width) + .attr("height", height); + + svg.selectAll("path") + .data(layers0) + .enter().append("path") + .attr("d", area) + .style("fill", function () { return color(Math.random()); }); + + function transition() { + d3.selectAll("path") + .data(function () { + var d = layers1; + layers1 = layers0; + return layers0 = d; + }) + .transition() + .duration(2500) + .attr("d", area); + } + + // Inspired by Lee Byron's test data generator. + function bumpLayer(n): Array<{x: number; y: number;y0?:number;}> { + + function bump(a) { + var x = 1 / (.1 + Math.random()), + y = 2 * Math.random() - .5, + z = 10 / (.1 + Math.random()); + for (var i = 0; i < n; i++) { + var w = (i / n - y) * z; + a[i] += x * Math.exp(-w * w); + } + } + + var a = [], i; + for (i = 0; i < n; ++i) a[i] = 0; + for (i = 0; i < 5; ++i) bump(a); + return a.map(function (d, i) { return { x: i, y: Math.max(0, d) }; } ); + } +} + +// example from http://mbostock.github.io/d3/talk/20111116/force-collapsible.html +function forceCollapsable2() { + var w = 1280, + h = 800, + node, + link, + root; + + var force = d3.layout.force() + .on("tick", tick) + .charge(function (d) { return d._children ? -d.size / 100 : -30; } ) + .linkDistance(function (d) { return d.target._children ? 80 : 30; } ) + .size([w, h - 160]); + + var vis = d3.select("body").append("svg:svg") + .attr("width", w) + .attr("height", h); + + d3.json("flare.json", function (json) { + root = json; + root.fixed = true; + root.x = w / 2; + root.y = h / 2 - 80; + update(); + } ); + + function update() { + var nodes = flatten(root), + links = d3.layout.tree().links(nodes); + + // Restart the force layout. + force + .nodes(nodes) + .links(links) + .start(); + + // Update the links… + link = vis.selectAll("line.link") + .data(links, function (d) { return d.target.id; } ); + + // Enter any new links. + link.enter().insert("svg:line", ".node") + .attr("class", "link") + .attr("x1", function (d) { return d.source.x; } ) + .attr("y1", function (d) { return d.source.y; } ) + .attr("x2", function (d) { return d.target.x; } ) + .attr("y2", function (d) { return d.target.y; } ); + + // Exit any old links. + link.exit().remove(); + + // Update the nodes… + node = vis.selectAll("circle.node") + .data(nodes, function (d) { return d.id; } ) + .style("fill", color); + + node.transition() + .attr("r", function (d) { return d.children ? 4.5 : Math.sqrt(d.size) / 10; } ); + + // Enter any new nodes. + node.enter().append("svg:circle") + .attr("class", "node") + .attr("cx", function (d) { return d.x; } ) + .attr("cy", function (d) { return d.y; } ) + .attr("r", function (d) { return d.children ? 4.5 : Math.sqrt(d.size) / 10; } ) + .style("fill", color) + .on("click", click) + .call(force.drag); + + // Exit any old nodes. + node.exit().remove(); + } + + function tick() { + link.attr("x1", function (d) { return d.source.x; } ) + .attr("y1", function (d) { return d.source.y; } ) + .attr("x2", function (d) { return d.target.x; } ) + .attr("y2", function (d) { return d.target.y; } ); + + node.attr("cx", function (d) { return d.x; } ) + .attr("cy", function (d) { return d.y; } ); + } + + // Color leaf nodes orange, and packages white or blue. + function color(d) { + return d._children ? "#3182bd" : d.children ? "#c6dbef" : "#fd8d3c"; + } + + // Toggle children on click. + function click(d) { + if (d.children) { + d._children = d.children; + d.children = null; + } else { + d.children = d._children; + d._children = null; + } + update(); + } + + // Returns a list of all nodes under the root. + function flatten(root) { + var nodes = [], i = 0; + + function recurse(node) { + if (node.children) node.size = node.children.reduce(function (p, v) { return p + recurse(v); } , 0); + if (!node.id) node.id = ++i; + nodes.push(node); + return node.size; + } + + root.size = recurse(root); + return nodes; + } +} + +//exapmle from http://bl.ocks.org/mbostock/4062006 +function chordDiagram() { + var matrix = [ + [11975, 5871, 8916, 2868], + [1951, 10048, 2060, 6171], + [8010, 16145, 8090, 8045], + [1013, 990, 940, 6907] + ]; + + var chord = d3.layout.chord() + .padding(.05) + .sortSubgroups(d3.descending) + .matrix(matrix); + + var width = 960, + height = 500, + innerRadius = Math.min(width, height) * .41, + outerRadius = innerRadius * 1.1; + + var fill = d3.scale.ordinal() + .domain(d3.range(4)) + .range(["#000000", "#FFDD89", "#957244", "#F26223"]); + + var svg = d3.select("body").append("svg") + .attr("width", width) + .attr("height", height) + .append("g") + .attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"); + + svg.append("g").selectAll("path") + .data(chord.groups) + .enter().append("path") + .style("fill", function (d) { return fill(d.index); } ) + .style("stroke", function (d) { return fill(d.index); } ) + .attr("d", d3.svg.arc().innerRadius(innerRadius).outerRadius(outerRadius)) + .on("mouseover", fade(.1)) + .on("mouseout", fade(1)); + + var ticks = svg.append("g").selectAll("g") + .data(chord.groups) + .enter().append("g").selectAll("g") + .data(groupTicks) + .enter().append("g") + .attr("transform", function (d) { + return "rotate(" + (d.angle * 180 / Math.PI - 90) + ")" + + "translate(" + outerRadius + ",0)"; + } ); + + ticks.append("line") + .attr("x1", 1) + .attr("y1", 0) + .attr("x2", 5) + .attr("y2", 0) + .style("stroke", "#000"); + + ticks.append("text") + .attr("x", 8) + .attr("dy", ".35em") + .attr("transform", function (d) { return d.angle > Math.PI ? "rotate(180)translate(-16)" : null; } ) + .style("text-anchor", function (d) { return d.angle > Math.PI ? "end" : null; } ) + .text(function (d) { return d.label; } ); + + svg.append("g") + .attr("class", "chord") + .selectAll("path") + .data(chord.chords) + .enter().append("path") + .attr("d", d3.svg.chord().radius(innerRadius)) + .style("fill", function (d) { return fill(d.target.index); } ) + .style("opacity", 1); + + // Returns an array of tick angles and labels, given a group. + function groupTicks(d) { + var k = (d.endAngle - d.startAngle) / d.value; + return d3.range(0, d.value, 1000).map(function (v, i) { + return { + angle: v * k + d.startAngle, + label: i % 5 ? null : v / 1000 + "k" + }; + } ); + } + + // Returns an event handler for fading a given chord group. + function fade(opacity) { + return function (g, i) { + svg.selectAll(".chord path") + .filter(function (d) { return d.source.index != i && d.target.index != i; } ) + .transition() + .style("opacity", opacity); + }; + } +} + +//example from http://mbostock.github.io/d3/talk/20111116/iris-parallel.html +function irisParallel() { + var species = ["setosa", "versicolor", "virginica"], + traits = ["sepal length", "petal length", "sepal width", "petal width"]; + + var m = [80, 160, 200, 160], + w = 1280 - m[1] - m[3], + h = 800 - m[0] - m[2]; + + var x = d3.scale.ordinal().domain(traits).rangePoints([0, w]), + y = {}; + + var line = d3.svg.line(), + axis = d3.svg.axis().orient("left"), + foreground; + + var svg = d3.select("body").append("svg:svg") + .attr("width", w + m[1] + m[3]) + .attr("height", h + m[0] + m[2]) + .append("svg:g") + .attr("transform", "translate(" + m[3] + "," + m[0] + ")"); + + d3.csv("iris.csv", function (flowers) { + + // Create a scale and brush for each trait. + traits.forEach(function (d) { + // Coerce values to numbers. + flowers.forEach(function (p) { p[d] = +p[d]; } ); + + y[d] = d3.scale.linear() + .domain(d3.extent(flowers, function (p) { return p[d]; } )) + .range([h, 0]); + + y[d].brush = d3.svg.brush() + .y(y[d]) + .on("brush", brush); + } ); + + // Add a legend. + var legend = svg.selectAll("g.legend") + .data(species) + .enter().append("svg:g") + .attr("class", "legend") + .attr("transform", function (d, i) { return "translate(0," + (i * 20 + 584) + ")"; } ); + + legend.append("svg:line") + .attr("class", String) + .attr("x2", 8); + + legend.append("svg:text") + .attr("x", 12) + .attr("dy", ".31em") + .text(function (d) { return "Iris " + d; } ); + + // Add foreground lines. + foreground = svg.append("svg:g") + .attr("class", "foreground") + .selectAll("path") + .data(flowers) + .enter().append("svg:path") + .attr("d", path) + .attr("class", function (d) { return d.species; } ); + + // Add a group element for each trait. + var g = svg.selectAll(".trait") + .data(traits) + .enter().append("svg:g") + .attr("class", "trait") + .attr("transform", function (d) { return "translate(" + x(d) + ")"; } ) + .call(d3.behavior.drag() + .origin(function (d) { return { x: x(d) }; } ) + .on("dragstart", dragstart) + .on("drag", drag) + .on("dragend", dragend)); + + // Add an axis and title. + g.append("svg:g") + .attr("class", "axis") + .each(function (d) { d3.select(this).call(axis.scale(y[d])); } ) + .append("svg:text") + .attr("text-anchor", "middle") + .attr("y", -9) + .text(String); + + // Add a brush for each axis. + g.append("svg:g") + .attr("class", "brush") + .each(function (d) { d3.select(this).call(y[d].brush); } ) + .selectAll("rect") + .attr("x", -8) + .attr("width", 16); + + function dragstart(d, i?) { + i = traits.indexOf(d); + } + + function drag(d, i?) { + x.range()[i] = d3.event.x; + traits.sort(function (a, b) { return x(a) - x(b); } ); + g.attr("transform", function (d) { return "translate(" + x(d) + ")"; } ); + foreground.attr("d", path); + } + + function dragend(d) { + x.domain(traits).rangePoints([0, w]); + var t = d3.transition().duration(500); + t.selectAll(".trait").attr("transform", function (d) { return "translate(" + x(d) + ")"; } ); + t.selectAll(".foreground path").attr("d", path); + } + } ); + + // Returns the path for a given data point. + function path(d) { + return line(traits.map(function (p) { return [x(p), y[p](d[p])]; } )); + } + + // Handles a brush event, toggling the display of foreground lines. + function brush() { + var actives = traits.filter(function (p) { return !y[p].brush.empty(); } ), + extents = actives.map(function (p) { return y[p].brush.extent(); } ); + foreground.classed("fade", function (d) { + return !actives.every(function (p, i) { + return extents[i][0] <= d[p] && d[p] <= extents[i][1]; + } ); + } ); + } +} + +//example from +function healthAndWealth() { + // Various accessors that specify the four dimensions of data to visualize. + function x(d) { return d.income; } + function y(d) { return d.lifeExpectancy; } + function radius(d) { return d.population; } + function color(d) { return d.region; } + function key(d) { return d.name; } + + // Chart dimensions. + var margin = { top: 19.5, right: 19.5, bottom: 19.5, left: 39.5 }, + width = 960 - margin.right, + height = 500 - margin.top - margin.bottom; + + // Various scales. These domains make assumptions of data, naturally. + var xScale = d3.scale.log().domain([300, 1e5]).range([0, width]), + yScale = d3.scale.linear().domain([10, 85]).range([height, 0]), + radiusScale = d3.scale.sqrt().domain([0, 5e8]).range([0, 40]), + colorScale = d3.scale.category10(); + + // The x & y axes. + var xAxis = d3.svg.axis().orient("bottom").scale(xScale).ticks(12, d3.format(",d")), + yAxis = d3.svg.axis().scale(yScale).orient("left"); + + // Create the SVG container and set the origin. + var svg = d3.select("#chart").append("svg") + .attr("width", width + margin.left + margin.right) + .attr("height", height + margin.top + margin.bottom) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + + // Add the x-axis. + svg.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height + ")") + .call(xAxis); + + // Add the y-axis. + svg.append("g") + .attr("class", "y axis") + .call(yAxis); + + // Add an x-axis label. + svg.append("text") + .attr("class", "x label") + .attr("text-anchor", "end") + .attr("x", width) + .attr("y", height - 6) + .text("income per capita, inflation-adjusted (dollars)"); + + // Add a y-axis label. + svg.append("text") + .attr("class", "y label") + .attr("text-anchor", "end") + .attr("y", 6) + .attr("dy", ".75em") + .attr("transform", "rotate(-90)") + .text("life expectancy (years)"); + + // Add the year label; the value is set on transition. + var label = svg.append("text") + .attr("class", "year label") + .attr("text-anchor", "end") + .attr("y", height - 24) + .attr("x", width) + .text(1800); + + // Load the data. + d3.json("nations.json", function (nations) { + + // A bisector since many nation's data is sparsely-defined. + var bisect = d3.bisector(function (d) { return d[0]; } ); + + // Add a dot per nation. Initialize the data at 1800, and set the colors. + var dot = svg.append("g") + .attr("class", "dots") + .selectAll(".dot") + .data(interpolateData(1800)) + .enter().append("circle") + .attr("class", "dot") + .style("fill", function (d) { return colorScale(color(d)); } ) + .call(position) + .sort(order); + + // Add a title. + dot.append("title") + .text(function (d) { return d.name; } ); + + // Add an overlay for the year label. + var box = (label.node()).getBBox(); + + var overlay = svg.append("rect") + .attr("class", "overlay") + .attr("x", box.x) + .attr("y", box.y) + .attr("width", box.width) + .attr("height", box.height) + .on("mouseover", enableInteraction); + + // Start a transition that interpolates the data based on year. + svg.transition() + .duration(30000) + .ease("linear") + .tween("year", tweenYear) + .each("end", enableInteraction); + + // Positions the dots based on data. + function position(dot) { + dot.attr("cx", function (d) { return xScale(x(d)); } ) + .attr("cy", function (d) { return yScale(y(d)); } ) + .attr("r", function (d) { return radiusScale(radius(d)); } ); + } + + // Defines a sort order so that the smallest dots are drawn on top. + function order(a, b) { + return radius(b) - radius(a); + } + + // After the transition finishes, you can mouseover to change the year. + function enableInteraction() { + var yearScale = d3.scale.linear() + .domain([1800, 2009]) + .range([box.x + 10, box.x + box.width - 10]) + .clamp(true); + + // Cancel the current transition, if any. + svg.transition().duration(0); + + overlay + .on("mouseover", mouseover) + .on("mouseout", mouseout) + .on("mousemove", mousemove) + .on("touchmove", mousemove); + + function mouseover() { + label.classed("active", true); + } + + function mouseout() { + label.classed("active", false); + } + + function mousemove() { + displayYear(yearScale.invert(d3.mouse(this)[0])); + } + } + + // Tweens the entire chart by first tweening the year, and then the data. + // For the interpolated data, the dots and label are redrawn. + function tweenYear() { + var year = d3.interpolateNumber(1800, 2009); + return function (t) { displayYear(year(t)); }; + } + + // Updates the display to show the specified year. + function displayYear(year) { + dot.data(interpolateData(year), key).call(position).sort(order); + label.text(Math.round(year)); + } + + // Interpolates the dataset for the given (fractional) year. + function interpolateData(year) { + return nations.map(function (d) { + return { + name: d.name, + region: d.region, + income: interpolateValues(d.income, year), + population: interpolateValues(d.population, year), + lifeExpectancy: interpolateValues(d.lifeExpectancy, year) + }; + } ); + } + + // Finds (and possibly interpolates) the value for the specified year. + function interpolateValues(values, year) { + var i = bisect.left(values, year, 0, values.length - 1), + a = values[i]; + if (i > 0) { + var b = values[i - 1], + t = (year - a[0]) / (b[0] - a[0]); + return a[1] * (1 - t) + b[1] * t; + } + return a[1]; + } + } ); +} + +// Test for d3.functor +function functorTest () { + var f = d3.functor(10); + var g = d3.functor(function (v) { return v; }); + + return f(10) === g(10); +} + +// Test for d3.Nest +// Most test adopted from: https://github.com/mbostock/d3/blob/master/test/arrays/nest-test.js +function nestTest () { + var data = [ + { + a: 10, + b: [ 1, 2 ] + }, + { + a: 20, + b: [ 2, 3 ] + }, + { + a: 30, + b: [ 1, 2 ] + } + ]; + + var n1 = d3.nest() + .key(function (d) { return d.a; }) + .sortKeys(d3.descending) + .rollup(function (vals) { + return d3.sum(vals); + }); + n1.map(data); + n1.entries(data); + + var n2 = d3.nest() + .key(function (d) { return d.a; }) + .sortValues(function (x1, x2) { + return x1[0] < x1[1] ? -1 : (x1[0] > x1[0] ? 1 : 0); }); + n2.map(data); + n2.entries(data); + + // Tests adopted from d3's tests. + var keys = d3.nest() + .key(function(d) { return d.foo; }) + .entries([{foo: 1}, {foo: 1}, {foo: 2}]) + .map(function(d) { return d.key; }) + .sort(d3.ascending); + + var entries = d3.nest() + .key(function(d) { return d.foo; }) + .entries([{foo: 1, bar: 0}, {foo: 2}, {foo: 1, bar: 1}]); + + keys = d3.nest() + .key(function(d) { return d.foo; }).sortKeys(d3.descending) + .entries([{foo: 1}, {foo: 1}, {foo: 2}]) + .map(function(d) { return d.key; }); + + entries = d3.nest() + .key(function(d) { return d.foo; }) + .sortValues(function(a, b) { return a.bar - b.bar; }) + .entries([{foo: 1, bar: 2}, {foo: 1, bar: 0}, {foo: 1, bar: 1}, {foo: 2}]); + + entries = d3.nest() + .key(function(d) { return d.foo; }) + .rollup(function(values) { return d3.sum(values, function(d) { return d.bar; }); }) + .entries([{foo: 1, bar: 2}, {foo: 1, bar: 0}, {foo: 1, bar: 1}, {foo: 2}]); + + entries = d3.nest() + .key(function(d) { return d[0]; }).sortKeys(d3.ascending) + .key(function(d) { return d[1]; }).sortKeys(d3.ascending) + .entries([[0, 1], [0, 2], [1, 1], [1, 2], [0, 2]]); + + entries = d3.nest() + .key(function(d) { return d[0]; }).sortKeys(d3.ascending) + .key(function(d) { return d[1]; }).sortKeys(d3.ascending) + .rollup(function(values) { return values.length; }) + .entries([[0, 1], [0, 2], [1, 1], [1, 2], [0, 2]]); + + entries = d3.nest() + .key(function(d) { return d[0]; }).sortKeys(d3.ascending) + .key(function(d) { return d[1]; }).sortKeys(d3.ascending) + .sortValues(function(a, b) { return a[2] - b[2]; }) + .entries([[0, 1], [0, 2, 1], [1, 1], [1, 2], [0, 2, 0]]); + + var map = d3.nest() + .key(function(d) { return d[0]; }).sortKeys(d3.ascending) + .key(function(d) { return d[1]; }).sortKeys(d3.ascending) + .sortValues(function(a, b) { return a[2] - b[2]; }) + .map([[0, 1], [0, 2, 1], [1, 1], [1, 2], [0, 2, 0]]); +} + +// Test for setting attributes as an object +// From https://github.com/mbostock/d3/blob/master/test/selection/attr-test.js +function attrObjTest () { + d3.select('body') + .data(["orange"]) + .attr({"xlink:href": function(d, i) { return d + "-" + i + ".png"; }}); +} + +// Test for setting styles as an object +// From https://github.com/mbostock/d3/blob/master/test/selection/style-test.js +function styleObjTest () { + d3.select('body') + .style({"background-color": "white", opacity: .42}); +} + +// Test for setting styles as an object +// From https://github.com/mbostock/d3/blob/master/test/selection/property-test.js +function propertyObjTest () { + d3.select('body') + .property({bgcolor: "purple", opacity: .41}); +} + + +// Test for brushes +function brushTest() { + var xScale = d3.scale.linear(), + yScale = d3.scale.linear(); + + var xMin = 0, xMax = 1, + yMin = 0, yMax = 1; + + // Setting only x scale. + var brush1 = d3.svg.brush() + .x(xScale) + .on('brush', function () { + var extent = brush1.extent(); + xMin = Math.max(extent[0], 0); + xMax = Math.min(extent[1], 1); + brush1.extent([xMin, xMax]); + }); + + // Setting both the x and y scale + var brush2 = d3.svg.brush() + .x(xScale) + .y(yScale) + .on('brush', function () { + var extent = brush2.extent(); + var xExtent = extent[0], + yExtent = extent[1]; + + xMin = Math.max(xExtent[0], 0); + xMax = Math.min(xExtent[1], 1); + + yMin = Math.max(yExtent[0], 0); + yMax = Math.min(yExtent[1], 1); + + brush1.extent([[xMin, xMax], [yMin, yMax]]); + }); +} + + +// Tests for area +// Adopted from: https://github.com/mbostock/d3/blob/master/test/svg/area-test.js +function svgAreaTest () { + var a = d3.svg.area(); + + a.x()([0, 1]); + a.x()([0, 1], 1); + a.x(0); + a.x(function (d) { return d.x * 10; }); + a.x(function (d, i) { return i * 10; }); + + a.x0()([0, 1]); + a.x0()([0, 1], 1); + a.x0(0); + a.x0(function (d) { return d.x * 10; }); + a.x0(function (d, i) { return i * 10; }); + + a.x1()([0, 1]); + a.x1()([0, 1], 1); + a.x1(0); + a.x1(function (d) { return d.x * 10; }); + a.x1(function (d, i) { return i * 10; }); + + a.y()([0, 1]); + a.y()([0, 1], 1); + a.y(0); + a.y(function (d) { return d.x * 10; }); + a.y(function (d, i) { return i * 10; }); + + a.y0()([0, 1]); + a.y0()([0, 1], 1); + a.y0(0); + a.y0(function (d) { return d.x * 10; }); + a.y0(function (d, i) { return i * 10; }); + + a.y1()([0, 1]); + a.y1()([0, 1], 1); + a.y1(0); + a.y1(function (d) { return d.x * 10; }); + a.y1(function (d, i) { return i * 10; }); +} + +// Tests for areaRadial +// Adopted from: https://github.com/mbostock/d3/blob/master/test/svg/area-radial-test.js +function svgAreaRadialTest () { + var a = d3.svg.area.radial(); + + a.x()([0, 1]); + a.x()([0, 1], 1); + a.x(0); + a.x(function (d) { return d.x * 10; }); + a.x(function (d, i) { return i * 10; }); + + a.x0()([0, 1]); + a.x0()([0, 1], 1); + a.x0(0); + a.x0(function (d) { return d.x * 10; }); + a.x0(function (d, i) { return i * 10; }); + + a.x1()([0, 1]); + a.x1()([0, 1], 1); + a.x1(0); + a.x1(function (d) { return d.x * 10; }); + a.x1(function (d, i) { return i * 10; }); + + a.y()([0, 1]); + a.y()([0, 1], 1); + a.y(0); + a.y(function (d) { return d.x * 10; }); + a.y(function (d, i) { return i * 10; }); + + a.y0()([0, 1]); + a.y0()([0, 1], 1); + a.y0(0); + a.y0(function (d) { return d.x * 10; }); + a.y0(function (d, i) { return i * 10; }); + + a.y1()([0, 1]); + a.y1()([0, 1], 1); + a.y1(0); + a.y1(function (d) { return d.x * 10; }); + a.y1(function (d, i) { return i * 10; }); + + a.radius(function () { return 10; }); + a.radius(function (d) { return d.x * 10; }); + a.radius(function (d, i) { return i * 10; }); + + a.innerRadius(function () { return 10; }); + a.innerRadius(function (d) { return d.x * 10; }); + a.innerRadius(function (d, i) { return i * 10; }); + + a.outerRadius(function () { return 10; }); + a.outerRadius(function (d) { return d.x * 10; }); + a.outerRadius(function (d, i) { return i * 10; }); + + a.angle(function () { return 10; }); + a.angle(function (d) { return d.x * 10; }); + a.angle(function (d, i) { return i * 10; }); + + a.startAngle(function () { return 10; }); + a.startAngle(function (d) { return d.x * 10; }); + a.startAngle(function (d, i) { return i * 10; }); + + a.endAngle(function () { return 10; }); + a.endAngle(function (d) { return d.x * 10; }); + a.endAngle(function (d, i) { return i * 10; }); +} + +// Tests for d3.svg.line +// Adopted from: https://github.com/mbostock/d3/blob/master/test/svg/line-test.js +function svgLineTest () { + var l = d3.svg.line(); + + l.x()([0, 1]); + l.x()([0, 1], 0); + l.x(0); + l.x(function (d) { return d.x; }); + l.x(function (d, i) { return i; }); + + l.y()([0, 1]); + l.y()([0, 1], 0); + l.y(0); + l.y(function (d) { return d.y; }); + l.y(function (d, i) { return i; }); +} + +// Tests for d3.svg.line.radial +// Adopted from: https://github.com/mbostock/d3/blob/master/test/svg/line-radial-test.js +function svgLineRadialTest () { + var l = d3.svg.line.radial(); + + l.x()([0, 1]); + l.x()([0, 1], 0); + l.x(0); + l.x(function (d) { return d.x; }); + l.x(function (d, i) { return i; }); + + l.y()([0, 1]); + l.y()([0, 1], 0); + l.y(0); + l.y(function (d) { return d.y; }); + l.y(function (d, i) { return i; }); + + l.radius()([0, 1]); + l.radius()([0, 1], 0); + l.radius(0); + l.radius(function (d) { return d.x; }); + l.radius(function (d, i) { return i; }); + + l.angle()([0, 1]); + l.angle()([0, 1], 0); + l.angle(0); + l.angle(function (d) { return d.y; }); + l.angle(function (d, i) { return i; }); +} + +// Tests for d3.svg.arc +// Adopted from: https://github.com/mbostock/d3/blob/master/test/svg/arc-test.js +function svgArcTest () { + var l = d3.svg.arc(); + + l.innerRadius()([0, 1]); + l.innerRadius()([0, 1], 0); + l.innerRadius(0); + l.innerRadius(function (d) { return d.x; }); + l.innerRadius(function (d, i) { return i; }); + + l.outerRadius()([0, 1]); + l.outerRadius()([0, 1], 0); + l.outerRadius(0); + l.outerRadius(function (d) { return d.x; }); + l.outerRadius(function (d, i) { return i; }); + + l.startAngle()([0, 1]); + l.startAngle()([0, 1], 0); + l.startAngle(0); + l.startAngle(function (d) { return d.x; }); + l.startAngle(function (d, i) { return i; }); + + l.endAngle()([0, 1]); + l.endAngle()([0, 1], 0); + l.endAngle(0); + l.endAngle(function (d) { return d.x; }); + l.endAngle(function (d, i) { return i; }); +} + +// Tests for d3.svg.diagonal +// Adopted from: https://github.com/mbostock/d3/blob/master/test/svg/diagonal-test.js +function svgDiagonalTest () { + var d = d3.svg.diagonal(); + + d.projection()({ x: 0, y: 1}); + d.projection()({ x: 0, y: 1}, 0); + d.projection(function (d) { return [d.x, d.y]; }); + d.projection(function (d, i) { return [i, i + 1]; }); + + d.source()({x: 0, y: 1}); + d.source()({x: 0, y: 1}, 0); + d.source({x: 0, y: 1}); + d.source(function (d) { return {x: d.x, y: d.y}; }); + d.source(function (d, i) { return {x: d.x * i, y: d.y * i}; }); + + d.target()({x: 0, y: 1}); + d.target()({x: 0, y: 1}, 0); + d.target({x: 0, y: 1}); + d.target(function (d) { return {x: d.x, y: d.y}; }); + d.target(function (d, i) { return {x: d.x * i, y: d.y * i}; }); +} + +// Tests for d3.extent +// Adopted from: https://github.com/mbostock/d3/blob/master/test/arrays/extent-test.js +function extentTest() { + var o = { valueOf: function () { return NaN; } }; + d3.extent([1]); + d3.extent([5, 1, 2, 3, 4]); + d3.extent([20, 3]); + d3.extent([3, 20]); + d3.extent(["c", "a", "b"]); + d3.extent(["20", "3"]); + d3.extent(["3", "20"]); + d3.extent([NaN, 1, 2, 3, 4, 5]); + d3.extent([o, 1, 2, 3, 4, 5]); + d3.extent([1, 2, 3, 4, 5, NaN]); + d3.extent([1, 2, 3, 4, 5, o]); + d3.extent([10, null, 3, undefined, 5, NaN]); + d3.extent([-1, null, -3, undefined, -5, NaN]); + d3.extent([20, "3"]); + d3.extent(["20", 3]); + d3.extent([3, "20"]); + d3.extent(["3", 20]); + + d3.extent([1], (d) => { return d; }); + d3.extent([5, 1, 2, 3, 4], (d) => { return d; }); + d3.extent([20, 3], (d) => { return d; }); + d3.extent([3, 20], (d) => { return d; }); + d3.extent(["c", "a", "b"], (d) => { return d; }); + d3.extent(["20", "3"], (d) => { return d; }); + d3.extent(["3", "20"], (d) => { return d; }); + d3.extent([NaN, 1, 2, 3, 4, 5], (d) => { return d; }); + d3.extent([o, 1, 2, 3, 4, 5], (d) => { return d; }); + d3.extent([1, 2, 3, 4, 5, NaN], (d) => { return d; }); + d3.extent([1, 2, 3, 4, 5, o], (d) => { return d; }); + d3.extent([10, null, 3, undefined, 5, NaN], (d) => { return d; }); + d3.extent([-1, null, -3, undefined, -5, NaN], (d) => { return d; }); + d3.extent([20, "3"], (d) => { return d; }); + d3.extent(["20", 3], (d) => { return d; }); + d3.extent([3, "20"], (d) => { return d; }); + d3.extent(["3", 20], (d) => { return d; }); +} + +// Tests for d3.time.format.multi +// Adopted from http://bl.ocks.org/mbostock/4149176 +function multiTest() { + var customTimeFormat = d3.time.format.multi([ + [".%L", function(d) { return d.getMilliseconds(); }], + [":%S", function(d) { return d.getSeconds(); }], + ["%I:%M", function(d) { return d.getMinutes(); }], + ["%I %p", function(d) { return d.getHours(); }], + ["%a %d", function(d) { return d.getDay() && d.getDate() != 1; }], + ["%b %d", function(d) { return d.getDate() != 1; }], + ["%B", function(d) { return d.getMonth(); }], + ["%Y", function() { return true; }] + ]); + + var margin = {top: 250, right: 40, bottom: 250, left: 40}, + width = 960 - margin.left - margin.right, + height = 500 - margin.top - margin.bottom; + + var x = d3.time.scale() + .domain([new Date(2012, 0, 1), new Date(2013, 0, 1)]) + .range([0, width]); + + var xAxis = d3.svg.axis() + .scale(x) + .tickFormat(customTimeFormat); + + var svg = d3.select("body").append("svg") + .attr("width", width + margin.left + margin.right) + .attr("height", height + margin.top + margin.bottom) + .append("g") + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + + svg.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height + ")") + .call(xAxis); +} \ No newline at end of file diff --git a/zeppelin-web/app/external/DefinitelyTyped/d3/d3-tests.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/d3/d3-tests.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/d3/d3-tests.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/d3/d3.d.ts b/zeppelin-web/app/external/DefinitelyTyped/d3/d3.d.ts new file mode 100644 index 00000000..15b1375f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/d3/d3.d.ts @@ -0,0 +1,3398 @@ +// Type definitions for d3JS +// Project: http://d3js.org/ +// Definitions by: Boris Yankov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module D3 { + export interface Selectors { + /** + * Select an element from the current document + */ + select: { + /** + * Returns the empty selection + */ + (): Selection; + /** + * Selects the first element that matches the specified selector string + * + * @param selector Selection String to match + */ + (selector: string): Selection; + /** + * Selects the specified node + * + * @param element Node element to select + */ + (element: EventTarget): Selection; + }; + + /** + * Select multiple elements from the current document + */ + selectAll: { + /** + * Selects all elements that match the specified selector + * + * @param selector Selection String to match + */ + (selector: string): Selection; + /** + * Selects the specified array of elements + * + * @param elements Array of node elements to select + */ + (elements: EventTarget[]): Selection; + }; + } + + export interface D3Event extends Event{ + dx: number; + dy: number; + clientX: number; + clientY: number; + translate: number[]; + scale: number; + sourceEvent: D3Event; + x: number; + y: number; + keyCode: number; + altKey: any; + type: string; + } + + export interface Base extends Selectors { + /** + * Create a behavior + */ + behavior: Behavior.Behavior; + /** + * Access the current user event for interaction + */ + event: D3Event; + + /** + * Compare two values for sorting. + * Returns -1 if a is less than b, or 1 if a is greater than b, or 0 + * + * @param a First value + * @param b Second value + */ + ascending(a: T, b: T): number; + /** + * Compare two values for sorting. + * Returns -1 if a is greater than b, or 1 if a is less than b, or 0 + * + * @param a First value + * @param b Second value + */ + descending(a: T, b: T): number; + /** + * Find the minimum value in an array + * + * @param arr Array to search + * @param map Accsessor function + */ + min(arr: T[], map: (v?: T, i?: number) => U): U; + /** + * Find the minimum value in an array + * + * @param arr Array to search + */ + min(arr: T[]): T; + /** + * Find the maximum value in an array + * + * @param arr Array to search + * @param map Accsessor function + */ + max(arr: T[], map: (v?: T, i?: number) => U): U; + /** + * Find the maximum value in an array + * + * @param arr Array to search + */ + max(arr: T[]): T; + /** + * Find the minimum and maximum value in an array + * + * @param arr Array to search + * @param map Accsessor function + */ + extent(arr: T[], map: (v: T) => U): U[]; + /** + * Find the minimum and maximum value in an array + * + * @param arr Array to search + */ + extent(arr: T[]): T[]; + /** + * Compute the sum of an array of numbers + * + * @param arr Array to search + * @param map Accsessor function + */ + sum(arr: T[], map: (v: T) => number): number; + /** + * Compute the sum of an array of numbers + * + * @param arr Array to search + */ + sum(arr: number[]): number; + /** + * Compute the arithmetic mean of an array of numbers + * + * @param arr Array to search + * @param map Accsessor function + */ + mean(arr: T[], map: (v: T) => number): number; + /** + * Compute the arithmetic mean of an array of numbers + * + * @param arr Array to search + */ + mean(arr: number[]): number; + /** + * Compute the median of an array of numbers (the 0.5-quantile). + * + * @param arr Array to search + * @param map Accsessor function + */ + median(arr: T[], map: (v: T) => number): number; + /** + * Compute the median of an array of numbers (the 0.5-quantile). + * + * @param arr Array to search + */ + median(arr: number[]): number; + /** + * Compute a quantile for a sorted array of numbers. + * + * @param arr Array to search + * @param p The quantile to return + */ + quantile: (arr: number[], p: number) => number; + /** + * Locate the insertion point for x in array to maintain sorted order + * + * @param arr Array to search + * @param x Value to search for insertion point + * @param low Minimum value of array subset + * @param hihg Maximum value of array subset + */ + bisect(arr: T[], x: T, low?: number, high?: number): number; + /** + * Locate the insertion point for x in array to maintain sorted order + * + * @param arr Array to search + * @param x Value to serch for insertion point + * @param low Minimum value of array subset + * @param high Maximum value of array subset + */ + bisectLeft(arr: T[], x: T, low?: number, high?: number): number; + /** + * Locate the insertion point for x in array to maintain sorted order + * + * @param arr Array to search + * @param x Value to serch for insertion point + * @param low Minimum value of array subset + * @param high Maximum value of array subset + */ + bisectRight(arr: T[], x: T, low?: number, high?: number): number; + /** + * Bisect using an accessor. + * + * @param accessor Accessor function + */ + bisector(accessor: (data: any, index: number) => any): any; + /** + * Randomize the order of an array. + * + * @param arr Array to randomize + */ + shuffle(arr: T[]): T[]; + /** + * Reorder an array of elements according to an array of indexes + * + * @param arr Array to reorder + * @param indexes Array containing the order the elements should be returned in + */ + permute(arr: any[], indexes: any[]): any[]; + /** + * Transpose a variable number of arrays. + * + * @param arrs Arrays to transpose + */ + zip(...arrs: any[]): any[]; + /** + * Parse the given 2D affine transform string, as defined by SVG's transform attribute. + * + * @param definition 2D affine transform string + */ + transform(definition: string): any; + /** + * Transpose an array of arrays. + * + * @param matrix Two dimensional array to transpose + */ + transpose(matrix: any[]): any[]; + /** + * Creates an array containing tuples of adjacent pairs + * + * @param arr An array containing entries to pair + * @returns any[][] An array of 2-element tuples for each pair + */ + pairs(arr: any[]): any[][]; + /** + * List the keys of an associative array. + * + * @param map Array of objects to get the key values from + */ + keys(map: any): string[]; + /** + * List the values of an associative array. + * + * @param map Array of objects to get the values from + */ + values(map: any): any[]; + /** + * List the key-value entries of an associative array. + * + * @param map Array of objects to get the key-value pairs from + */ + entries(map: any): any[]; + /** + * merge multiple arrays into one array + * + * @param map Arrays to merge + */ + merge(...map: any[]): any[]; + /** + * Generate a range of numeric values. + */ + range: { + /** + * Generate a range of numeric values from 0. + * + * @param stop Value to generate the range to + * @param step Step between each value + */ + (stop: number, step?: number): number[]; + /** + * Generate a range of numeric values. + * + * @param start Value to start + * @param stop Value to generate the range to + * @param step Step between each value + */ + (start: number, stop?: number, step?: number): number[]; + }; + /** + * Create new nest operator + */ + nest(): Nest; + /** + * Request a resource using XMLHttpRequest. + */ + xhr: { + /** + * Creates an asynchronous request for specified url + * + * @param url Url to request + * @param callback Function to invoke when resource is loaded or the request fails + */ + (url: string, callback?: (xhr: XMLHttpRequest) => void ): Xhr; + /** + * Creates an asynchronous request for specified url + * + * @param url Url to request + * @param mime MIME type to request + * @param callback Function to invoke when resource is loaded or the request fails + */ + (url: string, mime: string, callback?: (xhr: XMLHttpRequest) => void ): Xhr; + }; + /** + * Request a text file + */ + text: { + /** + * Request a text file + * + * @param url Url to request + * @param callback Function to invoke when resource is loaded or the request fails + */ + (url: string, callback?: (response: string) => void ): Xhr; + /** + * Request a text file + * + * @param url Url to request + * @param mime MIME type to request + * @param callback Function to invoke when resource is loaded or the request fails + */ + (url: string, mime: string, callback?: (response: string) => void ): Xhr; + }; + /** + * Request a JSON blob + * + * @param url Url to request + * @param callback Function to invoke when resource is loaded or the request fails + */ + json: (url: string, callback?: (error: any, data: any) => void ) => Xhr; + /** + * Request an HTML document fragment. + */ + xml: { + /** + * Request an HTML document fragment. + * + * @param url Url to request + * @param callback Function to invoke when resource is loaded or the request fails + */ + (url: string, callback?: (response: Document) => void ): Xhr; + /** + * Request an HTML document fragment. + * + * @param url Url to request + * @param mime MIME type to request + * @param callback Function to invoke when resource is loaded or the request fails + */ + (url: string, mime: string, callback?: (response: Document) => void ): Xhr; + }; + /** + * Request an XML document fragment. + * + * @param url Url to request + * @param callback Function to invoke when resource is loaded or the request fails + */ + html: (url: string, callback?: (response: DocumentFragment) => void ) => Xhr; + /** + * Request a comma-separated values (CSV) file. + */ + csv: Dsv; + /** + * Request a tab-separated values (TSV) file + */ + tsv: Dsv; + /** + * Time Functions + */ + time: Time.Time; + /** + * Scales + */ + scale: Scale.ScaleBase; + /* + * Interpolate two values + */ + interpolate: Transition.BaseInterpolate; + /* + * Interpolate two numbers + */ + interpolateNumber: Transition.BaseInterpolate; + /* + * Interpolate two integers + */ + interpolateRound: Transition.BaseInterpolate; + /* + * Interpolate two strings + */ + interpolateString: Transition.BaseInterpolate; + /* + * Interpolate two RGB colors + */ + interpolateRgb: Transition.BaseInterpolate; + /* + * Interpolate two HSL colors + */ + interpolateHsl: Transition.BaseInterpolate; + /* + * Interpolate two HCL colors + */ + interpolateHcl: Transition.BaseInterpolate; + /* + * Interpolate two L*a*b* colors + */ + interpolateLab: Transition.BaseInterpolate; + /* + * Interpolate two arrays of values + */ + interpolateArray: Transition.BaseInterpolate; + /* + * Interpolate two arbitary objects + */ + interpolateObject: Transition.BaseInterpolate; + /* + * Interpolate two 2D matrix transforms + */ + interpolateTransform: Transition.BaseInterpolate; + /* + * The array of built-in interpolator factories + */ + interpolators: Transition.InterpolateFactory[]; + /** + * Layouts + */ + layout: Layout.Layout; + /** + * Svg's + */ + svg: Svg.Svg; + /** + * Random number generators + */ + random: Random; + /** + * Create a function to format a number as a string + * + * @param specifier The format specifier to use + */ + format(specifier: string): (value: number) => string; + /** + * Returns the SI prefix for the specified value at the specified precision + */ + formatPrefix(value: number, precision?: number): MetricPrefix; + /** + * The version of the d3 library + */ + version: string; + /** + * Returns the root selection + */ + selection(): Selection; + ns: { + /** + * The map of registered namespace prefixes + */ + prefix: { + svg: string; + xhtml: string; + xlink: string; + xml: string; + xmlns: string; + }; + /** + * Qualifies the specified name + */ + qualify(name: string): { space: string; local: string; }; + }; + /** + * Returns a built-in easing function of the specified type + */ + ease: (type: string, ...arrs: any[]) => D3.Transition.Transition; + /** + * Constructs a new RGB color. + */ + rgb: { + /** + * Constructs a new RGB color with the specified r, g and b channel values + */ + (r: number, g: number, b: number): D3.Color.RGBColor; + /** + * Constructs a new RGB color by parsing the specified color string + */ + (color: string): D3.Color.RGBColor; + }; + /** + * Constructs a new HCL color. + */ + hcl: { + /** + * Constructs a new HCL color. + */ + (h: number, c: number, l: number): Color.HCLColor; + /** + * Constructs a new HCL color by parsing the specified color string + */ + (color: string): Color.HCLColor; + }; + /** + * Constructs a new HSL color. + */ + hsl: { + /** + * Constructs a new HSL color with the specified hue h, saturation s and lightness l + */ + (h: number, s: number, l: number): Color.HSLColor; + /** + * Constructs a new HSL color by parsing the specified color string + */ + (color: string): Color.HSLColor; + }; + /** + * Constructs a new RGB color. + */ + lab: { + /** + * Constructs a new LAB color. + */ + (l: number, a: number, b: number): Color.LABColor; + /** + * Constructs a new LAB color by parsing the specified color string + */ + (color: string): Color.LABColor; + }; + geo: Geo.Geo; + geom: Geom.Geom; + /** + * gets the mouse position relative to a specified container. + */ + mouse(container: any): number[]; + /** + * gets the touch positions relative to a specified container. + */ + touches(container: any): number[][]; + + /** + * If the specified value is a function, returns the specified value. + * Otherwise, returns a function that returns the specified value. + */ + functor(value: (p : R) => T): (p : R) => T; + functor(value: T): (p : any) => T; + + map(): Map; + set(): Set; + map(object: {[key: string]: T; }): Map; + set(array: T[]): Set; + dispatch(...types: string[]): Dispatch; + rebind(target: any, source: any, ...names: any[]): any; + requote(str: string): string; + timer: { + (funct: () => boolean, delay?: number, mark?: number): void; + flush(): void; + } + transition(): Transition.Transition; + + round(x: number, n: number): number; + } + + export interface Dispatch { + [event: string]: any; + on: { + (type: string): any; + (type: string, listener: any): any; + } + } + + export interface MetricPrefix { + /** + * the scale function, for converting numbers to the appropriate prefixed scale. + */ + scale: (d: number) => number; + /** + * the prefix symbol + */ + symbol: string; + } + + export interface Xhr { + /** + * Get or set request header + */ + header: { + /** + * Get the value of specified request header + * + * @param name Name of header to get the value for + */ + (name: string): string; + /** + * Set the value of specified request header + * + * @param name Name of header to set the value for + * @param value Value to set the header to + */ + (name: string, value: string): Xhr; + }; + /** + * Get or set MIME Type + */ + mimeType: { + /** + * Get the current MIME Type + */ + (): string; + /** + * Set the MIME Type for the request + * + * @param type The MIME type for the request + */ + (type: string): Xhr; + }; + /* + * Get or Set the function used to map the response to the associated data value + */ + response: { + /** + * Get function used to map the response to the associated data value + */ + (): (xhr: XMLHttpRequest) => any; + /** + * Set function used to map the response to the associated data value + * + * @param value The function used to map the response to a data value + */ + (value: (xhr: XMLHttpRequest) => any): Xhr; + }; + /** + * Issue the request using the GET method + * + * @param callback Function to invoke on completion of request + */ + get(callback?: (xhr: XMLHttpRequest) => void ): Xhr; + /** + * Issue the request using the POST method + */ + post: { + /** + * Issue the request using the POST method + * + * @param callback Function to invoke on completion of request + */ + (callback?: (xhr: XMLHttpRequest) => void ): Xhr; + /** + * Issue the request using the POST method + * + * @param data Data to post back in the request + * @param callback Function to invoke on completion of request + */ + (data: any, callback?: (xhr: XMLHttpRequest) => void ): Xhr; + }; + /** + * Issues this request using the specified method + */ + send: { + /** + * Issues this request using the specified method + * + * @param method Method to use to make the request + * @param callback Function to invoke on completion of request + */ + (method: string, callback?: (xhr: XMLHttpRequest) => void ): Xhr; + /** + * Issues this request using the specified method + * + * @param method Method to use to make the request + * @param data Data to post back in the request + * @param callback Function to invoke on completion of request + */ + (method: string, data: any, callback?: (xhr: XMLHttpRequest) => void ): Xhr; + }; + /** + * Aborts this request, if it is currently in-flight + */ + abort(): Xhr; + /** + * Registers a listener to receive events + * + * @param type Enent name to attach the listener to + * @param listener Function to attach to event + */ + on: (type: string, listener: (data: any, index?: number) => any) => Xhr; + } + + export interface Dsv { + /** + * Request a delimited values file + * + * @param url Url to request + * @param callback Function to invoke when resource is loaded or the request fails + */ + (url: string, callback?: (error: any, response: any[]) => void ): Xhr; + /** + * Parse a delimited string into objects using the header row. + * + * @param string delimited formatted string to parse + */ + parse(string: string): any[]; + /** + * Parse a delimited string into tuples, ignoring the header row. + * + * @param string delimited formatted string to parse + */ + parseRows(string: string, accessor: (row: any[], index: number) => any): any; + /** + * Format an array of tuples into a delimited string. + * + * @param rows Array to convert to a delimited string + */ + format(rows: any[]): string; + } + + export interface Selection extends Selectors, Array { + attr: { + (name: string): string; + (name: string, value: any): Selection; + (name: string, valueFunction: (data: any, index: number) => any): Selection; + (attrValueMap : Object): Selection; + }; + + classed: { + (name: string): string; + (name: string, value: any): Selection; + (name: string, valueFunction: (data: any, index: number) => any): Selection; + (classValueMap: Object): Selection; + }; + + style: { + (name: string): string; + (name: string, value: any, priority?: string): Selection; + (name: string, valueFunction: (data: any, index: number) => any, priority?: string): Selection; + (styleValueMap : Object): Selection; + }; + + property: { + (name: string): void; + (name: string, value: any): Selection; + (name: string, valueFunction: (data: any, index: number) => any): Selection; + (propertyValueMap : Object): Selection; + }; + + text: { + (): string; + (value: any): Selection; + (valueFunction: (data: any, index: number) => any): Selection; + }; + + html: { + (): string; + (value: any): Selection; + (valueFunction: (data: any, index: number) => any): Selection; + }; + + append: (name: string) => Selection; + insert: (name: string, before: string) => Selection; + remove: () => Selection; + empty: () => boolean; + + data: { + (values: (data: any, index?: number) => any[], key?: (data: any, index?: number) => any): UpdateSelection; + (values: any[], key?: (data: any, index?: number) => any): UpdateSelection; + (): any[]; + }; + + datum: { + (values: (data: any, index: number) => any): UpdateSelection; + (values: any): UpdateSelection; + () : any; + }; + + filter: { + (filter: (data: any, index: number) => boolean, thisArg?: any): UpdateSelection; + //(filter: string): UpdateSelection; + }; + + call(callback: (selection: Selection, ...args: any[]) => void, ...args: any[]): Selection; + each(eachFunction: (data: any, index: number) => any): Selection; + on: { + (type: string): (data: any, index: number) => any; + (type: string, listener: (data: any, index: number) => any, capture?: boolean): Selection; + }; + + /** + * Returns the total number of elements in the current selection. + */ + size(): number; + + /** + * Starts a transition for the current selection. Transitions behave much like selections, + * except operators animate smoothly over time rather than applying instantaneously. + */ + transition(): Transition.Transition; + + /** + * Sorts the elements in the current selection according to the specified comparator + * function. + * + * @param comparator a comparison function, which will be passed two data elements a and b + * to compare, and should return either a negative, positive, or zero value to indicate + * their relative order. + */ + sort(comparator?: (a: T, b: T) => number): Selection; + + /** + * Re-inserts elements into the document such that the document order matches the selection + * order. This is equivalent to calling sort() if the data is already sorted, but much + * faster. + */ + order: () => Selection; + + /** + * Returns the first non-null element in the current selection. If the selection is empty, + * returns null. + */ + node: () => T; + } + + export interface EnterSelection { + append: (name: string) => Selection; + insert: (name: string, before?: string) => Selection; + select: (selector: string) => Selection; + empty: () => boolean; + node: () => Element; + call: (callback: (selection: EnterSelection) => void) => EnterSelection; + size: () => number; + } + + export interface UpdateSelection extends Selection { + enter: () => EnterSelection; + update: () => Selection; + exit: () => Selection; + } + + export interface NestKeyValue { + key: string; + values: any; + } + + export interface Nest { + key(keyFunction: (data: any, index: number) => string): Nest; + sortKeys(comparator: (d1: any, d2: any) => number): Nest; + sortValues(comparator: (d1: any, d2: any) => number): Nest; + rollup(rollupFunction: (data: any, index: number) => any): Nest; + map(values: any[]): any; + entries(values: any[]): NestKeyValue[]; + } + + export interface MapKeyValue { + key: string; + value: T; + } + + export interface Map { + has(key: string): boolean; + get(key: string): T; + set(key: string, value: T): T; + remove(key: string): boolean; + keys(): string[]; + values(): T[]; + entries(): MapKeyValue[]; + forEach(func: (key: string, value: T) => void ): void; + empty(): boolean; + size(): number; + } + + export interface Set { + has(value: T): boolean; + add(value: T): T; + remove(value: T): boolean; + values(): string[]; + forEach(func: (value: string) => void ): void; + empty(): boolean; + size(): number; + } + + export interface Random { + /** + * Returns a function for generating random numbers with a normal distribution + * + * @param mean The expected value of the generated pseudorandom numbers + * @param deviation The given standard deviation + */ + normal(mean?: number, deviation?: number): () => number; + /** + * Returns a function for generating random numbers with a log-normal distribution + * + * @param mean The expected value of the generated pseudorandom numbers + * @param deviation The given standard deviation + */ + logNormal(mean?: number, deviation?: number): () => number; + /** + * Returns a function for generating random numbers with an Irwin-Hall distribution + * + * @param count The number of independent variables + */ + irwinHall(count: number): () => number; + } + + // Transitions + export module Transition { + export interface Transition { + duration: { + (duration: number): Transition; + (duration: (data: any, index: number) => any): Transition; + }; + delay: { + (delay: number): Transition; + (delay: (data: any, index: number) => any): Transition; + }; + attr: { + (name: string): string; + (name: string, value: any): Transition; + (name: string, valueFunction: (data: any, index: number) => any): Transition; + (attrValueMap : any): Transition; + }; + style: { + (name: string): string; + (name: string, value: any, priority?: string): Transition; + (name: string, valueFunction: (data: any, index: number) => any, priority?: string): Transition; + }; + call(callback: (transition: Transition, ...args: any[]) => void, ...args: any[]): Transition; + /** + * Select an element from the current document + */ + select: { + /** + * Selects the first element that matches the specified selector string + * + * @param selector Selection String to match + */ + (selector: string): Transition; + /** + * Selects the specified node + * + * @param element Node element to select + */ + (element: EventTarget): Transition; + }; + + /** + * Select multiple elements from the current document + */ + selectAll: { + /** + * Selects all elements that match the specified selector + * + * @param selector Selection String to match + */ + (selector: string): Transition; + /** + * Selects the specified array of elements + * + * @param elements Array of node elements to select + */ + (elements: EventTarget[]): Transition; + } + each: (type?: string, eachFunction?: (data: any, index: number) => any) => Transition; + transition: () => Transition; + ease: (value: string, ...arrs: any[]) => Transition; + attrTween(name: string, tween: (d: any, i: number, a: any) => BaseInterpolate): Transition; + styleTween(name: string, tween: (d: any, i: number, a: any) => BaseInterpolate, priority?: string): Transition; + text: { + (text: string): Transition; + (text: (d: any, i: number) => string): Transition; + } + tween(name: string, factory: InterpolateFactory): Transition; + filter: { + (selector: string): Transition; + (selector: (data: any, index: number) => boolean): Transition; + }; + remove(): Transition; + } + + export interface InterpolateFactory { + (a?: any, b?: any): BaseInterpolate; + } + + export interface BaseInterpolate { + (a: any, b?: any): any; + } + + export interface Interpolate { + (t: any): any; + } + } + + //Time + export module Time { + export interface Time { + second: Interval; + minute: Interval; + hour: Interval; + day: Interval; + week: Interval; + sunday: Interval; + monday: Interval; + tuesday: Interval; + wednesday: Interval; + thursday: Interval; + friday: Interval; + saturday: Interval; + month: Interval; + year: Interval; + + seconds: Range; + minutes: Range; + hours: Range; + days: Range; + weeks: Range; + months: Range; + years: Range; + + sundays: Range; + mondays: Range; + tuesdays: Range; + wednesdays: Range; + thursdays: Range; + fridays: Range; + saturdays: Range; + format: { + /** + * Constructs a new local time formatter using the given specifier. + */ + (specifier: string): TimeFormat; + /** + * Returns a new multi-resolution time format given the specified array of predicated formats. + */ + multi: (formats: any[][]) => TimeFormat; + + utc: { + /** + * Constructs a new local time formatter using the given specifier. + */ + (specifier: string): TimeFormat; + /** + * Returns a new multi-resolution UTC time format given the specified array of predicated formats. + */ + multi: (formats: any[][]) => TimeFormat; + }; + + /** + * The full ISO 8601 UTC time format: "%Y-%m-%dT%H:%M:%S.%LZ". + */ + iso: TimeFormat; + }; + + scale: { + /** + * Constructs a new time scale with the default domain and range; + * the ticks and tick format are configured for local time. + */ + (): Scale.TimeScale; + /** + * Constructs a new time scale with the default domain and range; + * the ticks and tick format are configured for UTC time. + */ + utc(): Scale.TimeScale; + }; + } + + export interface Range { + (start: Date, end: Date, step?: number): Date[]; + } + + export interface Interval { + (date: Date): Date; + floor: (date: Date) => Date; + round: (date: Date) => Date; + ceil: (date: Date) => Date; + range: Range; + offset: (date: Date, step: number) => Date; + utc?: Interval; + } + + export interface TimeFormat { + (date: Date): string; + parse: (string: string) => Date; + } + } + + // Layout + export module Layout { + export interface Layout { + /** + * Creates a new Stack layout + */ + stack(): StackLayout; + /** + * Creates a new pie layout + */ + pie(): PieLayout; + /** + * Creates a new force layout + */ + force(): ForceLayout; + /** + * Creates a new tree layout + */ + tree(): TreeLayout; + bundle(): BundleLayout; + chord(): ChordLayout; + cluster(): ClusterLayout; + hierarchy(): HierarchyLayout; + histogram(): HistogramLayout; + pack(): PackLayout; + partition(): PartitionLayout; + treemap(): TreeMapLayout; + } + + export interface StackLayout { + (layers: T[], index?: number): T[]; + values(accessor?: (d: any) => any): StackLayout; + offset(offset: string): StackLayout; + x(accessor: (d: any, i: number) => any): StackLayout; + y(accessor: (d: any, i: number) => any): StackLayout; + out(setter: (d: any, y0: number, y: number) => void): StackLayout; + } + + export interface TreeLayout { + /** + * Gets or sets the sort order of sibling nodes for the layout using the specified comparator function + */ + sort: { + /** + * Gets the sort order function of sibling nodes for the layout + */ + (): (d1: any, d2: any) => number; + /** + * Sets the sort order of sibling nodes for the layout using the specified comparator function + */ + (comparator: (d1: any, d2: any) => number): TreeLayout; + }; + /** + * Gets or sets the specified children accessor function + */ + children: { + /** + * Gets the children accessor function + */ + (): (d: any) => any; + /** + * Sets the specified children accessor function + */ + (children: (d: any) => any): TreeLayout; + }; + /** + * Runs the tree layout + */ + nodes(root: GraphNode): GraphNode[]; + /** + * Given the specified array of nodes, such as those returned by nodes, returns an array of objects representing the links from parent to child for each node + */ + links(nodes: GraphNode[]): GraphLink[]; + /** + * If separation is specified, uses the specified function to compute separation between neighboring nodes. If separation is not specified, returns the current separation function + */ + separation: { + /** + * Gets the current separation function + */ + (): (a: GraphNode, b: GraphNode) => number; + /** + * Sets the specified function to compute separation between neighboring nodes + */ + (separation: (a: GraphNode, b: GraphNode) => number): TreeLayout; + }; + /** + * Gets or sets the available layout size + */ + size: { + /** + * Gets the available layout size + */ + (): number[]; + /** + * Sets the available layout size + */ + (size: number[]): TreeLayout; + }; + /** + * Gets or sets the available node size + */ + nodeSize: { + /** + * Gets the available node size + */ + (): number[]; + /** + * Sets the available node size + */ + (size: number[]): TreeLayout; + }; + } + + export interface PieLayout { + (values: any[], index?: number): ArcDescriptor[]; + value: { + (): (d: any, index: number) => number; + (accessor: (d: any, index: number) => number): PieLayout; + }; + sort: { + (): (d1: any, d2: any) => number; + (comparator: (d1: any, d2: any) => number): PieLayout; + }; + startAngle: { + (): number; + (angle: number): PieLayout; + (angle: () => number): PieLayout; + (angle: (d : any) => number): PieLayout; + (angle: (d : any, i: number) => number): PieLayout; + }; + endAngle: { + (): number; + (angle: number): PieLayout; + (angle: () => number): PieLayout; + (angle: (d : any) => number): PieLayout + (angle: (d : any, i: number) => number): PieLayout; + }; + } + + export interface ArcDescriptor { + value: any; + data: any; + startAngle: number; + endAngle: number; + index: number; + } + + export interface GraphNode { + id: number; + index: number; + name: string; + px: number; + py: number; + size: number; + weight: number; + x: number; + y: number; + subindex: number; + startAngle: number; + endAngle: number; + value: number; + fixed: boolean; + children: GraphNode[]; + _children: GraphNode[]; + parent: GraphNode; + depth: number; + } + + export interface GraphLink { + source: GraphNode; + target: GraphNode; + } + + export interface GraphNodeForce { + index?: number; + x?: number; + y?: number; + px?: number; + py?: number; + fixed?: boolean; + weight?: number; + } + + export interface GraphLinkForce { + source: GraphNodeForce; + target: GraphNodeForce; + } + + export interface ForceLayout { + (): ForceLayout; + size: { + (): number; + (mysize: number[]): ForceLayout; + (accessor: (d: any, index: number) => {}): ForceLayout; + + }; + linkDistance: { + (): number; + (number:number): ForceLayout; + (accessor: (d: any, index: number) => number): ForceLayout; + }; + linkStrength: + { + (): number; + (number:number): ForceLayout; + (accessor: (d: any, index: number) => number): ForceLayout; + }; + friction: + { + (): number; + (number:number): ForceLayout; + (accessor: (d: any, index: number) => number): ForceLayout; + }; + alpha: { + (): number; + (number:number): ForceLayout; + (accessor: (d: any, index: number) => number): ForceLayout; + }; + charge: { + (): number; + (number:number): ForceLayout; + (accessor: (d: any, index: number) => number): ForceLayout; + }; + + theta: { + (): number; + (number:number): ForceLayout; + (accessor: (d: any, index: number) => number): ForceLayout; + }; + + gravity: { + (): number; + (number:number): ForceLayout; + (accessor: (d: any, index: number) => number): ForceLayout; + }; + + links: { + (): GraphLinkForce[]; + (arLinks: GraphLinkForce[]): ForceLayout; + + }; + nodes: + { + (): GraphNodeForce[]; + (arNodes: GraphNodeForce[]): ForceLayout; + + }; + start(): ForceLayout; + resume(): ForceLayout; + stop(): ForceLayout; + tick(): ForceLayout; + on(type: string, listener: () => void ): ForceLayout; + drag(): ForceLayout; + } + + export interface BundleLayout{ + (links: GraphLink[]): GraphNode[][]; + } + + export interface ChordLayout { + matrix: { + (): number[][]; + (matrix: number[][]): ChordLayout; + } + padding: { + (): number; + (padding: number): ChordLayout; + } + sortGroups: { + (): (a: number, b: number) => number; + (comparator: (a: number, b: number) => number): ChordLayout; + } + sortSubgroups: { + (): (a: number, b: number) => number; + (comparator: (a: number, b: number) => number): ChordLayout; + } + sortChords: { + (): (a: number, b: number) => number; + (comparator: (a: number, b: number) => number): ChordLayout; + } + chords(): GraphLink[]; + groups(): ArcDescriptor[]; + } + + export interface ClusterLayout{ + sort: { + (): (a: GraphNode, b: GraphNode) => number; + (comparator: (a: GraphNode, b: GraphNode) => number): ClusterLayout; + } + children: { + (): (d: any, i?: number) => GraphNode[]; + (children: (d: any, i?: number) => GraphNode[]): ClusterLayout; + } + nodes(root: GraphNode): GraphNode[]; + links(nodes: GraphNode[]): GraphLink[]; + separation: { + (): (a: GraphNode, b: GraphNode) => number; + (separation: (a: GraphNode, b: GraphNode) => number): ClusterLayout; + } + size: { + (): number[]; + (size: number[]): ClusterLayout; + } + value: { + (): (node: GraphNode) => number; + (value: (node: GraphNode) => number): ClusterLayout; + } + } + + export interface HierarchyLayout { + sort: { + (): (a: GraphNode, b: GraphNode) => number; + (comparator: (a: GraphNode, b: GraphNode) => number): HierarchyLayout; + } + children: { + (): (d: any, i?: number) => GraphNode[]; + (children: (d: any, i?: number) => GraphNode[]): HierarchyLayout; + } + nodes(root: GraphNode): GraphNode[]; + links(nodes: GraphNode[]): GraphLink[]; + value: { + (): (node: GraphNode) => number; + (value: (node: GraphNode) => number): HierarchyLayout; + } + reValue(root: GraphNode): HierarchyLayout; + } + + export interface Bin extends Array { + x: number; + dx: number; + y: number; + } + + export interface HistogramLayout { + (values: any[], index?: number): Bin[]; + value: { + (): (value: any) => any; + (accessor: (value: any) => any): HistogramLayout + } + range: { + (): (value: any, index: number) => number[]; + (range: (value: any, index: number) => number[]): HistogramLayout; + (range: number[]): HistogramLayout; + } + bins: { + (): (range: any[], index: number) => number[]; + (bins: (range: any[], index: number) => number[]): HistogramLayout; + (bins: number): HistogramLayout; + (bins: number[]): HistogramLayout; + } + frequency: { + (): boolean; + (frequency: boolean): HistogramLayout; + } + } + + export interface PackLayout { + sort: { + (): (a: GraphNode, b: GraphNode) => number; + (comparator: (a: GraphNode, b: GraphNode) => number): PackLayout; + } + children: { + (): (d: any, i?: number) => GraphNode[]; + (children: (d: any, i?: number) => GraphNode[]): PackLayout; + } + nodes(root: GraphNode): GraphNode[]; + links(nodes: GraphNode[]): GraphLink[]; + value: { + (): (node: GraphNode) => number; + (value: (node: GraphNode) => number): PackLayout; + } + size: { + (): number[]; + (size: number[]): PackLayout; + } + padding: { + (): number; + (padding: number): PackLayout; + } + } + + export interface PartitionLayout { + sort: { + (): (a: GraphNode, b: GraphNode) => number; + (comparator: (a: GraphNode, b: GraphNode) => number): PackLayout; + } + children: { + (): (d: any, i?: number) => GraphNode[]; + (children: (d: any, i?: number) => GraphNode[]): PackLayout; + } + nodes(root: GraphNode): GraphNode[]; + links(nodes: GraphNode[]): GraphLink[]; + value: { + (): (node: GraphNode) => number; + (value: (node: GraphNode) => number): PackLayout; + } + size: { + (): number[]; + (size: number[]): PackLayout; + } + } + + export interface TreeMapLayout { + sort: { + (): (a: GraphNode, b: GraphNode) => number; + (comparator: (a: GraphNode, b: GraphNode) => number): TreeMapLayout; + } + children: { + (): (d: any, i?: number) => GraphNode[]; + (children: (d: any, i?: number) => GraphNode[]): TreeMapLayout; + } + nodes(root: GraphNode): GraphNode[]; + links(nodes: GraphNode[]): GraphLink[]; + value: { + (): (node: GraphNode) => number; + (value: (node: GraphNode) => number): TreeMapLayout; + } + size: { + (): number[]; + (size: number[]): TreeMapLayout; + } + padding: { + (): number; + (padding: number): TreeMapLayout; + } + round: { + (): boolean; + (round: boolean): TreeMapLayout; + } + sticky: { + (): boolean; + (sticky: boolean): TreeMapLayout; + } + mode: { + (): string; + (mode: string): TreeMapLayout; + } + } + } + + // Color + export module Color { + export interface Color { + /** + * increase lightness by some exponential factor (gamma) + */ + brighter(k?: number): Color; + /** + * decrease lightness by some exponential factor (gamma) + */ + darker(k?: number): Color; + /** + * convert the color to a string. + */ + toString(): string; + } + + export interface RGBColor extends Color{ + /** + * the red color channel. + */ + r: number; + /** + * the green color channel. + */ + g: number; + /** + * the blue color channel. + */ + b: number; + /** + * convert from RGB to HSL. + */ + hsl(): HSLColor; + } + + export interface HSLColor extends Color{ + /** + * hue + */ + h: number; + /** + * saturation + */ + s: number; + /** + * lightness + */ + l: number; + /** + * convert from HSL to RGB. + */ + rgb(): RGBColor; + } + + export interface LABColor extends Color{ + /** + * lightness + */ + l: number; + /** + * a-dimension + */ + a: number; + /** + * b-dimension + */ + b: number; + /** + * convert from LAB to RGB. + */ + rgb(): RGBColor; + } + + export interface HCLColor extends Color{ + /** + * hue + */ + h: number; + /** + * chroma + */ + c: number; + /** + * luminance + */ + l: number; + /** + * convert from HCL to RGB. + */ + rgb(): RGBColor; + } + } + + // SVG + export module Svg { + export interface Svg { + /** + * Create a new symbol generator + */ + symbol(): Symbol; + /** + * Create a new axis generator + */ + axis(): Axis; + /** + * Create a new arc generator + */ + arc(): Arc; + /** + * Create a new line generator + */ + line: { + (): Line; + radial(): LineRadial; + } + /** + * Create a new area generator + */ + area: { + (): Area; + radial(): AreaRadial; + } + /** + * Create a new brush generator + */ + brush(): Brush; + /** + * Create a new chord generator + */ + chord(): Chord; + /** + * Create a new diagonal generator + */ + diagonal: { + (): Diagonal; + radial(): Diagonal; + } + /** + * The array of supported symbol types. + */ + symbolTypes: string[]; + } + + export interface Symbol { + type: (string:string) => Symbol; + size: (number:number) => Symbol; + (datum:any, index:number): string; + } + + export interface Brush { + /** + * Draws or redraws this brush into the specified selection of elements + */ + (selection: Selection): void; + /** + * Gets or sets the x-scale associated with the brush + */ + x: { + /** + * Gets the x-scale associated with the brush + */ + (): D3.Scale.Scale; + /** + * Sets the x-scale associated with the brush + * + * @param accessor The new Scale + */ + (scale: D3.Scale.Scale): Brush; + }; + /** + * Gets or sets the x-scale associated with the brush + */ + y: { + /** + * Gets the x-scale associated with the brush + */ + (): D3.Scale.Scale; + /** + * Sets the x-scale associated with the brush + * + * @param accessor The new Scale + */ + (scale: D3.Scale.Scale): Brush; + }; + /** + * Gets or sets the current brush extent + */ + extent: { + /** + * Gets the current brush extent + */ + (): any[]; + /** + * Sets the current brush extent + */ + (values: any[]): Brush; + }; + /** + * Clears the extent, making the brush extent empty. + */ + clear(): Brush; + /** + * Returns true if and only if the brush extent is empty + */ + empty(): boolean; + /** + * Gets or sets the listener for the specified event type + */ + on: { + /** + * Gets the listener for the specified event type + */ + (type: string): (data: any, index: number) => any; + /** + * Sets the listener for the specified event type + */ + (type: string, listener: (data: any, index: number) => any, capture?: boolean): Brush; + }; + } + + export interface Axis { + (selection: Selection): void; + (transition: Transition.Transition): void; + + scale: { + (): any; + (scale: any): Axis; + }; + + orient: { + (): string; + (orientation: string): Axis; + }; + + ticks: { + (): any[]; + (...arguments: any[]): Axis; + }; + + tickPadding: { + (): number; + (padding: number): Axis; + }; + + tickValues: { + (): any[]; + (values: any[]): Axis; + }; + tickSubdivide(count: number): Axis; + tickSize: { + (): number; + (inner: number, outer?: number): Axis; + } + innerTickSize: { + (): number; + (value: number): Axis; + } + outerTickSize: { + (): number; + (value: number): Axis; + } + tickFormat(formatter: (value: any) => string): Axis; + nice(count?: number): Axis; + } + + export interface Arc { + /** + * Returns the path data string + * + * @param data Array of data elements + * @param index Optional index + */ + (data: any, index?: number): string; + innerRadius: { + (): (data: any, index?: number) => number; + (radius: number): Arc; + (radius: () => number): Arc; + (radius: (data: any) => number): Arc; + (radius: (data: any, index: number) => number): Arc; + }; + outerRadius: { + (): (data: any, index?: number) => number; + (radius: number): Arc; + (radius: () => number): Arc; + (radius: (data: any) => number): Arc; + (radius: (data: any, index: number) => number): Arc; + }; + startAngle: { + (): (data: any, index?: number) => number; + (angle: number): Arc; + (angle: () => number): Arc; + (angle: (data: any) => number): Arc; + (angle: (data: any, index: number) => number): Arc; + }; + endAngle: { + (): (data: any, index?: number) => number; + (angle: number): Arc; + (angle: () => number): Arc; + (angle: (data: any) => number): Arc; + (angle: (data: any, index: number) => number): Arc; + }; + centroid(data: any, index?: number): number[]; + } + + export interface Line { + /** + * Returns the path data string + * + * @param data Array of data elements + * @param index Optional index + */ + (data: any[], index?: number): string; + /** + * Get or set the x-coordinate accessor. + */ + x: { + /** + * Get the x-coordinate accessor. + */ + (): (data: any, index ?: number) => number; + /** + * Set the x-coordinate accessor. + * + * @param accessor The new accessor function + */ + (accessor: (data: any) => number): Line; + (accessor: (data: any, index: number) => number): Line; + /** + * Set the x-coordinate to a constant. + * + * @param cnst The new constant value. + */ + (cnst: number): Line; + }; + /** + * Get or set the y-coordinate accessor. + */ + y: { + /** + * Get the y-coordinate accessor. + */ + (): (data: any, index ?: number) => number; + /** + * Set the y-coordinate accessor. + * + * @param accessor The new accessor function + */ + (accessor: (data: any) => number): Line; + (accessor: (data: any, index: number) => number): Line; + /** + * Set the y-coordinate to a constant. + * + * @param cnst The new constant value. + */ + (cnst: number): Line; + }; + /** + * Get or set the interpolation mode. + */ + interpolate: { + /** + * Get the interpolation accessor. + */ + (): string; + /** + * Set the interpolation accessor. + * + * @param interpolate The interpolation mode + */ + (interpolate: string): Line; + }; + /** + * Get or set the cardinal spline tension. + */ + tension: { + /** + * Get the cardinal spline accessor. + */ + (): number; + /** + * Set the cardinal spline accessor. + * + * @param tension The Cardinal spline interpolation tension + */ + (tension: number): Line; + }; + /** + * Control whether the line is defined at a given point. + */ + defined: { + /** + * Get the accessor function that controls where the line is defined. + */ + (): (data: any, index?: number) => boolean; + /** + * Set the accessor function that controls where the area is defined. + * + * @param defined The new accessor function + */ + (defined: (data: any, index?: number) => boolean): Line; + }; + } + + export interface LineRadial { + /** + * Returns the path data string + * + * @param data Array of data elements + * @param index Optional index + */ + (data: any[], index?: number): string; + /** + * Get or set the x-coordinate accessor. + */ + x: { + /** + * Get the x-coordinate accessor. + */ + (): (data: any, index ?: number) => number; + /** + * Set the x-coordinate accessor. + * + * @param accessor The new accessor function + */ + (accessor: (data: any) => number): LineRadial; + (accessor: (data: any, index: number) => number): LineRadial; + + /** + * Set the x-coordinate to a constant. + * + * @param cnst The new constant value. + */ + (cnst: number): LineRadial; + }; + /** + * Get or set the y-coordinate accessor. + */ + y: { + /** + * Get the y-coordinate accessor. + */ + (): (data: any, index ?: number) => number; + /** + * Set the y-coordinate accessor. + * + * @param accessor The new accessor function + */ + (accessor: (data: any) => number): LineRadial; + (accessor: (data: any, index: number) => number): LineRadial; + /** + * Set the y-coordinate to a constant. + * + * @param cnst The new constant value. + */ + (cnst: number): LineRadial; + }; + /** + * Get or set the interpolation mode. + */ + interpolate: { + /** + * Get the interpolation accessor. + */ + (): string; + /** + * Set the interpolation accessor. + * + * @param interpolate The interpolation mode + */ + (interpolate: string): LineRadial; + }; + /** + * Get or set the cardinal spline tension. + */ + tension: { + /** + * Get the cardinal spline accessor. + */ + (): number; + /** + * Set the cardinal spline accessor. + * + * @param tension The Cardinal spline interpolation tension + */ + (tension: number): LineRadial; + }; + /** + * Control whether the line is defined at a given point. + */ + defined: { + /** + * Get the accessor function that controls where the line is defined. + */ + (): (data: any) => any; + /** + * Set the accessor function that controls where the area is defined. + * + * @param defined The new accessor function + */ + (defined: (data: any) => any): LineRadial; + }; + radius: { + (): (d: any, i?: number) => number; + (radius: number): LineRadial; + (radius: (d: any) => number): LineRadial; + (radius: (d: any, i: number) => number): LineRadial; + } + angle: { + (): (d: any, i?: any) => number; + (angle: number): LineRadial; + (angle: (d: any) => number): LineRadial; + (angle: (d: any, i: any) => number): LineRadial; + } + } + + export interface Area { + /** + * Generate a piecewise linear area, as in an area chart. + */ + (data: any[], index?: number): string; + /** + * Get or set the x-coordinate accessor. + */ + x: { + /** + * Get the x-coordinate accessor. + */ + (): (data: any, index ?: number) => number; + /** + * Set the x-coordinate accessor. + * + * @param accessor The new accessor function + */ + (accessor: (data: any) => number): Area; + (accessor: (data: any, index: number) => number): Area; + /** + * Set the x-coordinate to a constant. + * + * @param cnst The new constant value. + */ + (cnst: number): Area; + }; + /** + * Get or set the x0-coordinate (baseline) accessor. + */ + x0: { + /** + * Get the x0-coordinate (baseline) accessor. + */ + (): (data: any, index ?: number) => number; + /** + * Set the x0-coordinate (baseline) accessor. + * + * @param accessor The new accessor function + */ + (accessor: (data: any) => number): Area; + (accessor: (data: any, index: number) => number): Area; + /** + * Set the x0-coordinate (baseline) to a constant. + * + * @param cnst The new constant value. + */ + (cnst: number): Area; + }; + /** + * Get or set the x1-coordinate (topline) accessor. + */ + x1: { + /** + * Get the x1-coordinate (topline) accessor. + */ + (): (data: any, index ?: number) => number; + /** + * Set the x1-coordinate (topline) accessor. + * + * @param accessor The new accessor function + */ + (accessor: (data: any) => number): Area; + (accessor: (data: any, index: number) => number): Area; + /** + * Set the x1-coordinate (topline) to a constant. + * + * @param cnst The new constant value. + */ + (cnst: number): Area; + }; + /** + * Get or set the y-coordinate accessor. + */ + y: { + /** + * Get the y-coordinate accessor. + */ + (): (data: any, index ?: number) => number; + /** + * Set the y-coordinate accessor. + * + * @param accessor The new accessor function + */ + (accessor: (data: any) => number): Area; + (accessor: (data: any, index: number) => number): Area; + /** + * Set the y-coordinate to a constant. + * + * @param cnst The constant value + */ + (cnst: number): Area; + }; + /** + * Get or set the y0-coordinate (baseline) accessor. + */ + y0: { + /** + * Get the y0-coordinate (baseline) accessor. + */ + (): (data: any, index ?: number) => number; + /** + * Set the y0-coordinate (baseline) accessor. + * + * @param accessor The new accessor function + */ + (accessor: (data: any) => number): Area; + (accessor: (data: any, index: number) => number): Area; + /** + * Set the y0-coordinate (baseline) to a constant. + * + * @param cnst The constant value + */ + (cnst: number): Area; + }; + /** + * Get or set the y1-coordinate (topline) accessor. + */ + y1: { + /** + * Get the y1-coordinate (topline) accessor. + */ + (): (data: any, index ?: number) => number; + /** + * Set the y1-coordinate (topline) accessor. + * + * @param accessor The new accessor function + */ + (accessor: (data: any) => number): Area; + (accessor: (data: any, index: number) => number): Area; + /** + * Set the y1-coordinate (baseline) to a constant. + * + * @param cnst The constant value + */ + (cnst: number): Area; + }; + /** + * Get or set the interpolation mode. + */ + interpolate: { + /** + * Get the interpolation accessor. + */ + (): string; + /** + * Set the interpolation accessor. + * + * @param interpolate The interpolation mode + */ + (interpolate: string): Area; + }; + /** + * Get or set the cardinal spline tension. + */ + tension: { + /** + * Get the cardinal spline accessor. + */ + (): number; + /** + * Set the cardinal spline accessor. + * + * @param tension The Cardinal spline interpolation tension + */ + (tension: number): Area; + }; + /** + * Control whether the area is defined at a given point. + */ + defined: { + /** + * Get the accessor function that controls where the area is defined. + */ + (): (data: any, index?: number) => any; + /** + * Set the accessor function that controls where the area is defined. + * + * @param defined The new accessor function + */ + (defined: (data: any, index?: number) => any): Area; + }; + } + + export interface AreaRadial { + /** + * Generate a piecewise linear area, as in an area chart. + */ + (data: any[], index?: number): string; + /** + * Get or set the x-coordinate accessor. + */ + x: { + /** + * Get the x-coordinate accessor. + */ + (): (data: any, index ?: number) => number; + /** + * Set the x-coordinate accessor. + * + * @param accessor The new accessor function + */ + (accessor: (data: any) => number): AreaRadial; + (accessor: (data: any, index: number) => number): AreaRadial; + /** + * Set the x-coordinate to a constant. + * + * @param cnst The new constant value. + */ + (cnst: number): AreaRadial; + }; + /** + * Get or set the x0-coordinate (baseline) accessor. + */ + x0: { + /** + * Get the x0-coordinate (baseline) accessor. + */ + (): (data: any, index ?: number) => number; + /** + * Set the x0-coordinate (baseline) accessor. + * + * @param accessor The new accessor function + */ + (accessor: (data: any) => number): AreaRadial; + (accessor: (data: any, index: number) => number): AreaRadial; + /** + * Set the x0-coordinate to a constant. + * + * @param cnst The new constant value. + */ + (cnst: number): AreaRadial; + }; + /** + * Get or set the x1-coordinate (topline) accessor. + */ + x1: { + /** + * Get the x1-coordinate (topline) accessor. + */ + (): (data: any, index ?: number) => number; + /** + * Set the x1-coordinate (topline) accessor. + * + * @param accessor The new accessor function + */ + (accessor: (data: any) => number): AreaRadial; + (accessor: (data: any, index: number) => number): AreaRadial; + /** + * Set the x1-coordinate to a constant. + * + * @param cnst The new constant value. + */ + (cnst: number): AreaRadial; + }; + /** + * Get or set the y-coordinate accessor. + */ + y: { + /** + * Get the y-coordinate accessor. + */ + (): (data: any, index ?: number) => number; + /** + * Set the y-coordinate accessor. + * + * @param accessor The new accessor function + */ + (accessor: (data: any) => number): AreaRadial; + (accessor: (data: any, index: number) => number): AreaRadial; + /** + * Set the y-coordinate to a constant. + * + * @param cnst The new constant value. + */ + (cnst: number): AreaRadial; + }; + /** + * Get or set the y0-coordinate (baseline) accessor. + */ + y0: { + /** + * Get the y0-coordinate (baseline) accessor. + */ + (): (data: any, index ?: number) => number; + /** + * Set the y0-coordinate (baseline) accessor. + * + * @param accessor The new accessor function + */ + (accessor: (data: any) => number): AreaRadial; + (accessor: (data: any, index: number) => number): AreaRadial; + /** + * Set the y0-coordinate to a constant. + * + * @param cnst The new constant value. + */ + (cnst: number): AreaRadial; + }; + /** + * Get or set the y1-coordinate (topline) accessor. + */ + y1: { + /** + * Get the y1-coordinate (topline) accessor. + */ + (): (data: any, index ?: number) => number; + /** + * Set the y1-coordinate (topline) accessor. + * + * @param accessor The new accessor function + */ + (accessor: (data: any) => number): AreaRadial; + (accessor: (data: any, index: number) => number): AreaRadial; + /** + * Set the y1-coordinate to a constant. + * + * @param cnst The new constant value. + */ + (cnst: number): AreaRadial; + }; + /** + * Get or set the interpolation mode. + */ + interpolate: { + /** + * Get the interpolation accessor. + */ + (): string; + /** + * Set the interpolation accessor. + * + * @param interpolate The interpolation mode + */ + (interpolate: string): AreaRadial; + }; + /** + * Get or set the cardinal spline tension. + */ + tension: { + /** + * Get the cardinal spline accessor. + */ + (): number; + /** + * Set the cardinal spline accessor. + * + * @param tension The Cardinal spline interpolation tension + */ + (tension: number): AreaRadial; + }; + /** + * Control whether the area is defined at a given point. + */ + defined: { + /** + * Get the accessor function that controls where the area is defined. + */ + (): (data: any) => any; + /** + * Set the accessor function that controls where the area is defined. + * + * @param defined The new accessor function + */ + (defined: (data: any) => any): AreaRadial; + }; + radius: { + (): number; + (radius: number): AreaRadial; + (radius: () => number): AreaRadial; + (radius: (data: any) => number): AreaRadial; + (radius: (data: any, index: number) => number): AreaRadial; + }; + innerRadius: { + (): number; + (radius: number): AreaRadial; + (radius: () => number): AreaRadial; + (radius: (data: any) => number): AreaRadial; + (radius: (data: any, index: number) => number): AreaRadial; + }; + outerRadius: { + (): number; + (radius: number): AreaRadial; + (radius: () => number): AreaRadial; + (radius: (data: any) => number): AreaRadial; + (radius: (data: any, index: number) => number): AreaRadial; + }; + angle: { + (): number; + (angle: number): AreaRadial; + (angle: () => number): AreaRadial; + (angle: (data: any) => number): AreaRadial; + (angle: (data: any, index: number) => number): AreaRadial; + }; + startAngle: { + (): number; + (angle: number): AreaRadial; + (angle: () => number): AreaRadial; + (angle: (data: any) => number): AreaRadial; + (angle: (data: any, index: number) => number): AreaRadial; + }; + endAngle: { + (): number; + (angle: number): AreaRadial; + (angle: () => number): AreaRadial; + (angle: (data: any) => number): AreaRadial; + (angle: (data: any, index: number) => number): AreaRadial; + }; + } + + export interface Chord { + (datum: any, index?: number): string; + radius: { + (): number; + (radius: number): Chord; + (radius: () => number): Chord; + }; + startAngle: { + (): number; + (angle: number): Chord; + (angle: () => number): Chord; + }; + endAngle: { + (): number; + (angle: number): Chord; + (angle: () => number): Chord; + }; + source: { + (): any; + (angle: any): Chord; + (angle: (d: any, i?: number) => any): Chord; + }; + target: { + (): any; + (angle: any): Chord; + (angle: (d: any, i?: number) => any): Chord; + }; + } + + export interface Diagonal { + (datum: any, index?: number): string; + projection: { + (): (datum: any, index?: number) => number[]; + (proj: (datum: any) => number[]): Diagonal; + (proj: (datum: any, index: number) => number[]): Diagonal; + }; + source: { + (): (datum: any, index?: number) => any; + (src: (datum: any) => any): Diagonal; + (src: (datum: any, index: number) => any): Diagonal; + (src: any): Diagonal; + }; + target: { + (): (datum: any, index?: number) => any; + (target: (d: any) => any): Diagonal; + (target: (d: any, i: number) => any): Diagonal; + (target: any): Diagonal; + }; + } + } + + // Scales + export module Scale { + export interface ScaleBase { + /** + * Construct a linear quantitative scale. + */ + linear(): LinearScale; + /* + * Construct an ordinal scale. + */ + ordinal(): OrdinalScale; + /** + * Construct a linear quantitative scale with a discrete output range. + */ + quantize(): QuantizeScale; + /* + * Construct an ordinal scale with ten categorical colors. + */ + category10(): OrdinalScale; + /* + * Construct an ordinal scale with twenty categorical colors + */ + category20(): OrdinalScale; + /* + * Construct an ordinal scale with twenty categorical colors + */ + category20b(): OrdinalScale; + /* + * Construct an ordinal scale with twenty categorical colors + */ + category20c(): OrdinalScale; + /* + * Construct a linear identity scale. + */ + identity(): IdentityScale; + /* + * Construct a quantitative scale with an logarithmic transform. + */ + log(): LogScale; + /* + * Construct a quantitative scale with an exponential transform. + */ + pow(): PowScale; + /* + * Construct a quantitative scale mapping to quantiles. + */ + quantile(): QuantileScale; + /* + * Construct a quantitative scale with a square root transform. + */ + sqrt(): SqrtScale; + /* + * Construct a threshold scale with a discrete output range. + */ + threshold(): ThresholdScale; + } + + export interface GenericScale { + (value: any): any; + domain: { + (values: any[]): S; + (): any[]; + }; + range: { + (values: any[]): S; + (): any[]; + }; + invertExtent?(y: any): any[]; + copy(): S; + } + + export interface Scale extends GenericScale { } + + export interface GenericQuantitativeScale extends GenericScale { + /** + * Get the range value corresponding to a given domain value. + * + * @param value Domain Value + */ + (value: number): number; + /** + * Get the domain value corresponding to a given range value. + * + * @param value Range Value + */ + invert(value: number): number; + /** + * Set the scale's output range, and enable rounding. + * + * @param value The output range. + */ + rangeRound: (values: any[]) => S; + /** + * get or set the scale's output interpolator. + */ + interpolate: { + (): D3.Transition.Interpolate; + (factory: D3.Transition.Interpolate): S; + }; + /** + * enable or disable clamping of the output range. + * + * @param clamp Enable or disable + */ + clamp: { + (): boolean; + (clamp: boolean): S; + } + /** + * extend the scale domain to nice round numbers. + * + * @param count Optional number of ticks to exactly fit the domain + */ + nice(count?: number): S; + /** + * get representative values from the input domain. + * + * @param count Aproximate representative values to return. + */ + ticks(count: number): any[]; + /** + * get a formatter for displaying tick values + * + * @param count Aproximate representative values to return + */ + tickFormat(count: number, format?: string): (n: number) => string; + } + + export interface QuantitativeScale extends GenericQuantitativeScale { } + + export interface LinearScale extends GenericQuantitativeScale { } + + export interface IdentityScale extends GenericScale { + /** + * Get the range value corresponding to a given domain value. + * + * @param value Domain Value + */ + (value: number): number; + /** + * Get the domain value corresponding to a given range value. + * + * @param value Range Value + */ + invert(value: number): number; + /** + * get representative values from the input domain. + * + * @param count Aproximate representative values to return. + */ + ticks(count: number): any[]; + /** + * get a formatter for displaying tick values + * + * @param count Aproximate representative values to return + */ + tickFormat(count: number): (n: number) => string; + } + + export interface SqrtScale extends GenericQuantitativeScale { } + + export interface PowScale extends GenericQuantitativeScale { } + + export interface LogScale extends GenericQuantitativeScale { } + + export interface OrdinalScale extends GenericScale { + rangePoints(interval: any[], padding?: number): OrdinalScale; + rangeBands(interval: any[], padding?: number, outerPadding?: number): OrdinalScale; + rangeRoundBands(interval: any[], padding?: number, outerPadding?: number): OrdinalScale; + rangeBand(): number; + rangeExtent(): any[]; + } + + export interface QuantizeScale extends GenericScale { } + + export interface ThresholdScale extends GenericScale { } + + export interface QuantileScale extends GenericScale { + quantiles(): any[]; + } + + export interface TimeScale extends GenericScale { + (value: Date): number; + invert(value: number): Date; + rangeRound: (values: any[]) => TimeScale; + interpolate: { + (): D3.Transition.Interpolate; + (factory: D3.Transition.InterpolateFactory): TimeScale; + }; + clamp(clamp: boolean): TimeScale; + ticks: { + (count: number): any[]; + (range: D3.Time.Range, count: number): any[]; + }; + tickFormat(count: number): (n: number) => string; + nice(count?: number): TimeScale; + } + } + + // Behaviour + export module Behavior { + export interface Behavior{ + /** + * Constructs a new drag behaviour + */ + drag(): Drag; + /** + * Constructs a new zoom behaviour + */ + zoom(): Zoom; + } + + export interface Zoom { + /** + * Applies the zoom behavior to the specified selection, + * registering the necessary event listeners to support + * panning and zooming. + */ + (selection: Selection): void; + + /** + * Registers a listener to receive events + * + * @param type Enent name to attach the listener to + * @param listener Function to attach to event + */ + on: (type: string, listener: (data: any, index?: number) => any) => Zoom; + + /** + * Gets or set the current zoom scale + */ + scale: { + /** + * Get the current current zoom scale + */ + (): number; + /** + * Set the current current zoom scale + * + * @param origin Zoom scale + */ + (scale: number): Zoom; + }; + + /** + * Gets or set the current zoom translation vector + */ + translate: { + /** + * Get the current zoom translation vector + */ + (): number[]; + /** + * Set the current zoom translation vector + * + * @param translate Tranlation vector + */ + (translate: number[]): Zoom; + }; + + /** + * Gets or set the allowed scale range + */ + scaleExtent: { + /** + * Get the current allowed zoom range + */ + (): number[]; + /** + * Set the allowable zoom range + * + * @param extent Allowed zoom range + */ + (extent: number[]): Zoom; + }; + + /** + * Gets or set the X-Scale that should be adjusted when zooming + */ + x: { + /** + * Get the X-Scale + */ + (): D3.Scale.Scale; + /** + * Set the X-Scale to be adjusted + * + * @param x The X Scale + */ + (x: D3.Scale.Scale): Zoom; + + }; + + /** + * Gets or set the Y-Scale that should be adjusted when zooming + */ + y: { + /** + * Get the Y-Scale + */ + (): D3.Scale.Scale; + /** + * Set the Y-Scale to be adjusted + * + * @param y The Y Scale + */ + (y: D3.Scale.Scale): Zoom; + }; + } + + export interface Drag { + /** + * Execute drag method + */ + (): any; + + /** + * Registers a listener to receive events + * + * @param type Enent name to attach the listener to + * @param listener Function to attach to event + */ + on: (type: string, listener: (data: any, index?: number) => any) => Drag; + + /** + * Gets or set the current origin accessor function + */ + origin: { + /** + * Get the current origin accessor function + */ + (): any; + /** + * Set the origin accessor function + * + * @param origin Accessor function + */ + (origin?: any): Drag; + }; + } + } + + // Geography + export module Geo { + export interface Geo { + /** + * create a new geographic path generator + */ + path(): Path; + /** + * create a circle generator. + */ + circle(): Circle; + /** + * compute the spherical area of a given feature. + */ + area(feature: any): number; + /** + * compute the latitude-longitude bounding box for a given feature. + */ + bounds(feature: any): number[][]; + /** + * compute the spherical centroid of a given feature. + */ + centroid(feature: any): number[]; + /** + * compute the great-arc distance between two points. + */ + distance(a: number[], b: number[]): number; + /** + * interpolate between two points along a great arc. + */ + interpolate(a: number[], b: number[]): (t: number) => number[]; + /** + * compute the length of a line string or the circumference of a polygon. + */ + length(feature: any): number; + /** + * create a standard projection from a raw projection. + */ + projection(raw: RawProjection): Projection; + /** + * create a standard projection from a mutable raw projection. + */ + projectionMutator(rawFactory: RawProjection): ProjectionMutator; + /** + * the Albers equal-area conic projection. + */ + albers(): Projection; + /** + * a composite Albers projection for the United States. + */ + albersUsa(): Projection; + /** + * the azimuthal equal-area projection. + */ + azimuthalEqualArea: { + (): Projection; + raw: RawProjection; + } + /** + * the azimuthal equidistant projection. + */ + azimuthalEquidistant: { + (): Projection; + raw: RawProjection; + } + /** + * the conic conformal projection. + */ + conicConformal: { + (): Projection; + raw(phi1:number, phi2:number): RawProjection; + } + /** + * the conic equidistant projection. + */ + conicEquidistant: { + (): Projection; + raw(phi1:number, phi2:number): RawProjection; + } + /** + * the conic equal-area (a.k.a. Albers) projection. + */ + conicEqualArea: { + (): Projection; + raw(phi1:number, phi2:number): RawProjection; + } + /** + * the equirectangular (plate carreé) projection. + */ + equirectangular: { + (): Projection; + raw: RawProjection; + } + /** + * the gnomonic projection. + */ + gnomonic: { + (): Projection; + raw: RawProjection; + } + /** + * the spherical Mercator projection. + */ + mercator: { + (): Projection; + raw: RawProjection; + } + /** + * the azimuthal orthographic projection. + */ + orthographic: { + (): Projection; + raw: RawProjection; + } + /** + * the azimuthal stereographic projection. + */ + stereographic: { + (): Projection; + raw: RawProjection; + } + /** + * the transverse Mercator projection. + */ + transverseMercator: { + (): Projection; + raw: RawProjection; + } + /** + * convert a GeoJSON object to a geometry stream. + */ + stream(object: GeoJSON, listener: Stream): void; + /** + * + */ + graticule(): Graticule; + /** + * + */ + greatArc(): GreatArc; + /** + * + */ + rotation(rotation: number[]): Rotation; + } + + export interface Path { + /** + * Returns the path data string for the given feature + */ + (feature: any, index?: any): string; + /** + * get or set the geographic projection. + */ + projection: { + /** + * get the geographic projection. + */ + (): Projection; + /** + * set the geographic projection. + */ + (projection: Projection): Path; + } + /** + * get or set the render context. + */ + context: { + /** + * return an SVG path string invoked on the given feature. + */ + (): string; + /** + * sets the render context and returns the path generator + */ + (context: Context): Path; + } + /** + * Computes the projected area + */ + area(feature: any): any; + /** + * Computes the projected centroid + */ + centroid(feature: any): any; + /** + * Computes the projected bounding box + */ + bounds(feature: any): any; + /** + * get or set the radius to display point features. + */ + pointRadius: { + /** + * returns the current radius + */ + (): number; + /** + * sets the radius used to display Point and MultiPoint features to the specified number + */ + (radius: number): Path; + /** + * sets the radius used to display Point and MultiPoint features to the specified number + */ + (radius: (feature: any, index: number) => number): Path; + } + } + + export interface Context { + beginPath(): any; + moveTo(x: number, y: number): any; + lineTo(x: number, y: number): any; + arc(x: number, y: number, radius: number, startAngle: number, endAngle: number): any; + closePath(): any; + } + + export interface Circle { + (...args: any[]): GeoJSON; + origin: { + (): number[]; + (origin: number[]): Circle; + (origin: (...args: any[]) => number[]): Circle; + } + angle: { + (): number; + (angle: number): Circle; + } + precision: { + (): number; + (precision: number): Circle; + } + } + + export interface Graticule{ + (): GeoJSON; + lines(): GeoJSON[]; + outline(): GeoJSON; + extent: { + (): number[][]; + (extent: number[][]): Graticule; + } + minorExtent: { + (): number[][]; + (extent: number[][]): Graticule; + } + majorExtent: { + (): number[][]; + (extent: number[][]): Graticule; + } + step: { + (): number[][]; + (extent: number[][]): Graticule; + } + minorStep: { + (): number[][]; + (extent: number[][]): Graticule; + } + majorStep: { + (): number[][]; + (extent: number[][]): Graticule; + } + precision: { + (): number; + (precision: number): Graticule; + } + } + + export interface GreatArc { + (): GeoJSON; + distance(): number; + source: { + (): any; + (source: any): GreatArc; + } + target: { + (): any; + (target: any): GreatArc; + } + precision: { + (): number; + (precision: number): GreatArc; + } + } + + export interface GeoJSON { + coordinates: number[][]; + type: string; + } + + export interface RawProjection { + (lambda: number, phi: number): number[]; + invert?(x: number, y: number): number[]; + } + + export interface Projection { + (coordinates: number[]): number[]; + invert?(point: number[]): number[]; + rotate: { + (): number[]; + (rotation: number[]): Projection; + }; + center: { + (): number[]; + (location: number[]): Projection; + }; + parallels: { + (): number[]; + (location: number[]): Projection; + }; + translate: { + (): number[]; + (point: number[]): Projection; + }; + scale: { + (): number; + (scale: number): Projection; + }; + clipAngle: { + (): number; + (angle: number): Projection; + }; + clipExtent: { + (): number[][]; + (extent: number[][]): Projection; + }; + precision: { + (): number; + (precision: number): Projection; + }; + stream(listener?: Stream): Stream; + } + + export interface Stream { + point(x: number, y: number, z?: number): void; + lineStart(): void; + lineEnd(): void; + polygonStart(): void; + polygonEnd(): void; + sphere(): void; + } + + export interface Rotation extends Array { + (location: number[]): Rotation; + invert(location: number[]): Rotation; + } + + export interface ProjectionMutator { + (lambda: number, phi: number): Projection; + } + } + + // Geometry + export module Geom { + export interface Geom { + voronoi(): Voronoi; + /** + * compute the Voronoi diagram for the specified points. + */ + voronoi(vertices: Vertice[]): Polygon[]; + /** + * compute the Delaunay triangulation for the specified points. + */ + delaunay(vertices?: Vertice[]): Polygon[]; + /** + * constructs a quadtree for an array of points. + */ + quadtree(): QuadtreeFactory; + /** + * Constructs a new quadtree for the specified array of points. + */ + quadtree(points: Point[], x1: number, y1: number, x2: number, y2: number): Quadtree; + /** + * Constructs a new quadtree for the specified array of points. + */ + quadtree(points: Point[], width: number, height: number): Quadtree; + /** + * Returns the input array of vertices with additional methods attached + */ + polygon(vertices:Vertice[]): Polygon; + /** + * creates a new hull layout with the default settings. + */ + hull(): Hull; + + hull(vertices:Vertice[]): Vertice[]; + } + + export interface Vertice extends Array { + /** + * Returns the angle of the vertice + */ + angle?: number; + } + + export interface Polygon extends Array { + /** + * Returns the signed area of this polygon + */ + area(): number; + /** + * Returns a two-element array representing the centroid of this polygon. + */ + centroid(): number[]; + /** + * Clips the subject polygon against this polygon + */ + clip(subject: Polygon): Polygon; + } + + export interface QuadtreeFactory { + /** + * Constructs a new quadtree for the specified array of points. + */ + (): Quadtree; + /** + * Constructs a new quadtree for the specified array of points. + */ + (points: Point[], x1: number, y1: number, x2: number, y2: number): Quadtree; + /** + * Constructs a new quadtree for the specified array of points. + */ + (points: Point[], width: number, height: number): Quadtree; + + x: { + (): (d: any) => any; + (accesor: (d: any) => any): QuadtreeFactory; + + } + y: { + (): (d: any) => any; + (accesor: (d: any) => any): QuadtreeFactory; + + } + size(): number[]; + size(size: number[]): QuadtreeFactory; + extent(): number[][]; + extent(points: number[][]): QuadtreeFactory; + } + + export interface Quadtree { + /** + * Adds a new point to the quadtree. + */ + add(point: Point): void; + visit(callback: any): void; + } + + export interface Point { + x: number; + y: number; + } + + export interface Voronoi { + /** + * Compute the Voronoi diagram for the specified data. + */ + (data: T[]): Polygon[]; + /** + * Compute the graph links for the Voronoi diagram for the specified data. + */ + links(data: T[]): Layout.GraphLink[]; + /** + * Compute the triangles for the Voronoi diagram for the specified data. + */ + triangles(data: T[]): number[][]; + x: { + /** + * Get the x-coordinate accessor. + */ + (): (data: T, index ?: number) => number; + + /** + * Set the x-coordinate accessor. + * + * @param accessor The new accessor function + */ + (accessor: (data: T, index: number) => number): Voronoi; + + /** + * Set the x-coordinate to a constant. + * + * @param constant The new constant value. + */ + (constant: number): Voronoi; + } + y: { + /** + * Get the y-coordinate accessor. + */ + (): (data: T, index ?: number) => number; + + /** + * Set the y-coordinate accessor. + * + * @param accessor The new accessor function + */ + (accessor: (data: T, index: number) => number): Voronoi; + + /** + * Set the y-coordinate to a constant. + * + * @param constant The new constant value. + */ + (constant: number): Voronoi; + } + clipExtent: { + /** + * Get the clip extent. + */ + (): number[][]; + /** + * Set the clip extent. + * + * @param extent The new clip extent. + */ + (extent: number[][]): Voronoi; + } + size: { + /** + * Get the size. + */ + (): number[]; + /** + * Set the size, equivalent to a clip extent starting from (0,0). + * + * @param size The new size. + */ + (size: number[]): Voronoi; + } + } + + export interface Hull { + (vertices: Vertice[]): Vertice[]; + x: { + (): (d: any) => any; + (accesor: (d: any) => any): any; + } + y: { + (): (d: any) => any; + (accesor: (d: any) => any): any; + } + } + } +} + +declare var d3: D3.Base; + +declare module "d3" { + export = d3; +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/d3/plugins/d3.superformula-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/d3/plugins/d3.superformula-tests.ts new file mode 100644 index 00000000..3e7dd4d5 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/d3/plugins/d3.superformula-tests.ts @@ -0,0 +1,40 @@ +/// +/// + +function superformula() { + var size = 1000; + + var x = d3.scale.ordinal() + .domain(d3.superformulaTypes) + .rangePoints([0, 960], 1); + + var svg = d3.select("body").append("svg") + .attr("width", 960) + .attr("height", 500); + + var small = d3.superformula() + .type(function (d) { return d; } ) + .size(size); + + var big = d3.superformula() + .type("square") + .size(size * 50) + .segments(360); + + svg.selectAll("a") + .data(d3.superformulaTypes) + .enter().append("a") + .attr("xlink:title", String) + .attr("transform", function (d, i) { return "translate(" + x(d) + ",40)"; } ) + .append("path") + .attr("class", "small") + .attr("d", small) + .on("mousedown", function () { d3.select(this).style("fill", "aliceblue"); } ) + .on("mouseup", function () { d3.select(this).style("fill", null); } ) + .on("click", function (d) { d3.select(".big").transition().duration(500).attr("d", big.type(d)); } ); + + svg.append("path") + .attr("class", "big") + .attr("transform", "translate(450,250)") + .attr("d", big); +} \ No newline at end of file diff --git a/zeppelin-web/app/external/DefinitelyTyped/d3/plugins/d3.superformula-tests.ts.tscparams b/zeppelin-web/app/external/DefinitelyTyped/d3/plugins/d3.superformula-tests.ts.tscparams new file mode 100644 index 00000000..d3f5a12f --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/d3/plugins/d3.superformula-tests.ts.tscparams @@ -0,0 +1 @@ + diff --git a/zeppelin-web/app/external/DefinitelyTyped/d3/plugins/d3.superformula.d.ts b/zeppelin-web/app/external/DefinitelyTyped/d3/plugins/d3.superformula.d.ts new file mode 100644 index 00000000..6f5c59b0 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/d3/plugins/d3.superformula.d.ts @@ -0,0 +1,38 @@ +/// + + +declare module D3 { + interface SuperformulaPath + { + superformulaPath(params: number[], n: number, diameter: number): Superformula; + } + + + interface SuperformulaType + { + (any: any): any;//hans + m: number; + n1: number; + n2: number; + n3: number; + a: number; + b: number; + } + + interface Superformula + { + (): any; + type(any: any): any; + param(name: string, value: number): Superformula; + size(x: number): Superformula; + segments(x: number): Superformula; + } + + + interface Base extends Selectors + { + superformula: Superformula; + superformulaPath: SuperformulaPath; + superformulaTypes: SuperformulaType[]; + } +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/jquery.scrollTo/jquery.scrollTo-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/jquery.scrollTo/jquery.scrollTo-tests.ts new file mode 100644 index 00000000..00911260 --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/jquery.scrollTo/jquery.scrollTo-tests.ts @@ -0,0 +1,31 @@ +/// +/// + +$('div').scrollTo(340); + +$('div').scrollTo('+=340px', { axis: 'y' }); + +$('div').scrollTo('p.paragraph:eq(2)', 500, { easing: 'swing', queue: true, axis: 'xy' }); + +var second_child = document.getElementById('container').firstChild.nextSibling; +$('#container').scrollTo(second_child, { + duration: 500, axis: 'x', onAfter: function () { + alert('scrolled!!'); + } +}); + +$('div').scrollTo({ top: 300, left: '+=200' }, { axis: 'xy', offset: -20 }); + +$.scrollTo(340); + +$.scrollTo('+=340px', { axis: 'y' }); + +$.scrollTo('p.paragraph:eq(2)', 500, { easing: 'swing', queue: true, axis: 'xy' }); + +$.scrollTo(second_child, { + duration: 500, axis: 'x', onAfter: function () { + alert('scrolled!!'); + } +}); + +$.scrollTo({ top: 300, left: '+=200' }, { axis: 'xy', offset: -20 }); \ No newline at end of file diff --git a/zeppelin-web/app/external/DefinitelyTyped/jquery.scrollTo/jquery.scrollTo.d.ts b/zeppelin-web/app/external/DefinitelyTyped/jquery.scrollTo/jquery.scrollTo.d.ts new file mode 100644 index 00000000..d3578c0d --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/jquery.scrollTo/jquery.scrollTo.d.ts @@ -0,0 +1,116 @@ +// Type definitions for jQuery.scrollTo.js 1.4.4 +// Project: https://github.com/flesler/jquery.scrollTo +// Definitions by: Neil Stalker +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface ScrollToOptions { + /** + * Which axis must be scrolled, use 'x', 'y', 'xy' or 'yx'. + */ + axis?: string; + /** + * The OVERALL length of the animation. + */ + duration?: any; + /** + * The easing method for the animation. + */ + easing?: string; + /** + * If true, the margin of the target element will be deducted from the final position. + */ + margin?: boolean; + /** + * Add/deduct from the end position. + * One number for both axes or { top:x, left:y }. + */ + offset?: any; + /** + * Add/deduct the height/width multiplied by 'over'. + * Can be { top:x, left:y } when using both axes. + */ + over? : any; + /** + * If true, and both axis are given. + * The 2nd axis will only be animated after the first one ends. + */ + queue?: boolean; + /** + * Function to be called after the scrolling ends. + */ + onAfter?: () => void; + /** + * If queuing is activated, this function will be called after the first scrolling ends. + */ + onAfterFirst?: () => void; +} + +interface JQuery { + /** + * Scroll the matched elements + */ + scrollTo: { + /** + * Scroll the matched elements + * + * @param target Where to scroll the matched elements. + * @param duration The OVERALL length of the animation + * @param settings Set of settings. + */ + (target: any, duration?: number, settings?: ScrollToOptions): JQuery; + /** + * Scroll the matched elements + * + * @param target Where to scroll the matched elements. + * @param duration The OVERALL length of the animation + * @param onAfter The onAfter callback. + */ + (target: any, duration: number, onAfter?: Function): JQuery; + /** + * Scroll the matched elements + * + * @param target Where to scroll the matched elements. + * @param settings Set of settings. + * @param onAfter The onAfter callback. + */ + (target: any, settings: ScrollToOptions, onAfter?: Function): JQuery; + + }; + +} + +interface JQueryStatic { + /** + * Scroll window + */ + scrollTo: { + /** + * Scroll window + * + * @param target Where to scroll the matched elements. + * @param duration The OVERALL length of the animation + * @param settings Set of settings. + */ + (target: any, duration?: number, settings?: ScrollToOptions): JQuery; + /** + * Scroll window + * + * @param target Where to scroll the matched elements. + * @param duration The OVERALL length of the animation + * @param onAfter The onAfter callback. + */ + (target: any, duration: number, onAfter?: Function): JQuery; + /** + * Scroll window + * + * @param target Where to scroll the matched elements. + * @param settings Set of settings. + * @param onAfter The onAfter callback. + */ + (target: any, settings: ScrollToOptions, onAfter?: Function): JQuery; + + }; + +} diff --git a/zeppelin-web/app/external/DefinitelyTyped/jquery/jquery-tests.ts b/zeppelin-web/app/external/DefinitelyTyped/jquery/jquery-tests.ts new file mode 100644 index 00000000..8a2e23cf --- /dev/null +++ b/zeppelin-web/app/external/DefinitelyTyped/jquery/jquery-tests.ts @@ -0,0 +1,3373 @@ +/// + +function test_add() { + $("p").add("div").addClass("widget"); + var pdiv = $("p").add("div"); + + $('li').add('p').css('background-color', 'red'); + $('li').add(document.getElementsByTagName('p')[0]) + .css('background-coailor', 'red'); + $('li').add('

new paragraph

') + .css('background-color', 'red'); + $("div").css("border", "2px solid red") + .add("p") + .css("background", "yellow"); + $("p").add("span").css("background", "yellow"); + $("p").clone().add("Again").appendTo(document.body); + $("p").add(document.getElementById("a")).css("background", "yellow"); + var collection = $("p"); + + collection = collection.add(document.getElementById("a")); + collection.css("background", "yellow"); +} + +function test_addClass() { + $("p").addClass("myClass yourClass"); + $("p").removeClass("myClass noClass").addClass("yourClass"); + $("ul li:last").addClass(function (index) { + return "item-" + index; + }); + $("p:last").addClass("selected"); + $("p:last").addClass("selected highlight"); + $("div").addClass(function (index, currentClass) { + var addedClass: string; + if (currentClass === "red") { + addedClass = "green"; + $("p").text("There is one green div"); + } + return addedClass; + }); +} + +function test_after() { + $('.inner').after('

Test

'); + $('
').after('

'); + $('
').after('

').addClass('foo') + .filter('p').attr('id', 'bar').html('hello') + .end() + .appendTo('body'); + $('p').after(function () { + return '
' + this.className + '
'; + }); + var $newdiv1 = $('
'), + newdiv2 = document.createElement('div'), + existingdiv1 = document.getElementById('foo'); + $('p').first().after($newdiv1, [newdiv2, existingdiv1]); + $("p").after(document.createTextNode("Hello")); + $("p").after($("b")); +} + +function test_ajax() { + $.ajax({ + url: "test.html", + context: document.body + }).done(function () { + $(this).addClass("done"); + }); + $.ajax({ + statusCode: { + 404: function () { + alert("page not found"); + } + } + }); + $.ajax({ + url: "http://fiddle.jshell.net/favicon.png", + beforeSend: function (xhr) { + xhr.overrideMimeType("text/plain; charset=x-user-defined"); + } + }).done(function (data) { + if (console && console.log) { + console.log("Sample of data:", data.slice(0, 100)); + } + }); + $.ajax({ + url: 'ajax/test.html', + success: function (data) { + $('.result').html(data); + alert('Load was performed.'); + }, + error: function (jqXHR, textStatus, errorThrown) { + alert('Load failed. responseJSON=' + jqXHR.responseJSON); + } + }); + var _super = jQuery.ajaxSettings.xhr; + jQuery.ajaxSettings.xhr = function () { + var xhr = _super(), + getAllResponseHeaders = xhr.getAllResponseHeaders; + + xhr.getAllResponseHeaders = function () { + if (getAllResponseHeaders()) { + return getAllResponseHeaders(); + } + var allHeaders = ""; + $(["Cache-Control", "Content-Language", "Content-Type", + "Expires", "Last-Modified", "Pragma"]).each(function (i, header_name) { + + if (xhr.getResponseHeader(header_name)) { + allHeaders += header_name + ": " + xhr.getResponseHeader(header_name) + "\n"; + } + return allHeaders; + }); + }; + return xhr; + }; + $.ajax({ + type: "POST", + url: "some.php", + data: { name: "John", location: "Boston" } + }).done(function (msg) { + alert("Data Saved: " + msg); + }); + $.ajax({ + url: "test.html", + cache: false + }).done(function (html) { + $("#results").append(html); + }); + var xmlDocument = []; + var xmlRequest = $.ajax({ + url: "page.php", + processData: false, + data: xmlDocument + }); + var handleResponse; + xmlRequest.done(handleResponse); + + var menuId = $("ul.nav").first().attr("id"); + var request = $.ajax({ + url: "script.php", + type: "POST", + data: { id: menuId }, + dataType: "html" + }); + request.done(function (msg) { + $("#log").html(msg); + }); + request.fail(function (jqXHR, textStatus) { + alert("Request failed: " + textStatus); + }); + + $.ajax({ + type: "GET", + url: "test.js", + dataType: "script" + }); + + // Test the jqXHR object returned by $.ajax() as of 1.5 + // More details: http://api.jquery.com/jQuery.ajax/#jqXHR + + // done method + $.ajax({ + url: "test.js" + }).done((data, textStatus, jqXHR) => { + console.log(data, textStatus, jqXHR); + }); + + // fail method + $.ajax({ + url: "test.js" + }).fail((jqXHR, textStatus, errorThrown) => { + console.log(jqXHR, textStatus, errorThrown); + }); + + // always method with successful request + $.ajax({ + url: "test.js" + }).always((data, textStatus, jqXHR) => { + console.log(data, textStatus, jqXHR); + }); + + // always method with failed request + $.ajax({ + url: "test.js" + }).always((jqXHR, textStatus, errorThrown) => { + console.log(jqXHR, textStatus, errorThrown); + }); + + // then method (as of 1.8) + $.ajax({ + url: "test.js" + }).then((data, textStatus, jqXHR) => { + console.log(data, textStatus, jqXHR); + }, (jqXHR, textStatus, errorThrown) => { + console.log(jqXHR, textStatus, errorThrown); + }); + + // jqXHR object + var jqXHR = $.ajax({ + url: "test.js" + }); + jqXHR.abort('aborting because I can'); +} + +function test_ajaxComplete() { + $('.log').ajaxComplete(function () { + $(this).text('Triggered ajaxComplete handler.'); + }); + $('.trigger').click(function () { + $('.result').load('ajax/test.html'); + }); + $('.log').ajaxComplete(function (e, xhr, settings) { + if (settings.url == 'ajax/test.html') { + $(this).text('Triggered ajaxComplete handler. The result is ' + xhr.responseText); + } + }); + $("#msg").ajaxComplete(function (event, request, settings) { + $(this).append("
  • Request Complete.
  • "); + }); +} + +function test_ajaxError() { + $("div.log").ajaxError(function () { + $(this).text("Triggered ajaxError handler."); + }); + $("button.trigger").click(function () { + $("div.result").load("ajax/missing.html"); + }); + $("div.log").ajaxError(function (e, jqxhr, settings, exception) { + if (settings.url == "ajax/missing.html") { + $(this).text("Triggered ajaxError handler."); + } + }); + $("#msg").ajaxError(function (event, request, settings) { + $(this).append("
  • Error requesting page " + settings.url + "
  • "); + }); +} + +function test_ajaxPrefilter() { + var currentRequests = {}; + $.ajaxPrefilter(function (options, originalOptions, jqXHR) { + if (options.abortOnRetry) { + if (currentRequests[options.url]) { + currentRequests[options.url].abort(); + } + currentRequests[options.url] = jqXHR; + } + }); + $.ajaxPrefilter(function (options) { + if (options.crossDomain) { + options.url = "http://mydomain.net/proxy/" + encodeURIComponent(options.url); + options.crossDomain = false; + } + }); + $.ajaxPrefilter("json script", function (options, originalOptions, jqXHR) { + + }); + var isActuallyScript; + $.ajaxPrefilter(function (options) { + if (isActuallyScript(options.url)) { + return "script"; + } + }); +} + +function test_ajaxSend() { + $('.log').ajaxSend(function () { + $(this).text('Triggered ajaxSend handler.'); + }); + $('.trigger').click(function () { + $('.result').load('ajax/test.html'); + }); + $('.log').ajaxSend(function (e, jqxhr, settings) { + if (settings.url == 'ajax/test.html') { + $(this).text('Triggered ajaxSend handler.'); + } + }); + $("#msg").ajaxSend(function (evt, request, settings) { + $(this).append("
  • Starting request at " + settings.url + "
  • "); + }); +} + +function test_ajaxSetup() { + $.ajaxSetup({ + url: 'ping.php' + }); + $.ajax({ + data: { 'name': 'Dan' } + }); + $.ajaxSetup({ + url: "/xmlhttp/", + global: false, + type: "POST" + }); +} + +function test_ajaxStart() { + $('.log').ajaxStart(function () { + $(this).text('Triggered ajaxStart handler.'); + }); + $('.trigger').click(function () { + $('.result').load('ajax/test.html'); + }); + $("#loading").ajaxStart(function () { + $(this).show(); + }); +} + +function test_ajaxStop() { + $('.log').ajaxStop(function () { + $(this).text('Triggered ajaxStop handler.'); + }); + $('.trigger').click(function () { + $('.result').load('ajax/test.html'); + }); + $("#loading").ajaxStop(function () { + $(this).hide(); + }); +} + +function test_ajaxSuccess() { + $('.log').ajaxSuccess(function () { + $(this).text('Triggered ajaxSuccess handler.'); + }); + $('.trigger').click(function () { + $('.result').load('ajax/test.html'); + }); + $('.log').ajaxSuccess(function (e, xhr, settings) { + if (settings.url == 'ajax/test.html') { + $(this).text('Triggered ajaxSuccess handler. The ajax response was:' + xhr.responseText); + } + }); + $("#msg").ajaxSuccess(function (evt, request, settings) { + $(this).append("
  • Successful Request!
  • "); + }); +} + +function test_allSelector() { + var elementCount = $("*").css("border", "3px solid red").length; + $("body").prepend("

    " + elementCount + " elements found

    "); + var elementCount2 = $("#test").find("*").css("border", "3px solid red").length; + $("body").prepend("

    " + elementCount2 + " elements found

    "); +} + +function test_animate() { + $('#clickme').click(function () { + $('#book').animate({ + opacity: 0.25, + left: '+=50', + height: 'toggle' + }, 5000, function () { + }); + }); + $('li').animate({ + opacity: .5, + height: '50%' + }, { + step: function (now, fx) { + var data = fx.elem.id + ' ' + fx.prop + ': ' + now; + $('body').append('
    ' + data + '
    '); + } + }); + $('#clickme').click(function () { + $('#book').animate({ + width: ['toggle', 'swing'], + height: ['toggle', 'swing'], + opacity: 'toggle' + }, 5000, 'linear', function () { + $(this).after('
    Animation complete.
    '); + }); + }); + $('#clickme').click(function () { + $('#book').animate({ + width: 'toggle', + height: 'toggle' + }, { + duration: 5000, + specialEasing: { + width: 'linear', + height: 'easeOutBounce' + }, + complete: function () { + $(this).after('
    Animation complete.
    '); + } + }); + }); + $("#go").click(function () { + $("#block").animate({ + width: "70%", + opacity: 0.4, + marginLeft: "0.6in", + fontSize: "3em", + borderWidth: "10px" + }, 1500); + }); + $("#right").click(function () { + $(".block").animate({ "left": "+=50px" }, "slow"); + }); + $("#left").click(function () { + $(".block").animate({ "left": "-=50px" }, "slow"); + }); + $("#go1").click(function () { + $("#block1").animate({ width: "90%" }, { queue: false, duration: 3000 }) + .animate({ fontSize: "24px" }, 1500) + .animate({ borderRightWidth: "15px" }, 1500); + }); + $("#go2").click(function () { + $("#block2").animate({ width: "90%" }, 1000) + .animate({ fontSize: "24px" }, 1000) + .animate({ borderLeftWidth: "15px" }, 1000); + }); + $("#go3").click(function () { + $("#go1").add("#go2").click(); + }); + $("#go4").click(function () { + $("div").css({ width: "", fontSize: "", borderWidth: "" }); + }); + $("#go").click(function () { + $(".block:first").animate({ + left: 100 + }, { + duration: 1000, + step: function (now, fx) { + $(".block:gt(0)").css("left", now); + } + }); + }); + $("p").animate({ + height: "toggle", opacity: "toggle" + }, "slow"); + $("p").animate({ + left: 50, opacity: 1 + }, 500); + $("p").animate({ + left: "50px", opacity: 1 + }, { duration: 500, queue: false }); + $("p").animate({ + opacity: "show" + }, "slow", "easein"); + $("p").animate({ + height: "toggle", opacity: "toggle" + }, { duration: "slow" }); + $("p").animate({ + opacity: "show" + }, { duration: "slow", easing: "easein" }); + $("p").animate({ + height: 200, width: 400, opacity: 0.5 + }, 1000, "linear", function () { + alert("all done"); + }); +} + +function test_animatedSelector() { + $("#run").click(function () { + $("div:animated").toggleClass("colored"); + }); + function animateIt() { + $("#mover").slideToggle("slow", animateIt); + } + animateIt(); +} + +function test_slideToggle() { + $("button").click(function () { + $("p").slideToggle("slow"); + }); + + $("#aa").click(function () { + $("div:not(.still)").slideToggle("slow", function () { + var n = parseInt($("span").text(), 10); + $("span").text(n + 1); + }); + }); +} + +function test_toggle() { + $(".target").toggle(); + + $("#clickme").click(function () { + $("#book").toggle("slow", function () { + // Animation complete. + }); + }); + + $("#foo").toggle(true); + + $("button").click(function () { + $("p").toggle(); + }); + + $("button").click(function () { + $("p").toggle("slow"); + }); + + var flip = 0; + $("button").click(function () { + $("p").toggle(flip++ % 2 === 0); + }); +} + +function test_append() { + $('.inner').append('

    Test

    '); + $('.container').append($('h2')); + + var $newdiv1 = $('
    '), + newdiv2 = document.createElement('div'), + existingdiv1 = document.getElementById('foo'); + + $('body').append($newdiv1, [newdiv2, existingdiv1]); +} + +function test_appendTo() { + $('

    Test

    ').appendTo('.inner'); + $('h2').appendTo($('.container')); +} + +function test_attr() { + var title = $("em").attr("title"); + $("div").text(title); + $('#greatphoto').attr('alt', 'Beijing Brush Seller'); + $('#greatphoto') + .attr('title', 'Photo by Kelly Clark'); + $('#greatphoto').attr({ + alt: 'Beijing Brush Seller', + title: 'photo by Kelly Clark' + }); + $('#greatphoto').attr('title', function (i, val) { + return val + ' - photo by Kelly Clark' + }); + $("div").attr("id", function (arr) { + return "div-id" + arr; + }) + .each(function () { + $("span", this).html("(ID = '" + this.id + "')"); + }); + $("img").attr("src", function () { + return "/images/" + this.title; + }); +} + +function test_attributeSelectors() { + $('a[hreflang|="en"]').css('border', '3px dotted green'); + $('input[name*="man"]').val('has man in it!'); + $('input[name~="man"]').val('mr. man is in it!'); + $('input[name$="letter"]').val('a letter'); + $('input[value="Hot Fuzz"]').next().text(" Hot Fuzz"); + $('input[name!="newsletter"]').next().append('; not newsletter'); + $('input[name^="news"]').val('news here!'); +} + +function test_before() { + $('.inner').before('

    Test

    '); + $('.container').before($('h2')); + $("
    ").before("

    "); + var $newdiv1 = $('
    '), + newdiv2 = document.createElement('div'), + existingdiv1 = document.getElementById('foo'); + $('p').first().before($newdiv1, [newdiv2, existingdiv1]); +} + +function test_bind() { + $('#foo').bind('click', function () { + alert('User clicked on "foo."'); + }); + $('#foo').bind('mouseenter mouseleave', function () { + $(this).toggleClass('entered'); + }); + $('#foo').bind({ + click: function () { }, + mouseenter: function () { } + }); + $('#foo').bind('click', function () { + alert($(this).text()); + }); + $(document).ready(function () { + $('#foo').bind('click', function (event) { + alert('The mouse cursor is at (' + + event.pageX + ', ' + event.pageY + ')'); + }); + }); + var message = 'Spoon!'; + $('#foo').bind('click', function () { + alert(message); + }); + message = 'Not in the face!'; + $('#bar').bind('click', function () { + alert(message); + }); + var message = 'Spoon!'; + $('#foo').bind('click', { msg: message }, function (event) { + alert(event.data.msg); + }); + message = 'Not in the face!'; + $('#bar').bind('click', { msg: message }, function (event) { + alert(event.data.msg); + }); + $("p").bind("click", function (event) { + var str = "( " + event.pageX + ", " + event.pageY + " )"; + $("span").text("Click happened! " + str); + }); + $("p").bind("dblclick", function () { + $("span").text("Double-click happened in " + this.nodeName); + }); + $("p").bind("mouseenter mouseleave", function (event) { + $(this).toggleClass("over"); + }); + $("p").bind("click", function () { + alert($(this).text()); + }); + function handler(event) { + alert(event.data.foo); + } + $("p").bind("click", { foo: "bar" }, handler) + $("form").bind("submit", function () { return false; }) + $("form").bind("submit", function (event) { + event.preventDefault(); + }); + $("form").bind("submit", function (event) { + event.stopPropagation(); + }); + $("p").bind("myCustomEvent", function (e, myName?, myValue?) { + $(this).text(myName + ", hi there!"); + $("span").stop().css("opacity", 1) + .text("myName = " + myName) + .fadeIn(30).fadeOut(1000); + }); + $("button").click(function () { + $("p").trigger("myCustomEvent", ["John"]); + }); + $("div.test").bind({ + click: function () { + $(this).addClass("active"); + }, + mouseenter: function () { + $(this).addClass("inside"); + }, + mouseleave: function () { + $(this).removeClass("inside"); + } + }); +} + +function test_unbind() { + $("#foo").unbind(); + + $("#foo").unbind("click"); + + var handler = function () { + alert("The quick brown fox jumps over the lazy dog."); + }; + $("#foo").bind("click", handler); + $("#foo").unbind("click", handler); + + $("#foo").bind("click", function () { + alert("The quick brown fox jumps over the lazy dog."); + }); + + // Will NOT work + $("#foo").unbind("click", function () { + alert("The quick brown fox jumps over the lazy dog."); + }); + + $("#foo").bind("click.myEvents", handler); + + $("#foo").unbind("click"); + + $("#foo").unbind("click.myEvents"); + + $("#foo").unbind(".myEvents"); + + var timesClicked = 0; + $("#foo").bind("click", function (event) { + alert("The quick brown fox jumps over the lazy dog."); + timesClicked++; + if (timesClicked >= 3) { + $(this).unbind(event); + } + }); + + function aClick() { + $("div").show().fadeOut("slow"); + } + $("#bind").click(function () { + $("#theone") + .bind("click", aClick) + .text("Can Click!"); + }); + $("#unbind").click(function () { + $("#theone") + .unbind("click", aClick) + .text("Does nothing..."); + }); + + $("p").unbind(); + + $("p").unbind("click"); + + var foo = function () { + // Code to handle some kind of event + }; + + $("p").bind("click", foo); // ... Now foo will be called when paragraphs are clicked ... + + $("p").unbind("click", foo); // ... foo will no longer be called. +} + +function test_blur() { + $('#target').blur(function () { + alert('Handler for .blur() called.'); + }); + $('#other').click(function () { + $('#target').blur(); + + }); + $("p").blur(); +} + +interface JQueryStatic { Topic; } +function test_callbacks() { + function fn1(value) { + console.log(value); + } + function fn2(value) { + fn1("fn2 says:" + value); + return false; + } + var callbacks = $.Callbacks(); + var callbacks2 = $.Callbacks("once"); + callbacks.add(fn1); + callbacks.fire("foo!"); + callbacks.add(fn2); + callbacks.fire("bar!"); + callbacks.remove(fn2); + callbacks.fire("foobar"); + var topics = {}; + + jQuery.Topic = function (id) { + var callbacks, + method, + topic = id && topics[id]; + if (!topic) { + callbacks = jQuery.Callbacks(); + topic = { + publish: callbacks.fire, + subscribe: callbacks.add, + unsubscribe: callbacks.remove + }; + if (id) { + topics[id] = topic; + } + } + return topic; + }; + $.Topic("mailArrived").subscribe(fn1); + $.Topic("mailArrived").subscribe(fn2); + $.Topic("mailSent").subscribe(fn1); + $.Topic("mailArrived").publish("hello world!"); + $.Topic("mailSent").publish("woo! mail!"); + $.Topic("mailArrived").subscribe(fn1); + + var dfd = $.Deferred(); + var topic = $.Topic("mailArrived"); + dfd.done(topic.publish); + dfd.resolve("its been published!"); +} + +function test_callbacksFunctions() { + var foo = function (value) { + console.log('foo:' + value); + } + var bar = function (value) { + console.log('bar:' + value); + } + var callbacks = $.Callbacks(); + callbacks.add(foo); + callbacks.fire('hello'); + callbacks.add(bar); + callbacks.fire('world'); + callbacks.disable(); + + // Test the disabled state of the list + console.log(callbacks.disabled()); + // Outputs: true + + callbacks.empty(); + callbacks.fire('hello'); + console.log(callbacks.fired()); + callbacks.fireWith(window, ['foo', 'bar']); + var foo2 = function (value1, value2) { + console.log('Received:' + value1 + ',' + value2); + }; + console.log(callbacks.has(foo2)); + callbacks.lock(); + console.log(callbacks.locked()); + callbacks.remove(foo); +} + +function test_change() { + $('.target').change(function () { + alert('Handler for .change() called.'); + }); + $('#other').click(function () { + $('.target').change(); + }); + $("input[type='text']").change(function () { }); + $("input[type='text']").change(); +} + +function test_children() { + $('ul.level-2').children().css('background-color', 'red'); + $("#container").click(function (e) { + $("*").removeClass("hilite"); + var $kids = $(e.target).children(); + var len = $kids.addClass("hilite").length; + + $("#results span:first").text(len); + //$("#results span:last").text(e.target.tagName); + + e.preventDefault(); + return false; + }); + $("div").children(".selected").css("color", "blue"); +} + +function test_clearQueue() { + $("#start").click(function () { + var myDiv = $("div"); + myDiv.show("slow"); + myDiv.animate({ left: '+=200' }, 5000); + myDiv.queue(function () { + var _this = $(this); + _this.addClass("newcolor"); + _this.dequeue(); + }); + myDiv.animate({ left: '-=200' }, 1500); + myDiv.queue(function () { + var _this = $(this); + _this.removeClass("newcolor"); + _this.dequeue(); + }); + myDiv.slideUp(); + + }); + $("#stop").click(function () { + var myDiv = $("div"); + myDiv.clearQueue(); + myDiv.stop(); + }); +} + +function test_click() { + $("#target").click(function () { + alert("Handler for .click() called."); + }); + $("#other").click(function () { + $("#target").click(); + }); + $("p").click(function () { + $(this).slideUp(); + }); + $("p").click(); +} + +function test_submit() { + $("#target").submit(function () { + alert("Handler for .submit() called."); + }); + $("#target").submit(); +} + +function test_trigger() { + + $("#foo").on("click", function () { + alert($(this).text()); + }); + $("#foo").trigger("click"); + + $("#foo").on("custom", function (event, param1?, param2?) { + alert(param1 + "\n" + param2); + }); + $("#foo").trigger("custom", ["Custom", "Event"]); + + $("button:first").click(function () { + update($("span:first")); + }); + + $("button:last").click(function () { + $("button:first").trigger("click"); + update($("span:last")); + }); + + function update(j) { + var n = parseInt(j.text(), 10); + j.text(n + 1); + } + + $("form:first").trigger("submit"); + + var event = jQuery.Event("submit"); + $("form:first").trigger(event); + if (event.isDefaultPrevented()) { + // Perform an action... + } + + $("p") + .click(function (event, a, b) { + // When a normal click fires, a and b are undefined + // for a trigger like below a refers to "foo" and b refers to "bar" + }) + .trigger("click", ["foo", "bar"]); + + var event = jQuery.Event("logged"); + (event).user = "foo"; + (event).pass = "bar"; + $("body").trigger(event); + + // Adapted from jQuery documentation which may be wrong on this occasion + var event2 = jQuery.Event("logged"); + $("body").trigger(event2, { + type: "logged", + user: "foo", + pass: "bar" + }); +} + +function test_clone() { + $('.hello').clone().appendTo('.goodbye'); + var $elem = $('#elem').data({ "arr": [1] }), + $clone = $elem.clone(true) + .data("arr", $.extend([], $elem.data("arr"))); + $("b").clone().prependTo("p"); + $('#copy').append($('#orig .elem') + .clone() + .children('a') + .prepend('foo - ') + .parent() + .clone()); +} + +function test_prependTo() { + $("

    Test

    ").prependTo(".inner"); + $("h2").prependTo($(".container")); + $("span").prependTo("#foo"); +} + +function test_closest() { + $('li.item-a').closest('ul') + .css('background-color', 'red'); + $('li.item-a').closest('li') + .css('background-color', 'red'); + var listItemII = document.getElementById('ii'); + $('li.item-a').closest('ul', listItemII) + .css('background-color', 'red'); + $('li.item-a').closest('#one', listItemII) + .css('background-color', 'green'); + $(document).bind("click", function (e) { + $(e.target).closest("li").toggleClass("hilight"); + }); + var $listElements = $("li").css("color", "blue"); + $(document).bind("click", function (e) { + //$(e.target).closest($listElements).toggleClass("hilight"); + }); +} + +function test_contains() { + jQuery.contains(document.documentElement, document.body); + jQuery.contains(document.body, document.documentElement); +} + +function test_contents() { + $('.container').contents().filter(function () { + return this.nodeType == 3; + }) + .wrap('

    ') + .end() + .filter('br') + .remove(); + $("#frameDemo").contents().find("a").css("background-color", "#BADA55"); +} + +function test_context() { + $("ul") + .append("
  • " + $("ul").context + "
  • ") + .append("
  • " + $("ul", document.body).context.nodeName + "
  • "); +} + +function test_css() { + $("div").click(function () { + var color = $(this).css("background-color"); + $("#result").html("That div is " + color + "."); + }); + $('div.example').css('width', function (index) { + return index * 50; + }); + $("p").mouseover(function () { + $(this).css("color", "red"); + }); + $("#box").one("click", function () { + $(this).css("width", "+=200"); + }); + var words = $("p:first").text().split(" "); + var text = words.join(" "); + $("p:first").html("" + text + ""); + $("span").click(function () { + $(this).css("background-color", "yellow"); + }); + $("p").hover(function () { + $(this).css({ 'background-color': 'yellow', 'font-weight': 'bolder' }); + }, function () { + var cssObj = { + 'background-color': '#ddd', + 'font-weight': '', + 'color': 'rgb(0,40,244)' + } + $(this).css(cssObj); + }); + $("div").click(function () { + $(this).css({ + width: function (index, value) { + return parseFloat(value) * 1.2; + }, + height: function (index, value) { + return parseFloat(value) * 1.2; + } + }); + }); + var dims = $("#box").css([ "width", "height", "backgroundColor" ]); +} + +function test_cssHooks() { + if (!$.cssHooks) { + throw ("jQuery 1.4.3 or above is required for this plugin to work"); + return; + } + $.cssHooks["someCSSProp"] = { + get: function (elem, computed, extra) { }, + set: function (elem, value) { } + }; + function styleSupport(prop) { + var vendorProp, supportedProp, + capProp = prop.charAt(0).toUpperCase() + prop.slice(1), + prefixes = ["Moz", "Webkit", "O", "ms"], + div = document.createElement("div"); + + if (prop in div.style) { + supportedProp = prop; + } else { + for (var i = 0; i < prefixes.length; i++) { + vendorProp = prefixes[i] + capProp; + if (vendorProp in div.style) { + supportedProp = vendorProp; + break; + } + } + } + div = null; + $.support[prop] = supportedProp; + return supportedProp; + } + styleSupport("borderRadius"); + + $.cssNumber["someCSSProp"] = true; + $.fx.step["someCSSProp"] = function (fx) { + $.cssHooks["someCSSProp"].set(fx.elem, fx.now + fx.unit); + }; +} + +function test_data() { + $('body').data('foo', 52); + $('body').data('bar', { myType: 'test', count: 40 }); + $('body').data('foo'); + $('body').data(); + $("div").data("test", { first: 16, last: "pizza!" }); + $("span:first").text($("div").data("test").first); + $("span:last").text($("div").data("test").last); + alert($('body').data('foo')); + alert($('body').data()); + alert($("body").data("foo")); + $("body").data("bar", "foobar"); + alert($("body").data("bar")); + $("div").data("role") === "page"; + $("div").data("lastValue") === 43; + $("div").data("hidden") === true; + $("div").data("options").name === "John"; + var value; + switch ($("button").index(this)) { + case 0: + value = $("div").data("blah"); + break; + case 1: + $("div").data("blah", "hello"); + value = "Stored!"; + break; + case 2: + $("div").data("blah", 86); + value = "Stored!"; + break; + case 3: + $("div").removeData("blah"); + value = "Removed!"; + break; + } + $("span").text("" + value); + jQuery.data(document.body, 'foo', 52); + jQuery.data(document.body, 'bar', 'test'); + var div = $("div")[0]; + jQuery.data(div, "test", { first: 16, last: "pizza!" }); + $("span:first").text(jQuery.data(div, "test").first); + $("span:last").text(jQuery.data(div, "test").last); + $.data(document.getElementById("id"), "", 8).toFixed(2); + $.data(document.getElementById("id"), "", "8").toUpperCase(); +} + +function test_removeData() { + $("span:eq(0)").text("" + $("div").data("test1")); + $("div").data("test1", "VALUE-1"); + $("div").data("test2", "VALUE-2"); + $("span:eq(1)").text("" + $("div").data("test1")); + $("div").removeData("test1"); + $("span:eq(2)").text("" + $("div").data("test1")); + $("span:eq(3)").text("" + $("div").data("test2")); +} + +function test_jQuery_removeData() { + var div = $("div")[0]; + $("span:eq(0)").text("" + $("div").data("test1")); + jQuery.data(div, "test1", "VALUE-1"); + jQuery.data(div, "test2", "VALUE-2"); + $("span:eq(1)").text("" + jQuery.data(div, "test1")); + jQuery.removeData(div, "test1"); + $("span:eq(2)").text("" + jQuery.data(div, "test1")); + $("span:eq(3)").text("" + jQuery.data(div, "test2")); +} + +function test_dblclick() { + $('#target').dblclick(function () { + alert('Handler for .dblclick() called.'); + }); + $('#other').click(function () { + $('#target').dblclick(); + }); + $("p").dblclick(function () { alert("Hello World!"); }); + var divdbl = $("div:first"); + divdbl.dblclick(function () { + divdbl.toggleClass('dbl'); + }); + $('#target').dblclick(); +} + +function test_delay() { + $('#foo').slideUp(300).delay(800).fadeIn(400); + $("button").click(function () { + $("div.first").slideUp(300).delay(800).fadeIn(400); + $("div.second").slideUp(300).fadeIn(400); + }); +} + +function test_delegate() { + $("table").delegate("td", "click", function () { + $(this).toggleClass("chosen"); + }); + $("table").on("click", "td", function () { + $(this).toggleClass("chosen"); + }); + $("body").delegate("p", "click", function () { + $(this).after("

    Another paragraph!

    "); + }); + $("body").delegate("p", "click", function () { + alert($(this).text()); + }); + $("body").delegate("a", "click", function () { return false; }); + $("body").delegate("a", "click", function (event) { + event.preventDefault(); + }); + $("body").delegate("p", "myCustomEvent", function (e, myName?, myValue?) { + $(this).text("Hi there!"); + $("span").stop().css("opacity", 1) + .text("myName = " + myName) + .fadeIn(30).fadeOut(1000); + }); + $("button").click(function () { + $("p").trigger("myCustomEvent"); + }); +} + +function test_undelegate() { + function aClick() { + $("div").show().fadeOut("slow"); + } + $("#bind").click(function () { + $("body") + .delegate("#theone", "click", aClick) + .find("#theone").text("Can Click!"); + }); + $("#unbind").click(function () { + $("body") + .undelegate("#theone", "click", aClick) + .find("#theone").text("Does nothing..."); + }); + + $("p").undelegate(); + + $("p").undelegate("click"); + + var foo = function () { + // Code to handle some kind of event + }; + + // ... Now foo will be called when paragraphs are clicked ... + $("body").delegate("p", "click", foo); + + // ... foo will no longer be called. + $("body").undelegate("p", "click", foo); + + var foo = function () { + // Code to handle some kind of event + }; + + // Delegate events under the ".whatever" namespace + $("form").delegate(":button", "click.whatever", foo); + + $("form").delegate("input[type='text'] ", "keypress.whatever", foo); + + // Unbind all events delegated under the ".whatever" namespace + $("form").undelegate(".whatever"); +} + +function test_dequeue() { + $("button").click(function () { + $("div").animate({ left: '+=200px' }, 2000); + $("div").animate({ top: '0px' }, 600); + $("div").queue(function () { + $(this).toggleClass("red"); + $(this).dequeue(); + }); + $("div").animate({ left: '10px', top: '30px' }, 700); + }); +} + +function test_queue() { + + $("#show").click(function () { + var n = jQuery.queue($("div")[0], "fx"); + $("span").text("Queue length is: " + n.length); + }); + + function runIt() { + $("div") + .show("slow") + .animate({ + left: "+=200" + }, 2000) + .slideToggle(1000) + .slideToggle("fast") + .animate({ + left: "-=200" + }, 1500) + .hide("slow") + .show(1200) + .slideUp("normal", runIt); + } + + runIt(); + + $(document.body).click(function () { + var divs = $("div") + .show("slow") + .animate({ left: "+=200" }, 2000); + jQuery.queue(divs[0], "fx", function () { + $(this).addClass("newcolor"); + jQuery.dequeue(this); + }); + divs.animate({ left: "-=200" }, 500); + jQuery.queue(divs[0], "fx", function () { + $(this).removeClass("newcolor"); + jQuery.dequeue(this); + }); + divs.slideUp(); + }); + + $("#start").click(function () { + var divs = $("div") + .show("slow") + .animate({ left: "+=200" }, 5000); + jQuery.queue(divs[0], "fx", function () { + $(this).addClass("newcolor"); + jQuery.dequeue(this); + }); + divs.animate({ left: "-=200" }, 1500); + jQuery.queue(divs[0], "fx", function () { + $(this).removeClass("newcolor"); + jQuery.dequeue(this); + }); + divs.slideUp(); + }); + $("#stop").click(function () { + jQuery.queue($("div")[0], "fx", []); + $("div").stop(); + }); +} + +function test_detach() { + $("p").click(function () { + $(this).toggleClass("off"); + }); + var p; + $("button").click(function () { + if (p) { + p.appendTo("body"); + p = null; + } else { + p = $("p").detach(); + } + }); +} + +function test_each() { + $.each([52, 97], function (index, value) { + alert(index + ': ' + value); + }); + var map = { + 'flammable': 'inflammable', + 'duh': 'no duh' + }; + $.each(map, function (key, value) { + alert(key + ': ' + value); + }); + var arr = ["one", "two", "three", "four", "five"]; + var obj = { one: 1, two: 2, three: 3, four: 4, five: 5 }; + jQuery.each(arr, function () { + $("#" + this).text("Mine is " + this + "."); + return (this != "three"); + }); + jQuery.each(obj, function (i, val) { + $("#" + i).append(document.createTextNode(" - " + val)); + }); + $.each(['a', 'b', 'c'], function (i, l) { + alert("Index #" + i + ": " + l); + }); + $.each({ name: "John", lang: "JS" }, function (k, v) { + alert("Key: " + k + ", Value: " + v); + }); + $.each([{a: 1}, {a: 2}, {a: 3}], function (i, o) { + alert("Index #" + i + ": " + o.a); + }); + $('li').each(function (index) { + alert(index + ': ' + $(this).text()); + }); + $(document.body).click(function () { + $("div").each(function (i) { + if (this.style.color != "blue") { + this.style.color = "blue"; + } else { + this.style.color = ""; + } + }); + }); + $("span").click(function () { + $("li").each(function () { + $(this).toggleClass("example"); + }); + }); + $("button").click(function () { + $("div").each(function (index, domEle) { + // domEle == this + $(domEle).css("backgroundColor", "yellow"); + if ($(this).is("#stop")) { + $("span").text("Stopped at div index #" + index); + return false; + } + }); + }); +} + +function test_empty() { + $('.hello').empty(); +} + +function test_end() { + $('ul.first').find('.foo').css('background-color', 'red') + .end().find('.bar').css('background-color', 'green'); + $('ul.first').find('.foo') + .css('background-color', 'red') + .end().find('.bar') + .css('background-color', 'green') + .end(); +} + +function test_eq() { + $('li').eq(2).css('background-color', 'red'); + $('li').eq(-2).css('background-color', 'red'); + $('li').eq(5).css('background-color', 'red'); + $("body").find("div").eq(2).addClass("blue"); +} + +function test_error() { + $('#book') + .error(function () { + alert('Handler for .error() called.') + }) + .attr("src", "missing.png"); + $("img") + .error(function () { + $(this).hide(); + }) + .attr("src", "missing.png"); + jQuery.error = (message?: string) => { + console.error(message); return this; + } +} + +function test_eventParams() { + $("p").click(function (event) { + event.currentTarget === this; + }); + $(".box").on("click", "button", function (event) { + $(event.delegateTarget).css("background-color", "red"); + }); + $("a").click(function (event) { + event.isDefaultPrevented(); + event.preventDefault(); + event.isDefaultPrevented(); + }); + function immediatePropStopped(e) { + var msg = ""; + if (e.isImmediatePropagationStopped()) { + msg = "called" + } else { + msg = "not called"; + } + $("#stop-log").append("
    " + msg + "
    "); + } + $("button").click(function (event) { + immediatePropStopped(event); + event.stopImmediatePropagation(); + immediatePropStopped(event); + }); + function propStopped(e) { + var msg = ""; + if (e.isPropagationStopped()) { + msg = "called" + } else { + msg = "not called"; + } + $("#stop-log").append("
    " + msg + "
    "); + } + $("button").click(function (event) { + propStopped(event); + event.stopPropagation(); + propStopped(event); + }); + $("p").bind("test.something", function (event) { + alert(event.namespace); + }); + $("button").click(function (event) { + $("p").trigger("test.something"); + }); + $(document).bind('mousemove', function (e) { + $("#log").text("e.pageX: " + e.pageX + ", e.pageY: " + e.pageY); + }); + $("a").click(function (event) { + event.preventDefault(); + $('
    ') + .append('default ' + event.type + ' prevented') + .appendTo('#log'); + }); + $("a").mouseout(function (event) { + alert(event.relatedTarget.nodeName); + }); + $("button").click(function (event) { + return "hey"; + }); + $("button").click(function (event) { + $("p").html(event.result); + }); + $("p").click(function (event) { + event.stopImmediatePropagation(); + }); + $("p").click(function (event) { + $(this).css("background-color", "#f00"); + }); + $("div").click(function (event) { + $(this).css("background-color", "#f00"); + }); + $("p").click(function (event) { + event.stopPropagation(); + }); + $("body").click(function (event) { + //bugfix, duplicate identifier. see: http://stackoverflow.com/questions/14824143/duplicate-identifier-nodename-in-jquery-d-ts + //$("#log").html("clicked: " + event.target.nodeName); + }); + $('#whichkey').bind('keydown', function (e) { + $('#log').html(e.type + ': ' + e.which); + }); + $('#whichkey').bind('mousedown', function (e) { + $('#log').html(e.type + ': ' + e.which); + }); + $(window).on('mousewheel', (e) => { + var delta = (e.originalEvent).deltaY; + }); +} + +function test_extend() { + var object1 = { + apple: 0, + banana: { weight: 52, price: 100 }, + cherry: 97 + }; + var object2 = { + banana: { price: 200 }, + durian: 100 + }; + $.extend(object1, object2); + var printObj = typeof JSON != "undefined" ? JSON.stringify : function (obj) { + var arr = []; + $.each(obj, function (key, val) { + var next = key + ": "; + next += $.isPlainObject(val) ? printObj(val) : val; + arr.push(next); + }); + return "{ " + arr.join(", ") + " }"; + }; + $("#log").append(printObj(object1)); + + var defaults = { validate: false, limit: 5, name: "foo" }; + var options = { validate: true, name: "bar" }; + var settings: typeof defaults = $.extend({}, defaults, options); +} + +function test_fadeIn() { + $('#clickme').click(function () { + $('#book').fadeIn('slow', function () { }); + }); + $(document.body).click(function () { + $("div:hidden:first").fadeIn("slow"); + }); + $("a").click(function () { + $("div").fadeIn(3000, function () { + $("span").fadeIn(100); + }); + return false; + }); +} + +function test_fadeOut() { + $('#clickme').click(function () { + $('#book').fadeOut('slow', function () { }); + }); + $("p").click(function () { + $("p").fadeOut("slow"); + }); + $("span").click(function () { + $(this).fadeOut(1000, function () { + $("div").text("'" + $(this).text() + "' has faded!"); + $(this).remove(); + }); + }); + $("span").hover(function () { + $(this).addClass("hilite"); + }, function () { + $(this).removeClass("hilite"); + }); + $("#btn1").click(function () { + function complete() { + $("
    ").text(this.id).appendTo("#log"); + } + $("#box1").fadeOut(1600, "linear", complete); + $("#box2").fadeOut(1600, complete); + }); + $("#btn2").click(function () { + $("div").show(); + $("#log").empty(); + }); +} + +function test_fadeTo() { + $('#clickme').click(function () { + $('#book').fadeTo('slow', 0.5, function () { }); + }); + $("p:first").click(function () { + $(this).fadeTo("slow", 0.33); + }); + $("div").click(function () { + $(this).fadeTo("fast", Math.random()); + }); + var getPos = function (n) { + return (Math.floor(n) * 90) + "px"; + }; + $("p").each(function (n) { + var r = Math.floor(Math.random() * 3); + var tmp = $(this).text(); + $(this).text($("p:eq(" + r + ")").text()); + $("p:eq(" + r + ")").text(tmp); + $(this).css("left", getPos(n)); + }); + $("div").each(function (n) { + $(this).css("left", getPos(n)); + }) + .css("cursor", "pointer") + .click(function () { + $(this).fadeTo(250, 0.25, function () { + $(this).css("cursor", "") + .prev().css({ + "font-weight": "bolder", + "font-style": "italic" + }); + }); + }); +} + +function test_fadeToggle() { + $("button:first").click(function () { + $("p:first").fadeToggle("slow", "linear"); + }); + $("button:last").click(function () { + $("p:last").fadeToggle("fast", function () { + $("#log").append("
    finished
    "); + }); + }); +} + +function test_filter() { + $('li').filter(':even').css('background-color', 'red'); + $('li').filter(function (index) { + return index % 3 == 2; + }).css('background-color', 'red'); + $("div").css("background", "#b4b0da") + .filter(function (index) { + return index == 1 || $(this).attr("id") == "fourth"; + }) + .css("border", "3px double red"); + $("div").filter(document.getElementById("unique")); + $("div").filter($("#unique")); +} + +function test_find() { + $('li.item-ii').find('li').css('background-color', 'red'); + var item1 = $('li.item-1')[0]; + $('li.item-ii').find(item1).css('background-color', 'red'); + var $spans = $('span'); + $("p").find($spans).css('color', 'red'); + var newText = $("p").text().split(" ").join(" "); + newText = "" + newText + ""; + $("p").html(newText) + .find('span') + .hover(function () { + $(this).addClass("hilite"); + }, + function () { + $(this).removeClass("hilite"); + }) + .end() + .find(":contains('t')") + .css({ "font-style": "italic", "font-weight": "bolder" }); +} + +function test_finish() { + $(".box").finish(); +} + +function test_first() { + $('li').first().css('background-color', 'red'); +} + +function test_focus() { + $('#target').focus(function () { + alert('Handler for .focus() called.'); + }); + $('#other').click(function () { + $('#target').focus(); + }); + $("input").focus(function () { + $(this).next("span").css('display', 'inline').fadeOut(1000); + }); + $("input[type=text]").focus(function () { + $(this).blur(); + }); + $(document).ready(function () { + $("#login").focus(); + }); +} + +function test_focusin() { + $("p").focusin(function () { + $(this).find("span").css('display', 'inline').fadeOut(1000); + }); +} + +function test_focusout() { + var fo = 0, b = 0; + $("p").focusout(function () { + fo++; + $("#fo") + .text("focusout fired: " + fo + "x"); + }).blur(function () { + b++; + $("#b") + .text("blur fired: " + b + "x"); + }); +} + +function test_fx() { + jQuery.fx.interval = 100; + $("input").click(function () { + $("div").toggle(3000); + }); + var toggleFx = function () { + $.fx.off = !$.fx.off; + }; + toggleFx(); + $("button").click(toggleFx) + $("input").click(function () { + $("div").toggle("slow"); + }); +} + +function test_get() { + $.get('ajax/test.html', function (data) { + $('.result').html(data); + alert('Load was performed.'); + }); + var jqxhr = $.get("example.php", function () { + alert("success"); + }) + .done(function () { alert("second success"); }) + .fail(function () { alert("error"); }); + + $.get("test.php"); + $.get("test.php", { name: "John", time: "2pm" }); + $.get("test.php", { 'choices[]': ["Jon", "Susan"] }); + $.get("test.php", function (data) { + alert("Data Loaded: " + data); + }); + $.get("test.cgi", { name: "John", time: "2pm" }, + function (data) { + alert("Data Loaded: " + data); + }); + $.get("test.php", + function (data) { + $('body').append("Name: " + data.name) + .append("Time: " + data.time); + }, "json"); + alert($('li').get()); + $('li').get(0); + $('li')[0]; + alert($('li').get(-1)); + function disp(divs) { + var a = []; + for (var i = 0; i < divs.length; i++) { + a.push(divs[i].innerHTML); + } + $("span").text(a.join(" ")); + } + disp($("div").get().reverse()); + $("*", document.body).click(function (e) { + e.stopPropagation(); + var domEl = $(this).get(0); + $("span:first").text("Clicked on - " + domEl.tagName); + }); +} + +function test_getJSON() { + $.getJSON('ajax/test.json', function (data) { + var items = []; + $.each(data, function (key, val) { + items.push('
  • ' + val + '
  • '); + }); + $('
      ', { + 'class': 'my-new-list', + html: items.join('') + }).appendTo('body'); + }); + var jqxhr = $.getJSON("example.json", function () { + alert("success"); + }) + .done(function () { alert("second success"); }) + .fail(function () { alert("error"); }); + $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?", + { + tags: "mount rainier", + tagmode: "any", + format: "json" + }, + function (data) { + $.each(data.items, function (i, item) { + $("").attr("src", item.media.m).appendTo("#images"); + if (i == 3) return false; + }); + }); + $.getJSON("test.js", function (json) { + alert("JSON Data: " + json.users[3].name); + }); + $.getJSON("test.js", { name: "John", time: "2pm" }, function (json) { + alert("JSON Data: " + json.users[3].name); + }); +} + +function test_getScript() { + $.getScript("ajax/test.js", function (data, textStatus, jqxhr) { + console.log(data); + console.log(textStatus); + console.log(jqxhr.status); + console.log('Load was performed.'); + }); + $.getScript("ajax/test.js") + .done(function (script, textStatus) { + console.log(textStatus); + }) + .fail(function (jqxhr, settings, exception) { + $("div.log").text("Triggered ajaxError handler."); + }); + $("div.log").ajaxError(function (e, jqxhr, settings, exception) { + if (settings.dataType == 'script') { + $(this).text("Triggered ajaxError handler."); + } + }); + $.ajaxSetup({ + cache: true + }); + $.getScript("/scripts/jquery.color.js", function () { + $("#go").click(function () { + $(".block").animate({ backgroundColor: "pink" }, 1000) + .delay(500) + .animate({ backgroundColor: "blue" }, 1000); + }); + }); +} + +function test_jQueryget() { + console.log($("li").get(0)); + console.log($("li")[0]); + console.log($("li").get(-1)); + $("*", document.body).click(function (event) { + event.stopPropagation(); + var domElement = $(this).get(0); + $("span:first").text("Clicked on - " + domElement.nodeName); + }); + + function display(divs) { + var a = []; + for (var i = 0; i < divs.length; i++) { + a.push(divs[i].innerHTML); + } + $("span").text(a.join(" ")); + } + display($("div").get().reverse()); +} + +function test_globalEval() { + jQuery.globalEval("var newVar = true;"); +} + +function test_grep() { + var arr = [1, 9, 3, 8, 6, 1, 5, 9, 4, 7, 3, 8, 6, 9, 1]; + $("div").text(arr.join(", ")); + arr = jQuery.grep(arr, function (n, i) { + return (n != 5 && i > 4); + }); + $("p").text(arr.join(", ")); + var arr2 = jQuery.grep(arr, function (a) { return a != 9; }); + $("span").text(arr.join(", ")); + $.grep([0, 1, 2], function (n, i) { + return n > 0; + }, true); + var arr3 = $.grep(["a", "b", "c"], function (n, i) { return n !== "b"; }); +} + +function test_has() { + $('li').has('ul').css('background-color', 'red'); + $("ul").append("
    • " + ($("ul").has("li").length ? "Yes" : "No") + "
    • "); + $("ul").has("li").addClass("full"); +} + +function test_hasClass() { + $('#mydiv').hasClass('foo'); + $("div#result1").append($("p:first").hasClass("selected").toString()); + $("div#result2").append($("p:last").hasClass("selected").toString()); + $("div#result3").append($("p").hasClass("selected").toString()); +} + +function test_hasData() { + var $p = jQuery("p"), p = $p[0]; + $p.append(jQuery.hasData(p) + " "); + $.data(p, "testing", 123); + $p.append(jQuery.hasData(p) + " "); + $.removeData(p, "testing"); + $p.append(jQuery.hasData(p) + " "); + $p.on('click', function () { }); + $p.append(jQuery.hasData(p) + " "); + $p.off('click'); + $p.append(jQuery.hasData(p) + " "); +} + +function test_jQuery_proxy() { + + function test1() { + var me = { + type: "zombie", + test: function (event?) { + // Without proxy, `this` would refer to the event target + // use event.target to reference that element. + var element = event.target; + $(element).css("background-color", "red"); + + // With proxy, `this` refers to the me object encapsulating + // this function. + $("#log").append("Hello " + this.type + "
      "); + $("#test").off("click", this.test); + } + }; + + var you = { + type: "person", + test: function (event?) { + $("#log").append(this.type + " "); + } + }; + + // Execute you.test() in the context of the `you` object + // no matter where it is called + // i.e. the `this` keyword will refer to `you` + var youClick = $.proxy(you.test, you); + + // attach click handlers to #test + $("#test") + // this === "zombie"; handler unbound after first click + .on("click", $.proxy(me.test, me)) + + // this === "person" + .on("click", youClick) + + // this === "zombie" + .on("click", $.proxy(you.test, me)) + + // this === " - I'm zeppelin Zeppelin + I'm zeppelin Zeppelin
  • Interpreter
  • -
    @@ -140,14 +146,51 @@

    {{setting.name}} Properties - + + - + + + + + + +
    namename valueaction
    {{key}} + + {{value.value | breakFilter}} + + +
    +
    +
    + + + + + +
    +
    +
    +
    + + +

    diff --git a/zeppelin-web/app/views/notebooks.html b/zeppelin-web/app/views/notebooks.html index 49cecddc..70ebbafb 100644 --- a/zeppelin-web/app/views/notebooks.html +++ b/zeppelin-web/app/views/notebooks.html @@ -18,12 +18,12 @@

    -

    {{note.name || 'Note ' + note.id}}

    + ng-show="showNameEditor" ng-model="note.name" ng-enter="sendNewName()" ng-delete="showNameEditor = false" autofocus/> +

    {{note.name || 'Note ' + note.id}}

    @@ -156,16 +156,16 @@
    Interpreter binding
    -
    -
    + ng-hide="paragraph.config.tableHide && viewOnly">
    diff --git a/zeppelin-web/app/views/paragraph.html b/zeppelin-web/app/views/paragraph.html index 2f81cc7d..3a45ec32 100644 --- a/zeppelin-web/app/views/paragraph.html +++ b/zeppelin-web/app/views/paragraph.html @@ -25,7 +25,7 @@ ng-model="paragraph.title" ng-show="showTitleEditor" ng-delete="showTitleEditor = false" - ng-enter="setTitle(); showTitleEditor = false"/> + ng-enter="commitParagraph(); showTitleEditor = false"/>
    @@ -34,7 +34,8 @@
    -
    + ng-class="{'disable': isRunningOrPending()}">
    -
    +
    -
    +
    -
    - {{getProgress()}}% +
    + {{currentProgress}}%
    @@ -70,21 +71,21 @@
    - +
    @@ -343,10 +157,10 @@
  • Hide title Show title
  • diff --git a/zeppelin-web/app/views/paragraph_result.html b/zeppelin-web/app/views/paragraph_result.html new file mode 100644 index 00000000..36dc1c8c --- /dev/null +++ b/zeppelin-web/app/views/paragraph_result.html @@ -0,0 +1,207 @@ + + +
    +
    + + + + + +
    + + + settings + + + settings + + + +
    + All fields: +
    +
      +
    • +
      + {{col.name | limitTo: 30}}{{col.name.length > 30 ? '...' : ''}} +
      +
    • +
    +
    + +
    +
    + + Keys +
      +
    • + +
    • +
    +
    +
    +
    + + Groups +
      +
    • + +
    • +
    +
    +
    +
    + + Values +
      +
    • +
      + + +
      +
    • +
    +
    +
    +
    +
    + +
    + +
    +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    + +
    +
    + +
    +
    + +
    +
    + +
    +
    + + + + +
    +
    + +
    +
    +
    diff --git a/zeppelin-web/bower.json b/zeppelin-web/bower.json index 856ad973..fe94c922 100644 --- a/zeppelin-web/bower.json +++ b/zeppelin-web/bower.json @@ -21,7 +21,8 @@ "perfect-scrollbar": "~0.5.4", "ng-sortable": "~1.1.9", "angular-elastic": "~2.4.2", - "angular-elastic-input": "~2.0.1" + "angular-elastic-input": "~2.0.1", + "angular-xeditable" : "0.1.8" }, "devDependencies": { "angular-mocks": "1.3.8", diff --git a/zeppelin-web/package.json b/zeppelin-web/package.json index 209cc383..c498e615 100644 --- a/zeppelin-web/package.json +++ b/zeppelin-web/package.json @@ -29,7 +29,8 @@ "grunt-karma": "~0.8.3", "karma-phantomjs-launcher": "~0.1.4", "karma": "~0.12.23", - "karma-jasmine": "~0.1.5" + "karma-jasmine": "~0.1.5", + "grunt-typescript": "" }, "engines": { "node": ">=0.10.0"