mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge branch 'master' of https://github.com/borisyankov/DefinitelyTyped
This commit is contained in:
@@ -22,6 +22,7 @@ Properties
|
||||
*~
|
||||
|
||||
# test folder
|
||||
!_infrastructure/*.js
|
||||
!_infrastructure/tests/*
|
||||
!_infrastructure/tests/*.js
|
||||
!_infrastructure/tests/*/*.js
|
||||
|
||||
@@ -63,6 +63,7 @@ List of Definitions
|
||||
* [FlexSlider](http://www.woothemes.com/flexslider/) (by [Diullei Gomes](https://github.com/Diullei))
|
||||
* [Foundation](http://foundation.zurb.com/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [FPSMeter](http://darsa.in/fpsmeter/) (by [Aaron Lampros](https://github.com/alampros))
|
||||
* [FullCalendar](http://arshaw.com/fullcalendar/) (by [Neil Stalker](https://github.com/nestalk))
|
||||
* [Gamepad](http://www.w3.org/TR/gamepad/) (by [Kon](http://phyzkit.net/))
|
||||
* [glDatePicker](http://glad.github.com/glDatePicker/) (by [Dániel Tar](https://github.com/qcz))
|
||||
* [GreenSock Animation Platform (GSAP)](http://www.greensock.com/get-started-js/) (by [Robert S.](https://github.com/codeBelt))
|
||||
@@ -99,6 +100,7 @@ List of Definitions
|
||||
* [jQuery.Globalize](https://github.com/jquery/globalize) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [jQuery.jNotify](http://jnotify.codeplex.com) (by [James Curran](https://github.com/jamescurran/))
|
||||
* [jQuery.noty](http://needim.github.io/noty/) (by [Aaron King](https://github.com/kingdango/))
|
||||
* [jQuery.pickadate](https://github.com/amsul/pickadate.js) (by [Theodore Brown](https://github.com/theodorejb))
|
||||
* [jQuery.scrollTo](https://github.com/flesler/jquery.scrollTo) (by [Neil Stalker](https://github.com/nestalk/))
|
||||
* [jQuery.simplePagination](https://github.com/flaviusmatis/simplePagination.js) (by [Natan Vivo](https://github.com/nvivo/))
|
||||
* [jQuery.timeago](http://timeago.yarp.com/) (by [François Guillot](http://fguillot.developpez.com/))
|
||||
@@ -111,6 +113,7 @@ List of Definitions
|
||||
* [jScrollPane](http://jscrollpane.kelvinluck.com) (by [Dániel Tar](https://github.com/qcz))
|
||||
* [JSDeferred](http://cho45.stfuawsc.com/jsdeferred/) (by [Daisuke Mino](https://github.com/minodisk))
|
||||
* [JSONEditorOnline](https://github.com/josdejong/jsoneditoronline) (by [Vincent Bortone](https://github.com/vbortone/))
|
||||
* [jStorage](http://www.jstorage.info/) (by [Danil Flores](https://github.com/dflor003/))
|
||||
* [JWPlayer](http://developer.longtailvideo.com/trac/) (by [Martin Duparc](https://github.com/martinduparc/))
|
||||
* [KeyboardJS](https://github.com/RobertWHurst/KeyboardJS) (by [Vincent Bortone](https://github.com/vbortone/))
|
||||
* [Knockback](http://kmalakoff.github.com/knockback/) (by [Marcel Binot](https://github.com/docgit))
|
||||
@@ -123,8 +126,9 @@ List of Definitions
|
||||
* [KoLite](https://github.com/CodeSeven/kolite) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [Leaflet](https://github.com/Leaflet/Leaflet) (by [Vladimir](https://github.com/rgripper))
|
||||
* [Libxmljs](https://github.com/polotek/libxmljs) (by [François de Campredon](https://github.com/fdecampredon))
|
||||
* [ladda](https://github.com/hakimel/Ladda) (by [Danil Flores](https://github.com/dflor003))
|
||||
* [linq.js](http://linqjs.codeplex.com/) (by [Marcin Najder](https://github.com/marcinnajder))
|
||||
* [Livestamp.js](https://github.com/mattbradley/livestampjs) (by [Vincent Bortone] (https://github.com/vbortone))
|
||||
* [Livestamp.js](https://github.com/mattbradley/livestampjs) (by [Vincent Bortone](https://github.com/vbortone))
|
||||
* [Marked](https://github.com/chjj/marked) (by [William Orr](https://github.com/worr))
|
||||
* [Modernizr](http://modernizr.com/) (by [Boris Yankov](https://github.com/borisyankov) and [Theodore Brown](https://github.com/theodorejb/))
|
||||
* [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield))
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,557 @@
|
||||
/// <reference path='src/exec.ts' />
|
||||
/// <reference path='src/io.ts' />
|
||||
|
||||
module DefinitelyTyped {
|
||||
|
||||
export module TestManager {
|
||||
|
||||
var path = require('path');
|
||||
|
||||
function endsWith(str, suffix) {
|
||||
return str.indexOf(suffix, str.length - suffix.length) !== -1;
|
||||
}
|
||||
|
||||
class Iterator {
|
||||
index: number = -1;
|
||||
|
||||
constructor(public list: any[]){}
|
||||
|
||||
public next() {
|
||||
this.index++;
|
||||
return this.list[this.index];
|
||||
}
|
||||
|
||||
public hasNext() {
|
||||
return this.list[1 + this.index] != null;
|
||||
}
|
||||
}
|
||||
|
||||
class Tsc {
|
||||
public static run(tsfile: string, callback: Function) {
|
||||
Exec.exec('node ./_infrastructure/tests/typescript/tsc.js ', [tsfile], (ExecResult) => {
|
||||
callback(ExecResult);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
constructor(public tsfile: string) {}
|
||||
|
||||
public run(callback: Function) {
|
||||
Tsc.run(this.tsfile , callback);
|
||||
}
|
||||
}
|
||||
|
||||
class Typing {
|
||||
public fileHandler: FileHandler;
|
||||
|
||||
constructor(public name: string, baseDir: string) {
|
||||
this.fileHandler = new FileHandler(baseDir + '/' + name + '/', /.\.ts/g);
|
||||
}
|
||||
}
|
||||
|
||||
class FileHandler {
|
||||
public files: string[] = [];
|
||||
public typings: Typing[] = [];
|
||||
|
||||
constructor(public path: string, pattern: any) {
|
||||
this.files = IO.dir(path, pattern, { recursive: true });
|
||||
}
|
||||
|
||||
public allTS(): string[] {
|
||||
return this.files;
|
||||
}
|
||||
|
||||
public allTests(): string[] {
|
||||
var tests = [];
|
||||
|
||||
for(var i = 0; i < this.files.length; i++) {
|
||||
if (endsWith(this.files[i].toUpperCase(), '-TESTS.TS')) {
|
||||
tests.push(this.files[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return tests;
|
||||
}
|
||||
|
||||
public allTypings(): string[] {
|
||||
var typings = {};
|
||||
|
||||
for(var i = 0; i < this.files.length; i++) {
|
||||
var file = this.files[i];
|
||||
var firName = path.dirname(file.substr(this.path.length + 1)).replace('\\', '/');
|
||||
var dir = firName.split('/')[0];
|
||||
|
||||
if(!typings[dir]) typings[dir] = true;
|
||||
}
|
||||
|
||||
var list = [];
|
||||
for(var attr in typings) {
|
||||
list.push(attr);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
class Timer {
|
||||
public startTime;
|
||||
public time = 0;
|
||||
public asString: string;
|
||||
|
||||
private static prettyDate(date1, date2): string {
|
||||
var diff = ((date2 - date1) / 1000),
|
||||
day_diff = Math.floor(diff / 86400);
|
||||
|
||||
if ( isNaN(day_diff) || day_diff < 0 || day_diff >= 31 )
|
||||
return;
|
||||
|
||||
return <string><any> (day_diff == 0 && (
|
||||
diff < 60 && (diff + " secconds") ||
|
||||
diff < 120 && "1 minute" ||
|
||||
diff < 3600 && Math.floor( diff / 60 ) + " minutes" ||
|
||||
diff < 7200 && "1 hour" ||
|
||||
diff < 86400 && Math.floor( diff / 3600 ) + " hours") ||
|
||||
day_diff == 1 && "Yesterday" ||
|
||||
day_diff < 7 && day_diff + " days" ||
|
||||
day_diff < 31 && Math.ceil( day_diff / 7 ) + " weeks");
|
||||
}
|
||||
|
||||
public start() {
|
||||
this.time = 0;
|
||||
this.startTime = this.now();
|
||||
}
|
||||
|
||||
private now() {
|
||||
return Date.now();
|
||||
}
|
||||
|
||||
public end() {
|
||||
this.time = (this.now() - this.startTime) / 1000;
|
||||
this.asString = Timer.prettyDate(this.startTime, this.now());
|
||||
}
|
||||
}
|
||||
|
||||
class Print {
|
||||
constructor(public version: string, public typings: number, public tsFiles: number) { }
|
||||
|
||||
public out(s) {
|
||||
process.stdout.write(s);
|
||||
}
|
||||
|
||||
public printHeader() {
|
||||
this.out('=============================================================================\n');
|
||||
this.out(' \33[36m\33[1mDefinitelyTyped test runner 0.2.0\33[0m\n');
|
||||
this.out('=============================================================================\n');
|
||||
this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n');
|
||||
this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n');
|
||||
this.out(' \33[36m\33[1mTypeScript files :\33[0m ' + this.tsFiles + '\n');
|
||||
}
|
||||
|
||||
public printSyntaxCheking() {
|
||||
this.out('============================ \33[34m\33[1mSyntax cheking\33[0m =================================\n');
|
||||
}
|
||||
|
||||
public printTypingTests() {
|
||||
this.out('============================= \33[34m\33[1mTyping tests\33[0m ==================================\n');
|
||||
}
|
||||
|
||||
public printSuccess() {
|
||||
this.out('\33[36m\33[1m.\33[0m');
|
||||
}
|
||||
|
||||
public printFailure() {
|
||||
this.out('x');
|
||||
}
|
||||
|
||||
public printDiv() {
|
||||
this.out('-----------------------------------------------------------------------------\n');
|
||||
}
|
||||
|
||||
public printfilesWithSintaxErrorMessage() {
|
||||
this.out(' \33[36m\33[1mFiles with syntax error\33[0m\n');
|
||||
}
|
||||
|
||||
public printFailedTestMessage() {
|
||||
this.out(' \33[36m\33[1mFailed tests\33[0m\n');
|
||||
}
|
||||
|
||||
public printTypingsWithoutTestsMessage() {
|
||||
this.out(' \33[36m\33[1mTyping without tests\33[0m\n');
|
||||
}
|
||||
|
||||
public printTotalMessage() {
|
||||
this.out(' \33[36m\33[1mTotal\33[0m\n');
|
||||
}
|
||||
|
||||
public printErrorFile(file) {
|
||||
this.out(' - ' + file + '\n');
|
||||
}
|
||||
|
||||
public printTypingsWithoutTest(file) {
|
||||
this.out(' - \33[33m\33[1m' + file + '\33[0m\n');
|
||||
}
|
||||
|
||||
public breack() {
|
||||
this.out('\n');
|
||||
}
|
||||
|
||||
public printSuccessCount(current: number, total: number) {
|
||||
this.out(' \33[36m\33[1mSuccessful :\33[0m \33[32m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
|
||||
}
|
||||
|
||||
public printFailedCount(current: number, total: number) {
|
||||
this.out(' \33[36m\33[1mFailure :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
|
||||
}
|
||||
|
||||
public printElapsedTime(time, s) {
|
||||
this.out(' \33[36m\33[1mElapsed time :\33[0m ~' + time + ' (' + s + 's)\n');
|
||||
}
|
||||
|
||||
public printSyntaxErrorCount(current: number, total: number) {
|
||||
this.out(' \33[36m\33[1mSyntaxe error :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
|
||||
}
|
||||
|
||||
public printTestErrorCount(current: number, total: number) {
|
||||
this.out(' \33[36m\33[1mFailed tests :\33[0m \33[31m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
|
||||
}
|
||||
|
||||
public printWithoutTestCount(current: number, total: number) {
|
||||
this.out(' \33[36m\33[1mWithout tests :\33[0m \33[33m\33[1m' + ((current / total) * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
|
||||
}
|
||||
}
|
||||
|
||||
class File {
|
||||
|
||||
constructor(public name: string, public hasError: boolean) {}
|
||||
|
||||
public formatName(baseDir: string): string {
|
||||
var dirName = path.dirname(this.name.substr(baseDir.length + 1)).replace('\\', '/');
|
||||
var dir = dirName.split('/')[0];
|
||||
var file = path.basename(this.name, '.ts');
|
||||
var ext = path.extname(this.name);
|
||||
|
||||
return dir + ((dirName.split('/').length > 1) ? '/-/' : '/') + '\33[36m\33[1m' + file + '\33[0m' + ext;
|
||||
}
|
||||
}
|
||||
|
||||
class SyntaxCheking {
|
||||
|
||||
private timer: Timer;
|
||||
|
||||
public files: File[] = [];
|
||||
|
||||
private getFailedFiles(): File[] {
|
||||
var list: File[] = [];
|
||||
|
||||
for(var i = 0; i < this.files.length; i++) {
|
||||
if(this.files[i].hasError) {
|
||||
list.push(this.files[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private getSuccessFiles(): File[] {
|
||||
var list: File[] = [];
|
||||
|
||||
for(var i = 0; i < this.files.length; i++) {
|
||||
if(!this.files[i].hasError) {
|
||||
list.push(this.files[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
constructor(public fielHandler: FileHandler, public out: Print) {
|
||||
this.timer = new Timer();
|
||||
}
|
||||
|
||||
private printStats() {
|
||||
this.out.printDiv();
|
||||
this.out.printElapsedTime(this.timer.asString, this.timer.time);
|
||||
this.out.printSuccessCount(this.getSuccessFiles().length, this.files.length);
|
||||
this.out.printFailedCount(this.getFailedFiles().length, this.files.length);
|
||||
}
|
||||
|
||||
private printFailedFiles() {
|
||||
if (this.getFailedFiles().length > 0) {
|
||||
this.out.printDiv();
|
||||
|
||||
this.out.printfilesWithSintaxErrorMessage();
|
||||
|
||||
this.out.printDiv();
|
||||
|
||||
for(var i = 0; i < this.getFailedFiles().length; i++) {
|
||||
var errorFile = this.getFailedFiles()[i];
|
||||
this.out.printErrorFile(errorFile.formatName(this.fielHandler.path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private run(it, file, len, maxLen, callback: Function) {
|
||||
if (!endsWith(file, '-tests.ts')) {
|
||||
new Test(file).run((o) => {
|
||||
var failed = false;
|
||||
|
||||
if(o.exitCode === 1) {
|
||||
this.out.printFailure();
|
||||
failed = true;
|
||||
len++;
|
||||
} else {
|
||||
this.out.printSuccess();
|
||||
len++;
|
||||
}
|
||||
|
||||
this.files.push(new File(file, failed));
|
||||
|
||||
if(len > maxLen) {
|
||||
len = 0;
|
||||
this.out.breack();
|
||||
}
|
||||
|
||||
if (it.hasNext()) {
|
||||
this.run(it, it.next(), len, maxLen, callback);
|
||||
} else {
|
||||
this.out.breack();
|
||||
this.timer.end();
|
||||
this.printFailedFiles();
|
||||
this.printStats();
|
||||
|
||||
callback(this.getFailedFiles().length, this.files.length);
|
||||
}
|
||||
});
|
||||
} else if (it.hasNext()) {
|
||||
this.run(it, it.next(), len, maxLen, callback);
|
||||
} else {
|
||||
this.out.breack();
|
||||
this.timer.end();
|
||||
this.printStats();
|
||||
this.printFailedFiles();
|
||||
|
||||
callback(this.getFailedFiles().length, this.files.length);
|
||||
}
|
||||
}
|
||||
|
||||
public start(callback: Function) {
|
||||
this.timer.start();
|
||||
|
||||
var tsFiles = this.fielHandler.allTS();
|
||||
|
||||
var it = new Iterator(tsFiles);
|
||||
|
||||
var len = 0;
|
||||
var maxLen = 76;
|
||||
|
||||
if (it.hasNext()) {
|
||||
this.run(it, it.next(), len, maxLen, callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class TestEval {
|
||||
|
||||
private timer: Timer;
|
||||
|
||||
public files: File[] = [];
|
||||
|
||||
private getFailedFiles(): File[] {
|
||||
var list: File[] = [];
|
||||
|
||||
for(var i = 0; i < this.files.length; i++) {
|
||||
if(this.files[i].hasError) {
|
||||
list.push(this.files[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private getSuccessFiles(): File[] {
|
||||
var list: File[] = [];
|
||||
|
||||
for(var i = 0; i < this.files.length; i++) {
|
||||
if(!this.files[i].hasError) {
|
||||
list.push(this.files[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
constructor(public fielHandler: FileHandler, public out: Print) {
|
||||
this.timer = new Timer();
|
||||
}
|
||||
|
||||
private printStats() {
|
||||
this.out.printDiv();
|
||||
this.out.printElapsedTime(this.timer.asString, this.timer.time);
|
||||
this.out.printSuccessCount(this.getSuccessFiles().length, this.files.length);
|
||||
this.out.printFailedCount(this.getFailedFiles().length, this.files.length);
|
||||
}
|
||||
|
||||
private printFailedFiles() {
|
||||
if (this.getFailedFiles().length > 0) {
|
||||
this.out.printDiv();
|
||||
|
||||
this.out.printFailedTestMessage();
|
||||
|
||||
this.out.printDiv();
|
||||
|
||||
for(var i = 0; i < this.getFailedFiles().length; i++) {
|
||||
var errorFile = this.getFailedFiles()[i];
|
||||
this.out.printErrorFile(errorFile.formatName(this.fielHandler.path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private run(it, file, len, maxLen, callback: Function) {
|
||||
if (endsWith(file, '-tests.ts')) {
|
||||
new Test(file).run((o) => {
|
||||
var failed = false;
|
||||
|
||||
if(o.exitCode === 1) {
|
||||
this.out.printFailure();
|
||||
failed = true;
|
||||
len++;
|
||||
} else {
|
||||
this.out.printSuccess();
|
||||
len++;
|
||||
}
|
||||
|
||||
this.files.push(new File(file, failed));
|
||||
|
||||
if(len > maxLen) {
|
||||
len = 0;
|
||||
this.out.breack();
|
||||
}
|
||||
|
||||
if (it.hasNext()) {
|
||||
this.run(it, it.next(), len, maxLen, callback);
|
||||
} else {
|
||||
this.out.breack();
|
||||
this.timer.end();
|
||||
this.printFailedFiles();
|
||||
this.printStats();
|
||||
|
||||
callback(this.getFailedFiles().length, this.files.length);
|
||||
}
|
||||
});
|
||||
} else if (it.hasNext()) {
|
||||
this.run(it, it.next(), len, maxLen, callback);
|
||||
} else {
|
||||
this.out.breack();
|
||||
this.timer.end();
|
||||
this.printFailedFiles();
|
||||
this.printStats();
|
||||
|
||||
callback(this.getFailedFiles().length, this.files.length);
|
||||
}
|
||||
}
|
||||
|
||||
public start(callback: Function) {
|
||||
this.timer.start();
|
||||
|
||||
var tsFiles = this.fielHandler.allTS();
|
||||
|
||||
var it = new Iterator(tsFiles);
|
||||
|
||||
var len = 0;
|
||||
var maxLen = 76;
|
||||
|
||||
if (it.hasNext()) {
|
||||
this.run(it, it.next(), len, maxLen, callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class TestRunner {
|
||||
private fh: FileHandler;
|
||||
private out: Print;
|
||||
private sc: SyntaxCheking;
|
||||
private te: TestEval;
|
||||
private typings: Typing[] = [];
|
||||
|
||||
private printTypingsWithoutTest() {
|
||||
var count = 0;
|
||||
|
||||
if (this.typings.length > 0) {
|
||||
this.out.printDiv();
|
||||
|
||||
this.out.printTypingsWithoutTestsMessage();
|
||||
|
||||
this.out.printDiv();
|
||||
|
||||
for(var i = 0; i < this.typings.length; i++) {
|
||||
var typing = this.typings[i];
|
||||
if(typing.fileHandler.allTests().length == 0) {
|
||||
if (typing.name != '_infrastructure'
|
||||
&& typing.name != '_ReSharper.DefinitelyTyped'
|
||||
&& typing.name != 'obj'
|
||||
&& typing.name != 'bin'
|
||||
&& typing.name != 'Properties') {
|
||||
this.out.printTypingsWithoutTest(typing.name);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
constructor(public dtPath: string) {
|
||||
this.fh = new FileHandler(dtPath, /.\.ts/g);
|
||||
this.out = new Print('0.9.0.0', this.fh.allTypings().length, this.fh.allTS().length);
|
||||
this.sc = new SyntaxCheking(this.fh, this.out);
|
||||
this.te = new TestEval(this.fh, this.out);
|
||||
|
||||
var tpgs = this.fh.allTypings();
|
||||
for(var i = 0; i < tpgs.length; i++) {
|
||||
this.typings.push(new Typing(tpgs[i], this.dtPath));
|
||||
}
|
||||
}
|
||||
|
||||
public run() {
|
||||
var timer = new Timer();
|
||||
timer.start();
|
||||
|
||||
this.out.printHeader();
|
||||
this.out.printSyntaxCheking();
|
||||
|
||||
this.sc.start((syntaxFailedCount, syntaxTotal) => {
|
||||
this.out.printTypingTests();
|
||||
this.te.start((testFailedCount, testTotal) => {
|
||||
var total = this.printTypingsWithoutTest();
|
||||
|
||||
timer.end();
|
||||
|
||||
this.out.printDiv();
|
||||
this.out.printTotalMessage();
|
||||
this.out.printDiv();
|
||||
|
||||
this.out.printElapsedTime(timer.asString, timer.time);
|
||||
this.out.printSyntaxErrorCount(syntaxFailedCount, syntaxTotal);
|
||||
this.out.printTestErrorCount(testFailedCount, testTotal);
|
||||
this.out.printWithoutTestCount(total, this.fh.allTypings().length);
|
||||
|
||||
this.out.printDiv();
|
||||
|
||||
if (syntaxFailedCount > 0 || testFailedCount > 0) {
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
declare var __dirname: any;
|
||||
|
||||
var dtPath = __dirname + '/../..';
|
||||
|
||||
var runner = new DefinitelyTyped.TestManager.TestRunner(dtPath);
|
||||
runner.run();
|
||||
@@ -1,65 +1,65 @@
|
||||
var ExecResult = (function () {
|
||||
function ExecResult() {
|
||||
this.stdout = "";
|
||||
this.stderr = "";
|
||||
}
|
||||
return ExecResult;
|
||||
})();
|
||||
|
||||
var WindowsScriptHostExec = (function () {
|
||||
function WindowsScriptHostExec() {
|
||||
}
|
||||
WindowsScriptHostExec.prototype.exec = function (filename, cmdLineArgs, handleResult) {
|
||||
var result = new ExecResult();
|
||||
var shell = new ActiveXObject('WScript.Shell');
|
||||
try {
|
||||
var process = shell.Exec(filename + ' ' + cmdLineArgs.join(' '));
|
||||
} catch (e) {
|
||||
result.stderr = e.message;
|
||||
result.exitCode = 1;
|
||||
handleResult(result);
|
||||
return;
|
||||
}
|
||||
|
||||
while (process.Status != 0) {
|
||||
}
|
||||
|
||||
result.exitCode = process.ExitCode;
|
||||
if (!process.StdOut.AtEndOfStream)
|
||||
result.stdout = process.StdOut.ReadAll();
|
||||
if (!process.StdErr.AtEndOfStream)
|
||||
result.stderr = process.StdErr.ReadAll();
|
||||
|
||||
handleResult(result);
|
||||
};
|
||||
return WindowsScriptHostExec;
|
||||
})();
|
||||
|
||||
var NodeExec = (function () {
|
||||
function NodeExec() {
|
||||
}
|
||||
NodeExec.prototype.exec = function (filename, cmdLineArgs, handleResult) {
|
||||
var nodeExec = require('child_process').exec;
|
||||
|
||||
var result = new ExecResult();
|
||||
result.exitCode = null;
|
||||
var cmdLine = filename + ' ' + cmdLineArgs.join(' ');
|
||||
|
||||
var process = nodeExec(cmdLine, function (error, stdout, stderr) {
|
||||
result.stdout = stdout;
|
||||
result.stderr = stderr;
|
||||
result.exitCode = error ? error.code : 0;
|
||||
handleResult(result);
|
||||
});
|
||||
};
|
||||
return NodeExec;
|
||||
})();
|
||||
|
||||
var Exec = (function () {
|
||||
var global = Function("return this;").call(null);
|
||||
if (typeof global.ActiveXObject !== "undefined") {
|
||||
return new WindowsScriptHostExec();
|
||||
} else {
|
||||
return new NodeExec();
|
||||
}
|
||||
})();
|
||||
var ExecResult = (function () {
|
||||
function ExecResult() {
|
||||
this.stdout = "";
|
||||
this.stderr = "";
|
||||
}
|
||||
return ExecResult;
|
||||
})();
|
||||
|
||||
var WindowsScriptHostExec = (function () {
|
||||
function WindowsScriptHostExec() {
|
||||
}
|
||||
WindowsScriptHostExec.prototype.exec = function (filename, cmdLineArgs, handleResult) {
|
||||
var result = new ExecResult();
|
||||
var shell = new ActiveXObject('WScript.Shell');
|
||||
try {
|
||||
var process = shell.Exec(filename + ' ' + cmdLineArgs.join(' '));
|
||||
} catch (e) {
|
||||
result.stderr = e.message;
|
||||
result.exitCode = 1;
|
||||
handleResult(result);
|
||||
return;
|
||||
}
|
||||
|
||||
while (process.Status != 0) {
|
||||
}
|
||||
|
||||
result.exitCode = process.ExitCode;
|
||||
if (!process.StdOut.AtEndOfStream)
|
||||
result.stdout = process.StdOut.ReadAll();
|
||||
if (!process.StdErr.AtEndOfStream)
|
||||
result.stderr = process.StdErr.ReadAll();
|
||||
|
||||
handleResult(result);
|
||||
};
|
||||
return WindowsScriptHostExec;
|
||||
})();
|
||||
|
||||
var NodeExec = (function () {
|
||||
function NodeExec() {
|
||||
}
|
||||
NodeExec.prototype.exec = function (filename, cmdLineArgs, handleResult) {
|
||||
var nodeExec = require('child_process').exec;
|
||||
|
||||
var result = new ExecResult();
|
||||
result.exitCode = null;
|
||||
var cmdLine = filename + ' ' + cmdLineArgs.join(' ');
|
||||
|
||||
var process = nodeExec(cmdLine, function (error, stdout, stderr) {
|
||||
result.stdout = stdout;
|
||||
result.stderr = stderr;
|
||||
result.exitCode = error ? error.code : 0;
|
||||
handleResult(result);
|
||||
});
|
||||
};
|
||||
return NodeExec;
|
||||
})();
|
||||
|
||||
var Exec = (function () {
|
||||
var global = Function("return this;").call(null);
|
||||
if (typeof global.ActiveXObject !== "undefined") {
|
||||
return new WindowsScriptHostExec();
|
||||
} else {
|
||||
return new NodeExec();
|
||||
}
|
||||
})();
|
||||
|
||||
+445
-443
@@ -1,443 +1,445 @@
|
||||
var IOUtils;
|
||||
(function (IOUtils) {
|
||||
function createDirectoryStructure(ioHost, dirName) {
|
||||
if (ioHost.directoryExists(dirName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var parentDirectory = ioHost.dirName(dirName);
|
||||
if (parentDirectory != "") {
|
||||
createDirectoryStructure(ioHost, parentDirectory);
|
||||
}
|
||||
ioHost.createDirectory(dirName);
|
||||
}
|
||||
|
||||
function createFileAndFolderStructure(ioHost, fileName, useUTF8) {
|
||||
var path = ioHost.resolvePath(fileName);
|
||||
var dirName = ioHost.dirName(path);
|
||||
createDirectoryStructure(ioHost, dirName);
|
||||
return ioHost.createFile(path, useUTF8);
|
||||
}
|
||||
IOUtils.createFileAndFolderStructure = createFileAndFolderStructure;
|
||||
|
||||
function throwIOError(message, error) {
|
||||
var errorMessage = message;
|
||||
if (error && error.message) {
|
||||
errorMessage += (" " + error.message);
|
||||
}
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
IOUtils.throwIOError = throwIOError;
|
||||
})(IOUtils || (IOUtils = {}));
|
||||
|
||||
var IO = (function () {
|
||||
function getWindowsScriptHostIO() {
|
||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
var streamObjectPool = [];
|
||||
|
||||
function getStreamObject() {
|
||||
if (streamObjectPool.length > 0) {
|
||||
return streamObjectPool.pop();
|
||||
} else {
|
||||
return new ActiveXObject("ADODB.Stream");
|
||||
}
|
||||
}
|
||||
|
||||
function releaseStreamObject(obj) {
|
||||
streamObjectPool.push(obj);
|
||||
}
|
||||
|
||||
var args = [];
|
||||
for (var i = 0; i < WScript.Arguments.length; i++) {
|
||||
args[i] = WScript.Arguments.Item(i);
|
||||
}
|
||||
|
||||
return {
|
||||
readFile: function (path) {
|
||||
try {
|
||||
var streamObj = getStreamObject();
|
||||
streamObj.Open();
|
||||
streamObj.Type = 2;
|
||||
streamObj.Charset = 'x-ansi';
|
||||
streamObj.LoadFromFile(path);
|
||||
var bomChar = streamObj.ReadText(2);
|
||||
streamObj.Position = 0;
|
||||
if ((bomChar.charCodeAt(0) == 0xFE && bomChar.charCodeAt(1) == 0xFF) || (bomChar.charCodeAt(0) == 0xFF && bomChar.charCodeAt(1) == 0xFE)) {
|
||||
streamObj.Charset = 'unicode';
|
||||
} else if (bomChar.charCodeAt(0) == 0xEF && bomChar.charCodeAt(1) == 0xBB) {
|
||||
streamObj.Charset = 'utf-8';
|
||||
}
|
||||
|
||||
var str = streamObj.ReadText(-1);
|
||||
streamObj.Close();
|
||||
releaseStreamObject(streamObj);
|
||||
return str;
|
||||
} catch (err) {
|
||||
IOUtils.throwIOError("Error reading file \"" + path + "\".", err);
|
||||
}
|
||||
},
|
||||
writeFile: function (path, contents) {
|
||||
var file = this.createFile(path);
|
||||
file.Write(contents);
|
||||
file.Close();
|
||||
},
|
||||
fileExists: function (path) {
|
||||
return fso.FileExists(path);
|
||||
},
|
||||
resolvePath: function (path) {
|
||||
return fso.GetAbsolutePathName(path);
|
||||
},
|
||||
dirName: function (path) {
|
||||
return fso.GetParentFolderName(path);
|
||||
},
|
||||
findFile: function (rootPath, partialFilePath) {
|
||||
var path = fso.GetAbsolutePathName(rootPath) + "/" + partialFilePath;
|
||||
|
||||
while (true) {
|
||||
if (fso.FileExists(path)) {
|
||||
try {
|
||||
var content = this.readFile(path);
|
||||
return { content: content, path: path };
|
||||
} catch (err) {
|
||||
}
|
||||
} else {
|
||||
rootPath = fso.GetParentFolderName(fso.GetAbsolutePathName(rootPath));
|
||||
|
||||
if (rootPath == "") {
|
||||
return null;
|
||||
} else {
|
||||
path = fso.BuildPath(rootPath, partialFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
deleteFile: function (path) {
|
||||
try {
|
||||
if (fso.FileExists(path)) {
|
||||
fso.DeleteFile(path, true);
|
||||
}
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e);
|
||||
}
|
||||
},
|
||||
createFile: function (path, useUTF8) {
|
||||
try {
|
||||
var streamObj = getStreamObject();
|
||||
streamObj.Charset = useUTF8 ? 'utf-8' : 'x-ansi';
|
||||
streamObj.Open();
|
||||
return {
|
||||
Write: function (str) {
|
||||
streamObj.WriteText(str, 0);
|
||||
},
|
||||
WriteLine: function (str) {
|
||||
streamObj.WriteText(str, 1);
|
||||
},
|
||||
Close: function () {
|
||||
try {
|
||||
streamObj.SaveToFile(path, 2);
|
||||
} catch (saveError) {
|
||||
IOUtils.throwIOError("Couldn't write to file '" + path + "'.", saveError);
|
||||
} finally {
|
||||
if (streamObj.State != 0) {
|
||||
streamObj.Close();
|
||||
}
|
||||
releaseStreamObject(streamObj);
|
||||
}
|
||||
}
|
||||
};
|
||||
} catch (creationError) {
|
||||
IOUtils.throwIOError("Couldn't write to file '" + path + "'.", creationError);
|
||||
}
|
||||
},
|
||||
directoryExists: function (path) {
|
||||
return fso.FolderExists(path);
|
||||
},
|
||||
createDirectory: function (path) {
|
||||
try {
|
||||
if (!this.directoryExists(path)) {
|
||||
fso.CreateFolder(path);
|
||||
}
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e);
|
||||
}
|
||||
},
|
||||
dir: function (path, spec, options) {
|
||||
options = options || {};
|
||||
function filesInFolder(folder, root) {
|
||||
var paths = [];
|
||||
var fc;
|
||||
|
||||
if (options.recursive) {
|
||||
fc = new Enumerator(folder.subfolders);
|
||||
|
||||
for (; !fc.atEnd(); fc.moveNext()) {
|
||||
paths = paths.concat(filesInFolder(fc.item(), root + "/" + fc.item().Name));
|
||||
}
|
||||
}
|
||||
|
||||
fc = new Enumerator(folder.files);
|
||||
|
||||
for (; !fc.atEnd(); fc.moveNext()) {
|
||||
if (!spec || fc.item().Name.match(spec)) {
|
||||
paths.push(root + "/" + fc.item().Name);
|
||||
}
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
var folder = fso.GetFolder(path);
|
||||
var paths = [];
|
||||
|
||||
return filesInFolder(folder, path);
|
||||
},
|
||||
print: function (str) {
|
||||
WScript.StdOut.Write(str);
|
||||
},
|
||||
printLine: function (str) {
|
||||
WScript.Echo(str);
|
||||
},
|
||||
arguments: args,
|
||||
stderr: WScript.StdErr,
|
||||
stdout: WScript.StdOut,
|
||||
watchFile: null,
|
||||
run: function (source, filename) {
|
||||
try {
|
||||
eval(source);
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Error while executing file '" + filename + "'.", e);
|
||||
}
|
||||
},
|
||||
getExecutingFilePath: function () {
|
||||
return WScript.ScriptFullName;
|
||||
},
|
||||
quit: function (exitCode) {
|
||||
if (typeof exitCode === "undefined") { exitCode = 0; }
|
||||
try {
|
||||
WScript.Quit(exitCode);
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
function getNodeIO() {
|
||||
var _fs = require('fs');
|
||||
var _path = require('path');
|
||||
var _module = require('module');
|
||||
|
||||
return {
|
||||
readFile: function (file) {
|
||||
try {
|
||||
var buffer = _fs.readFileSync(file);
|
||||
switch (buffer[0]) {
|
||||
case 0xFE:
|
||||
if (buffer[1] == 0xFF) {
|
||||
var i = 0;
|
||||
while ((i + 1) < buffer.length) {
|
||||
var temp = buffer[i];
|
||||
buffer[i] = buffer[i + 1];
|
||||
buffer[i + 1] = temp;
|
||||
i += 2;
|
||||
}
|
||||
return buffer.toString("ucs2", 2);
|
||||
}
|
||||
break;
|
||||
case 0xFF:
|
||||
if (buffer[1] == 0xFE) {
|
||||
return buffer.toString("ucs2", 2);
|
||||
}
|
||||
break;
|
||||
case 0xEF:
|
||||
if (buffer[1] == 0xBB) {
|
||||
return buffer.toString("utf8", 3);
|
||||
}
|
||||
}
|
||||
|
||||
return buffer.toString();
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Error reading file \"" + file + "\".", e);
|
||||
}
|
||||
},
|
||||
writeFile: _fs.writeFileSync,
|
||||
deleteFile: function (path) {
|
||||
try {
|
||||
_fs.unlinkSync(path);
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e);
|
||||
}
|
||||
},
|
||||
fileExists: function (path) {
|
||||
return _fs.existsSync(path);
|
||||
},
|
||||
createFile: function (path, useUTF8) {
|
||||
function mkdirRecursiveSync(path) {
|
||||
var stats = _fs.statSync(path);
|
||||
if (stats.isFile()) {
|
||||
IOUtils.throwIOError("\"" + path + "\" exists but isn't a directory.", null);
|
||||
} else if (stats.isDirectory()) {
|
||||
return;
|
||||
} else {
|
||||
mkdirRecursiveSync(_path.dirname(path));
|
||||
_fs.mkdirSync(path, 0775);
|
||||
}
|
||||
}
|
||||
|
||||
mkdirRecursiveSync(_path.dirname(path));
|
||||
|
||||
try {
|
||||
var fd = _fs.openSync(path, 'w');
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Couldn't write to file '" + path + "'.", e);
|
||||
}
|
||||
return {
|
||||
Write: function (str) {
|
||||
_fs.writeSync(fd, str);
|
||||
},
|
||||
WriteLine: function (str) {
|
||||
_fs.writeSync(fd, str + '\r\n');
|
||||
},
|
||||
Close: function () {
|
||||
_fs.closeSync(fd);
|
||||
fd = null;
|
||||
}
|
||||
};
|
||||
},
|
||||
dir: function dir(path, spec, options) {
|
||||
options = options || {};
|
||||
|
||||
function filesInFolder(folder) {
|
||||
var paths = [];
|
||||
|
||||
var files = _fs.readdirSync(folder);
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var stat = _fs.statSync(folder + "/" + files[i]);
|
||||
if (options.recursive && stat.isDirectory()) {
|
||||
paths = paths.concat(filesInFolder(folder + "/" + files[i]));
|
||||
} else if (stat.isFile() && (!spec || files[i].match(spec))) {
|
||||
paths.push(folder + "/" + files[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
return filesInFolder(path);
|
||||
},
|
||||
createDirectory: function (path) {
|
||||
try {
|
||||
if (!this.directoryExists(path)) {
|
||||
_fs.mkdirSync(path);
|
||||
}
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e);
|
||||
}
|
||||
},
|
||||
directoryExists: function (path) {
|
||||
return _fs.existsSync(path) && _fs.lstatSync(path).isDirectory();
|
||||
},
|
||||
resolvePath: function (path) {
|
||||
return _path.resolve(path);
|
||||
},
|
||||
dirName: function (path) {
|
||||
return _path.dirname(path);
|
||||
},
|
||||
findFile: function (rootPath, partialFilePath) {
|
||||
var path = rootPath + "/" + partialFilePath;
|
||||
|
||||
while (true) {
|
||||
if (_fs.existsSync(path)) {
|
||||
try {
|
||||
var content = this.readFile(path);
|
||||
return { content: content, path: path };
|
||||
} catch (err) {
|
||||
}
|
||||
} else {
|
||||
var parentPath = _path.resolve(rootPath, "..");
|
||||
|
||||
if (rootPath === parentPath) {
|
||||
return null;
|
||||
} else {
|
||||
rootPath = parentPath;
|
||||
path = _path.resolve(rootPath, partialFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
print: function (str) {
|
||||
process.stdout.write(str);
|
||||
},
|
||||
printLine: function (str) {
|
||||
process.stdout.write(str + '\n');
|
||||
},
|
||||
arguments: process.argv.slice(2),
|
||||
stderr: {
|
||||
Write: function (str) {
|
||||
process.stderr.write(str);
|
||||
},
|
||||
WriteLine: function (str) {
|
||||
process.stderr.write(str + '\n');
|
||||
},
|
||||
Close: function () {
|
||||
}
|
||||
},
|
||||
stdout: {
|
||||
Write: function (str) {
|
||||
process.stdout.write(str);
|
||||
},
|
||||
WriteLine: function (str) {
|
||||
process.stdout.write(str + '\n');
|
||||
},
|
||||
Close: function () {
|
||||
}
|
||||
},
|
||||
watchFile: function (filename, callback) {
|
||||
var firstRun = true;
|
||||
var processingChange = false;
|
||||
|
||||
var fileChanged = function (curr, prev) {
|
||||
if (!firstRun) {
|
||||
if (curr.mtime < prev.mtime) {
|
||||
return;
|
||||
}
|
||||
|
||||
_fs.unwatchFile(filename, fileChanged);
|
||||
if (!processingChange) {
|
||||
processingChange = true;
|
||||
callback(filename);
|
||||
setTimeout(function () {
|
||||
processingChange = false;
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
firstRun = false;
|
||||
_fs.watchFile(filename, { persistent: true, interval: 500 }, fileChanged);
|
||||
};
|
||||
|
||||
fileChanged();
|
||||
return {
|
||||
filename: filename,
|
||||
close: function () {
|
||||
_fs.unwatchFile(filename, fileChanged);
|
||||
}
|
||||
};
|
||||
},
|
||||
run: function (source, filename) {
|
||||
require.main.filename = filename;
|
||||
require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(filename)));
|
||||
require.main._compile(source, filename);
|
||||
},
|
||||
getExecutingFilePath: function () {
|
||||
return process.mainModule.filename;
|
||||
},
|
||||
quit: process.exit
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
if (typeof ActiveXObject === "function")
|
||||
return getWindowsScriptHostIO(); else if (typeof require === "function")
|
||||
return getNodeIO(); else
|
||||
return null;
|
||||
})();
|
||||
var IOUtils;
|
||||
(function (IOUtils) {
|
||||
function createDirectoryStructure(ioHost, dirName) {
|
||||
if (ioHost.directoryExists(dirName)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var parentDirectory = ioHost.dirName(dirName);
|
||||
if (parentDirectory != "") {
|
||||
createDirectoryStructure(ioHost, parentDirectory);
|
||||
}
|
||||
ioHost.createDirectory(dirName);
|
||||
}
|
||||
|
||||
function createFileAndFolderStructure(ioHost, fileName, useUTF8) {
|
||||
var path = ioHost.resolvePath(fileName);
|
||||
var dirName = ioHost.dirName(path);
|
||||
createDirectoryStructure(ioHost, dirName);
|
||||
return ioHost.createFile(path, useUTF8);
|
||||
}
|
||||
IOUtils.createFileAndFolderStructure = createFileAndFolderStructure;
|
||||
|
||||
function throwIOError(message, error) {
|
||||
var errorMessage = message;
|
||||
if (error && error.message) {
|
||||
errorMessage += (" " + error.message);
|
||||
}
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
IOUtils.throwIOError = throwIOError;
|
||||
})(IOUtils || (IOUtils = {}));
|
||||
|
||||
var IO = (function () {
|
||||
function getWindowsScriptHostIO() {
|
||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
var streamObjectPool = [];
|
||||
|
||||
function getStreamObject() {
|
||||
if (streamObjectPool.length > 0) {
|
||||
return streamObjectPool.pop();
|
||||
} else {
|
||||
return new ActiveXObject("ADODB.Stream");
|
||||
}
|
||||
}
|
||||
|
||||
function releaseStreamObject(obj) {
|
||||
streamObjectPool.push(obj);
|
||||
}
|
||||
|
||||
var args = [];
|
||||
for (var i = 0; i < WScript.Arguments.length; i++) {
|
||||
args[i] = WScript.Arguments.Item(i);
|
||||
}
|
||||
|
||||
return {
|
||||
readFile: function (path) {
|
||||
try {
|
||||
var streamObj = getStreamObject();
|
||||
streamObj.Open();
|
||||
streamObj.Type = 2;
|
||||
streamObj.Charset = 'x-ansi';
|
||||
streamObj.LoadFromFile(path);
|
||||
var bomChar = streamObj.ReadText(2);
|
||||
streamObj.Position = 0;
|
||||
if ((bomChar.charCodeAt(0) == 0xFE && bomChar.charCodeAt(1) == 0xFF) || (bomChar.charCodeAt(0) == 0xFF && bomChar.charCodeAt(1) == 0xFE)) {
|
||||
streamObj.Charset = 'unicode';
|
||||
} else if (bomChar.charCodeAt(0) == 0xEF && bomChar.charCodeAt(1) == 0xBB) {
|
||||
streamObj.Charset = 'utf-8';
|
||||
}
|
||||
|
||||
var str = streamObj.ReadText(-1);
|
||||
streamObj.Close();
|
||||
releaseStreamObject(streamObj);
|
||||
return str;
|
||||
} catch (err) {
|
||||
IOUtils.throwIOError("Error reading file \"" + path + "\".", err);
|
||||
}
|
||||
},
|
||||
writeFile: function (path, contents) {
|
||||
var file = this.createFile(path);
|
||||
file.Write(contents);
|
||||
file.Close();
|
||||
},
|
||||
fileExists: function (path) {
|
||||
return fso.FileExists(path);
|
||||
},
|
||||
resolvePath: function (path) {
|
||||
return fso.GetAbsolutePathName(path);
|
||||
},
|
||||
dirName: function (path) {
|
||||
return fso.GetParentFolderName(path);
|
||||
},
|
||||
findFile: function (rootPath, partialFilePath) {
|
||||
var path = fso.GetAbsolutePathName(rootPath) + "/" + partialFilePath;
|
||||
|
||||
while (true) {
|
||||
if (fso.FileExists(path)) {
|
||||
try {
|
||||
var content = this.readFile(path);
|
||||
return { content: content, path: path };
|
||||
} catch (err) {
|
||||
}
|
||||
} else {
|
||||
rootPath = fso.GetParentFolderName(fso.GetAbsolutePathName(rootPath));
|
||||
|
||||
if (rootPath == "") {
|
||||
return null;
|
||||
} else {
|
||||
path = fso.BuildPath(rootPath, partialFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
deleteFile: function (path) {
|
||||
try {
|
||||
if (fso.FileExists(path)) {
|
||||
fso.DeleteFile(path, true);
|
||||
}
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e);
|
||||
}
|
||||
},
|
||||
createFile: function (path, useUTF8) {
|
||||
try {
|
||||
var streamObj = getStreamObject();
|
||||
streamObj.Charset = useUTF8 ? 'utf-8' : 'x-ansi';
|
||||
streamObj.Open();
|
||||
return {
|
||||
Write: function (str) {
|
||||
streamObj.WriteText(str, 0);
|
||||
},
|
||||
WriteLine: function (str) {
|
||||
streamObj.WriteText(str, 1);
|
||||
},
|
||||
Close: function () {
|
||||
try {
|
||||
streamObj.SaveToFile(path, 2);
|
||||
} catch (saveError) {
|
||||
IOUtils.throwIOError("Couldn't write to file '" + path + "'.", saveError);
|
||||
} finally {
|
||||
if (streamObj.State != 0) {
|
||||
streamObj.Close();
|
||||
}
|
||||
releaseStreamObject(streamObj);
|
||||
}
|
||||
}
|
||||
};
|
||||
} catch (creationError) {
|
||||
IOUtils.throwIOError("Couldn't write to file '" + path + "'.", creationError);
|
||||
}
|
||||
},
|
||||
directoryExists: function (path) {
|
||||
return fso.FolderExists(path);
|
||||
},
|
||||
createDirectory: function (path) {
|
||||
try {
|
||||
if (!this.directoryExists(path)) {
|
||||
fso.CreateFolder(path);
|
||||
}
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e);
|
||||
}
|
||||
},
|
||||
dir: function (path, spec, options) {
|
||||
options = options || {};
|
||||
function filesInFolder(folder, root) {
|
||||
var paths = [];
|
||||
var fc;
|
||||
|
||||
if (options.recursive) {
|
||||
fc = new Enumerator(folder.subfolders);
|
||||
|
||||
for (; !fc.atEnd(); fc.moveNext()) {
|
||||
paths = paths.concat(filesInFolder(fc.item(), root + "/" + fc.item().Name));
|
||||
}
|
||||
}
|
||||
|
||||
fc = new Enumerator(folder.files);
|
||||
|
||||
for (; !fc.atEnd(); fc.moveNext()) {
|
||||
if (!spec || fc.item().Name.match(spec)) {
|
||||
paths.push(root + "/" + fc.item().Name);
|
||||
}
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
var folder = fso.GetFolder(path);
|
||||
var paths = [];
|
||||
|
||||
return filesInFolder(folder, path);
|
||||
},
|
||||
print: function (str) {
|
||||
WScript.StdOut.Write(str);
|
||||
},
|
||||
printLine: function (str) {
|
||||
WScript.Echo(str);
|
||||
},
|
||||
arguments: args,
|
||||
stderr: WScript.StdErr,
|
||||
stdout: WScript.StdOut,
|
||||
watchFile: null,
|
||||
run: function (source, filename) {
|
||||
try {
|
||||
eval(source);
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Error while executing file '" + filename + "'.", e);
|
||||
}
|
||||
},
|
||||
getExecutingFilePath: function () {
|
||||
return WScript.ScriptFullName;
|
||||
},
|
||||
quit: function (exitCode) {
|
||||
if (typeof exitCode === "undefined") { exitCode = 0; }
|
||||
try {
|
||||
WScript.Quit(exitCode);
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
function getNodeIO() {
|
||||
var _fs = require('fs');
|
||||
var _path = require('path');
|
||||
var _module = require('module');
|
||||
|
||||
return {
|
||||
readFile: function (file) {
|
||||
try {
|
||||
var buffer = _fs.readFileSync(file);
|
||||
switch (buffer[0]) {
|
||||
case 0xFE:
|
||||
if (buffer[1] == 0xFF) {
|
||||
var i = 0;
|
||||
while ((i + 1) < buffer.length) {
|
||||
var temp = buffer[i];
|
||||
buffer[i] = buffer[i + 1];
|
||||
buffer[i + 1] = temp;
|
||||
i += 2;
|
||||
}
|
||||
return buffer.toString("ucs2", 2);
|
||||
}
|
||||
break;
|
||||
case 0xFF:
|
||||
if (buffer[1] == 0xFE) {
|
||||
return buffer.toString("ucs2", 2);
|
||||
}
|
||||
break;
|
||||
case 0xEF:
|
||||
if (buffer[1] == 0xBB) {
|
||||
return buffer.toString("utf8", 3);
|
||||
}
|
||||
}
|
||||
|
||||
return buffer.toString();
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Error reading file \"" + file + "\".", e);
|
||||
}
|
||||
},
|
||||
writeFile: _fs.writeFileSync,
|
||||
deleteFile: function (path) {
|
||||
try {
|
||||
_fs.unlinkSync(path);
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e);
|
||||
}
|
||||
},
|
||||
fileExists: function (path) {
|
||||
return _fs.existsSync(path);
|
||||
},
|
||||
createFile: function (path, useUTF8) {
|
||||
function mkdirRecursiveSync(path) {
|
||||
var stats = _fs.statSync(path);
|
||||
if (stats.isFile()) {
|
||||
IOUtils.throwIOError("\"" + path + "\" exists but isn't a directory.", null);
|
||||
} else if (stats.isDirectory()) {
|
||||
return;
|
||||
} else {
|
||||
mkdirRecursiveSync(_path.dirname(path));
|
||||
_fs.mkdirSync(path, 0775);
|
||||
}
|
||||
}
|
||||
|
||||
mkdirRecursiveSync(_path.dirname(path));
|
||||
|
||||
try {
|
||||
var fd = _fs.openSync(path, 'w');
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Couldn't write to file '" + path + "'.", e);
|
||||
}
|
||||
return {
|
||||
Write: function (str) {
|
||||
_fs.writeSync(fd, str);
|
||||
},
|
||||
WriteLine: function (str) {
|
||||
_fs.writeSync(fd, str + '\r\n');
|
||||
},
|
||||
Close: function () {
|
||||
_fs.closeSync(fd);
|
||||
fd = null;
|
||||
}
|
||||
};
|
||||
},
|
||||
dir: function dir(path, spec, options) {
|
||||
options = options || {};
|
||||
|
||||
function filesInFolder(folder, deep) {
|
||||
var paths = [];
|
||||
|
||||
var files = _fs.readdirSync(folder);
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var stat = _fs.statSync(folder + "/" + files[i]);
|
||||
if (options.recursive && stat.isDirectory()) {
|
||||
if (deep < (options.deep || 100)) {
|
||||
paths = paths.concat(filesInFolder(folder + "/" + files[i], 1));
|
||||
}
|
||||
} else if (stat.isFile() && (!spec || files[i].match(spec))) {
|
||||
paths.push(folder + "/" + files[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return paths;
|
||||
}
|
||||
|
||||
return filesInFolder(path, 0);
|
||||
},
|
||||
createDirectory: function (path) {
|
||||
try {
|
||||
if (!this.directoryExists(path)) {
|
||||
_fs.mkdirSync(path);
|
||||
}
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e);
|
||||
}
|
||||
},
|
||||
directoryExists: function (path) {
|
||||
return _fs.existsSync(path) && _fs.lstatSync(path).isDirectory();
|
||||
},
|
||||
resolvePath: function (path) {
|
||||
return _path.resolve(path);
|
||||
},
|
||||
dirName: function (path) {
|
||||
return _path.dirname(path);
|
||||
},
|
||||
findFile: function (rootPath, partialFilePath) {
|
||||
var path = rootPath + "/" + partialFilePath;
|
||||
|
||||
while (true) {
|
||||
if (_fs.existsSync(path)) {
|
||||
try {
|
||||
var content = this.readFile(path);
|
||||
return { content: content, path: path };
|
||||
} catch (err) {
|
||||
}
|
||||
} else {
|
||||
var parentPath = _path.resolve(rootPath, "..");
|
||||
|
||||
if (rootPath === parentPath) {
|
||||
return null;
|
||||
} else {
|
||||
rootPath = parentPath;
|
||||
path = _path.resolve(rootPath, partialFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
print: function (str) {
|
||||
process.stdout.write(str);
|
||||
},
|
||||
printLine: function (str) {
|
||||
process.stdout.write(str + '\n');
|
||||
},
|
||||
arguments: process.argv.slice(2),
|
||||
stderr: {
|
||||
Write: function (str) {
|
||||
process.stderr.write(str);
|
||||
},
|
||||
WriteLine: function (str) {
|
||||
process.stderr.write(str + '\n');
|
||||
},
|
||||
Close: function () {
|
||||
}
|
||||
},
|
||||
stdout: {
|
||||
Write: function (str) {
|
||||
process.stdout.write(str);
|
||||
},
|
||||
WriteLine: function (str) {
|
||||
process.stdout.write(str + '\n');
|
||||
},
|
||||
Close: function () {
|
||||
}
|
||||
},
|
||||
watchFile: function (filename, callback) {
|
||||
var firstRun = true;
|
||||
var processingChange = false;
|
||||
|
||||
var fileChanged = function (curr, prev) {
|
||||
if (!firstRun) {
|
||||
if (curr.mtime < prev.mtime) {
|
||||
return;
|
||||
}
|
||||
|
||||
_fs.unwatchFile(filename, fileChanged);
|
||||
if (!processingChange) {
|
||||
processingChange = true;
|
||||
callback(filename);
|
||||
setTimeout(function () {
|
||||
processingChange = false;
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
firstRun = false;
|
||||
_fs.watchFile(filename, { persistent: true, interval: 500 }, fileChanged);
|
||||
};
|
||||
|
||||
fileChanged();
|
||||
return {
|
||||
filename: filename,
|
||||
close: function () {
|
||||
_fs.unwatchFile(filename, fileChanged);
|
||||
}
|
||||
};
|
||||
},
|
||||
run: function (source, filename) {
|
||||
require.main.filename = filename;
|
||||
require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(filename)));
|
||||
require.main._compile(source, filename);
|
||||
},
|
||||
getExecutingFilePath: function () {
|
||||
return process.mainModule.filename;
|
||||
},
|
||||
quit: process.exit
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
if (typeof ActiveXObject === "function")
|
||||
return getWindowsScriptHostIO(); else if (typeof require === "function")
|
||||
return getNodeIO(); else
|
||||
return null;
|
||||
})();
|
||||
|
||||
@@ -25,11 +25,11 @@ interface IFileWatcher {
|
||||
interface IIO {
|
||||
readFile(path: string): string;
|
||||
writeFile(path: string, contents: string): void;
|
||||
createFile(path: string, useUTF8?: boolean): ITextWriter;
|
||||
createFile(path: string, useUTF8?: bool): ITextWriter;
|
||||
deleteFile(path: string): void;
|
||||
dir(path: string, re?: RegExp, options?: { recursive?: boolean; }): string[];
|
||||
fileExists(path: string): boolean;
|
||||
directoryExists(path: string): boolean;
|
||||
dir(path: string, re?: RegExp, options?: { recursive?: bool; deep?: number; }): string[];
|
||||
fileExists(path: string): bool;
|
||||
directoryExists(path: string): bool;
|
||||
createDirectory(path: string): void;
|
||||
resolvePath(path: string): string;
|
||||
dirName(path: string): string;
|
||||
@@ -60,7 +60,7 @@ module IOUtils {
|
||||
}
|
||||
|
||||
// Creates a file including its directory structure if not already present
|
||||
export function createFileAndFolderStructure(ioHost: IIO, fileName: string, useUTF8?: boolean) {
|
||||
export function createFileAndFolderStructure(ioHost: IIO, fileName: string, useUTF8?: bool) {
|
||||
var path = ioHost.resolvePath(fileName);
|
||||
var dirName = ioHost.dirName(path);
|
||||
createDirectoryStructure(ioHost, dirName);
|
||||
@@ -78,13 +78,13 @@ module IOUtils {
|
||||
|
||||
// Declare dependencies needed for all supported hosts
|
||||
declare class Enumerator {
|
||||
public atEnd(): boolean;
|
||||
public atEnd(): bool;
|
||||
public moveNext();
|
||||
public item(): any;
|
||||
constructor (o: any);
|
||||
}
|
||||
declare function setTimeout(callback: () =>void , ms?: number);
|
||||
declare var require: any;
|
||||
//declare var require: any;
|
||||
declare module process {
|
||||
export var argv: string[];
|
||||
export var platform: string;
|
||||
@@ -160,7 +160,7 @@ var IO = (function() {
|
||||
file.Close();
|
||||
},
|
||||
|
||||
fileExists: function(path: string): boolean {
|
||||
fileExists: function(path: string): bool {
|
||||
return fso.FileExists(path);
|
||||
},
|
||||
|
||||
@@ -236,7 +236,7 @@ var IO = (function() {
|
||||
},
|
||||
|
||||
directoryExists: function(path) {
|
||||
return <boolean>fso.FolderExists(path);
|
||||
return <bool>fso.FolderExists(path);
|
||||
},
|
||||
|
||||
createDirectory: function(path) {
|
||||
@@ -250,7 +250,7 @@ var IO = (function() {
|
||||
},
|
||||
|
||||
dir: function(path, spec?, options?) {
|
||||
options = options || <{ recursive?: boolean; }>{};
|
||||
options = options || <{ recursive?: bool; deep?: number; }>{};
|
||||
function filesInFolder(folder, root): string[]{
|
||||
var paths = [];
|
||||
var fc: Enumerator;
|
||||
@@ -365,7 +365,7 @@ var IO = (function() {
|
||||
IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e);
|
||||
}
|
||||
},
|
||||
fileExists: function(path): boolean {
|
||||
fileExists: function(path): bool {
|
||||
return _fs.existsSync(path);
|
||||
},
|
||||
createFile: function(path, useUTF8?) {
|
||||
@@ -395,16 +395,18 @@ var IO = (function() {
|
||||
};
|
||||
},
|
||||
dir: function dir(path, spec?, options?) {
|
||||
options = options || <{ recursive?: boolean; }>{};
|
||||
options = options || <{ recursive?: bool; deep?: number; }>{};
|
||||
|
||||
function filesInFolder(folder: string): string[]{
|
||||
function filesInFolder(folder: string, deep?: number): string[]{
|
||||
var paths = [];
|
||||
|
||||
var files = _fs.readdirSync(folder);
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
var stat = _fs.statSync(folder + "/" + files[i]);
|
||||
if (options.recursive && stat.isDirectory()) {
|
||||
paths = paths.concat(filesInFolder(folder + "/" + files[i]));
|
||||
if (deep < (options.deep || 100)) {
|
||||
paths = paths.concat(filesInFolder(folder + "/" + files[i], 1));
|
||||
}
|
||||
} else if (stat.isFile() && (!spec || files[i].match(spec))) {
|
||||
paths.push(folder + "/" + files[i]);
|
||||
}
|
||||
@@ -413,7 +415,7 @@ var IO = (function() {
|
||||
return paths;
|
||||
}
|
||||
|
||||
return filesInFolder(path);
|
||||
return filesInFolder(path, 0);
|
||||
},
|
||||
createDirectory: function(path: string): void {
|
||||
try {
|
||||
@@ -425,7 +427,7 @@ var IO = (function() {
|
||||
}
|
||||
},
|
||||
|
||||
directoryExists: function(path: string): boolean {
|
||||
directoryExists: function(path: string): bool {
|
||||
return _fs.existsSync(path) && _fs.lstatSync(path).isDirectory();
|
||||
},
|
||||
resolvePath: function(path: string): string {
|
||||
|
||||
@@ -1,619 +0,0 @@
|
||||
var ExecResult = (function () {
|
||||
function ExecResult() {
|
||||
this.stdout = "";
|
||||
this.stderr = "";
|
||||
}
|
||||
return ExecResult;
|
||||
})();
|
||||
var WindowsScriptHostExec = (function () {
|
||||
function WindowsScriptHostExec() { }
|
||||
WindowsScriptHostExec.prototype.exec = function (filename, cmdLineArgs, handleResult) {
|
||||
var result = new ExecResult();
|
||||
var shell = new ActiveXObject('WScript.Shell');
|
||||
try {
|
||||
var process = shell.Exec(filename + ' ' + cmdLineArgs.join(' '));
|
||||
} catch (e) {
|
||||
result.stderr = e.message;
|
||||
result.exitCode = 1;
|
||||
handleResult(result);
|
||||
return;
|
||||
}
|
||||
while(process.Status != 0) {
|
||||
}
|
||||
result.exitCode = process.ExitCode;
|
||||
if(!process.StdOut.AtEndOfStream) {
|
||||
result.stdout = process.StdOut.ReadAll();
|
||||
}
|
||||
if(!process.StdErr.AtEndOfStream) {
|
||||
result.stderr = process.StdErr.ReadAll();
|
||||
}
|
||||
handleResult(result);
|
||||
};
|
||||
return WindowsScriptHostExec;
|
||||
})();
|
||||
var NodeExec = (function () {
|
||||
function NodeExec() { }
|
||||
NodeExec.prototype.exec = function (filename, cmdLineArgs, handleResult) {
|
||||
var nodeExec = require('child_process').exec;
|
||||
var result = new ExecResult();
|
||||
result.exitCode = null;
|
||||
var cmdLine = filename + ' ' + cmdLineArgs.join(' ');
|
||||
var process = nodeExec(cmdLine, function (error, stdout, stderr) {
|
||||
result.stdout = stdout;
|
||||
result.stderr = stderr;
|
||||
result.exitCode = error ? error.code : 0;
|
||||
handleResult(result);
|
||||
});
|
||||
};
|
||||
return NodeExec;
|
||||
})();
|
||||
var Exec = (function () {
|
||||
var global = Function("return this;").call(null);
|
||||
if(typeof global.ActiveXObject !== "undefined") {
|
||||
return new WindowsScriptHostExec();
|
||||
} else {
|
||||
return new NodeExec();
|
||||
}
|
||||
})();
|
||||
var IOUtils;
|
||||
(function (IOUtils) {
|
||||
function createDirectoryStructure(ioHost, dirName) {
|
||||
if(ioHost.directoryExists(dirName)) {
|
||||
return;
|
||||
}
|
||||
var parentDirectory = ioHost.dirName(dirName);
|
||||
if(parentDirectory != "") {
|
||||
createDirectoryStructure(ioHost, parentDirectory);
|
||||
}
|
||||
ioHost.createDirectory(dirName);
|
||||
}
|
||||
function createFileAndFolderStructure(ioHost, fileName, useUTF8) {
|
||||
var path = ioHost.resolvePath(fileName);
|
||||
var dirName = ioHost.dirName(path);
|
||||
createDirectoryStructure(ioHost, dirName);
|
||||
return ioHost.createFile(path, useUTF8);
|
||||
}
|
||||
IOUtils.createFileAndFolderStructure = createFileAndFolderStructure;
|
||||
function throwIOError(message, error) {
|
||||
var errorMessage = message;
|
||||
if(error && error.message) {
|
||||
errorMessage += (" " + error.message);
|
||||
}
|
||||
throw new Error(errorMessage);
|
||||
}
|
||||
IOUtils.throwIOError = throwIOError;
|
||||
})(IOUtils || (IOUtils = {}));
|
||||
|
||||
var IO = (function () {
|
||||
function getWindowsScriptHostIO() {
|
||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
var streamObjectPool = [];
|
||||
function getStreamObject() {
|
||||
if(streamObjectPool.length > 0) {
|
||||
return streamObjectPool.pop();
|
||||
} else {
|
||||
return new ActiveXObject("ADODB.Stream");
|
||||
}
|
||||
}
|
||||
function releaseStreamObject(obj) {
|
||||
streamObjectPool.push(obj);
|
||||
}
|
||||
var args = [];
|
||||
for(var i = 0; i < WScript.Arguments.length; i++) {
|
||||
args[i] = WScript.Arguments.Item(i);
|
||||
}
|
||||
return {
|
||||
readFile: function (path) {
|
||||
try {
|
||||
var streamObj = getStreamObject();
|
||||
streamObj.Open();
|
||||
streamObj.Type = 2;
|
||||
streamObj.Charset = 'x-ansi';
|
||||
streamObj.LoadFromFile(path);
|
||||
var bomChar = streamObj.ReadText(2);
|
||||
streamObj.Position = 0;
|
||||
if((bomChar.charCodeAt(0) == 254 && bomChar.charCodeAt(1) == 255) || (bomChar.charCodeAt(0) == 255 && bomChar.charCodeAt(1) == 254)) {
|
||||
streamObj.Charset = 'unicode';
|
||||
} else if(bomChar.charCodeAt(0) == 239 && bomChar.charCodeAt(1) == 187) {
|
||||
streamObj.Charset = 'utf-8';
|
||||
}
|
||||
var str = streamObj.ReadText(-1);
|
||||
streamObj.Close();
|
||||
releaseStreamObject(streamObj);
|
||||
return str;
|
||||
} catch (err) {
|
||||
IOUtils.throwIOError("Error reading file \"" + path + "\".", err);
|
||||
}
|
||||
},
|
||||
writeFile: function (path, contents) {
|
||||
var file = this.createFile(path);
|
||||
file.Write(contents);
|
||||
file.Close();
|
||||
},
|
||||
fileExists: function (path) {
|
||||
return fso.FileExists(path);
|
||||
},
|
||||
resolvePath: function (path) {
|
||||
return fso.GetAbsolutePathName(path);
|
||||
},
|
||||
dirName: function (path) {
|
||||
return fso.GetParentFolderName(path);
|
||||
},
|
||||
findFile: function (rootPath, partialFilePath) {
|
||||
var path = fso.GetAbsolutePathName(rootPath) + "/" + partialFilePath;
|
||||
while(true) {
|
||||
if(fso.FileExists(path)) {
|
||||
try {
|
||||
var content = this.readFile(path);
|
||||
return {
|
||||
content: content,
|
||||
path: path
|
||||
};
|
||||
} catch (err) {
|
||||
}
|
||||
} else {
|
||||
rootPath = fso.GetParentFolderName(fso.GetAbsolutePathName(rootPath));
|
||||
if(rootPath == "") {
|
||||
return null;
|
||||
} else {
|
||||
path = fso.BuildPath(rootPath, partialFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
deleteFile: function (path) {
|
||||
try {
|
||||
if(fso.FileExists(path)) {
|
||||
fso.DeleteFile(path, true);
|
||||
}
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e);
|
||||
}
|
||||
},
|
||||
createFile: function (path, useUTF8) {
|
||||
try {
|
||||
var streamObj = getStreamObject();
|
||||
streamObj.Charset = useUTF8 ? 'utf-8' : 'x-ansi';
|
||||
streamObj.Open();
|
||||
return {
|
||||
Write: function (str) {
|
||||
streamObj.WriteText(str, 0);
|
||||
},
|
||||
WriteLine: function (str) {
|
||||
streamObj.WriteText(str, 1);
|
||||
},
|
||||
Close: function () {
|
||||
try {
|
||||
streamObj.SaveToFile(path, 2);
|
||||
} catch (saveError) {
|
||||
IOUtils.throwIOError("Couldn't write to file '" + path + "'.", saveError);
|
||||
}finally {
|
||||
if(streamObj.State != 0) {
|
||||
streamObj.Close();
|
||||
}
|
||||
releaseStreamObject(streamObj);
|
||||
}
|
||||
}
|
||||
};
|
||||
} catch (creationError) {
|
||||
IOUtils.throwIOError("Couldn't write to file '" + path + "'.", creationError);
|
||||
}
|
||||
},
|
||||
directoryExists: function (path) {
|
||||
return fso.FolderExists(path);
|
||||
},
|
||||
createDirectory: function (path) {
|
||||
try {
|
||||
if(!this.directoryExists(path)) {
|
||||
fso.CreateFolder(path);
|
||||
}
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e);
|
||||
}
|
||||
},
|
||||
dir: function (path, spec, options) {
|
||||
options = options || {
|
||||
};
|
||||
function filesInFolder(folder, root) {
|
||||
var paths = [];
|
||||
var fc;
|
||||
if(options.recursive) {
|
||||
fc = new Enumerator(folder.subfolders);
|
||||
for(; !fc.atEnd(); fc.moveNext()) {
|
||||
paths = paths.concat(filesInFolder(fc.item(), root + "/" + fc.item().Name));
|
||||
}
|
||||
}
|
||||
fc = new Enumerator(folder.files);
|
||||
for(; !fc.atEnd(); fc.moveNext()) {
|
||||
if(!spec || fc.item().Name.match(spec)) {
|
||||
paths.push(root + "/" + fc.item().Name);
|
||||
}
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
var folder = fso.GetFolder(path);
|
||||
var paths = [];
|
||||
return filesInFolder(folder, path);
|
||||
},
|
||||
print: function (str) {
|
||||
WScript.StdOut.Write(str);
|
||||
},
|
||||
printLine: function (str) {
|
||||
WScript.Echo(str);
|
||||
},
|
||||
arguments: args,
|
||||
stderr: WScript.StdErr,
|
||||
stdout: WScript.StdOut,
|
||||
watchFile: null,
|
||||
run: function (source, filename) {
|
||||
try {
|
||||
eval(source);
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Error while executing file '" + filename + "'.", e);
|
||||
}
|
||||
},
|
||||
getExecutingFilePath: function () {
|
||||
return WScript.ScriptFullName;
|
||||
},
|
||||
quit: function (exitCode) {
|
||||
if (typeof exitCode === "undefined") { exitCode = 0; }
|
||||
try {
|
||||
WScript.Quit(exitCode);
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
;
|
||||
function getNodeIO() {
|
||||
var _fs = require('fs');
|
||||
var _path = require('path');
|
||||
var _module = require('module');
|
||||
return {
|
||||
readFile: function (file) {
|
||||
try {
|
||||
var buffer = _fs.readFileSync(file);
|
||||
switch(buffer[0]) {
|
||||
case 254:
|
||||
if(buffer[1] == 255) {
|
||||
var i = 0;
|
||||
while((i + 1) < buffer.length) {
|
||||
var temp = buffer[i];
|
||||
buffer[i] = buffer[i + 1];
|
||||
buffer[i + 1] = temp;
|
||||
i += 2;
|
||||
}
|
||||
return buffer.toString("ucs2", 2);
|
||||
}
|
||||
break;
|
||||
case 255:
|
||||
if(buffer[1] == 254) {
|
||||
return buffer.toString("ucs2", 2);
|
||||
}
|
||||
break;
|
||||
case 239:
|
||||
if(buffer[1] == 187) {
|
||||
return buffer.toString("utf8", 3);
|
||||
}
|
||||
}
|
||||
return buffer.toString();
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Error reading file \"" + file + "\".", e);
|
||||
}
|
||||
},
|
||||
writeFile: _fs.writeFileSync,
|
||||
deleteFile: function (path) {
|
||||
try {
|
||||
_fs.unlinkSync(path);
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Couldn't delete file '" + path + "'.", e);
|
||||
}
|
||||
},
|
||||
fileExists: function (path) {
|
||||
return _fs.existsSync(path);
|
||||
},
|
||||
createFile: function (path, useUTF8) {
|
||||
function mkdirRecursiveSync(path) {
|
||||
var stats = _fs.statSync(path);
|
||||
if(stats.isFile()) {
|
||||
IOUtils.throwIOError("\"" + path + "\" exists but isn't a directory.", null);
|
||||
} else if(stats.isDirectory()) {
|
||||
return;
|
||||
} else {
|
||||
mkdirRecursiveSync(_path.dirname(path));
|
||||
_fs.mkdirSync(path, 775);
|
||||
}
|
||||
}
|
||||
mkdirRecursiveSync(_path.dirname(path));
|
||||
try {
|
||||
var fd = _fs.openSync(path, 'w');
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Couldn't write to file '" + path + "'.", e);
|
||||
}
|
||||
return {
|
||||
Write: function (str) {
|
||||
_fs.writeSync(fd, str);
|
||||
},
|
||||
WriteLine: function (str) {
|
||||
_fs.writeSync(fd, str + '\r\n');
|
||||
},
|
||||
Close: function () {
|
||||
_fs.closeSync(fd);
|
||||
fd = null;
|
||||
}
|
||||
};
|
||||
},
|
||||
dir: function dir(path, spec, options) {
|
||||
options = options || {
|
||||
};
|
||||
function filesInFolder(folder, deep) {
|
||||
var paths = [];
|
||||
var files = _fs.readdirSync(folder);
|
||||
for(var i = 0; i < files.length; i++) {
|
||||
var stat = _fs.statSync(folder + "/" + files[i]);
|
||||
if(options.recursive && stat.isDirectory()) {
|
||||
if(deep < (options.deep || 100)) {
|
||||
paths = paths.concat(filesInFolder(folder + "/" + files[i], 1));
|
||||
}
|
||||
} else if(stat.isFile() && (!spec || files[i].match(spec))) {
|
||||
paths.push(folder + "/" + files[i]);
|
||||
}
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
return filesInFolder(path, 0);
|
||||
},
|
||||
createDirectory: function (path) {
|
||||
try {
|
||||
if(!this.directoryExists(path)) {
|
||||
_fs.mkdirSync(path);
|
||||
}
|
||||
} catch (e) {
|
||||
IOUtils.throwIOError("Couldn't create directory '" + path + "'.", e);
|
||||
}
|
||||
},
|
||||
directoryExists: function (path) {
|
||||
return _fs.existsSync(path) && _fs.lstatSync(path).isDirectory();
|
||||
},
|
||||
resolvePath: function (path) {
|
||||
return _path.resolve(path);
|
||||
},
|
||||
dirName: function (path) {
|
||||
return _path.dirname(path);
|
||||
},
|
||||
findFile: function (rootPath, partialFilePath) {
|
||||
var path = rootPath + "/" + partialFilePath;
|
||||
while(true) {
|
||||
if(_fs.existsSync(path)) {
|
||||
try {
|
||||
var content = this.readFile(path);
|
||||
return {
|
||||
content: content,
|
||||
path: path
|
||||
};
|
||||
} catch (err) {
|
||||
}
|
||||
} else {
|
||||
var parentPath = _path.resolve(rootPath, "..");
|
||||
if(rootPath === parentPath) {
|
||||
return null;
|
||||
} else {
|
||||
rootPath = parentPath;
|
||||
path = _path.resolve(rootPath, partialFilePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
print: function (str) {
|
||||
process.stdout.write(str);
|
||||
},
|
||||
printLine: function (str) {
|
||||
process.stdout.write(str + '\n');
|
||||
},
|
||||
arguments: process.argv.slice(2),
|
||||
stderr: {
|
||||
Write: function (str) {
|
||||
process.stderr.write(str);
|
||||
},
|
||||
WriteLine: function (str) {
|
||||
process.stderr.write(str + '\n');
|
||||
},
|
||||
Close: function () {
|
||||
}
|
||||
},
|
||||
stdout: {
|
||||
Write: function (str) {
|
||||
process.stdout.write(str);
|
||||
},
|
||||
WriteLine: function (str) {
|
||||
process.stdout.write(str + '\n');
|
||||
},
|
||||
Close: function () {
|
||||
}
|
||||
},
|
||||
watchFile: function (filename, callback) {
|
||||
var firstRun = true;
|
||||
var processingChange = false;
|
||||
var fileChanged = function (curr, prev) {
|
||||
if(!firstRun) {
|
||||
if(curr.mtime < prev.mtime) {
|
||||
return;
|
||||
}
|
||||
_fs.unwatchFile(filename, fileChanged);
|
||||
if(!processingChange) {
|
||||
processingChange = true;
|
||||
callback(filename);
|
||||
setTimeout(function () {
|
||||
processingChange = false;
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
firstRun = false;
|
||||
_fs.watchFile(filename, {
|
||||
persistent: true,
|
||||
interval: 500
|
||||
}, fileChanged);
|
||||
};
|
||||
fileChanged();
|
||||
return {
|
||||
filename: filename,
|
||||
close: function () {
|
||||
_fs.unwatchFile(filename, fileChanged);
|
||||
}
|
||||
};
|
||||
},
|
||||
run: function (source, filename) {
|
||||
require.main.filename = filename;
|
||||
require.main.paths = _module._nodeModulePaths(_path.dirname(_fs.realpathSync(filename)));
|
||||
require.main._compile(source, filename);
|
||||
},
|
||||
getExecutingFilePath: function () {
|
||||
return process.mainModule.filename;
|
||||
},
|
||||
quit: process.exit
|
||||
};
|
||||
}
|
||||
;
|
||||
if(typeof ActiveXObject === "function") {
|
||||
return getWindowsScriptHostIO();
|
||||
} else if(typeof require === "function") {
|
||||
return getNodeIO();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
})();
|
||||
var cfg = {
|
||||
root: '.',
|
||||
pattern: /.\-tests\.ts/g,
|
||||
tsc: 'node ./_infrastructure/tests/typescript/tsc.js ',
|
||||
exclude: {
|
||||
'.git': true,
|
||||
'.gitignore': true,
|
||||
'package.json': true,
|
||||
'_infrastructure': true,
|
||||
'.travis.yml': true,
|
||||
'LICENSE': true,
|
||||
'README.md': true,
|
||||
'_ReSharper.DefinitelyTyped': true,
|
||||
'obj': true,
|
||||
'bin': true,
|
||||
'Properties': true,
|
||||
'DefinitelyTyped.csproj': true,
|
||||
'DefinitelyTyped.csproj.user': true,
|
||||
'DefinitelyTyped.sln': true,
|
||||
'DefinitelyTyped.v11.suo': true
|
||||
}
|
||||
};
|
||||
if(process.argv.length > 2) {
|
||||
cfg.root = process.argv[2];
|
||||
}
|
||||
var TestFile = (function () {
|
||||
function TestFile() {
|
||||
this.errors = [];
|
||||
}
|
||||
return TestFile;
|
||||
})();
|
||||
var Test = (function () {
|
||||
function Test(lib) {
|
||||
this.lib = lib;
|
||||
this.files = [];
|
||||
}
|
||||
return Test;
|
||||
})();
|
||||
var Tests = (function () {
|
||||
function Tests() {
|
||||
this.tests = [];
|
||||
}
|
||||
return Tests;
|
||||
})();
|
||||
function getLibDirectory(file) {
|
||||
return file.substr(cfg.root.length).split('/')[1];
|
||||
}
|
||||
function getErrorList(out) {
|
||||
var splitContentByNewlines = function (content) {
|
||||
var lines = content.split('\r\n');
|
||||
if(lines.length === 1) {
|
||||
lines = content.split('\n');
|
||||
}
|
||||
return lines;
|
||||
};
|
||||
var result = [];
|
||||
var lines = splitContentByNewlines(out);
|
||||
for(var i = 0; i < lines.length; i++) {
|
||||
if(lines[i]) {
|
||||
result.push(lines[i]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
function runTests(testFiles) {
|
||||
var tests = new Tests();
|
||||
Exec.exec(cfg.tsc, [
|
||||
testFiles[testIndex]
|
||||
], function (ExecResult) {
|
||||
var lib = getLibDirectory(testFiles[testIndex]);
|
||||
cache_visited_libs[lib] = true;
|
||||
var testFile = new TestFile();
|
||||
testFile.name = testFiles[testIndex];
|
||||
testFile.errors = getErrorList(ExecResult.stderr);
|
||||
if(testFile.errors.length == 0) {
|
||||
total_success++;
|
||||
} else {
|
||||
total_failure++;
|
||||
}
|
||||
console.log(' [\033[36m' + lib + '\033[0m] ' + testFiles[testIndex].substr(cfg.root.length) + ' - ' + (testFile.errors.length == 0 ? '\033[32msuccess\033[0m' : '\033[31mfailure\033[0m'));
|
||||
var test = new Test(lib);
|
||||
test.files.push(testFile);
|
||||
tests.tests.push(test);
|
||||
testIndex++;
|
||||
if(testIndex < totalTest) {
|
||||
Exec.exec(cfg.tsc, [
|
||||
testFiles[testIndex]
|
||||
], arguments.callee);
|
||||
} else {
|
||||
var withoutTests = {
|
||||
};
|
||||
for(var k = 0; k < allFiles.length; k++) {
|
||||
var rootFolder = allFiles[k].substr(cfg.root.length).split('/')[1];
|
||||
if(!(rootFolder in cfg.exclude)) {
|
||||
if(!(rootFolder in cache_visited_libs)) {
|
||||
withoutTests[rootFolder] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
var withoutTestsCount = 0;
|
||||
for(var attr in withoutTests) {
|
||||
var test = new Test(attr);
|
||||
tests.tests.push(test);
|
||||
console.log(' [\033[36m' + attr + '\033[0m] without tests');
|
||||
withoutTestsCount++;
|
||||
}
|
||||
console.log('\n> ' + (total_failure + total_success + withoutTestsCount) + ' tests. ' + '\033[32m' + total_success + ' tests success\033[0m, ' + '\033[31m' + total_failure + ' tests failed\033[0m and ' + withoutTestsCount + ' definitions without tests.\n');
|
||||
if(total_failure > 0) {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
var testFiles = IO.dir(cfg.root, cfg.pattern, {
|
||||
recursive: true,
|
||||
deep: 1
|
||||
});
|
||||
var allFiles = IO.dir(cfg.root, null, {
|
||||
recursive: true
|
||||
});
|
||||
var totalTest = testFiles.length;
|
||||
var testIndex = 0;
|
||||
var cache_visited_libs = {
|
||||
};
|
||||
var total_failure = 0;
|
||||
var total_success = 0;
|
||||
var tscVersion = '?.?.?';
|
||||
Exec.exec(cfg.tsc, [
|
||||
'-version'
|
||||
], function (ExecResult) {
|
||||
tscVersion = ExecResult.stdout;
|
||||
console.log('$ tsc -version');
|
||||
console.log(tscVersion);
|
||||
runTests(testFiles);
|
||||
});
|
||||
@@ -1,168 +0,0 @@
|
||||
/// <reference path='src/exec.ts' />
|
||||
/// <reference path='src/io.ts' />
|
||||
|
||||
var cfg = {
|
||||
root: '.',
|
||||
pattern: /.\-tests\.ts/g,
|
||||
tsc: 'node ./_infrastructure/tests/typescript/tsc.js ',
|
||||
exclude: {
|
||||
'.git': true,
|
||||
'.gitignore': true,
|
||||
'package.json': true,
|
||||
'_infrastructure': true,
|
||||
'.travis.yml': true,
|
||||
'LICENSE': true,
|
||||
'README.md': true,
|
||||
'_ReSharper.DefinitelyTyped': true,
|
||||
'obj': true,
|
||||
'bin': true,
|
||||
'Properties': true,
|
||||
'DefinitelyTyped.csproj': true,
|
||||
'DefinitelyTyped.csproj.user': true,
|
||||
'DefinitelyTyped.sln': true,
|
||||
'DefinitelyTyped.v11.suo': true
|
||||
}
|
||||
};
|
||||
|
||||
if (process.argv.length > 2) {
|
||||
cfg.root = process.argv[2];
|
||||
}
|
||||
|
||||
class TestFile {
|
||||
public name: string;
|
||||
public errors: string[] = [];
|
||||
}
|
||||
|
||||
class Test {
|
||||
public files: TestFile[] = [];
|
||||
constructor(public lib: string) { }
|
||||
}
|
||||
|
||||
class Tests {
|
||||
public tests: Test[] = [];
|
||||
}
|
||||
|
||||
function getLibDirectory(file: string) {
|
||||
return file.substr(cfg.root.length).split('/')[1];
|
||||
}
|
||||
|
||||
function getErrorList(out): string[] {
|
||||
var splitContentByNewlines = function (content: string) {
|
||||
var lines = content.split('\r\n');
|
||||
if (lines.length === 1) {
|
||||
lines = content.split('\n');
|
||||
}
|
||||
return lines;
|
||||
}
|
||||
|
||||
var result: string[] = [];
|
||||
|
||||
var lines = splitContentByNewlines(out);
|
||||
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
if (lines[i]) {
|
||||
result.push(lines[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function runTests(testFiles) {
|
||||
var tests = new Tests();
|
||||
|
||||
Exec.exec(
|
||||
cfg.tsc,
|
||||
[testFiles[testIndex]],
|
||||
(ExecResult) => {
|
||||
var lib = getLibDirectory(testFiles[testIndex]);
|
||||
|
||||
cache_visited_libs[lib] = true;
|
||||
|
||||
var testFile = new TestFile();
|
||||
testFile.name = testFiles[testIndex];
|
||||
testFile.errors = getErrorList(ExecResult.stderr);
|
||||
|
||||
if (testFile.errors.length == 0) {
|
||||
total_success++;
|
||||
} else {
|
||||
total_failure++;
|
||||
}
|
||||
|
||||
console.log(' [\033[36m' + lib + '\033[0m] ' + testFiles[testIndex].substr(cfg.root.length)
|
||||
+ ' - ' + (testFile.errors.length == 0 ? '\033[32msuccess\033[0m' : '\033[31mfailure\033[0m'));
|
||||
|
||||
var test = new Test(lib);
|
||||
test.files.push(testFile);
|
||||
tests.tests.push(test);
|
||||
|
||||
testIndex++;
|
||||
if (testIndex < totalTest) {
|
||||
Exec.exec(
|
||||
cfg.tsc,
|
||||
[testFiles[testIndex]],
|
||||
<(ExecResult) => any>arguments.callee);
|
||||
} else {
|
||||
var withoutTests = {};
|
||||
for (var k = 0; k < allFiles.length; k++) {
|
||||
var rootFolder = allFiles[k].substr(cfg.root.length).split('/')[1];
|
||||
if (!(rootFolder in cfg.exclude)) {
|
||||
if (!(rootFolder in cache_visited_libs)) {
|
||||
withoutTests[rootFolder] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var withoutTestsCount = 0;
|
||||
for (var attr in withoutTests) {
|
||||
|
||||
var test = new Test(attr);
|
||||
tests.tests.push(test);
|
||||
|
||||
console.log(' [\033[36m' + attr + '\033[0m] without tests');
|
||||
withoutTestsCount++;
|
||||
}
|
||||
|
||||
console.log('\n> ' + (total_failure + total_success + withoutTestsCount)
|
||||
+ ' tests. '
|
||||
+ '\033[32m' + total_success + ' tests success\033[0m, '
|
||||
+ '\033[31m' + total_failure + ' tests failed\033[0m and '
|
||||
+ withoutTestsCount + ' definitions without tests.\n');
|
||||
|
||||
if (total_failure > 0) {
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
////// GLOBAL VARS
|
||||
|
||||
// get all files: "*-tests.ts"
|
||||
var testFiles = IO.dir(cfg.root, cfg.pattern, { recursive: true, deep: 1 });
|
||||
|
||||
// get all proect files
|
||||
var allFiles = IO.dir(cfg.root, null, { recursive: true });
|
||||
|
||||
var totalTest = testFiles.length;
|
||||
var testIndex = 0;
|
||||
var cache_visited_libs = {};
|
||||
|
||||
// total
|
||||
var total_failure = 0;
|
||||
var total_success = 0;
|
||||
|
||||
// var to have current typescript version
|
||||
var tscVersion = '?.?.?';
|
||||
|
||||
////// END GLOBAL VARS
|
||||
|
||||
// entry point
|
||||
Exec.exec(cfg.tsc, ['-version'], (ExecResult) => {
|
||||
tscVersion = ExecResult.stdout;
|
||||
|
||||
console.log('$ tsc -version');
|
||||
console.log(tscVersion);
|
||||
|
||||
runTests(testFiles);
|
||||
});
|
||||
Vendored
+18
-18
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Diullei Gomes <https://github.com/Diullei>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
module AceAjax {
|
||||
declare module AceAjax {
|
||||
|
||||
export interface Delta {
|
||||
action: string;
|
||||
@@ -75,7 +75,7 @@ module AceAjax {
|
||||
|
||||
onTextInput(text);
|
||||
}
|
||||
declare var KeyBinding: {
|
||||
var KeyBinding: {
|
||||
new(editor: Editor): KeyBinding;
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ module AceAjax {
|
||||
**/
|
||||
detach();
|
||||
}
|
||||
declare var Anchor: {
|
||||
var Anchor: {
|
||||
/**
|
||||
* Creates a new `Anchor` and associates it with a document.
|
||||
* @param doc The document to associate with the anchor
|
||||
@@ -248,7 +248,7 @@ module AceAjax {
|
||||
**/
|
||||
getState(row: number): string;
|
||||
}
|
||||
declare var BackgroundTokenizer: {
|
||||
var BackgroundTokenizer: {
|
||||
/**
|
||||
* Creates a new `BackgroundTokenizer` object.
|
||||
* @param tokenizer The tokenizer to use
|
||||
@@ -435,7 +435,7 @@ module AceAjax {
|
||||
**/
|
||||
positionToIndex(pos: Position, startRow: number): number;
|
||||
}
|
||||
declare var Document: {
|
||||
var Document: {
|
||||
/**
|
||||
* Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty.
|
||||
* @param text The starting text
|
||||
@@ -1011,7 +1011,7 @@ module AceAjax {
|
||||
**/
|
||||
getScreenLength(): number;
|
||||
}
|
||||
declare var EditSession: {
|
||||
var EditSession: {
|
||||
/**
|
||||
* Sets up a new `EditSession` and associates it with the given `Document` and `TextMode`.
|
||||
* @param text [If `text` is a `Document`, it associates the `EditSession` with it. Otherwise, a new `Document` is created, with the initial text]{: #textParam}
|
||||
@@ -1702,7 +1702,7 @@ module AceAjax {
|
||||
|
||||
}
|
||||
|
||||
declare var Editor: {
|
||||
var Editor: {
|
||||
/**
|
||||
* Creates a new `Editor` object.
|
||||
* @param renderer Associated `VirtualRenderer` that draws everything
|
||||
@@ -1761,7 +1761,7 @@ module AceAjax {
|
||||
**/
|
||||
cancel();
|
||||
}
|
||||
declare var PlaceHolder: {
|
||||
var PlaceHolder: {
|
||||
/**
|
||||
* - @param session (Document): The document to associate with the anchor
|
||||
* - @param length (Number): The starting row position
|
||||
@@ -1995,7 +1995,7 @@ module AceAjax {
|
||||
* @param endRow The ending row
|
||||
* @param endColumn The ending column
|
||||
**/
|
||||
declare var Range: {
|
||||
var Range: {
|
||||
fromPoints(pos1: Position, pos2: Position): Range;
|
||||
new(startRow: number, startColumn: number, endRow: number, endColumn: number): Range;
|
||||
}
|
||||
@@ -2005,7 +2005,7 @@ module AceAjax {
|
||||
////////////////
|
||||
|
||||
export interface RenderLoop { }
|
||||
declare var RenderLoop: {
|
||||
var RenderLoop: {
|
||||
new(): RenderLoop;
|
||||
}
|
||||
|
||||
@@ -2047,7 +2047,7 @@ module AceAjax {
|
||||
**/
|
||||
setScrollTop(scrollTop: number);
|
||||
}
|
||||
declare var ScrollBar: {
|
||||
var ScrollBar: {
|
||||
/**
|
||||
* Creates a new `ScrollBar`. `parent` is the owner of the scroll bar.
|
||||
* @param parent A DOM element
|
||||
@@ -2102,7 +2102,7 @@ module AceAjax {
|
||||
**/
|
||||
replace(input: string, replacement: string): string;
|
||||
}
|
||||
declare var Search: {
|
||||
var Search: {
|
||||
/**
|
||||
* Creates a new `Search` object. The following search options are avaliable:
|
||||
* - `needle`: The string or regular expression you're looking for
|
||||
@@ -2371,7 +2371,7 @@ module AceAjax {
|
||||
**/
|
||||
moveCursorToScreen(row: number, column: number, keepDesiredColumn: boolean);
|
||||
}
|
||||
declare var Selection: {
|
||||
var Selection: {
|
||||
/**
|
||||
* Creates a new `Selection` object.
|
||||
* @param session The session to use
|
||||
@@ -2459,7 +2459,7 @@ module AceAjax {
|
||||
**/
|
||||
resize();
|
||||
}
|
||||
declare var Split: {
|
||||
var Split: {
|
||||
new(): Split;
|
||||
}
|
||||
|
||||
@@ -2497,7 +2497,7 @@ module AceAjax {
|
||||
**/
|
||||
getCurrentTokenColumn(): number;
|
||||
}
|
||||
declare var TokenIterator: {
|
||||
var TokenIterator: {
|
||||
/**
|
||||
* Creates a new token iterator object. The inital token index is set to the provided row and column coordinates.
|
||||
* @param session The session to associate with
|
||||
@@ -2522,7 +2522,7 @@ module AceAjax {
|
||||
**/
|
||||
getLineTokens(): any;
|
||||
}
|
||||
declare var Tokenizer: {
|
||||
var Tokenizer: {
|
||||
/**
|
||||
* Constructs a new tokenizer based on the given rules and flags.
|
||||
* @param rules The highlighting rules
|
||||
@@ -2576,7 +2576,7 @@ module AceAjax {
|
||||
hasRedo(): boolean;
|
||||
|
||||
}
|
||||
declare var UndoManager: {
|
||||
var UndoManager: {
|
||||
/**
|
||||
* Resets the current undo state and creates a new `UndoManager`.
|
||||
**/
|
||||
@@ -2924,7 +2924,7 @@ module AceAjax {
|
||||
destroy();
|
||||
|
||||
}
|
||||
declare var VirtualRenderer: {
|
||||
var VirtualRenderer: {
|
||||
/**
|
||||
* Constructs a new `VirtualRenderer` within the `container` specified, applying the given `theme`.
|
||||
* @param container The root element of the editor
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference path="../ace.d.ts" />
|
||||
|
||||
exports = {
|
||||
var assert: any;
|
||||
var exports = {
|
||||
|
||||
"test create anchor" : function() {
|
||||
var doc = new AceAjax.Document("juhu");
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
/// <reference path="../ace.d.ts" />
|
||||
|
||||
var assert: any;
|
||||
|
||||
function forceTokenize(session) {
|
||||
for (var i = 0, l = session.getLength(); i < l; i++)
|
||||
session.getTokens(i)
|
||||
@@ -11,7 +13,7 @@ function testStates(session, states) {
|
||||
assert.ok(l == states.length)
|
||||
}
|
||||
|
||||
exports = {
|
||||
var exports = {
|
||||
|
||||
"test background tokenizer update on session change": function() {
|
||||
var doc = new AceAjax.EditSession([
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/// <reference path="../ace.d.ts" />
|
||||
|
||||
var assert: any;
|
||||
var editor = ace.edit("editor");
|
||||
editor.setTheme("ace/theme/monokai");
|
||||
editor.getSession().setMode("ace/mode/javascript");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference path="../ace.d.ts" />
|
||||
|
||||
exports = {
|
||||
var assert: any;
|
||||
var exports = {
|
||||
"test: insert text in line": function() {
|
||||
var doc = new AceAjax.Document(["12", "34"]);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference path="../ace.d.ts" />
|
||||
|
||||
var lang: any;
|
||||
var assert: any;
|
||||
|
||||
function createFoldTestSession() {
|
||||
var lines = [
|
||||
@@ -26,7 +27,7 @@ function assertArray(a, b) {
|
||||
}
|
||||
}
|
||||
|
||||
exports = {
|
||||
var exports = {
|
||||
|
||||
"test: find matching opening bracket in Text mode": function() {
|
||||
var session = new AceAjax.EditSession(["(()(", "())))"]);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference path="../ace.d.ts" />
|
||||
|
||||
exports = {
|
||||
var assert: any;
|
||||
var exports = {
|
||||
|
||||
setUp: function(next) {
|
||||
this.session1 = new AceAjax.EditSession(["abc", "def"]);
|
||||
|
||||
@@ -27,10 +27,13 @@ function callHighlighterUpdate(session: AceAjax.IEditSession, firstRow: number,
|
||||
return rangeCount;
|
||||
}
|
||||
|
||||
exports = {
|
||||
var assert: any;
|
||||
var renderer: AceAjax.VirtualRenderer;
|
||||
|
||||
var exports = {
|
||||
setUp: function(next) {
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
var selection = session.getSelection();
|
||||
next();
|
||||
} ,
|
||||
@@ -38,7 +41,7 @@ exports = {
|
||||
"test: highlight selected words by default": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
assert.equal(editor.getHighlightSelectedWord(), true);
|
||||
} ,
|
||||
@@ -46,7 +49,7 @@ exports = {
|
||||
"test: highlight a word": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 9);
|
||||
selection.selectWord();
|
||||
@@ -63,7 +66,7 @@ exports = {
|
||||
"test: highlight a word and clear highlight": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 8);
|
||||
selection.selectWord();
|
||||
@@ -79,7 +82,7 @@ exports = {
|
||||
"test: highlight another word": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
selection.moveCursorTo(0, 14);
|
||||
selection.selectWord();
|
||||
@@ -92,7 +95,7 @@ exports = {
|
||||
"test: no selection, no highlight": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
selection.clearSelection();
|
||||
assert.equal(callHighlighterUpdate(session, 0, 0), 0);
|
||||
@@ -101,7 +104,7 @@ exports = {
|
||||
"test: select a word, no highlight": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
selection.moveCursorTo(0, 14);
|
||||
selection.selectWord();
|
||||
@@ -116,7 +119,7 @@ exports = {
|
||||
"test: select a word with no matches": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.setHighlightSelectedWord(true);
|
||||
|
||||
@@ -143,7 +146,7 @@ exports = {
|
||||
"test: partial word selection 1": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
selection.moveCursorTo(0, 14);
|
||||
selection.selectWord();
|
||||
@@ -157,7 +160,7 @@ exports = {
|
||||
"test: partial word selection 2": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
selection.moveCursorTo(0, 13);
|
||||
selection.selectWord();
|
||||
@@ -171,7 +174,7 @@ exports = {
|
||||
"test: partial word selection 3": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
selection.moveCursorTo(0, 14);
|
||||
selection.selectWord();
|
||||
@@ -186,7 +189,7 @@ exports = {
|
||||
"test: select last word": function () {
|
||||
var selection = session.getSelection();
|
||||
var session = new AceAjax.EditSession(lipsum);
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
selection.moveCursorTo(0, 1);
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/// <reference path="../ace.d.ts" />
|
||||
|
||||
exports = {
|
||||
var assert: any;
|
||||
var renderer: AceAjax.VirtualRenderer;
|
||||
var exports = {
|
||||
createEditSession: function (rows, cols) {
|
||||
var line = new Array(cols + 1).join("a");
|
||||
var text = new Array(rows).join(line + "\n") + line;
|
||||
@@ -9,7 +11,7 @@ exports = {
|
||||
|
||||
"test: navigate to end of file should scroll the last line into view": function () {
|
||||
var doc = this.createEditSession(200, 10);
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), doc);
|
||||
var editor = new AceAjax.Editor(renderer, doc);
|
||||
|
||||
editor.navigateFileEnd();
|
||||
var cursor = editor.getCursorPosition();
|
||||
@@ -20,7 +22,7 @@ exports = {
|
||||
|
||||
"test: navigate to start of file should scroll the first row into view": function () {
|
||||
var doc = this.createEditSession(200, 10);
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), doc);
|
||||
var editor = new AceAjax.Editor(renderer, doc);
|
||||
|
||||
editor.moveCursorTo(editor.getLastVisibleRow() + 20);
|
||||
editor.navigateFileStart();
|
||||
@@ -29,7 +31,7 @@ exports = {
|
||||
},
|
||||
|
||||
"test: goto hidden line should scroll the line into the middle of the viewport": function () {
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), this.createEditSession(200, 5));
|
||||
var editor = new AceAjax.Editor(renderer, this.createEditSession(200, 5));
|
||||
|
||||
editor.navigateTo(0, 0);
|
||||
editor.gotoLine(101);
|
||||
@@ -63,7 +65,7 @@ exports = {
|
||||
},
|
||||
|
||||
"test: goto visible line should only move the cursor and not scroll": function () {
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), this.createEditSession(200, 5));
|
||||
var editor = new AceAjax.Editor(renderer, this.createEditSession(200, 5));
|
||||
|
||||
editor.navigateTo(0, 0);
|
||||
editor.gotoLine(12);
|
||||
@@ -77,7 +79,7 @@ exports = {
|
||||
},
|
||||
|
||||
"test: navigate from the end of a long line down to a short line and back should maintain the curser column": function () {
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), new AceAjax.EditSession(["123456", "1"]));
|
||||
var editor = new AceAjax.Editor(renderer, new AceAjax.EditSession(["123456", "1"]));
|
||||
|
||||
editor.navigateTo(0, 6);
|
||||
assert.position(editor.getCursorPosition(), 0, 6);
|
||||
@@ -90,7 +92,7 @@ exports = {
|
||||
},
|
||||
|
||||
"test: reset desired column on navigate left or right": function () {
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), new AceAjax.EditSession(["123456", "12"]));
|
||||
var editor = new AceAjax.Editor(renderer, new AceAjax.EditSession(["123456", "12"]));
|
||||
|
||||
editor.navigateTo(0, 6);
|
||||
assert.position(editor.getCursorPosition(), 0, 6);
|
||||
@@ -106,7 +108,7 @@ exports = {
|
||||
},
|
||||
|
||||
"test: typing text should update the desired column": function () {
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), new AceAjax.EditSession(["1234", "1234567890"]));
|
||||
var editor = new AceAjax.Editor(renderer, new AceAjax.EditSession(["1234", "1234567890"]));
|
||||
|
||||
editor.navigateTo(0, 3);
|
||||
editor.insert("juhu");
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
/// <reference path="../ace.d.ts" />
|
||||
|
||||
exports = {
|
||||
var assert: any;
|
||||
var renderer: AceAjax.VirtualRenderer;
|
||||
var mode: any;
|
||||
var exports = {
|
||||
"test: delete line from the middle": function () {
|
||||
var session = new AceAjax.EditSession(["a", "b", "c", "d"].join("\n"));
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.removeLines();
|
||||
@@ -29,7 +32,7 @@ exports = {
|
||||
|
||||
"test: delete multiple selected lines": function () {
|
||||
var session = new AceAjax.EditSession(["a", "b", "c", "d"].join("\n"));
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.getSelection().selectDown();
|
||||
@@ -41,7 +44,7 @@ exports = {
|
||||
|
||||
"test: delete first line": function () {
|
||||
var session = new AceAjax.EditSession(["a", "b", "c"].join("\n"));
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.removeLines();
|
||||
|
||||
@@ -51,7 +54,7 @@ exports = {
|
||||
|
||||
"test: delete last should also delete the new line of the previous line": function () {
|
||||
var session = new AceAjax.EditSession(["a", "b", "c", ""].join("\n"));
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(3, 0);
|
||||
|
||||
@@ -66,7 +69,7 @@ exports = {
|
||||
|
||||
"test: indent block": function () {
|
||||
var session = new AceAjax.EditSession(["a12345", "b12345", "c12345"].join("\n"));
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(1, 3);
|
||||
editor.getSelection().selectDown();
|
||||
@@ -84,7 +87,7 @@ exports = {
|
||||
|
||||
"test: indent selected lines": function () {
|
||||
var session = new AceAjax.EditSession(["a12345", "b12345", "c12345"].join("\n"));
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.getSelection().selectDown();
|
||||
@@ -94,8 +97,8 @@ exports = {
|
||||
},
|
||||
|
||||
"test: no auto indent if cursor is before the {": function () {
|
||||
var session = new AceAjax.EditSession("{", new JavaScriptMode());
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var session = new AceAjax.EditSession("{",mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 0);
|
||||
editor.onTextInput("\n");
|
||||
@@ -104,7 +107,7 @@ exports = {
|
||||
|
||||
"test: outdent block": function () {
|
||||
var session = new AceAjax.EditSession([" a12345", " b12345", " c12345"].join("\n"));
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 5);
|
||||
editor.getSelection().selectDown();
|
||||
@@ -129,7 +132,7 @@ exports = {
|
||||
|
||||
"test: outent without a selection should update cursor": function () {
|
||||
var session = new AceAjax.EditSession(" 12");
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 3);
|
||||
editor.blockOutdent(" ");
|
||||
@@ -139,8 +142,8 @@ exports = {
|
||||
},
|
||||
|
||||
"test: comment lines should perserve selection": function () {
|
||||
var session = new AceAjax.EditSession([" abc", "cde"].join("\n"), new JavaScriptMode());
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var session = new AceAjax.EditSession([" abc", "cde"].join("\n"),mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 2);
|
||||
editor.getSelection().selectDown();
|
||||
@@ -154,8 +157,8 @@ exports = {
|
||||
},
|
||||
|
||||
"test: uncomment lines should perserve selection": function () {
|
||||
var session = new AceAjax.EditSession(["// abc", "//cde"].join("\n"), new JavaScriptMode());
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var session = new AceAjax.EditSession(["// abc", "//cde"].join("\n"),mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 1);
|
||||
editor.getSelection().selectDown();
|
||||
@@ -169,8 +172,8 @@ exports = {
|
||||
},
|
||||
|
||||
"test: toggle comment lines twice should return the original text": function () {
|
||||
var session = new AceAjax.EditSession([" abc", "cde", "fg"], new JavaScriptMode());
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var session = new AceAjax.EditSession([" abc", "cde", "fg"], mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 0);
|
||||
editor.getSelection().selectDown();
|
||||
@@ -185,8 +188,8 @@ exports = {
|
||||
|
||||
"test: comment lines - if the selection end is at the line start it should stay there": function () {
|
||||
//select down
|
||||
var session = new AceAjax.EditSession(["abc", "cde"].join("\n"), new JavaScriptMode());
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var session = new AceAjax.EditSession(["abc", "cde"].join("\n"),mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 0);
|
||||
editor.getSelection().selectDown();
|
||||
@@ -195,8 +198,8 @@ exports = {
|
||||
assert.range(editor.getSelectionRange(), 0, 2, 1, 0);
|
||||
|
||||
// select up
|
||||
var session = new AceAjax.EditSession(["abc", "cde"].join("\n"), new JavaScriptMode());
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var session = new AceAjax.EditSession(["abc", "cde"].join("\n"),mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.getSelection().selectUp();
|
||||
@@ -207,7 +210,7 @@ exports = {
|
||||
|
||||
"test: move lines down should select moved lines": function () {
|
||||
var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(0, 1);
|
||||
editor.getSelection().selectDown();
|
||||
@@ -234,7 +237,7 @@ exports = {
|
||||
|
||||
"test: move lines up should select moved lines": function () {
|
||||
var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(2, 1);
|
||||
editor.getSelection().selectDown();
|
||||
@@ -254,7 +257,7 @@ exports = {
|
||||
|
||||
"test: move line without active selection should not move cursor relative to the moved line": function () {
|
||||
var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.clearSelection();
|
||||
@@ -272,7 +275,7 @@ exports = {
|
||||
|
||||
"test: copy lines down should select lines and place cursor at the selection start": function () {
|
||||
var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.getSelection().selectDown();
|
||||
@@ -287,7 +290,7 @@ exports = {
|
||||
|
||||
"test: copy lines up should select lines and place cursor at the selection start": function () {
|
||||
var session = new AceAjax.EditSession(["11", "22", "33", "44"].join("\n"));
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.getSelection().selectDown();
|
||||
@@ -302,7 +305,7 @@ exports = {
|
||||
|
||||
"test: input a tab with soft tab should convert it to spaces": function () {
|
||||
var session = new AceAjax.EditSession("");
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
session.setTabSize(2);
|
||||
session.setUseSoftTabs(true);
|
||||
@@ -317,7 +320,7 @@ exports = {
|
||||
|
||||
"test: input tab without soft tabs should keep the tab character": function () {
|
||||
var session = new AceAjax.EditSession("");
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
session.setUseSoftTabs(false);
|
||||
|
||||
@@ -331,7 +334,7 @@ exports = {
|
||||
session.setUndoManager(undoManager);
|
||||
|
||||
var initialText = session.toString();
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
editor.removeLines();
|
||||
var step1 = session.toString();
|
||||
@@ -361,7 +364,7 @@ exports = {
|
||||
"test: remove left should remove character left of the cursor": function () {
|
||||
var session = new AceAjax.EditSession(["123", "456"]);
|
||||
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.remove("left");
|
||||
assert.equal(session.toString(), "123\n56");
|
||||
@@ -370,7 +373,7 @@ exports = {
|
||||
"test: remove left should remove line break if cursor is at line start": function () {
|
||||
var session = new AceAjax.EditSession(["123", "456"]);
|
||||
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.remove("left");
|
||||
assert.equal(session.toString(), "123456");
|
||||
@@ -381,7 +384,7 @@ exports = {
|
||||
session.setUseSoftTabs(true);
|
||||
session.setTabSize(4);
|
||||
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 8);
|
||||
editor.remove("left");
|
||||
assert.equal(session.toString(), "123\n 456");
|
||||
@@ -390,7 +393,7 @@ exports = {
|
||||
"test: transpose at line start should be a noop": function () {
|
||||
var session = new AceAjax.EditSession(["123", "4567", "89"]);
|
||||
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.transposeLetters();
|
||||
|
||||
@@ -400,7 +403,7 @@ exports = {
|
||||
"test: transpose in line should swap the charaters before and after the cursor": function () {
|
||||
var session = new AceAjax.EditSession(["123", "4567", "89"]);
|
||||
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 2);
|
||||
editor.transposeLetters();
|
||||
|
||||
@@ -410,7 +413,7 @@ exports = {
|
||||
"test: transpose at line end should swap the last two characters": function () {
|
||||
var session = new AceAjax.EditSession(["123", "4567", "89"]);
|
||||
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 4);
|
||||
editor.transposeLetters();
|
||||
|
||||
@@ -420,7 +423,7 @@ exports = {
|
||||
"test: transpose with non empty selection should be a noop": function () {
|
||||
var session = new AceAjax.EditSession(["123", "4567", "89"]);
|
||||
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 1);
|
||||
editor.getSelection().selectRight();
|
||||
editor.transposeLetters();
|
||||
@@ -431,7 +434,7 @@ exports = {
|
||||
"test: transpose should move the cursor behind the last swapped character": function () {
|
||||
var session = new AceAjax.EditSession(["123", "4567", "89"]);
|
||||
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 2);
|
||||
editor.transposeLetters();
|
||||
assert.position(editor.getCursorPosition(), 1, 3);
|
||||
@@ -440,7 +443,7 @@ exports = {
|
||||
"test: remove to line end": function () {
|
||||
var session = new AceAjax.EditSession(["123", "4567", "89"]);
|
||||
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 2);
|
||||
editor.removeToLineEnd();
|
||||
assert.equal(session.getValue(), ["123", "45", "89"].join("\n"));
|
||||
@@ -449,7 +452,7 @@ exports = {
|
||||
"test: remove to line end at line end should remove the new line": function () {
|
||||
var session = new AceAjax.EditSession(["123", "4567", "89"]);
|
||||
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 4);
|
||||
editor.removeToLineEnd();
|
||||
assert.position(editor.getCursorPosition(), 1, 4);
|
||||
@@ -459,7 +462,7 @@ exports = {
|
||||
"test: transform selection to uppercase": function () {
|
||||
var session = new AceAjax.EditSession(["ajax", "dot", "org"]);
|
||||
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.getSelection().selectLineEnd();
|
||||
editor.toUpperCase()
|
||||
@@ -469,7 +472,7 @@ exports = {
|
||||
"test: transform word to uppercase": function () {
|
||||
var session = new AceAjax.EditSession(["ajax", "dot", "org"]);
|
||||
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.toUpperCase()
|
||||
assert.equal(session.getValue(), ["ajax", "DOT", "org"].join("\n"));
|
||||
@@ -479,7 +482,7 @@ exports = {
|
||||
"test: transform selection to lowercase": function () {
|
||||
var session = new AceAjax.EditSession(["AJAX", "DOT", "ORG"]);
|
||||
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.getSelection().selectLineEnd();
|
||||
editor.toLowerCase()
|
||||
@@ -489,7 +492,7 @@ exports = {
|
||||
"test: transform word to lowercase": function () {
|
||||
var session = new AceAjax.EditSession(["AJAX", "DOT", "ORG"]);
|
||||
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
editor.moveCursorTo(1, 0);
|
||||
editor.toLowerCase()
|
||||
assert.equal(session.getValue(), ["AJAX", "dot", "ORG"].join("\n"));
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
/// <reference path="../ace.d.ts" />
|
||||
|
||||
var assert: any;
|
||||
var editor: any;
|
||||
var renderer: any;
|
||||
var exec = function (name?, times?, args?) {
|
||||
do {
|
||||
editor.commands.exec(name, editor, args);
|
||||
@@ -9,7 +12,7 @@ var testRanges = function (str) {
|
||||
assert.equal(editor.selection.getAllRanges() + "", str + "");
|
||||
}
|
||||
|
||||
exports = {
|
||||
var exports = {
|
||||
|
||||
name: "ACE multi_select.js",
|
||||
|
||||
@@ -19,7 +22,7 @@ exports = {
|
||||
" wtt.w",
|
||||
" wtt.w"
|
||||
]);
|
||||
editor = new AceAjax.Editor(new MockRenderer(), doc);
|
||||
editor = new AceAjax.Editor(renderer, doc);
|
||||
|
||||
editor.navigateFileEnd();
|
||||
exec("selectMoreBefore", 3);
|
||||
@@ -45,7 +48,7 @@ exports = {
|
||||
" wtt.w",
|
||||
" wtt.we"
|
||||
]);
|
||||
editor = new AceAjax.Editor(new MockRenderer(), doc);
|
||||
editor = new AceAjax.Editor(renderer, doc);
|
||||
|
||||
editor.selectMoreLines(1);
|
||||
testRanges("Range: [0/0] -> [0/0],Range: [1/0] -> [1/0]");
|
||||
@@ -67,7 +70,7 @@ exports = {
|
||||
" wtt.w",
|
||||
" wtt.w"
|
||||
]);
|
||||
editor = new AceAjax.Editor(new MockRenderer(), doc);
|
||||
editor = new AceAjax.Editor(renderer, doc);
|
||||
|
||||
editor.selectMoreLines(1)
|
||||
testRanges("Range: [0/0] -> [0/0],Range: [1/0] -> [1/0]");
|
||||
@@ -87,7 +90,7 @@ exports = {
|
||||
" wtt.w",
|
||||
" wtt.w"
|
||||
]);
|
||||
editor = new AceAjax.Editor(new MockRenderer(), doc);
|
||||
editor = new AceAjax.Editor(renderer, doc);
|
||||
|
||||
var selection = editor.selection;
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
/// <reference path="../ace.d.ts" />
|
||||
|
||||
exports = {
|
||||
var assert: any;
|
||||
var renderer: AceAjax.VirtualRenderer;
|
||||
var mode: any;
|
||||
var exports = {
|
||||
|
||||
"test: simple at the end appending of text": function () {
|
||||
var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", new JavaScriptMode());
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]);
|
||||
|
||||
@@ -20,8 +23,8 @@ exports = {
|
||||
},
|
||||
|
||||
"test: inserting text outside placeholder": function () {
|
||||
var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);\n", new JavaScriptMode());
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);\n", mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]);
|
||||
|
||||
@@ -31,8 +34,8 @@ exports = {
|
||||
},
|
||||
|
||||
"test: insertion at the beginning": function (next) {
|
||||
var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", new JavaScriptMode());
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
var p = new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]);
|
||||
|
||||
@@ -49,8 +52,8 @@ exports = {
|
||||
},
|
||||
|
||||
"test: detaching placeholder": function () {
|
||||
var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", new JavaScriptMode());
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
var p = new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]);
|
||||
|
||||
@@ -63,8 +66,8 @@ exports = {
|
||||
},
|
||||
|
||||
"test: events": function () {
|
||||
var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", new JavaScriptMode());
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
|
||||
var p = new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]);
|
||||
var entered = false;
|
||||
@@ -86,9 +89,9 @@ exports = {
|
||||
},
|
||||
|
||||
"test: cancel": function (next) {
|
||||
var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", new JavaScriptMode());
|
||||
var session = new AceAjax.EditSession("var a = 10;\nconsole.log(a, a);", mode);
|
||||
session.setUndoManager(new AceAjax.UndoManager());
|
||||
var editor = new AceAjax.Editor(new MockRenderer(), session);
|
||||
var editor = new AceAjax.Editor(renderer, session);
|
||||
var p = new AceAjax.PlaceHolder(session, 1, { row: 0, column: 4 }, [{ row: 1, column: 12 }, { row: 1, column: 15 }]);
|
||||
|
||||
editor.moveCursorTo(0, 5);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference path="../ace.d.ts" />
|
||||
|
||||
exports = {
|
||||
var assert: any;
|
||||
var exports = {
|
||||
|
||||
name: "ACE range.js",
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/// <reference path="../ace.d.ts" />
|
||||
|
||||
var assert: any;
|
||||
function flatten(rangeList) {
|
||||
var points = [];
|
||||
rangeList.ranges.forEach(function (r) {
|
||||
@@ -11,7 +12,7 @@ function testRangeList(rangeList, points) {
|
||||
assert.equal("" + flatten(rangeList), "" + points);
|
||||
}
|
||||
|
||||
exports = {
|
||||
var exports = {
|
||||
|
||||
name: "ACE range_list.js",
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference path="../ace.d.ts" />
|
||||
|
||||
exports = {
|
||||
var assert: any;
|
||||
var exports = {
|
||||
"test: configure the search object": function () {
|
||||
var search = new AceAjax.Search();
|
||||
search.set({
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference path="../ace.d.ts" />
|
||||
|
||||
exports = {
|
||||
var assert: any;
|
||||
var exports = {
|
||||
createSession: function (rows, cols) {
|
||||
var line = new Array(cols + 1).join("a");
|
||||
var text = new Array(rows).join(line + "\n") + line;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
/// <reference path="../ace.d.ts" />
|
||||
|
||||
exports = {
|
||||
var assert: any;
|
||||
var mode: any;
|
||||
var exports = {
|
||||
"test: token iterator initialization in JavaScript document": function () {
|
||||
var lines = [
|
||||
"function foo(items) {",
|
||||
@@ -9,7 +11,7 @@ exports = {
|
||||
" } // Real Tab.",
|
||||
"}"
|
||||
];
|
||||
var session = new AceAjax.EditSession(lines.join("\n"), new JavaScriptMode());
|
||||
var session = new AceAjax.EditSession(lines.join("\n"),mode);
|
||||
|
||||
var iterator = new AceAjax.TokenIterator(session, 0, 0);
|
||||
assert.equal(iterator.getCurrentToken().value, "function");
|
||||
@@ -96,7 +98,7 @@ exports = {
|
||||
" } // Real Tab.",
|
||||
"}"
|
||||
];
|
||||
var session = new AceAjax.EditSession(lines.join("\n"), new JavaScriptMode());
|
||||
var session = new AceAjax.EditSession(lines.join("\n"),mode);
|
||||
|
||||
var tokens = [];
|
||||
var len = session.getLength();
|
||||
@@ -118,7 +120,7 @@ exports = {
|
||||
" } // Real Tab.",
|
||||
"}"
|
||||
];
|
||||
var session = new AceAjax.EditSession(lines.join("\n"), new JavaScriptMode());
|
||||
var session = new AceAjax.EditSession(lines.join("\n"),mode);
|
||||
|
||||
var tokens = [];
|
||||
var len = session.getLength();
|
||||
@@ -140,7 +142,7 @@ exports = {
|
||||
" } // Real Tab.",
|
||||
"}"
|
||||
];
|
||||
var session = new AceAjax.EditSession(lines.join("\n"), new JavaScriptMode());
|
||||
var session = new AceAjax.EditSession(lines.join("\n"),mode);
|
||||
|
||||
var iterator = new AceAjax.TokenIterator(session, 0, 0);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference path="../ace.d.ts" />
|
||||
|
||||
exports = {
|
||||
var assert: any;
|
||||
var exports = {
|
||||
"test: screen2text the column should be rounded to the next character edge": function () {
|
||||
var el = document.createElement("div");
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ module HttpAndRegularPromiseTests {
|
||||
// Test for AngularJS Syntac
|
||||
|
||||
module My.Namespace {
|
||||
|
||||
export var x; // need to export something for module to kick in
|
||||
}
|
||||
|
||||
// IModule Registering Test
|
||||
@@ -150,7 +150,7 @@ var mod = angular.module('tests',[]);
|
||||
mod.controller('name', function($scope : ng.IScope) {})
|
||||
mod.controller('name', ['$scope', <any>function($scope : ng.IScope) {}])
|
||||
mod.controller(My.Namespace);
|
||||
mod.directive('name', function($scope : ng.IScope) {})
|
||||
mod.directive('name', <any>function ($scope: ng.IScope) {})
|
||||
mod.directive('name', ['$scope', <any>function($scope : ng.IScope) {}])
|
||||
mod.directive(My.Namespace);
|
||||
mod.factory('name', function($scope : ng.IScope) {})
|
||||
|
||||
Vendored
+1
-1
@@ -173,7 +173,7 @@ declare module ng {
|
||||
// see http://docs.angularjs.org/api/ng.$rootScope.Scope
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IScope {
|
||||
// Documentation says exp is optional, but actual implementaton counts on it
|
||||
$apply(): any;
|
||||
$apply(exp: string): any;
|
||||
$apply(exp: (scope: IScope) => any): any;
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ async.series([
|
||||
function () { }
|
||||
]);
|
||||
|
||||
var data;
|
||||
function asyncProcess() { }
|
||||
var data = [];
|
||||
function asyncProcess(item, callback) { }
|
||||
async.map(data, asyncProcess, function (err, results) {
|
||||
alert(results);
|
||||
console.log(results);
|
||||
});
|
||||
|
||||
var openFiles = ['file1', 'file2'];
|
||||
|
||||
Vendored
+53
-49
@@ -1,67 +1,71 @@
|
||||
// Type definitions for Async 0.1
|
||||
// Type definitions for Async 0.1.23
|
||||
// Project: https://github.com/caolan/async
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface AsyncMultipleResultsCallback<T> { (err: string, results: T[]): any; }
|
||||
interface AsyncSingleResultCallback<T> { (err: string, result: T): any; }
|
||||
interface AsyncTimesCallback<T> { (n: number, callback: AsyncMultipleResultsCallback<T>): void; }
|
||||
interface AsyncIterator<T> { (item: T, callback: AsyncMultipleResultsCallback<T>): void; }
|
||||
interface AsyncMemoIterator<T> { (memo: T, item: T, callback: AsyncSingleResultCallback<T>): void; }
|
||||
interface AsyncWorker<T> { (task: T, callback: Function): void; }
|
||||
|
||||
interface AsyncCallback { (err: string, results: any): any; }
|
||||
interface AsyncIterator { (item, callback: AsyncCallback): void; }
|
||||
interface AsyncMemoIterator { (memo: any, item: any, callback: AsyncCallback): void; }
|
||||
interface AsyncWorker { (task: any, callback: Function): void; }
|
||||
|
||||
interface AsyncQueue {
|
||||
interface AsyncQueue<T> {
|
||||
length(): number;
|
||||
concurrency: number;
|
||||
push(task: any, callback: AsyncCallback): void;
|
||||
saturated: AsyncCallback;
|
||||
empty: AsyncCallback;
|
||||
drain: AsyncCallback;
|
||||
push(task: T, callback: AsyncMultipleResultsCallback<T>): void;
|
||||
saturated: AsyncMultipleResultsCallback<T>;
|
||||
empty: AsyncMultipleResultsCallback<T>;
|
||||
drain: AsyncMultipleResultsCallback<T>;
|
||||
}
|
||||
|
||||
interface Async {
|
||||
|
||||
// Collections
|
||||
forEach(arr: any[], iterator: AsyncIterator, callback: AsyncCallback): void;
|
||||
forEachSeries(arr: any[], iterator: AsyncIterator, callback: AsyncCallback): void;
|
||||
forEachLimit(arr: any[], limit: number, iterator: AsyncIterator, callback: AsyncCallback): void;
|
||||
map(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
|
||||
mapSeries(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
|
||||
filter(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
|
||||
select(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
|
||||
filterSeries(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
|
||||
selectSeries(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
|
||||
reject(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
|
||||
rejectSeries(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
|
||||
reduce(arr: any[], memo: any, iterator: AsyncMemoIterator, callback: AsyncCallback);
|
||||
inject(arr: any[], memo: any, iterator: AsyncMemoIterator, callback: AsyncCallback);
|
||||
foldl(arr: any[], memo: any, iterator: AsyncMemoIterator, callback: AsyncCallback);
|
||||
reduceRight(arr: any[], memo: any, iterator: AsyncMemoIterator, callback: AsyncCallback);
|
||||
foldr(arr: any[], memo: any, iterator: AsyncMemoIterator, callback: AsyncCallback);
|
||||
detect(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
|
||||
detectSeries(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
|
||||
sortBy(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
|
||||
some(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
|
||||
any(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
|
||||
every(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
|
||||
all(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
|
||||
concat(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
|
||||
concatSeries(arr: any[], iterator: AsyncIterator, callback: AsyncCallback);
|
||||
forEach<T>(arr: T[], iterator: AsyncIterator<T>, callback: AsyncMultipleResultsCallback<T>): void;
|
||||
forEachSeries<T>(arr: T[], iterator: AsyncIterator<T>, callback: AsyncMultipleResultsCallback<T>): void;
|
||||
forEachLimit<T>(arr: T[], limit: number, iterator: AsyncIterator<T>, callback: AsyncMultipleResultsCallback<T>): void;
|
||||
map<T>(arr: T[], iterator: AsyncIterator<T>, callback: AsyncMultipleResultsCallback<T>);
|
||||
mapSeries<T>(arr: T[], iterator: AsyncIterator<T>, callback: AsyncMultipleResultsCallback<T>);
|
||||
filter<T>(arr: T[], iterator: AsyncIterator<T>, callback: AsyncMultipleResultsCallback<T>);
|
||||
select<T>(arr: T[], iterator: AsyncIterator<T>, callback: AsyncMultipleResultsCallback<T>);
|
||||
filterSeries<T>(arr: T[], iterator: AsyncIterator<T>, callback: AsyncMultipleResultsCallback<T>);
|
||||
selectSeries<T>(arr: T[], iterator: AsyncIterator<T>, callback: AsyncMultipleResultsCallback<T>);
|
||||
reject<T>(arr: T[], iterator: AsyncIterator<T>, callback: AsyncMultipleResultsCallback<T>);
|
||||
rejectSeries<T>(arr: T[], iterator: AsyncIterator<T>, callback: AsyncMultipleResultsCallback<T>);
|
||||
reduce<T>(arr: T[], memo: T, iterator: AsyncMemoIterator<T>, callback: AsyncSingleResultCallback<T>);
|
||||
inject<T>(arr: T[], memo: T, iterator: AsyncMemoIterator<T>, callback: AsyncSingleResultCallback<T>);
|
||||
foldl<T>(arr: T[], memo: T, iterator: AsyncMemoIterator<T>, callback: AsyncSingleResultCallback<T>);
|
||||
reduceRight<T>(arr: T[], memo: T, iterator: AsyncMemoIterator<T>, callback: AsyncSingleResultCallback<T>);
|
||||
foldr<T, U>(arr: T[], memo: T, iterator: AsyncMemoIterator<T>, callback: AsyncSingleResultCallback<T>);
|
||||
detect<T>(arr: T[], iterator: AsyncIterator<T>, callback: AsyncMultipleResultsCallback<T>);
|
||||
detectSeries<T>(arr: T[], iterator: AsyncIterator<T>, callback: AsyncMultipleResultsCallback<T>);
|
||||
sortBy<T>(arr: T[], iterator: AsyncIterator<T>, callback: AsyncMultipleResultsCallback<T>);
|
||||
some<T>(arr: T[], iterator: AsyncIterator<T>, callback: AsyncMultipleResultsCallback<T>);
|
||||
any<T>(arr: T[], iterator: AsyncIterator<T>, callback: AsyncMultipleResultsCallback<T>);
|
||||
every<T>(arr: T[], iterator: AsyncIterator<T>, callback: (result: boolean) => any);
|
||||
all<T>(arr: T[], iterator: AsyncIterator<T>, callback: (result: boolean) => any);
|
||||
concat<T>(arr: T[], iterator: AsyncIterator<T>, callback: AsyncMultipleResultsCallback<T>);
|
||||
concatSeries<T>(arr: T[], iterator: AsyncIterator<T>, callback: AsyncMultipleResultsCallback<T>);
|
||||
|
||||
// Control Flow
|
||||
series(tasks: any[], callback?: AsyncCallback): void;
|
||||
series(tasks: any, callback?: AsyncCallback): void;
|
||||
parallel(tasks: any[], callback?: AsyncCallback): void;
|
||||
parallel(tasks: any, callback?: AsyncCallback): void;
|
||||
whilst(test: Function, fn: Function, callback: AsyncCallback): void;
|
||||
until(test: Function, fn: Function, callback: AsyncCallback): void;
|
||||
waterfall(tasks: any[], callback?: AsyncCallback): void;
|
||||
waterfall(tasks: any, callback?: AsyncCallback): void;
|
||||
queue(worker: AsyncWorker, concurrency: number): AsyncQueue;
|
||||
//auto(tasks: any[], callback?: AsyncCallback): void;
|
||||
auto(tasks: any, callback?: AsyncCallback): void;
|
||||
iterator(tasks): Function;
|
||||
series<T>(tasks: T[], callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
series<T>(tasks: T, callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
parallel<T>(tasks: T[], callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
parallel<T>(tasks: T, callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
whilst(test: Function, fn: Function, callback: Function): void;
|
||||
until(test: Function, fn: Function, callback: Function): void;
|
||||
waterfall<T>(tasks: T[], callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
waterfall<T>(tasks: T, callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
queue<T>(worker: AsyncWorker<T>, concurrency: number): AsyncQueue<T>;
|
||||
// auto(tasks: any[], callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
auto(tasks: any, callback?: AsyncMultipleResultsCallback<any>): void;
|
||||
iterator(tasks: Function[]): Function;
|
||||
apply(fn: Function, ...arguments: any[]): void;
|
||||
nextTick(callback: AsyncCallback): void;
|
||||
nextTick<T>(callback: Function): void;
|
||||
|
||||
times<T> (n: number, callback: AsyncTimesCallback<T>): void;
|
||||
timesSeries<T> (n: number, callback: AsyncTimesCallback<T>): void;
|
||||
|
||||
// Utils
|
||||
memoize(fn: Function, hasher?: Function): Function;
|
||||
|
||||
@@ -32,8 +32,8 @@ tableTodoItems.read()
|
||||
|
||||
|
||||
//define simple handler used in callback calls for insert/update and delete
|
||||
function handlerInsUpd(e, i) => { if (!e) data.push(<TodoItem> i); };
|
||||
function handlerDelErr(e) => { if (e) alert("ERROR: " + e); }
|
||||
function handlerInsUpd(e, i) { if (!e) data.push(<TodoItem> i); };
|
||||
function handlerDelErr(e) { if (e) alert("ERROR: " + e); }
|
||||
|
||||
|
||||
//insert one data passing info in POST + custom data in QueryString + simple callback handler
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Morosinotto Daniele <https://github.com/dmorosinotto/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
module Microsoft.WindowsAzure {
|
||||
declare module Microsoft.WindowsAzure {
|
||||
|
||||
// MobileServiceClient object based on Microsoft Azure documentation: http://msdn.microsoft.com/en-us/library/windowsazure/jj554219.aspx
|
||||
interface MobileServiceClient {
|
||||
|
||||
Vendored
+60
-53
@@ -1,6 +1,7 @@
|
||||
// Type definitions for Backbone 0.9.10
|
||||
// Type definitions for Backbone 1.0.0
|
||||
// Project: http://backbonejs.org/
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
|
||||
// Definitions by: Natan Vivo <https://github.com/nvivo/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
@@ -8,61 +9,61 @@
|
||||
|
||||
declare module Backbone {
|
||||
|
||||
export interface AddOptions extends Silenceable {
|
||||
interface AddOptions extends Silenceable {
|
||||
at: number;
|
||||
}
|
||||
|
||||
export interface HistoryOptions extends Silenceable {
|
||||
pushState?: bool;
|
||||
interface HistoryOptions extends Silenceable {
|
||||
pushState?: boolean;
|
||||
root?: string;
|
||||
}
|
||||
|
||||
export interface NavigateOptions {
|
||||
trigger: bool;
|
||||
interface NavigateOptions {
|
||||
trigger: boolean;
|
||||
}
|
||||
|
||||
export interface RouterOptions {
|
||||
interface RouterOptions {
|
||||
routes: any;
|
||||
}
|
||||
|
||||
export interface Silenceable {
|
||||
silent?: bool;
|
||||
interface Silenceable {
|
||||
silent?: boolean;
|
||||
}
|
||||
|
||||
interface Validable {
|
||||
validate?: bool;
|
||||
validate?: boolean;
|
||||
}
|
||||
|
||||
interface Waitable {
|
||||
wait?: bool;
|
||||
wait?: boolean;
|
||||
}
|
||||
|
||||
interface Parseable {
|
||||
parse?: any;
|
||||
}
|
||||
|
||||
export interface PersistenceOptions {
|
||||
interface PersistenceOptions {
|
||||
url?: string;
|
||||
beforeSend?: (jqxhr: JQueryXHR) => void;
|
||||
success?: (modelOrCollection?: any, response?: any, options?: any) => void;
|
||||
error?: (modelOrCollection?: any, jqxhr?: JQueryXHR, options?: any) => void;
|
||||
}
|
||||
|
||||
export interface ModelSetOptions extends Silenceable extends Validable {
|
||||
interface ModelSetOptions extends Silenceable, Validable {
|
||||
}
|
||||
|
||||
export interface ModelFetchOptions extends PersistenceOptions extends ModelSetOptions extends Parseable {
|
||||
interface ModelFetchOptions extends PersistenceOptions, ModelSetOptions, Parseable {
|
||||
}
|
||||
|
||||
export interface ModelSaveOptions extends Silenceable extends Waitable extends Validable extends Parseable extends PersistenceOptions {
|
||||
patch?: bool;
|
||||
interface ModelSaveOptions extends Silenceable, Waitable, Validable, Parseable, PersistenceOptions {
|
||||
patch?: boolean;
|
||||
}
|
||||
|
||||
export interface ModelDestroyOptions extends Waitable extends PersistenceOptions {
|
||||
interface ModelDestroyOptions extends Waitable, PersistenceOptions {
|
||||
}
|
||||
|
||||
export interface CollectionFetchOptions extends PersistenceOptions extends Parseable {
|
||||
reset?: bool;
|
||||
interface CollectionFetchOptions extends PersistenceOptions, Parseable {
|
||||
reset?: boolean;
|
||||
}
|
||||
|
||||
interface on { (eventName: string, callback: (...args: any[]) => void, context?: any): any; }
|
||||
@@ -71,7 +72,7 @@ declare module Backbone {
|
||||
interface bind { (eventName: string, callback: (...args: any[]) => void, context?: any): any; }
|
||||
interface unbind { (eventName?: string, callback?: (...args: any[]) => void, context?: any): any; }
|
||||
|
||||
declare class Events {
|
||||
class Events {
|
||||
on(eventName: string, callback: (...args:any[]) => void, context?: any): any;
|
||||
off(eventName?: string, callback?: (...args:any[]) => void, context?: any): any;
|
||||
trigger(eventName: string, ...args: any[]): any;
|
||||
@@ -84,7 +85,7 @@ declare module Backbone {
|
||||
stopListening(object?: any, events?: string, callback?: (...args: any[]) => void ): any;
|
||||
}
|
||||
|
||||
export class ModelBase extends Events {
|
||||
class ModelBase extends Events {
|
||||
url: any;
|
||||
parse(response, options?: any);
|
||||
toJSON(options?: any): any;
|
||||
@@ -92,7 +93,7 @@ declare module Backbone {
|
||||
}
|
||||
|
||||
|
||||
export class Model extends ModelBase {
|
||||
class Model extends ModelBase {
|
||||
|
||||
static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality
|
||||
|
||||
@@ -120,10 +121,10 @@ declare module Backbone {
|
||||
defaults(): any;
|
||||
destroy(options?: ModelDestroyOptions);
|
||||
escape(attribute: string);
|
||||
has(attribute: string): bool;
|
||||
hasChanged(attribute?: string): bool;
|
||||
isNew(): bool;
|
||||
isValid(): bool;
|
||||
has(attribute: string): boolean;
|
||||
hasChanged(attribute?: string): boolean;
|
||||
isNew(): boolean;
|
||||
isValid(): boolean;
|
||||
previous(attribute: string): any;
|
||||
previousAttributes(): any[];
|
||||
save(attributes?: any, options?: ModelSaveOptions);
|
||||
@@ -131,7 +132,7 @@ declare module Backbone {
|
||||
validate(attributes: any, options?: any): any;
|
||||
}
|
||||
|
||||
export class Collection extends ModelBase {
|
||||
class Collection extends ModelBase {
|
||||
|
||||
static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality
|
||||
|
||||
@@ -164,34 +165,34 @@ declare module Backbone {
|
||||
unshift(model: Model, options?: AddOptions);
|
||||
where(properies: any): Model[];
|
||||
|
||||
all(iterator: (element: Model, index: number) => bool, context?: any): bool;
|
||||
any(iterator: (element: Model, index: number) => bool, context?: any): bool;
|
||||
all(iterator: (element: Model, index: number) => boolean, context?: any): boolean;
|
||||
any(iterator: (element: Model, index: number) => boolean, context?: any): boolean;
|
||||
collect(iterator: (element: Model, index: number, context?: any) => any[], context?: any): any[];
|
||||
chain(): any;
|
||||
compact(): Model[];
|
||||
contains(value: any): bool;
|
||||
contains(value: any): boolean;
|
||||
countBy(iterator: (element: Model, index: number) => any): any[];
|
||||
countBy(attribute: string): any[];
|
||||
detect(iterator: (item: any) => bool, context?: any): any; // ???
|
||||
detect(iterator: (item: any) => boolean, context?: any): any; // ???
|
||||
difference(...model: Model[]): Model[];
|
||||
drop(): Model;
|
||||
drop(n: number): Model[];
|
||||
each(iterator: (element: Model, index: number, list?: any) => void, context?: any);
|
||||
every(iterator: (element: Model, index: number) => bool, context?: any): bool;
|
||||
filter(iterator: (element: Model, index: number) => bool, context?: any): Model[];
|
||||
find(iterator: (element: Model, index: number) => bool, context?: any): Model;
|
||||
every(iterator: (element: Model, index: number) => boolean, context?: any): boolean;
|
||||
filter(iterator: (element: Model, index: number) => boolean, context?: any): Model[];
|
||||
find(iterator: (element: Model, index: number) => boolean, context?: any): Model;
|
||||
first(): Model;
|
||||
first(n: number): Model[];
|
||||
flatten(shallow?: bool): Model[];
|
||||
flatten(shallow?: boolean): Model[];
|
||||
foldl(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any;
|
||||
forEach(iterator: (element: Model, index: number, list?: any) => void, context?: any);
|
||||
include(value: any): bool;
|
||||
indexOf(element: Model, isSorted?: bool): number;
|
||||
include(value: any): boolean;
|
||||
indexOf(element: Model, isSorted?: boolean): number;
|
||||
initial(): Model;
|
||||
initial(n: number): Model[];
|
||||
inject(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any;
|
||||
intersection(...model: Model[]): Model[];
|
||||
isEmpty(object: any): bool;
|
||||
isEmpty(object: any): boolean;
|
||||
invoke(methodName: string, arguments?: any[]);
|
||||
last(): Model;
|
||||
last(n: number): Model[];
|
||||
@@ -204,26 +205,26 @@ declare module Backbone {
|
||||
select(iterator: any, context?: any): any[];
|
||||
size(): number;
|
||||
shuffle(): any[];
|
||||
some(iterator: (element: Model, index: number) => bool, context?: any): bool;
|
||||
some(iterator: (element: Model, index: number) => boolean, context?: any): boolean;
|
||||
sortBy(iterator: (element: Model, index: number) => number, context?: any): Model[];
|
||||
sortBy(attribute: string, context?: any): Model[];
|
||||
sortedIndex(element: Model, iterator?: (element: Model, index: number) => number): number;
|
||||
range(stop: number, step?: number);
|
||||
range(start: number, stop: number, step?: number);
|
||||
reduceRight(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any[];
|
||||
reject(iterator: (element: Model, index: number) => bool, context?: any): Model[];
|
||||
reject(iterator: (element: Model, index: number) => boolean, context?: any): Model[];
|
||||
rest(): Model;
|
||||
rest(n: number): Model[];
|
||||
tail(): Model;
|
||||
tail(n: number): Model[];
|
||||
toArray(): any[];
|
||||
union(...model: Model[]): Model[];
|
||||
uniq(isSorted?: bool, iterator?: (element: Model, index: number) => bool): Model[];
|
||||
uniq(isSorted?: boolean, iterator?: (element: Model, index: number) => boolean): Model[];
|
||||
without(...values: any[]): Model[];
|
||||
zip(...model: Model[]): Model[];
|
||||
}
|
||||
|
||||
export class Router extends Events {
|
||||
class Router extends Events {
|
||||
|
||||
static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality
|
||||
|
||||
@@ -233,20 +234,20 @@ declare module Backbone {
|
||||
initialize (options?: RouterOptions);
|
||||
route(route: string, name: string, callback?: (...parameter: any[]) => void);
|
||||
navigate(fragment: string, options?: NavigateOptions);
|
||||
navigate(fragment: string, trigger?: bool);
|
||||
navigate(fragment: string, trigger?: boolean);
|
||||
}
|
||||
|
||||
export var history: History;
|
||||
export class History {
|
||||
var history: History;
|
||||
class History {
|
||||
start(options?: HistoryOptions);
|
||||
navigate(fragment: string, options: any);
|
||||
pushSate();
|
||||
getFragment(fragment?: string, forcePushState?: bool): string;
|
||||
getFragment(fragment?: string, forcePushState?: boolean): string;
|
||||
getHash(window?: Window): string;
|
||||
started: bool;
|
||||
started: boolean;
|
||||
}
|
||||
|
||||
export interface ViewOptions {
|
||||
interface ViewOptions {
|
||||
model?: Backbone.Model;
|
||||
collection?: Backbone.Collection;
|
||||
el?: any;
|
||||
@@ -256,7 +257,7 @@ declare module Backbone {
|
||||
attributes?: any[];
|
||||
}
|
||||
|
||||
export class View extends Events {
|
||||
class View extends Events {
|
||||
|
||||
static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality
|
||||
|
||||
@@ -267,7 +268,7 @@ declare module Backbone {
|
||||
collection: Collection;
|
||||
template: (data?: any) => string;
|
||||
make(tagName: string, attrs?, opts?): View;
|
||||
setElement(element: HTMLElement, delegate?: bool);
|
||||
setElement(element: HTMLElement, delegate?: boolean);
|
||||
id: string;
|
||||
className: string;
|
||||
tagName: string;
|
||||
@@ -288,10 +289,16 @@ declare module Backbone {
|
||||
|
||||
// SYNC
|
||||
function sync(method, model, options?: JQueryAjaxSettings);
|
||||
var emulateHTTP: bool;
|
||||
var emulateJSONBackbone: bool;
|
||||
var emulateHTTP: boolean;
|
||||
var emulateJSONBackbone: boolean;
|
||||
|
||||
// Utility
|
||||
function noConflict(): Backbone;
|
||||
|
||||
// 0.9 cannot return modules anymore, and "typeof <Module>" is not compiling for some reason
|
||||
// returning "any" until this is fixed
|
||||
|
||||
//function noConflict(): typeof Backbone;
|
||||
function noConflict(): any;
|
||||
|
||||
function setDomLibrary(jQueryNew);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="../chai/chai.d.ts" />
|
||||
/// <reference path="chai-jquery.d.ts" />
|
||||
/// <reference path="../chai/chai.d.ts" />
|
||||
/// <reference path="chai-jquery.d.ts" />
|
||||
|
||||
declare var $;
|
||||
var expect = chai.expect;
|
||||
|
||||
@@ -330,7 +330,7 @@ suite('assert', function () {
|
||||
|
||||
test('isArray', function () {
|
||||
assert.isArray([]);
|
||||
assert.isArray(new Array);
|
||||
assert.isArray(new Array<any>());
|
||||
|
||||
err(function () {
|
||||
assert.isArray({});
|
||||
@@ -345,7 +345,7 @@ suite('assert', function () {
|
||||
}, "expected [] not to be an array");
|
||||
|
||||
err(function () {
|
||||
assert.isNotArray(new Array);
|
||||
assert.isNotArray(new Array<any>());
|
||||
}, "expected [] not to be an array");
|
||||
});
|
||||
|
||||
Vendored
+1
-1
@@ -107,7 +107,7 @@ declare module chai
|
||||
ifError(val:any, msg?:string);
|
||||
}
|
||||
//node module
|
||||
declare var assert:Assert;
|
||||
var assert:Assert;
|
||||
}
|
||||
//browser global
|
||||
declare var assert:chai.Assert;
|
||||
Vendored
+5
-6
@@ -33,9 +33,9 @@ declare module chai {
|
||||
(expected: RegExp, message?: string);
|
||||
}
|
||||
|
||||
interface TypeComparison {
|
||||
interface TypeComparison {
|
||||
(type: string, message?: string): bool;
|
||||
instanceof(type: Object, ): bool;
|
||||
instanceof(type: Object): bool;
|
||||
}
|
||||
|
||||
interface NumericComparison {
|
||||
@@ -116,7 +116,6 @@ declare module chai {
|
||||
to: To;
|
||||
}
|
||||
|
||||
var expect : {
|
||||
(target: any): ExpectMatchers;
|
||||
}
|
||||
}
|
||||
function expect(target: any): chai.ExpectMatchers;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,65 +1,65 @@
|
||||
/// <reference path="cheerio.d.ts" />
|
||||
|
||||
import cheerio = module("cheerio");
|
||||
|
||||
var $ = cheerio.load("<html></html>");
|
||||
var $el = $('selector');
|
||||
var $multiEl = $('seletor', 'selector', 'selector');
|
||||
|
||||
$el.addClass("class").addClass("test");
|
||||
$el.hasClass("test");
|
||||
$el.removeClass("class").removeClass("test");
|
||||
|
||||
$el.attr('class');
|
||||
$el.attr('class', 'test');
|
||||
$el.removeAttr("class").removeAttr("test");
|
||||
|
||||
$el.find("ul").find("> li");
|
||||
|
||||
$el.parent().parent();
|
||||
$el.next().next();
|
||||
$el.prev().prev();
|
||||
$el.siblings().siblings();
|
||||
|
||||
$el.children().children();
|
||||
$el.children("li").children("a");
|
||||
|
||||
$el.children().each((index, element) => {
|
||||
$(element).find('t');
|
||||
});
|
||||
|
||||
$el.children().map((index, element) => {
|
||||
return $(element).find('t');
|
||||
});
|
||||
|
||||
$el.children().filter((index) => {
|
||||
return $el.children().eq(index).find('t');
|
||||
});
|
||||
|
||||
$el.filter('span').filter('li');
|
||||
|
||||
$el.first().last().find('t');
|
||||
|
||||
$('div').eq(0).find('b');
|
||||
|
||||
$('#id').append("test html", "other html").find('a');
|
||||
$('#id').prepend("test html", "other html").find('a');
|
||||
$('#id').after("test html", "other html").find('a');
|
||||
$('#id').before("test html", "other html").find('a');
|
||||
|
||||
$el.remove('div').remove('a');
|
||||
|
||||
$('#id').replaceWith('some html').parent();
|
||||
$('#id').empty().parent();
|
||||
|
||||
$el.html();
|
||||
$el.html("<html></html>").find('div');
|
||||
|
||||
$el.text();
|
||||
$el.text('some text');
|
||||
|
||||
$el.toArray();
|
||||
$el.clone().find('a').parent();
|
||||
$el.root().find('a');
|
||||
|
||||
$el.dom();
|
||||
/// <reference path="cheerio.d.ts" />
|
||||
|
||||
import cheerio = module("cheerio");
|
||||
|
||||
var $ = cheerio.load("<html></html>");
|
||||
var $el = $('selector');
|
||||
var $multiEl = $('seletor', 'selector', 'selector');
|
||||
|
||||
$el.addClass("class").addClass("test");
|
||||
$el.hasClass("test");
|
||||
$el.removeClass("class").removeClass("test");
|
||||
|
||||
$el.attr('class');
|
||||
$el.attr('class', 'test');
|
||||
$el.removeAttr("class").removeAttr("test");
|
||||
|
||||
$el.find("ul").find("> li");
|
||||
|
||||
$el.parent().parent();
|
||||
$el.next().next();
|
||||
$el.prev().prev();
|
||||
$el.siblings().siblings();
|
||||
|
||||
$el.children().children();
|
||||
$el.children("li").children("a");
|
||||
|
||||
$el.children().each((index, element) => {
|
||||
return $(element).find('t');
|
||||
});
|
||||
|
||||
$el.children().map((index, element) => {
|
||||
return $(element).find('t');
|
||||
});
|
||||
|
||||
$el.children().filter((index) => {
|
||||
return $el.children().eq(index).find('t');
|
||||
});
|
||||
|
||||
$el.filter('span').filter('li');
|
||||
|
||||
$el.first().last().find('t');
|
||||
|
||||
$('div').eq(0).find('b');
|
||||
|
||||
$('#id').append("test html", "other html").find('a');
|
||||
$('#id').prepend("test html", "other html").find('a');
|
||||
$('#id').after("test html", "other html").find('a');
|
||||
$('#id').before("test html", "other html").find('a');
|
||||
|
||||
$el.remove('div').remove('a');
|
||||
|
||||
$('#id').replaceWith('some html').parent();
|
||||
$('#id').empty().parent();
|
||||
|
||||
$el.html();
|
||||
$el.html("<html></html>").find('div');
|
||||
|
||||
$el.text();
|
||||
$el.text('some text');
|
||||
|
||||
$el.toArray();
|
||||
$el.clone().find('a').parent();
|
||||
$el.root().find('a');
|
||||
|
||||
$el.dom();
|
||||
Vendored
+3
-3
@@ -4,7 +4,7 @@
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
declare interface Cheerio {
|
||||
interface Cheerio {
|
||||
|
||||
addClass(classNames: string): Cheerio;
|
||||
hasClass(className: string): bool;
|
||||
@@ -65,13 +65,13 @@ declare interface Cheerio {
|
||||
|
||||
}
|
||||
|
||||
declare interface CheerioOptionsInterface {
|
||||
interface CheerioOptionsInterface {
|
||||
ignoreWhitespace?: bool;
|
||||
xmlMode?: bool;
|
||||
lowerCaseTags?: bool;
|
||||
}
|
||||
|
||||
declare interface CheerioStatic {
|
||||
interface CheerioStatic {
|
||||
(...selectors: any[]): Cheerio;
|
||||
(): Cheerio;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare interface String {
|
||||
interface String {
|
||||
bold:string;
|
||||
italic:string;
|
||||
underline:string;
|
||||
|
||||
+1336
-8
File diff suppressed because it is too large
Load Diff
Vendored
+2446
-990
File diff suppressed because it is too large
Load Diff
Vendored
+21
-21
@@ -18,11 +18,11 @@ declare module "durandal/system" {
|
||||
/**
|
||||
* Call this function to enable or disable Durandal's debug mode. Calling it with no parameters will return true if the framework is currently in debug mode, false otherwise.
|
||||
*/
|
||||
export var debug: (debug?: bool) => bool;
|
||||
export var debug: (debug?: boolean) => boolean;
|
||||
/**
|
||||
* Checks if the obj is an array
|
||||
*/
|
||||
export var isArray: (obj: any) => bool;
|
||||
export var isArray: (obj: any) => boolean;
|
||||
/**
|
||||
* Logs data to the console. Pass any number of parameters to be logged. Log output is not processed if the framework is not running in debug mode.
|
||||
*/
|
||||
@@ -91,7 +91,7 @@ declare module "durandal/composition" {
|
||||
/**
|
||||
* sets activate: true on every compose binding
|
||||
*/
|
||||
export var activateDuringComposition: bool;
|
||||
export var activateDuringComposition: boolean;
|
||||
/**
|
||||
* changes the convention for finding where transitions are located
|
||||
*/
|
||||
@@ -161,7 +161,7 @@ declare module "durandal/modalDialog" {
|
||||
/**
|
||||
* This is a helper function which will tell you if any modals are currently open.
|
||||
*/
|
||||
export var isModalOpen: () => bool;
|
||||
export var isModalOpen: () => boolean;
|
||||
/**
|
||||
* You may wish to customize modal displays or add additional contexts in order to display modals in different ways. To alter the default context, you would acquire it by calling getContext() and then alter it's pipeline. If you don't provide a value for name it returns the default context.
|
||||
*/
|
||||
@@ -192,7 +192,7 @@ declare module "durandal/viewEngine" {
|
||||
/**
|
||||
* Returns true if the potential string is a url for a view, according to the view engine.
|
||||
*/
|
||||
export var isViewUrl: (url: string) => bool;
|
||||
export var isViewUrl: (url: string) => boolean;
|
||||
/**
|
||||
* Converts a view url into a view id.
|
||||
*/
|
||||
@@ -267,15 +267,15 @@ interface IViewModelDefaults {
|
||||
/**
|
||||
* When the activator attempts to activate an item as described below, it will only activate the new item, by default, if it is a different instance than the current. Overwrite this function to change that behavior.
|
||||
*/
|
||||
areSameItem(currentItem, newItem, activationData): bool;
|
||||
areSameItem(currentItem, newItem, activationData): boolean;
|
||||
/**
|
||||
* default is true
|
||||
*/
|
||||
closeOnDeactivate: bool;
|
||||
closeOnDeactivate: boolean;
|
||||
/**
|
||||
* Interprets values returned from guard methods like canActivate and canDeactivate by transforming them into bools. The default implementation translates string values "Yes" and "Ok" as true...and all other string values as false. Non string values evaluate according to the truthy/falsey values of JavaScript. Replace this function with your own to expand or set up different values. This transformation is used by the activator internally and allows it to work smoothly in the common scenario where a deactivated item needs to show a message box to prompt the user before closing. Since the message box returns a promise that resolves to the button option the user selected, it can be automatically processed as part of the activator's guard check.
|
||||
*/
|
||||
interpretResponse(value: any): bool;
|
||||
interpretResponse(value: any): boolean;
|
||||
/**
|
||||
* called before activating a module
|
||||
*/
|
||||
@@ -284,7 +284,7 @@ interface IViewModelDefaults {
|
||||
* called after deactivating a module
|
||||
*/
|
||||
afterDeactivate(): any;
|
||||
};
|
||||
}
|
||||
|
||||
interface IDurandalViewModelActiveItem {
|
||||
/**
|
||||
@@ -298,7 +298,7 @@ interface IDurandalViewModelActiveItem {
|
||||
/**
|
||||
* This observable is set internally by the activator during the activation process. It can be used to determine if an activation is currently happening.
|
||||
*/
|
||||
isActivating(val?: bool): bool;
|
||||
isActivating(val?: boolean): boolean;
|
||||
/**
|
||||
* Pass a specific item as well as an indication of whether it should be closed, and this function will tell you the answer.
|
||||
*/
|
||||
@@ -339,7 +339,7 @@ interface IDurandalViewModelActiveItem {
|
||||
* Sets up a collection representing a pool of objects which the activator will activate. See below for details. Activators without an item bool always close their values on deactivate. Activators with an items pool only deactivate, but do not close them.
|
||||
*/
|
||||
forItems(items): IDurandalViewModelActiveItem;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* A router plugin, currently based on SammyJS. The router abstracts away the core configuration of Sammy and re-interprets it in terms of durandal's composition and activation mechanism. To use the router, you must require it, configure it and bind it in the UI.
|
||||
@@ -360,12 +360,12 @@ declare module "durandal/plugins/router" {
|
||||
/** used to set the document title */
|
||||
caption: string;
|
||||
/** determines whether or not to include it in the router's visibleRoutes array for easy navigation UI binding */
|
||||
visible: bool;
|
||||
visible: boolean;
|
||||
settings: Object;
|
||||
hash: string;
|
||||
/** only present on visible routes to track if they are active in the nav */
|
||||
isActive?: KnockoutComputed;
|
||||
};
|
||||
isActive?: KnockoutComputed<boolean>;
|
||||
}
|
||||
/**
|
||||
* Parameters to the map function. e only required parameter is url the rest can be derived. The derivation
|
||||
* happens by stripping parameters from the url and casing where appropriate. You can always explicitly provide
|
||||
@@ -383,25 +383,25 @@ declare module "durandal/plugins/router" {
|
||||
/** used to set the document title */
|
||||
caption?: string;
|
||||
/** determines whether or not to include it in the router's visibleRoutes array for easy navigation UI binding */
|
||||
visible?: bool;
|
||||
visible?: boolean;
|
||||
settings?: Object;
|
||||
}
|
||||
/**
|
||||
* observable that is called when the router is ready
|
||||
*/
|
||||
export var ready: KnockoutObservableBool;
|
||||
export var ready: KnockoutObservable<boolean>;
|
||||
/**
|
||||
* An observable array containing all route info objects.
|
||||
*/
|
||||
export var allRoutes: KnockoutObservableArray;
|
||||
export var allRoutes: KnockoutObservableArray<IRouteInfo>;
|
||||
/**
|
||||
* An observable array containing route info objects configured with visible:true (or by calling the mapNav function).
|
||||
*/
|
||||
export var visibleRoutes: KnockoutObservableArray;
|
||||
export var visibleRoutes: KnockoutObservableArray<IRouteInfo>;
|
||||
/**
|
||||
* An observable boolean which is true while navigation is in process; false otherwise.
|
||||
*/
|
||||
export var isNavigating: KnockoutObservableBool;
|
||||
export var isNavigating: KnockoutObservable<boolean>;
|
||||
/**
|
||||
* An observable whose value is the currently active item/module/page.
|
||||
*/
|
||||
@@ -409,7 +409,7 @@ declare module "durandal/plugins/router" {
|
||||
/**
|
||||
* An observable whose value is the currently active route.
|
||||
*/
|
||||
export var activeRoute: KnockoutObservableAny;
|
||||
export var activeRoute: KnockoutObservable<IRouteInfo>;
|
||||
/**
|
||||
* called after an a new module is composed
|
||||
*/
|
||||
@@ -467,7 +467,7 @@ declare module "durandal/plugins/router" {
|
||||
*/
|
||||
export var mapRoute: {
|
||||
(route: IRouteInfoParameters): IRouteInfo;
|
||||
(url: string, moduleId?: string, name?: string, visible?: bool): IRouteInfo;
|
||||
(url: string, moduleId?: string, name?: string, visible?: boolean): IRouteInfo;
|
||||
}
|
||||
/**
|
||||
* This function takes an array of routeInfo objects or a single routeInfo object and uses it to configure the router. The finalized routeInfo (or array of infos) is returned.
|
||||
|
||||
Vendored
+1
-1
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
|
||||
|
||||
/// <reference path="tweenjs.d.ts" />
|
||||
/// <reference path="../tweenjs/tweenjs.d.ts" />
|
||||
|
||||
// rename the native MouseEvent, to avoid conflit with createjs's MouseEvent
|
||||
interface NativeMouseEvent extends MouseEvent {
|
||||
|
||||
Vendored
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
declare function expect(target?: any): Expect.Root;
|
||||
|
||||
module Expect {
|
||||
declare module Expect {
|
||||
interface Assertion {
|
||||
/**
|
||||
* Check if the value is truthy
|
||||
|
||||
@@ -1277,7 +1277,7 @@ function test_general() {
|
||||
|
||||
app.enabled('trust proxy');
|
||||
|
||||
app.configure(function () => {
|
||||
app.configure(() => {
|
||||
app.set('title', 'My Application');
|
||||
});
|
||||
|
||||
|
||||
Vendored
+611
-606
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
@@ -6,7 +6,7 @@
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts" />
|
||||
|
||||
module jquery.flot {
|
||||
declare module jquery.flot {
|
||||
interface plotOptions {
|
||||
colors?: any[];
|
||||
series?: seriesOptions;
|
||||
|
||||
@@ -0,0 +1,832 @@
|
||||
/// <reference path="fullCalendar.d.ts" />
|
||||
/// <reference path="../jquery/jquery.d.ts"/>
|
||||
/// <reference path="../jqueryui/jqueryui.d.ts"/>
|
||||
|
||||
// All examples from http://arshaw.com/fullcalendar/docs/
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
})
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
weekends: false
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
dayClick: function () {
|
||||
alert('a day has been clicked!');
|
||||
}
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar('next');
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
events: 'http://www.google.com/your_feed_url/'
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
events: {
|
||||
url: 'http://www.google.com/your_feed_url/',
|
||||
className: 'gcal-event', // an option!
|
||||
currentTimezone: 'America/Chicago' // an option!
|
||||
}
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
eventSources: [
|
||||
|
||||
// source with no options
|
||||
"http://www.google.com/your_feed_url1/",
|
||||
|
||||
// source with no options
|
||||
"http://www.google.com/your_feed_url2/",
|
||||
|
||||
// source WITH options
|
||||
{
|
||||
url: "http://www.google.com/your_feed_url3/",
|
||||
className: 'nice-event'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
height: 650
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar('option', 'height', 700);
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
contentHeight: 600
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar('option', 'contentHeight', 650);
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
aspectRatio: 2
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar('option', 'aspectRatio', 1.8);
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
viewDisplay: function (view) {
|
||||
alert('The new title of the view is ' + view.title);
|
||||
}
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
windowResize: function (view) {
|
||||
alert('The calendar has adjusted to a window resize');
|
||||
}
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar('render');
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
dragOpacity: {
|
||||
month: .2,
|
||||
'': .5
|
||||
}
|
||||
});
|
||||
|
||||
var view: FullCalendar.View = <any>$('#calendar').fullCalendar('getView');
|
||||
alert("The view's title is " + view.title);
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,basicWeek,basicDay'
|
||||
},
|
||||
editable: true,
|
||||
events: [
|
||||
{
|
||||
title: 'All Day Event',
|
||||
start: new Date(y, m, 1)
|
||||
},
|
||||
{
|
||||
title: 'Long Event',
|
||||
start: new Date(y, m, d - 5),
|
||||
end: new Date(y, m, d - 2)
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d - 3, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d + 4, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Meeting',
|
||||
start: new Date(y, m, d, 10, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Lunch',
|
||||
start: new Date(y, m, d, 12, 0),
|
||||
end: new Date(y, m, d, 14, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Birthday Party',
|
||||
start: new Date(y, m, d + 1, 19, 0),
|
||||
end: new Date(y, m, d + 1, 22, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Click for Google',
|
||||
start: new Date(y, m, 28),
|
||||
end: new Date(y, m, 29),
|
||||
url: 'http://google.com/'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,basicWeek,basicDay'
|
||||
},
|
||||
defaultView: 'basicWeek',
|
||||
editable: true,
|
||||
events: [
|
||||
{
|
||||
title: 'All Day Event',
|
||||
start: new Date(y, m, 1)
|
||||
},
|
||||
{
|
||||
title: 'Long Event',
|
||||
start: new Date(y, m, d - 5),
|
||||
end: new Date(y, m, d - 2)
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d - 3, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d + 4, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Meeting',
|
||||
start: new Date(y, m, d, 10, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Lunch',
|
||||
start: new Date(y, m, d, 12, 0),
|
||||
end: new Date(y, m, d, 14, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Birthday Party',
|
||||
start: new Date(y, m, d + 1, 19, 0),
|
||||
end: new Date(y, m, d + 1, 22, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Click for Google',
|
||||
start: new Date(y, m, 28),
|
||||
end: new Date(y, m, 29),
|
||||
url: 'http://google.com/'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,basicWeek,basicDay'
|
||||
},
|
||||
defaultView: 'basicDay',
|
||||
editable: true,
|
||||
events: [
|
||||
{
|
||||
id: 1,
|
||||
title: "Long Event",
|
||||
start: new Date(y, m, d, 14, 0),
|
||||
end: new Date(y, m, d + 3),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: "Repeating Event",
|
||||
start: new Date(y, m, d - 1),
|
||||
allDay: true
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: "Repeating Event",
|
||||
start: new Date(y, m, d + 6),
|
||||
allDay: true
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
title: "Meeting",
|
||||
start: new Date(y, m, d, 9, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
title: "Click for Facebook",
|
||||
start: new Date(y, m, d, 16),
|
||||
end: new Date(y, m, d),
|
||||
url: "http://facebook.com/",
|
||||
allDay: false
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
editable: true,
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,agendaDay'
|
||||
},
|
||||
defaultView: 'agendaWeek',
|
||||
events: [
|
||||
{
|
||||
title: 'All Day Event',
|
||||
start: new Date(y, m, 1)
|
||||
},
|
||||
{
|
||||
title: 'Long Event',
|
||||
start: new Date(y, m, d - 5),
|
||||
end: new Date(y, m, d - 2)
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d - 3, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d + 4, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Meeting',
|
||||
start: new Date(y, m, d, 10, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Lunch',
|
||||
start: new Date(y, m, d, 12, 0),
|
||||
end: new Date(y, m, d, 14, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Birthday Party',
|
||||
start: new Date(y, m, d + 1, 19, 0),
|
||||
end: new Date(y, m, d + 1, 22, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Click for Google',
|
||||
start: new Date(y, m, 28),
|
||||
end: new Date(y, m, 29),
|
||||
url: 'http://google.com/'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,agendaDay'
|
||||
},
|
||||
defaultView: 'agendaDay',
|
||||
editable: true,
|
||||
events: [
|
||||
{
|
||||
id: 1,
|
||||
title: "Long Event",
|
||||
start: new Date(y, m, d),
|
||||
end: new Date(y, m, d + 3),
|
||||
allDay: true
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: "Repeating Event",
|
||||
start: new Date(y, m, d - 1),
|
||||
allDay: true
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: "Repeating Event",
|
||||
start: new Date(y, m, d + 6),
|
||||
allDay: true
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
title: "Meeting",
|
||||
start: new Date(y, m, d, 10, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
title: "Click for Facebook",
|
||||
start: new Date(y, m, d, 11, 30),
|
||||
end: new Date(y, m, d),
|
||||
url: "http://facebook.com/",
|
||||
allDay: false
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$('#my-prev-button').click(function () {
|
||||
$('#calendar').fullCalendar('prev');
|
||||
});
|
||||
|
||||
$('#my-next-button').click(function () {
|
||||
$('#calendar').fullCalendar('next');
|
||||
});
|
||||
|
||||
$('#my-today-button').click(function () {
|
||||
$('#calendar').fullCalendar('today');
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar('gotoDate', 1, 0, 1);
|
||||
|
||||
$('#my-button').click(function () {
|
||||
var d: Date = <any>$('#calendar').fullCalendar('getDate');
|
||||
alert("The current date of the calendar is " + d);
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
events: [
|
||||
{
|
||||
title: 'My Event',
|
||||
start: '2010-01-01T14:30:00',
|
||||
allDay: false
|
||||
}
|
||||
// other events here...
|
||||
],
|
||||
timeFormat: 'H(:mm)' // uppercase H for 24-hour clock
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
buttonText: {
|
||||
prev: '<',
|
||||
next: '>'
|
||||
}
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
dayClick: function (date, allDay, jsEvent, view) {
|
||||
|
||||
if (allDay) {
|
||||
alert('Clicked on the entire day: ' + date);
|
||||
} else {
|
||||
alert('Clicked on the slot: ' + date);
|
||||
}
|
||||
|
||||
alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
|
||||
|
||||
alert('Current view: ' + view.name);
|
||||
|
||||
// change the day's background color just for fun
|
||||
$(this).css('background-color', 'red');
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
eventClick: function (calEvent, jsEvent, view) {
|
||||
|
||||
alert('Event: ' + calEvent.title);
|
||||
alert('Coordinates: ' + jsEvent.pageX + ',' + jsEvent.pageY);
|
||||
alert('View: ' + view.name);
|
||||
|
||||
// change the border color just for fun
|
||||
$(this).css('border-color', 'red');
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
events: [
|
||||
{
|
||||
title: 'My Event',
|
||||
start: '2010-01-01',
|
||||
url: 'http://google.com/'
|
||||
}
|
||||
// other events here
|
||||
],
|
||||
eventClick: function (event) {
|
||||
if (event.url) {
|
||||
window.open(event.url);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
|
||||
eventSources: [
|
||||
|
||||
// your event source
|
||||
{
|
||||
url: '/myfeed.php',
|
||||
type: 'POST',
|
||||
data: {
|
||||
custom_param1: 'something',
|
||||
custom_param2: 'somethingelse'
|
||||
},
|
||||
error: function () {
|
||||
alert('there was an error while fetching events!');
|
||||
},
|
||||
color: 'yellow', // a non-ajax option
|
||||
textColor: 'black' // a non-ajax option
|
||||
}
|
||||
|
||||
// any other sources...
|
||||
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
|
||||
events: {
|
||||
url: '/myfeed.php',
|
||||
type: 'POST',
|
||||
data: {
|
||||
custom_param1: 'something',
|
||||
custom_param2: 'somethingelse'
|
||||
},
|
||||
error: function () {
|
||||
alert('there was an error while fetching events!');
|
||||
},
|
||||
color: 'yellow', // a non-ajax option
|
||||
textColor: 'black' // a non-ajax option
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
|
||||
events: {
|
||||
url: '/myfeed.php',
|
||||
cache: true
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
|
||||
eventSources: [
|
||||
|
||||
// your event source
|
||||
{
|
||||
url: '/myfeed.php', // use the `url` property
|
||||
color: 'yellow', // an option!
|
||||
textColor: 'black' // an option!
|
||||
}
|
||||
|
||||
// any other sources...
|
||||
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
events: '/myfeed.php'
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
events: [
|
||||
{
|
||||
title: 'event1',
|
||||
start: '2010-01-01'
|
||||
},
|
||||
{
|
||||
title: 'event2',
|
||||
start: '2010-01-05',
|
||||
end: '2010-01-07'
|
||||
},
|
||||
{
|
||||
title: 'event3',
|
||||
start: '2010-01-09 12:30:00',
|
||||
allDay: false // will make the time show
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
|
||||
eventSources: [
|
||||
|
||||
// your event source
|
||||
{
|
||||
events: [ // put the array in the `events` property
|
||||
{
|
||||
title: 'event1',
|
||||
start: '2010-01-01'
|
||||
},
|
||||
{
|
||||
title: 'event2',
|
||||
start: '2010-01-05',
|
||||
end: '2010-01-07'
|
||||
},
|
||||
{
|
||||
title: 'event3',
|
||||
start: '2010-01-09 12:30:00',
|
||||
}
|
||||
],
|
||||
color: 'black', // an option!
|
||||
textColor: 'yellow' // an option!
|
||||
}
|
||||
|
||||
// any other event sources...
|
||||
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
events: function (start, end, callback) {
|
||||
$.ajax({
|
||||
url: 'myxmlfeed.php',
|
||||
dataType: 'xml',
|
||||
data: {
|
||||
// our hypothetical feed requires UNIX timestamps
|
||||
start: Math.round(start.getTime() / 1000),
|
||||
end: Math.round(end.getTime() / 1000)
|
||||
},
|
||||
success: function (doc) {
|
||||
var events = [];
|
||||
$(doc).find('event').each(function () {
|
||||
events.push({
|
||||
title: $(this).attr('title'),
|
||||
start: $(this).attr('start') // will be parsed
|
||||
});
|
||||
});
|
||||
callback(events);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
|
||||
eventSources: [
|
||||
|
||||
// your event source
|
||||
{
|
||||
events: function (start, end, callback) {
|
||||
// ...
|
||||
},
|
||||
color: 'yellow', // an option!
|
||||
textColor: 'black' // an option!
|
||||
}
|
||||
|
||||
// any other sources...
|
||||
|
||||
]
|
||||
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
eventSources: [
|
||||
'/feed1.php',
|
||||
'/feed2.php'
|
||||
]
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
eventClick: function (event, element) {
|
||||
|
||||
event.title = "CLICKED!";
|
||||
|
||||
$('#calendar').fullCalendar('updateEvent', event);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
events: [
|
||||
// my event data
|
||||
],
|
||||
eventColor: '#378006'
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
events: [
|
||||
{
|
||||
title: 'My Event',
|
||||
start: '2010-01-01',
|
||||
description: 'This is a cool event'
|
||||
}
|
||||
// more events here
|
||||
],
|
||||
eventRender: function (event, element) {
|
||||
element.qtip({
|
||||
content: event.description
|
||||
});
|
||||
}
|
||||
});
|
||||
$('#my-draggable').draggable({
|
||||
revert: true, // immediately snap back to original position
|
||||
revertDuration: 0 //
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
droppable: true,
|
||||
drop: function (date, allDay) {
|
||||
alert("Dropped on " + date + " with allDay=" + allDay);
|
||||
}
|
||||
});
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
droppable: true,
|
||||
dropAccept: '.cool-event',
|
||||
drop: function () {
|
||||
alert('dropped!');
|
||||
}
|
||||
});
|
||||
|
||||
$('#draggable1').draggable();
|
||||
$('#draggable2').draggable();
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
var date = new Date();
|
||||
var d = date.getDate();
|
||||
var m = date.getMonth();
|
||||
var y = date.getFullYear();
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
theme: true,
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,agendaDay'
|
||||
},
|
||||
editable: true,
|
||||
events: [
|
||||
{
|
||||
title: 'All Day Event',
|
||||
start: new Date(y, m, 1)
|
||||
},
|
||||
{
|
||||
title: 'Long Event',
|
||||
start: new Date(y, m, d - 5),
|
||||
end: new Date(y, m, d - 2)
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d - 3, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
id: 999,
|
||||
title: 'Repeating Event',
|
||||
start: new Date(y, m, d + 4, 16, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Meeting',
|
||||
start: new Date(y, m, d, 10, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Lunch',
|
||||
start: new Date(y, m, d, 12, 0),
|
||||
end: new Date(y, m, d, 14, 0),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Birthday Party',
|
||||
start: new Date(y, m, d + 1, 19, 0),
|
||||
end: new Date(y, m, d + 1, 22, 30),
|
||||
allDay: false
|
||||
},
|
||||
{
|
||||
title: 'Click for Google',
|
||||
start: new Date(y, m, 28),
|
||||
end: new Date(y, m, 29),
|
||||
url: 'http://google.com/'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
/* initialize the external events
|
||||
-----------------------------------------------------------------*/
|
||||
$('#external-events div.external-event').each(function () {
|
||||
|
||||
// create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
|
||||
// it doesn't need to have a start or end
|
||||
var eventObject = {
|
||||
title: $.trim($(this).text()) // use the element's text as the event title
|
||||
};
|
||||
|
||||
// store the Event Object in the DOM element so we can get to it later
|
||||
$(this).data('eventObject', eventObject);
|
||||
|
||||
// make the event draggable using jQuery UI
|
||||
$(this).draggable({
|
||||
zIndex: 999,
|
||||
revert: true, // will cause the event to go back to its
|
||||
revertDuration: 0 // original position after the drag
|
||||
});
|
||||
|
||||
});
|
||||
/* initialize the calendar
|
||||
-----------------------------------------------------------------*/
|
||||
|
||||
$('#calendar').fullCalendar({
|
||||
header: {
|
||||
left: 'prev,next today',
|
||||
center: 'title',
|
||||
right: 'month,agendaWeek,agendaDay'
|
||||
},
|
||||
editable: true,
|
||||
droppable: true, // this allows things to be dropped onto the calendar !!!
|
||||
drop: function (date, allDay) { // this function is called when something is dropped
|
||||
|
||||
// retrieve the dropped element's stored Event Object
|
||||
var originalEventObject = $(this).data('eventObject');
|
||||
|
||||
// we need to copy it, so that multiple events don't have a reference to the same object
|
||||
var copiedEventObject: any = $.extend({}, originalEventObject);
|
||||
|
||||
// assign it the date that was reported
|
||||
copiedEventObject.start = date;
|
||||
copiedEventObject.allDay = allDay;
|
||||
|
||||
// render the event on the calendar
|
||||
// the last `true` argument determines if the event "sticks" (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)
|
||||
$('#calendar').fullCalendar('renderEvent', copiedEventObject, true);
|
||||
|
||||
// is the "remove after drop" checkbox checked?
|
||||
if ($('#drop-remove').is(':checked')) {
|
||||
// if so, remove the element from the "Draggable Events" list
|
||||
$(this).remove();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
Vendored
+188
@@ -0,0 +1,188 @@
|
||||
// Type definitions for FullCalendar 1.6.1
|
||||
// Project: http://arshaw.com/fullcalendar/ (http://arshaw.com/fullcalendar/)
|
||||
// Definitions by: Neil Stalker <https://github.com/nestalk>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts"/>
|
||||
|
||||
declare module FullCalendar {
|
||||
export interface Calendar {
|
||||
formatDate(date: Date, format: string, options?: Options): string;
|
||||
formatDates(date1: Date, date2: Date, format: string, options?: Options): string;
|
||||
parseDate(dateString: string, ignoreTimezone?: boolean): Date;
|
||||
parseISO8601(dateString: string, ignoreTimezone?: boolean): Date;
|
||||
version: string;
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
header?: {
|
||||
left: string;
|
||||
center: string;
|
||||
right: string;
|
||||
}
|
||||
theme?: boolean
|
||||
buttonIcons?: {
|
||||
prev: string;
|
||||
next: string;
|
||||
}
|
||||
firstDay?: number;
|
||||
isRTL?: boolean;
|
||||
weekends?: boolean;
|
||||
weekMode?: string;
|
||||
weekNumbers?: boolean;
|
||||
weekNumberCalculation?: any; // String/Function
|
||||
height?: number;
|
||||
contentHeight?: number;
|
||||
aspectRation?: number;
|
||||
viewDisplay?: (view: View) => void;
|
||||
windowResize?: (view: View) => void;
|
||||
dayRender?: (date: Date, cell: HTMLTableDataCellElement) => void;
|
||||
|
||||
defaultView?: string;
|
||||
|
||||
year?: number;
|
||||
month?: number;
|
||||
date?: number;
|
||||
|
||||
timeFormat?: any; // String/ViewOptionHash
|
||||
columnFormat?: any; // String/ViewOptionHash
|
||||
titleFormat?: any; // String/ViewOptionHash
|
||||
buttonText?: ButtonTextObject;
|
||||
monthNames?: Array<string>;
|
||||
monthNamesShort?: Array<string>;
|
||||
dayNames?: Array<string>;
|
||||
dayNamesShort?: Array<string>;
|
||||
weekNumberTitle?: number;
|
||||
|
||||
dayClick?: (date: Date, allDay: boolean, jsEvent: Event, view: View) => void;
|
||||
eventClick?: (event: EventObject, jsEvent: Event, view: View) => any; // return type boolean or void
|
||||
eventMouseover?: (event: EventObject, jsEvent: Event, view: View) => void;
|
||||
eventMouseout?: (event: EventObject, jsEvent: Event, view: View) => void;
|
||||
|
||||
selectable?: any; // Boolean/ViewOptionHash
|
||||
selectHelper?: any; // Boolean/Function
|
||||
unselectAuto?: boolean;
|
||||
unselectCancel?: string;
|
||||
select?: (startDate: Date, endDate: Date, allDay: boolean, jsEvent: Event, view: View) => void;
|
||||
unselect?: (view: View, jsEvent: Event) => void;
|
||||
|
||||
eventSources?: Array<EventSource>;
|
||||
allDayDefault?: boolean;
|
||||
ignoreTimezone?: boolean;
|
||||
eventDataTransform?: (eventData: any) => EventObject;
|
||||
startParam?: string;
|
||||
endParam?: string
|
||||
lazyFetching?: boolean;
|
||||
loading?: (isLoading: boolean, view: View) => void;
|
||||
|
||||
eventColor?: string;
|
||||
eventBackgroundColor?: string;
|
||||
eventBorderColor?: string;
|
||||
eventTextColor?: string;
|
||||
eventRender?: (event: EventObject, element: HTMLDivElement, view: View) => void;
|
||||
eventAfterRender?: (event: EventObject, element: HTMLDivElement, view: View) => void;
|
||||
eventAllAfterRender?: (view: View) => void;
|
||||
|
||||
editable?: boolean;
|
||||
disableDragging?: boolean;
|
||||
disableResizing?: boolean;
|
||||
dragRevertDuration?: number;
|
||||
dragOpacity?: any; // Float/ViewOptionHash
|
||||
eventDragStart?: (event: EventObject, jsEvent: Event, ui: any, view: View) => void;
|
||||
eventDragStop?: (event: EventObject, jsEvent: Event, ui: any, view: View) => void;
|
||||
eventDrop?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: View) => void;
|
||||
eventResizeStart?: (event: EventObject, jsEvent: Event, ui: any, view: View) => void;
|
||||
eventResizeStop?: (event: EventObject, jsEvent: Event, ui: any, view: View) => void;
|
||||
eventResize?: (event: EventObject, dayDelta: number, minuteDelta: number, revertFunc: Function, jsEvent: Event, ui: any, view: View) => void;
|
||||
|
||||
droppable?: boolean;
|
||||
dropAccept?: any; // String/Function
|
||||
drop?: (date: Date, allDay: boolean, jsEvent: Event, ui: any) => void;
|
||||
}
|
||||
|
||||
export interface View {
|
||||
name: string;
|
||||
title: string;
|
||||
start: Date;
|
||||
End: Date;
|
||||
visStart: Date;
|
||||
visEnd: Date;
|
||||
}
|
||||
|
||||
export interface ViewOptionHash {
|
||||
month?: any;
|
||||
week?: any;
|
||||
day?: any;
|
||||
agenda?: any;
|
||||
agendaDay?: any;
|
||||
agendaWeek?: any;
|
||||
basic?: any;
|
||||
basicDay?: any;
|
||||
basicWeek?: any;
|
||||
''?: any;
|
||||
}
|
||||
|
||||
export interface AgendaOptions {
|
||||
allDaySlot?: boolean;
|
||||
allDayText?: string;
|
||||
axisFormat?: string;
|
||||
slotMinutes?: number;
|
||||
snapMinutes?: number;
|
||||
defaultEventMinutes?: number;
|
||||
firstHour?: number;
|
||||
minTime?: any; // Integer/String
|
||||
maxTime?: any; // Integer/String
|
||||
}
|
||||
|
||||
export interface ButtonTextObject {
|
||||
prev?: string;
|
||||
next?: string;
|
||||
prevYear?: string;
|
||||
nextYear?: string;
|
||||
today?: string;
|
||||
month?: string;
|
||||
week?: string;
|
||||
day?: string;
|
||||
}
|
||||
|
||||
export interface EventObject {
|
||||
id?: any // String/number
|
||||
title: string;
|
||||
allDay?: boolean;
|
||||
start: Date;
|
||||
end?: Date;
|
||||
url?: string;
|
||||
className?: any; // string/Array<string>
|
||||
editable?: boolean;
|
||||
source?: EventSource;
|
||||
color?: string;
|
||||
backgroundColor?: string;
|
||||
borderColor?: string;
|
||||
textColor?: string;
|
||||
}
|
||||
|
||||
export interface EventSource extends JQueryAjaxSettings {
|
||||
events?: any;
|
||||
color?: string;
|
||||
backgroundColor?: string;
|
||||
borderColor?: string;
|
||||
textColor?: string;
|
||||
className?: any; // string/Array<string>
|
||||
editable?: boolean;
|
||||
allDayDefault?: boolean;
|
||||
ignoreTimezone?: boolean;
|
||||
eventTransform?: any;
|
||||
startParam?: string;
|
||||
endParam?: string
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface JQuery {
|
||||
fullCalendar(options: FullCalendar.Options): JQuery;
|
||||
fullCalendar(method: string, ...args: Array<any>): JQuery;
|
||||
}
|
||||
|
||||
interface JQueryStatic {
|
||||
fullCalendar: FullCalendar.Calendar;
|
||||
}
|
||||
Vendored
+1
-2
@@ -34,7 +34,6 @@ declare module google.maps {
|
||||
notify(key: string): void;
|
||||
set(key: string, value: any): void;
|
||||
setValues(values: any): void;
|
||||
setValues(values: undefined);
|
||||
unbind(key: string): void;
|
||||
unbindAll(): void;
|
||||
}
|
||||
@@ -1582,4 +1581,4 @@ declare module google.maps {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
/// <reference path="../lib/sinon.d.ts" />
|
||||
/// <reference path="../lib/mocha.d.ts" />
|
||||
/// <reference path="../sinon/sinon-1.5.d.ts" />
|
||||
/// <reference path="../mocha/mocha.d.ts" />
|
||||
/// <reference path="../expect.js/expect.js.d.ts" />
|
||||
/// <reference path="../js-fixtures/fixtures.d.ts" />
|
||||
/// <reference path="../jquery/jquery.d.ts" />
|
||||
/// <reference path="../i18next.d.ts" />
|
||||
|
||||
// declarations for expect.js
|
||||
declare var expect: (actual: string) => any;
|
||||
declare var expect: (actual: number) => any;
|
||||
|
||||
// declarations for jsfixtures.js
|
||||
declare var setFixtures: (html) => void;
|
||||
/// <reference path="i18next.d.ts" />
|
||||
|
||||
declare function done(): void;
|
||||
|
||||
describe('i18next', function () {
|
||||
|
||||
var i18n = $.i18n
|
||||
@@ -1221,9 +1218,7 @@ describe('i18next', function () {
|
||||
};
|
||||
|
||||
beforeEach(function (done) {
|
||||
setFixtures('
|
||||
|
||||
');
|
||||
fixtures.set('');
|
||||
|
||||
i18n.init($.extend(opts, { resStore: resStore }),
|
||||
function (t) { done(); });
|
||||
@@ -1250,9 +1245,7 @@ describe('i18next', function () {
|
||||
};
|
||||
|
||||
beforeEach(function (done) {
|
||||
setFixtures('
|
||||
|
||||
');
|
||||
fixtures.set('');
|
||||
|
||||
i18n.init($.extend(opts, { resStore: resStore }),
|
||||
function (t) { done(); });
|
||||
@@ -1279,9 +1272,7 @@ describe('i18next', function () {
|
||||
};
|
||||
|
||||
beforeEach(function (done) {
|
||||
setFixtures('
|
||||
|
||||
');
|
||||
fixtures.set('');
|
||||
|
||||
i18n.init($.extend(opts, { resStore: resStore }),
|
||||
function (t) { done(); });
|
||||
@@ -1299,14 +1290,11 @@ describe('i18next', function () {
|
||||
var resStore = {
|
||||
dev: { translation: {} },
|
||||
en: { translation: {} },
|
||||
'en-US': { translation: { 'simpleTest': '
|
||||
test
|
||||
' } }
|
||||
'en-US': { translation: { 'simpleTest': 'test' } }
|
||||
};
|
||||
|
||||
beforeEach(function (done) {
|
||||
setFixtures('
|
||||
');
|
||||
fixtures.set('');
|
||||
|
||||
i18n.init($.extend(opts, { resStore: resStore }),
|
||||
function (t) { done(); });
|
||||
@@ -1329,9 +1317,7 @@ test
|
||||
};
|
||||
|
||||
beforeEach(function (done) {
|
||||
setFixtures('
|
||||
|
||||
');
|
||||
fixtures.set('');
|
||||
|
||||
i18n.init($.extend(opts, {
|
||||
resStore: resStore,
|
||||
Vendored
+1
-1
@@ -13,7 +13,7 @@ interface IResourceStoreLanguage {
|
||||
[namespace: string]: IResourceStoreKey;
|
||||
}
|
||||
interface IResourceStoreKey {
|
||||
[key: string];
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
interface I18nextOptions {
|
||||
|
||||
Vendored
-758
@@ -1,758 +0,0 @@
|
||||
/* *****************************************************************************
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
// Typing for the jQuery library, version 1.7.x
|
||||
|
||||
/*
|
||||
Interface for the AJAX setting that will configure the AJAX request
|
||||
*/
|
||||
interface JQueryAjaxSettings {
|
||||
accepts?: any;
|
||||
async?: bool;
|
||||
beforeSend?(jqXHR: JQueryXHR, settings: JQueryAjaxSettings);
|
||||
cache?: bool;
|
||||
complete?(jqXHR: JQueryXHR, textStatus: string);
|
||||
contents?: { [key: string]: any; };
|
||||
contentType?: string;
|
||||
context?: any;
|
||||
converters?: { [key: string]: any; };
|
||||
crossDomain?: bool;
|
||||
data?: any;
|
||||
dataFilter?(data: any, ty: any): any;
|
||||
dataType?: string;
|
||||
error?(jqXHR: JQueryXHR, textStatus: string, errorThrow: string): any;
|
||||
global?: bool;
|
||||
headers?: { [key: string]: any; };
|
||||
ifModified?: bool;
|
||||
isLocal?: bool;
|
||||
jsonp?: string;
|
||||
jsonpCallback?: any;
|
||||
mimeType?: string;
|
||||
password?: string;
|
||||
processData?: bool;
|
||||
scriptCharset?: string;
|
||||
statusCode?: { [key: string]: any; };
|
||||
success?(data: any, textStatus: string, jqXHR: JQueryXHR);
|
||||
timeout?: number;
|
||||
traditional?: bool;
|
||||
type?: string;
|
||||
url?: string;
|
||||
username?: string;
|
||||
xhr?: any;
|
||||
xhrFields?: { [key: string]: any; };
|
||||
}
|
||||
|
||||
/*
|
||||
Interface for the jqXHR object
|
||||
*/
|
||||
interface JQueryXHR extends XMLHttpRequest, JQueryPromise {
|
||||
overrideMimeType(mimeType: string);
|
||||
}
|
||||
|
||||
/*
|
||||
Interface for the JQuery callback
|
||||
*/
|
||||
interface JQueryCallback {
|
||||
add(...callbacks: any[]): any;
|
||||
disable(): any;
|
||||
empty(): any;
|
||||
fire(...arguments: any[]): any;
|
||||
fired(): bool;
|
||||
fireWith(context: any, ...args: any[]): any;
|
||||
has(callback: any): bool;
|
||||
lock(): any;
|
||||
locked(): bool;
|
||||
remove(...callbacks: any[]): any;
|
||||
}
|
||||
|
||||
/*
|
||||
Interface for the JQuery promise, part of callbacks
|
||||
*/
|
||||
interface JQueryPromise {
|
||||
always(...alwaysCallbacks: any[]): JQueryDeferred;
|
||||
done(...doneCallbacks: any[]): JQueryDeferred;
|
||||
fail(...failCallbacks: any[]): JQueryDeferred;
|
||||
progress(...progressCallbacks: any[]): JQueryDeferred;
|
||||
state(): string;
|
||||
pipe(doneFilter?: (...args: any[]) => any, failFilter?: (...args: any[]) => any, progressFilter?: (...args: any[]) => any): JQueryPromise;
|
||||
then(doneCallbacks: any, failCallbacks: any, progressCallbacks?: any): JQueryDeferred;
|
||||
}
|
||||
|
||||
/*
|
||||
Interface for the JQuery deferred, part of callbacks
|
||||
*/
|
||||
interface JQueryDeferred extends JQueryPromise {
|
||||
notify(...args: any[]): JQueryDeferred;
|
||||
notifyWith(context: any, ...args: any[]): JQueryDeferred;
|
||||
|
||||
pipe(doneFilter?: any, failFilter?: any, progressFilter?: any): JQueryPromise;
|
||||
progress(...progressCallbacks: any[]): JQueryDeferred;
|
||||
promise(target? ): JQueryDeferred;
|
||||
reject(...args: any[]): JQueryDeferred;
|
||||
rejectWith(context:any, ...args: any[]): JQueryDeferred;
|
||||
resolve(...args: any[]): JQueryDeferred;
|
||||
resolveWith(context:any, ...args: any[]): JQueryDeferred;
|
||||
state(): string;
|
||||
then(doneCallbacks: any, failCallbacks: any, progressCallbacks?: any): JQueryDeferred;
|
||||
}
|
||||
|
||||
/*
|
||||
Interface of the JQuery extension of the W3C event object
|
||||
*/
|
||||
interface JQueryEventObject extends Event {
|
||||
data: any;
|
||||
delegateTarget: Element;
|
||||
isDefaultPrevented(): bool;
|
||||
isImmediatePropogationStopped(): bool;
|
||||
isPropogationStopped(): bool;
|
||||
namespace: string;
|
||||
preventDefault(): any;
|
||||
relatedTarget: Element;
|
||||
result: any;
|
||||
stopImmediatePropagation();
|
||||
stopPropagation();
|
||||
pageX: number;
|
||||
pageY: number;
|
||||
which: number;
|
||||
metaKey: any;
|
||||
}
|
||||
|
||||
/*
|
||||
Collection of properties of the current browser
|
||||
*/
|
||||
interface JQueryBrowserInfo {
|
||||
safari:bool;
|
||||
opera:bool;
|
||||
msie:bool;
|
||||
mozilla:bool;
|
||||
webkit:bool;
|
||||
version:string;
|
||||
}
|
||||
|
||||
interface JQuerySupport {
|
||||
ajax?: bool;
|
||||
boxModel?: bool;
|
||||
changeBubbles?: bool;
|
||||
checkClone?: bool;
|
||||
checkOn?: bool;
|
||||
cors?: bool;
|
||||
cssFloat?: bool;
|
||||
hrefNormalized?: bool;
|
||||
htmlSerialize?: bool;
|
||||
leadingWhitespace?: bool;
|
||||
noCloneChecked?: bool;
|
||||
noCloneEvent?: bool;
|
||||
opacity?: bool;
|
||||
optDisabled?: bool;
|
||||
optSelected?: bool;
|
||||
scriptEval?(): bool;
|
||||
style?: bool;
|
||||
submitBubbles?: bool;
|
||||
tbody?: bool;
|
||||
}
|
||||
|
||||
/*
|
||||
Static members of jQuery (those on $ and jQuery themselves)
|
||||
*/
|
||||
interface JQueryStatic {
|
||||
|
||||
/****
|
||||
AJAX
|
||||
*****/
|
||||
ajax(settings: JQueryAjaxSettings): JQueryXHR;
|
||||
ajax(url: string, settings?: JQueryAjaxSettings): JQueryXHR;
|
||||
|
||||
ajaxPrefilter(dataTypes: string, handler: (opts: any, originalOpts: any, jqXHR: JQueryXHR) => any): any;
|
||||
ajaxPrefilter(handler: (opts: any, originalOpts: any, jqXHR: JQueryXHR) => any): any;
|
||||
|
||||
ajaxSettings: JQueryAjaxSettings;
|
||||
|
||||
ajaxSetup(options: any);
|
||||
|
||||
get(url: string, data?: any, success?: any, dataType?: any): JQueryXHR;
|
||||
getJSON(url: string, data?: any, success?: any): JQueryXHR;
|
||||
getScript(url: string, success?: any): JQueryXHR;
|
||||
|
||||
param(obj: any): string;
|
||||
param(obj: any, traditional: bool): string;
|
||||
|
||||
post(url: string, data?: any, success?: any, dataType?: any): JQueryXHR;
|
||||
|
||||
/*********
|
||||
CALLBACKS
|
||||
**********/
|
||||
Callbacks(flags?: string): JQueryCallback;
|
||||
|
||||
/****
|
||||
CORE
|
||||
*****/
|
||||
holdReady(hold: bool): any;
|
||||
|
||||
(selector: string, context?: any): JQuery;
|
||||
(element: Element): JQuery;
|
||||
(object: { }): JQuery;
|
||||
(elementArray: Element[]): JQuery;
|
||||
(object: JQuery): JQuery;
|
||||
(func: Function): JQuery;
|
||||
(array: any[]): JQuery;
|
||||
(): JQuery;
|
||||
|
||||
noConflict(removeAll?: bool): Object;
|
||||
|
||||
when(...deferreds: any[]): JQueryPromise;
|
||||
|
||||
/***
|
||||
CSS
|
||||
****/
|
||||
css(e: any, propertyName: string, value?: any);
|
||||
css(e: any, propertyName: any, value?: any);
|
||||
cssHooks: { [key: string]: any; };
|
||||
cssNumber: any;
|
||||
|
||||
/****
|
||||
DATA
|
||||
*****/
|
||||
data(element: Element, key: string, value: any): any;
|
||||
data(element: Element, key: string): any;
|
||||
data(element: Element): any;
|
||||
|
||||
dequeue(element: Element, queueName?: string): any;
|
||||
|
||||
hasData(element: Element): bool;
|
||||
|
||||
queue(element: Element, queueName?: string): any[];
|
||||
queue(element: Element, queueName: string, newQueueOrCallback: any): JQuery;
|
||||
|
||||
removeData(element: Element, name?: string): JQuery;
|
||||
|
||||
/*******
|
||||
EFFECTS
|
||||
********/
|
||||
fx: { tick: () => void; interval: number; stop: () => void; speeds: { slow: number; fast: number; }; off: bool; step: any; };
|
||||
|
||||
/******
|
||||
EVENTS
|
||||
*******/
|
||||
proxy(fn: Function, context: any): any;
|
||||
proxy(context: any, name: any): any;
|
||||
Deferred(): JQueryDeferred;
|
||||
|
||||
/*********
|
||||
INTERNALS
|
||||
**********/
|
||||
error(message: any);
|
||||
|
||||
/*************
|
||||
MISCELLANEOUS
|
||||
**************/
|
||||
expr: any;
|
||||
fn: any; //TODO: Decide how we want to type this
|
||||
isReady: bool;
|
||||
|
||||
/**********
|
||||
PROPERTIES
|
||||
***********/
|
||||
browser: JQueryBrowserInfo;
|
||||
support: JQuerySupport;
|
||||
|
||||
/*********
|
||||
UTILITIES
|
||||
**********/
|
||||
contains(container: Element, contained: Element): bool;
|
||||
|
||||
each(collection: any, callback: (indexInArray: any, valueOfElement: any) => any): any;
|
||||
|
||||
extend(target: any, ...objs: any[]): Object;
|
||||
extend(deep: bool, target: any, ...objs: any[]): Object;
|
||||
|
||||
globalEval(code: string): any;
|
||||
|
||||
grep(array: any[], func: any, invert?: bool): any[];
|
||||
|
||||
inArray(value: any, array: any[], fromIndex?: number): number;
|
||||
|
||||
isArray(obj: any): bool;
|
||||
isEmptyObject(obj: any): bool;
|
||||
isFunction(obj: any): bool;
|
||||
isNumeric(value: any): bool;
|
||||
isPlainObject(obj: any): bool;
|
||||
isWindow(obj: any): bool;
|
||||
isXMLDoc(node: Node): bool;
|
||||
|
||||
makeArray(obj: any): any[];
|
||||
|
||||
map(array: any[], callback: (elementOfArray: any, indexInArray: any) =>any): any[];
|
||||
|
||||
merge(first: any[], second: any[]): any[];
|
||||
|
||||
noop(): any;
|
||||
|
||||
now(): number;
|
||||
|
||||
parseJSON(json: string): Object;
|
||||
|
||||
//FIXME: This should return an XMLDocument
|
||||
parseXML(data: string): any;
|
||||
|
||||
queue(element: Element, queueName: string, newQueue: any[]): JQuery;
|
||||
|
||||
trim(str: string): string;
|
||||
|
||||
type(obj: any): string;
|
||||
|
||||
unique(arr: any[]): any[];
|
||||
}
|
||||
|
||||
/*
|
||||
The jQuery instance members
|
||||
*/
|
||||
interface JQuery {
|
||||
/****
|
||||
AJAX
|
||||
*****/
|
||||
ajaxComplete(handler: any): JQuery;
|
||||
ajaxError(handler: (event: any, jqXHR: any, settings: any, exception: any) => any): JQuery;
|
||||
ajaxSend(handler: (event: any, jqXHR: any, settings: any, exception: any) => any): JQuery;
|
||||
ajaxStart(handler: () => any): JQuery;
|
||||
ajaxStop(handler: () => any): JQuery;
|
||||
ajaxSuccess(handler: (event: any, jqXHR: any, settings: any, exception: any) => any): JQuery;
|
||||
|
||||
load(url: string, data?: any, complete?: any): JQuery;
|
||||
|
||||
serialize(): string;
|
||||
serializeArray(): any[];
|
||||
|
||||
/**********
|
||||
ATTRIBUTES
|
||||
***********/
|
||||
addClass(classNames: string): JQuery;
|
||||
addClass(func: (index: any, currentClass: any) => string): JQuery;
|
||||
|
||||
attr(attributeName: string): string;
|
||||
attr(attributeName: string, value: any): JQuery;
|
||||
attr(map: { [key: string]: any; }): JQuery;
|
||||
attr(attributeName: string, func: (index: any, attr: any) => any): JQuery;
|
||||
|
||||
hasClass(className: string): bool;
|
||||
|
||||
html(): string;
|
||||
html(htmlString: string): JQuery;
|
||||
html(htmlContent: (index: number, oldhtml: string) => string): JQuery;
|
||||
|
||||
prop(propertyName: string): any;
|
||||
prop(propertyName: string, value: any): JQuery;
|
||||
prop(map: any): JQuery;
|
||||
prop(propertyName: string, func: (index: any, oldPropertyValue: any) => any): JQuery;
|
||||
|
||||
removeAttr(attributeName: any): JQuery;
|
||||
|
||||
removeClass(className?: any): JQuery;
|
||||
removeClass(func: (index: any, cls: any) => any): JQuery;
|
||||
|
||||
removeProp(propertyName: any): JQuery;
|
||||
|
||||
toggleClass(className: any, swtch?: bool): JQuery;
|
||||
toggleClass(swtch?: bool): JQuery;
|
||||
toggleClass(func: (index: any, cls: any, swtch: any) => any): JQuery;
|
||||
|
||||
val(): any;
|
||||
val(value: string[]): JQuery;
|
||||
val(value: string): JQuery;
|
||||
val(value: number): JQuery;
|
||||
val(func: (index: any, value: any) => any): JQuery;
|
||||
|
||||
/***
|
||||
CSS
|
||||
****/
|
||||
css(propertyName: string, value?: any): any;
|
||||
css(propertyName: any, value?: any): any;
|
||||
|
||||
height(): number;
|
||||
height(value: number): JQuery;
|
||||
height(value: string): JQuery;
|
||||
height(func: (index: any, height: any) => any): JQuery;
|
||||
|
||||
innerHeight(): number;
|
||||
innerWidth(): number;
|
||||
|
||||
offset(): { left: number; top: number; };
|
||||
offset(coordinates: any): JQuery;
|
||||
offset(func: (index: any, coords: any) => any): JQuery;
|
||||
|
||||
outerHeight(includeMargin?: bool): number;
|
||||
outerWidth(includeMargin?: bool): number;
|
||||
|
||||
position(): { top: number; left: number; };
|
||||
|
||||
scrollLeft(): number;
|
||||
scrollLeft(value: number): JQuery;
|
||||
|
||||
scrollTop(): number;
|
||||
scrollTop(value: number): JQuery;
|
||||
|
||||
width(): number;
|
||||
width(value: number): JQuery;
|
||||
width(value: string): JQuery;
|
||||
width(func: (index: any, height: any) => any): JQuery;
|
||||
|
||||
/****
|
||||
DATA
|
||||
*****/
|
||||
clearQueue(queueName?: string): JQuery;
|
||||
|
||||
data(key: string, value: any): JQuery;
|
||||
data(obj: { [key: string]: any; }): JQuery;
|
||||
data(key?: string): any;
|
||||
|
||||
dequeue(queueName?: string): JQuery;
|
||||
|
||||
removeData(nameOrList?: any): JQuery;
|
||||
|
||||
/********
|
||||
DEFERRED
|
||||
*********/
|
||||
promise(type?: any, target?: any): JQueryPromise;
|
||||
|
||||
/*******
|
||||
EFFECTS
|
||||
********/
|
||||
animate(properties: any, duration?: any, complete?: Function): JQuery;
|
||||
animate(properties: any, duration?: any, easing?: string, complete?: Function): JQuery;
|
||||
animate(properties: any, options: { duration?: any; easing?: string; complete?: Function; step?: Function; queue?: bool; specialEasing?: any; });
|
||||
|
||||
delay(duration: number, queueName?: string): JQuery;
|
||||
|
||||
fadeIn(duration?: any, callback?: any): JQuery;
|
||||
fadeIn(duration?: any, easing?: string, callback?: any): JQuery;
|
||||
|
||||
fadeOut(duration?: any, callback?: any): JQuery;
|
||||
fadeOut(duration?: any, easing?: string, callback?: any): JQuery;
|
||||
|
||||
fadeTo(duration: any, opacity: number, callback?: any): JQuery;
|
||||
fadeTo(duration: any, opacity: number, easing?: string, callback?: any): JQuery;
|
||||
|
||||
fadeToggle(duration?: any, callback?: any): JQuery;
|
||||
fadeToggle(duration?: any, easing?: string, callback?: any): JQuery;
|
||||
|
||||
hide(duration?: any, callback?: any): JQuery;
|
||||
hide(duration?: any, easing?: string, callback?: any): JQuery;
|
||||
|
||||
show(duration?: any, callback?: any): JQuery;
|
||||
show(duration?: any, easing?: string, callback?: any): JQuery;
|
||||
|
||||
slideDown(duration?: any, callback?: any): JQuery;
|
||||
slideDown(duration?: any, easing?: string, callback?: any): JQuery;
|
||||
|
||||
slideToggle(duration?: any, callback?: any): JQuery;
|
||||
slideToggle(duration?: any, easing?: string, callback?: any): JQuery;
|
||||
|
||||
slideUp(duration?: any, callback?: any): JQuery;
|
||||
slideUp(duration?: any, easing?: string, callback?: any): JQuery;
|
||||
|
||||
stop(clearQueue?: bool, jumpToEnd?: bool): JQuery;
|
||||
stop(queue?:any, clearQueue?: bool, jumpToEnd?: bool): JQuery;
|
||||
|
||||
toggle(duration?: any, callback?: any): JQuery;
|
||||
toggle(duration?: any, easing?: string, callback?: any): JQuery;
|
||||
toggle(showOrHide: bool): JQuery;
|
||||
|
||||
/******
|
||||
EVENTS
|
||||
*******/
|
||||
bind(eventType: string, eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
bind(eventType: string, eventData: any, preventBubble:bool): JQuery;
|
||||
bind(eventType: string, preventBubble:bool): JQuery;
|
||||
bind(...events: any[]);
|
||||
|
||||
blur(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
blur(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
change(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
change(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
click(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
click(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
dblclick(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
dblclick(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
delegate(selector: any, eventType: string, handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
focus(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
focus(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
focusin(eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
focusin(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
focusout(eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
focusout(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
hover(handlerIn: (eventObject: JQueryEventObject) => any, handlerOut: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
hover(handlerInOut: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
keydown(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
keydown(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
keypress(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
keypress(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
keyup(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
keyup(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
load(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
load(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
mousedown(): JQuery;
|
||||
mousedown(eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
mousedown(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
mouseevent(eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
mouseevent(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
mouseenter(): JQuery;
|
||||
mouseenter(eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
mouseenter(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
mouseleave(): JQuery;
|
||||
mouseleave(eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
mouseleave(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
mousemove(): JQuery;
|
||||
mousemove(eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
mousemove(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
mouseout(): JQuery;
|
||||
mouseout(eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
mouseout(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
mouseover(): JQuery;
|
||||
mouseover(eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
mouseover(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
mouseup(): JQuery;
|
||||
mouseup(eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
mouseup(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
off(events?: string, selector?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
off(eventsMap: { [key: string]: any; }, selector?: any): JQuery;
|
||||
|
||||
on(events: string, selector?: any, data?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
on(eventsMap: { [key: string]: any; }, selector?: any, data?: any): JQuery;
|
||||
|
||||
one(events: string, selector?: any, data?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
one(eventsMap: { [key: string]: any; }, selector?: any, data?: any): JQuery;
|
||||
|
||||
ready(handler: any): JQuery;
|
||||
|
||||
resize(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
resize(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
scroll(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
scroll(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
select(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
select(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
submit(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
submit(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
trigger(eventType: string, ...extraParameters: any[]): JQuery;
|
||||
trigger(event: JQueryEventObject): JQuery;
|
||||
|
||||
triggerHandler(eventType: string, ...extraParameters: any[]): Object;
|
||||
|
||||
unbind(eventType?: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
unbind(eventType: string, fls: bool): JQuery;
|
||||
unbind(evt: any): JQuery;
|
||||
|
||||
undelegate(): JQuery;
|
||||
undelegate(selector: any, eventType: string, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
undelegate(selector: any, events: any): JQuery;
|
||||
undelegate(namespace: string): JQuery;
|
||||
|
||||
unload(eventData?: any, handler?: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
unload(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
/*********
|
||||
INTERNALS
|
||||
**********/
|
||||
|
||||
context: Element;
|
||||
jquery: string;
|
||||
|
||||
error(handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
error(eventData: any, handler: (eventObject: JQueryEventObject) => any): JQuery;
|
||||
|
||||
pushStack(elements: any[]): JQuery;
|
||||
pushStack(elements: any[], name: any, arguments: any): JQuery;
|
||||
|
||||
/************
|
||||
MANIPULATION
|
||||
*************/
|
||||
after(...content: any[]): JQuery;
|
||||
after(func: (index: any) => any);
|
||||
|
||||
append(...content: any[]): JQuery;
|
||||
append(func: (index: any, html: any) => any);
|
||||
|
||||
appendTo(target: any): JQuery;
|
||||
|
||||
before(...content: any[]): JQuery;
|
||||
before(func: (index: any) => any);
|
||||
|
||||
clone(withDataAndEvents?: bool, deepWithDataAndEvents?: bool): JQuery;
|
||||
|
||||
detach(selector?: any): JQuery;
|
||||
|
||||
empty(): JQuery;
|
||||
|
||||
insertAfter(target: any): JQuery;
|
||||
insertBefore(target: any): JQuery;
|
||||
|
||||
prepend(...content: any[]): JQuery;
|
||||
prepend(func: (index: any, html: any) =>any): JQuery;
|
||||
|
||||
prependTo(target: any): JQuery;
|
||||
|
||||
remove(selector?: any): JQuery;
|
||||
|
||||
replaceAll(target: any): JQuery;
|
||||
|
||||
replaceWith(func: any): JQuery;
|
||||
|
||||
text(): string;
|
||||
text(textString: any): JQuery;
|
||||
text(textString: (index: number, text: string) => string): JQuery;
|
||||
|
||||
toArray(): any[];
|
||||
|
||||
unwrap(): JQuery;
|
||||
|
||||
wrap(wrappingElement: any): JQuery;
|
||||
wrap(func: (index: any) =>any): JQuery;
|
||||
|
||||
wrapAll(wrappingElement: any): JQuery;
|
||||
|
||||
wrapInner(wrappingElement: any): JQuery;
|
||||
wrapInner(func: (index: any) =>any): JQuery;
|
||||
|
||||
/*************
|
||||
MISCELLANEOUS
|
||||
**************/
|
||||
each(func: (index: any, elem: Element) => any);
|
||||
|
||||
get(index?: number): any;
|
||||
|
||||
index(): number;
|
||||
index(selector: string): number;
|
||||
index(element: any): number;
|
||||
|
||||
/**********
|
||||
PROPERTIES
|
||||
***********/
|
||||
length: number;
|
||||
[x: string]: HTMLElement;
|
||||
[x: number]: HTMLElement;
|
||||
|
||||
/**********
|
||||
TRAVERSING
|
||||
***********/
|
||||
add(selector: string, context?: any): JQuery;
|
||||
add(...elements: any[]): JQuery;
|
||||
add(html: string): JQuery;
|
||||
add(obj: JQuery): JQuery;
|
||||
|
||||
andSelf(): JQuery;
|
||||
|
||||
children(selector?: any): JQuery;
|
||||
|
||||
closest(selector: string): JQuery;
|
||||
closest(selector: string, context?: Element): JQuery;
|
||||
closest(obj: JQuery): JQuery;
|
||||
closest(element: any): JQuery;
|
||||
closest(selectors: any, context?: Element): any[];
|
||||
|
||||
contents(): JQuery;
|
||||
|
||||
end(): JQuery;
|
||||
|
||||
eq(index: number): JQuery;
|
||||
|
||||
filter(selector: string): JQuery;
|
||||
filter(func: (index: any) =>any): JQuery;
|
||||
filter(element: any): JQuery;
|
||||
filter(obj: JQuery): JQuery;
|
||||
|
||||
find(selector: string): JQuery;
|
||||
find(element: any): JQuery;
|
||||
find(obj: JQuery): JQuery;
|
||||
|
||||
first(): JQuery;
|
||||
|
||||
has(selector: string): JQuery;
|
||||
has(contained: Element): JQuery;
|
||||
|
||||
is(selector: string): bool;
|
||||
is(func: (index: any) =>any): bool;
|
||||
is(element: any): bool;
|
||||
is(obj: JQuery): bool;
|
||||
|
||||
last(): JQuery;
|
||||
|
||||
map(callback: (index: any, domElement: Element) =>any): JQuery;
|
||||
|
||||
next(selector?: string): JQuery;
|
||||
|
||||
nextAll(selector?: string): JQuery;
|
||||
|
||||
nextUntil(selector?: string, filter?: string): JQuery;
|
||||
nextUntil(element?: Element, filter?: string): JQuery;
|
||||
|
||||
not(selector: string): JQuery;
|
||||
not(func: (index: any) =>any): JQuery;
|
||||
not(element: any): JQuery;
|
||||
not(obj: JQuery): JQuery;
|
||||
|
||||
offsetParent(): JQuery;
|
||||
|
||||
parent(selector?: string): JQuery;
|
||||
|
||||
parents(selector?: string): JQuery;
|
||||
|
||||
parentsUntil(selector?: string, filter?: string): JQuery;
|
||||
parentsUntil(element?: Element, filter?: string): JQuery;
|
||||
|
||||
prev(selector?: string): JQuery;
|
||||
|
||||
prevAll(selector?: string): JQuery;
|
||||
|
||||
prevUntil(selector?: string, filter?:string): JQuery;
|
||||
prevUntil(element?: Element, filter?:string): JQuery;
|
||||
|
||||
siblings(selector?: string): JQuery;
|
||||
|
||||
slice(start: number, end?: number): JQuery;
|
||||
|
||||
/*********
|
||||
UTILITIES
|
||||
**********/
|
||||
|
||||
queue(queueName?: string): any[];
|
||||
queue(queueName: string, newQueueOrCallback: any): JQuery;
|
||||
queue(newQueueOrCallback: any): JQuery;
|
||||
}
|
||||
|
||||
declare var jQuery: JQueryStatic;
|
||||
declare var $: JQueryStatic;
|
||||
Vendored
-44
@@ -1,44 +0,0 @@
|
||||
// BDD
|
||||
declare function describe(cb: () => void);
|
||||
declare function describe(cb: (done:() => void) => void);
|
||||
declare function describe(title: string, cb: () => void);
|
||||
declare function describe(title: string, cb: (done:() => void) => void);
|
||||
|
||||
declare function it(cb: () => void);
|
||||
declare function it(cb: (done:() => void) => void);
|
||||
declare function it(title: string, cb: () => void);
|
||||
declare function it(title: string, cb: (done:() => void) => void);
|
||||
|
||||
declare function before(cb: () => void);
|
||||
declare function before(cb: (done:() => void) => void);
|
||||
declare function before(title: string, cb: () => void);
|
||||
declare function before(title: string, cb: (done:() => void) => void);
|
||||
|
||||
declare function after(cb: () => void);
|
||||
declare function after(cb: (done:() => void) => void);
|
||||
declare function after(title: string, cb: () => void);
|
||||
declare function after(title: string, cb: (done:() => void) => void);
|
||||
|
||||
declare function beforeEach(cb: () => void);
|
||||
declare function beforeEach(cb: (done:() => void) => void);
|
||||
declare function beforeEach(title: string, cb: () => void);
|
||||
declare function beforeEach(title: string, cb: (done:() => void) => void);
|
||||
|
||||
declare function afterEach(cb: () => void);
|
||||
declare function afterEach(cb: (done:() => void) => void);
|
||||
declare function afterEach(title: string, cb: () => void);
|
||||
declare function afterEach(title: string, cb: (done:() => void) => void);
|
||||
|
||||
|
||||
// TDD
|
||||
declare function suite(title: string, cb: () => void);
|
||||
declare function test(title: string, cb: () => void);
|
||||
declare function test(title: string, cb: (done:() => void) => void);
|
||||
declare function setup(title: string, cb: () => void);
|
||||
declare function teardown(title: string, cb: () => void);
|
||||
|
||||
declare function suite(cb: () => void);
|
||||
declare function test(cb: () => void);
|
||||
declare function test(cb: (done:() => void) => void);
|
||||
declare function setup(cb: () => void);
|
||||
declare function teardown(cb: () => void);
|
||||
Vendored
-33
@@ -1,33 +0,0 @@
|
||||
/// <reference path="jquery.d.ts" />
|
||||
|
||||
interface spy {
|
||||
called: bool;
|
||||
getCall(x: number): any;
|
||||
fakeServer: ISinonFakeServer;
|
||||
calledOnce: bool;
|
||||
calledWith(x: any, message: string): bool;
|
||||
}
|
||||
|
||||
interface IJsonReponse {
|
||||
responseCode: number;
|
||||
responseHeaders: any;
|
||||
responseString: string;
|
||||
}
|
||||
|
||||
interface ISinonFakeServer {
|
||||
create(): any;
|
||||
restore(): void;
|
||||
respondWith(postType: string, relativeUrl: string, x: any): any;
|
||||
respond(): any;
|
||||
}
|
||||
|
||||
declare module sinon {
|
||||
export function spy(): spy;
|
||||
export function spy(fn: Function): spy;
|
||||
//export function spy(jquery: JQueryStatic , x: string): spy;
|
||||
export function spy(jquery: JQueryStatic , x: any): spy;
|
||||
export function spy(obj: Object , methodName: string): spy;
|
||||
export var fakeServer: ISinonFakeServer;
|
||||
export function stub(x: any, name: string);
|
||||
export function useFakeTimers(): void;
|
||||
}
|
||||
@@ -149,7 +149,7 @@ test( 'jQuery.param.sorted', function() {
|
||||
|
||||
expect( tests.length * 2 + 6 );
|
||||
|
||||
$.each( tests, function(i,test){
|
||||
$.each( tests, function(i,test: any){
|
||||
var unsorted = $.param( test.obj, test.traditional ),
|
||||
sorted = $.param.sorted( test.obj, test.traditional );
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -5,7 +5,7 @@
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts" />
|
||||
|
||||
module JQueryBbq {
|
||||
declare module JQueryBbq {
|
||||
|
||||
interface JQuery {
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,400 @@
|
||||
///<reference path="jquery.pickadate.d.ts" />
|
||||
|
||||
/*
|
||||
* Date picker tests
|
||||
* From http://amsul.ca/pickadate.js/date.htm
|
||||
*/
|
||||
|
||||
$('.datepicker').pickadate();
|
||||
|
||||
$('.datepicker').pickadate({
|
||||
weekdaysShort: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
|
||||
showMonthsShort: true
|
||||
});
|
||||
|
||||
$('.datepicker').pickadate({
|
||||
today: '',
|
||||
clear: 'Clear selection'
|
||||
});
|
||||
|
||||
// Extend the default picker options for all instances.
|
||||
$.extend($.fn.pickadate.defaults, {
|
||||
monthsFull: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
|
||||
weekdaysShort: ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'],
|
||||
today: 'aujourd\'hui',
|
||||
clear: 'effacer',
|
||||
formatSubmit: 'yyyy/mm/dd'
|
||||
});
|
||||
|
||||
// Or, pass the months and weekdays as an array for each invocation.
|
||||
$('.datepicker').pickadate({
|
||||
monthsFull: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
|
||||
weekdaysShort: ['Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'],
|
||||
today: 'aujourd\'hui',
|
||||
clear: 'effacer',
|
||||
formatSubmit: 'yyyy/mm/dd'
|
||||
});
|
||||
|
||||
$('.datepicker').pickadate({
|
||||
// Escape any "rule" characters with an exclamation mark (!).
|
||||
format: 'You selecte!d: dddd, dd mmm, yyyy',
|
||||
formatSubmit: 'yyyy/mm/dd',
|
||||
hiddenSuffix: '--submit'
|
||||
});
|
||||
|
||||
$('.datepicker').pickadate({
|
||||
selectYears: true,
|
||||
selectMonths: true
|
||||
});
|
||||
|
||||
$('.datepicker').pickadate({
|
||||
// `true` defaults to 10.
|
||||
selectYears: 4
|
||||
});
|
||||
|
||||
$('.datepicker').pickadate({
|
||||
firstDay: 1
|
||||
});
|
||||
|
||||
$('.datepicker').pickadate({
|
||||
min: new Date(2013, 3, 20),
|
||||
max: new Date(2013, 7, 14)
|
||||
});
|
||||
|
||||
$('.datepicker').pickadate({
|
||||
min: [2013, 3, 20],
|
||||
max: [2013, 7, 14]
|
||||
});
|
||||
|
||||
$('.datepicker').pickadate({
|
||||
// An integer (positive/negative) sets it relative to today.
|
||||
min: -15,
|
||||
// `true` sets it to today. `false` removes any limits.
|
||||
max: true
|
||||
});
|
||||
|
||||
$('.datepicker').pickadate({
|
||||
disable: [
|
||||
[2013, 3, 3],
|
||||
[2013, 3, 12],
|
||||
[2013, 3, 20],
|
||||
[2013, 3, 29]
|
||||
]
|
||||
});
|
||||
|
||||
$('.datepicker').pickadate({
|
||||
disable: [
|
||||
1, 4, 7
|
||||
]
|
||||
});
|
||||
|
||||
$('.datepicker').pickadate({
|
||||
disable: [
|
||||
true,
|
||||
1, 4, 7,
|
||||
[2013, 3, 3],
|
||||
[2013, 3, 12],
|
||||
[2013, 3, 20],
|
||||
[2013, 3, 29]
|
||||
]
|
||||
});
|
||||
|
||||
$('.datepicker').pickadate({
|
||||
onStart: function () {
|
||||
console.log('Hello there :)')
|
||||
},
|
||||
onRender: function () {
|
||||
console.log('Whoa.. rendered anew')
|
||||
},
|
||||
onOpen: function () {
|
||||
console.log('Opened up')
|
||||
},
|
||||
onClose: function () {
|
||||
console.log('Closed now')
|
||||
},
|
||||
onStop: function () {
|
||||
console.log('See ya.')
|
||||
},
|
||||
onSet: function (event) {
|
||||
console.log('Just set stuff:', event)
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* Time picker tests
|
||||
* From http://amsul.ca/pickadate.js/time.htm
|
||||
*/
|
||||
|
||||
$('.timepicker').pickatime();
|
||||
|
||||
$('.timepicker').pickatime({
|
||||
clear: ''
|
||||
});
|
||||
|
||||
$('.timepicker').pickatime({
|
||||
// Escape any "rule" characters with an exclamation mark (!).
|
||||
format: 'T!ime selected: h:i a',
|
||||
formatLabel: '<b>h</b>:i <!i>a</!i>',
|
||||
formatSubmit: 'HH:i',
|
||||
hiddenSuffix: '--submit'
|
||||
});
|
||||
|
||||
$('.timepicker').pickatime({
|
||||
formatLabel: function (time: TimePickerItemObject) {
|
||||
var hours = (time.pick - this.get('now').pick) / 60,
|
||||
label = hours < 0 ? ' !hours to now' : hours > 0 ? ' !hours from now' : 'now'
|
||||
return 'h:i a <sm!all>' + (hours ? Math.abs(hours).toString() : '') + label + '</sm!all>'
|
||||
}
|
||||
});
|
||||
|
||||
$('.datepicker').pickadate({
|
||||
interval: 150
|
||||
});
|
||||
|
||||
$('.timepicker').pickatime({
|
||||
min: [7, 30],
|
||||
max: [14, 0]
|
||||
});
|
||||
|
||||
$('.timepicker').pickatime({
|
||||
// An integer (positive/negative) sets it as intervals relative from now.
|
||||
min: -5,
|
||||
// `true` sets it to now. `false` removes any limits.
|
||||
max: true
|
||||
});
|
||||
|
||||
$('.timepicker').pickatime({
|
||||
disable: [
|
||||
[0, 30],
|
||||
[2, 0],
|
||||
[8, 30],
|
||||
[9, 0]
|
||||
]
|
||||
});
|
||||
|
||||
$('.timepicker').pickatime({
|
||||
disable: [
|
||||
3, 5, 7
|
||||
]
|
||||
});
|
||||
|
||||
$('.timepicker').pickatime({
|
||||
disable: [
|
||||
true,
|
||||
3, 5, 7,
|
||||
[0, 30],
|
||||
[2, 0],
|
||||
[8, 30],
|
||||
[9, 0]
|
||||
]
|
||||
});
|
||||
|
||||
$('.timepicker').pickatime({
|
||||
onStart: function () {
|
||||
console.log('Hello there :)')
|
||||
},
|
||||
onRender: function () {
|
||||
console.log('Whoa.. rendered anew')
|
||||
},
|
||||
onOpen: function () {
|
||||
console.log('Opened up')
|
||||
},
|
||||
onClose: function () {
|
||||
console.log('Closed now')
|
||||
},
|
||||
onStop: function () {
|
||||
console.log('See ya.')
|
||||
},
|
||||
onSet: function (event) {
|
||||
console.log('Just set stuff:', event)
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
* API tests
|
||||
* From http://amsul.ca/pickadate.js/api.htm
|
||||
*/
|
||||
|
||||
var $input = $('.datepicker').pickadate();
|
||||
|
||||
// Use the picker object directly.
|
||||
var picker = $input.pickadate('picker');
|
||||
|
||||
picker.open().clear().close();
|
||||
|
||||
picker.open();
|
||||
picker.close();
|
||||
picker.close(true);
|
||||
|
||||
picker.open(false)
|
||||
$(document).on('click', function () {
|
||||
picker.close()
|
||||
});
|
||||
|
||||
picker.start();
|
||||
picker.stop();
|
||||
picker.render();
|
||||
picker.clear();
|
||||
|
||||
picker.get() // Short for `picker.get('value')`
|
||||
|
||||
picker.get('select');
|
||||
picker.get('select', 'yyyy/mm/dd');
|
||||
|
||||
picker.get('highlight');
|
||||
picker.get('highlight', 'yyyy/mm/dd');
|
||||
|
||||
picker.get('view');
|
||||
|
||||
picker.get('min');
|
||||
picker.get('min', 'yyyy/mm/dd');
|
||||
picker.get('max');
|
||||
picker.get('max', 'yyyy/mm/dd');
|
||||
|
||||
picker.get('open');
|
||||
picker.get('start');
|
||||
picker.get('id');
|
||||
picker.get('disable');
|
||||
|
||||
picker.set('clear');
|
||||
|
||||
// Using arrays formatted as [YEAR,MONTH,DATE].
|
||||
picker.set('select', [2013, 3, 20]);
|
||||
|
||||
// Using JavaScript Date objects.
|
||||
picker.set('select', new Date(2013,03,20));
|
||||
|
||||
// Using positive integers as UNIX timestamps.
|
||||
picker.set('select', 1365961912346);
|
||||
|
||||
// Using arrays formatted as [HOUR,MINUTE].
|
||||
picker.set('select', [3, 0]);
|
||||
|
||||
// Using positive integers as minutes.
|
||||
picker.set('select', 540);
|
||||
|
||||
// Using arrays formatted as [YEAR,MONTH,DATE].
|
||||
picker.set('highlight', [2013, 3, 20]);
|
||||
|
||||
// Using JavaScript Date objects.
|
||||
picker.set('highlight', new Date(2013,7,14));
|
||||
|
||||
// Using positive integers as UNIX timestamps.
|
||||
picker.set('highlight', 1365961912346);
|
||||
|
||||
// Using arrays formatted as [HOUR,MINUTE].
|
||||
picker.set('highlight', [15, 30]);
|
||||
|
||||
// Using positive integers as minutes.
|
||||
picker.set('highlight', 1080);
|
||||
|
||||
// Using arrays formatted as [YEAR,MONTH,DATE].
|
||||
picker.set('view', [2000, 3, 20]);
|
||||
|
||||
// Using JavaScript Date objects.
|
||||
picker.set('view', new Date(1988,7,14));
|
||||
|
||||
// Using positive integers as UNIX timestamps.
|
||||
picker.set('view', 1587355200000);
|
||||
|
||||
// Using arrays formatted as [HOUR,MINUTE].
|
||||
picker.set('view', [15, 30]);
|
||||
|
||||
// Using positive integers as minutes.
|
||||
picker.set('view', 1080);
|
||||
|
||||
// Using arrays formatted as [YEAR,MONTH,DATE].
|
||||
picker.set('min', [2013, 3, 20]);
|
||||
|
||||
// Using JavaScript Date objects.
|
||||
picker.set('min', new Date(2013,7,14));
|
||||
|
||||
// Using integers as days relative to today.
|
||||
picker.set('min', -4);
|
||||
|
||||
// Using `true` for "today".
|
||||
picker.set('min', true);
|
||||
|
||||
// Using `false` to remove.
|
||||
picker.set('min', false);
|
||||
|
||||
// Using arrays formatted as [HOUR,MINUTE].
|
||||
picker.set('min', [15, 30]);
|
||||
|
||||
// Using integers as intervals relative from now.
|
||||
picker.set('min', -4);
|
||||
|
||||
// Using `true` for "now".
|
||||
picker.set('min', true);
|
||||
|
||||
// Using `false` to remove.
|
||||
picker.set('min', false);
|
||||
|
||||
// Using arrays formatted as [YEAR,MONTH,DATE].
|
||||
picker.set('max', [2013, 3, 20]);
|
||||
|
||||
// Using JavaScript Date objects.
|
||||
picker.set('max', new Date(2013,7,14));
|
||||
|
||||
// Using integers as days relative to today.
|
||||
picker.set('max', 4);
|
||||
|
||||
// Using `true` for "today".
|
||||
picker.set('max', true);
|
||||
|
||||
// Using `false` to remove.
|
||||
picker.set('max', false);
|
||||
|
||||
// Using arrays formatted as [HOUR,MINUTE].
|
||||
picker.set('max', [15, 30]);
|
||||
|
||||
// Using integers as intervals relative from now.
|
||||
picker.set('max', 4);
|
||||
|
||||
// Using `true` for "now".
|
||||
picker.set('max', true);
|
||||
|
||||
// Using `false` to remove.
|
||||
picker.set('max', false);
|
||||
|
||||
picker.on('open', function () {
|
||||
console.log('Opened.. and here I am!');
|
||||
});
|
||||
|
||||
picker.on({
|
||||
open: function () {
|
||||
console.log('Opened.. and here I am!');
|
||||
},
|
||||
close: function () {
|
||||
console.log('Closed.. and here I am!');
|
||||
}
|
||||
});
|
||||
|
||||
$('.datepicker').pickadate({
|
||||
onOpen: function () {
|
||||
console.log('Opened up!')
|
||||
},
|
||||
onClose: function () {
|
||||
console.log('Closed now')
|
||||
},
|
||||
onRender: function () {
|
||||
console.log('Just rendered anew')
|
||||
},
|
||||
onStart: function () {
|
||||
console.log('Hello there :)')
|
||||
},
|
||||
onStop: function () {
|
||||
console.log('See ya')
|
||||
},
|
||||
onSet: function (event) {
|
||||
console.log('Set stuff:', event)
|
||||
}
|
||||
});
|
||||
|
||||
picker.on('open', function () {
|
||||
console.log('Didn\'t open.. yet here I am!');
|
||||
})
|
||||
picker.trigger('open');
|
||||
|
||||
picker.$node;
|
||||
picker.$root;
|
||||
+375
@@ -0,0 +1,375 @@
|
||||
// Type definitions for pickadate.js 3.0.5
|
||||
// Project: https://github.com/amsul/pickadate.js
|
||||
// Definitions by: Theodore Brown <https://github.com/theodorejb/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
///<reference path="../jquery/jquery.d.ts" />
|
||||
|
||||
interface pickadateOptions {
|
||||
// Strings and translations
|
||||
monthsFull?: string[]; // default 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'
|
||||
monthsShort?: string[]; // default 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
|
||||
weekdaysFull?: string[]; // default 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'
|
||||
weekdaysShort?: string[]; // default 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
|
||||
showMonthsShort?: boolean;
|
||||
showWeekdaysFull?: boolean;
|
||||
|
||||
// Buttons
|
||||
today?: string; // default 'Today'
|
||||
clear?: string; // default 'Clear'
|
||||
|
||||
// Formats
|
||||
format?: string; // default 'd mmmm, yyyy'
|
||||
formatSubmit?: string; // e.g. 'yyyy/mm/dd'
|
||||
hiddenSuffix?: string; // default '_submit'
|
||||
|
||||
// Dropdown selectors
|
||||
selectYears?: any; // Specify the number of years selectable using an even integer - half before and half after the year in focus:
|
||||
selectMonths?: boolean;
|
||||
|
||||
// First day of the week
|
||||
firstDay?: any; // The first day of the week can be set to either Sunday or Monday. Anything truth-y sets it as Monday and anything false-y as Sunday
|
||||
|
||||
// Date limits
|
||||
min?: any; // date object, array formatted as [YEAR,MONTH,DATE], or dates relative to today using integers or a boolean (`true` sets it to today. `false` removes any limits).
|
||||
max?: any;
|
||||
|
||||
// Disable dates
|
||||
disable?: any[]; // arrays formatted as [YEAR,MONTH,DATE] or integers representing days of the week (from 1 to 7). Switch to whitelist by setting first item in collection to `true`.
|
||||
|
||||
// Events
|
||||
onStart?: (event: any) => void;
|
||||
onRender?: (event: any) => void;
|
||||
onOpen?: (event: any) => void;
|
||||
onClose?: (event: any) => void;
|
||||
onSet?: (event: any) => void;
|
||||
onStop?: (event: any) => void;
|
||||
|
||||
// Classes
|
||||
klass?: {
|
||||
|
||||
// The element states
|
||||
input?: string; // default 'picker__input'
|
||||
active?: string; // default 'picker__input--active'
|
||||
|
||||
// The root picker and states
|
||||
picker?: string; // default 'picker'
|
||||
opened?: string; // default 'picker--opened'
|
||||
focused?: string; // default 'picker--focused'
|
||||
|
||||
// The picker holder
|
||||
holder?: string; // default 'picker__holder'
|
||||
|
||||
// The picker frame, wrapper, and box
|
||||
frame?: string; // default 'picker__frame'
|
||||
wrap?: string; // default 'picker__wrap'
|
||||
box?: string; // default 'picker__box'
|
||||
|
||||
// The picker header
|
||||
header?: string; // default 'picker__header'
|
||||
|
||||
// Month navigation
|
||||
navPrev?: string; // default 'picker__nav--prev'
|
||||
navNext?: string; // default 'picker__nav--next'
|
||||
navDisabled?: string; // default 'picker__nav--disabled'
|
||||
|
||||
// Month & year labels
|
||||
month?: string; // default 'picker__month'
|
||||
year?: string; // default 'picker__year'
|
||||
|
||||
// Month & year dropdowns
|
||||
selectMonth?: string; // default 'picker__select--month'
|
||||
selectYear?: string; // default 'picker__select--year'
|
||||
|
||||
// Table of dates
|
||||
table?: string; // default 'picker__table'
|
||||
|
||||
// Weekday labels
|
||||
weekdays?: string; // default 'picker__weekday'
|
||||
|
||||
// Day states
|
||||
day?: string; // default 'picker__day'
|
||||
disabled?: string; // default 'picker__day--disabled'
|
||||
selected?: string // default 'picker__day--selected'
|
||||
highlighted?: string // default 'picker__day--highlighted'
|
||||
now?: string; // default 'picker__day--today'
|
||||
infocus?: string; // default 'picker__day--infocus'
|
||||
outfocus?: string; // default 'picker__day--outfocus'
|
||||
|
||||
// The picker footer
|
||||
footer?: string; // default 'picker__footer'
|
||||
|
||||
// Today & clear buttons
|
||||
buttonClear?: string; // default 'picker__button--clear'
|
||||
buttonToday?: string; // default 'picker__button--today'
|
||||
}
|
||||
}
|
||||
|
||||
interface pickatimeOptions {
|
||||
// Translations and clear button
|
||||
clear?: string; // default 'Clear'
|
||||
|
||||
// Formats
|
||||
format?: string; // default 'h:i A'
|
||||
formatLabel?: any;
|
||||
formatSubmit?: string;
|
||||
hiddenSuffix?: string; // default '_submit'
|
||||
|
||||
// Time intervals
|
||||
interval?: number; // interval in minutes. default 30.
|
||||
|
||||
// Time limits
|
||||
min?: any; // array formatted as [HOUR,MINUTE], or as times relative to now using integers or a boolean (`true` sets it to now, `false` removes any limits).
|
||||
max?: any;
|
||||
|
||||
// Disable times
|
||||
disable?: any[]; // arrays formatted as [HOUR,MINUTE] or integers representing hours (from 0 to 23). Switch to whitelist by setting true as the first item in the collection.
|
||||
|
||||
// Events
|
||||
onStart?: (event: any) => void;
|
||||
onRender?: (event: any) => void;
|
||||
onOpen?: (event: any) => void;
|
||||
onClose?: (event: any) => void;
|
||||
onSet?: (event: any) => void;
|
||||
onStop?: (event: any) => void;
|
||||
|
||||
// Classes
|
||||
klass?: {
|
||||
|
||||
// The element states
|
||||
input?: string; // default 'picker__input'
|
||||
active?: string; // default 'picker__input--active'
|
||||
|
||||
// The root picker and states
|
||||
picker?: string; // default 'picker picker--time'
|
||||
opened?: string; // default 'picker--opened'
|
||||
focused?: string; // default 'picker--focused'
|
||||
|
||||
// The picker holder
|
||||
holder?: string; // default 'picker__holder'
|
||||
|
||||
// The picker frame, wrapper, and box
|
||||
frame?: string; // default 'picker__frame'
|
||||
wrap?: string; // default 'picker__wrap'
|
||||
box?: string; // default 'picker__box'
|
||||
|
||||
// List of times
|
||||
list?: string; // default 'picker__list'
|
||||
listItem?: string; // default 'picker__list-item'
|
||||
|
||||
// Time states
|
||||
disabled?: string; // default 'picker__list-item--disabled'
|
||||
selected?: string; // default 'picker__list-item--selected'
|
||||
highlighted?: string; // default 'picker__list-item--highlighted'
|
||||
viewset?: string; // default 'picker__list-item--viewset'
|
||||
now?: string; // default 'picker__list-item--now'
|
||||
|
||||
// Clear button
|
||||
buttonClear?: string; // default 'picker__button--clear'
|
||||
}
|
||||
}
|
||||
|
||||
interface PickerItemObject {
|
||||
/** The "pick" value used for comparisons. */
|
||||
pick: number;
|
||||
}
|
||||
|
||||
interface DatePickerItemObject extends PickerItemObject {
|
||||
/** The full year. */
|
||||
year: number;
|
||||
|
||||
/** The month with zero-as-index. */
|
||||
month: number;
|
||||
|
||||
/** The date of the month. */
|
||||
date: number;
|
||||
|
||||
/** The day of the week with zero-as-index. */
|
||||
day: number;
|
||||
|
||||
/** The underlying JavaScript Date object. */
|
||||
obj: Date;
|
||||
}
|
||||
|
||||
interface TimePickerItemObject extends PickerItemObject {
|
||||
/** Hour of the day from 0 to 23. */
|
||||
hour: number;
|
||||
|
||||
/** The minutes of the hour from 0 to 59 (based on the interval). */
|
||||
mins: number;
|
||||
}
|
||||
|
||||
interface CallbackObject {
|
||||
open?: () => void;
|
||||
close?: () => void;
|
||||
render?: () => void;
|
||||
start?: () => void;
|
||||
stop?: () => void;
|
||||
set?: () => void;
|
||||
}
|
||||
|
||||
interface SetThings {
|
||||
clear?;
|
||||
select?: any;
|
||||
highlight?: any;
|
||||
view?: any;
|
||||
min?: any;
|
||||
max?: any;
|
||||
disable?: any;
|
||||
enable?: any;
|
||||
}
|
||||
|
||||
interface TimePickerSetThings extends SetThings {
|
||||
interval?: any;
|
||||
}
|
||||
|
||||
interface PickerObject {
|
||||
/** The picker's relative input element wrapped as a jQuery object. */
|
||||
$node: JQuery;
|
||||
|
||||
/** The picker's relative root holder element wrapped as a jQuery object. */
|
||||
$root: JQuery;
|
||||
}
|
||||
|
||||
interface DatePickerObject extends PickerObject {
|
||||
open(withoutFocus?: boolean): DatePickerObject;
|
||||
close(withFocus?: boolean): DatePickerObject;
|
||||
|
||||
/** Rebuild the picker. */
|
||||
start(): DatePickerObject;
|
||||
|
||||
/** Destroy the picker. */
|
||||
stop(): DatePickerObject;
|
||||
|
||||
/** Refresh the picker after adding something to the holder. */
|
||||
render(): DatePickerObject;
|
||||
|
||||
/** Clear the value in the picker's input element. */
|
||||
clear(): DatePickerObject;
|
||||
|
||||
/** Get the properties, objects, and states that make up the current state of the picker. */
|
||||
get(thing: string): any;
|
||||
|
||||
/** Returns the string value of the picker's input element. */
|
||||
get(thing?: 'value'): string;
|
||||
|
||||
/** Returns the item object that is visually selected. */
|
||||
get(thing: 'select'): DatePickerItemObject;
|
||||
|
||||
/** Returns the item object that is visually highlighted. */
|
||||
get(thing: 'highlight'): DatePickerItemObject;
|
||||
|
||||
/** Returns the item object that sets the current view. */
|
||||
get(thing: 'view'): DatePickerItemObject;
|
||||
|
||||
/** Returns the item object that limits the picker's lower range. */
|
||||
get(thing: 'min'): DatePickerItemObject;
|
||||
|
||||
/** Returns the item object that limits the picker's upper range. */
|
||||
get(thing: 'max'): DatePickerItemObject;
|
||||
|
||||
/** Returns a boolean value of whether the picker is open or not. */
|
||||
get(thing: 'open'): boolean;
|
||||
|
||||
/** Returns a boolean value of whether the picker has started or not. */
|
||||
get(thing: 'start'): boolean;
|
||||
|
||||
/** Returns a unique 9-digit integer that is the ID of the picker. */
|
||||
get(thing: 'id'): number;
|
||||
|
||||
/** Returns an array of items that determine which item objects to disable on the picker. */
|
||||
get(thing: 'disable'): any[];
|
||||
|
||||
/** Returns a formatted string for the item object specified by `thing` */
|
||||
get(thing: string, format: string): string;
|
||||
|
||||
/** Set the properties, objects, and states to change the state of the picker. */
|
||||
set(thing: string, value?: any): DatePickerObject;
|
||||
set(things: SetThings): DatePickerObject;
|
||||
|
||||
/** Bind callbacks to get fired off when the relative picker method is called. */
|
||||
on(methodName, callback: () => void ): DatePickerObject;
|
||||
|
||||
/** Bind multiple callbacks at once to get fired off when the relative picker method is called. */
|
||||
on(callbackObject: CallbackObject): DatePickerObject;
|
||||
|
||||
/** Trigger callbacks that have been queued up using the the on method. */
|
||||
trigger(event: string): DatePickerObject;
|
||||
}
|
||||
|
||||
interface TimePickerObject extends PickerObject {
|
||||
open(withoutFocus?: boolean): TimePickerObject;
|
||||
close(withFocus?: boolean): TimePickerObject;
|
||||
|
||||
/** Rebuild the picker. */
|
||||
start(): TimePickerObject;
|
||||
|
||||
/** Destroy the picker. */
|
||||
stop(): TimePickerObject;
|
||||
|
||||
/** Refresh the picker after adding something to the holder. */
|
||||
render(): TimePickerObject;
|
||||
|
||||
/** Clear the value in the picker's input element. */
|
||||
clear(): TimePickerObject;
|
||||
|
||||
/** Get the properties, objects, and states that make up the current state of the picker. */
|
||||
get(thing: string): any;
|
||||
|
||||
/** Returns the string value of the picker's input element. */
|
||||
get(thing?: 'value'): string;
|
||||
|
||||
/** Returns the item object that is visually selected. */
|
||||
get(thing: 'select'): TimePickerItemObject;
|
||||
|
||||
/** Returns the item object that is visually highlighted. */
|
||||
get(thing: 'highlight'): TimePickerItemObject;
|
||||
|
||||
/** Returns the item object that sets the current view. */
|
||||
get(thing: 'view'): TimePickerItemObject;
|
||||
|
||||
/** Returns the item object that limits the picker's lower range. */
|
||||
get(thing: 'min'): TimePickerItemObject;
|
||||
|
||||
/** Returns the item object that limits the picker's upper range. */
|
||||
get(thing: 'max'): TimePickerItemObject;
|
||||
|
||||
/** Returns a boolean value of whether the picker is open or not. */
|
||||
get(thing: 'open'): boolean;
|
||||
|
||||
/** Returns a boolean value of whether the picker has started or not. */
|
||||
get(thing: 'start'): boolean;
|
||||
|
||||
/** Returns a unique 9-digit integer that is the ID of the picker. */
|
||||
get(thing: 'id'): number;
|
||||
|
||||
/** Returns an array of items that determine which item objects to disable on the picker. */
|
||||
get(thing: 'disable'): any[];
|
||||
|
||||
/** Returns a formatted string for the item object specified by `thing` */
|
||||
get(thing: string, format: string): string;
|
||||
|
||||
/** Set the properties, objects, and states to change the state of the picker. */
|
||||
set(thing: string, value?: any): TimePickerObject;
|
||||
set(things: TimePickerSetThings): TimePickerObject;
|
||||
|
||||
/** Bind callbacks to get fired off when the relative picker method is called. */
|
||||
on(methodName, callback: () => void ): TimePickerObject;
|
||||
|
||||
/** Bind multiple callbacks at once to get fired off when the relative picker method is called. */
|
||||
on(callbackObject: CallbackObject): TimePickerObject;
|
||||
|
||||
/** Trigger callbacks that have been queued up using the the on method. */
|
||||
trigger(event: string): TimePickerObject;
|
||||
}
|
||||
|
||||
interface JQuery {
|
||||
pickadate(options?: pickadateOptions): HTMLInputElement;
|
||||
pickatime(options?: pickatimeOptions): HTMLInputElement;
|
||||
}
|
||||
|
||||
interface HTMLInputElement {
|
||||
pickadate(picker: string): DatePickerObject;
|
||||
pickatime(picker: string): TimePickerObject;
|
||||
|
||||
}
|
||||
Vendored
+1
-1
@@ -86,7 +86,7 @@ interface JQueryPromise {
|
||||
done(...doneCallbacks: any[]): JQueryDeferred;
|
||||
fail(...failCallbacks: any[]): JQueryDeferred;
|
||||
pipe(doneFilter?: (x: any) => any, failFilter?: (x: any) => any, progressFilter?: (x: any) => any): JQueryPromise;
|
||||
then(doneCallbacks: any, failCallbacks: any, progressCallbacks?: any): JQueryDeferred;
|
||||
then(doneCallbacks: any, failCallbacks?: any, progressCallbacks?: any): JQueryDeferred;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -601,7 +601,7 @@ function test_accordion() {
|
||||
var heightStyle = $(".selector").accordion("option", "heightStyle");
|
||||
$(".selector").accordion("option", "heightStyle", "fill");
|
||||
$(".selector").accordion({ icons: { "header": "ui-icon-plus", "headerSelected": "ui-icon-minus" } });
|
||||
var icons = $(".selector").accordion("option", "icons");
|
||||
icons = $(".selector").accordion("option", "icons");
|
||||
$(".selector").accordion("option", "icons", { "header": "ui-icon-plus", "headerSelected": "ui-icon-minus" });
|
||||
var isDisabled = $(".selector").accordion("option", "disabled");
|
||||
$(".selector").accordion("option", { disabled: true });
|
||||
|
||||
Vendored
+809
-807
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>
|
||||
// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare interface Fixtures {
|
||||
interface Fixtures {
|
||||
path: string;
|
||||
containerId: string;
|
||||
body(): string;
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/// <reference path="jstorage.d.ts" />
|
||||
|
||||
// Test set first overload
|
||||
var storedValue = $.jStorage.set("testObj", { foo: 'bar' });
|
||||
console.assert(storedValue.foo === "bar");
|
||||
|
||||
// Test set second overload
|
||||
$.jStorage.set("testNum", 42, { TTL: 65535 });
|
||||
var readValue = $.jStorage.get<number>("testNum");
|
||||
console.assert(readValue + 5 === 47);
|
||||
|
||||
// Test deleteKey
|
||||
if ($.jStorage.deleteKey("testObj") === true) {
|
||||
console.log('deleted');
|
||||
}
|
||||
|
||||
// Test setTTL/getTTL
|
||||
$.jStorage.setTTL("testNum", 100);
|
||||
console.assert($.jStorage.getTTL("testNum") === 100);
|
||||
|
||||
// Test flush
|
||||
console.assert($.jStorage.flush() === true);
|
||||
|
||||
// Test storageObj
|
||||
var storeObj = $.jStorage.storageObj();
|
||||
console.assert(storeObj["testNum"] !== null);
|
||||
|
||||
// Test index
|
||||
var keys = $.jStorage.index();
|
||||
console.assert(keys.length > 0);
|
||||
|
||||
// Test storageSize
|
||||
var size = $.jStorage.storageSize();
|
||||
console.assert(size > 0);
|
||||
|
||||
// Test currentBackend
|
||||
var currentBackend = $.jStorage.currentBackend();
|
||||
console.assert(currentBackend != null && typeof currentBackend.getItem !== "undefined");
|
||||
|
||||
// Test storageAvailable
|
||||
var isStorageAvailable = $.jStorage.storageAvailable();
|
||||
console.assert(isStorageAvailable === true);
|
||||
|
||||
// Test listenKeyChange
|
||||
$.jStorage.listenKeyChange("testNum", (key, value) => {
|
||||
console.assert(key.length > 0);
|
||||
console.assert(value != null);
|
||||
} );
|
||||
|
||||
$.jStorage.listenKeyChange<number>("testNum", (key, value) => {
|
||||
console.assert(key === "testNum");
|
||||
console.assert(value + 10 > 0);
|
||||
} );
|
||||
|
||||
// Test stopListening
|
||||
$.jStorage.stopListening("testNum");
|
||||
$.jStorage.stopListening("testNum", () => { console.assert(); } );
|
||||
|
||||
// Test subscribe
|
||||
$.jStorage.subscribe("ESPN", (channel, value) => {
|
||||
console.assert(channel !== "ABC");
|
||||
console.assert(value !== null);
|
||||
} );
|
||||
|
||||
$.jStorage.subscribe<Date>("ESPN", (channel, value) => {
|
||||
console.assert(channel === "ESPN");
|
||||
console.assert(value.getDate() > Date.now());
|
||||
} );
|
||||
|
||||
// Test publish
|
||||
$.jStorage.publish("ESPN", { date: new Date(2013, 4, 26, 7), game: "Miami Heat" });
|
||||
|
||||
// Test reinit
|
||||
$.jStorage.reInit();
|
||||
Vendored
+159
@@ -0,0 +1,159 @@
|
||||
// Type definitions for jStorage 0.3.0
|
||||
// Project: http://www.jstorage.info/
|
||||
// Definitions by: Danil Flores <https://github.com/dflor003/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module $.jStorage {
|
||||
|
||||
class IStorageOptions {
|
||||
TTL: number;
|
||||
}
|
||||
|
||||
interface IJStorage {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a key's value.
|
||||
*
|
||||
* @param key Key to set. If this value is not set or not
|
||||
* a string an exception is raised.
|
||||
* @param value Value to set. This can be any value that is JSON
|
||||
* compatible (Numbers, Strings, Objects etc.).
|
||||
* @param [options] - possible options to use
|
||||
* @param [options.TTL] - optional TTL value
|
||||
* @return the used value
|
||||
*/
|
||||
function set <TValue>(key: string, value: TValue, options?: IStorageOptions): TValue;
|
||||
|
||||
/**
|
||||
* Looks up a key in cache
|
||||
*
|
||||
* @param key - Key to look up.
|
||||
* @param defaultIfNotFound - Default value to return, if key didn't exist.
|
||||
* @return the key value, default value or null
|
||||
*/
|
||||
function get <TValue>(key: string, defaultIfNotFound?: TValue): TValue;
|
||||
|
||||
/**
|
||||
* Deletes a key from cache.
|
||||
*
|
||||
* @param key - Key to delete.
|
||||
* @return true if key existed or false if it didn't
|
||||
*/
|
||||
function deleteKey(key: string): boolean;
|
||||
|
||||
/**
|
||||
* Sets a TTL for a key, or remove it if ttl value is 0 or below
|
||||
*
|
||||
* @param key - key to set the TTL for
|
||||
* @param ttl - TTL timeout in milliseconds
|
||||
* @return true if key existed or false if it didn't
|
||||
*/
|
||||
function setTTL(key: string, ttl: number): boolean;
|
||||
|
||||
/**
|
||||
* Gets remaining TTL (in milliseconds) for a key or 0 when no TTL has been set
|
||||
*
|
||||
* @param key Key to check
|
||||
* @return Remaining TTL in milliseconds
|
||||
*/
|
||||
function getTTL(key: string): number;
|
||||
|
||||
/**
|
||||
* Deletes everything in cache.
|
||||
*
|
||||
* @return Always true
|
||||
*/
|
||||
function flush(): boolean;
|
||||
|
||||
/**
|
||||
* Returns a read-only copy of _storage
|
||||
*
|
||||
* @return Read-only copy of _storage
|
||||
*/
|
||||
function storageObj(): IJStorage
|
||||
|
||||
/**
|
||||
* Returns an index of all used keys as an array
|
||||
* ['key1', 'key2',..'keyN']
|
||||
*
|
||||
* @return Used keys
|
||||
*/
|
||||
function index(): string[];
|
||||
|
||||
/**
|
||||
* How much space in bytes does the storage take?
|
||||
*
|
||||
* @return Storage size in chars (not the same as in bytes,
|
||||
* since some chars may take several bytes)
|
||||
*/
|
||||
function storageSize(): number;
|
||||
|
||||
/**
|
||||
* Which backend is currently in use?
|
||||
*
|
||||
* @return Backend name
|
||||
*/
|
||||
function currentBackend(): Storage;
|
||||
|
||||
/**
|
||||
* Test if storage is available
|
||||
*
|
||||
* @return True if storage can be used
|
||||
*/
|
||||
function storageAvailable(): boolean;
|
||||
|
||||
/**
|
||||
* Register change listeners
|
||||
*
|
||||
* @param key Key name
|
||||
* @param callback Function to run when the key changes
|
||||
*/
|
||||
function listenKeyChange(key: string, callback: (key: string, value: any) => void ): void;
|
||||
|
||||
/**
|
||||
* Register change listeners
|
||||
*
|
||||
* @param key Key name
|
||||
* @param callback Function to run when the key changes
|
||||
*/
|
||||
function listenKeyChange<TValue>(key: string, callback: (key: string, value: TValue) => void ): void;
|
||||
|
||||
/**
|
||||
* Remove change listeners
|
||||
*
|
||||
* @param key Key name to unregister listeners against
|
||||
* @param [callback] If set, unregister the callback, if not - unregister all
|
||||
*/
|
||||
function stopListening(key: string, callback?: Function): void;
|
||||
|
||||
/**
|
||||
* Subscribe to a Publish/Subscribe event stream
|
||||
*
|
||||
* @param channel Channel name
|
||||
* @param callback Function to run when the something is published to the channel
|
||||
*/
|
||||
function subscribe(channel: string, callback: (channel: string, value: any) => void ): void;
|
||||
|
||||
/**
|
||||
* Subscribe to a Publish/Subscribe event stream
|
||||
*
|
||||
* @param channel Channel name
|
||||
* @param callback Function to run when the something is published to the channel
|
||||
*/
|
||||
function subscribe<TValue>(channel: string, callback: (channel: string, value: TValue) => void ): void;
|
||||
|
||||
/**
|
||||
* Publish data to an event stream
|
||||
*
|
||||
* @param channel Channel name
|
||||
* @param payload Payload to deliver
|
||||
*/
|
||||
function publish(channel: string, payload: any): void;
|
||||
|
||||
/**
|
||||
* Reloads the data from browser storage
|
||||
*/
|
||||
function reInit(): void;
|
||||
}
|
||||
Vendored
+34
-34
@@ -2,37 +2,37 @@
|
||||
/// <reference path="../knockout/knockout.d.ts" />
|
||||
|
||||
declare module Knockback {
|
||||
export interface EventWatcherOptions {
|
||||
interface EventWatcherOptions {
|
||||
emitter: (newEmitter) => void;
|
||||
update: (newValue) => void;
|
||||
event_selector: string;
|
||||
key?: string;
|
||||
}
|
||||
|
||||
export interface FactoryOptions {
|
||||
interface FactoryOptions {
|
||||
factories: any;
|
||||
}
|
||||
|
||||
export interface StoreOptions {
|
||||
interface StoreOptions {
|
||||
creator: any;
|
||||
path: string;
|
||||
store: Store;
|
||||
factory: Factory;
|
||||
}
|
||||
|
||||
export class Destroyable {
|
||||
class Destroyable {
|
||||
destroy();
|
||||
}
|
||||
|
||||
export class ViewModel extends Destroyable {
|
||||
class ViewModel extends Destroyable {
|
||||
constructor (model?: Backbone.Model, options?: ViewModelOptions, viewModel?: ViewModel);
|
||||
shareOptions(): ViewModelOptions;
|
||||
extend(source: any);
|
||||
model(): Backbone.Model;
|
||||
}
|
||||
|
||||
export class EventWatcher extends Destroyable {
|
||||
static useOptionsOrCreate(options, emitter: KnockoutObservableAny, obj: Backbone.Model, callback_options: any);
|
||||
class EventWatcher extends Destroyable {
|
||||
static useOptionsOrCreate(options, emitter: KnockoutObservable<any>, obj: Backbone.Model, callback_options: any);
|
||||
|
||||
emitter(): Backbone.Model;
|
||||
emitter(newEmitter: Backbone.Model);
|
||||
@@ -40,7 +40,7 @@ declare module Knockback {
|
||||
releaseCallbacks(obj: any);
|
||||
}
|
||||
|
||||
export class Factory {
|
||||
class Factory {
|
||||
static useOptionsOrCreate(options: FactoryOptions, obj: any, owner_path: string);
|
||||
|
||||
constructor (parent_factory: any);
|
||||
@@ -51,39 +51,39 @@ declare module Knockback {
|
||||
creatorForPath(obj: any, path: string);
|
||||
}
|
||||
|
||||
export class Store extends Destroyable {
|
||||
static useOptionsOrCreate(options: StoreOptions, obj: any, observable: KnockoutObservableAny);
|
||||
class Store extends Destroyable {
|
||||
static useOptionsOrCreate(options: StoreOptions, obj: any, observable: KnockoutObservable<any>);
|
||||
|
||||
constructor (model:Backbone.Model, options: StoreOptions);
|
||||
clear();
|
||||
register(obj: Backbone.Model, observable: KnockoutObservableAny, options: StoreOptions);
|
||||
register(obj: Backbone.Model, observable: KnockoutObservable<any>, options: StoreOptions);
|
||||
findOrCreate(obj: Backbone.Model, options: StoreOptions);
|
||||
}
|
||||
|
||||
export class DefaultObservable extends Destroyable {
|
||||
constructor (targetObservable: KnockoutObservableAny, defaultValue: any);
|
||||
class DefaultObservable extends Destroyable {
|
||||
constructor (targetObservable: KnockoutObservable<any>, defaultValue: any);
|
||||
setToDefault();
|
||||
}
|
||||
|
||||
export class FormattedObservable extends Destroyable {
|
||||
class FormattedObservable extends Destroyable {
|
||||
constructor (format: string, args: any[]);
|
||||
constructor (format: KnockoutObservableAny, args: any[]);
|
||||
constructor (format: KnockoutObservable<any>, args: any[]);
|
||||
}
|
||||
|
||||
export interface LocalizedObservable {
|
||||
interface LocalizedObservable {
|
||||
constructor (value: any, options: any, vm: any);
|
||||
destroy();
|
||||
resetToCurrent();
|
||||
observedValue(value: any);
|
||||
}
|
||||
|
||||
export class TriggeredObservable extends Destroyable {
|
||||
class TriggeredObservable extends Destroyable {
|
||||
constructor (emitter: Backbone.ModelBase, event: string);
|
||||
emitter(): Backbone.ModelBase;
|
||||
emitter(newEmitter: Backbone.ModelBase);
|
||||
}
|
||||
|
||||
export class Statistics {
|
||||
class Statistics {
|
||||
constructor ();
|
||||
clear();
|
||||
addModelEvent(event: string);
|
||||
@@ -94,14 +94,14 @@ declare module Knockback {
|
||||
registeredStatsString(success_message: string): string;
|
||||
}
|
||||
|
||||
export interface OptionsBase {
|
||||
interface OptionsBase {
|
||||
path?: string; // the path to the value (used to create related observables from the factory).
|
||||
store?: Store; // a store used to cache and share view models.
|
||||
factory?: Factory; // a factory used to create view models.
|
||||
options?: any; // a set of options merge into these options using _.defaults. Useful for extending options when deriving classes rather than merging them by hand.
|
||||
}
|
||||
|
||||
export interface ViewModelOptions extends OptionsBase {
|
||||
interface ViewModelOptions extends OptionsBase {
|
||||
internals?: string[]; // an array of atttributes that should be scoped with an underscore, eg. name -> _name
|
||||
requires?: string[]; // an array of atttributes that will have kb.Observables created even if they do not exist on the Backbone.Model. Useful for binding Views that require specific observables to exist
|
||||
keys?: string[]; // restricts the keys used on a model. Useful for reducing the number of kb.Observables created from a limited set of Backbone.Model attributes
|
||||
@@ -110,7 +110,7 @@ declare module Knockback {
|
||||
factories?: any; // a map of dot-deliminated paths; for example {'models.name': kb.ViewModel} to either constructors or create functions. Signature: {'some.path': function(object, options)}
|
||||
}
|
||||
|
||||
export interface CollectionOptions extends OptionsBase {
|
||||
interface CollectionOptions extends OptionsBase {
|
||||
models_only?: bool; // flag for skipping the creation of view models. The collection observable will be populated with (possibly sorted) models.
|
||||
view_model?: any; // (Constructor) — the view model constructor used for models in the collection. Signature: constructor(model, options)
|
||||
create?: any; // a function used to create a view model for models in the collection. Signature: create(model, options)
|
||||
@@ -120,7 +120,7 @@ declare module Knockback {
|
||||
filters?: any; // filters can be individual ids (observable or simple) or arrays of ids, functions, or arrays of functions.
|
||||
}
|
||||
|
||||
export interface CollectionObservable extends KnockoutObservableArray {
|
||||
interface CollectionObservable extends KnockoutObservableArray<any> {
|
||||
collection(colleciton: Backbone.Collection);
|
||||
collection(): Backbone.Collection;
|
||||
destroy();
|
||||
@@ -134,7 +134,7 @@ declare module Knockback {
|
||||
hasViewModels(): bool;
|
||||
}
|
||||
|
||||
export interface Utils {
|
||||
interface Utils {
|
||||
wrappedObservable(obj: any): any;
|
||||
wrappedObservable(obj: any, value: any);
|
||||
wrappedObject(obj: any): any;
|
||||
@@ -148,7 +148,7 @@ declare module Knockback {
|
||||
wrappedEventWatcher(obj: any): any;
|
||||
wrappedEventWatcher(obj: any, value: any);
|
||||
wrappedDestroy(obj: any);
|
||||
valueType(observable: KnockoutObservableAny): any;
|
||||
valueType(observable: KnockoutObservable<any>): any;
|
||||
pathJoin(path1: string, path2: string): string;
|
||||
optionsPathJoin(options: any, path: string): any;
|
||||
inferCreator(value: any, factory: Factory, path: string, owner: any, key: string);
|
||||
@@ -157,7 +157,7 @@ declare module Knockback {
|
||||
hasCollectionSignature(obj: any): bool;
|
||||
}
|
||||
|
||||
export interface Static extends Utils {
|
||||
interface Static extends Utils {
|
||||
collectionObservable(model?: Backbone.Collection, options?: CollectionOptions): CollectionObservable;
|
||||
/** Base class for observing model attributes. */
|
||||
observable(
|
||||
@@ -166,19 +166,19 @@ declare module Knockback {
|
||||
/** the create options. String is a single attribute name, Array is an array of attribute names. */
|
||||
options: IObservableOptions,
|
||||
/** the viewModel */
|
||||
vm?: ViewModel): KnockoutObservableAny;
|
||||
vm?: ViewModel): KnockoutObservable<any>;
|
||||
observable(
|
||||
/** the model to observe (can be null) */
|
||||
model: Backbone.Model,
|
||||
/** the create options. String is a single attribute name, Array is an array of attribute names. */
|
||||
options_attributeName: string,
|
||||
/** the viewModel */
|
||||
vm?: ViewModel): KnockoutObservableAny;
|
||||
viewModel(model?: Backbone.Model, options?: any): KnockoutObservableAny;
|
||||
defaultObservable(targetObservable: KnockoutObservableAny, defaultValue: any): KnockoutObservableAny;
|
||||
formattedObservable(format: string, args: any[]): KnockoutObservableAny;
|
||||
formattedObservable(format: KnockoutObservableAny, args: any[]): KnockoutObservableAny;
|
||||
localizedObservable(data: any, options: any): KnockoutObservableAny;
|
||||
vm?: ViewModel): KnockoutObservable<any>;
|
||||
viewModel(model?: Backbone.Model, options?: any): KnockoutObservable<any>;
|
||||
defaultObservable(targetObservable: KnockoutObservable<any>, defaultValue: any): KnockoutObservable<any>;
|
||||
formattedObservable(format: string, args: any[]): KnockoutObservable<any>;
|
||||
formattedObservable(format: KnockoutObservable<any>, args: any[]): KnockoutObservable<any>;
|
||||
localizedObservable(data: any, options: any): KnockoutObservable<any>;
|
||||
release(object: any, pre_release?: () => void );
|
||||
releaseKeys(object: any);
|
||||
releaseOnNodeRemove(viewmodel: ViewModel, node: Element);
|
||||
@@ -204,7 +204,7 @@ declare module Knockback {
|
||||
key: string;
|
||||
read?: () => any;
|
||||
write?: (value: any) => void;
|
||||
args?: KnockoutObservableAny[];
|
||||
args?: KnockoutObservable<any>[];
|
||||
localizer?: LocalizedObservable;
|
||||
default?: any;
|
||||
path?: string;
|
||||
@@ -213,6 +213,6 @@ declare module Knockback {
|
||||
options?: any;
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
declare var kb: Knockback.Static;
|
||||
+1
-1
@@ -13,7 +13,7 @@ interface KnockoutMappingCreateOptions {
|
||||
interface KnockoutMappingUpdateOptions {
|
||||
data: any;
|
||||
parent: any;
|
||||
observable: KnockoutObservableAny;
|
||||
observable: KnockoutObservable<any>;
|
||||
}
|
||||
|
||||
interface KnockoutMappingOptions {
|
||||
|
||||
+11
-42
@@ -1,53 +1,22 @@
|
||||
// Type definitions for knockout-postbox
|
||||
// Project: https://github.com/rniemeyer/knockout-postbox
|
||||
// Definitions by: Judah Gabriel <https://github.com/JudahGabriel>
|
||||
// Definitions by: Judah Gabriel Himango <https://debuggerdotbreak.wordpress.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../knockout/knockout.d.ts" />
|
||||
|
||||
interface KnockoutPostBox {
|
||||
subscribe: (topic: string, handler: (value) => void, target?: any) => KnockoutObservableAny;
|
||||
publish: (topic: string, value?: any) => KnockoutObservableAny;
|
||||
defaultComparer: (newValue: any, oldValue: any) => bool;
|
||||
subscribe<T>(topic: string, handler: (value: T) => void , target?: any): KnockoutSubscription;
|
||||
publish<T>(topic: string, value?: T): void;
|
||||
defaultComparer<T>(newValue: T, oldValue: T): boolean;
|
||||
}
|
||||
|
||||
interface KnockoutObservableString {
|
||||
subscribeTo: (topic: string, useLastPublishedValueToInitialize?: bool, transform?: (val: any) => string) => KnockoutObservableString;
|
||||
unsubscribeFrom: (topic: string) => KnockoutObservableString;
|
||||
publishOn: (topic: string, skipInitialPublish?: bool, equalityComparer?: (newValue: string, oldValue: string) => bool) => KnockoutObservableString;
|
||||
stopPublishingOn: (topic: string) => KnockoutObservableString;
|
||||
syncWith: (topic: string, initializeWithLatestValue?: bool, skipInitialPublish?: bool, equalityComparer?: (newValue: string, oldValue: string) => bool) => KnockoutObservableString;
|
||||
}
|
||||
|
||||
interface KnockoutObservableDate {
|
||||
subscribeTo: (topic: string, useLastPublishedValueToInitialize?: bool, transform?: (val: any) => Date) => KnockoutObservableDate;
|
||||
unsubscribeFrom: (topic: string) => KnockoutObservableDate;
|
||||
publishOn: (topic: string, skipInitialPublish?: bool, equalityComparer?: (newValue: Date, oldValue: Date) => bool) => KnockoutObservableDate;
|
||||
stopPublishingOn: (topic: string) => KnockoutObservableDate;
|
||||
syncWith: (topic: string, initializeWithLatestValue?: bool, skipInitialPublish?: bool, equalityComparer?: (newValue: Date, oldValue: Date) => bool) => KnockoutObservableDate;
|
||||
}
|
||||
|
||||
interface KnockoutObservableNumber {
|
||||
subscribeTo: (topic: string, useLastPublishedValueToInitialize?: bool, transform?: (val: any) => number) => KnockoutObservableNumber;
|
||||
unsubscribeFrom: (topic: string) => KnockoutObservableNumber;
|
||||
publishOn: (topic: string, skipInitialPublish?: bool, equalityComparer?: (newValue: Number, oldValue: Number) => bool) => KnockoutObservableNumber;
|
||||
stopPublishingOn: (topic: string) => KnockoutObservableNumber;
|
||||
syncWith: (topic: string, initializeWithLatestValue?: bool, skipInitialPublish?: bool, equalityComparer?: (newValue: Number, oldValue: Number) => bool) => KnockoutObservableNumber;
|
||||
}
|
||||
|
||||
interface KnockoutObservableBool {
|
||||
subscribeTo: (topic: string, useLastPublishedValueToInitialize?: bool, transform?: (val: any) => bool) => KnockoutObservableBool;
|
||||
unsubscribeFrom: (topic: string) => KnockoutObservableBool;
|
||||
publishOn: (topic: string, skipInitialPublish?: bool, equalityComparer?: (newValue: bool, oldValue: bool) => bool) => KnockoutObservableBool;
|
||||
stopPublishingOn: (topic: string) => KnockoutObservableBool;
|
||||
syncWith: (topic: string, initializeWithLatestValue?: bool, skipInitialPublish?: bool, equalityComparer?: (newValue: bool, oldValue: bool) => bool) => KnockoutObservableBool;
|
||||
}
|
||||
|
||||
interface KnockoutObservableAny {
|
||||
subscribeTo: (topic: string, useLastPublishedValueToInitialize?: bool, transform?: (val: any) => any) => KnockoutObservableAny;
|
||||
unsubscribeFrom: (topic: string) => KnockoutObservableAny;
|
||||
publishOn: (topic: string, skipInitialPublish?: bool, equalityComparer?: (newValue: any, oldValue: any) => bool) => KnockoutObservableAny;
|
||||
stopPublishingOn: (topic: string) => KnockoutObservableAny;
|
||||
syncWith: (topic: string, initializeWithLatestValue?: bool, skipInitialPublish?: bool, equalityComparer?: (newValue: any, oldValue: any) => bool) => KnockoutObservableAny;
|
||||
interface KnockoutObservable<T> {
|
||||
subscribeTo(topic: string, useLastPublishedValueToInitialize?: boolean, transform?: (val: any) => T): KnockoutObservable<T>;
|
||||
unsubscribeFrom(topic: string): KnockoutObservable<T>;
|
||||
publishOn(topic: string, skipInitialPublish?: boolean, equalityComparer?: (newValue: T, oldValue: T) => boolean): KnockoutObservable<T>;
|
||||
stopPublishingOn(topic: string): KnockoutObservable<T>;
|
||||
syncWith(topic: string, initializeWithLatestValue?: boolean, skipInitialPublish?: boolean, equalityComparer?: (newValue: T, oldValue: T) => boolean): KnockoutObservable<T>;
|
||||
}
|
||||
|
||||
interface KnockoutStatic {
|
||||
|
||||
+146
-145
@@ -1,145 +1,146 @@
|
||||
// Type definitions for Knockout Validation
|
||||
// Project: https://github.com/ericmbarnard/Knockout-Validation
|
||||
// Definitions by: Dan Ludwig <https://github.com/danludwig>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../knockout/knockout.d.ts" />
|
||||
|
||||
interface KnockoutValidationGroupingOptions {
|
||||
deep?: bool;
|
||||
observable?: bool;
|
||||
}
|
||||
|
||||
interface KnockoutValidationConfiguration {
|
||||
registerExtenders?: bool;
|
||||
messagesOnModified?: bool;
|
||||
messageTemplate?: string;
|
||||
insertMessages?: bool;
|
||||
parseInputAttributes?: bool;
|
||||
writeInputAttributes?: bool;
|
||||
decorateElement?: bool;
|
||||
errorClass?: string;
|
||||
errorElementClass?: string;
|
||||
errorMessageClass?: string;
|
||||
grouping?: KnockoutValidationGroupingOptions;
|
||||
}
|
||||
|
||||
interface KnockoutValidationUtils {
|
||||
isArray(o: any): bool;
|
||||
isObject(o: any): bool;
|
||||
values(o: any): any[];
|
||||
getValue(o: any): any;
|
||||
hasAttribute(node: Element, attr: string): bool;
|
||||
isValidatable(o: any): bool;
|
||||
insertAfter(node: Element, newNode: Element): void;
|
||||
newId(): number;
|
||||
getConfigOptions(element: Element): KnockoutValidationConfiguration;
|
||||
setDomData(node: Element, data: KnockoutValidationConfiguration): void;
|
||||
getDomData(node: Element): KnockoutValidationConfiguration;
|
||||
contextFor(node: Element): KnockoutValidationConfiguration;
|
||||
isEmptyVal(val: any): bool;
|
||||
}
|
||||
|
||||
interface KnockoutValidationAsyncCallbackArgs {
|
||||
isValid: bool;
|
||||
message: string;
|
||||
}
|
||||
|
||||
interface KnockoutValidationAsyncCallback {
|
||||
(result: bool): void;
|
||||
(result: KnockoutValidationAsyncCallbackArgs): void;
|
||||
}
|
||||
|
||||
interface KnockoutValidationRuleDefinition {
|
||||
message: string;
|
||||
validator(value: any, params: any): bool;
|
||||
}
|
||||
|
||||
interface KnockoutValidationAsyncRuleDefinition extends KnockoutValidationRuleDefinition {
|
||||
async: bool;
|
||||
validator(value: any, params: any, callback: KnockoutValidationAsyncCallback): void;
|
||||
}
|
||||
|
||||
interface KnockoutValidationAnonymousRuleDefinition {
|
||||
validation: KnockoutValidationRuleDefinition;
|
||||
}
|
||||
|
||||
interface KnockoutValidationRuleDefinitions {
|
||||
date: KnockoutValidationRuleDefinition;
|
||||
dateISO: KnockoutValidationRuleDefinition;
|
||||
digit: KnockoutValidationRuleDefinition;
|
||||
email: KnockoutValidationRuleDefinition;
|
||||
equal: KnockoutValidationRuleDefinition;
|
||||
max: KnockoutValidationRuleDefinition;
|
||||
maxLength: KnockoutValidationRuleDefinition;
|
||||
min: KnockoutValidationRuleDefinition;
|
||||
minLength: KnockoutValidationRuleDefinition;
|
||||
notEqual: KnockoutValidationRuleDefinition;
|
||||
number: KnockoutValidationRuleDefinition;
|
||||
pattern: KnockoutValidationRuleDefinition;
|
||||
phoneUS: KnockoutValidationRuleDefinition;
|
||||
required: KnockoutValidationRuleDefinition;
|
||||
step: KnockoutValidationRuleDefinition;
|
||||
unique: KnockoutValidationRuleDefinition;
|
||||
}
|
||||
|
||||
interface KnockoutValidationRule {
|
||||
rule: string;
|
||||
params: any;
|
||||
message?: string;
|
||||
condition?: () => bool;
|
||||
}
|
||||
|
||||
interface KnockoutValidationErrors {
|
||||
(): string[];
|
||||
showAllMessages(): void;
|
||||
showAllMessages(show: bool): void;
|
||||
}
|
||||
|
||||
interface KnockoutValidationGroup {
|
||||
errors?: KnockoutValidationErrors;
|
||||
isValid?: () => bool;
|
||||
isAnyMessageShown?: () => bool;
|
||||
}
|
||||
|
||||
interface KnockoutValidationStatic {
|
||||
init(options?: KnockoutValidationConfiguration, force?: bool): void;
|
||||
configure(options: KnockoutValidationConfiguration): void;
|
||||
reset(): void;
|
||||
|
||||
group(obj: any, options?: any): KnockoutValidationErrors;
|
||||
|
||||
formatMessage(message: string, params: string): string;
|
||||
|
||||
addRule(observable: KnockoutObservableAny, rule: KnockoutValidationRule): KnockoutObservableAny;
|
||||
addRule(observable: KnockoutObservableString, rule: KnockoutValidationRule): KnockoutObservableString;
|
||||
addRule(observable: KnockoutObservableNumber, rule: KnockoutValidationRule): KnockoutObservableNumber;
|
||||
addRule(observable: KnockoutObservableBool, rule: KnockoutValidationRule): KnockoutObservableBool;
|
||||
addRule(observable: KnockoutObservableDate, rule: KnockoutValidationRule): KnockoutObservableDate;
|
||||
addAnonymousRule(observable: KnockoutObservableBase, ruleObj: KnockoutValidationAnonymousRuleDefinition): void;
|
||||
|
||||
insertValidationMessage(element: Element): Element;
|
||||
parseInputValidationAttributes(element: Element, valueAccessor: () => KnockoutObservableBase): void;
|
||||
|
||||
rules: KnockoutValidationRuleDefinitions;
|
||||
|
||||
addExtender(ruleName: string): void;
|
||||
registerExtenders(): void;
|
||||
utils: KnockoutValidationUtils;
|
||||
|
||||
localize(msgTranslations: any): void;
|
||||
validateObservable(observable: KnockoutObservableBase): bool;
|
||||
}
|
||||
|
||||
interface KnockoutStatic {
|
||||
validation: KnockoutValidationStatic;
|
||||
validatedObservable(initialValue: any): KnockoutObservableBase;
|
||||
applyBindingsWithValidation(viewModel: any, rootNode?: any, options?: KnockoutValidationConfiguration): void;
|
||||
}
|
||||
|
||||
interface KnockoutSubscribableFunctions {
|
||||
isValid: KnockoutComputed;
|
||||
isValidating: KnockoutObservableBool;
|
||||
rules: KnockoutObservableArray;
|
||||
}
|
||||
|
||||
// Type definitions for Knockout Validation
|
||||
// Project: https://github.com/ericmbarnard/Knockout-Validation
|
||||
// Definitions by: Dan Ludwig <https://github.com/danludwig>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../knockout/knockout.d.ts" />
|
||||
|
||||
interface KnockoutValidationGroupingOptions {
|
||||
deep?: boolean;
|
||||
observable?: boolean;
|
||||
}
|
||||
|
||||
interface KnockoutValidationConfiguration {
|
||||
registerExtenders?: boolean;
|
||||
messagesOnModified?: boolean;
|
||||
messageTemplate?: string;
|
||||
insertMessages?: boolean;
|
||||
parseInputAttributes?: boolean;
|
||||
writeInputAttributes?: boolean;
|
||||
decorateElement?: boolean;
|
||||
errorClass?: string;
|
||||
errorElementClass?: string;
|
||||
errorMessageClass?: string;
|
||||
grouping?: KnockoutValidationGroupingOptions;
|
||||
}
|
||||
|
||||
interface KnockoutValidationUtils {
|
||||
isArray(o: any): boolean;
|
||||
isObject(o: any): boolean;
|
||||
values(o: any): any[];
|
||||
getValue(o: any): any;
|
||||
hasAttribute(node: Element, attr: string): boolean;
|
||||
isValidatable(o: any): boolean;
|
||||
insertAfter(node: Element, newNode: Element): void;
|
||||
newId(): number;
|
||||
getConfigOptions(element: Element): KnockoutValidationConfiguration;
|
||||
setDomData(node: Element, data: KnockoutValidationConfiguration): void;
|
||||
getDomData(node: Element): KnockoutValidationConfiguration;
|
||||
contextFor(node: Element): KnockoutValidationConfiguration;
|
||||
isEmptyVal(val: any): boolean;
|
||||
}
|
||||
|
||||
interface KnockoutValidationAsyncCallbackArgs {
|
||||
isValid: boolean;
|
||||
message: string;
|
||||
}
|
||||
|
||||
interface KnockoutValidationAsyncCallback {
|
||||
(result: boolean): void;
|
||||
(result: KnockoutValidationAsyncCallbackArgs): void;
|
||||
}
|
||||
|
||||
interface KnockoutValidationRuleBase
|
||||
{
|
||||
message: string;
|
||||
}
|
||||
|
||||
interface KnockoutValidationRuleDefinition extends KnockoutValidationRuleBase {
|
||||
validator(value: any, params: any): boolean;
|
||||
}
|
||||
|
||||
interface KnockoutValidationAsyncRuleDefinition extends KnockoutValidationRuleBase {
|
||||
async: boolean;
|
||||
validator(value: any, params: any, callback: KnockoutValidationAsyncCallback): void;
|
||||
}
|
||||
|
||||
interface KnockoutValidationAnonymousRuleDefinition {
|
||||
validation: KnockoutValidationRuleDefinition;
|
||||
}
|
||||
|
||||
interface KnockoutValidationRuleDefinitions {
|
||||
date: KnockoutValidationRuleDefinition;
|
||||
dateISO: KnockoutValidationRuleDefinition;
|
||||
digit: KnockoutValidationRuleDefinition;
|
||||
email: KnockoutValidationRuleDefinition;
|
||||
equal: KnockoutValidationRuleDefinition;
|
||||
max: KnockoutValidationRuleDefinition;
|
||||
maxLength: KnockoutValidationRuleDefinition;
|
||||
min: KnockoutValidationRuleDefinition;
|
||||
minLength: KnockoutValidationRuleDefinition;
|
||||
notEqual: KnockoutValidationRuleDefinition;
|
||||
number: KnockoutValidationRuleDefinition;
|
||||
pattern: KnockoutValidationRuleDefinition;
|
||||
phoneUS: KnockoutValidationRuleDefinition;
|
||||
required: KnockoutValidationRuleDefinition;
|
||||
step: KnockoutValidationRuleDefinition;
|
||||
unique: KnockoutValidationRuleDefinition;
|
||||
}
|
||||
|
||||
interface KnockoutValidationRule {
|
||||
rule: string;
|
||||
params: any;
|
||||
message?: string;
|
||||
condition?: () => boolean;
|
||||
}
|
||||
|
||||
interface KnockoutValidationErrors {
|
||||
(): string[];
|
||||
showAllMessages(): void;
|
||||
showAllMessages(show: boolean): void;
|
||||
}
|
||||
|
||||
interface KnockoutValidationGroup {
|
||||
errors?: KnockoutValidationErrors;
|
||||
isValid?: () => boolean;
|
||||
isAnyMessageShown?: () => boolean;
|
||||
}
|
||||
|
||||
interface KnockoutValidationStatic {
|
||||
init(options?: KnockoutValidationConfiguration, force?: boolean): void;
|
||||
configure(options: KnockoutValidationConfiguration): void;
|
||||
reset(): void;
|
||||
|
||||
group(obj: any, options?: any): KnockoutValidationErrors;
|
||||
|
||||
formatMessage(message: string, params: string): string;
|
||||
|
||||
addRule<T>(observable: KnockoutObservable<T>, rule: KnockoutValidationRule): KnockoutObservable<T>;
|
||||
|
||||
addAnonymousRule(observable: KnockoutObservableBase, ruleObj: KnockoutValidationAnonymousRuleDefinition): void;
|
||||
|
||||
insertValidationMessage(element: Element): Element;
|
||||
parseInputValidationAttributes(element: Element, valueAccessor: () => KnockoutObservableBase): void;
|
||||
|
||||
rules: KnockoutValidationRuleDefinitions;
|
||||
|
||||
addExtender(ruleName: string): void;
|
||||
registerExtenders(): void;
|
||||
utils: KnockoutValidationUtils;
|
||||
|
||||
localize(msgTranslations: any): void;
|
||||
validateObservable(observable: KnockoutObservableBase): boolean;
|
||||
}
|
||||
|
||||
interface KnockoutStatic {
|
||||
validation: KnockoutValidationStatic;
|
||||
validatedObservable(initialValue: any): KnockoutObservableBase;
|
||||
applyBindingsWithValidation(viewModel: any, rootNode?: any, options?: KnockoutValidationConfiguration): void;
|
||||
}
|
||||
|
||||
interface KnockoutSubscribableFunctions {
|
||||
isValid: KnockoutComputed<boolean>;
|
||||
isValidating: KnockoutObservable<boolean>;
|
||||
rules: KnockoutObservableArray<KnockoutValidationRule>;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+24
-23
@@ -15,7 +15,7 @@ interface KnockoutSubscribableFunctions {
|
||||
|
||||
interface KnockoutComputedFunctions extends KnockoutSubscribableFunctions {
|
||||
getDependenciesCount(): number;
|
||||
hasWriteFunction(): bool;
|
||||
hasWriteFunction(): boolean;
|
||||
}
|
||||
|
||||
interface KnockoutObservableFunctions extends KnockoutSubscribableFunctions {
|
||||
@@ -62,7 +62,7 @@ interface KnockoutComputedStatic {
|
||||
fn: KnockoutComputedFunctions;
|
||||
|
||||
<T>(): KnockoutComputed<T>;
|
||||
<T>(func: () => T, context?: any): KnockoutComputed<T>;
|
||||
<T>(func: () => T, context?: any, options?: any): KnockoutComputed<T>;
|
||||
<T>(def: KnockoutComputedDefine<T>): KnockoutComputed<T>;
|
||||
(options?: any): KnockoutComputed<any>;
|
||||
}
|
||||
@@ -72,15 +72,15 @@ interface KnockoutComputed<T> extends KnockoutComputedFunctions {
|
||||
(value: T): void;
|
||||
|
||||
subscribe(callback: (newValue: T) => void, target?:any, topic?: string): KnockoutSubscription;
|
||||
notifySubscribers(valueToWrite: T, topic?: string);
|
||||
notifySubscribers(valueToWrite: T, topic?: string);
|
||||
}
|
||||
|
||||
interface KnockoutObservableArrayStatic {
|
||||
|
||||
fn: KnockoutObservableArrayFunctions<any>;
|
||||
|
||||
|
||||
<T>(): KnockoutObservableArray<T>;
|
||||
<T>(value: T[]): KnockoutObservableArray<T>;
|
||||
<T>(value: T[]): KnockoutObservableArray<T>;
|
||||
}
|
||||
|
||||
interface KnockoutObservableArray<T> extends KnockoutObservableArrayFunctions<T> {
|
||||
@@ -94,17 +94,18 @@ interface KnockoutObservableArray<T> extends KnockoutObservableArrayFunctions<T>
|
||||
interface KnockoutObservableStatic {
|
||||
fn: KnockoutObservableFunctions;
|
||||
|
||||
<T>(value: T): KnockoutObservable<T>;
|
||||
<T>(value?: T): KnockoutObservable<T>;
|
||||
<T>(): KnockoutObservable<T>;
|
||||
}
|
||||
|
||||
/** use as method to get/set the value */
|
||||
interface KnockoutObservableBase extends KnockoutObservableFunctions {
|
||||
getSubscriptionsCount(): number;
|
||||
}
|
||||
|
||||
|
||||
interface KnockoutObservable<T> extends KnockoutObservableBase {
|
||||
(): T;
|
||||
(value: T): void;
|
||||
(value: T): void;
|
||||
|
||||
subscribe(callback: (newValue: T) => void, target?:any, topic?: string): KnockoutSubscription;
|
||||
notifySubscribers(valueToWrite: T, topic?: string);
|
||||
@@ -175,7 +176,7 @@ interface KnockoutMemoization {
|
||||
interface KnockoutVirtualElement {}
|
||||
|
||||
interface KnockoutVirtualElements {
|
||||
allowedBindings: { [bindingName: string]: bool; };
|
||||
allowedBindings: { [bindingName: string]: boolean; };
|
||||
emptyNode( e: KnockoutVirtualElement );
|
||||
firstChild( e: KnockoutVirtualElement );
|
||||
insertAfter( container: KnockoutVirtualElement, nodeToInsert: HTMLElement, insertAfter: HTMLElement );
|
||||
@@ -215,7 +216,7 @@ interface KnockoutUtils {
|
||||
|
||||
set (node: Element, key: string, value: any);
|
||||
|
||||
getAll(node: Element, createIfNotFound: bool);
|
||||
getAll(node: Element, createIfNotFound: boolean);
|
||||
|
||||
clear(node: Element);
|
||||
};
|
||||
@@ -244,7 +245,7 @@ interface KnockoutUtils {
|
||||
|
||||
arrayIndexOf(array: any[], item: any): number;
|
||||
|
||||
arrayFirst(array: any[], predicate: (item) => bool, predicateOwner?: any): any;
|
||||
arrayFirst(array: any[], predicate: (item) => boolean, predicateOwner?: any): any;
|
||||
|
||||
arrayRemoveItem(array: any[], itemToRemove: any): void;
|
||||
|
||||
@@ -252,7 +253,7 @@ interface KnockoutUtils {
|
||||
|
||||
arrayMap(array: any[], mapping: (item) => any): any[];
|
||||
|
||||
arrayFilter(array: any[], predicate: (item) => bool): any[];
|
||||
arrayFilter(array: any[], predicate: (item) => boolean): any[];
|
||||
|
||||
arrayPushAll(array: any[], valuesToPush: any[]): any[];
|
||||
|
||||
@@ -262,13 +263,13 @@ interface KnockoutUtils {
|
||||
|
||||
moveCleanedNodesToContainerElement(nodes: any[]): HTMLElement;
|
||||
|
||||
cloneNodes(nodesArray: any[], shouldCleanNodes: bool): any[];
|
||||
cloneNodes(nodesArray: any[], shouldCleanNodes: boolean): any[];
|
||||
|
||||
setDomNodeChildren(domNode: any, childNodes: any[]): void;
|
||||
|
||||
replaceDomNodes(nodeToReplaceOrNodeArray: any, newNodesArray: any[]): void;
|
||||
|
||||
setOptionNodeSelectionState(optionNode: any, isSelected: bool): void;
|
||||
setOptionNodeSelectionState(optionNode: any, isSelected: boolean): void;
|
||||
|
||||
stringTrim(str: string): string;
|
||||
|
||||
@@ -276,9 +277,9 @@ interface KnockoutUtils {
|
||||
|
||||
stringStartsWith(str: string, startsWith: string): string;
|
||||
|
||||
domNodeIsContainedBy(node: any, containedByNode: any): bool;
|
||||
domNodeIsContainedBy(node: any, containedByNode: any): boolean;
|
||||
|
||||
domNodeIsAttachedToDocument(node: any): bool;
|
||||
domNodeIsAttachedToDocument(node: any): boolean;
|
||||
|
||||
tagNameLower(element: any): string;
|
||||
|
||||
@@ -288,7 +289,7 @@ interface KnockoutUtils {
|
||||
|
||||
unwrapObservable(value: any): any;
|
||||
|
||||
toggleDomNodeCssClass(node: any, className: string, shouldHaveClass: bool): void;
|
||||
toggleDomNodeCssClass(node: any, className: string, shouldHaveClass: boolean): void;
|
||||
|
||||
//setTextContent(element: any, textContent: string): void; // NOT PART OF THE MINIFIED API SURFACE (ONLY IN knockout-{version}.debug.js) https://github.com/SteveSanderson/knockout/issues/670
|
||||
|
||||
@@ -314,9 +315,9 @@ interface KnockoutUtils {
|
||||
|
||||
ieVersion: number;
|
||||
|
||||
isIe6: bool;
|
||||
isIe6: boolean;
|
||||
|
||||
isIe7: bool;
|
||||
isIe7: boolean;
|
||||
}
|
||||
|
||||
//////////////////////////////////
|
||||
@@ -364,7 +365,7 @@ interface KnockoutTemplateEngine extends KnockoutNativeTemplateEngine {
|
||||
|
||||
renderTemplate(template, bindingContext, options, templateDocument);
|
||||
|
||||
isTemplateRewritten(template, templateDocument): bool;
|
||||
isTemplateRewritten(template, templateDocument): boolean;
|
||||
|
||||
rewriteTemplate(template, rewriterCallback, templateDocument);
|
||||
}
|
||||
@@ -388,11 +389,11 @@ interface KnockoutStatic {
|
||||
observableArray: KnockoutObservableArrayStatic;
|
||||
|
||||
contextFor(node: any): any;
|
||||
isSubscribable(instance: any): bool;
|
||||
isSubscribable(instance: any): boolean;
|
||||
toJSON(viewModel: any, replacer?: Function, space?: any): string;
|
||||
toJS(viewModel: any): any;
|
||||
isObservable(instance: any): bool;
|
||||
isComputed(instance: any): bool;
|
||||
isObservable(instance: any): boolean;
|
||||
isComputed(instance: any): boolean;
|
||||
dataFor(node: any): any;
|
||||
removeNode(node: Element);
|
||||
cleanNode(node: Element);
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
/// <reference path="../knockout.d.ts" />
|
||||
/// <reference path="../../knockout.mapping/knockout.mapping.d.ts" />
|
||||
|
||||
declare var $;
|
||||
|
||||
var dummyTemplateEngine = function (templates?) {
|
||||
var inMemoryTemplates = templates || {};
|
||||
var inMemoryTemplateData = {};
|
||||
@@ -137,7 +135,7 @@ describe('Templating', function() {
|
||||
});
|
||||
|
||||
it('Should automatically rerender into DOM element when dependencies change', function () {
|
||||
var dependency = new ko.observable("A");
|
||||
var dependency = ko.observable("A");
|
||||
ko.setTemplateEngine(new dummyTemplateEngine({ someTemplate: function () {
|
||||
return "Value = " + dependency();
|
||||
}
|
||||
@@ -153,7 +151,7 @@ describe('Templating', function() {
|
||||
});
|
||||
|
||||
it('Should not rerender DOM element if observable accessed in \'afterRender\' callaback is changed', function () {
|
||||
var observable = new ko.observable("A"), count = 0;
|
||||
var observable = ko.observable("A"), count = 0;
|
||||
var myCallback = function(elementsArray, dataItem) {
|
||||
observable(); // access observable in callback
|
||||
};
|
||||
@@ -171,7 +169,7 @@ describe('Templating', function() {
|
||||
});
|
||||
|
||||
it('If the supplied data item is observable, evaluates it and has subscription on it', function () {
|
||||
var observable = new ko.observable("A");
|
||||
var observable = ko.observable("A");
|
||||
ko.setTemplateEngine(new dummyTemplateEngine({ someTemplate: function (data) {
|
||||
return "Value = " + data;
|
||||
}
|
||||
@@ -184,7 +182,7 @@ describe('Templating', function() {
|
||||
});
|
||||
|
||||
it('Should stop updating DOM nodes when the dependency next changes if the DOM node has been removed from the document', function () {
|
||||
var dependency = new ko.observable("A");
|
||||
var dependency = ko.observable("A");
|
||||
var template = { someTemplate: function () { return "Value = " + dependency() } };
|
||||
ko.setTemplateEngine(new dummyTemplateEngine(template));
|
||||
|
||||
@@ -275,7 +273,7 @@ describe('Templating', function() {
|
||||
});
|
||||
|
||||
it('Should rerender chained templates when their dependencies change, without rerendering parent templates', function () {
|
||||
var observable = new ko.observable("ABC");
|
||||
var observable = ko.observable("ABC");
|
||||
var timesRenderedOuter = 0, timesRenderedInner = 0;
|
||||
ko.setTemplateEngine(new dummyTemplateEngine({
|
||||
outerTemplate: function () { timesRenderedOuter++; return "outer template output, [renderTemplate:innerTemplate]" }, // [renderTemplate:...] is special syntax supported by dummy template engine
|
||||
@@ -390,7 +388,7 @@ describe('Templating', function() {
|
||||
});
|
||||
|
||||
it('Data binding syntax should support \'foreach\' option, whereby it renders for each item in an array but doesn\'t rerender everything if you push or splice', function () {
|
||||
var myArray = new ko.observableArray([{ personName: "Bob" }, { personName: "Frank"}]);
|
||||
var myArray = ko.observableArray([{ personName: "Bob" }, { personName: "Frank"}]);
|
||||
ko.setTemplateEngine(new dummyTemplateEngine({ itemTemplate: "<div>The item is [js: personName]</div>" }));
|
||||
testNode.innerHTML = "<div data-bind='template: { name: \"itemTemplate\", foreach: myCollection }'></div>";
|
||||
|
||||
@@ -406,7 +404,7 @@ describe('Templating', function() {
|
||||
});
|
||||
|
||||
it('Data binding \'foreach\' option should apply bindings within the context of each item in the array', function () {
|
||||
var myArray = new ko.observableArray([{ personName: "Bob" }, { personName: "Frank"}]);
|
||||
var myArray = ko.observableArray([{ personName: "Bob" }, { personName: "Frank"}]);
|
||||
ko.setTemplateEngine(new dummyTemplateEngine({ itemTemplate: "The item is <span data-bind='text: personName'></span>" }));
|
||||
testNode.innerHTML = "<div data-bind='template: { name: \"itemTemplate\", foreach: myCollection }'></div>";
|
||||
|
||||
@@ -479,7 +477,7 @@ describe('Templating', function() {
|
||||
});
|
||||
|
||||
it('Data binding \'foreach\' option should apply bindings with an $index in the context', function () {
|
||||
var myArray = new ko.observableArray([{ personName: "Bob" }, { personName: "Frank"}]);
|
||||
var myArray = ko.observableArray([{ personName: "Bob" }, { personName: "Frank"}]);
|
||||
ko.setTemplateEngine(new dummyTemplateEngine({ itemTemplate: "The item # is <span data-bind='text: $index'></span>" }));
|
||||
testNode.innerHTML = "<div data-bind='template: { name: \"itemTemplate\", foreach: myCollection }'></div>";
|
||||
|
||||
@@ -488,7 +486,7 @@ describe('Templating', function() {
|
||||
});
|
||||
|
||||
it('Data binding \'foreach\' option should update bindings that reference an $index if the list changes', function () {
|
||||
var myArray = new ko.observableArray([{ personName: "Bob" }, { personName: "Frank"}]);
|
||||
var myArray = ko.observableArray([{ personName: "Bob" }, { personName: "Frank"}]);
|
||||
ko.setTemplateEngine(new dummyTemplateEngine({ itemTemplate: "The item <span data-bind='text: personName'></span>is <span data-bind='text: $index'></span>" }));
|
||||
testNode.innerHTML = "<div data-bind='template: { name: \"itemTemplate\", foreach: myCollection }'></div>";
|
||||
|
||||
@@ -504,7 +502,7 @@ describe('Templating', function() {
|
||||
});
|
||||
|
||||
it('Data binding \'foreach\' option should accept array with "undefined" and "null" items', function () {
|
||||
var myArray = new ko.observableArray([undefined, null]);
|
||||
var myArray = ko.observableArray([undefined, null]);
|
||||
ko.setTemplateEngine(new dummyTemplateEngine({ itemTemplate: "The item is <span data-bind='text: String($data)'></span>" }));
|
||||
testNode.innerHTML = "<div data-bind='template: { name: \"itemTemplate\", foreach: myCollection }'></div>";
|
||||
|
||||
@@ -513,8 +511,8 @@ describe('Templating', function() {
|
||||
});
|
||||
|
||||
it('Data binding \'foreach\' option should update DOM nodes when a dependency of their mapping function changes', function() {
|
||||
var myObservable = new ko.observable("Steve");
|
||||
var myArray = new ko.observableArray([{ personName: "Bob" }, { personName: myObservable }, { personName: "Another" }]);
|
||||
var myObservable = ko.observable("Steve");
|
||||
var myArray = ko.observableArray([{ personName: "Bob" }, { personName: myObservable }, { personName: "Another" }]);
|
||||
ko.setTemplateEngine(new dummyTemplateEngine({ itemTemplate: "<div>The item is [js: ko.utils.unwrapObservable(personName)]</div>" }));
|
||||
testNode.innerHTML = "<div data-bind='template: { name: \"itemTemplate\", foreach: myCollection }'></div>";
|
||||
|
||||
@@ -535,7 +533,7 @@ describe('Templating', function() {
|
||||
});
|
||||
|
||||
it('Data binding \'foreach\' option should treat a null parameter as meaning \'no items\'', function() {
|
||||
var myArray = new ko.observableArray(["A", "B"]);
|
||||
var myArray = ko.observableArray(["A", "B"]);
|
||||
ko.setTemplateEngine(new dummyTemplateEngine({ itemTemplate: "hello" }));
|
||||
testNode.innerHTML = "<div data-bind='template: { name: \"itemTemplate\", foreach: myCollection }'></div>";
|
||||
|
||||
@@ -551,7 +549,7 @@ describe('Templating', function() {
|
||||
it('Data binding \'foreach\' option should accept an \"as\" option to define an alias for the iteration variable', function() {
|
||||
// Note: There are more detailed specs (e.g., covering nesting) associated with the "foreach" binding which
|
||||
// uses this templating functionality internally.
|
||||
var myArray = new ko.observableArray(["A", "B"]);
|
||||
var myArray = ko.observableArray(["A", "B"]);
|
||||
ko.setTemplateEngine(new dummyTemplateEngine({ itemTemplate: "[js:myAliasedItem]" }));
|
||||
testNode.innerHTML = "<div data-bind='template: { name: \"itemTemplate\", foreach: myCollection, as: \"myAliasedItem\" }'></div>";
|
||||
|
||||
@@ -561,7 +559,7 @@ describe('Templating', function() {
|
||||
|
||||
it('Data binding \'foreach\' option should stop tracking inner observables when the container node is removed', function() {
|
||||
var innerObservable = ko.observable("some value");
|
||||
var myArray = new ko.observableArray([{obsVal:innerObservable}, {obsVal:innerObservable}]);
|
||||
var myArray = ko.observableArray([{obsVal:innerObservable}, {obsVal:innerObservable}]);
|
||||
ko.setTemplateEngine(new dummyTemplateEngine({ itemTemplate: "The item is [js: ko.utils.unwrapObservable(obsVal)]" }));
|
||||
testNode.innerHTML = "<div data-bind='template: { name: \"itemTemplate\", foreach: myCollection }'></div>";
|
||||
|
||||
@@ -574,7 +572,7 @@ describe('Templating', function() {
|
||||
|
||||
it('Data binding \'foreach\' option should stop tracking inner observables related to each array item when that array item is removed', function() {
|
||||
var innerObservable = ko.observable("some value");
|
||||
var myArray = new ko.observableArray([{obsVal:innerObservable}, {obsVal:innerObservable}]);
|
||||
var myArray = ko.observableArray([{obsVal:innerObservable}, {obsVal:innerObservable}]);
|
||||
ko.setTemplateEngine(new dummyTemplateEngine({ itemTemplate: "The item is [js: ko.utils.unwrapObservable(obsVal)]" }));
|
||||
testNode.innerHTML = "<div data-bind='template: { name: \"itemTemplate\", foreach: myCollection }'></div>";
|
||||
|
||||
@@ -588,7 +586,7 @@ describe('Templating', function() {
|
||||
});
|
||||
|
||||
it('Data binding syntax should omit any items whose \'_destroy\' flag is set (unwrapping the flag if it is observable)', function() {
|
||||
var myArray = new ko.observableArray([{ someProp: 1 }, { someProp: 2, _destroy: 'evals to true' }, { someProp : 3 }, { someProp: 4, _destroy: ko.observable(false) }]);
|
||||
var myArray = ko.observableArray([{ someProp: 1 }, { someProp: 2, _destroy: 'evals to true' }, { someProp : 3 }, { someProp: 4, _destroy: ko.observable(false) }]);
|
||||
ko.setTemplateEngine(new dummyTemplateEngine({ itemTemplate: "<div>someProp=[js: someProp]</div>" }));
|
||||
testNode.innerHTML = "<div data-bind='template: { name: \"itemTemplate\", foreach: myCollection }'></div>";
|
||||
|
||||
@@ -597,7 +595,7 @@ describe('Templating', function() {
|
||||
});
|
||||
|
||||
it('Data binding syntax should include any items whose \'_destroy\' flag is set if you use includeDestroyed', function() {
|
||||
var myArray = new ko.observableArray([{ someProp: 1 }, { someProp: 2, _destroy: 'evals to true' }, { someProp : 3 }]);
|
||||
var myArray = ko.observableArray([{ someProp: 1 }, { someProp: 2, _destroy: 'evals to true' }, { someProp : 3 }]);
|
||||
ko.setTemplateEngine(new dummyTemplateEngine({ itemTemplate: "<div>someProp=[js: someProp]</div>" }));
|
||||
testNode.innerHTML = "<div data-bind='template: { name: \"itemTemplate\", foreach: myCollection, includeDestroyed: true }'></div>";
|
||||
|
||||
@@ -677,7 +675,7 @@ describe('Templating', function() {
|
||||
});
|
||||
|
||||
it('Should be able to render a different template for each array entry by passing a function as template name, with the array entry\'s binding context available as a second parameter', function() {
|
||||
var myArray = new ko.observableArray([
|
||||
var myArray = ko.observableArray([
|
||||
{ preferredTemplate: 1, someProperty: 'firstItemValue' },
|
||||
{ preferredTemplate: 2, someProperty: 'secondItemValue' }
|
||||
]);
|
||||
@@ -700,7 +698,7 @@ describe('Templating', function() {
|
||||
it('Data binding \'templateOptions\' should be passed to template', function() {
|
||||
var myModel = {
|
||||
someAdditionalData: { myAdditionalProp: "someAdditionalValue" },
|
||||
people: new ko.observableArray([
|
||||
people: ko.observableArray([
|
||||
{ name: "Alpha" },
|
||||
{ name: "Beta" }
|
||||
])
|
||||
|
||||
@@ -53,7 +53,7 @@ function test_computed() {
|
||||
});
|
||||
}
|
||||
|
||||
function MyViewModel() {
|
||||
function MyViewModel1() {
|
||||
this.price = ko.observable(25.99);
|
||||
|
||||
this.formattedPrice = ko.computed({
|
||||
@@ -68,7 +68,7 @@ function test_computed() {
|
||||
});
|
||||
}
|
||||
|
||||
function MyViewModel() {
|
||||
function MyViewModel2() {
|
||||
this.acceptedNumericValue = ko.observable(123);
|
||||
this.lastInputWasValid = ko.observable(true);
|
||||
|
||||
@@ -90,13 +90,13 @@ function test_computed() {
|
||||
}
|
||||
|
||||
class GetterViewModel {
|
||||
private _selectedRange: KnockoutObservableAny;
|
||||
private _selectedRange: KnockoutObservable<any>;
|
||||
|
||||
constructor() {
|
||||
this._selectedRange = ko.observable();
|
||||
}
|
||||
|
||||
public range: KnockoutObservableAny;
|
||||
public range: KnockoutObservable<any>;
|
||||
}
|
||||
|
||||
function testGetter() {
|
||||
@@ -333,12 +333,12 @@ function test_more() {
|
||||
return target;
|
||||
};
|
||||
|
||||
function AppViewModel(first, last) {
|
||||
function AppViewModel2(first, last) {
|
||||
this.firstName = ko.observable(first).extend({ required: "Please enter a first name" });
|
||||
this.lastName = ko.observable(last).extend({ required: "" });
|
||||
}
|
||||
|
||||
ko.applyBindings(new AppViewModel("Bob", "Smith"));
|
||||
ko.applyBindings(new AppViewModel2("Bob", "Smith"));
|
||||
|
||||
var first;
|
||||
this.firstName = ko.observable(first).extend({ required: "Please enter a first name", logChange: "first name" });
|
||||
@@ -347,7 +347,7 @@ function test_more() {
|
||||
return name.toUpperCase();
|
||||
}).extend({ throttle: 500 });
|
||||
|
||||
function AppViewModel() {
|
||||
function AppViewModel3() {
|
||||
this.instantaneousValue = ko.observable();
|
||||
this.throttledValue = ko.computed(this.instantaneousValue)
|
||||
.extend({ throttle: 400 });
|
||||
@@ -420,7 +420,7 @@ function test_more() {
|
||||
this.done = ko.observable(done);
|
||||
}
|
||||
|
||||
function AppViewModel() {
|
||||
function AppViewModel4() {
|
||||
this.tasks = ko.observableArray([
|
||||
new Task('Find new desktop background', true),
|
||||
new Task('Put shiny stickers on laptop', false),
|
||||
@@ -430,7 +430,7 @@ function test_more() {
|
||||
this.doneTasks = this.tasks.filterByProperty("done", true);
|
||||
}
|
||||
|
||||
ko.applyBindings(new AppViewModel());
|
||||
ko.applyBindings(new AppViewModel4());
|
||||
this.doneTasks = ko.computed(function () {
|
||||
var all = this.tasks(), done = [];
|
||||
for (var i = 0; i < all.length; i++)
|
||||
@@ -441,7 +441,7 @@ function test_more() {
|
||||
}
|
||||
|
||||
function test_mappingplugin() {
|
||||
var viewModel = {
|
||||
var viewModel0 = {
|
||||
serverTime: ko.observable(),
|
||||
numUsers: ko.observable()
|
||||
}
|
||||
@@ -449,8 +449,8 @@ function test_mappingplugin() {
|
||||
serverTime: '2010-01-07',
|
||||
numUsers: 3
|
||||
};
|
||||
viewModel.serverTime(data.serverTime);
|
||||
viewModel.numUsers(data.numUsers);
|
||||
viewModel0.serverTime(data.serverTime);
|
||||
viewModel0.numUsers(data.numUsers);
|
||||
|
||||
var viewModel = ko.mapping.fromJS(data);
|
||||
ko.mapping.fromJS(data, viewModel);
|
||||
@@ -526,7 +526,7 @@ function test_misc() {
|
||||
return this;
|
||||
};
|
||||
|
||||
this.myObservable = <KnockoutObservableString>ko.observable("myValue").publishOn("myTopic");
|
||||
this.myObservable = <KnockoutObservable<string>>ko.observable("myValue").publishOn("myTopic");
|
||||
|
||||
ko.subscribable.fn.subscribeTo = function (topic) {
|
||||
postbox.subscribe(this, null, topic);
|
||||
@@ -534,7 +534,7 @@ function test_misc() {
|
||||
return this;
|
||||
};
|
||||
|
||||
this.observableFromAnotherVM = <KnockoutObservableAny>ko.observable().subscribeTo("myTopic");
|
||||
this.observableFromAnotherVM = <KnockoutObservable<any>>ko.observable().subscribeTo("myTopic");
|
||||
|
||||
postbox.subscribe(function (newValue) {
|
||||
this(newValue);
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/// <reference path="ladda.d.ts" />
|
||||
|
||||
// Test bind
|
||||
Ladda.bind('button.ladda-button', { timeout: 42, callback: btn => alert('Clicked!!!') });
|
||||
Ladda.bind('button.ladda-button');
|
||||
Ladda.bind(document.createElement('button'), {});
|
||||
Ladda.bind(document.createElement('button'));
|
||||
|
||||
// Test stop all
|
||||
Ladda.stopAll();
|
||||
|
||||
// Test create
|
||||
var btnElement = document.createElement('button');
|
||||
var laddaBtn = Ladda.create(btnElement);
|
||||
|
||||
// Test operations via chaining
|
||||
laddaBtn.start().stop().toggle().setProgress(42).enable().disable().start();
|
||||
|
||||
// Test isLoading
|
||||
console.assert(laddaBtn.isLoading() === true);
|
||||
Vendored
+35
@@ -0,0 +1,35 @@
|
||||
// Type definitions for jStorage 0.4.0
|
||||
// Project: https://github.com/hakimel/Ladda
|
||||
// Definitions by: Danil Flores <https://github.com/dflor003/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module Ladda {
|
||||
|
||||
interface ILaddaButton {
|
||||
start(): ILaddaButton;
|
||||
|
||||
stop(): ILaddaButton;
|
||||
|
||||
toggle(): ILaddaButton;
|
||||
|
||||
setProgress(progress: number): ILaddaButton;
|
||||
|
||||
enable(): ILaddaButton;
|
||||
|
||||
disable(): ILaddaButton;
|
||||
|
||||
isLoading(): boolean;
|
||||
}
|
||||
|
||||
interface ILaddaOptions {
|
||||
timeout?: number;
|
||||
callback?: (instance: ILaddaButton) => void;
|
||||
}
|
||||
|
||||
function bind(target: HTMLElement, options?: ILaddaOptions): void;
|
||||
function bind(cssSelector: string, options?: ILaddaOptions): void;
|
||||
|
||||
function create(button: HTMLElement): ILaddaButton;
|
||||
|
||||
function stopAll(): void;
|
||||
}
|
||||
Vendored
+18
-14
@@ -312,7 +312,7 @@ declare module "cluster" {
|
||||
}
|
||||
export interface Worker {
|
||||
id: string;
|
||||
process: child_process;
|
||||
process: child_process.ChildProcess;
|
||||
suicide: boolean;
|
||||
send(message: any, sendHandle?: any): void;
|
||||
destroy(): void;
|
||||
@@ -1019,19 +1019,23 @@ declare module "util" {
|
||||
}
|
||||
|
||||
declare module "assert" {
|
||||
export function (booleanValue: boolean, message?: string);
|
||||
export function fail(actual: any, expected: any, message: string, operator: string): void;
|
||||
export function assert(value: any, message: string): void;
|
||||
export function ok(value: any, message?: string): void;
|
||||
export function equal(actual: any, expected: any, message?: string): void;
|
||||
export function notEqual(actual: any, expected: any, message?: string): void;
|
||||
export function deepEqual(actual: any, expected: any, message?: string): void;
|
||||
export function notDeepEqual(acutal: any, expected: any, message?: string): void;
|
||||
export function strictEqual(actual: any, expected: any, message?: string): void;
|
||||
export function notStrictEqual(actual: any, expected: any, message?: string): void;
|
||||
export function throws(block: any, error?: any, messsage?: string): void;
|
||||
export function doesNotThrow(block: any, error?: any, messsage?: string): void;
|
||||
export function ifError(value: any): void;
|
||||
function internal (booleanValue: boolean, message?: string): void;
|
||||
module internal {
|
||||
export function fail(actual: any, expected: any, message: string, operator: string): void;
|
||||
export function assert(value: any, message: string): void;
|
||||
export function ok(value: any, message?: string): void;
|
||||
export function equal(actual: any, expected: any, message?: string): void;
|
||||
export function notEqual(actual: any, expected: any, message?: string): void;
|
||||
export function deepEqual(actual: any, expected: any, message?: string): void;
|
||||
export function notDeepEqual(acutal: any, expected: any, message?: string): void;
|
||||
export function strictEqual(actual: any, expected: any, message?: string): void;
|
||||
export function notStrictEqual(actual: any, expected: any, message?: string): void;
|
||||
export function throws(block: any, error?: any, messsage?: string): void;
|
||||
export function doesNotThrow(block: any, error?: any, messsage?: string): void;
|
||||
export function ifError(value: any): void;
|
||||
}
|
||||
|
||||
export = internal;
|
||||
}
|
||||
|
||||
declare module "tty" {
|
||||
|
||||
+1
-1
@@ -2,6 +2,6 @@
|
||||
"name": "DefinitelyTyped",
|
||||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"test": "node ./_infrastructure/tests/testRunner.js"
|
||||
"test": "node ./_infrastructure/tests/runner.js"
|
||||
}
|
||||
}
|
||||
|
||||
+16
-11
@@ -1,6 +1,10 @@
|
||||
/// <reference path="Q.d.ts" />
|
||||
|
||||
var delay = function (delay) {
|
||||
import q = module('q');
|
||||
|
||||
Q(8).then(x => console.log(x.toExponential()));
|
||||
|
||||
var delay = function (delay: number) {
|
||||
var d = Q.defer();
|
||||
setTimeout(d.resolve, delay);
|
||||
return d.promise;
|
||||
@@ -10,6 +14,14 @@ Q.when(delay(1000), function () {
|
||||
console.log('Hello, World!');
|
||||
});
|
||||
|
||||
Q.delay(Q(8), 1000).then(x => x.toExponential());
|
||||
Q.delay(8, 1000).then(x => x.toExponential());
|
||||
Q.delay(Q("asdf"), 1000).then(x => x.length);
|
||||
Q.delay("asdf", 1000).then(x => x.length);
|
||||
|
||||
var eventualAdd = Q.promised((a: number, b: number) => a + b);
|
||||
eventualAdd(Q(1), Q(2)).then(x => x.toExponential());
|
||||
|
||||
var eventually = function (eventually) {
|
||||
return Q.delay(eventually, 1000);
|
||||
};
|
||||
@@ -22,11 +34,11 @@ Q.when(x, function (x) {
|
||||
Q.all([
|
||||
eventually(10),
|
||||
eventually(20)
|
||||
])
|
||||
.spread(function (x, y) {
|
||||
]).spread(function (x, y) {
|
||||
console.log(x, y);
|
||||
});
|
||||
|
||||
|
||||
Q.fcall(function () { })
|
||||
.then(function () { })
|
||||
.then(function () { })
|
||||
@@ -38,7 +50,7 @@ Q.fcall(function () { })
|
||||
}).done();
|
||||
|
||||
Q.allResolved([])
|
||||
.then(function (promises: Qpromise[]) {
|
||||
.then(function (promises: Q.Promise<any>[]) {
|
||||
promises.forEach(function (promise) {
|
||||
if (promise.isFulfilled()) {
|
||||
var value = promise.valueOf();
|
||||
@@ -46,11 +58,4 @@ Q.allResolved([])
|
||||
var exception = promise.valueOf().exception;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
var initialVal: any;
|
||||
var funcs = ['foo', 'bar', 'baz', 'qux'];
|
||||
var result = Q.resolve(initialVal);
|
||||
funcs.forEach(function (f) {
|
||||
result = result.then(f);
|
||||
});
|
||||
@@ -1,64 +1,75 @@
|
||||
// Type definitions for Q
|
||||
// Project: https://github.com/kriskowal/q
|
||||
// Definitions by: Barrie Nemetchek
|
||||
// Definitions by: Barrie Nemetchek, Andrew Gaspar
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface Qdeferred {
|
||||
promise: Qpromise;
|
||||
resolve(value: any): any;
|
||||
reject(reason: any);
|
||||
notify(value: any);
|
||||
makeNodeResolver(): () => void;
|
||||
declare function Q<T>(value): Q.Promise<T>;
|
||||
|
||||
declare module Q {
|
||||
interface Deferred<T> {
|
||||
promise: Promise<T>;
|
||||
resolve(value: T): any;
|
||||
reject(reason: any);
|
||||
notify(value: any);
|
||||
makeNodeResolver(): (reason, value: T) => void;
|
||||
}
|
||||
|
||||
interface Promise<T> {
|
||||
fail(errorCallback: Function): Promise<any>;
|
||||
fin(finallyCallback: Function): Promise<T>;
|
||||
finally(finallyCallback: Function): Promise<T>;
|
||||
then(onFulfilled?: (value: T) => any, onRejected?: (reason) => any, onProgress?: Function): Promise<any>;
|
||||
spread(onFulfilled: Function, onRejected?: Function): Promise<any>;
|
||||
catch(onRejected: Function): Promise<any>;
|
||||
progress(onProgress: Function): Promise<any>;
|
||||
done(onFulfilled?: Function, onRejected?: Function, onProgress?: Function): void;
|
||||
get(propertyName: String): Promise<any>;
|
||||
set(propertyName: String, value: any): Promise<any>;
|
||||
delete(propertyName: String): Promise<any>;
|
||||
post(methodName: String, args: any[]): Promise<any>;
|
||||
invoke(methodName: String, ...args: any[]): Promise<any>;
|
||||
keys(): Promise<string[]>;
|
||||
fapply(args: any[]): Promise<any>;
|
||||
fcall(method: Function, ...args: any[]): Promise<any>;
|
||||
timeout(ms: number, message?): Promise<T>;
|
||||
delay(ms: number): Promise<T>;
|
||||
isFulfilled(): boolean;
|
||||
isRejected(): boolean;
|
||||
isPending(): boolean;
|
||||
valueOf(): any;
|
||||
}
|
||||
|
||||
export function when(value: any, onFulfilled: Function, onRejected?: Function): Promise<any>;
|
||||
//export function try(method: Function, ...args: any[]): Promise<any>; // <- This is broken currently - not sure how to fix.
|
||||
export function fbind(method: Function, ...args: any[]): Promise<any>;
|
||||
export function fcall(method: Function, ...args: any[]): Promise<any>;
|
||||
export function nfbind(nodeFunction: Function): (...args: any[]) => Promise<any>;
|
||||
export function nfcall(nodeFunction: Function, ...args: any[]): Promise<any>;
|
||||
export function ninvoke(nodeModule: any, functionName: string, ...args: any[]): Promise<any>;
|
||||
export function all(promises: Promise<any>[]): Promise<any>;
|
||||
export function allResolved(promises: Promise<any>[]): Promise<any>;
|
||||
export function spread(onFulfilled: Function, onRejected: Function): Promise<any>;
|
||||
export function timeout<T>(promise: Promise<T>, ms: number, message?): Promise<T>;
|
||||
export function delay<T>(promise: Promise<T>, ms: number): Promise<T>;
|
||||
export function delay<T>(value: T, ms: number): Promise<T>;
|
||||
export function isFulfilled(promise: Promise<any>): boolean;
|
||||
export function isRejected(promise: Promise<any>): boolean;
|
||||
export function isPending(promise: Promise<any>): boolean;
|
||||
export function valueOf<T>(promise: Promise<T>): T;
|
||||
export function defer<T>(): Deferred<T>;
|
||||
export function reject(reason?): Promise<any>;
|
||||
export function promise<T>(factory: { resolve: Function; reject: Function; notify: Function; }): Promise<T>;
|
||||
export function promised<T>(callback: (...any) => T): (...any) => Promise<T>;
|
||||
export function isPromise(object): boolean;
|
||||
export function isPromiseAlike(object): boolean;
|
||||
export function isPending(object): boolean;
|
||||
export function async<T>(generatorFunction: any): (...args) => Promise<T>;
|
||||
export function nextTick(callback: Function): void;
|
||||
export var oneerror: () => void;
|
||||
export var longStackSupport: boolean;
|
||||
export function resolve<T>(object): Promise<T>;
|
||||
}
|
||||
|
||||
interface Qpromise {
|
||||
fail(errorCallback: Function): Qpromise;
|
||||
fin(finallyCallback: Function): Qpromise;
|
||||
then(onFulfilled?: Function, onRejected?: Function, onProgress?: Function): Qpromise;
|
||||
spread(onFulfilled: Function, onRejected?: Function): Qpromise;
|
||||
catch(onRejected: Function): Qpromise;
|
||||
progress(onProgress: Function): Qpromise;
|
||||
done(onFulfilled?: Function, onRejected?: Function, onProgress?: Function): Qpromise;
|
||||
get (propertyName: String): Qpromise;
|
||||
set (propertyName: String, value: any): Qpromise;
|
||||
delete (propertyName: String): Qpromise;
|
||||
post(methodName: String, args: any[]): Qpromise;
|
||||
invoke(methodName: String, ...args: any[]): Qpromise;
|
||||
keys(): Qpromise;
|
||||
fapply(args: any[]): Qpromise;
|
||||
fcall(method: Function, ...args: any[]): Qpromise;
|
||||
timeout(ms: number): Qpromise;
|
||||
delay(ms: number): Qpromise;
|
||||
isFulfilled(): bool;
|
||||
isRejected(): bool;
|
||||
isPending(): bool;
|
||||
valueOf(): any;
|
||||
}
|
||||
|
||||
interface QStatic {
|
||||
when(value: any, onFulfilled?: Function, onRejected?: Function): Qpromise;
|
||||
try(method: Function, ...args: any[]): Qpromise;
|
||||
fbind(method: Function, ...args: any[]): Qpromise;
|
||||
fcall(method: Function, ...args: any[]): Qpromise;
|
||||
all(promises: Qpromise[]): Qpromise;
|
||||
allResolved(promises: Qpromise[]): Qpromise;
|
||||
resolve(object:any):Qpromise;
|
||||
spread(onFulfilled: Function, onRejected: Function): Qpromise;
|
||||
timeout(ms: number): Qpromise;
|
||||
delay(ms: number): Qpromise;
|
||||
delay(value: any, ms: number): Qpromise;
|
||||
isFulfilled(): bool;
|
||||
isRejected(): bool;
|
||||
isPending(): bool;
|
||||
valueOf(): any;
|
||||
defer(): Qdeferred;
|
||||
(value: any): Qpromise;
|
||||
reject(): Qpromise;
|
||||
promise(factory: { resolve: Function; reject: Function; notify: Function; }): Qpromise;
|
||||
isPromise(value: any): bool;
|
||||
async(generatorFunction: any): Qdeferred;
|
||||
nextTick(callback: Function);
|
||||
oneerror: any;
|
||||
longStackJumpLimit: number;
|
||||
}
|
||||
declare var Q: QStatic;
|
||||
declare module "q" {
|
||||
export = Q;
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/// <reference path="q.module.d.ts" />
|
||||
/// <reference path="../jasmine/jasmine.d.ts" />
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
import Q = module("q");
|
||||
import fs = module("fs");
|
||||
|
||||
var delay = function (delay) {
|
||||
var d = Q.defer();
|
||||
setTimeout(d.resolve, delay);
|
||||
return d.promise;
|
||||
};
|
||||
|
||||
Q.when(delay(1000), function () {
|
||||
console.log('Hello, World!');
|
||||
});
|
||||
|
||||
var eventually = function (eventually) {
|
||||
return Q.delay(eventually, 1000);
|
||||
};
|
||||
|
||||
var x = Q.all([1, 2, 3].map(eventually));
|
||||
Q.when(x, function (x) {
|
||||
console.log(x);
|
||||
});
|
||||
|
||||
Q.all([
|
||||
eventually(10),
|
||||
eventually(20)
|
||||
])
|
||||
.spread(function (x, y) {
|
||||
console.log(x, y);
|
||||
});
|
||||
|
||||
Q.fcall(function () { })
|
||||
.then(function () { })
|
||||
.then(function () { })
|
||||
.then(function () { })
|
||||
.then(function (value4) {
|
||||
// Do something with value4
|
||||
}, function (error) {
|
||||
// Handle any error from step1 through step4
|
||||
}).done();
|
||||
|
||||
Q.allResolved([])
|
||||
.then(function (promises: Qpromise[]) {
|
||||
promises.forEach(function (promise) {
|
||||
if (promise.isFulfilled()) {
|
||||
var value = promise.valueOf();
|
||||
} else {
|
||||
var exception = promise.valueOf().exception;
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
var initialVal: any;
|
||||
var funcs = ['foo', 'bar', 'baz', 'qux'];
|
||||
var result = Q.resolve(initialVal);
|
||||
funcs.forEach(function (f) {
|
||||
result = result.then(f);
|
||||
});
|
||||
|
||||
var replaceText = (text: string) => text.replace("a", "b");
|
||||
|
||||
Q.nfcall(fs.readFile, "foo.txt", "utf-8").then(replaceText);
|
||||
|
||||
Q.ninvoke(fs, "readFile", "foo.txt", "utf-8").then(replaceText);
|
||||
|
||||
var deferred = Q.defer();
|
||||
fs.readFile("foo.txt", "utf-8", deferred.makeNodeResolver());
|
||||
deferred.promise.then(replaceText);
|
||||
|
||||
var readFile = Q.nfbind(fs.readFile);
|
||||
readFile("foo.txt", "utf-8").then(replaceText);
|
||||
Vendored
-31
@@ -1,31 +0,0 @@
|
||||
/// <reference path="Q.d.ts" />
|
||||
|
||||
declare module "q" {
|
||||
export function when(value: any, onFulfilled: Function, onRejected?: Function): Qpromise;
|
||||
export function try(method: Function, ...args: any[]): Qpromise;
|
||||
export function fbind(method: Function, ...args: any[]): Qpromise;
|
||||
export function fcall(method: Function, ...args: any[]): Qpromise;
|
||||
export function nfbind(nodeFunction: Function): (...args: any[]) => Qpromise;
|
||||
export function nfcall(nodeFunction: Function, ...args: any[]): Qpromise;
|
||||
export function ninvoke(nodeModule: any, functionName: string, ...args: any[]): Qpromise;
|
||||
export function all(promises: Qpromise[]): Qpromise;
|
||||
export function allResolved(promises: Qpromise[]): Qpromise;
|
||||
export function spread(onFulfilled: Function, onRejected: Function): Qpromise;
|
||||
export function timeout(ms: number): Qpromise;
|
||||
export function delay(ms: number): Qpromise;
|
||||
export function delay(value: any, ms: number): Qpromise;
|
||||
export function isFulfilled(): bool;
|
||||
export function isRejected(): bool;
|
||||
export function isPending(): bool;
|
||||
export function valueOf(): any;
|
||||
export function defer(): Qdeferred;
|
||||
export function (value: any): Qpromise;
|
||||
export function reject(): Qpromise;
|
||||
export function promise(factory: { resolve: Function; reject: Function; notify: Function; }): Qpromise;
|
||||
export function isPromise(value: any): bool;
|
||||
export function async(generatorFunction: any): Qdeferred;
|
||||
export function nextTick(callback: Function);
|
||||
export var oneerror: any;
|
||||
export var longStackJumpLimit: number;
|
||||
export function resolve(object?:Qpromise);
|
||||
}
|
||||
@@ -122,7 +122,7 @@ test("a test", function () {
|
||||
QUnit.config.autostart = false;
|
||||
QUnit.start();
|
||||
|
||||
QUnit.config.urlConfig.push({
|
||||
QUnit.config.urlConfig.push(<any>{
|
||||
id: "min",
|
||||
label: "Minified source",
|
||||
tooltip: "Load minified source files instead of the regular unminified ones."
|
||||
@@ -729,13 +729,7 @@ test("just a test", function() {
|
||||
// ************** BUG ? ******************
|
||||
// TODO disable reordering for this suite!
|
||||
|
||||
var begin = 0,
|
||||
moduleStart = 0,
|
||||
moduleDone = 0,
|
||||
testStart = 0,
|
||||
testDone = 0,
|
||||
log = 0,
|
||||
moduleContext,
|
||||
var moduleContext,
|
||||
moduleDoneContext,
|
||||
testContext,
|
||||
testDoneContext,
|
||||
|
||||
Vendored
+1
@@ -134,6 +134,7 @@ interface Config {
|
||||
current: Object;
|
||||
reorder: bool;
|
||||
requireExpects: bool;
|
||||
testTimeout: number;
|
||||
urlConfig: Array;
|
||||
done: any;
|
||||
}
|
||||
|
||||
Vendored
-1
@@ -245,7 +245,6 @@ interface RaphaelStatic {
|
||||
format(token: string, ...parameters: any[]): string;
|
||||
fullfill(token: string, json: JSON): string;
|
||||
getColor(value?: number): string;
|
||||
getColor: { reset(); };
|
||||
getPointAtLength(path: string, length: number): { x: number; y: number; alpha: number; };
|
||||
getRGB(colour: string): { r: number; g: number; b: number; hex: string; error: bool; };
|
||||
getSubpath(path: string, from: number, to: number): string;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/// <reference path="../chai/chai.d.ts" />
|
||||
/// <reference path="sinon-chai.d.ts" />
|
||||
/// <reference path="../chai/chai.d.ts" />
|
||||
/// <reference path="sinon-chai.d.ts" />
|
||||
|
||||
var expect = chai.expect;
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -387,4 +387,4 @@ interface SinonStatic {
|
||||
log: (message: string) => void;
|
||||
}
|
||||
|
||||
var sinon: SinonStatic;
|
||||
declare var sinon: SinonStatic;
|
||||
|
||||
@@ -16,7 +16,6 @@ function test_basic() {
|
||||
toastr.options.onclick = function () { }
|
||||
}
|
||||
|
||||
declare var $;
|
||||
function test_fromdemo() {
|
||||
var i = -1,
|
||||
toastCount = 0,
|
||||
|
||||
Vendored
+1
-1
@@ -10,7 +10,7 @@
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
module createjs {
|
||||
declare module createjs {
|
||||
|
||||
export class TweenJS {
|
||||
// properties
|
||||
|
||||
Reference in New Issue
Block a user