mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
merge master
This commit is contained in:
Vendored
+2
-2
@@ -27,8 +27,7 @@ declare module Backbone {
|
||||
wait: bool;
|
||||
}
|
||||
|
||||
export class ModelBase {
|
||||
bind(eventName: string, handler: Function, ctx?: any);
|
||||
export class ModelBase extends Events {
|
||||
fetch(options? : ICallbackOptions);
|
||||
url: string; // or url(): string;
|
||||
parse(response);
|
||||
@@ -189,6 +188,7 @@ declare module Backbone {
|
||||
export var history: History;
|
||||
export class History {
|
||||
start(options? : IHistoryOptions );
|
||||
navigate(fragment: string, options: any);
|
||||
pushSate();
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1531
-1512
File diff suppressed because it is too large
Load Diff
Vendored
+222
@@ -0,0 +1,222 @@
|
||||
// Type definitions for linq.js 2.2
|
||||
// Project: http://linqjs.codeplex.com/
|
||||
// Definitions by: Marcin Najder
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// todo: jQuery plugin, RxJS Binding
|
||||
|
||||
module linq {
|
||||
|
||||
interface EnumerableStatic {
|
||||
Choice(...contents: any[]): Enumerable;
|
||||
Choice(contents: any[]): Enumerable;
|
||||
Cycle(...contents: any[]): Enumerable;
|
||||
Cycle(contents: any[]): Enumerable;
|
||||
Empty(): Enumerable;
|
||||
From(obj: any[]): Enumerable;
|
||||
From(obj: any): Enumerable;
|
||||
Return(element: any): Enumerable;
|
||||
Matches(input: string, pattern: RegExp): Enumerable;
|
||||
Matches(input: string, pattern: string, flags?: string): Enumerable;
|
||||
Range(start: number, count: number, step?: number): Enumerable;
|
||||
RangeDown(start: number, count: number, step?: number): Enumerable;
|
||||
RangeTo(start: number, to: number, step?: number): Enumerable;
|
||||
Repeat(obj: any, count?: number): Enumerable;
|
||||
RepeatWithFinalize(initializer: () => any, finalizer: (resource: any) =>void ): Enumerable;
|
||||
Generate(func: () => any, count?: number): Enumerable;
|
||||
Generate(func: string, count?: number): Enumerable;
|
||||
ToInfinity(start?: number, step?: number): Enumerable;
|
||||
ToNegativeInfinity(start?: number, step?: number): Enumerable;
|
||||
Unfold(seed, func: ($) => any): Enumerable;
|
||||
Unfold(seed, func: string): Enumerable;
|
||||
}
|
||||
|
||||
interface Enumerable {
|
||||
//Projection and Filtering Methods
|
||||
CascadeBreadthFirst(func: ($) => any[], resultSelector: (v, i: number) => any): Enumerable;
|
||||
CascadeBreadthFirst(func: string, resultSelector: string): Enumerable;
|
||||
CascadeDepthFirst(func: ($) => any[], resultSelector: (v, i: number) => any): Enumerable;
|
||||
CascadeDepthFirst(func: string, resultSelector: string): Enumerable;
|
||||
Flatten(...items: any[]): Enumerable;
|
||||
Pairwise(selector: (prev, next) => any): Enumerable;
|
||||
Pairwise(selector: string): Enumerable;
|
||||
Scan(func: (a, b) => any): Enumerable;
|
||||
Scan(func: string): Enumerable;
|
||||
Scan(seed, func: (a, b) => any, resultSelector?: ($) => any): Enumerable;
|
||||
Scan(seed, func: string, resultSelector?: string): Enumerable;
|
||||
Select(selector: ($, i: number) => any): Enumerable;
|
||||
Select(selector: string): Enumerable;
|
||||
SelectMany(collectionSelector: ($, i: number) => any[], resultSelector?: ($, item) => any): Enumerable;
|
||||
SelectMany(collectionSelector: ($, i: number) => Enumerable, resultSelector?: ($, item) => any): Enumerable;
|
||||
SelectMany(collectionSelector: string, resultSelector?: string): Enumerable;
|
||||
Where(predicate: ($, i: number) => bool): Enumerable;
|
||||
Where(predicate: string): Enumerable;
|
||||
OfType(type: Function): Enumerable;
|
||||
Zip(second: any[], selector: (v1, v2, i: number) => any): Enumerable;
|
||||
Zip(second: any[], selector: string): Enumerable;
|
||||
Zip(second: Enumerable, selector: (v1, v2, i: number) => any): Enumerable;
|
||||
Zip(second: Enumerable, selector: string): Enumerable;
|
||||
//Join Methods
|
||||
Join(inner: any[], outerKeySelector: (v1) => any, innerKeySelector: (v1) => any, resultSelector: (v1, v2) => any, compareSelector?: (v) => any): Enumerable;
|
||||
Join(inner: any[], outerKeySelector: string, innerKeySelector: string, resultSelector: string, compareSelector?: string): Enumerable;
|
||||
Join(inner: Enumerable, outerKeySelector: (v1) => any, innerKeySelector: (v1) => any, resultSelector: (v1, v2) => any, compareSelector?: (v) => any): Enumerable;
|
||||
Join(inner: Enumerable, outerKeySelector: string, innerKeySelector: string, resultSelector: string, compareSelector?: string): Enumerable;
|
||||
GroupJoin(inner: any[], outerKeySelector: (v1) => any, innerKeySelector: (v1) => any, resultSelector: (v1, v2: Enumerable) => any, compareSelector?: (v) => any): Enumerable;
|
||||
GroupJoin(inner: any[], outerKeySelector: string, innerKeySelector: string, resultSelector: string, compareSelector?: string): Enumerable;
|
||||
GroupJoin(inner: Enumerable, outerKeySelector: (v1) => any, innerKeySelector: (v1) => any, resultSelector: (v1, v2: Enumerable) => any, compareSelector?: (v) => any): Enumerable;
|
||||
GroupJoin(inner: Enumerable, outerKeySelector: string, innerKeySelector: string, resultSelector: string, compareSelector?: string): Enumerable;
|
||||
//Set Methods
|
||||
All(predicate: ($) => bool): bool;
|
||||
All(predicate: string): bool;
|
||||
Any(predicate?: ($) => bool): bool;
|
||||
Any(predicate?: string): bool;
|
||||
Concat(second: any[]): Enumerable;
|
||||
Concat(second: Enumerable): Enumerable;
|
||||
Insert(index: number, second: any[]): Enumerable;
|
||||
Insert(index: number, second: Enumerable): Enumerable;
|
||||
Alternate(value): Enumerable;
|
||||
Contains(value, compareSelector?: ($) => any): bool;
|
||||
Contains(value, compareSelector?: string): bool;
|
||||
DefaultIfEmpty(defaultValue): Enumerable;
|
||||
Distinct(compareSelector?: ($) => any): Enumerable;
|
||||
Distinct(compareSelector?: string): Enumerable;
|
||||
Except(second: any[], compareSelector?: ($) => any): Enumerable;
|
||||
Except(second: any[], compareSelector?: string): Enumerable;
|
||||
Except(second: Enumerable, compareSelector?: ($) => any): Enumerable;
|
||||
Except(second: Enumerable, compareSelector?: string): Enumerable;
|
||||
Intersect(second: any[], compareSelector?: ($) => any): Enumerable;
|
||||
Intersect(second: any[], compareSelector?: string): Enumerable;
|
||||
Intersect(second: Enumerable, compareSelector?: ($) => any): Enumerable;
|
||||
Intersect(second: Enumerable, compareSelector?: string): Enumerable;
|
||||
SequenceEqual(second: any[], compareSelector?: ($) => any): bool;
|
||||
SequenceEqual(second: any[], compareSelector?: string): bool;
|
||||
SequenceEqual(second: Enumerable, compareSelector?: ($) => any): bool;
|
||||
SequenceEqual(second: Enumerable, compareSelector?: string): bool;
|
||||
Union(second: any[], compareSelector?: ($) => any): Enumerable;
|
||||
Union(second: any[], compareSelector?: string): Enumerable;
|
||||
Union(second: Enumerable, compareSelector?: ($) => any): Enumerable;
|
||||
Union(second: Enumerable, compareSelector?: string): Enumerable;
|
||||
//Ordering Methods
|
||||
OrderBy(keySelector?: ($) => any): OrderedEnumerable;
|
||||
OrderBy(keySelector?: string): OrderedEnumerable;
|
||||
OrderByDescending(keySelector?: ($) => any): OrderedEnumerable;
|
||||
OrderByDescending(keySelector?: string): OrderedEnumerable;
|
||||
Reverse(): Enumerable;
|
||||
Shuffle(): Enumerable;
|
||||
//Grouping Methods
|
||||
GroupBy(keySelector: ($) => any, elementSelector?: ($) => any, resultSelector?: (key, e) => any, compareSelector?: ($) =>any): Enumerable;
|
||||
GroupBy(keySelector: string, elementSelector?: string, resultSelector?: string, compareSelector?: string): Enumerable;
|
||||
PartitionBy(keySelector: ($) => any, elementSelector?: ($) => any, resultSelector?: (key, e) => any, compareSelector?: ($) =>any): Enumerable;
|
||||
PartitionBy(keySelector: string, elementSelector?: string, resultSelector?: string, compareSelector?: string): Enumerable;
|
||||
BufferWithCount(count: number): Enumerable;
|
||||
// Aggregate Methods
|
||||
Aggregate(func: (a, b) => any);
|
||||
Aggregate(seed, func: (a, b) => any, resultSelector?: ($) => any);
|
||||
Aggregate(func: string);
|
||||
Aggregate(seed, func: string, resultSelector?: string);
|
||||
Average(selector?: ($) => number): number;
|
||||
Average(selector?: string): number;
|
||||
Count(predicate?: ($) => bool): number;
|
||||
Count(predicate?: string): number;
|
||||
Max(selector?: ($) => number): number;
|
||||
Max(selector?: string): number;
|
||||
Min(selector?: ($) => number): number;
|
||||
Min(selector?: string): number;
|
||||
MaxBy(selector: ($) => number): any;
|
||||
MaxBy(selector: string): any;
|
||||
MinBy(selector: ($) => number): any;
|
||||
MinBy(selector: string): any;
|
||||
Sum(selector?: ($) => number): number;
|
||||
Sum(selector?: string): number;
|
||||
//Paging Methods
|
||||
ElementAt(index: number): any;
|
||||
ElementAtOrDefault(index: number, defaultValue): any;
|
||||
First(predicate?: ($) => bool): any;
|
||||
First(predicate?: string): any;
|
||||
FirstOrDefault(defaultValue, predicate?: ($) => bool): any;
|
||||
FirstOrDefault(defaultValue, predicate?: string): any;
|
||||
Last(predicate?: ($) => bool): any;
|
||||
Last(predicate?: string): any;
|
||||
LastOrDefault(defaultValue, predicate?: ($) => bool): any;
|
||||
LastOrDefault(defaultValue, predicate?: string): any;
|
||||
Single(predicate?: ($) => bool): any;
|
||||
Single(predicate?: string): any;
|
||||
SingleOrDefault(defaultValue, predicate?: ($) => bool): any;
|
||||
SingleOrDefault(defaultValue, predicate?: string): any;
|
||||
Skip(count: number): Enumerable;
|
||||
SkipWhile(predicate: ($, i: number) => bool): Enumerable;
|
||||
SkipWhile(predicate: string): Enumerable;
|
||||
Take(count: number): Enumerable;
|
||||
TakeWhile(predicate: ($, i: number) => bool): Enumerable;
|
||||
TakeWhile(predicate: string): Enumerable;
|
||||
TakeExceptLast(count?: number): Enumerable;
|
||||
TakeFromLast(count: number): Enumerable;
|
||||
IndexOf(item): number;
|
||||
LastIndexOf(item): number;
|
||||
// Convert Methods
|
||||
ToArray(): any[];
|
||||
ToLookup(keySelector: ($) => any, elementSelector?: ($) => any, compareSelector?: (key) => any): Lookup;
|
||||
ToLookup(keySelector: string, elementSelector?: string, compareSelector?: string): Lookup;
|
||||
ToObject(keySelector: ($) => string, elementSelector: ($) => any): any;
|
||||
ToObject(keySelector: string, elementSelector: string): any;
|
||||
ToDictionary(keySelector: ($) => any, elementSelector: ($) => any, compareSelector?: (key) => any): Dictionary;
|
||||
ToDictionary(keySelector: string, elementSelector: string, compareSelector?: string): Dictionary;
|
||||
ToJSON(replacer?: (key, value) => any, space?: number): string;
|
||||
ToJSON(replacer?: string, space?: number): string;
|
||||
ToString(separator?: string, selector?: ($) =>any): string;
|
||||
ToString(separator?: string, selector?: string): string;
|
||||
//Action Methods
|
||||
Do(action: ($, i: number) => void ): Enumerable;
|
||||
Do(action: string): Enumerable;
|
||||
ForEach(action: ($, i: number) => void ): void;
|
||||
ForEach(func: ($, i: number) => bool): void;
|
||||
ForEach(action_func: string): void;
|
||||
Write(separator?: string, selector?: ($) =>any): void;
|
||||
Write(separator?: string, selector?: string): void;
|
||||
WriteLine(selector?: ($) =>any): void;
|
||||
Force(): void;
|
||||
//Functional Methods
|
||||
Let(func: (e: Enumerable) => Enumerable): Enumerable;
|
||||
Share(): Enumerable;
|
||||
MemoizeAll(): Enumerable;
|
||||
//Error Handling Methods
|
||||
Catch(handler: (error: Error) => void ): Enumerable;
|
||||
Catch(handler: string): Enumerable;
|
||||
Finally(finallyAction: () => void ): Enumerable;
|
||||
Finally(finallyAction: string): Enumerable;
|
||||
//For Debug Methods
|
||||
Trace(message?: string, selector?: ($) =>any): Enumerable;
|
||||
Trace(message?: string, selector?: string): Enumerable;
|
||||
}
|
||||
|
||||
interface OrderedEnumerable extends Enumerable {
|
||||
ThenBy(keySelector: ($) => any): OrderedEnumerable;
|
||||
ThenBy(keySelector: string): OrderedEnumerable;
|
||||
ThenByDescending(keySelector: ($) => any): OrderedEnumerable;
|
||||
ThenByDescending(keySelector: string): OrderedEnumerable;
|
||||
}
|
||||
|
||||
interface Grouping extends Enumerable {
|
||||
Key();
|
||||
}
|
||||
|
||||
interface Lookup {
|
||||
Count(): number;
|
||||
Get(key): Enumerable;
|
||||
Contains(key): bool;
|
||||
ToEnumerable(): Enumerable;
|
||||
}
|
||||
|
||||
interface Dictionary {
|
||||
Add(key, value): void;
|
||||
Get(key): any;
|
||||
Set(key, value): bool;
|
||||
Contains(key): bool;
|
||||
Clear(): void;
|
||||
Remove(key): void;
|
||||
Count(): number;
|
||||
ToEnumerable(): Enumerable;
|
||||
}
|
||||
}
|
||||
|
||||
declare var Enumerable: linq.EnumerableStatic;
|
||||
Vendored
+235
@@ -0,0 +1,235 @@
|
||||
// Type definitions for Sammy.js
|
||||
// Project: http://sammyjs.org/
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
/// <reference path="jquery-1.8.d.ts"/>
|
||||
|
||||
module Sammy {
|
||||
export function (): Sammy.Application;
|
||||
export function (selector: string): Sammy.Application;
|
||||
export function (handler: Function): Sammy.Application;
|
||||
export function (selector: string, handler: Function): Sammy.Application;
|
||||
|
||||
export function Cache(app, options);
|
||||
export function DataCacheProxy(initial, $element);
|
||||
export function DataLocationProxy(app, data_name, href_attribute);
|
||||
export function DefaultLocationProxy(app, run_interval_every);
|
||||
export function EJS(app, method_alias);
|
||||
|
||||
export function Exceptional(app, errorReporter);
|
||||
export function Flash(app);
|
||||
export function Form(app); // formFor ( name, object, content_callback )
|
||||
|
||||
export function Haml(app, method_alias);
|
||||
export function Handlebars(app, method_alias);
|
||||
export function Hogan(app, method_alias);
|
||||
export function Hoptoad(app, errorReporter);
|
||||
export function JSON(app);
|
||||
export function Meld(app, method_alias);
|
||||
export function MemoryCacheProxy(initial);
|
||||
export function Mustache(app, method_alias);
|
||||
export function NestedParams(app);
|
||||
export function OAuth2(app);
|
||||
export function PathLocationProxy(app);
|
||||
export function Pure(app, method_alias);
|
||||
export function PushLocationProxy(app);
|
||||
export function Session(app, options);
|
||||
export function Storage(app);
|
||||
|
||||
export function Title();
|
||||
export function Tmpl(app, method_alias);
|
||||
export function addLogger(logger);
|
||||
export function log();
|
||||
|
||||
export interface Object {
|
||||
|
||||
constructor (obj: any);
|
||||
|
||||
escapeHTML(s: string): string;
|
||||
h(s: string): string;
|
||||
|
||||
has(key: string): bool;
|
||||
join(...args: any[]): string;
|
||||
keys(attributes_only?: bool): string[];
|
||||
log(...args: any[]): void;
|
||||
toHTML(): string;
|
||||
toHash(): any;
|
||||
toString(include_functions?: bool): string;
|
||||
}
|
||||
|
||||
export interface Application extends Object {
|
||||
|
||||
ROUTE_VERBS: string[];
|
||||
APP_EVENTS: string[];
|
||||
|
||||
(appFn: Function);
|
||||
|
||||
$element(selector?: string): JQuery;
|
||||
after(callback: Function): Application;
|
||||
any(verb: string, path: string, callback: Function): void;
|
||||
route(verb: string, path: string, callback: Function): void;
|
||||
around(callback: Function): Application;
|
||||
before(options: any, callback: Function): Application;
|
||||
bind(name: string, callback: Function): Application;
|
||||
bind(name: string, data: any, callback: Function): Application;
|
||||
bindToAllEvents(callback: Function): Application;
|
||||
clearTemplateCache(): any;
|
||||
contextMatchesOptions(context: any, match_options: any, positive?: bool): bool;
|
||||
del(path: string, callback: Function): Application;
|
||||
del(path: RegExp, callback: Function): Application;
|
||||
destroy(): Application;
|
||||
error(message: string, original_error: Error): void;
|
||||
eventNamespace(): string;
|
||||
get(path: string, callback: Function): Application;
|
||||
get(path: RegExp, callback: Function): Application;
|
||||
getLocation(): string;
|
||||
helper(name: string, method: Function): Application;
|
||||
helpers(extensions: any): Application;
|
||||
isRunning(): bool;
|
||||
log(...params: any[]): void;
|
||||
lookupRoute(verb: string, path: string): any;
|
||||
mapRoutes(route_array: any[]): Application;
|
||||
notFound(verb: string, path: string): any;
|
||||
post(path: string, callback: Function): Application;
|
||||
post(path: RegExp, callback: Function): Application;
|
||||
put(path: string, callback: Function): Application;
|
||||
put(path: RegExp, callback: Function): Application;
|
||||
refresh(): Application;
|
||||
routablePath(path: string): string;
|
||||
route(verb: string, path: string, callback: Function): Application;
|
||||
route(verb: string, path: RegExp, callback: Function): Application;
|
||||
run(start_url?: string): Application;
|
||||
runRoute(verb: string, path: string, params: any, target: any): any;
|
||||
setLocation(new_location: string): string;
|
||||
setLocationProxy(new_proxy: DataLocationProxy): void;
|
||||
swap(content: any, callback: Function): string;
|
||||
templateCache(key: string, value: any): any;
|
||||
toString(): string;
|
||||
trigger(name: string, data?: any): Application;
|
||||
unload(): Application;
|
||||
use(...params: any[]): void;
|
||||
}
|
||||
|
||||
export interface DataLocationProxy {
|
||||
constructor (app, run_interval_every): DataLocationProxy;
|
||||
fullPath(location_obj): string;
|
||||
bind(): void;
|
||||
unbind(): void;
|
||||
setLocation(new_location: string): string;
|
||||
_startPolling(every: number): void;
|
||||
}
|
||||
|
||||
export interface EventContext extends Object {
|
||||
constructor (app, verb, path, params, target);
|
||||
$element(): JQuery;
|
||||
engineFor(engine: any): any;
|
||||
eventNamespace(): string;
|
||||
interpolate(content: any, data: any, engine: any, partials): EventContext;
|
||||
json(str: string): any;
|
||||
load(location: any, options?: any, callback?: Function): any;
|
||||
loadPartials(partials);
|
||||
notFound(): any;
|
||||
partial(location: string, data: any, callback: Function, partials): RenderContext;
|
||||
redirect(...params: any[]): void;
|
||||
render(location: string, data: any, callback: Function, partials): RenderContext;
|
||||
renderEach(location: any, name?: string, data?: any, callback?: Function): RenderContext;
|
||||
send(...params: any[]): RenderContext;
|
||||
swap(contents: any, callback: Function): string;
|
||||
toString(): string;
|
||||
trigger(name: string, data?: any): EventContext;
|
||||
}
|
||||
|
||||
export interface FormBuilder {
|
||||
constructor (name, object);
|
||||
checkbox(keypath: string, value: any, ...attributes: any[]): string;
|
||||
close(): string;
|
||||
hidden(keypath: string, ...attributes: any[]): string;
|
||||
label(keypath: string, content: any, ...attributes: any[]): string;
|
||||
open(...attributes: any[]);
|
||||
password(keypath: string, ...attributes: any[]): string;
|
||||
radio(keypath: string, value: any, ...attributes: any[]): string;
|
||||
select(keypath: string, options: any, ...attributes: any[]): string;
|
||||
submit(...attributes: any[]): string;
|
||||
text(keypath: string, ...attributes: any[]): string;
|
||||
textarea(keypath: string, ...attributes: any[]): string;
|
||||
}
|
||||
|
||||
export interface Form {
|
||||
formFor(name: string, object: any, content_callback: Function): FormBuilder;
|
||||
}
|
||||
|
||||
export interface GoogleAnalytics {
|
||||
constructor (app, tracker);
|
||||
noTrack();
|
||||
track(path);
|
||||
}
|
||||
|
||||
export interface RenderContext extends Object {
|
||||
constructor (event_context);
|
||||
appendTo(selector: string): RenderContext;
|
||||
collect(array: any[], callback: Function, now?: bool): RenderContext;
|
||||
interpolate(data: any, engine?: any, retain?: bool): RenderContext;
|
||||
load(location: string, options?: any, callback?: Function): RenderContext;
|
||||
loadPartials(partials?: any): RenderContext;
|
||||
next(content: any): void;
|
||||
partial(location: string, callback: Function, partials): RenderContext;
|
||||
partial(location: string, data: any, callback: Function, partials): RenderContext;
|
||||
prependTo(selector: string): RenderContext;
|
||||
render(callback: Function): RenderContext;
|
||||
render(location: string, data: any): RenderContext;
|
||||
render(location: string, callback: Function, partials?: any): RenderContext;
|
||||
render(location: string, data: any, callback: Function): RenderContext;
|
||||
render(location: string, data: any, callback: Function, partials: any): RenderContext;
|
||||
renderEach(location: string, name: string, data: any, callback: Function): RenderContext;
|
||||
replace(selector: string): RenderContext;
|
||||
send(...params: any[]): RenderContext;
|
||||
swap(callback: Function): RenderContext;
|
||||
then(callback: Function): RenderContext;
|
||||
trigger(name, data);
|
||||
wait(): void;
|
||||
}
|
||||
|
||||
|
||||
export interface StoreOptions {
|
||||
name?: string;
|
||||
element?: string;
|
||||
type?: string;
|
||||
memory?: any;
|
||||
data?: any;
|
||||
cookie?: any;
|
||||
local?: any;
|
||||
session?: any;
|
||||
}
|
||||
|
||||
export interface Store {
|
||||
|
||||
stores: any;
|
||||
|
||||
constructor (options);
|
||||
|
||||
clear(key: string): any;
|
||||
clearAll(): void;
|
||||
each(callback: Function): bool;
|
||||
exists(key: string): bool;
|
||||
fetch(key: string, callback: Function): any;
|
||||
filter(callback: Function): bool;
|
||||
first(callback: Function): bool;
|
||||
get(key: string): any;
|
||||
isAvailable(): bool;
|
||||
keys(): string[];
|
||||
load(key: string, path: string, callback: Function): void;
|
||||
set(key: string, value: any): any;
|
||||
|
||||
Cookie(name, element, options);
|
||||
Data(name, element);
|
||||
LocalStorage(name, element);
|
||||
Memory(name, element);
|
||||
SessionStorage(name, element);
|
||||
isAvailable(type);
|
||||
Template(app, method_alias);
|
||||
}
|
||||
}
|
||||
interface JQueryStatic {
|
||||
sammy: Sammy;
|
||||
}
|
||||
@@ -28,6 +28,7 @@ Complete
|
||||
* [jQuery UI](http://jqueryui.com/)
|
||||
* [Knockout.js](http://knockoutjs.com/)
|
||||
* [Knockout.Mapping](https://github.com/SteveSanderson/knockout.mapping)
|
||||
* [linq.js](http://linqjs.codeplex.com/) (by Marcin Najder (https://github.com/marcinnajder))
|
||||
* [Modernizr](http://modernizr.com/)
|
||||
* [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield))
|
||||
* [Mustache.js](https://github.com/janl/mustache.js)
|
||||
@@ -35,6 +36,7 @@ Complete
|
||||
* [node_redis](https://github.com/mranney/node_redis)
|
||||
* [QUnit](http://qunitjs.com/) (by [Diullei Gomes](https://github.com/Diullei))
|
||||
* [Raphael](http://raphaeljs.com/) (by [CheCoxshall](https://github.com/CheCoxshall))
|
||||
* [Sammy.js](http://sammyjs.org/)
|
||||
* [Spin](http://fgnass.github.com/spin.js/)
|
||||
* [Underscore.js](http://underscorejs.org/)
|
||||
|
||||
@@ -47,4 +49,6 @@ Next
|
||||
* Meteor
|
||||
* PhoneGap
|
||||
* Isotope
|
||||
* Zepto
|
||||
* Zepto
|
||||
* Socket.IO
|
||||
* MongoDB
|
||||
@@ -0,0 +1,39 @@
|
||||
/// <reference path='../Definitions/jasmine-1.2.d.ts'/>
|
||||
/// <reference path='../Definitions/linq-2.2.0.2.d.ts'/>
|
||||
// <reference path="c:/linq.js" /> tests were run from VisualStudio + Resharper7
|
||||
|
||||
describe("Linq.js tests", function () {
|
||||
it("Projection and Filtering Methods", function () {
|
||||
expect(Enumerable.From([1,2,3,4]).ToString(",")).toBe("1,2,3,4");
|
||||
expect(Enumerable.Range(1, 4).Where((item: number) => item > 2).ToString(",")).toBe("3,4");
|
||||
expect(Enumerable.Range(1, 4).Where("(item) => item > 2").ToString(",")).toBe("3,4");
|
||||
expect(Enumerable.Range(1, 4).Where("$>2").ToString(",")).toBe("3,4");
|
||||
expect(Enumerable.Range(1, 4).Select((item: number,index:number) => item+index).ToString(",")).toBe("1,3,5,7");
|
||||
expect(Enumerable.Range(1, 4).Zip(Enumerable.Range(1, 10), (a: number,b:number) => a-b).ToString(",")).toBe("0,0,0,0");
|
||||
|
||||
});
|
||||
it("Join Methods", function () {
|
||||
expect(Enumerable.Range(1, 4).Join(Enumerable.From(["a", "aaa"]), (l) => l, (r: string) => r.length, (l, r) =>l + ":" + r).ToString(",")).toBe("1:a,3:aaa");
|
||||
});
|
||||
it("Set Methods", function () {
|
||||
expect(Enumerable.Range(2, 4, 2).All((item: number) => item % 2 == 0)).toBe(true);
|
||||
expect(Enumerable.Range(1, 4).Intersect(Enumerable.Range(3, 4)).ToString(",")).toBe("3,4");
|
||||
});
|
||||
it("Ordering Methods", function () {
|
||||
expect(Enumerable.From(
|
||||
[
|
||||
{ name: "marcin", age:15},
|
||||
{ name: "albert", age:51},
|
||||
{ name: "marcin", age:30},
|
||||
]).OrderBy((p) => p.name).ThenByDescending((p) => p.age).Select((p) => p.name+p.age).ToString(",")).toBe("albert51,marcin30,marcin15");
|
||||
});
|
||||
it("Grouping Methods", function () {
|
||||
expect(Enumerable.From(["a","aa","aaa","a","a","aaa"])
|
||||
.GroupBy((item:string) => item.length)
|
||||
.Select((g: linq.Grouping) => { return { key: g.Key(), count: g.Count() }; })
|
||||
.OrderBy(g => g.key)
|
||||
.Select(g => g.key+":"+g.count)
|
||||
.ToString(",")).toBe("1:3,2:1,3:2");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,540 @@
|
||||
/// <reference path="../Definitions/sammyjs-0.7.d.ts" />
|
||||
|
||||
function test_general() {
|
||||
var app = Sammy('#main', function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.use('Mustache');
|
||||
_this.get('#/', function () {
|
||||
var _this: Sammy.RenderContext;
|
||||
_this.load('posts.json')
|
||||
.renderEach('post.mustache')
|
||||
.swap();
|
||||
});
|
||||
});
|
||||
|
||||
app.run('#/');
|
||||
|
||||
var _this: Sammy.Application;
|
||||
_this.get('#/', function (context) {
|
||||
var _this: Sammy.RenderContext;
|
||||
_this.load('data/items.json')
|
||||
.then(function (items) {
|
||||
$.each(items, function (i, item) {
|
||||
context.log(item.title, '-', item.artist);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function test_app() {
|
||||
var s = new Sammy.Object({ first_name: 'Sammy', last_name: 'Davis Jr.' });
|
||||
s.toHTML();
|
||||
|
||||
var app = $.sammy(function () {
|
||||
|
||||
var current_user = false;
|
||||
function checkLoggedIn(callback) {
|
||||
var _this: Sammy.EventContext;
|
||||
if (!current_user) {
|
||||
$.getJSON('/session', function (json) {
|
||||
if (json.login) {
|
||||
current_user = json;
|
||||
callback();
|
||||
} else {
|
||||
current_user = false;
|
||||
_this.redirect('#/login');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
var _this: Sammy.Application;
|
||||
_this.around(checkLoggedIn);
|
||||
});
|
||||
|
||||
var app = $.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.before('#/route', function () { });
|
||||
_this.before({ except: { path: '#/route' } }, function () {
|
||||
_this.log('not before #/route');
|
||||
});
|
||||
_this.get('#/', function () { });
|
||||
_this.get('#/route', function () { });
|
||||
});
|
||||
|
||||
var app = $.sammy(),
|
||||
context = { verb: 'get', path: '#/mypath' };
|
||||
|
||||
app.contextMatchesOptions(context, '#/mypath');
|
||||
app.contextMatchesOptions(context, '#/otherpath');
|
||||
app.contextMatchesOptions(context, { only: { path: '#/mypath' } });
|
||||
app.contextMatchesOptions(context, { only: { path: '#/otherpath' } });
|
||||
app.contextMatchesOptions(context, /path/);
|
||||
app.contextMatchesOptions(context, /^path/);
|
||||
app.contextMatchesOptions(context, { only: { verb: 'get' } });
|
||||
app.contextMatchesOptions(context, { only: { verb: 'post' } });
|
||||
app.contextMatchesOptions(context, { except: { verb: 'post' } });
|
||||
app.contextMatchesOptions(context, { except: { verb: 'get' } });
|
||||
app.contextMatchesOptions(context, { except: { path: '#/otherpath' } });
|
||||
app.contextMatchesOptions(context, { except: { path: '#/mypath' } });
|
||||
app.contextMatchesOptions(context, { path: ['#/mypath', '#/otherpath'] });
|
||||
app.contextMatchesOptions(context, { path: ['#/otherpath', '#/thirdpath'] });
|
||||
app.contextMatchesOptions(context, { only: { path: ['#/mypath', '#/otherpath'] } });
|
||||
app.contextMatchesOptions(context, { only: { path: ['#/otherpath', '#/thirdpath'] } });
|
||||
app.contextMatchesOptions(context, { except: { path: ['#/mypath', '#/otherpath'] } });
|
||||
app.contextMatchesOptions(context, { except: { path: ['#/otherpath', '#/thirdpath'] } });
|
||||
|
||||
var app = $.sammy(function (app) {
|
||||
var _this: Sammy.Application;
|
||||
$.each([1, 2, 3], function (i, num) {
|
||||
app.helper('helper' + num, function () {
|
||||
_this.log("I'm helper number " + num);
|
||||
});
|
||||
});
|
||||
_this.get('#/', function () {
|
||||
});
|
||||
});
|
||||
|
||||
var app = $.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.helpers({
|
||||
upcase: function (text) {
|
||||
return text.toString().toUpperCase();
|
||||
}
|
||||
});
|
||||
_this.get('#/', function () {
|
||||
with (_this) {
|
||||
$('#main').html(upcase($('#main').text()));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var app = $.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.mapRoutes([
|
||||
['get', '#/', function () { }],
|
||||
['post', '#/create', 'addUser'],
|
||||
[/dowhatever/, function () { }]
|
||||
]);
|
||||
});
|
||||
|
||||
var app = $.sammy(function () { });
|
||||
$(function () {
|
||||
app.run();
|
||||
});
|
||||
|
||||
var app = $.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.setLocationProxy(new Sammy.DataLocationProxy(_this));
|
||||
});
|
||||
|
||||
var app = $.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.swap = function (content, callback) {
|
||||
var context = _this;
|
||||
context.$element().fadeOut('slow', function () {
|
||||
context.$element().html(content);
|
||||
context.$element().fadeIn('slow', function () {
|
||||
if (callback) {
|
||||
callback.apply();
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
var MyPlugin = function (app, prepend) {
|
||||
var _this: Sammy.Application;
|
||||
_this.helpers({
|
||||
myhelper: function (text) {
|
||||
alert(prepend + " " + text);
|
||||
}
|
||||
});
|
||||
};
|
||||
var app = $.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.use(MyPlugin, '_this is my plugin');
|
||||
_this.get('#/', function () {
|
||||
});
|
||||
});
|
||||
|
||||
$.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.use('Mustache');
|
||||
_this.use('Storage');
|
||||
});
|
||||
}
|
||||
|
||||
function test_misc() {
|
||||
var app = $.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.setLocationProxy(new Sammy.DataLocationProxy(_this, 'location', 'rel'));
|
||||
_this.get('about', function () {
|
||||
var _this: Sammy.EventContext;
|
||||
_this.partial('about.html');
|
||||
});
|
||||
});
|
||||
|
||||
$.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.get('#/:name', function () {
|
||||
if (_this.params['name'] == 'sammy') {
|
||||
_this.partial('name.html.erb', { name: 'Sammy' });
|
||||
} else {
|
||||
_this.redirect('#/somewhere-else')
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var _this: Sammy.Application;
|
||||
_this.redirect('#/other/route');
|
||||
_this.redirect('#', 'other', 'route');
|
||||
_this.render('mytemplate.mustache', { name: 'quirkey' })
|
||||
.appendTo('ul');
|
||||
_this.renderEach('mytemplate.mustache', [{ name: 'quirkey' }, { name: 'endor' }]);
|
||||
|
||||
var item = {
|
||||
name: 'My Item',
|
||||
price: '$25.50',
|
||||
meta: {
|
||||
id: '123'
|
||||
}
|
||||
};
|
||||
var form = new Sammy.FormBuilder('item', item);
|
||||
form.text('name');
|
||||
|
||||
var options = [
|
||||
['Small', 's'],
|
||||
['Medium', 'm'],
|
||||
['Large', 'l']
|
||||
];
|
||||
form.select('size', options);
|
||||
|
||||
$.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.use('GoogleAnalytics')
|
||||
_this.get('#/dont/track/me', function () {
|
||||
_this.noTrack();
|
||||
});
|
||||
});
|
||||
|
||||
var app = $.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.use(Sammy.Haml);
|
||||
_this.get('#/hello/:name', function () {
|
||||
_this.title = 'Hello!'
|
||||
_this.name = _this.params.name;
|
||||
_this.partial('mytemplate.haml');
|
||||
});
|
||||
});
|
||||
app.run()
|
||||
|
||||
var app = $.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.use('Handlebars', 'hb');
|
||||
_this.get('#/hello/:name', function () {
|
||||
_this.title = 'Hello!'
|
||||
_this.name = _this.params.name;
|
||||
_this.partial('mytemplate.hb');
|
||||
});
|
||||
});
|
||||
|
||||
var app = $.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.use('Handlebars', 'hb');
|
||||
_this.get('#/hello/:name/to/:friend', function (context) {
|
||||
_this.load('mypartial.hb')
|
||||
.then(function (partial) {
|
||||
context.partials = { hello_friend: partial };
|
||||
context.name = context.params.name;
|
||||
context.friend = context.params.friend;
|
||||
context.partial('mytemplate.hb');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
var app = $.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.use('Hogan', 'hg');
|
||||
_this.get('#/hello/:name', function () {
|
||||
_this.title = 'Hello!'
|
||||
_this.name = _this.params.name;
|
||||
_this.partial('mytemplate.hg');
|
||||
});
|
||||
});
|
||||
|
||||
var app = $.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.use('Hogan', 'hg');
|
||||
_this.get('#/hello/:name/to/:friend', function (context) {
|
||||
_this.load('mypartial.hg')
|
||||
.then(function (partial) {
|
||||
context.partials = { hello_friend: partial };
|
||||
context.name = context.params.name;
|
||||
context.friend = context.params.friend;
|
||||
context.partial('mytemplate.hg');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
var app = $.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.use(Sammy.JSON);
|
||||
_this.get('#/', function () {
|
||||
_this.json({ user_id: 123 });
|
||||
_this.json("{\"user_id\":\"123\"}");
|
||||
_this.json("{\"user_id\":\"123\"}").user_id;
|
||||
});
|
||||
})
|
||||
|
||||
var app = $.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.use('Mustache', 'ms');
|
||||
_this.get('#/hello/:name', function () {
|
||||
_this.title = 'Hello!'
|
||||
_this.name = _this.params.name;
|
||||
_this.partial('mytemplate.ms');
|
||||
});
|
||||
});
|
||||
|
||||
var app = $.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.use('Mustache', 'ms');
|
||||
_this.get('#/hello/:name/to/:friend', function (context) {
|
||||
_this.load('mypartial.ms')
|
||||
.then(function (partial) {
|
||||
context.partials = { hello_friend: partial };
|
||||
context.name = context.params.name;
|
||||
context.friend = context.params.friend;
|
||||
context.partial('mytemplate.ms');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
var app = $.sammy(function (app) {
|
||||
var _this: Sammy.Application;
|
||||
_this.use(Sammy.NestedParams);
|
||||
_this.post('#/parse_me', function (context) {
|
||||
$.log(_this.params);
|
||||
});
|
||||
});
|
||||
|
||||
var _this: Sammy.Application;
|
||||
_this.use('Storage');
|
||||
_this.use('OAuth2');
|
||||
_this.oauthorize = "/oauth/authorize";
|
||||
_this.requireOAuth();
|
||||
_this.requireOAuth("/private");
|
||||
_this.before(function (context) { return context.requireOAuth(); })
|
||||
_this.get("/private", function (context) {
|
||||
_this.requireOAuth(function () { });
|
||||
});
|
||||
_this.bind("oauth.connected", function () { $("#signin").hide() });
|
||||
_this.bind("oauth.disconnected", function () { $("#signin").show() });
|
||||
_this.bind("oauth.denied", function (evt, error) {
|
||||
_this.partial("admin/views/no_access.tmpl", { error: error.message });
|
||||
});
|
||||
_this.get("#/signout", function (context) {
|
||||
context.loseAccessToken();
|
||||
context.redirect("#/");
|
||||
});
|
||||
|
||||
_this.get('#/', function () {
|
||||
_this.render('mytemplate.template', { name: 'test' });
|
||||
});
|
||||
|
||||
_this.send($.getJSON, '/app.json')
|
||||
.then(function (json) {
|
||||
$('#message').text(json['message']);
|
||||
}
|
||||
);
|
||||
|
||||
_this.get('#/', function () {
|
||||
_this.load('myfile.txt')
|
||||
.then(function (content) {
|
||||
$('#main').html(content);
|
||||
});
|
||||
});
|
||||
|
||||
_this.get('#/', function () {
|
||||
_this.load('mytext.json')
|
||||
.then(function (content) {
|
||||
var context = _this,
|
||||
data = JSON.parse(content);
|
||||
context.wait();
|
||||
$.post(data.url, {}, function (response) {
|
||||
context.next(JSON.parse(response));
|
||||
});
|
||||
})
|
||||
.then(function (data) {
|
||||
$('#message').text(data.status);
|
||||
});
|
||||
});
|
||||
|
||||
var store = new Sammy.Store({ name: 'mystore', element: '#element', type: 'local' });
|
||||
store.set('foo', 'bar');
|
||||
store.get('foo');
|
||||
store.set('json', { obj: '_this is an obj' });
|
||||
store.get('json');
|
||||
store.keys();
|
||||
store.clear('foo');
|
||||
store.keys();
|
||||
store.clearAll();
|
||||
store.keys();
|
||||
|
||||
store.each(function (key, value) {
|
||||
Sammy.log('key', key, 'value', value);
|
||||
});
|
||||
var store = new Sammy.Store;
|
||||
store.exists('foo');
|
||||
store.fetch('foo', function () {
|
||||
return 'bar!';
|
||||
});
|
||||
store.get('foo');
|
||||
store.fetch('foo', function () {
|
||||
return 'baz!';
|
||||
});
|
||||
|
||||
var store = new Sammy.Store;
|
||||
store.set('one', 'two');
|
||||
store.set('two', 'three');
|
||||
store.set('1', 'two');
|
||||
var returned = store.filter(function (key, value) {
|
||||
return value === 'two';
|
||||
});
|
||||
|
||||
var store = new Sammy.Store;
|
||||
store.load('mytemplate', '/mytemplate.tpl', function () {
|
||||
s.get('mytemplate')
|
||||
});
|
||||
|
||||
var store = new Sammy.Store({ name: 'kvo' });
|
||||
$('body').bind('set-kvo-foo', function (e, data) {
|
||||
Sammy.log(data.key + ' changed to ' + data.value);
|
||||
});
|
||||
store.set('foo', 'bar');
|
||||
|
||||
$.sammy(function () {
|
||||
_this.use('Template');
|
||||
_this.get('#/', function () {
|
||||
_this.user = { name: 'Aaron Quint' };
|
||||
_this.partial('user.template');
|
||||
})
|
||||
});
|
||||
|
||||
_this.use(Sammy.Template, 'tpl');
|
||||
_this.get('#/', function () {
|
||||
_this.partial('myfile.tpl');
|
||||
});
|
||||
_this.get('#/', function () {
|
||||
_this.template('myform.tpl', { form: "<form></form>" }, { escape_html: false });
|
||||
});
|
||||
}
|
||||
|
||||
function test_routes() {
|
||||
var _this: Sammy.Application;
|
||||
|
||||
_this.route('get', '#/', function () {
|
||||
});
|
||||
_this.put('#/post/form', function () {
|
||||
return false;
|
||||
});
|
||||
_thisget('/test/123', function () {
|
||||
});
|
||||
|
||||
_thisget('#/by_name/:name', function () {
|
||||
alert(_this.params['name']);
|
||||
});
|
||||
_thisget(/\#\/by_name\/(.*)/, function () {
|
||||
alert(_this.params['splat']);
|
||||
});
|
||||
_thisget('#/by_name/:name', function () {
|
||||
_this.redirect('#', _this.params['name']);
|
||||
});
|
||||
|
||||
_thisget('#/by_name/:name', function (context) {
|
||||
context.redirect('#', _this.params['name']);
|
||||
});
|
||||
}
|
||||
|
||||
function test_events() {
|
||||
var _this: Sammy.Application;
|
||||
|
||||
_this.bind('db-loaded', function (e, data) {
|
||||
var _this: Sammy.EventContext;
|
||||
_this.redirect('#/');
|
||||
});
|
||||
|
||||
var app = $.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.bind('test', function () {
|
||||
var _this: Sammy.EventContext;
|
||||
_this.trigger('other-event');
|
||||
});
|
||||
});
|
||||
app.trigger('other-event');
|
||||
|
||||
var app = $.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.bind('test', function (e, data) {
|
||||
alert(data['my_data']);
|
||||
});
|
||||
_this.get('#/', function () {
|
||||
_this.trigger('test', { my_data: 'EVENTED!' });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function test_plugins() {
|
||||
var MyPlugin = function (app) {
|
||||
var _this: Sammy.Application;
|
||||
_this.helpers({
|
||||
alert: function (message) {
|
||||
_this.log("ALERT! " + message);
|
||||
}
|
||||
});
|
||||
};
|
||||
var app = $.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.use(MyPlugin);
|
||||
_this.get('#/', function () {
|
||||
var _this: Sammy.EventContext;
|
||||
_this.alert("I'm home");
|
||||
});
|
||||
});
|
||||
var MyAdvancedPlugin = function (app, prefix, suffix) {
|
||||
var _this: Sammy.Application;
|
||||
_this.helpers({
|
||||
alert: function (message) {
|
||||
_this.log(prefix, message, suffix);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var app = $.sammy(function () {
|
||||
var _this: Sammy.Application;
|
||||
_this.use(MyAdvancedPlugin, 'BEFORE!', 'AFTER!');
|
||||
_this.get('#/', function () {
|
||||
_this.alert("I'm home");
|
||||
});
|
||||
});
|
||||
|
||||
var dbLoadAndDisplay = function (app) {
|
||||
var _this: Sammy.Application;
|
||||
_this.get('#/', function () {
|
||||
_this.record = _this.app.db[_this.app.element_selector];
|
||||
_this.app.swap(_this.record.toHTML());
|
||||
});
|
||||
_this.bind('run', function () {
|
||||
});
|
||||
};
|
||||
|
||||
var app1 = Sammy('#div_1', function () {
|
||||
_this.use(dbLoadAndDisplay);
|
||||
});
|
||||
|
||||
var app2 = Sammy('#div_2', function () {
|
||||
_this.use(dbLoadAndDisplay);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user