mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-31 11:40:47 +08:00
Merge remote-tracking branch 'remotes/upstream/master' into RxJS
Conflicts: knockout.rx/knockout.rx.d.ts
This commit is contained in:
@@ -28,6 +28,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [aws-sdk-js](https://github.com/aws/aws-sdk-js) (by [midknight41](https://github.com/midknight41))
|
||||
* [Backbone.js](http://backbonejs.org/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [Backbone Relational](http://backbonerelational.org/) (by [Eirik Hoem](https://github.com/eirikhm))
|
||||
* [big.js](https://github.com/MikeMcl/big.js) (by [Steve Ognibene](https://github.com/nycdotnet))
|
||||
* [BigInteger](https://github.com/peterolson/BigInteger.js) (by [Ingo Bürk](https://github.com/Airblader))
|
||||
* [BigScreen](http://brad.is/coding/BigScreen/) (by [Douglas Eichelberger](https://github.com/dduugg))
|
||||
* [Bluebird](https://github.com/petkaantonov/bluebird) (by [Bart van der Schoor](https://github.com/Bartvds))
|
||||
@@ -164,6 +165,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [jQuery.payment](http://needim.github.io/noty/) (by [Eric J. Smith](https://github.com/ejsmith/))
|
||||
* [jQuery.pickadate](https://github.com/amsul/pickadate.js) (by [Theodore Brown](https://github.com/theodorejb))
|
||||
* [jQuery.pjax](https://github.com/defunkt/jquery-pjax) (by [Junle Li](https://github.com/lijunle))
|
||||
* [jQuery.pjax.falsandtru](https://github.com/falsandtru/jquery.pjax.js/) (by [NewNotMoon](http://new.not-moon.net/))
|
||||
* [jQuery.pnotify](http://sciactive.github.io/pnotify/) (by [David Sichau](https://github.com/DavidSichau/))
|
||||
* [jQuery.postMessage](http://benalman.com/projects/jquery-postmessage-plugin/) (by [Junle Li](https://github.com/lijunle))
|
||||
* [jQuery.prettyphoto](https://github.com/scaron/prettyphoto) (by [Paul Gaske](https://github.com/pgaske))
|
||||
@@ -270,6 +272,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [Platform](https://github.com/bestiejs/platform.js) (by [Jake Hickman](https://github.com/JakeH))
|
||||
* [PouchDB](http://pouchdb.com) (by [Bill Sears](https://github.com/MrBigDog2U/))
|
||||
* [PreloadJS](http://www.createjs.com/#!/PreloadJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
|
||||
* [ProgressJs](http://usablica.github.io/progress.js/) (by [Shunsuke Ohtani](https://github.com/zaneli))
|
||||
* [Q](https://github.com/kriskowal/q) (by Barrie Nemetchek, Andrew Gaspar)
|
||||
* [Q-io](https://github.com/kriskowal/q-io) (by [Bart van der Schoor](https://github.com/Bartvds))
|
||||
* [QUnit](http://qunitjs.com/) (by [Diullei Gomes](https://github.com/Diullei))
|
||||
|
||||
@@ -153,21 +153,36 @@ function TestProtractor() {
|
||||
|
||||
ptor.debugger();
|
||||
|
||||
var webElement: protractor.WebElement = ptor.findElement(by.css('.class'));
|
||||
var promise: webdriver.promise.Promise;
|
||||
promise = ptor.findElements(by.css('.class'));
|
||||
promise = ptor.isElementPresent(by.css('.class'));
|
||||
promise = ptor.isElementPresent(webElement);
|
||||
|
||||
ptor.clearMockModules();
|
||||
ptor.addMockModule('name', 'script');
|
||||
ptor.addMockModule('name', function() {});
|
||||
ptor.removeMockModule('name');
|
||||
ptor.waitForAngular();
|
||||
|
||||
var elementFinder: protractor.ElementFinder;
|
||||
var elementArrayFinder: protractor.ElementArrayFinder;
|
||||
|
||||
elementFinder = ptor.element(by.id('ABC'));
|
||||
elementFinder = ptor.$('.class');
|
||||
|
||||
var elementArrayFinder: protractor.ElementArrayFinder = ptor.$$('.class');
|
||||
|
||||
var webElement: webdriver.WebElement = ptor.wrapWebElement(new webdriver.WebElement(driver, 'id'));
|
||||
elementArrayFinder = ptor.$$('.class');
|
||||
|
||||
var locationAbsUrl: webdriver.promise.Promise = ptor.getLocationAbsUrl();
|
||||
ptor.setLocation('webaddress.com');
|
||||
|
||||
promise = ptor.get('webaddress.com');
|
||||
promise = ptor.get('webdaddress.com', 45);
|
||||
ptor.refresh();
|
||||
ptor.refresh(45);
|
||||
var navigation: webdriver.WebDriverNavigation = ptor.navigate();
|
||||
ptor.pause();
|
||||
ptor.pause(8080);
|
||||
}
|
||||
|
||||
function TestElement() {
|
||||
@@ -180,6 +195,7 @@ function TestElementFinder() {
|
||||
var promise: webdriver.promise.Promise;
|
||||
|
||||
promise = elementFinder.click();
|
||||
promise = elementFinder.allowAnimations('string');
|
||||
promise = elementFinder.sendKeys(protractor.Key.UP, protractor.Key.DOWN);
|
||||
promise = elementFinder.getTagName();
|
||||
promise = elementFinder.getCssValue('display');
|
||||
@@ -195,19 +211,49 @@ function TestElementFinder() {
|
||||
promise = elementFinder.getOuterHtml();
|
||||
promise = elementFinder.getInnerHtml();
|
||||
promise = elementFinder.isElementPresent(by.id('id'));
|
||||
promise = elementFinder.isElementPresent(by.js('function(a, b, c) {}'), 1, 2, 3);
|
||||
promise = elementFinder.findElements(by.className('class'));
|
||||
promise = elementFinder.findElements(by.js('function(a, b, c) {}'), 1, 2, 3);
|
||||
promise = elementFinder.$('.class');
|
||||
promise = elementFinder.$$('.class');
|
||||
promise = elementFinder.evaluate('expression');
|
||||
promise = elementFinder.isPresent();
|
||||
|
||||
var webElement: webdriver.WebElement;
|
||||
}
|
||||
|
||||
webElement = elementFinder.$('.class');
|
||||
webElement = elementFinder.findElement(by.id('id'));
|
||||
webElement = elementFinder.findElement(by.js('function(a, b, c) {}'), 1, 2, 3);
|
||||
webElement = elementFinder.find();
|
||||
function TestElementArrayFinder() {
|
||||
var elementArrayFinder: protractor.ElementArrayFinder = element.all(by.id('id'));
|
||||
var promise: webdriver.promise.Promise;
|
||||
var elementFinder: protractor.ElementFinder;
|
||||
|
||||
var driverElementArray: webdriver.WebElement[] = elementArrayFinder.getWebElements();
|
||||
elementFinder = elementArrayFinder.get(42);
|
||||
elementFinder = elementArrayFinder.first();
|
||||
elementFinder = elementArrayFinder.last();
|
||||
promise = elementArrayFinder.count();
|
||||
promise = elementArrayFinder.asElementFinders_();
|
||||
elementArrayFinder.each(function(element: protractor.ElementFinder){
|
||||
// nothing
|
||||
});
|
||||
elementArrayFinder.map(function(element: protractor.ElementFinder, index: number){
|
||||
// nothing
|
||||
});
|
||||
elementArrayFinder.filter(function(element: protractor.ElementFinder, index: number){
|
||||
return element.getText().then((text: string) => {
|
||||
return text === "foo";
|
||||
});
|
||||
});
|
||||
elementArrayFinder.reduce(function(accumulator: string, element: protractor.ElementFinder){
|
||||
return element.getText().then((text: string) => {
|
||||
return accumulator + ',' + text;
|
||||
});
|
||||
}, '');
|
||||
elementArrayFinder.reduce(function(accumulator: string, element: protractor.ElementFinder, index: number, array: protractor.ElementFinder[]){
|
||||
return element.getText().then((text: string) => {
|
||||
return accumulator + ',' + text;
|
||||
});
|
||||
}, '');
|
||||
elementArrayFinder.then(function(underlyingElementFinders: protractor.ElementFinder[]){
|
||||
//nothing
|
||||
});
|
||||
}
|
||||
|
||||
// This function tests the angular specific locator strategies.
|
||||
@@ -216,29 +262,19 @@ function TestLocatorStrategies() {
|
||||
var webElement: webdriver.WebElement;
|
||||
|
||||
// Protractor Specific Locators
|
||||
protractor.By.addLocator('customLocator', 'script');
|
||||
protractor.By.addLocator('customLocator2', function(){
|
||||
// nothing
|
||||
});
|
||||
webElement = ptor.findElement(protractor.By.binding('binding'));
|
||||
webElement = ptor.findElement(protractor.By.select('select'));
|
||||
webElement = ptor.findElement(protractor.By.selectedOption('selectedOptions'));
|
||||
webElement = ptor.findElement(protractor.By.input('input'));
|
||||
webElement = ptor.findElement(protractor.By.exactBinding('exactBinding'));
|
||||
webElement = ptor.findElement(protractor.By.model('model'));
|
||||
webElement = ptor.findElement(protractor.By.textarea('textarea'));
|
||||
webElement = ptor.findElement(protractor.By.repeater('repeater'));
|
||||
webElement = ptor.findElement(protractor.By.repeater('repeater').column(0));
|
||||
webElement = ptor.findElement(protractor.By.repeater('repeater').row(0));
|
||||
webElement = ptor.findElement(protractor.By.repeater('repeater').row(0).column(0));
|
||||
webElement = ptor.findElement(protractor.By.buttonText('buttonText'));
|
||||
webElement = ptor.findElement(protractor.By.partialButtonText('partialButtonText'));
|
||||
}
|
||||
|
||||
// This function tests the methods that were added to the base WebElement class
|
||||
function TestWebElements() {
|
||||
var ptor: protractor.Protractor = protractor.getInstance();
|
||||
|
||||
var webElement: protractor.WebElement;
|
||||
var promise: webdriver.promise.Promise;
|
||||
|
||||
webElement = ptor.findElement(by.id('id')).$('.class');
|
||||
promise = ptor.findElement(by.id('id')).$$('.class');
|
||||
promise = ptor.findElement(by.id('id')).evaluate('something');
|
||||
|
||||
webElement = webElement.findElement(by.id('id')).$('.class');
|
||||
promise = webElement.findElement(by.id('id')).$$('.class');
|
||||
promise = webElement.findElement(by.id('id')).evaluate('something');
|
||||
webElement = ptor.findElement(protractor.By.cssContainingText('cssSelector', 'search text'));
|
||||
webElement = ptor.findElement(protractor.By.options('options'));
|
||||
}
|
||||
|
||||
+525
-272
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Angular Protractor 0.17.0
|
||||
// Type definitions for Angular Protractor 1.0.0-rc4
|
||||
// Project: https://github.com/angular/protractor
|
||||
// Definitions by: Bill Armstrong <https://github.com/BillArmstrong>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -25,71 +25,7 @@ declare module protractor {
|
||||
class CommandName extends webdriver.CommandName {}
|
||||
class Key extends webdriver.Key {}
|
||||
class UnhandledAlertError extends webdriver.UnhandledAlertError {}
|
||||
|
||||
class WebElement extends webdriver.WebElement {
|
||||
/**
|
||||
* Shortcut for querying the document directly with css.
|
||||
*
|
||||
* @param {string} selector a css selector
|
||||
* @see webdriver.WebElement.findElement
|
||||
* @return {!protractor.WebElement}
|
||||
*/
|
||||
$(selector: string): protractor.WebElement;
|
||||
|
||||
/**
|
||||
* Shortcut for querying the document directly with css.
|
||||
*
|
||||
* @param {string} selector a css selector
|
||||
* @see webdriver.WebElement.findElements
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved to an
|
||||
* array of the located {@link webdriver.WebElement}s.
|
||||
*/
|
||||
$$(selector: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Evalates the input as if it were on the scope of the current element.
|
||||
* @param {string} expression
|
||||
*
|
||||
* @return {!webdriver.promise.Promise} A promise that will resolve to the
|
||||
* evaluated expression. The result will be resolved as in
|
||||
* {@link webdriver.WebDriver.executeScript}. In summary - primitives will
|
||||
* be resolved as is, functions will be converted to string, and elements
|
||||
* will be returned as a WebElement.
|
||||
*/
|
||||
evaluate(expression: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedule a command to find a descendant of this element. If the element
|
||||
* cannot be found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will
|
||||
* be returned by the driver. Unlike other commands, this error cannot be
|
||||
* suppressed. In other words, scheduling a command to find an element doubles
|
||||
* as an assert that the element is present on the page. To test whether an
|
||||
* element is present on the page, use {@code #isElementPresent} instead.
|
||||
* <p/>
|
||||
* The search criteria for find an element may either be a
|
||||
* {@code webdriver.Locator} object, or a simple JSON object whose sole key
|
||||
* is one of the accepted locator strategies, as defined by
|
||||
* {@code webdriver.Locator.Strategy}. For example, the following two
|
||||
* statements are equivalent:
|
||||
* <code><pre>
|
||||
* var e1 = element.findElement(By.id('foo'));
|
||||
* var e2 = element.findElement({id:'foo'});
|
||||
* </pre></code>
|
||||
* <p/>
|
||||
* Note that JS locator searches cannot be restricted to a subtree. All such
|
||||
* searches are delegated to this instance's parent WebDriver.
|
||||
*
|
||||
* @param {webdriver.Locator|Object.<string>} locator The locator
|
||||
* strategy to use when searching for the element.
|
||||
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
|
||||
* using a JavaScript locator. Otherwise ignored.
|
||||
* @return {protractor.WebElement} A WebElement that can be used to issue
|
||||
* commands against the located element. If the element is not found, the
|
||||
* element will be invalidated and all scheduled commands aborted.
|
||||
*/
|
||||
findElement(locator: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
|
||||
findElement(locator: any, ...var_args: any[]): protractor.WebElement;
|
||||
}
|
||||
class WebElement extends webdriver.WebElement {}
|
||||
|
||||
module command {
|
||||
class Command extends webdriver.Command {}
|
||||
@@ -273,13 +209,140 @@ declare module protractor {
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
/**
|
||||
* Use as: element(locator)
|
||||
*
|
||||
* The ElementFinder can be treated as a WebElement for most purposes, in
|
||||
* particular, you may perform actions (i.e. click, getText) on them as you
|
||||
* would a WebElement. ElementFinders extend Promise, and once an action
|
||||
* is performed on an ElementFinder, the latest result from the chain can be
|
||||
* accessed using then. Unlike a WebElement, an ElementFinder will wait for
|
||||
* angular to settle before performing finds or actions.
|
||||
*
|
||||
* ElementFinder can be used to build a chain of locators that is used to find
|
||||
* an element. An ElementFinder does not actually attempt to find the element
|
||||
* until an action is called, which means they can be set up in helper files
|
||||
* before the page is available.
|
||||
*
|
||||
* @param {webdriver.Locator} locator An element locator.
|
||||
* @return {ElementFinder}
|
||||
*/
|
||||
interface Element {
|
||||
(locator: webdriver.Locator): ElementFinder;
|
||||
|
||||
/**
|
||||
* ElementArrayFinder is used for operations on an array of elements (as opposed
|
||||
* to a single element).
|
||||
*
|
||||
* @param {webdriver.Locator} locator An element locator.
|
||||
* @return {ElementArrayFinder}
|
||||
*/
|
||||
all(locator: webdriver.Locator): ElementArrayFinder;
|
||||
}
|
||||
|
||||
interface ElementFinder {
|
||||
/**
|
||||
* Use as: element(locator).element(locator)
|
||||
* Calls to element may be chained to find elements within a parent.
|
||||
*
|
||||
* @param {webdriver.Locator} locator The locator that will be used to find descendents.
|
||||
*
|
||||
* @return {protractor.ElementFinder} The descendent element found by the locator
|
||||
*/
|
||||
element(locator: webdriver.Locator): protractor.ElementFinder;
|
||||
|
||||
/**
|
||||
* Use as: element(locator).all(locator)
|
||||
* Calls to element may be chained to find an array of elements within a parent.
|
||||
*
|
||||
* @param {webdriver.Locator} locator The locator that will be used to find descendents.
|
||||
*
|
||||
* @return {protractor.ElementArrayFinder} The descendent elements found by the locator
|
||||
*/
|
||||
all(locator: webdriver.Locator): protractor.ElementArrayFinder;
|
||||
|
||||
/**
|
||||
* Shortcut for querying the document directly with css.
|
||||
*
|
||||
* @param {string} selector a css selector
|
||||
* @see webdriver.WebElement.findElement
|
||||
* @return {!protractor.WebElement}
|
||||
*/
|
||||
$(selector: string): protractor.WebElement;
|
||||
|
||||
/**
|
||||
* Shortcut for querying the document directly with css.
|
||||
*
|
||||
* @param {string} selector a css selector
|
||||
* @see webdriver.WebElement.findElements
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved to an
|
||||
* array of the located {@link webdriver.WebElement}s.
|
||||
*/
|
||||
$$(selector: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Use as: element(locator).isPresent()
|
||||
* Determine whether the element is present on the page.
|
||||
*
|
||||
* @return {protractor.ElementFinder} Which resolves to whether the element is present on the page.
|
||||
*/
|
||||
isPresent(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Override for WebElement.prototype.isElementPresent so that protractor waits
|
||||
* for Angular to settle before making the check.
|
||||
*
|
||||
* @see ElementFinder.isPresent
|
||||
* @return {!webdriver.promise.Promise} which resolves to whether the element is present on the page.
|
||||
*/
|
||||
isElementPresent(locator: webdriver.Locator): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Return this ElementFinder's locator.
|
||||
*
|
||||
* @return {webdriver.Locator}
|
||||
*/
|
||||
locator(): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Use as: element(locator).getWebElement()
|
||||
* Returns the WebElement represented by this ElementFinder.
|
||||
* Throws the WebDriver error if the element doesn't exist.
|
||||
* If index is null, it makes sure that there is only one underlying WebElement
|
||||
* described by the chain of locators and issues a warning otherwise.
|
||||
* If index is not null, it retrieves the WebElement specified by the index..
|
||||
* @return {webdriver.WebElement} The WebElement represented by the ElementFinder.
|
||||
*/
|
||||
getWebElement(): webdriver.WebElement;
|
||||
|
||||
/**
|
||||
* Evalates the input as if it were on the scope of the current element.
|
||||
* @param {string} expression
|
||||
*
|
||||
* @return {!webdriver.promise.Promise} A promise that will resolve to the
|
||||
* evaluated expression. The result will be resolved as in
|
||||
* {@link webdriver.WebDriver.executeScript}. In summary - primitives will
|
||||
* be resolved as is, functions will be converted to string, and elements
|
||||
* will be returned as a WebElement.
|
||||
*/
|
||||
evaluate(expression: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Determine if animation is allowed on the current element.
|
||||
* @param {string} value
|
||||
*
|
||||
* @return {ElementFinder} which resolves to whether animation is allowed.
|
||||
*/
|
||||
allowAnimations(value: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Access the underlying actionResult of ElementFinder. Implementation allows ElementFinder to be used as a webdriver.promise.Promise.
|
||||
* @param {function(webdriver.promise.Promise)} fn Function which takes the value of the underlying actionResult.
|
||||
*
|
||||
* @return {webdriver.promise.Promise} Promise which contains the results of evaluating fn.
|
||||
*/
|
||||
then(fn: IThenFunction): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to click on this element.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved when
|
||||
@@ -460,113 +523,163 @@ declare module protractor {
|
||||
getInnerHtml(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to test if there is at least one descendant of this
|
||||
* element that matches the given search criteria.
|
||||
*
|
||||
* <p>Note that JS locator searches cannot be restricted to a subtree of the
|
||||
* DOM. All such searches are delegated to this instance's parent WebDriver.
|
||||
*
|
||||
* @param {webdriver.Locator|Object.<string>} locator The locator
|
||||
* strategy to use when searching for the element.
|
||||
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
|
||||
* using a JavaScript locator. Otherwise ignored.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with
|
||||
* whether an element could be located on the page.
|
||||
* @return {!webdriver.promise.Promise.<webdriver.WebElement.Id>} A promise
|
||||
* that resolves to this element's JSON representation as defined by the
|
||||
* WebDriver wire protocol.
|
||||
* @see http://code.google.com/p/selenium/wiki/JsonWireProtocol
|
||||
*/
|
||||
isElementPresent(locator: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise;
|
||||
isElementPresent(locator: any, ...var_args: any[]): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to find all of the descendants of this element that match
|
||||
* the given search criteria.
|
||||
* <p/>
|
||||
* Note that JS locator searches cannot be restricted to a subtree. All such
|
||||
* searches are delegated to this instance's parent WebDriver.
|
||||
*
|
||||
* @param {webdriver.Locator|Object.<string>} locator The locator
|
||||
* strategy to use when searching for the elements.
|
||||
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
|
||||
* using a JavaScript locator. Otherwise ignored.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with an
|
||||
* array of located {@link webdriver.WebElement}s.
|
||||
*/
|
||||
findElements(locator: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise;
|
||||
findElements(locator: any, ...var_args: any[]): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Shortcut for querying the document directly with css.
|
||||
*
|
||||
* @param {string} selector a css selector
|
||||
* @see webdriver.WebElement.findElement
|
||||
* @return {!protractor.WebElement}
|
||||
*/
|
||||
$(selector: string): protractor.WebElement;
|
||||
|
||||
/**
|
||||
* Shortcut for querying the document directly with css.
|
||||
*
|
||||
* @param {string} selector a css selector
|
||||
* @see webdriver.WebElement.findElements
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved to an
|
||||
* array of the located {@link webdriver.WebElement}s.
|
||||
*/
|
||||
$$(selector: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedule a command to find a descendant of this element. If the element
|
||||
* cannot be found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will
|
||||
* be returned by the driver. Unlike other commands, this error cannot be
|
||||
* suppressed. In other words, scheduling a command to find an element doubles
|
||||
* as an assert that the element is present on the page. To test whether an
|
||||
* element is present on the page, use {@code #isElementPresent} instead.
|
||||
* <p/>
|
||||
* The search criteria for find an element may either be a
|
||||
* {@code webdriver.Locator} object, or a simple JSON object whose sole key
|
||||
* is one of the accepted locator strategies, as defined by
|
||||
* {@code webdriver.Locator.Strategy}. For example, the following two
|
||||
* statements are equivalent:
|
||||
* <code><pre>
|
||||
* var e1 = element.findElement(By.id('foo'));
|
||||
* var e2 = element.findElement({id:'foo'});
|
||||
* </pre></code>
|
||||
* <p/>
|
||||
* Note that JS locator searches cannot be restricted to a subtree. All such
|
||||
* searches are delegated to this instance's parent WebDriver.
|
||||
*
|
||||
* @param {webdriver.Locator|Object.<string>} locator The locator
|
||||
* strategy to use when searching for the element.
|
||||
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
|
||||
* using a JavaScript locator. Otherwise ignored.
|
||||
* @return {protractor.WebElement} A WebElement that can be used to issue
|
||||
* commands against the located element. If the element is not found, the
|
||||
* element will be invalidated and all scheduled commands aborted.
|
||||
*/
|
||||
findElement(locator: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
|
||||
findElement(locator: any, ...var_args: any[]): protractor.WebElement;
|
||||
|
||||
/**
|
||||
* Evalates the input as if it were on the scope of the current element.
|
||||
* @param {string} expression
|
||||
*
|
||||
* @return {!webdriver.promise.Promise} A promise that will resolve to the
|
||||
* evaluated expression. The result will be resolved as in
|
||||
* {@link webdriver.WebDriver.executeScript}. In summary - primitives will
|
||||
* be resolved as is, functions will be converted to string, and elements
|
||||
* will be returned as a WebElement.
|
||||
*/
|
||||
evaluate(expression: string): webdriver.promise.Promise;
|
||||
|
||||
find(): protractor.WebElement;
|
||||
|
||||
isPresent(): webdriver.promise.Promise;
|
||||
toWireValue(): webdriver.promise.Promise;
|
||||
}
|
||||
|
||||
interface ElementArrayFinder{
|
||||
interface IThenFunction {
|
||||
(promiseResult: any): any;
|
||||
}
|
||||
|
||||
|
||||
interface ElementArrayFinder {
|
||||
/**
|
||||
* Use as: element.all(locator).getWebElements()
|
||||
* Returns the array of WebElements represented by this ElementArrayFinder.
|
||||
*
|
||||
* @return {Array.<webdriver.WebElement>} Array of WebElements represented by this ElementArrayFinder
|
||||
*/
|
||||
getWebElements(): webdriver.WebElement[];
|
||||
|
||||
/**
|
||||
* Use as: element.all(locator).get(index)
|
||||
* Get an element found by the locator by index. The index starts at 0. This does not actually retrieve the underlying element.
|
||||
*
|
||||
* @param {number} index Element index.
|
||||
*
|
||||
* @return {protractor.ElementFinder} Finder representing element at the given index
|
||||
*/
|
||||
get(index: number): protractor.ElementFinder;
|
||||
|
||||
|
||||
/**
|
||||
* Use as: element.all(locator).first()
|
||||
* Get the first matching element for the locator. This does not actually retrieve the underlying element.
|
||||
*
|
||||
* @return {Protractor.ElementFinder} Finder representing the first matching element
|
||||
*/
|
||||
first(): protractor.ElementFinder;
|
||||
|
||||
/**
|
||||
* Use as: element.all(locator).last()
|
||||
* Get the last matching element for the locator. This does not actually retrieve the underlying element.
|
||||
*
|
||||
* @return {Protractor.ElementFinder} Finder representing the last matching element
|
||||
*/
|
||||
last(): protractor.ElementFinder;
|
||||
|
||||
/**
|
||||
* Use as: element.all(locator).getWebElements()
|
||||
* Returns the array of WebElements represented by this ElementArrayFinder.
|
||||
*
|
||||
* @return {!webdriver.promise.Promise} The array of WebElements represented by this ElementArrayFinder
|
||||
*/
|
||||
count(): webdriver.promise.Promise;
|
||||
get(index: number): protractor.WebElement;
|
||||
first(): protractor.WebElement;
|
||||
last(): protractor.WebElement;
|
||||
then(fn: (value: any) => any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Use as: element.all(locator).each(eachFunction)
|
||||
* Calls the input function on each ElementFinder found by the locator.
|
||||
*
|
||||
* @param {function(ElementFinder)} fn Input function.
|
||||
*/
|
||||
each(fn: IEachFunction): void;
|
||||
|
||||
/**
|
||||
* Use as: element.all(locator).map(mapFunction)
|
||||
* Apply a map function to each element found using the locator. The callback receives the ElementFinder as the first argument and the index as a second arg.
|
||||
*
|
||||
* @param {function(ElementFinder, number)} mapFn Map function that will be applied to each element.
|
||||
*
|
||||
* @return {!webdriver.promise.Promise} A promise that resolves to an array of values returned by the map function.
|
||||
*/
|
||||
map(mapFn: IMapFunction): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Use as: element.all(locator).filter(filterFn)
|
||||
* Apply a filter function to each element found using the locator. Returns promise of a new array with all elements that pass the filter function. The filter function receives the ElementFinder as the first argument and the index as a second arg.
|
||||
*
|
||||
* @param {function(ElementFinder, number): webdriver.promise.Promise} filterFn Filter function that will test if an element should be returned. filterFn should return a promise that resolves to a boolean.
|
||||
*
|
||||
* @return {!webdriver.promise.Promise} A promise that resolves to an array of ElementFinders that satisfy the filter function.
|
||||
*/
|
||||
filter(func: IFilterFunction): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Use as: element.all(locator).reduce(reduceFn)
|
||||
* Apply a reduce function against an accumulator and every element found using the locator (from left-to-right).
|
||||
* The reduce function has to reduce every element into a single value (the accumulator).
|
||||
* Returns promise of the accumulator.
|
||||
* The reduce function receives the accumulator, current ElementFinder, the index, and the entire array of ElementFinders, respectively.
|
||||
*
|
||||
* @param {function(number, ElementFinder, number, Array.<ElementFinder>): webdriver.promise.Promise} reduceFn Reduce function that reduces every element into a single value.
|
||||
* @param {*} initialValue Initial value of the accumulator.
|
||||
*
|
||||
* @return {!webdriver.promise.Promise} A promise that resolves to the final value of the accumulator.
|
||||
*/
|
||||
reduce(func: IReductionFunction, initialValue: any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Represents the ElementArrayFinder as an array of ElementFinders.
|
||||
*
|
||||
* @return {!webdriver.promise.Promise} Return a promise, which resolves to a list (array)
|
||||
* of ElementFinders specified by the locator.
|
||||
*/
|
||||
asElementFinders_(): webdriver.promise.Promise;
|
||||
|
||||
|
||||
/**
|
||||
* Find the elements specified by the locator. The input function is passed
|
||||
* to the resulting promise, which resolves to an array of ElementFinders.
|
||||
*
|
||||
* Use as: element.all(locator).then(thenFunction)
|
||||
* <ul class="items">
|
||||
* <li>First</li>
|
||||
* <li>Second</li>
|
||||
* <li>Third</li>
|
||||
* </ul>
|
||||
*
|
||||
* element.all(by.css('.items li')).then(function(arr) {
|
||||
* expect(arr.length).toEqual(3);
|
||||
* });
|
||||
*
|
||||
* @param {function(Array.<ElementFinder>)} fn
|
||||
*
|
||||
* @type {webdriver.promise.Promise} a promise which will resolve to
|
||||
* an array of ElementFinders matching the locator.
|
||||
*/
|
||||
then(fn: IElementArrayFinderThenFunction): webdriver.promise.Promise;
|
||||
}
|
||||
|
||||
interface IEachFunction {
|
||||
(element: protractor.ElementFinder): void;
|
||||
}
|
||||
|
||||
interface IMapFunction {
|
||||
(element: ElementFinder, index: number): any;
|
||||
}
|
||||
|
||||
interface IFilterFunction {
|
||||
(element: ElementFinder, index: number): webdriver.promise.Promise;
|
||||
}
|
||||
|
||||
interface IReductionFunction {
|
||||
(accumulator: any, element: protractor.ElementFinder, index?: number, array?: protractor.ElementFinder[]): webdriver.promise.Promise;
|
||||
}
|
||||
|
||||
interface IElementArrayFinderThenFunction {
|
||||
(promiseResult: ElementFinder[]): any;
|
||||
}
|
||||
|
||||
class LocatorWithColumn extends webdriver.Locator {
|
||||
column(index: number): webdriver.Locator;
|
||||
}
|
||||
|
||||
class RepeaterLocator extends LocatorWithColumn {
|
||||
row(index: number): LocatorWithColumn;
|
||||
}
|
||||
|
||||
interface IProtractorLocatorStrategy extends webdriver.ILocatorStrategy {
|
||||
@@ -587,69 +700,160 @@ declare module protractor {
|
||||
* Usage:
|
||||
* <span>{{status}}</span>
|
||||
* var status = element(by.binding('{{status}}'));
|
||||
*
|
||||
* @param {string} bindingDescriptor
|
||||
* @return {webdriver.Locator}
|
||||
*/
|
||||
binding(bindingDescriptor: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <select ng-model="user" ng-options="user.name for user in users"></select>
|
||||
* element(by.select("user"));
|
||||
* Find an element by exact binding.
|
||||
*
|
||||
* <span>{{ person.name }}</span>
|
||||
* <span ng-bind="person-email"></span>
|
||||
* <span>{{person_phone|uppercase}}</span>
|
||||
*
|
||||
* expect(element(by.exactBinding('person.name')).isPresent()).toBe(true);
|
||||
* expect(element(by.exactBinding('person-email')).isPresent()).toBe(true);
|
||||
* expect(element(by.exactBinding('person')).isPresent()).toBe(false);
|
||||
* expect(element(by.exactBinding('person_phone')).isPresent()).toBe(true);
|
||||
* expect(element(by.exactBinding('person_phone|uppercase')).isPresent()).toBe(true);
|
||||
* expect(element(by.exactBinding('phone')).isPresent()).toBe(false);
|
||||
*
|
||||
* @param {string} bindingDescriptor
|
||||
* @return {webdriver.Locator}
|
||||
*/
|
||||
select(model: string): webdriver.Locator;
|
||||
exactBinding(bindingDescriptor: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
*
|
||||
* Find an element by ng-model expression.
|
||||
*
|
||||
* Usage:
|
||||
* <select ng-model="user" ng-options="user.name for user in users"></select>
|
||||
* element(by.selectedOption("user"));
|
||||
*/
|
||||
selectedOption(model: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* @DEPRECATED - use 'model' instead.
|
||||
* Usage:
|
||||
* <input ng-model="user" type="text"/>
|
||||
* element(by.input('user'));
|
||||
*/
|
||||
input(model: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <input ng-model="user" type="text"/>
|
||||
* element(by.model('user'));
|
||||
* <input type="text" ng-model="person.name"/>
|
||||
* var input = element(by.model('person.name'));
|
||||
* input.sendKeys('123');
|
||||
* expect(input.getAttribute('value')).toBe('Foo123');
|
||||
*
|
||||
* @param {string} model ng-model expression.
|
||||
* @return {webdriver.Locator}
|
||||
*/
|
||||
model(model: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <textarea ng-model="user"></textarea>
|
||||
* element(by.textarea("user"));
|
||||
*/
|
||||
textarea(model: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <div ng-repeat = "cat in pets">
|
||||
* <span>{{cat.name}}</span>
|
||||
* <span>{{cat.age}}</span>
|
||||
* </div>
|
||||
* Find a button by text.
|
||||
*
|
||||
* // Returns the DIV for the second cat.
|
||||
* var secondCat = element(by.repeater("cat in pets").row(2));
|
||||
* // Returns the SPAN for the first cat's name.
|
||||
* var firstCatName = element(
|
||||
* by.repeater("cat in pets").row(1).column("{{cat.name}}"));
|
||||
* // Returns a promise that resolves to an array of WebElements from a column
|
||||
* var ages = element(
|
||||
* by.repeater("cat in pets").column("{{cat.age}}"));
|
||||
* // Returns a promise that resolves to an array of WebElements containing
|
||||
* // all rows of the repeater.
|
||||
* var rows = element(by.repeater("cat in pets"));
|
||||
* Usage:
|
||||
* <button>Save</button>
|
||||
* element(by.buttonText('Save'));
|
||||
*
|
||||
* @param {string} searchText
|
||||
* @return {webdriver.Locator}
|
||||
*/
|
||||
repeater(repeatDescriptor: string): webdriver.Locator;
|
||||
|
||||
buttonText(searchText: string): webdriver.Locator;
|
||||
|
||||
|
||||
/**
|
||||
* Find a button by partial text.
|
||||
*
|
||||
* Usage:
|
||||
* <button>Save my file</button>
|
||||
* element(by.partialButtonText('Save'));
|
||||
*
|
||||
* @param {string} searchText
|
||||
* @return {webdriver.Locator}
|
||||
*/
|
||||
partialButtonText(searchText: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Find elements inside an ng-repeat.
|
||||
*
|
||||
* Usage:
|
||||
* <div ng-repeat="cat in pets">
|
||||
* <span>{{cat.name}}</span>
|
||||
* <span>{{cat.age}}</span>
|
||||
* </div>
|
||||
*
|
||||
* <div class="book-img" ng-repeat-start="book in library">
|
||||
* <span>{{$index}}</span>
|
||||
* </div>
|
||||
* <div class="book-info" ng-repeat-end>
|
||||
* <h4>{{book.name}}</h4>
|
||||
* <p>{{book.blurb}}</p>
|
||||
* </div>
|
||||
*
|
||||
* // Returns the DIV for the second cat.
|
||||
* var secondCat = element(by.repeater('cat in pets').row(1));
|
||||
*
|
||||
* // Returns the SPAN for the first cat's name.
|
||||
* var firstCatName = element(by.repeater('cat in pets').
|
||||
* row(0).column('{{cat.name}}'));
|
||||
*
|
||||
* // Returns a promise that resolves to an array of WebElements from a column
|
||||
* var ages = element.all(
|
||||
* by.repeater('cat in pets').column('{{cat.age}}'));
|
||||
*
|
||||
* // Returns a promise that resolves to an array of WebElements containing
|
||||
* // all top level elements repeated by the repeater. For 2 pets rows resolves
|
||||
* // to an array of 2 elements.
|
||||
* var rows = element.all(by.repeater('cat in pets'));
|
||||
*
|
||||
* // Returns a promise that resolves to an array of WebElements containing all
|
||||
* // the elements with a binding to the book's name.
|
||||
* var divs = element.all(by.repeater('book in library').column('book.name'));
|
||||
*
|
||||
* // Returns a promise that resolves to an array of WebElements containing
|
||||
* // the DIVs for the second book.
|
||||
* var bookInfo = element.all(by.repeater('book in library').row(1));
|
||||
*
|
||||
* // Returns the H4 for the first book's name.
|
||||
* var firstBookName = element(by.repeater('book in library').
|
||||
* row(0).column('{{book.name}}'));
|
||||
*
|
||||
* // Returns a promise that resolves to an array of WebElements containing
|
||||
* // all top level elements repeated by the repeater. For 2 books divs
|
||||
* // resolves to an array of 4 elements.
|
||||
* var divs = element.all(by.repeater('book in library'));
|
||||
*/
|
||||
repeater(repeatDescriptor: string): RepeaterLocator;
|
||||
|
||||
/**
|
||||
* Find elements by CSS which contain a certain string.
|
||||
*
|
||||
* @view
|
||||
* <ul>
|
||||
* <li class="pet">Dog</li>
|
||||
* <li class="pet">Cat</li>
|
||||
* </ul>
|
||||
*
|
||||
* @example
|
||||
* // Returns the DIV for the dog, but not cat.
|
||||
* var dog = element(by.cssContainingText('.pet', 'Dog'));
|
||||
*
|
||||
* @param cssSelector {string}
|
||||
* @param searchText {string}
|
||||
* @return {webdriver.Locator}
|
||||
*/
|
||||
cssContainingText(cssSelector: string, searchText: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Find an element by ng-options expression.
|
||||
*
|
||||
* Usage:
|
||||
* <select ng-model="color" ng-options="c for c in colors">
|
||||
* <option value="0" selected="selected">red</option>
|
||||
* <option value="1">green</option>
|
||||
* </select>
|
||||
*
|
||||
* var allOptions = element.all(by.options('c for c in colors'));
|
||||
* expect(allOptions.count()).toEqual(2);
|
||||
* var firstOption = allOptions.first();
|
||||
* expect(firstOption.getText()).toEqual('red');
|
||||
*
|
||||
* @param {string} optionsDescriptor ng-options expression.
|
||||
* @return {webdriver.Locator}
|
||||
*/
|
||||
options(optionsDescriptor: string): webdriver.Locator;
|
||||
}
|
||||
|
||||
var By: IProtractorLocatorStrategy;
|
||||
@@ -718,6 +922,43 @@ declare module protractor {
|
||||
|
||||
//region Methods
|
||||
|
||||
/**
|
||||
* Instruct webdriver to wait until Angular has finished rendering and has
|
||||
* no outstanding $http calls before continuing.
|
||||
*
|
||||
* @return {!webdriver.promise.Promise} A promise that will resolve to the
|
||||
* scripts return value.
|
||||
*/
|
||||
waitForAngular(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Waits for Angular to finish rendering before searching for elements.
|
||||
* @see webdriver.WebDriver.findElement
|
||||
*
|
||||
* @param {webdriver.Locator} locator The locator used to find the element.
|
||||
* @return {!webdriver.WebElement}
|
||||
*/
|
||||
findElement(locator: webdriver.Locator): protractor.WebElement;
|
||||
|
||||
/**
|
||||
* Waits for Angular to finish rendering before searching for elements.
|
||||
* @see webdriver.WebDriver.findElements
|
||||
*
|
||||
* @param {webdriver.Locator} locator The locator used to find the elements.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved to an
|
||||
* array of the located {@link webdriver.WebElement}s.
|
||||
*/
|
||||
findElements(locator: webdriver.Locator): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Tests if an element is present on the page.
|
||||
* @see webdriver.WebDriver.isElementPresent
|
||||
* @return {!webdriver.promise.Promise} A promise that will resolve to whether
|
||||
* the element is present on the page.
|
||||
*/
|
||||
isElementPresent(locatorOrElement: webdriver.Locator): webdriver.promise.Promise;
|
||||
isElementPresent(locatorOrElement: any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Helper function for finding elements.
|
||||
*
|
||||
@@ -739,40 +980,71 @@ declare module protractor {
|
||||
*/
|
||||
$$(cssLocator: string): ElementArrayFinder;
|
||||
|
||||
/**
|
||||
* Instruct webdriver to wait until Angular has finished rendering and has
|
||||
* no outstanding $http calls before continuing.
|
||||
*
|
||||
* @return {!webdriver.promise.Promise} A promise that will resolve to the
|
||||
* scripts return value.
|
||||
*/
|
||||
waitForAngular(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Wrap a webdriver.WebElement with protractor specific functionality.
|
||||
*
|
||||
* @param {webdriver.WebElement} element
|
||||
* @return {protractor.WebElement} the wrapped web element.
|
||||
*/
|
||||
wrapWebElement(element: webdriver.WebElement): protractor.WebElement;
|
||||
|
||||
/**
|
||||
* Add a module to load before Angular whenever Protractor.get is called.
|
||||
* Modules will be registered after existing modules already on the page,
|
||||
* so any module registered here will override preexisting modules with the same
|
||||
* name.
|
||||
*
|
||||
* @param {!string} name The name of the module to load or override.
|
||||
* @param {!string|Function} script The JavaScript to load the module.
|
||||
* @param {string} name The name of the module to load or override.
|
||||
* @param {string|Function} script The JavaScript to load the module.
|
||||
* @param {...*} varArgs Any additional arguments will be provided to
|
||||
* the script and may be referenced using the `arguments` object.
|
||||
*/
|
||||
addMockModule(name: string, script: string): void;
|
||||
addMockModule(name: string, script: any): void;
|
||||
addMockModule(name: string, script: string, ...varArgs: any[]): void;
|
||||
addMockModule(name: string, script: any, ...varArgs: any[]): void;
|
||||
|
||||
/**
|
||||
* Clear the list of registered mock modules.
|
||||
*/
|
||||
clearMockModules(): void;
|
||||
|
||||
/**
|
||||
* Remove a registered mock module.
|
||||
* @param {!string} name The name of the module to remove.
|
||||
*/
|
||||
removeMockModule(name: string): void;
|
||||
|
||||
/**
|
||||
* See webdriver.WebDriver.get
|
||||
*
|
||||
* Navigate to the given destination and loads mock modules before
|
||||
* Angular. Assumes that the page being loaded uses Angular.
|
||||
* If you need to access a page which does not have Angular on load, use
|
||||
* the wrapped webdriver directly.
|
||||
*
|
||||
* @param {string} destination Destination URL.
|
||||
* @param {number=} opt_timeout Number of seconds to wait for Angular to start.
|
||||
*/
|
||||
get(destination: string, opt_timeout?: number): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* See webdriver.WebDriver.refresh
|
||||
*
|
||||
* Makes a full reload of the current page and loads mock modules before
|
||||
* Angular. Assumes that the page being loaded uses Angular.
|
||||
* If you need to access a page which does not have Angular on load, use
|
||||
* the wrapped webdriver directly.
|
||||
*
|
||||
* @param {number=} opt_timeout Number of seconds to wait for Angular to start.
|
||||
*/
|
||||
refresh(opt_timeout?: number): void;
|
||||
|
||||
/**
|
||||
* Mixin navigation methods back into the navigation object so that
|
||||
* they are invoked as before, i.e. driver.navigate().refresh()
|
||||
*/
|
||||
navigate(): webdriver.WebDriverNavigation;
|
||||
|
||||
/**
|
||||
* Browse to another page using in-page navigation.
|
||||
*
|
||||
* @param {string} url In page URL using the same syntax as $location.url()
|
||||
* @returns {!webdriver.promise.Promise} A promise that will resolve once
|
||||
* page has been changed.
|
||||
*/
|
||||
setLocation(url: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Returns the current absolute url from AngularJS.
|
||||
*/
|
||||
@@ -799,43 +1071,14 @@ declare module protractor {
|
||||
debugger(): void;
|
||||
|
||||
/**
|
||||
* Schedule a command to find an element on the page. If the element cannot be
|
||||
* found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will be returned
|
||||
* by the driver. Unlike other commands, this error cannot be suppressed. In
|
||||
* other words, scheduling a command to find an element doubles as an assert
|
||||
* that the element is present on the page. To test whether an element is
|
||||
* present on the page, use {@code #isElementPresent} instead.
|
||||
* Beta (unstable) pause function for debugging webdriver tests. Use
|
||||
* browser.pause() in your test to enter the protractor debugger from that
|
||||
* point in the control flow.
|
||||
* Does not require changes to the command line (no need to add 'debug').
|
||||
*
|
||||
* <p>The search criteria for find an element may either be a
|
||||
* {@code webdriver.Locator} object, or a simple JSON object whose sole key
|
||||
* is one of the accepted locator strategies, as defined by
|
||||
* {@code webdriver.Locator.Strategy}. For example, the following two statements
|
||||
* are equivalent:
|
||||
* <code><pre>
|
||||
* var e1 = driver.findElement(By.id('foo'));
|
||||
* var e2 = driver.findElement({id:'foo'});
|
||||
* </pre></code>
|
||||
*
|
||||
* <p>When running in the browser, a WebDriver cannot manipulate DOM elements
|
||||
* directly; it may do so only through a {@link webdriver.WebElement} reference.
|
||||
* This function may be used to generate a WebElement from a DOM element. A
|
||||
* reference to the DOM element will be stored in a known location and this
|
||||
* driver will attempt to retrieve it through {@link #executeScript}. If the
|
||||
* element cannot be found (eg, it belongs to a different document than the
|
||||
* one this instance is currently focused on), a
|
||||
* {@link bot.ErrorCode.NO_SUCH_ELEMENT} error will be returned.
|
||||
*
|
||||
* @param {!(webdriver.Locator|Object.<string>|Element)} locatorOrElement The
|
||||
* locator strategy to use when searching for the element, or the actual
|
||||
* DOM element to be located by the server.
|
||||
* @param {...} var_args Arguments to pass to {@code #executeScript} if using a
|
||||
* JavaScript locator. Otherwise ignored.
|
||||
* @return {!protractor.WebElement} A WebElement that can be used to issue
|
||||
* commands against the located element. If the element is not found, the
|
||||
* element will be invalidated and all scheduled commands aborted.
|
||||
* @param {=number} opt_debugPort Optional port to use for the debugging process
|
||||
*/
|
||||
findElement(locatorOrElement: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
|
||||
findElement(locatorOrElement: any, ...var_args: any[]): protractor.WebElement;
|
||||
pause(opt_debugPort?: number): void;
|
||||
|
||||
//endregion
|
||||
}
|
||||
@@ -863,9 +1106,19 @@ declare module protractor {
|
||||
|
||||
}
|
||||
|
||||
interface cssSelectorHelper {
|
||||
(cssLocator: string): protractor.ElementFinder;
|
||||
}
|
||||
|
||||
interface cssArraySelectorHelper {
|
||||
(cssLocator: string): protractor.ElementArrayFinder;
|
||||
}
|
||||
|
||||
declare var browser: protractor.Protractor;
|
||||
declare var by: protractor.IProtractorLocatorStrategy;
|
||||
declare var element: protractor.Element;
|
||||
declare var $: cssSelectorHelper;
|
||||
declare var $$: cssArraySelectorHelper;
|
||||
|
||||
declare module 'protractor' {
|
||||
export = protractor;
|
||||
|
||||
@@ -0,0 +1,244 @@
|
||||
/// <reference path="angular-protractor-0.17.0.d.ts" />
|
||||
|
||||
function TestWebDriverExports() {
|
||||
var abstractBuilder: protractor.AbstractBuilder = new protractor.AbstractBuilder();
|
||||
var baseAbstractBuilder: webdriver.AbstractBuilder = abstractBuilder;
|
||||
|
||||
var button: protractor.Button = new protractor.Button();
|
||||
var baseButton: webdriver.Button = button;
|
||||
|
||||
var key: string = protractor.Key.ADD;
|
||||
var chord: string = protractor.Key.chord(protractor.Key.NUMPAD0, protractor.Key.NUMPAD1);
|
||||
|
||||
var driver: protractor.WebDriver = new protractor.Builder().
|
||||
withCapabilities(protractor.Capabilities.chrome()).
|
||||
build();
|
||||
var baseDriver: webdriver.WebDriver = driver;
|
||||
|
||||
var action: protractor.ActionSequence = new protractor.ActionSequence(driver);
|
||||
var baseAction: webdriver.ActionSequence = action;
|
||||
|
||||
var alert: protractor.Alert = new protractor.Alert(driver, 'Message');
|
||||
var baseAlert: webdriver.Alert = alert;
|
||||
|
||||
var unhandledAlertError: protractor.UnhandledAlertError = new protractor.UnhandledAlertError('Message', alert);
|
||||
var baseUnhandledAlertError: webdriver.UnhandledAlertError = unhandledAlertError;
|
||||
|
||||
var browser: string = protractor.Browser.ANDROID;
|
||||
|
||||
var builder: protractor.Builder = new protractor.Builder();
|
||||
var baseBuilder: webdriver.Builder = builder;
|
||||
|
||||
var capability: string = protractor.Capability.BROWSER_NAME;
|
||||
|
||||
var capabilities: protractor.Capabilities = protractor.Capabilities.chrome();
|
||||
var baseCapabilities: webdriver.Capabilities = capabilities;
|
||||
|
||||
var commandName: string = protractor.CommandName.CLICK_ELEMENT;
|
||||
|
||||
var command: protractor.Command = new protractor.Command(protractor.CommandName.CLICK);
|
||||
var baseCommand: webdriver.Command = command;
|
||||
|
||||
var eventEmitter: protractor.EventEmitter = new protractor.EventEmitter();
|
||||
var baseEventEmitter: webdriver.EventEmitter = eventEmitter;
|
||||
|
||||
var firefoxDomExecutor: protractor.FirefoxDomExecutor = new protractor.FirefoxDomExecutor();
|
||||
var baseFirefoxDomExecutor: webdriver.FirefoxDomExecutor = firefoxDomExecutor;
|
||||
|
||||
var webElement: protractor.WebElement = new protractor.WebElement(driver, new protractor.promise.Promise());
|
||||
var baseWebElement: webdriver.WebElement = webElement;
|
||||
|
||||
var locator: protractor.Locator = new protractor.Locator('id', 'ABC');
|
||||
var baseLocator: webdriver.Locator = locator;
|
||||
|
||||
var session: protractor.Session = new protractor.Session('ABC', webdriver.Capabilities.android());
|
||||
var baseSession: webdriver.Session = session;
|
||||
|
||||
locator = protractor.By.name('name');
|
||||
|
||||
// logging module
|
||||
|
||||
var levelName: string = protractor.logging.LevelName.ALL;
|
||||
var loggingType: string = protractor.logging.Type.CLIENT;
|
||||
|
||||
var level: webdriver.logging.Level = protractor.logging.Level.ALL;
|
||||
|
||||
var entry: protractor.logging.Entry = new protractor.logging.Entry(protractor.logging.Level.ALL, 'Message');
|
||||
var baseEntry: webdriver.logging.Entry = entry;
|
||||
|
||||
level = protractor.logging.getLevel('DEBUG');
|
||||
|
||||
protractor.logging.Preferences = { a: 123 };
|
||||
|
||||
// promise module
|
||||
|
||||
var promise: protractor.promise.Promise = new protractor.promise.Promise();
|
||||
var basePromise: webdriver.promise.Promise = promise;
|
||||
|
||||
var deferred: protractor.promise.Deferred = new protractor.promise.Deferred();
|
||||
var baseDeferred: webdriver.promise.Deferred = deferred;
|
||||
|
||||
var flow: protractor.promise.ControlFlow = new protractor.promise.ControlFlow();
|
||||
var baseFlow: webdriver.promise.ControlFlow = flow;
|
||||
|
||||
protractor.promise.asap(promise, function(value: any){ return true; });
|
||||
protractor.promise.asap(promise, function(value: any){}, function(err: any) { return 'ABC'; });
|
||||
|
||||
promise = protractor.promise.checkedNodeCall(function(err: any, value: any) { return 123; });
|
||||
|
||||
flow = protractor.promise.controlFlow();
|
||||
|
||||
promise = protractor.promise.createFlow(function(newFlow: webdriver.promise.ControlFlow) { });
|
||||
|
||||
deferred = protractor.promise.defer(function() {});
|
||||
deferred = protractor.promise.defer(function(reason?: any) {});
|
||||
|
||||
promise = protractor.promise.delayed(123);
|
||||
|
||||
promise = protractor.promise.fulfilled();
|
||||
promise = protractor.promise.fulfilled({a: 123});
|
||||
|
||||
promise = protractor.promise.fullyResolved({a: 123});
|
||||
|
||||
var isPromise: boolean = protractor.promise.isPromise('ABC');
|
||||
|
||||
promise = protractor.promise.rejected({a: 123});
|
||||
|
||||
protractor.promise.setDefaultFlow(new webdriver.promise.ControlFlow());
|
||||
|
||||
promise = protractor.promise.when(promise, function(value: any) { return 123; }, function(err: Error) { return 123; });
|
||||
|
||||
// error module
|
||||
|
||||
var errorCode: number = protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE;
|
||||
var error: protractor.error.Error = new protractor.error.Error(protractor.error.ErrorCode.ELEMENT_NOT_VISIBLE);
|
||||
var baseError: webdriver.error.Error = error;
|
||||
|
||||
// process module
|
||||
|
||||
var isNative: boolean = protractor.process.isNative();
|
||||
var value: string;
|
||||
|
||||
value = protractor.process.getEnv('name');
|
||||
value = protractor.process.getEnv('name', 'default');
|
||||
|
||||
protractor.process.setEnv('name', 'value');
|
||||
protractor.process.setEnv('name', 123);
|
||||
|
||||
}
|
||||
|
||||
function TestProtractor() {
|
||||
var ptor: protractor.Protractor;
|
||||
var driver: webdriver.WebDriver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.chrome()).
|
||||
build();
|
||||
|
||||
ptor = new protractor.Protractor(driver);
|
||||
ptor = new protractor.Protractor(driver, 'baseUrl');
|
||||
ptor = new protractor.Protractor(driver, 'baseUrl', 'rootElement');
|
||||
ptor = protractor.getInstance();
|
||||
protractor.setInstance(ptor);
|
||||
|
||||
ptor = protractor.wrapDriver(driver);
|
||||
ptor = protractor.wrapDriver(driver, 'baseUrl');
|
||||
ptor = protractor.wrapDriver(driver, 'baseUrl', 'rootElement');
|
||||
|
||||
ptor = browser;
|
||||
|
||||
driver = ptor.driver;
|
||||
var baseUrl: string = ptor.baseUrl;
|
||||
var rootEl: string = ptor.rootEl;
|
||||
var ignoreSynchronization: boolean = ptor.ignoreSynchronization;
|
||||
var params: any = ptor.params;
|
||||
|
||||
ptor.debugger();
|
||||
|
||||
ptor.clearMockModules();
|
||||
ptor.addMockModule('name', 'script');
|
||||
ptor.addMockModule('name', function() {});
|
||||
ptor.waitForAngular();
|
||||
|
||||
var elementFinder: protractor.ElementFinder;
|
||||
|
||||
elementFinder = ptor.element(by.id('ABC'));
|
||||
elementFinder = ptor.$('.class');
|
||||
|
||||
var elementArrayFinder: protractor.ElementArrayFinder = ptor.$$('.class');
|
||||
|
||||
var webElement: webdriver.WebElement = ptor.wrapWebElement(new webdriver.WebElement(driver, 'id'));
|
||||
|
||||
var locationAbsUrl: webdriver.promise.Promise = ptor.getLocationAbsUrl();
|
||||
}
|
||||
|
||||
function TestElement() {
|
||||
var elementFinder: protractor.ElementFinder = element(by.id('id'));
|
||||
var elementArrayFinder: protractor.ElementArrayFinder = element.all(by.className('class'));
|
||||
}
|
||||
|
||||
function TestElementFinder() {
|
||||
var elementFinder: protractor.ElementFinder = element(by.id('id'));
|
||||
var promise: webdriver.promise.Promise;
|
||||
|
||||
promise = elementFinder.click();
|
||||
promise = elementFinder.sendKeys(protractor.Key.UP, protractor.Key.DOWN);
|
||||
promise = elementFinder.getTagName();
|
||||
promise = elementFinder.getCssValue('display');
|
||||
promise = elementFinder.getAttribute('atribute');
|
||||
promise = elementFinder.getText();
|
||||
promise = elementFinder.getSize();
|
||||
promise = elementFinder.getLocation();
|
||||
promise = elementFinder.isEnabled();
|
||||
promise = elementFinder.isSelected();
|
||||
promise = elementFinder.submit();
|
||||
promise = elementFinder.clear();
|
||||
promise = elementFinder.isDisplayed();
|
||||
promise = elementFinder.getOuterHtml();
|
||||
promise = elementFinder.getInnerHtml();
|
||||
promise = elementFinder.isElementPresent(by.id('id'));
|
||||
promise = elementFinder.isElementPresent(by.js('function(a, b, c) {}'), 1, 2, 3);
|
||||
promise = elementFinder.findElements(by.className('class'));
|
||||
promise = elementFinder.findElements(by.js('function(a, b, c) {}'), 1, 2, 3);
|
||||
promise = elementFinder.$$('.class');
|
||||
promise = elementFinder.evaluate('expression');
|
||||
promise = elementFinder.isPresent();
|
||||
|
||||
var webElement: webdriver.WebElement;
|
||||
|
||||
webElement = elementFinder.$('.class');
|
||||
webElement = elementFinder.findElement(by.id('id'));
|
||||
webElement = elementFinder.findElement(by.js('function(a, b, c) {}'), 1, 2, 3);
|
||||
webElement = elementFinder.find();
|
||||
}
|
||||
|
||||
// This function tests the angular specific locator strategies.
|
||||
function TestLocatorStrategies() {
|
||||
var ptor: protractor.Protractor = protractor.getInstance();
|
||||
var webElement: webdriver.WebElement;
|
||||
|
||||
// Protractor Specific Locators
|
||||
webElement = ptor.findElement(protractor.By.binding('binding'));
|
||||
webElement = ptor.findElement(protractor.By.select('select'));
|
||||
webElement = ptor.findElement(protractor.By.selectedOption('selectedOptions'));
|
||||
webElement = ptor.findElement(protractor.By.input('input'));
|
||||
webElement = ptor.findElement(protractor.By.model('model'));
|
||||
webElement = ptor.findElement(protractor.By.textarea('textarea'));
|
||||
webElement = ptor.findElement(protractor.By.repeater('repeater'));
|
||||
webElement = ptor.findElement(protractor.By.buttonText('buttonText'));
|
||||
webElement = ptor.findElement(protractor.By.partialButtonText('partialButtonText'));
|
||||
}
|
||||
|
||||
// This function tests the methods that were added to the base WebElement class
|
||||
function TestWebElements() {
|
||||
var ptor: protractor.Protractor = protractor.getInstance();
|
||||
|
||||
var webElement: protractor.WebElement;
|
||||
var promise: webdriver.promise.Promise;
|
||||
|
||||
webElement = ptor.findElement(by.id('id')).$('.class');
|
||||
promise = ptor.findElement(by.id('id')).$$('.class');
|
||||
promise = ptor.findElement(by.id('id')).evaluate('something');
|
||||
|
||||
webElement = webElement.findElement(by.id('id')).$('.class');
|
||||
promise = webElement.findElement(by.id('id')).$$('.class');
|
||||
promise = webElement.findElement(by.id('id')).evaluate('something');
|
||||
}
|
||||
@@ -0,0 +1,906 @@
|
||||
// Type definitions for Angular Protractor 0.17.0
|
||||
// Project: https://github.com/angular/protractor
|
||||
// Definitions by: Bill Armstrong <https://github.com/BillArmstrong>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../../selenium-webdriver/selenium-webdriver.d.ts" />
|
||||
|
||||
declare module protractor {
|
||||
//region Wrapped webdriver Items
|
||||
|
||||
class AbstractBuilder extends webdriver.AbstractBuilder {}
|
||||
class ActionSequence extends webdriver.ActionSequence {}
|
||||
class Alert extends webdriver.Alert {}
|
||||
class Builder extends webdriver.Builder {}
|
||||
class Button extends webdriver.Button {}
|
||||
class Capabilities extends webdriver.Capabilities {}
|
||||
class Command extends webdriver.Command {}
|
||||
class EventEmitter extends webdriver.EventEmitter {}
|
||||
class FirefoxDomExecutor extends webdriver.FirefoxDomExecutor {}
|
||||
class Locator extends webdriver.Locator {}
|
||||
class Session extends webdriver.Session {}
|
||||
class WebDriver extends webdriver.WebDriver {}
|
||||
class Browser extends webdriver.Browser {}
|
||||
class Capability extends webdriver.Capability {}
|
||||
class CommandName extends webdriver.CommandName {}
|
||||
class Key extends webdriver.Key {}
|
||||
class UnhandledAlertError extends webdriver.UnhandledAlertError {}
|
||||
|
||||
class WebElement extends webdriver.WebElement {
|
||||
/**
|
||||
* Shortcut for querying the document directly with css.
|
||||
*
|
||||
* @param {string} selector a css selector
|
||||
* @see webdriver.WebElement.findElement
|
||||
* @return {!protractor.WebElement}
|
||||
*/
|
||||
$(selector: string): protractor.WebElement;
|
||||
|
||||
/**
|
||||
* Shortcut for querying the document directly with css.
|
||||
*
|
||||
* @param {string} selector a css selector
|
||||
* @see webdriver.WebElement.findElements
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved to an
|
||||
* array of the located {@link webdriver.WebElement}s.
|
||||
*/
|
||||
$$(selector: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Evalates the input as if it were on the scope of the current element.
|
||||
* @param {string} expression
|
||||
*
|
||||
* @return {!webdriver.promise.Promise} A promise that will resolve to the
|
||||
* evaluated expression. The result will be resolved as in
|
||||
* {@link webdriver.WebDriver.executeScript}. In summary - primitives will
|
||||
* be resolved as is, functions will be converted to string, and elements
|
||||
* will be returned as a WebElement.
|
||||
*/
|
||||
evaluate(expression: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedule a command to find a descendant of this element. If the element
|
||||
* cannot be found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will
|
||||
* be returned by the driver. Unlike other commands, this error cannot be
|
||||
* suppressed. In other words, scheduling a command to find an element doubles
|
||||
* as an assert that the element is present on the page. To test whether an
|
||||
* element is present on the page, use {@code #isElementPresent} instead.
|
||||
* <p/>
|
||||
* The search criteria for find an element may either be a
|
||||
* {@code webdriver.Locator} object, or a simple JSON object whose sole key
|
||||
* is one of the accepted locator strategies, as defined by
|
||||
* {@code webdriver.Locator.Strategy}. For example, the following two
|
||||
* statements are equivalent:
|
||||
* <code><pre>
|
||||
* var e1 = element.findElement(By.id('foo'));
|
||||
* var e2 = element.findElement({id:'foo'});
|
||||
* </pre></code>
|
||||
* <p/>
|
||||
* Note that JS locator searches cannot be restricted to a subtree. All such
|
||||
* searches are delegated to this instance's parent WebDriver.
|
||||
*
|
||||
* @param {webdriver.Locator|Object.<string>} locator The locator
|
||||
* strategy to use when searching for the element.
|
||||
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
|
||||
* using a JavaScript locator. Otherwise ignored.
|
||||
* @return {protractor.WebElement} A WebElement that can be used to issue
|
||||
* commands against the located element. If the element is not found, the
|
||||
* element will be invalidated and all scheduled commands aborted.
|
||||
*/
|
||||
findElement(locator: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
|
||||
findElement(locator: any, ...var_args: any[]): protractor.WebElement;
|
||||
}
|
||||
|
||||
module command {
|
||||
class Command extends webdriver.Command {}
|
||||
class CommandName extends webdriver.CommandName {}
|
||||
}
|
||||
|
||||
module error {
|
||||
class Error extends webdriver.error.Error {}
|
||||
class ErrorCode extends webdriver.error.ErrorCode {}
|
||||
}
|
||||
|
||||
module events {
|
||||
class EventEmitter extends webdriver.EventEmitter {}
|
||||
}
|
||||
|
||||
module logging {
|
||||
var Preferences: any;
|
||||
|
||||
class LevelName extends webdriver.logging.LevelName {}
|
||||
class Type extends webdriver.logging.Type {}
|
||||
class Level extends webdriver.logging.Level {}
|
||||
class Entry extends webdriver.logging.Entry {}
|
||||
|
||||
function getLevel(nameOrValue: string): webdriver.logging.Level;
|
||||
function getLevel(nameOrValue: number): webdriver.logging.Level;
|
||||
}
|
||||
|
||||
module promise {
|
||||
class Promise extends webdriver.promise.Promise {}
|
||||
class Deferred extends webdriver.promise.Deferred {}
|
||||
class ControlFlow extends webdriver.promise.ControlFlow {}
|
||||
|
||||
/**
|
||||
* @return {!webdriver.promise.ControlFlow} The currently active control flow.
|
||||
*/
|
||||
function controlFlow(): webdriver.promise.ControlFlow;
|
||||
|
||||
/**
|
||||
* Creates a new control flow. The provided callback will be invoked as the
|
||||
* first task within the new flow, with the flow as its sole argument. Returns
|
||||
* a promise that resolves to the callback result.
|
||||
* @param {function(!webdriver.promise.ControlFlow)} callback The entry point
|
||||
* to the newly created flow.
|
||||
* @return {!webdriver.promise.Promise} A promise that resolves to the callback
|
||||
* result.
|
||||
*/
|
||||
function createFlow(callback: (flow: webdriver.promise.ControlFlow) => any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Determines whether a {@code value} should be treated as a promise.
|
||||
* Any object whose "then" property is a function will be considered a promise.
|
||||
*
|
||||
* @param {*} value The value to test.
|
||||
* @return {boolean} Whether the value is a promise.
|
||||
*/
|
||||
function isPromise(value: any): boolean;
|
||||
|
||||
/**
|
||||
* Creates a promise that will be resolved at a set time in the future.
|
||||
* @param {number} ms The amount of time, in milliseconds, to wait before
|
||||
* resolving the promise.
|
||||
* @return {!webdriver.promise.Promise} The promise.
|
||||
*/
|
||||
function delayed(ms: number): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Creates a new deferred object.
|
||||
* @param {Function=} opt_canceller Function to call when cancelling the
|
||||
* computation of this instance's value.
|
||||
* @return {!webdriver.promise.Deferred} The new deferred object.
|
||||
*/
|
||||
function defer(opt_canceller?: any): webdriver.promise.Deferred;
|
||||
|
||||
/**
|
||||
* Creates a promise that has been resolved with the given value.
|
||||
* @param {*=} opt_value The resolved value.
|
||||
* @return {!webdriver.promise.Promise} The resolved promise.
|
||||
*/
|
||||
function fulfilled(opt_value?: any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Creates a promise that has been rejected with the given reason.
|
||||
* @param {*=} opt_reason The rejection reason; may be any value, but is
|
||||
* usually an Error or a string.
|
||||
* @return {!webdriver.promise.Promise} The rejected promise.
|
||||
*/
|
||||
function rejected(opt_reason?: any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Wraps a function that is assumed to be a node-style callback as its final
|
||||
* argument. This callback takes two arguments: an error value (which will be
|
||||
* null if the call succeeded), and the success value as the second argument.
|
||||
* If the call fails, the returned promise will be rejected, otherwise it will
|
||||
* be resolved with the result.
|
||||
* @param {!Function} fn The function to wrap.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* result of the provided function's callback.
|
||||
*/
|
||||
function checkedNodeCall(fn: (error: any, value: any) => any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Registers an observer on a promised {@code value}, returning a new promise
|
||||
* that will be resolved when the value is. If {@code value} is not a promise,
|
||||
* then the return promise will be immediately resolved.
|
||||
* @param {*} value The value to observe.
|
||||
* @param {Function=} opt_callback The function to call when the value is
|
||||
* resolved successfully.
|
||||
* @param {Function=} opt_errback The function to call when the value is
|
||||
* rejected.
|
||||
* @return {!webdriver.promise.Promise} A new promise.
|
||||
*/
|
||||
function when(value: any, opt_callback?: (value: any) => any, opt_errback?: (error: any) => any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Invokes the appropriate callback function as soon as a promised
|
||||
* {@code value} is resolved. This function is similar to
|
||||
* {@code webdriver.promise.when}, except it does not return a new promise.
|
||||
* @param {*} value The value to observe.
|
||||
* @param {Function} callback The function to call when the value is
|
||||
* resolved successfully.
|
||||
* @param {Function=} opt_errback The function to call when the value is
|
||||
* rejected.
|
||||
*/
|
||||
function asap(value: any, callback: (value: any) => any, opt_errback?: (error: any) => any): void;
|
||||
|
||||
/**
|
||||
* Returns a promise that will be resolved with the input value in a
|
||||
* fully-resolved state. If the value is an array, each element will be fully
|
||||
* resolved. Likewise, if the value is an object, all keys will be fully
|
||||
* resolved. In both cases, all nested arrays and objects will also be
|
||||
* fully resolved. All fields are resolved in place; the returned promise will
|
||||
* resolve on {@code value} and not a copy.
|
||||
*
|
||||
* Warning: This function makes no checks against objects that contain
|
||||
* cyclical references:
|
||||
*
|
||||
* var value = {};
|
||||
* value['self'] = value;
|
||||
* webdriver.promise.fullyResolved(value); // Stack overflow.
|
||||
*
|
||||
* @param {*} value The value to fully resolve.
|
||||
* @return {!webdriver.promise.Promise} A promise for a fully resolved version
|
||||
* of the input value.
|
||||
*/
|
||||
function fullyResolved(value: any): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Changes the default flow to use when no others are active.
|
||||
* @param {!webdriver.promise.ControlFlow} flow The new default flow.
|
||||
* @throws {Error} If the default flow is not currently active.
|
||||
*/
|
||||
function setDefaultFlow(flow: webdriver.promise.ControlFlow): void;
|
||||
|
||||
}
|
||||
|
||||
module process {
|
||||
|
||||
/**
|
||||
* Queries for a named environment variable.
|
||||
* @param {string} name The name of the environment variable to look up.
|
||||
* @param {string=} opt_default The default value if the named variable is not
|
||||
* defined.
|
||||
* @return {string} The queried environment variable.
|
||||
*/
|
||||
function getEnv(name: string, opt_default?: string): string;
|
||||
|
||||
/**
|
||||
* @return {boolean} Whether the current process is Node's native process
|
||||
* object.
|
||||
*/
|
||||
function isNative(): boolean;
|
||||
|
||||
/**
|
||||
* Sets an environment value. If the new value is either null or undefined, the
|
||||
* environment variable will be cleared.
|
||||
* @param {string} name The value to set.
|
||||
* @param {*} value The new value; will be coerced to a string.
|
||||
*/
|
||||
function setEnv(name: string, value: any): void;
|
||||
|
||||
}
|
||||
|
||||
//endregion
|
||||
|
||||
interface Element {
|
||||
(locator: webdriver.Locator): ElementFinder;
|
||||
all(locator: webdriver.Locator): ElementArrayFinder;
|
||||
}
|
||||
|
||||
interface ElementFinder {
|
||||
/**
|
||||
* Schedules a command to click on this element.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved when
|
||||
* the click command has completed.
|
||||
*/
|
||||
click(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to type a sequence on the DOM element represented by this
|
||||
* instance.
|
||||
* <p/>
|
||||
* Modifier keys (SHIFT, CONTROL, ALT, META) are stateful; once a modifier is
|
||||
* processed in the keysequence, that key state is toggled until one of the
|
||||
* following occurs:
|
||||
* <ul>
|
||||
* <li>The modifier key is encountered again in the sequence. At this point the
|
||||
* state of the key is toggled (along with the appropriate keyup/down events).
|
||||
* </li>
|
||||
* <li>The {@code webdriver.Key.NULL} key is encountered in the sequence. When
|
||||
* this key is encountered, all modifier keys current in the down state are
|
||||
* released (with accompanying keyup events). The NULL key can be used to
|
||||
* simulate common keyboard shortcuts:
|
||||
* <code>
|
||||
* element.sendKeys("text was",
|
||||
* webdriver.Key.CONTROL, "a", webdriver.Key.NULL,
|
||||
* "now text is");
|
||||
* // Alternatively:
|
||||
* element.sendKeys("text was",
|
||||
* webdriver.Key.chord(webdriver.Key.CONTROL, "a"),
|
||||
* "now text is");
|
||||
* </code></li>
|
||||
* <li>The end of the keysequence is encountered. When there are no more keys
|
||||
* to type, all depressed modifier keys are released (with accompanying keyup
|
||||
* events).
|
||||
* </li>
|
||||
* </ul>
|
||||
* <strong>Note:</strong> On browsers where native keyboard events are not yet
|
||||
* supported (e.g. Firefox on OS X), key events will be synthesized. Special
|
||||
* punctionation keys will be synthesized according to a standard QWERTY en-us
|
||||
* keyboard layout.
|
||||
*
|
||||
* @param {...string} var_args The sequence of keys to
|
||||
* type. All arguments will be joined into a single sequence (var_args is
|
||||
* permitted for convenience).
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved when all
|
||||
* keys have been typed.
|
||||
*/
|
||||
sendKeys(...var_args: string[]): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to query for the tag/node name of this element.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* element's tag name.
|
||||
*/
|
||||
getTagName(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to query for the computed style of the element
|
||||
* represented by this instance. If the element inherits the named style from
|
||||
* its parent, the parent will be queried for its value. Where possible, color
|
||||
* values will be converted to their hex representation (e.g. #00ff00 instead of
|
||||
* rgb(0, 255, 0)).
|
||||
* <p/>
|
||||
* <em>Warning:</em> the value returned will be as the browser interprets it, so
|
||||
* it may be tricky to form a proper assertion.
|
||||
*
|
||||
* @param {string} cssStyleProperty The name of the CSS style property to look
|
||||
* up.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* requested CSS value.
|
||||
*/
|
||||
getCssValue(cssStyleProperty: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to query for the value of the given attribute of the
|
||||
* element. Will return the current value even if it has been modified after the
|
||||
* page has been loaded. More exactly, this method will return the value of the
|
||||
* given attribute, unless that attribute is not present, in which case the
|
||||
* value of the property with the same name is returned. If neither value is
|
||||
* set, null is returned. The "style" attribute is converted as best can be to a
|
||||
* text representation with a trailing semi-colon. The following are deemed to
|
||||
* be "boolean" attributes and will be returned as thus:
|
||||
*
|
||||
* <p>async, autofocus, autoplay, checked, compact, complete, controls, declare,
|
||||
* defaultchecked, defaultselected, defer, disabled, draggable, ended,
|
||||
* formnovalidate, hidden, indeterminate, iscontenteditable, ismap, itemscope,
|
||||
* loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open,
|
||||
* paused, pubdate, readonly, required, reversed, scoped, seamless, seeking,
|
||||
* selected, spellcheck, truespeed, willvalidate
|
||||
*
|
||||
* <p>Finally, the following commonly mis-capitalized attribute/property names
|
||||
* are evaluated as expected:
|
||||
* <ul>
|
||||
* <li>"class"
|
||||
* <li>"readonly"
|
||||
* </ul>
|
||||
* @param {string} attributeName The name of the attribute to query.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* attribute's value.
|
||||
*/
|
||||
getAttribute(attributeName: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Get the visible (i.e. not hidden by CSS) innerText of this element, including
|
||||
* sub-elements, without any leading or trailing whitespace.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* element's visible text.
|
||||
*/
|
||||
getText(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to compute the size of this element's bounding box, in
|
||||
* pixels.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* element's size as a {@code {width:number, height:number}} object.
|
||||
*/
|
||||
getSize(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to compute the location of this element in page space.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved to the
|
||||
* element's location as a {@code {x:number, y:number}} object.
|
||||
*/
|
||||
getLocation(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to query whether the DOM element represented by this
|
||||
* instance is enabled, as dicted by the {@code disabled} attribute.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with
|
||||
* whether this element is currently enabled.
|
||||
*/
|
||||
isEnabled(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to query whether this element is selected.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with
|
||||
* whether this element is currently selected.
|
||||
*/
|
||||
isSelected(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to submit the form containing this element (or this
|
||||
* element if it is a FORM element). This command is a no-op if the element is
|
||||
* not contained in a form.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved when
|
||||
* the form has been submitted.
|
||||
*/
|
||||
submit(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to clear the {@code value} of this element. This command
|
||||
* has no effect if the underlying DOM element is neither a text INPUT element
|
||||
* nor a TEXTAREA element.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved when
|
||||
* the element has been cleared.
|
||||
*/
|
||||
clear(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to test whether this element is currently displayed.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with
|
||||
* whether this element is currently visible on the page.
|
||||
*/
|
||||
isDisplayed(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to retrieve the outer HTML of this element.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with
|
||||
* the element's outer HTML.
|
||||
*/
|
||||
getOuterHtml(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to retrieve the inner HTML of this element.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with the
|
||||
* element's inner HTML.
|
||||
*/
|
||||
getInnerHtml(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to test if there is at least one descendant of this
|
||||
* element that matches the given search criteria.
|
||||
*
|
||||
* <p>Note that JS locator searches cannot be restricted to a subtree of the
|
||||
* DOM. All such searches are delegated to this instance's parent WebDriver.
|
||||
*
|
||||
* @param {webdriver.Locator|Object.<string>} locator The locator
|
||||
* strategy to use when searching for the element.
|
||||
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
|
||||
* using a JavaScript locator. Otherwise ignored.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with
|
||||
* whether an element could be located on the page.
|
||||
*/
|
||||
isElementPresent(locator: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise;
|
||||
isElementPresent(locator: any, ...var_args: any[]): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedules a command to find all of the descendants of this element that match
|
||||
* the given search criteria.
|
||||
* <p/>
|
||||
* Note that JS locator searches cannot be restricted to a subtree. All such
|
||||
* searches are delegated to this instance's parent WebDriver.
|
||||
*
|
||||
* @param {webdriver.Locator|Object.<string>} locator The locator
|
||||
* strategy to use when searching for the elements.
|
||||
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
|
||||
* using a JavaScript locator. Otherwise ignored.
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved with an
|
||||
* array of located {@link webdriver.WebElement}s.
|
||||
*/
|
||||
findElements(locator: webdriver.Locator, ...var_args: any[]): webdriver.promise.Promise;
|
||||
findElements(locator: any, ...var_args: any[]): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Shortcut for querying the document directly with css.
|
||||
*
|
||||
* @param {string} selector a css selector
|
||||
* @see webdriver.WebElement.findElement
|
||||
* @return {!protractor.WebElement}
|
||||
*/
|
||||
$(selector: string): protractor.WebElement;
|
||||
|
||||
/**
|
||||
* Shortcut for querying the document directly with css.
|
||||
*
|
||||
* @param {string} selector a css selector
|
||||
* @see webdriver.WebElement.findElements
|
||||
* @return {!webdriver.promise.Promise} A promise that will be resolved to an
|
||||
* array of the located {@link webdriver.WebElement}s.
|
||||
*/
|
||||
$$(selector: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Schedule a command to find a descendant of this element. If the element
|
||||
* cannot be found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will
|
||||
* be returned by the driver. Unlike other commands, this error cannot be
|
||||
* suppressed. In other words, scheduling a command to find an element doubles
|
||||
* as an assert that the element is present on the page. To test whether an
|
||||
* element is present on the page, use {@code #isElementPresent} instead.
|
||||
* <p/>
|
||||
* The search criteria for find an element may either be a
|
||||
* {@code webdriver.Locator} object, or a simple JSON object whose sole key
|
||||
* is one of the accepted locator strategies, as defined by
|
||||
* {@code webdriver.Locator.Strategy}. For example, the following two
|
||||
* statements are equivalent:
|
||||
* <code><pre>
|
||||
* var e1 = element.findElement(By.id('foo'));
|
||||
* var e2 = element.findElement({id:'foo'});
|
||||
* </pre></code>
|
||||
* <p/>
|
||||
* Note that JS locator searches cannot be restricted to a subtree. All such
|
||||
* searches are delegated to this instance's parent WebDriver.
|
||||
*
|
||||
* @param {webdriver.Locator|Object.<string>} locator The locator
|
||||
* strategy to use when searching for the element.
|
||||
* @param {...} var_args Arguments to pass to {@code WebDriver#executeScript} if
|
||||
* using a JavaScript locator. Otherwise ignored.
|
||||
* @return {protractor.WebElement} A WebElement that can be used to issue
|
||||
* commands against the located element. If the element is not found, the
|
||||
* element will be invalidated and all scheduled commands aborted.
|
||||
*/
|
||||
findElement(locator: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
|
||||
findElement(locator: any, ...var_args: any[]): protractor.WebElement;
|
||||
|
||||
/**
|
||||
* Evalates the input as if it were on the scope of the current element.
|
||||
* @param {string} expression
|
||||
*
|
||||
* @return {!webdriver.promise.Promise} A promise that will resolve to the
|
||||
* evaluated expression. The result will be resolved as in
|
||||
* {@link webdriver.WebDriver.executeScript}. In summary - primitives will
|
||||
* be resolved as is, functions will be converted to string, and elements
|
||||
* will be returned as a WebElement.
|
||||
*/
|
||||
evaluate(expression: string): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Use as: element(locator).element(locator)
|
||||
* Calls to element may be chained to find elements within a parent.
|
||||
*
|
||||
* @param {webdriver.Locator} The locator that will be used to find descendents.
|
||||
*
|
||||
* @return {protractor.ElementFinder} the descendent element found by the locator
|
||||
*/
|
||||
element(locator: webdriver.Locator): protractor.ElementFinder;
|
||||
|
||||
/**
|
||||
* Use as: element(locator).all(locator)
|
||||
* Calls to element may be chained to find an array of elements within a parent.
|
||||
*
|
||||
* @param {webdriver.Locator} The locator that will be used to find descendents.
|
||||
*
|
||||
* @return {protractor.ElementArrayFinder} the descendent elements found by the locator
|
||||
*/
|
||||
all(locator: webdriver.Locator): protractor.ElementArrayFinder;
|
||||
|
||||
find(): protractor.WebElement;
|
||||
|
||||
isPresent(): webdriver.promise.Promise;
|
||||
}
|
||||
|
||||
interface ElementArrayFinder{
|
||||
count(): webdriver.promise.Promise;
|
||||
get(index: number): protractor.WebElement;
|
||||
first(): protractor.WebElement;
|
||||
last(): protractor.WebElement;
|
||||
then(fn: (value: any) => any): webdriver.promise.Promise;
|
||||
}
|
||||
|
||||
class LocatorWithColumn extends webdriver.Locator {
|
||||
column(index: number): webdriver.Locator;
|
||||
}
|
||||
|
||||
class RepeaterLocator extends LocatorWithColumn {
|
||||
row(index: number): LocatorWithColumn;
|
||||
}
|
||||
|
||||
interface IProtractorLocatorStrategy extends webdriver.ILocatorStrategy {
|
||||
/**
|
||||
* Add a locator to this instance of ProtractorBy. This locator can then be
|
||||
* used with element(by.<name>(<args>)).
|
||||
*
|
||||
* @param {string} name
|
||||
* @param {function|string} script A script to be run in the context of
|
||||
* the browser. This script will be passed an array of arguments
|
||||
* that begins with the element scoping the search, and then
|
||||
* contains any args passed into the locator. It should return
|
||||
* an array of elements.
|
||||
*/
|
||||
addLocator(name: string, script: any): void;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <span>{{status}}</span>
|
||||
* var status = element(by.binding('{{status}}'));
|
||||
*/
|
||||
binding(bindingDescriptor: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <select ng-model="user" ng-options="user.name for user in users"></select>
|
||||
* element(by.select("user"));
|
||||
*/
|
||||
select(model: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <select ng-model="user" ng-options="user.name for user in users"></select>
|
||||
* element(by.selectedOption("user"));
|
||||
*/
|
||||
selectedOption(model: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* @DEPRECATED - use 'model' instead.
|
||||
* Usage:
|
||||
* <input ng-model="user" type="text"/>
|
||||
* element(by.input('user'));
|
||||
*/
|
||||
input(model: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <input ng-model="user" type="text"/>
|
||||
* element(by.model('user'));
|
||||
*/
|
||||
model(model: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <textarea ng-model="user"></textarea>
|
||||
* element(by.textarea("user"));
|
||||
*/
|
||||
textarea(model: string): webdriver.Locator;
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
* <div ng-repeat = "cat in pets">
|
||||
* <span>{{cat.name}}</span>
|
||||
* <span>{{cat.age}}</span>
|
||||
* </div>
|
||||
*
|
||||
* // Returns the DIV for the second cat.
|
||||
* var secondCat = element(by.repeater("cat in pets").row(2));
|
||||
* // Returns the SPAN for the first cat's name.
|
||||
* var firstCatName = element(
|
||||
* by.repeater("cat in pets").row(1).column("{{cat.name}}"));
|
||||
* // Returns a promise that resolves to an array of WebElements from a column
|
||||
* var ages = element(
|
||||
* by.repeater("cat in pets").column("{{cat.age}}"));
|
||||
* // Returns a promise that resolves to an array of WebElements containing
|
||||
* // all rows of the repeater.
|
||||
* var rows = element(by.repeater("cat in pets"));
|
||||
*/
|
||||
repeater(repeatDescriptor: string): RepeaterLocator;
|
||||
|
||||
buttonText(searchText: string): webdriver.Locator;
|
||||
|
||||
partialButtonText(searchText: string): webdriver.Locator;
|
||||
}
|
||||
|
||||
var By: IProtractorLocatorStrategy;
|
||||
|
||||
class Protractor extends webdriver.WebDriver {
|
||||
|
||||
//region Constructors
|
||||
|
||||
/**
|
||||
* @param {webdriver.WebDriver} webdriver
|
||||
* @param {string=} opt_baseUrl A base URL to run get requests against.
|
||||
* @param {string=body} opt_rootElement Selector element that has an ng-app in
|
||||
* scope.
|
||||
* @constructor
|
||||
*/
|
||||
constructor(webdriver: webdriver.WebDriver, opt_baseUrl?: string, opt_rootElement?: string);
|
||||
|
||||
//endregion
|
||||
|
||||
//region Properties
|
||||
|
||||
/**
|
||||
* The wrapped webdriver instance. Use this to interact with pages that do
|
||||
* not contain Angular (such as a log-in screen).
|
||||
*
|
||||
* @type {webdriver.WebDriver}
|
||||
*/
|
||||
driver: webdriver.WebDriver;
|
||||
|
||||
/**
|
||||
* All get methods will be resolved against this base URL. Relative URLs are =
|
||||
* resolved the way anchor tags resolve.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
baseUrl: string;
|
||||
|
||||
/**
|
||||
* The css selector for an element on which to find Angular. This is usually
|
||||
* 'body' but if your ng-app is on a subsection of the page it may be
|
||||
* a subelement.
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
rootEl: string;
|
||||
|
||||
/**
|
||||
* If true, Protractor will not attempt to synchronize with the page before
|
||||
* performing actions. This can be harmful because Protractor will not wait
|
||||
* until $timeouts and $http calls have been processed, which can cause
|
||||
* tests to become flaky. This should be used only when necessary, such as
|
||||
* when a page continuously polls an API using $timeout.
|
||||
*
|
||||
* @type {boolean}
|
||||
*/
|
||||
ignoreSynchronization: boolean;
|
||||
|
||||
/**
|
||||
* An object that holds custom test parameters.
|
||||
*
|
||||
* @type {Object}
|
||||
*/
|
||||
params: any;
|
||||
|
||||
//endregion
|
||||
|
||||
//region Methods
|
||||
|
||||
/**
|
||||
* Helper function for finding elements.
|
||||
*
|
||||
* @type {function(webdriver.Locator): ElementFinder}
|
||||
*/
|
||||
element(locator: webdriver.Locator): ElementFinder;
|
||||
|
||||
/**
|
||||
* Helper function for finding elements by css.
|
||||
*
|
||||
* @type {function(string): ElementFinder}
|
||||
*/
|
||||
$(cssLocator: string): ElementFinder;
|
||||
|
||||
/**
|
||||
* Helper function for finding arrays of elements by css.
|
||||
*
|
||||
* @type {function(string): ElementArrayFinder}
|
||||
*/
|
||||
$$(cssLocator: string): ElementArrayFinder;
|
||||
|
||||
/**
|
||||
* Instruct webdriver to wait until Angular has finished rendering and has
|
||||
* no outstanding $http calls before continuing.
|
||||
*
|
||||
* @return {!webdriver.promise.Promise} A promise that will resolve to the
|
||||
* scripts return value.
|
||||
*/
|
||||
waitForAngular(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Wrap a webdriver.WebElement with protractor specific functionality.
|
||||
*
|
||||
* @param {webdriver.WebElement} element
|
||||
* @return {protractor.WebElement} the wrapped web element.
|
||||
*/
|
||||
wrapWebElement(element: webdriver.WebElement): protractor.WebElement;
|
||||
|
||||
/**
|
||||
* Add a module to load before Angular whenever Protractor.get is called.
|
||||
* Modules will be registered after existing modules already on the page,
|
||||
* so any module registered here will override preexisting modules with the same
|
||||
* name.
|
||||
*
|
||||
* @param {!string} name The name of the module to load or override.
|
||||
* @param {!string|Function} script The JavaScript to load the module.
|
||||
*/
|
||||
addMockModule(name: string, script: string): void;
|
||||
addMockModule(name: string, script: any): void;
|
||||
|
||||
/**
|
||||
* Clear the list of registered mock modules.
|
||||
*/
|
||||
clearMockModules(): void;
|
||||
|
||||
/**
|
||||
* Returns the current absolute url from AngularJS.
|
||||
*/
|
||||
getLocationAbsUrl(): webdriver.promise.Promise;
|
||||
|
||||
/**
|
||||
* Pauses the test and injects some helper functions into the browser, so that
|
||||
* debugging may be done in the browser console.
|
||||
*
|
||||
* This should be used under node in debug mode, i.e. with
|
||||
* protractor debug <configuration.js>
|
||||
*
|
||||
* While in the debugger, commands can be scheduled through webdriver by
|
||||
* entering the repl:
|
||||
* debug> repl
|
||||
* Press Ctrl + C to leave rdebug repl
|
||||
* > ptor.findElement(protractor.By.input('user').sendKeys('Laura'));
|
||||
* > ptor.debugger();
|
||||
* debug> c
|
||||
*
|
||||
* This will run the sendKeys command as the next task, then re-enter the
|
||||
* debugger.
|
||||
*/
|
||||
debugger(): void;
|
||||
|
||||
/**
|
||||
* Schedule a command to find an element on the page. If the element cannot be
|
||||
* found, a {@code bot.ErrorCode.NO_SUCH_ELEMENT} result will be returned
|
||||
* by the driver. Unlike other commands, this error cannot be suppressed. In
|
||||
* other words, scheduling a command to find an element doubles as an assert
|
||||
* that the element is present on the page. To test whether an element is
|
||||
* present on the page, use {@code #isElementPresent} instead.
|
||||
*
|
||||
* <p>The search criteria for find an element may either be a
|
||||
* {@code webdriver.Locator} object, or a simple JSON object whose sole key
|
||||
* is one of the accepted locator strategies, as defined by
|
||||
* {@code webdriver.Locator.Strategy}. For example, the following two statements
|
||||
* are equivalent:
|
||||
* <code><pre>
|
||||
* var e1 = driver.findElement(By.id('foo'));
|
||||
* var e2 = driver.findElement({id:'foo'});
|
||||
* </pre></code>
|
||||
*
|
||||
* <p>When running in the browser, a WebDriver cannot manipulate DOM elements
|
||||
* directly; it may do so only through a {@link webdriver.WebElement} reference.
|
||||
* This function may be used to generate a WebElement from a DOM element. A
|
||||
* reference to the DOM element will be stored in a known location and this
|
||||
* driver will attempt to retrieve it through {@link #executeScript}. If the
|
||||
* element cannot be found (eg, it belongs to a different document than the
|
||||
* one this instance is currently focused on), a
|
||||
* {@link bot.ErrorCode.NO_SUCH_ELEMENT} error will be returned.
|
||||
*
|
||||
* @param {!(webdriver.Locator|Object.<string>|Element)} locatorOrElement The
|
||||
* locator strategy to use when searching for the element, or the actual
|
||||
* DOM element to be located by the server.
|
||||
* @param {...} var_args Arguments to pass to {@code #executeScript} if using a
|
||||
* JavaScript locator. Otherwise ignored.
|
||||
* @return {!protractor.WebElement} A WebElement that can be used to issue
|
||||
* commands against the located element. If the element is not found, the
|
||||
* element will be invalidated and all scheduled commands aborted.
|
||||
*/
|
||||
findElement(locatorOrElement: webdriver.Locator, ...var_args: any[]): protractor.WebElement;
|
||||
findElement(locatorOrElement: any, ...var_args: any[]): protractor.WebElement;
|
||||
|
||||
//endregion
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new instance of Protractor by wrapping a webdriver instance.
|
||||
*
|
||||
* @param {webdriver.WebDriver} webdriver The configured webdriver instance.
|
||||
* @param {string=} opt_baseUrl A URL to prepend to relative gets.
|
||||
* @return {Protractor}
|
||||
*/
|
||||
function wrapDriver(webdriver: webdriver.WebDriver, opt_baseUrl?: string, opt_rootElement?: string): Protractor;
|
||||
|
||||
/**
|
||||
* Set a singleton instance of protractor.
|
||||
* @param {Protractor} ptor
|
||||
*/
|
||||
function setInstance(ptor: Protractor): void;
|
||||
|
||||
/**
|
||||
* Get the singleton instance.
|
||||
* @return {Protractor}
|
||||
*/
|
||||
function getInstance(): Protractor;
|
||||
|
||||
}
|
||||
|
||||
interface cssSelectorHelper {
|
||||
(cssLocator: string): protractor.ElementFinder;
|
||||
}
|
||||
|
||||
declare var browser: protractor.Protractor;
|
||||
declare var by: protractor.IProtractorLocatorStrategy;
|
||||
declare var element: protractor.Element;
|
||||
declare var $: cssSelectorHelper;
|
||||
declare var $$: cssSelectorHelper;
|
||||
|
||||
declare module 'protractor' {
|
||||
export = protractor;
|
||||
}
|
||||
+22
-19
@@ -113,9 +113,12 @@ class EmployeeCollection extends Backbone.Collection<Employee> {
|
||||
class Book extends Backbone.Model {
|
||||
title: string;
|
||||
author: string;
|
||||
published: boolean;
|
||||
}
|
||||
|
||||
class Library extends Backbone.Collection<Book> {
|
||||
// This model definition is here only to test type compatibility of the model, but it
|
||||
// is not necessary in working code as it is automatically inferred through generics.
|
||||
model: typeof Book;
|
||||
}
|
||||
|
||||
@@ -123,31 +126,31 @@ class Books extends Backbone.Collection<Book> { }
|
||||
|
||||
function test_collection() {
|
||||
|
||||
var books = new Library();
|
||||
var books = new Books();
|
||||
|
||||
books.each(book => {
|
||||
book.get("title");
|
||||
});
|
||||
var book1: Book = new Book({ title: "Title 1", author: "Mike" });
|
||||
books.add(book1);
|
||||
|
||||
var titles = books.map(book => {
|
||||
return book.get("title");
|
||||
});
|
||||
// Objects can be added to collection by casting to model type.
|
||||
// Compiler will check if object properties are valid for the cast.
|
||||
// This gives better type checking than declaring an `any` overload.
|
||||
books.add(<Book>{ title: "Title 2", author: "Mikey" });
|
||||
|
||||
var publishedBooks = books.filter(book => {
|
||||
return book.get("published") === true;
|
||||
});
|
||||
|
||||
var alphabetical = books.sortBy((book: Book): number => {
|
||||
return null;
|
||||
});
|
||||
|
||||
var model: Book = new Book({title: "Test", author: "Mike"});
|
||||
books.add(model);
|
||||
var model2: Book = model.collection.first();
|
||||
if (model !== model2) {
|
||||
var model: Book = book1.collection.first();
|
||||
if (model !== book1) {
|
||||
throw new Error("Error");
|
||||
}
|
||||
|
||||
books.each(book =>
|
||||
book.get("title"));
|
||||
|
||||
var titles = books.map(book =>
|
||||
book.get("title"));
|
||||
|
||||
var publishedBooks = books.filter(book =>
|
||||
book.get("published") === true);
|
||||
|
||||
var alphabetical = books.sortBy((book: Book): number => null);
|
||||
}
|
||||
|
||||
//////////
|
||||
|
||||
Vendored
+23
-3
@@ -113,8 +113,23 @@ declare module Backbone {
|
||||
|
||||
fetch(options?: ModelFetchOptions): JQueryXHR;
|
||||
|
||||
get(attributeName: string): any;
|
||||
set(attributeName: string, value: any, options?: ModelSetOptions): Model;
|
||||
/**
|
||||
* For strongly-typed access to attributes, use the `get` method only privately in public getter properties.
|
||||
* @example
|
||||
* get name(): string {
|
||||
* return super.get("name");
|
||||
* }
|
||||
**/
|
||||
/*private*/ get(attributeName: string): any;
|
||||
|
||||
/**
|
||||
* For strongly-typed assignment of attributes, use the `set` method only privately in public setter properties.
|
||||
* @example
|
||||
* set name(value: string) {
|
||||
* super.set("name", value);
|
||||
* }
|
||||
**/
|
||||
/*private*/ set(attributeName: string, value: any, options?: ModelSetOptions): Model;
|
||||
set(obj: any, options?: ModelSetOptions): Model;
|
||||
|
||||
change(): any;
|
||||
@@ -170,7 +185,12 @@ declare module Backbone {
|
||||
add(model: TModel, options?: AddOptions): Collection<TModel>;
|
||||
add(models: TModel[], options?: AddOptions): Collection<TModel>;
|
||||
at(index: number): TModel;
|
||||
/**
|
||||
* Get a model from a collection, specified by an id, a cid, or by passing in a model.
|
||||
**/
|
||||
get(id: number): TModel;
|
||||
get(id: string): TModel;
|
||||
get(id: Model): TModel;
|
||||
create(attributes: any, options?: ModelSaveOptions): TModel;
|
||||
pluck(attribute: string): any[];
|
||||
push(model: TModel, options?: AddOptions): TModel;
|
||||
@@ -359,7 +379,7 @@ declare module Backbone {
|
||||
|
||||
// Utility
|
||||
function noConflict(): typeof Backbone;
|
||||
function setDomLibrary(jQueryNew: any): any;
|
||||
var $: JQueryStatic;
|
||||
}
|
||||
|
||||
declare module "backbone" {
|
||||
|
||||
@@ -0,0 +1,233 @@
|
||||
// Type definitions for big.js
|
||||
// Project: https://github.com/MikeMcl/big.js/
|
||||
// Definitions by: Steve Ognibene <https://github.com/nycdotnet/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
///<reference path="big.js.d.ts" />
|
||||
|
||||
/*
|
||||
|
||||
Tests include code from http://mikemcl.github.io/big.js/
|
||||
|
||||
Minor changes have been made such as adding variable definitions where required.
|
||||
|
||||
*/
|
||||
|
||||
function constructorTests() {
|
||||
var x = new Big(9) // '9'
|
||||
var y = new Big(x) // '9'
|
||||
var d = Big(435.345) // 'new' is optional
|
||||
var e = Big('435.345') // 'new' is optional
|
||||
var a = new Big('5032485723458348569331745.33434346346912144534543')
|
||||
var b = new Big('4.321e+4') // '43210'
|
||||
var c = new Big('-735.0918e-430') // '-7.350918e-428'
|
||||
}
|
||||
|
||||
function staticPropertiesTests() {
|
||||
Big.DP = 40;
|
||||
Big.RM = 3;
|
||||
Big.RM = BigJsLibrary.RoundingMode.RoundAwayFromZero;
|
||||
}
|
||||
|
||||
function absTests() {
|
||||
var x = new Big(-0.8);
|
||||
x.abs(); // '0.8'
|
||||
}
|
||||
|
||||
function cmpTests() {
|
||||
var x = new Big(6);
|
||||
var y = new Big(5);
|
||||
x.cmp(y); // 1
|
||||
y.cmp(x.minus(1)); // 0
|
||||
}
|
||||
|
||||
function divTests() {
|
||||
var x = new Big(355);
|
||||
var y = new Big(113);
|
||||
x.div(y); // '3.14159292035398230088'
|
||||
Big.DP = 2;
|
||||
x.div(y); // '3.14'
|
||||
x.div(5); // '71'
|
||||
}
|
||||
|
||||
function eqTests() {
|
||||
0 === 1e-324; // true
|
||||
var x = new Big(0);
|
||||
x.eq('1e-324'); // false
|
||||
Big(-0).eq(x); // true ( -0 === 0 )
|
||||
}
|
||||
|
||||
function gtTests() {
|
||||
0.1 > 0.3 - 0.2; // true
|
||||
var x = new Big(0.1);
|
||||
x.gt(Big(0.3).minus(0.2)); // false
|
||||
Big(0).gt(x); // false
|
||||
}
|
||||
|
||||
function gteTests() {
|
||||
0.3 - 0.2 >= 0.1; // false
|
||||
var x = new Big(0.3).minus(0.2);
|
||||
x.gte(0.1); // true
|
||||
Big(1).gte(x); // true
|
||||
}
|
||||
|
||||
function ltTests() {
|
||||
0.3 - 0.2 < 0.1; // true
|
||||
var x = new Big(0.3).minus(0.2);
|
||||
x.lt(0.1); // false
|
||||
Big(0).lt(x); // true
|
||||
}
|
||||
|
||||
function lteTests() {
|
||||
0.1 <= 0.3 - 0.2; // false
|
||||
var x = new Big(0.1);
|
||||
x.lte(Big(0.3).minus(0.2)); // true
|
||||
Big(-1).lte(x); // true
|
||||
}
|
||||
|
||||
function minusTests() {
|
||||
0.3 - 0.1; // 0.19999999999999998
|
||||
var x = new Big(0.3);
|
||||
x.minus(0.1); // '0.2'
|
||||
}
|
||||
|
||||
function modTests() {
|
||||
1 % 0.9 // 0.09999999999999998
|
||||
var x = Big(1);
|
||||
x.mod(0.9) // '0.1'
|
||||
}
|
||||
|
||||
function plusTests() {
|
||||
0.1 + 0.2 // 0.30000000000000004
|
||||
var x = new Big(0.1)
|
||||
var y = x.plus(0.2) // '0.3'
|
||||
Big(0.7).plus(x).plus(y) // '1'
|
||||
}
|
||||
|
||||
function powTests() {
|
||||
Math.pow(0.7, 2) // 0.48999999999999994
|
||||
var x = new Big(0.7)
|
||||
x.pow(2) // '0.49'
|
||||
Big.DP = 20
|
||||
Big(3).pow(-2) // '0.11111111111111111111'
|
||||
|
||||
new Big(123.456).pow(1000).toString().length // 5099
|
||||
new Big(2).pow(1e+6) // Time taken (Node.js): 9 minutes 34 secs.
|
||||
}
|
||||
|
||||
function roundTests() {
|
||||
var x = 123.45
|
||||
Math.round(x) // 123
|
||||
var y = new Big(x)
|
||||
y.round() // '123'
|
||||
y.round(2) // '123.45'
|
||||
y.round(10) // '123.45'
|
||||
y.round(1, 0) // '123.4'
|
||||
y.round(1, 1) // '123.5'
|
||||
y.round(1, 2) // '123.4'
|
||||
y.round(1, 3) // '123.5'
|
||||
y // '123.45'
|
||||
}
|
||||
|
||||
function sqrtTests() {
|
||||
var x = new Big(16)
|
||||
x.sqrt() // '4'
|
||||
var y = new Big(3)
|
||||
y.sqrt() // '1.73205080756887729353'
|
||||
}
|
||||
|
||||
function timesTests() {
|
||||
0.6 * 3 // 1.7999999999999998
|
||||
var x = new Big(0.6)
|
||||
var y = x.times(3) // '1.8'
|
||||
Big('7e+500').times(y) // '1.26e+501'
|
||||
}
|
||||
|
||||
function toExponentialTests() {
|
||||
var x = 45.6
|
||||
var y = new Big(x)
|
||||
x.toExponential() // '4.56e+1'
|
||||
y.toExponential() // '4.56e+1'
|
||||
x.toExponential(0) // '5e+1'
|
||||
y.toExponential(0) // '5e+1'
|
||||
x.toExponential(1) // '4.6e+1'
|
||||
y.toExponential(1) // '4.6e+1'
|
||||
x.toExponential(3) // '4.560e+1'
|
||||
y.toExponential(3) // '4.560e+1'
|
||||
}
|
||||
|
||||
function toFixedTests() {
|
||||
var x = 45.6
|
||||
var y = new Big(x)
|
||||
x.toFixed() // '46'
|
||||
y.toFixed() // '45.6'
|
||||
y.toFixed(0) // '46'
|
||||
x.toFixed(3) // '45.600'
|
||||
y.toFixed(3) // '45.600'
|
||||
}
|
||||
|
||||
function toPrecisionTests() {
|
||||
var x = 45.6
|
||||
var y = new Big(x)
|
||||
x.toPrecision() // '45.6'
|
||||
y.toPrecision() // '45.6'
|
||||
x.toPrecision(1) // '5e+1'
|
||||
y.toPrecision(1) // '5e+1'
|
||||
x.toPrecision(5) // '45.600'
|
||||
y.toPrecision(5) // '45.600'
|
||||
}
|
||||
|
||||
function toStringTests() {
|
||||
var x = new Big('9.99e+20')
|
||||
x.toString() // '999000000000000000000'
|
||||
var y = new Big('1E21')
|
||||
x.toString() // '1e+21'
|
||||
}
|
||||
|
||||
function valueOfTests() {
|
||||
var x = new Big('177.7e+457')
|
||||
x.valueOf() // '1.777e+459'
|
||||
}
|
||||
|
||||
function toJSONTests() {
|
||||
var x = new Big('177.7e+457')
|
||||
var y = new Big(235.4325)
|
||||
var z = new Big('0.0098074')
|
||||
var str = JSON.stringify([x, y, z])
|
||||
|
||||
var a = new Big('123').toJSON();
|
||||
|
||||
JSON.parse(str, function (k, v) { return k === '' ? v : new Big(v) }) // Returns an array of three Big numbers.
|
||||
}
|
||||
|
||||
function propertiesTest1() {
|
||||
var x = new Big(0.123) // '0.123'
|
||||
x.toExponential() // '1.23e-1'
|
||||
x.c // '1,2,3'
|
||||
x.e // -1
|
||||
x.s // 1
|
||||
|
||||
var y = new Number(-123.4567000e+2) // '-12345.67'
|
||||
y.toExponential() // '-1.234567e+4'
|
||||
var z = new Big('-123.4567000e+2') // '-12345.67'
|
||||
z.toExponential() // '-1.234567e+4'
|
||||
z.c // '1,2,3,4,5,6,7'
|
||||
z.e // 4
|
||||
z.s // -1
|
||||
}
|
||||
|
||||
function propertiesTest2() {
|
||||
var x = new Big('1234.000') // '1234'
|
||||
x.toExponential() // '1.234e+3'
|
||||
x.c // '1,2,3,4'
|
||||
x.e // 3
|
||||
|
||||
x.e = -5
|
||||
x // '0.00001234'
|
||||
}
|
||||
|
||||
function propertiesTest3() {
|
||||
var y = new Big(-0) // '0'
|
||||
y.c // '0' [0].toString()
|
||||
y.e // 0
|
||||
y.s // -1
|
||||
}
|
||||
Vendored
+200
@@ -0,0 +1,200 @@
|
||||
// Type definitions for big.js
|
||||
// Project: https://github.com/MikeMcl/big.js/
|
||||
// Definitions by: Steve Ognibene <https://github.com/nycdotnet/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
declare module BigJsLibrary {
|
||||
|
||||
export enum RoundingMode {
|
||||
RoundTowardsZero = 0,
|
||||
RoundTowardsNearestAwayFromZero = 1,
|
||||
RoundTowardsNearestTowardsEven = 2,
|
||||
RoundAwayFromZero = 3
|
||||
}
|
||||
|
||||
interface BigJS extends BigJS_Constructors {
|
||||
/** The maximum number of decimal places of the results of operations involving division.
|
||||
It is relevant only to the div and sqrt methods, and the pow method when the exponent is negative.
|
||||
@default 40 */
|
||||
DP: number;
|
||||
|
||||
/** The rounding mode used in the above operations and by round, toExponential, toFixed and toPrecision.
|
||||
Default is RoundTowardsNearestAwayFromZero
|
||||
@default 1 */
|
||||
RM: RoundingMode;
|
||||
}
|
||||
|
||||
interface BigJS_Constructors {
|
||||
/** A decimal value. */
|
||||
new (value: number): BigJS;
|
||||
/** A decimal value.
|
||||
String values may be in exponential, as well as normal (non-exponential) notation. There is no limit to the number of digits of a string value (other than that of Javascript's maximum array size), but the largest recommended exponent magnitude is 1e+6. Infinity, NaN and hexadecimal literal strings, e.g. '0xff', are not valid.
|
||||
String values in octal literal form will be interpreted as decimals, e.g. '011' is 11, not 9. */
|
||||
new (value: string): BigJS;
|
||||
/** A decimal value. */
|
||||
new (value: BigJS): BigJS;
|
||||
/** A decimal value. */
|
||||
(value: number): BigJS;
|
||||
/** A decimal value.
|
||||
String values may be in exponential, as well as normal (non-exponential) notation. There is no limit to the number of digits of a string value (other than that of Javascript's maximum array size), but the largest recommended exponent magnitude is 1e+6. Infinity, NaN and hexadecimal literal strings, e.g. '0xff', are not valid.
|
||||
String values in octal literal form will be interpreted as decimals, e.g. '011' is 11, not 9. */
|
||||
(value: string): BigJS;
|
||||
/** A decimal value. */
|
||||
(value: BigJS): BigJS;
|
||||
}
|
||||
|
||||
/** BigJS instance methods */
|
||||
interface BigJS extends BigJS_Constructors {
|
||||
/** Returns a Big number whose value is the absolute value, i.e. the magnitude, of this Big number. */
|
||||
abs(): BigJS;
|
||||
|
||||
/** Compare
|
||||
@returns {Number}
|
||||
1 = If the value of this Big number is greater than the value of n
|
||||
-1 = If the value of this Big number is less than the value of n
|
||||
0 = If this Big number and n have the same value */
|
||||
cmp(n: number): number;
|
||||
/** Compare
|
||||
@returns {Number}
|
||||
1 = If the value of this Big number is greater than the value of n
|
||||
-1 = If the value of this Big number is less than the value of n
|
||||
0 = If this Big number and n have the same value */
|
||||
cmp(n: string): number;
|
||||
/** Compare
|
||||
@returns {Number}
|
||||
1 = If the value of this Big number is greater than the value of n
|
||||
-1 = If the value of this Big number is less than the value of n
|
||||
0 = If this Big number and n have the same value */
|
||||
cmp(n: BigJS): number;
|
||||
|
||||
/** Returns a Big number whose value is the value of this Big number divided by n. */
|
||||
div(n: number): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number divided by n. */
|
||||
div(n: string): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number divided by n. */
|
||||
div(n: BigJS): BigJS;
|
||||
|
||||
/** Returns true if the value of this Big equals the value of n, otherwise returns false. */
|
||||
eq(n: number): boolean;
|
||||
/** Returns true if the value of this Big equals the value of n, otherwise returns false. */
|
||||
eq(n: string): boolean;
|
||||
/** Returns true if the value of this Big equals the value of n, otherwise returns false. */
|
||||
eq(n: BigJS): boolean;
|
||||
|
||||
/** Returns true if the value of this Big is greater than the value of n, otherwise returns false. */
|
||||
gt(n: number): boolean;
|
||||
/** Returns true if the value of this Big is greater than the value of n, otherwise returns false. */
|
||||
gt(n: string): boolean;
|
||||
/** Returns true if the value of this Big is greater than the value of n, otherwise returns false. */
|
||||
gt(n: BigJS): boolean;
|
||||
|
||||
/** Returns true if the value of this Big is greater than or equal to the value of n, otherwise returns false. */
|
||||
gte(n: number): boolean;
|
||||
/** Returns true if the value of this Big is greater than or equal to the value of n, otherwise returns false. */
|
||||
gte(n: string): boolean;
|
||||
/** Returns true if the value of this Big is greater than or equal to the value of n, otherwise returns false. */
|
||||
gte(n: BigJS): boolean;
|
||||
|
||||
/** Returns true if the value of this Big is less than the value of n, otherwise returns false. */
|
||||
lt(n: number): boolean;
|
||||
/** Returns true if the value of this Big is less than the value of n, otherwise returns false. */
|
||||
lt(n: string): boolean;
|
||||
/** Returns true if the value of this Big is less than the value of n, otherwise returns false. */
|
||||
lt(n: BigJS): boolean;
|
||||
|
||||
/** Returns true if the value of this Big is less than or equal to the value of n, otherwise returns false. */
|
||||
lte(n: number): boolean;
|
||||
/** Returns true if the value of this Big is less than or equal to the value of n, otherwise returns false. */
|
||||
lte(n: string): boolean;
|
||||
/** Returns true if the value of this Big is less than or equal to the value of n, otherwise returns false. */
|
||||
lte(n: BigJS): boolean;
|
||||
|
||||
/** Returns a Big number whose value is the value of this Big number minus n. */
|
||||
minus(n: number): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number minus n. */
|
||||
minus(n: string): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number minus n. */
|
||||
minus(n: BigJS): BigJS;
|
||||
|
||||
/** Returns a Big number whose value is the value of this Big number modulo n, i.e. the integer remainder of dividing this Big number by n.
|
||||
The result will have the same sign as this Big number, and it will match that of Javascript's % operator (within the limits of its precision) and BigDecimal's remainder method. */
|
||||
mod(n: number): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number modulo n, i.e. the integer remainder of dividing this Big number by n.
|
||||
The result will have the same sign as this Big number, and it will match that of Javascript's % operator (within the limits of its precision) and BigDecimal's remainder method. */
|
||||
mod(n: string): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number modulo n, i.e. the integer remainder of dividing this Big number by n.
|
||||
The result will have the same sign as this Big number, and it will match that of Javascript's % operator (within the limits of its precision) and BigDecimal's remainder method. */
|
||||
mod(n: BigJS): BigJS;
|
||||
|
||||
/** Returns a Big number whose value is the value of this Big number plus n. */
|
||||
plus(n: number): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number plus n. */
|
||||
plus(n: string): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number plus n. */
|
||||
plus(n: BigJS): BigJS;
|
||||
|
||||
/** Returns a Big number whose value is the value of this Big number raised to the power exp.
|
||||
If exp is negative and the result has more fraction digits than is specified by Big.DP, it will be rounded to Big.DP decimal places using rounding mode Big.RM.
|
||||
@param exp integer, -1e+6 to 1e+6 inclusive */
|
||||
pow(exp: number): BigJS;
|
||||
|
||||
/** Returns a Big number whose value is the value of this Big number rounded to a whole number. */
|
||||
round(): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number rounded using rounding mode rm to a maximum of dp decimal places.
|
||||
@param dp Number of decimal places (0 to 1e+6 inclusive). If dp is omitted or is null or undefined, the return value is n rounded to a whole number. */
|
||||
round(dp: number): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number rounded using rounding mode rm to a maximum of dp decimal places.
|
||||
@param dp Number of decimal places (0 to 1e+6 inclusive). If dp is omitted or is null or undefined, the return value is n rounded to a whole number.
|
||||
@param rm Rounding mode. If rm is omitted or is null or undefined, the current Big.RM setting is used. */
|
||||
round(dp: number, rm: RoundingMode): BigJS;
|
||||
|
||||
/** Returns a Big number whose value is the square root of this Big number. */
|
||||
sqrt(): BigJS;
|
||||
|
||||
/** Returns a Big number whose value is the value of this Big number times n. */
|
||||
times(n: number): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number times n. */
|
||||
times(n: string): BigJS;
|
||||
/** Returns a Big number whose value is the value of this Big number times n. */
|
||||
times(n: BigJS): BigJS;
|
||||
|
||||
/** Returns a string representing the value of this Big number in exponential notation to a fixed number of decimal places dp. */
|
||||
toExponential(): string;
|
||||
/** Returns a string representing the value of this Big number in exponential notation to a fixed number of decimal places dp.
|
||||
@param dp Number of decimal places (0 to 1e+6 inclusive). If dp is omitted, or is null or undefined, the number of digits after the decimal point defaults to the minimum number of digits necessary to represent the value exactly. */
|
||||
toExponential(dp: number): string;
|
||||
|
||||
/** Returns a string representing the value of this Big number in normal notation to a fixed number of decimal places dp. */
|
||||
toFixed(): string;
|
||||
/** Returns a string representing the value of this Big number in normal notation to a fixed number of decimal places dp.
|
||||
@param dp Number of decimal places (0 to 1e+6 inclusive). If dp is omitted, or is null or undefined, then the return value is simply the value in normal notation. This is also unlike Number.prototype.toFixed, which returns the value to zero decimal places. */
|
||||
toFixed(dp: number): string;
|
||||
|
||||
/** Returns a string representing the value of this Big number to the specified number of significant digits sd. */
|
||||
toPrecision(): string;
|
||||
/** Returns a string representing the value of this Big number to the specified number of significant digits sd.
|
||||
@param sd significant digits. If sd is omitted, or is null or undefined, then the return value is the same as .toString(). */
|
||||
toPrecision(sd: number /** number of significant digits (0 to 1e+6 inclusive) */): string;
|
||||
|
||||
/** Returns a string representing the value of this Big number. */
|
||||
toString(): string;
|
||||
|
||||
/** As toString. */
|
||||
valueOf(): string;
|
||||
|
||||
/** As toString. */
|
||||
toJSON(): string;
|
||||
|
||||
/** coefficient (significand) */
|
||||
c: number[];
|
||||
|
||||
/** exponent (Integer, -1e+6 to 1e+6 inclusive) */
|
||||
e: number;
|
||||
|
||||
/** sign (-1 or 1) */
|
||||
s: number;
|
||||
}
|
||||
}
|
||||
|
||||
declare var Big: BigJsLibrary.BigJS;
|
||||
Vendored
-1
@@ -2235,7 +2235,6 @@ declare module Em {
|
||||
var print: typeof Ember.Handlebars.print;
|
||||
var logger: typeof Ember.Handlebars.logger;
|
||||
var log: typeof Ember.Handlebars.log;
|
||||
var compile: typeof Ember.Handlebars.compile;
|
||||
}
|
||||
class HashLocation extends Ember.HashLocation { }
|
||||
class HistoryLocation extends Ember.HistoryLocation { }
|
||||
|
||||
@@ -698,3 +698,5 @@ describe("Asynchronous specs", function () {
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000;
|
||||
|
||||
Vendored
+1
@@ -429,4 +429,5 @@ declare module jasmine {
|
||||
|
||||
export var HtmlReporter: HtmlReporter;
|
||||
export var HtmlSpecFilter: HtmlSpecFilter;
|
||||
export var DEFAULT_TIMEOUT_INTERVAL: number;
|
||||
}
|
||||
|
||||
@@ -9,3 +9,17 @@ $.blockUI(opt);
|
||||
$.unblockUI();
|
||||
$("#test").block().unblock();
|
||||
$("#test").block(opt);
|
||||
|
||||
$.blockUI.defaults.css.border = '5px solid red';
|
||||
$.blockUI.defaults.fadeOut = 200;
|
||||
|
||||
$.blockUI({ message: $('#domMessage') });
|
||||
$.unblockUI({ fadeOut: 200 });
|
||||
|
||||
$.blockUI({
|
||||
fadeIn: 1000,
|
||||
timeout: 2000,
|
||||
onBlock: function() {
|
||||
alert('Page is now blocked; fadeIn complete');
|
||||
}
|
||||
});
|
||||
|
||||
Vendored
+5
-5
@@ -7,7 +7,7 @@
|
||||
|
||||
interface JQBlockUIOptions {
|
||||
/** message displayed when blocking (use null for no message) */
|
||||
message?: string;
|
||||
message?: any;
|
||||
/** title string; only used when theme == true */
|
||||
title?: string;
|
||||
/** only used when theme == true (requires jquery-ui.js to be loaded) */
|
||||
@@ -76,7 +76,7 @@ interface JQBlockUIOptions {
|
||||
focusInput?: boolean;
|
||||
|
||||
/** callback method invoked when fadeIn has completed and blocking message is visible */
|
||||
onBlock?: boolean;
|
||||
onBlock?: () => void;
|
||||
|
||||
/**
|
||||
* callback method invoked when unblocking has completed; the callback is
|
||||
@@ -99,7 +99,7 @@ interface JQBlockUIOptions {
|
||||
|
||||
interface JQBlockUIStatic {
|
||||
/** default options */
|
||||
default?: JQBlockUIOptions;
|
||||
defaults?: JQBlockUIOptions;
|
||||
/** block user activity for the page */
|
||||
(): void;
|
||||
/**
|
||||
@@ -113,7 +113,7 @@ interface JQueryStatic {
|
||||
/** block user activity for the page */
|
||||
blockUI?: JQBlockUIStatic;
|
||||
/** unblock the page */
|
||||
unblockUI?: () => void;
|
||||
unblockUI?: JQBlockUIStatic;
|
||||
}
|
||||
|
||||
interface JQuery {
|
||||
@@ -125,5 +125,5 @@ interface JQuery {
|
||||
/**
|
||||
* unblock the element(s)
|
||||
*/
|
||||
unblock(): JQuery;
|
||||
unblock(option?: JQBlockUIOptions): JQuery;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
/// <reference path="jquery.pjax.d.ts" />
|
||||
/// <reference path="../jquery/jquery.d.ts" />
|
||||
|
||||
function test_pjax() {
|
||||
$.pjax();
|
||||
}
|
||||
|
||||
function test_pjax_selector() {
|
||||
$('a').pjax();
|
||||
}
|
||||
|
||||
function test_pjax_option() {
|
||||
$.pjax({
|
||||
area: 'body',
|
||||
load: {
|
||||
head: 'base, meta, link',
|
||||
css: true,
|
||||
script: true
|
||||
},
|
||||
cache: { click: true, submit: false, popstate: true },
|
||||
server: { query: null }
|
||||
});
|
||||
}
|
||||
|
||||
function test_pjax_event() {
|
||||
$.pjax({
|
||||
wait: 1000
|
||||
});
|
||||
$(document).bind('pjax.request', function () {
|
||||
$('div.loading').fadeIn(100);
|
||||
});
|
||||
$(document).bind('pjax.render', function () {
|
||||
$('div.loading').fadeOut(500);
|
||||
});
|
||||
}
|
||||
+189
@@ -0,0 +1,189 @@
|
||||
// Type definitions for jquery.pjax.ts by falsandtru
|
||||
// Project: https://github.com/falsandtru/jquery.pjax.js/
|
||||
// Definitions by: 新ゝ月 NewNotMoon <http://new.not-moon.net/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts" />
|
||||
|
||||
interface PjaxSetting {
|
||||
gns?: string;
|
||||
ns?: string;
|
||||
area?: any; // string, array, function( event, param, origUrl, destUrl )
|
||||
link?: string;
|
||||
filter?: any; // string, function()
|
||||
form?: string;
|
||||
scope?: Object;
|
||||
state?: any; // any, function(event, param, origUrl, destUrl )
|
||||
scrollTop?: any; // number, function( event, param, origUrl, destUrl ), null, false
|
||||
scrollLeft?: any; // number, function( event, param, origUrl, destUrl ), null, false
|
||||
scroll?: {
|
||||
delay?: number;
|
||||
record?: boolean //internal
|
||||
queue?: number[] //internal
|
||||
};
|
||||
ajax?: JQueryAjaxSettings;
|
||||
contentType?: string;
|
||||
load?: {
|
||||
head?: string;
|
||||
css?: boolean;
|
||||
script?: boolean;
|
||||
execute?: boolean;
|
||||
reload?: string;
|
||||
ignore?: string;
|
||||
sync?: boolean;
|
||||
ajax?: JQueryAjaxSettings;
|
||||
rewrite?: (element: any) => any;
|
||||
redirect?: boolean;
|
||||
};
|
||||
interval?: number;
|
||||
cache?: {
|
||||
click?: boolean;
|
||||
submit?: boolean;
|
||||
popstate?: boolean;
|
||||
get?: boolean;
|
||||
post?: boolean;
|
||||
page?: boolean;
|
||||
size?: number;
|
||||
mix?: number;
|
||||
expires?: {
|
||||
min?: number;
|
||||
max?: number;
|
||||
};
|
||||
};
|
||||
wait?: any; // number, function( event, param, origUrl, destUrl ): number
|
||||
fallback?: any; // boolean, function( event, param, origUrl, destUrl ): boolean
|
||||
fix?: {
|
||||
location?: boolean;
|
||||
history?: boolean;
|
||||
scroll?: boolean;
|
||||
reset?: boolean;
|
||||
};
|
||||
database?: boolean;
|
||||
server?: {
|
||||
query?: any; // string, object
|
||||
header?: {
|
||||
area?: boolean;
|
||||
head?: boolean;
|
||||
css?: boolean;
|
||||
script?: boolean;
|
||||
};
|
||||
};
|
||||
callback?: (event: JQueryEventObject, param: any) => any;
|
||||
callbacks?: {
|
||||
before?: (event: JQueryEventObject, param: any) => any;
|
||||
after?: (event: JQueryEventObject, param: any) => any;
|
||||
ajax?: {
|
||||
xhr?: (event: JQueryEventObject, param: any) => any;
|
||||
beforeSend?: (event: JQueryEventObject, param: any, data: any, ajaxSettings: any) => any;
|
||||
dataFilter?: (event: JQueryEventObject, param: any, data: any, dataType: any) => any;
|
||||
success?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
error?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string, errorThrown: any) => any;
|
||||
complete?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string) => any;
|
||||
done?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
fail?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string, errorThrown: any) => any;
|
||||
always?: (event: JQueryEventObject, param: any, XMLHttpRequest: XMLHttpRequest, textStatus: string) => any;
|
||||
};
|
||||
update?: {
|
||||
before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
cache?: {
|
||||
before?: (event: JQueryEventObject, param: any, cache: any) => any;
|
||||
after?: (event: JQueryEventObject, param: any, cache: any) => any;
|
||||
};
|
||||
redirect?: {
|
||||
before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
};
|
||||
url?: {
|
||||
before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
};
|
||||
title?: {
|
||||
before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
};
|
||||
head?: {
|
||||
before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
};
|
||||
content?: {
|
||||
before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
};
|
||||
scroll?: {
|
||||
before?: (event: JQueryEventObject, param: any) => any;
|
||||
after?: (event: JQueryEventObject, param: any) => any;
|
||||
};
|
||||
css?: {
|
||||
before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
};
|
||||
script?: {
|
||||
before?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
after?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
};
|
||||
render?: {
|
||||
before?: (event: JQueryEventObject, param: any) => any;
|
||||
after?: (event: JQueryEventObject, param: any) => any;
|
||||
};
|
||||
verify?: {
|
||||
before?: (event: JQueryEventObject, param: any) => any;
|
||||
after?: (event: JQueryEventObject, param: any) => any;
|
||||
};
|
||||
success?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
error?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
complete?: (event: JQueryEventObject, param: any, data: any, textStatus: string, XMLHttpRequest: XMLHttpRequest) => any;
|
||||
};
|
||||
param?: any;
|
||||
|
||||
// internal
|
||||
uuid?: string;
|
||||
nss?: {
|
||||
name?: string;
|
||||
event?: string[];
|
||||
click?: string;
|
||||
submit?: string;
|
||||
popstate?: string;
|
||||
scroll?: string;
|
||||
data?: string;
|
||||
class4html?: string;
|
||||
requestHeader?: string;
|
||||
};
|
||||
origLocation?: HTMLAnchorElement;
|
||||
destLocation?: HTMLAnchorElement;
|
||||
retry?: boolean;
|
||||
speedcheck?: boolean;
|
||||
disable?: boolean;
|
||||
option?: any;
|
||||
};
|
||||
}
|
||||
|
||||
interface JQueryStatic {
|
||||
pjax: {
|
||||
(setting?: PjaxSetting): any;
|
||||
enable(): any;
|
||||
disable(): any;
|
||||
click(url: string, attr: { href?: string; }): any;
|
||||
click(url: HTMLAnchorElement, attr: { href?: string; }): any;
|
||||
click(url: JQuery, attr: { href?: string; }): any;
|
||||
click(url: any, attr: { href?: string; }): any;
|
||||
submit(url: string, attr: { action?: string; method?: string; }, data: any): any;
|
||||
submit(url: HTMLFormElement, attr?: { action?: string; method?: string; }, data?: any): any;
|
||||
submit(url: JQuery, attr?: { action?: string; method?: string; }, data?: any): any;
|
||||
submit(url: any, attr?: { action?: string; method?: string; }, data?: any): any;
|
||||
follow(event: JQueryEventObject, ajax: JQueryXHR, timeStamp?: number): boolean;
|
||||
setCache(): any;
|
||||
setCache(url: string): any;
|
||||
setCache(url: string, data: string): any;
|
||||
setCache(url: string, data: string, textStatus: string, XMLHttpRequest: XMLHttpRequest): any;
|
||||
getCache(): any;
|
||||
getCache(url: string): any;
|
||||
removeCache(url: string): any;
|
||||
removeCache(): any;
|
||||
clearCache(): any;
|
||||
};
|
||||
}
|
||||
|
||||
interface JQuery {
|
||||
pjax(setting?: PjaxSetting): any;
|
||||
}
|
||||
Vendored
+1
-1
@@ -3655,7 +3655,7 @@ interface JQuery {
|
||||
*
|
||||
* @param func A function used as a test for each element in the set. this is the current DOM element.
|
||||
*/
|
||||
filter(func: (index: number) => any): JQuery;
|
||||
filter(func: (index: number, element: Element) => any): JQuery;
|
||||
/**
|
||||
* Reduce the set of matched elements to those that match the selector or pass the function's test.
|
||||
*
|
||||
|
||||
Vendored
+5
-2
@@ -609,11 +609,14 @@ declare module JQueryUI {
|
||||
orientation?: string;
|
||||
range?: any; // boolean or string
|
||||
step?: number;
|
||||
// value?: number;
|
||||
// values?: number[];
|
||||
value?: number;
|
||||
values?: number[];
|
||||
}
|
||||
|
||||
interface SliderUIParams {
|
||||
handle?: JQuery;
|
||||
value?: number;
|
||||
values?: number[];
|
||||
}
|
||||
|
||||
interface SliderEvent {
|
||||
|
||||
Vendored
+1
-1
@@ -45,7 +45,7 @@ declare module Kinetic {
|
||||
isDraggable(): boolean;
|
||||
isDragging(): boolean;
|
||||
isListening(): boolean;
|
||||
move(x: number, y: number): void;
|
||||
move(change:{x: number; y: number}): void;
|
||||
moveDown(): void;
|
||||
moveTo(newContainer: IContainer): void;
|
||||
moveToBottom(): void;
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/// <reference path="lunr.d.ts" />
|
||||
|
||||
/**
|
||||
* Basic test, from http://lunrjs.com/
|
||||
*/
|
||||
function basic_test() {
|
||||
var index = lunr(function () {
|
||||
this.field('title', {boost: 10});
|
||||
this.field('body');
|
||||
this.ref('id');
|
||||
});
|
||||
|
||||
index.add({
|
||||
id: 1,
|
||||
title: 'Foo',
|
||||
body: 'Foo foo foo!'
|
||||
});
|
||||
|
||||
index.add({
|
||||
id: 2,
|
||||
title: 'Bar',
|
||||
body: 'Bar bar bar!'
|
||||
});
|
||||
|
||||
index.search('foo');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Pipeline test, from http://lunrjs.com/
|
||||
*/
|
||||
function pipeline_test() {
|
||||
var index = lunr(function () {
|
||||
this.pipeline.add(function (token:string, tokenIndex:number, tokens:string[]):string {
|
||||
// text processing in here
|
||||
return token;
|
||||
});
|
||||
|
||||
this.pipeline.after(lunr.stopWordFilter, function (token:string, tokenIndex:number, tokens:string[]):string {
|
||||
// text processing in here
|
||||
return token;
|
||||
});
|
||||
})
|
||||
}
|
||||
Vendored
+839
@@ -0,0 +1,839 @@
|
||||
// Type definitions for lunr.js 0.5.4
|
||||
// Project: https://github.com/olivernn/lunr.js
|
||||
// Definitions by: Sebastian Lenz <https://github.com/sebastian-lenz>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* lunr - http://lunrjs.com - A bit like Solr, but much smaller and not as bright - 0.5.4
|
||||
* Copyright (C) 2014 Oliver Nightingale
|
||||
* MIT Licensed
|
||||
* @license
|
||||
*/
|
||||
declare module lunr
|
||||
{
|
||||
var version:string;
|
||||
|
||||
|
||||
/**
|
||||
* A function for splitting a string into tokens ready to be inserted into the search index.
|
||||
*
|
||||
* @param token The token to pass through the filter
|
||||
*/
|
||||
function tokenizer(token:string):string;
|
||||
|
||||
|
||||
/**
|
||||
* lunr.stemmer is an english language stemmer, this is a JavaScript implementation of
|
||||
* the PorterStemmer taken from http://tartaurs.org/~martin
|
||||
*
|
||||
* @param token The string to stem
|
||||
*/
|
||||
function stemmer(token:string):string;
|
||||
|
||||
|
||||
/**
|
||||
* lunr.stopWordFilter is an English language stop word list filter, any words contained
|
||||
* in the list will not be passed through the filter.
|
||||
*
|
||||
* This is intended to be used in the Pipeline. If the token does not pass the filter then
|
||||
* undefined will be returned.
|
||||
*
|
||||
* @param token The token to pass through the filter
|
||||
*/
|
||||
function stopWordFilter(token:string):string;
|
||||
|
||||
module stopWordFilter {
|
||||
var stopWords:SortedSet<string>;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* lunr.trimmer is a pipeline function for trimming non word characters from the beginning
|
||||
* and end of tokens before they enter the index.
|
||||
*
|
||||
* This implementation may not work correctly for non latin characters and should either
|
||||
* be removed or adapted for use with languages with non-latin characters.
|
||||
* @param token The token to pass through the filter
|
||||
*/
|
||||
function trimmer(token:string):string;
|
||||
|
||||
|
||||
/**
|
||||
* lunr.EventEmitter is an event emitter for lunr. It manages adding and removing event handlers
|
||||
* and triggering events and their handlers.
|
||||
*/
|
||||
class EventEmitter
|
||||
{
|
||||
/**
|
||||
* Can bind a single function to many different events in one call.
|
||||
*
|
||||
* @param eventName The name(s) of events to bind this function to.
|
||||
* @param handler The function to call when an event is fired. Binds a handler
|
||||
* function to a specific event(s).
|
||||
*/
|
||||
addListener(eventName:string, handler:Function):void;
|
||||
addListener(eventName:string, eventName2:string, handler:Function):void;
|
||||
addListener(eventName:string, eventName2:string, eventName3:string, handler:Function):void;
|
||||
addListener(eventName:string, eventName2:string, eventName3:string, eventName4:string, handler:Function):void;
|
||||
addListener(eventName:string, eventName2:string, eventName3:string, eventName4:string, eventName5:string, handler:Function):void;
|
||||
|
||||
|
||||
/**
|
||||
* Removes a handler function from a specific event.
|
||||
*
|
||||
* @param eventName The name of the event to remove this function from.
|
||||
* @param handler The function to remove from an event.
|
||||
*/
|
||||
removeListener(eventName:string, handler:Function):void;
|
||||
|
||||
|
||||
/**
|
||||
* Calls all functions bound to the given event.
|
||||
*
|
||||
* Additional data can be passed to the event handler as arguments to emit after the event name.
|
||||
*
|
||||
* @param eventName The name of the event to emit.
|
||||
* @param args
|
||||
*/
|
||||
emit(eventName:string, ...args:any[]):void;
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether a handler has ever been stored against an event.
|
||||
*
|
||||
* @param eventName The name of the event to check.
|
||||
*/
|
||||
hasHandler(eventName:string):boolean;
|
||||
}
|
||||
|
||||
|
||||
interface IPipelineFunction {
|
||||
(token:string):string;
|
||||
(token:string, tokenIndex:number):string;
|
||||
(token:string, tokenIndex:number, tokens:string[]):string;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* lunr.Pipelines maintain an ordered list of functions to be applied to all tokens in documents
|
||||
* entering the search index and queries being ran against the index.
|
||||
*
|
||||
* An instance of lunr.Index created with the lunr shortcut will contain a pipeline with a stop
|
||||
* word filter and an English language stemmer. Extra functions can be added before or after either
|
||||
* of these functions or these default functions can be removed.
|
||||
*
|
||||
* When run the pipeline will call each function in turn, passing a token, the index of that token
|
||||
* in the original list of all tokens and finally a list of all the original tokens.
|
||||
*
|
||||
* The output of functions in the pipeline will be passed to the next function in the pipeline.
|
||||
* To exclude a token from entering the index the function should return undefined, the rest of
|
||||
* the pipeline will not be called with this token.
|
||||
*
|
||||
* For serialisation of pipelines to work, all functions used in an instance of a pipeline should
|
||||
* be registered with lunr.Pipeline. Registered functions can then be loaded. If trying to load a
|
||||
* serialised pipeline that uses functions that are not registered an error will be thrown.
|
||||
*
|
||||
* If not planning on serialising the pipeline then registering pipeline functions is not necessary.
|
||||
*/
|
||||
class Pipeline
|
||||
{
|
||||
registeredFunctions:{[label:string]:Function};
|
||||
|
||||
|
||||
/**
|
||||
* Register a function with the pipeline.
|
||||
*
|
||||
* Functions that are used in the pipeline should be registered if the pipeline needs to be
|
||||
* serialised, or a serialised pipeline needs to be loaded.
|
||||
*
|
||||
* Registering a function does not add it to a pipeline, functions must still be added to instances
|
||||
* of the pipeline for them to be used when running a pipeline.
|
||||
*
|
||||
* @param fn The function to check for.
|
||||
* @param label The label to register this function with
|
||||
*/
|
||||
registerFunction(fn:IPipelineFunction, label:string):void;
|
||||
|
||||
|
||||
/**
|
||||
* Warns if the function is not registered as a Pipeline function.
|
||||
*
|
||||
* @param fn The function to check for.
|
||||
*/
|
||||
warnIfFunctionNotRegistered(fn:IPipelineFunction):void;
|
||||
|
||||
|
||||
/**
|
||||
* Adds new functions to the end of the pipeline.
|
||||
*
|
||||
* Logs a warning if the function has not been registered.
|
||||
*
|
||||
* @param functions Any number of functions to add to the pipeline.
|
||||
*/
|
||||
add(...functions:IPipelineFunction[]):void;
|
||||
|
||||
|
||||
/**
|
||||
* Adds a single function after a function that already exists in the pipeline.
|
||||
*
|
||||
* Logs a warning if the function has not been registered.
|
||||
*
|
||||
* @param existingFn A function that already exists in the pipeline.
|
||||
* @param newFn The new function to add to the pipeline.
|
||||
*/
|
||||
after(existingFn:IPipelineFunction, newFn:IPipelineFunction):void;
|
||||
|
||||
|
||||
/**
|
||||
* Adds a single function before a function that already exists in the pipeline.
|
||||
*
|
||||
* Logs a warning if the function has not been registered.
|
||||
*
|
||||
* @param existingFn A function that already exists in the pipeline.
|
||||
* @param newFn The new function to add to the pipeline.
|
||||
*/
|
||||
before(existingFn:IPipelineFunction, newFn:IPipelineFunction):void;
|
||||
|
||||
|
||||
/**
|
||||
* Removes a function from the pipeline.
|
||||
*
|
||||
* @param fn The function to remove from the pipeline.
|
||||
*/
|
||||
remove(fn:IPipelineFunction):void;
|
||||
|
||||
|
||||
/**
|
||||
* Runs the current list of functions that make up the pipeline against
|
||||
* the passed tokens.
|
||||
*
|
||||
* @param tokens The tokens to run through the pipeline.
|
||||
*/
|
||||
run(tokens:string[]):string[];
|
||||
|
||||
|
||||
/**
|
||||
* Resets the pipeline by removing any existing processors.
|
||||
*/
|
||||
reset():void;
|
||||
|
||||
|
||||
/**
|
||||
* Returns a representation of the pipeline ready for serialisation.
|
||||
*/
|
||||
toJSON():any;
|
||||
|
||||
|
||||
/**
|
||||
* Loads a previously serialised pipeline.
|
||||
*
|
||||
* All functions to be loaded must already be registered with lunr.Pipeline. If any function from
|
||||
* the serialised data has not been registered then an error will be thrown.
|
||||
*
|
||||
* @param serialised The serialised pipeline to load.
|
||||
*/
|
||||
static load(serialised:any):Pipeline;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* lunr.Vectors implement vector related operations for a series of elements.
|
||||
*/
|
||||
class Vector
|
||||
{
|
||||
list:Node;
|
||||
|
||||
|
||||
/**
|
||||
* Calculates the magnitude of this vector.
|
||||
*/
|
||||
magnitude():number;
|
||||
|
||||
|
||||
/**
|
||||
* Calculates the dot product of this vector and another vector.
|
||||
* @param otherVector The vector to compute the dot product with.
|
||||
*/
|
||||
dot(otherVector:Vector):number;
|
||||
|
||||
|
||||
/**
|
||||
* Calculates the cosine similarity between this vector and another vector.
|
||||
*
|
||||
* @param otherVector The other vector to calculate the
|
||||
*/
|
||||
similarity(otherVector:Vector):number;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* lunr.Vector.Node is a simple struct for each node in a lunr.Vector.
|
||||
*/
|
||||
class Node
|
||||
{
|
||||
/**
|
||||
* The index of the node in the vector.
|
||||
*/
|
||||
idx:number;
|
||||
|
||||
/**
|
||||
* The data at this node in the vector.
|
||||
*/
|
||||
val:number;
|
||||
|
||||
/**
|
||||
* The node directly after this node in the vector.
|
||||
*/
|
||||
next:Node;
|
||||
|
||||
|
||||
/**
|
||||
* @param idx The index of the node in the vector.
|
||||
* @param val The data at this node in the vector.
|
||||
* @param next The node directly after this node in the vector.
|
||||
*/
|
||||
constructor(idx:number, val:number, next:Node);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* lunr.SortedSets are used to maintain an array of unique values in a sorted order.
|
||||
*/
|
||||
class SortedSet<T>
|
||||
{
|
||||
elements:T[];
|
||||
|
||||
length:number;
|
||||
|
||||
|
||||
/**
|
||||
* Inserts new items into the set in the correct position to maintain the order.
|
||||
*
|
||||
* @param values The objects to add to this set.
|
||||
*/
|
||||
add(...values:T[]):void;
|
||||
|
||||
|
||||
/**
|
||||
* Converts this sorted set into an array.
|
||||
*/
|
||||
toArray():T[];
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new array with the results of calling a provided function on
|
||||
* every element in this sorted set.
|
||||
*
|
||||
* Delegates to Array.prototype.map and has the same signature.
|
||||
*
|
||||
* @param fn The function that is called on each element of the
|
||||
* @param ctx An optional object that can be used as the context
|
||||
*/
|
||||
map(fn:Function, ctx:any):T[];
|
||||
|
||||
|
||||
/**
|
||||
* Executes a provided function once per sorted set element.
|
||||
*
|
||||
* Delegates to Array.prototype.forEach and has the same signature.
|
||||
*
|
||||
* @param fn The function that is called on each element of the
|
||||
* @param ctx An optional object that can be used as the context
|
||||
*/
|
||||
forEach(fn:Function, ctx:any):any;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the index at which a given element can be found in the sorted
|
||||
* set, or -1 if it is not present.
|
||||
*
|
||||
* @param elem The object to locate in the sorted set.
|
||||
* @param start An optional index at which to start searching from
|
||||
* @param end An optional index at which to stop search from within
|
||||
*/
|
||||
indexOf(elem:T, start?:number, end?:number):number;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the position within the sorted set that an element should be
|
||||
* inserted at to maintain the current order of the set.
|
||||
*
|
||||
* This function assumes that the element to search for does not already exist
|
||||
* in the sorted set.
|
||||
*
|
||||
* @param elem - The elem to find the position for in the set
|
||||
* @param start - An optional index at which to start searching from
|
||||
* @param end - An optional index at which to stop search from within
|
||||
*/
|
||||
locationFor(elem:T, start?:number, end?:number):number;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new lunr.SortedSet that contains the elements in the
|
||||
* intersection of this set and the passed set.
|
||||
*
|
||||
* @param otherSet The set to intersect with this set.
|
||||
*/
|
||||
intersect(otherSet:SortedSet<T>):SortedSet<T>;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new lunr.SortedSet that contains the elements in the union of this
|
||||
* set and the passed set.
|
||||
*
|
||||
* @param otherSet The set to union with this set.
|
||||
*/
|
||||
union(otherSet:SortedSet<T>):SortedSet<T>;
|
||||
|
||||
|
||||
/**
|
||||
* Makes a copy of this set
|
||||
*/
|
||||
clone():SortedSet<T>;
|
||||
|
||||
|
||||
/**
|
||||
* Returns a representation of the sorted set ready for serialisation.
|
||||
*/
|
||||
toJSON():any;
|
||||
|
||||
|
||||
/**
|
||||
* Loads a previously serialised sorted set.
|
||||
*
|
||||
* @param serialisedData The serialised set to load.
|
||||
*/
|
||||
static load<T>(serialisedData:T[]):SortedSet<T>;
|
||||
}
|
||||
|
||||
|
||||
interface IIndexField
|
||||
{
|
||||
/**
|
||||
* The name of the field within the document that
|
||||
*/
|
||||
name:string;
|
||||
|
||||
/**
|
||||
* An optional boost that can be applied to terms in this field.
|
||||
*/
|
||||
boost:number;
|
||||
}
|
||||
|
||||
|
||||
interface IIndexSearchResult
|
||||
{
|
||||
ref:any;
|
||||
|
||||
score:number;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* lunr.Index is object that manages a search index. It contains the indexes and stores
|
||||
* all the tokens and document lookups. It also provides the main user facing API for
|
||||
* the library.
|
||||
*/
|
||||
class Index
|
||||
{
|
||||
eventEmitter:EventEmitter;
|
||||
|
||||
documentStore:Store<string>;
|
||||
|
||||
tokenStore:TokenStore;
|
||||
|
||||
corpusTokens:SortedSet<string>;
|
||||
|
||||
pipeline:Pipeline;
|
||||
|
||||
_fields:IIndexField[];
|
||||
|
||||
_ref:string;
|
||||
|
||||
_idfCache:{[key:string]:string};
|
||||
|
||||
|
||||
/**
|
||||
* Bind a handler to events being emitted by the index.
|
||||
*
|
||||
* The handler can be bound to many events at the same time.
|
||||
*
|
||||
* @param eventName The name(s) of events to bind the function to.
|
||||
* @param handler The function to call when an event is fired. Binds a handler
|
||||
* function to a specific event(s).
|
||||
*/
|
||||
on(eventName:string, handler:Function):void;
|
||||
on(eventName:string, eventName2:string, handler:Function):void;
|
||||
on(eventName:string, eventName2:string, eventName3:string, handler:Function):void;
|
||||
on(eventName:string, eventName2:string, eventName3:string, eventName4:string, handler:Function):void;
|
||||
on(eventName:string, eventName2:string, eventName3:string, eventName4:string, eventName5:string, handler:Function):void;
|
||||
|
||||
|
||||
/**
|
||||
* Removes a handler from an event being emitted by the index.
|
||||
*
|
||||
* @param eventName The name of events to remove the function from.
|
||||
* @param handler The serialised set to load.
|
||||
*/
|
||||
off(eventName:string, handler:Function):void;
|
||||
|
||||
|
||||
/**
|
||||
* Adds a field to the list of fields that will be searchable within documents in the index.
|
||||
*
|
||||
* An optional boost param can be passed to affect how much tokens in this field rank in
|
||||
* search results, by default the boost value is 1.
|
||||
*
|
||||
* Fields should be added before any documents are added to the index, fields that are added
|
||||
* after documents are added to the index will only apply to new documents added to the index.
|
||||
*
|
||||
* @param fieldName The name of the field within the document that
|
||||
* @param options An optional boost that can be applied to terms in this field.
|
||||
*/
|
||||
field(fieldName:string, options?:{boost?:number}):Index;
|
||||
|
||||
|
||||
/**
|
||||
* Sets the property used to uniquely identify documents added to the index, by default this
|
||||
* property is 'id'.
|
||||
*
|
||||
* This should only be changed before adding documents to the index, changing the ref property
|
||||
* without resetting the index can lead to unexpected results.
|
||||
*
|
||||
* @refName The property to use to uniquely identify the
|
||||
*/
|
||||
ref(refName:string):Index;
|
||||
|
||||
|
||||
/**
|
||||
* Add a document to the index.
|
||||
*
|
||||
* This is the way new documents enter the index, this function will run the fields from the
|
||||
* document through the index's pipeline and then add it to the index, it will then show up
|
||||
* in search results.
|
||||
*
|
||||
* An 'add' event is emitted with the document that has been added and the index the document
|
||||
* has been added to. This event can be silenced by passing false as the second argument to add.
|
||||
*
|
||||
* @param doc The document to add to the index.
|
||||
* @param emitEvent Whether or not to emit events, default true.
|
||||
*/
|
||||
add(doc:any, emitEvent?:boolean):void;
|
||||
|
||||
|
||||
/**
|
||||
* Removes a document from the index.
|
||||
*
|
||||
* To make sure documents no longer show up in search results they can be removed from the
|
||||
* index using this method.
|
||||
*
|
||||
* The document passed only needs to have the same ref property value as the document that was
|
||||
* added to the index, they could be completely different objects.
|
||||
*
|
||||
* A 'remove' event is emitted with the document that has been removed and the index the
|
||||
* document has been removed from. This event can be silenced by passing false as the second
|
||||
* argument to remove.
|
||||
*
|
||||
* @param doc The document to remove from the index.
|
||||
* @param emitEvent Whether to emit remove events, defaults to true
|
||||
*/
|
||||
remove(doc:any, emitEvent?:boolean):void;
|
||||
|
||||
|
||||
/**
|
||||
* Updates a document in the index.
|
||||
*
|
||||
* When a document contained within the index gets updated, fields changed, added or removed,
|
||||
* to make sure it correctly matched against search queries, it should be updated in the index.
|
||||
*
|
||||
* This method is just a wrapper around [[remove]] and [[add]].
|
||||
*
|
||||
* An 'update' event is emitted with the document that has been updated and the index.
|
||||
* This event can be silenced by passing false as the second argument to update. Only an
|
||||
* update event will be fired, the 'add' and 'remove' events of the underlying calls are
|
||||
* silenced.
|
||||
*
|
||||
* @param doc The document to update in the index.
|
||||
* @param emitEvent Whether to emit update events, defaults to true
|
||||
*/
|
||||
update(doc:any, emitEvent?:boolean):void;
|
||||
|
||||
|
||||
/**
|
||||
* Calculates the inverse document frequency for a token within the index.
|
||||
*
|
||||
* @param token The token to calculate the idf of.
|
||||
*/
|
||||
idf(token:string):string;
|
||||
|
||||
|
||||
/**
|
||||
* Searches the index using the passed query.
|
||||
*
|
||||
* Queries should be a string, multiple words are allowed and will lead to an AND based
|
||||
* query, e.g. idx.search('foo bar') will run a search for documents containing both
|
||||
* 'foo' and 'bar'.
|
||||
*
|
||||
* All query tokens are passed through the same pipeline that document tokens are passed
|
||||
* through, so any language processing involved will be run on every query term.
|
||||
*
|
||||
* Each query term is expanded, so that the term 'he' might be expanded to 'hello'
|
||||
* and 'help' if those terms were already included in the index.
|
||||
*
|
||||
* Matching documents are returned as an array of objects, each object contains the
|
||||
* matching document ref, as set for this index, and the similarity score for this
|
||||
* document against the query.
|
||||
*
|
||||
* @param query The query to search the index with.
|
||||
*/
|
||||
search(query:string):IIndexSearchResult[];
|
||||
|
||||
|
||||
/**
|
||||
* Generates a vector containing all the tokens in the document matching the
|
||||
* passed documentRef.
|
||||
*
|
||||
* The vector contains the tf-idf score for each token contained in the document with
|
||||
* the passed documentRef. The vector will contain an element for every token in the
|
||||
* indexes corpus, if the document does not contain that token the element will be 0.
|
||||
*
|
||||
* @param documentRef The ref to find the document with.
|
||||
*/
|
||||
documentVector(documentRef:string):Vector;
|
||||
|
||||
|
||||
/**
|
||||
* Returns a representation of the index ready for serialisation.
|
||||
*/
|
||||
toJSON():any;
|
||||
|
||||
|
||||
/**
|
||||
* Applies a plugin to the current index.
|
||||
*
|
||||
* A plugin is a function that is called with the index as its context. Plugins can be
|
||||
* used to customise or extend the behaviour the index in some way. A plugin is just a
|
||||
* function, that encapsulated the custom behaviour that should be applied to the index.
|
||||
*
|
||||
* The plugin function will be called with the index as its argument, additional arguments
|
||||
* can also be passed when calling use. The function will be called with the index as
|
||||
* its context.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```javascript
|
||||
* var myPlugin = function(idx, arg1, arg2) {
|
||||
* // `this` is the index to be extended
|
||||
* // apply any extensions etc here.
|
||||
* };
|
||||
*
|
||||
* var idx = lunr(function() {
|
||||
* this.use(myPlugin, 'arg1', 'arg2');
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
* @param plugin The plugin to apply.
|
||||
* @param args
|
||||
*/
|
||||
use(plugin:Function, ...args:any[]):void;
|
||||
|
||||
|
||||
/**
|
||||
* Loads a previously serialised index.
|
||||
*
|
||||
* Issues a warning if the index being imported was serialised by a different version
|
||||
* of lunr.
|
||||
*
|
||||
* @param serialisedData The serialised set to load.
|
||||
*/
|
||||
static load(serialisedData:any):Index;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* lunr.Store is a simple key-value store used for storing sets of tokens for documents
|
||||
* stored in index.
|
||||
*/
|
||||
class Store<T>
|
||||
{
|
||||
store:{[id:string]:SortedSet<T>};
|
||||
|
||||
length:number;
|
||||
|
||||
|
||||
/**
|
||||
* Stores the given tokens in the store against the given id.
|
||||
*
|
||||
* @param id The key used to store the tokens against.
|
||||
* @param tokens The tokens to store against the key.
|
||||
*/
|
||||
set(id:string, tokens:SortedSet<T>):void;
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves the tokens from the store for a given key.
|
||||
*
|
||||
* @param id The key to lookup and retrieve from the store.
|
||||
*/
|
||||
get(id:string):SortedSet<T>;
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether the store contains a key.
|
||||
*
|
||||
* @param id The id to look up in the store.
|
||||
*/
|
||||
has(id:string):boolean;
|
||||
|
||||
|
||||
/**
|
||||
* Removes the value for a key in the store.
|
||||
*
|
||||
* @param id The id to remove from the store.
|
||||
*/
|
||||
remove(id:string):void;
|
||||
|
||||
|
||||
/**
|
||||
* Returns a representation of the store ready for serialisation.
|
||||
*/
|
||||
toJSON():any;
|
||||
|
||||
|
||||
/**
|
||||
* Loads a previously serialised store.
|
||||
*
|
||||
* @param serialisedData The serialised store to load.
|
||||
*/
|
||||
static load<T>(serialisedData:any):Store<T>;
|
||||
}
|
||||
|
||||
|
||||
interface ITokenDocument
|
||||
{
|
||||
ref:number;
|
||||
|
||||
tf:number;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* lunr.TokenStore is used for efficient storing and lookup of the reverse index of token
|
||||
* to document ref.
|
||||
*/
|
||||
class TokenStore
|
||||
{
|
||||
root:{[token:string]:TokenStore};
|
||||
|
||||
docs:{[ref:string]:ITokenDocument};
|
||||
|
||||
length:number;
|
||||
|
||||
|
||||
/**
|
||||
* Adds a new token doc pair to the store.
|
||||
*
|
||||
* By default this function starts at the root of the current store, however it can
|
||||
* start at any node of any token store if required.
|
||||
*
|
||||
* @param token The token to store the doc under
|
||||
* @param doc The doc to store against the token
|
||||
* @param root An optional node at which to start looking for the
|
||||
*/
|
||||
add(token:string, doc:ITokenDocument, root?:TokenStore):void;
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether this key is contained within this lunr.TokenStore.
|
||||
*
|
||||
* @param token The token to check for
|
||||
*/
|
||||
has(token:string):boolean;
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve a node from the token store for a given token.
|
||||
*
|
||||
* @param token The token to get the node for.
|
||||
*/
|
||||
getNode(token:string):TokenStore;
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the documents for a node for the given token.
|
||||
*
|
||||
* By default this function starts at the root of the current store, however it can
|
||||
* start at any node of any token store if required.
|
||||
*
|
||||
* @param token The token to get the documents for.
|
||||
* @param root An optional node at which to start.
|
||||
*/
|
||||
get(token:string, root:TokenStore):{[ref:string]:ITokenDocument};
|
||||
|
||||
|
||||
count(token:string, root:TokenStore):number;
|
||||
|
||||
|
||||
/**
|
||||
* Remove the document identified by ref from the token in the store.
|
||||
*
|
||||
* @param token The token to get the documents for.
|
||||
* @param ref The ref of the document to remove from this token.
|
||||
*/
|
||||
remove(token:string, ref:string):void;
|
||||
|
||||
|
||||
/**
|
||||
* Find all the possible suffixes of the passed token using tokens currently in
|
||||
* the store.
|
||||
*
|
||||
* @param token The token to expand.
|
||||
* @param memo
|
||||
*/
|
||||
expand(token:string, memo?:string[]):string[];
|
||||
|
||||
|
||||
/**
|
||||
* Returns a representation of the token store ready for serialisation.
|
||||
*/
|
||||
toJSON():any;
|
||||
|
||||
|
||||
/**
|
||||
* Loads a previously serialised token store.
|
||||
*
|
||||
* @param serialisedData The serialised token store to load.
|
||||
*/
|
||||
static load(serialisedData:any):TokenStore;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Convenience function for instantiating a new lunr index and configuring it with the default
|
||||
* pipeline functions and the passed config function.
|
||||
*
|
||||
* When using this convenience function a new index will be created with the following functions
|
||||
* already in the pipeline:
|
||||
*
|
||||
* * lunr.StopWordFilter - filters out any stop words before they enter the index
|
||||
*
|
||||
* * lunr.stemmer - stems the tokens before entering the index.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```javascript
|
||||
* var idx = lunr(function () {
|
||||
* this.field('title', 10);
|
||||
* this.field('tags', 100);
|
||||
* this.field('body');
|
||||
*
|
||||
* this.ref('cid');
|
||||
*
|
||||
* this.pipeline.add(function () {
|
||||
* // some custom pipeline function
|
||||
* });
|
||||
* });
|
||||
* ```
|
||||
*/
|
||||
declare function lunr(config:Function):lunr.Index;
|
||||
@@ -0,0 +1,36 @@
|
||||
/// <reference path="progress.d.ts"/>
|
||||
|
||||
progressJs(); //without selector, set progress-bar for whole page
|
||||
progressJs("#targetElement"); //start progress-bar for element id='targetElement'
|
||||
|
||||
progressJs().start();
|
||||
|
||||
progressJs().set(20); //set progress to 20%
|
||||
|
||||
progressJs().start().autoIncrease(4, 500); //every 500 milliseconds, percentage + 4
|
||||
|
||||
progressJs().increase(); //increase one percent
|
||||
progressJs().increase(2); //increase two percent
|
||||
|
||||
progressJs().start().set(20).end();
|
||||
|
||||
progressJs().setOption("theme", "black");
|
||||
progressJs().setOption("overlayMode", true);
|
||||
progressJs().setOption("considerTransition", false);
|
||||
|
||||
progressJs().setOptions({ 'theme': 'black', 'overlayMode': true });
|
||||
progressJs().setOptions({ 'theme': 'black', 'overlayMode': true });
|
||||
progressJs().setOptions({ 'theme': 'black', 'overlayMode': true, 'considerTransition': false });
|
||||
progressJs().setOptions({ 'overlayMode': true });
|
||||
|
||||
progressJs().onbeforeend(function() {
|
||||
alert("before end");
|
||||
});
|
||||
|
||||
progressJs().onbeforestart(function() {
|
||||
alert("before start");
|
||||
});
|
||||
|
||||
progressJs().onprogress(function(targetElm, percent) {
|
||||
alert("progress changed to:" + percent);
|
||||
});
|
||||
Vendored
+103
@@ -0,0 +1,103 @@
|
||||
// Type definitions for ProgressJs v0.1.0
|
||||
// Project: http://usablica.github.io/progress.js/
|
||||
// Definitions by: Shunsuke Ohtani <https://github.com/zaneli>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface ProgressJsStatic {
|
||||
|
||||
/**
|
||||
* Creating an ProgressJS object.
|
||||
*
|
||||
* @param targetElm String (optional) Should be defined to start progress-bar for specific element.
|
||||
*/
|
||||
(targetElm?: string): ProgressJs;
|
||||
}
|
||||
|
||||
interface ProgressJs {
|
||||
|
||||
/**
|
||||
* Start the progress-bar for defined element(s).
|
||||
*/
|
||||
start(): ProgressJs;
|
||||
|
||||
/**
|
||||
* Set specific percentage to progress-bar.
|
||||
*
|
||||
* @param percent Set to specific percentage.
|
||||
*/
|
||||
set(percent: number): ProgressJs;
|
||||
|
||||
/**
|
||||
* Set an auto-increase timer for the progress-bar.
|
||||
*
|
||||
* @param size The size of increment when timer elapsed.
|
||||
* @param millisecond Timer in milliseconds.
|
||||
*/
|
||||
autoIncrease(size: number, millisecond: number): ProgressJs;
|
||||
|
||||
/**
|
||||
* Increase the progress-bar bar specified size. Default size is 1.
|
||||
*
|
||||
* @param size The size of increment.
|
||||
*/
|
||||
increase(size?: number): ProgressJs;
|
||||
|
||||
/**
|
||||
* End the progress-bar and remove the elements from page.
|
||||
*/
|
||||
end(): ProgressJs;
|
||||
|
||||
/**
|
||||
* Set a single option to progressJs object.
|
||||
*
|
||||
* @param option Option key name.
|
||||
* @param value Value of the option.
|
||||
*/
|
||||
setOption(option: string, value: string): ProgressJs;
|
||||
setOption(option: string, value: boolean): ProgressJs;
|
||||
|
||||
/**
|
||||
* Set a group of options to the progressJs object.
|
||||
*
|
||||
* @param options Object that contains option keys with values.
|
||||
*/
|
||||
setOptions(options: ProgressJsOptions): ProgressJs;
|
||||
|
||||
/**
|
||||
* Set a callback function for before end of the progress-bar.
|
||||
*
|
||||
* @param providedCallback Callback function.
|
||||
*/
|
||||
onbeforeend(providedCallback: () => any): ProgressJs;
|
||||
|
||||
/**
|
||||
* Set a callback function to call before start the progress-bar.
|
||||
*
|
||||
* @param providedCallback Callback function.
|
||||
*/
|
||||
onbeforestart(providedCallback: () => any): ProgressJs;
|
||||
|
||||
/**
|
||||
* Set callback function to call for each change of progress-bar.
|
||||
*
|
||||
* @param providedCallback Callback function.
|
||||
*/
|
||||
onprogress(providedCallback: (targetElement: string, percent: number) => any): ProgressJs;
|
||||
}
|
||||
|
||||
interface ProgressJsOptions {
|
||||
/**
|
||||
* progress bar theme
|
||||
*/
|
||||
theme?: string;
|
||||
/**
|
||||
* overlay mode makes an overlay layer in the target element
|
||||
*/
|
||||
overlayMode?: boolean;
|
||||
/**
|
||||
* to consider CSS3 transitions in events
|
||||
*/
|
||||
considerTransition?: boolean;
|
||||
}
|
||||
|
||||
declare var progressJs: ProgressJsStatic
|
||||
@@ -85,3 +85,8 @@ $('.example-countries .typeahead').typeahead({
|
||||
prefetch: '../data/countries.json',
|
||||
limit: 10
|
||||
});
|
||||
|
||||
module valueTest {
|
||||
var value: string = $('foo').typeahead('val');
|
||||
$('foo').typeahead('val', value);
|
||||
}
|
||||
Vendored
+11
@@ -60,6 +60,17 @@ interface JQuery {
|
||||
* @param dataset Array of datasets
|
||||
*/
|
||||
typeahead(options: Twitter.Typeahead.Options, dataset: Twitter.Typeahead.Dataset): JQuery;
|
||||
|
||||
/**
|
||||
* Returns the current value of the typeahead. The value is the text the user has entered into the input element.
|
||||
*/
|
||||
typeahead(methodName: 'val'): string;
|
||||
typeahead(methodName: string): string;
|
||||
|
||||
/**
|
||||
* Sets the value of the typeahead. This should be used in place of jQuery#val.
|
||||
*/
|
||||
typeahead(methodName: 'val', value: string): JQuery;
|
||||
}
|
||||
|
||||
declare module Twitter.Typeahead {
|
||||
|
||||
Reference in New Issue
Block a user