mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-25 21:55:49 +08:00
addded polymer definition files
This commit is contained in:
79
polymer/polymer-tests.ts
Normal file
79
polymer/polymer-tests.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
/// <reference path="polymer.d.ts"/>
|
||||
|
||||
class AbstractPolymerElement implements PolymerElement {
|
||||
$: { [id: string]: HTMLElement }; //polymer object for elements that have an ID
|
||||
|
||||
// inargs is the [args] for the callback.. need to update function def
|
||||
async(inMethod: () => void, inArgs?: Array<any>, inTimeout?: number): void { }
|
||||
job(jobName: string, inMethod: () => void, inTimeout?: number): void { }
|
||||
fire(eventName: string, details?: any, targetNode?: any, bubbles?: boolean, cancelable?: boolean): void { }
|
||||
asyncFire(eventName: string, details?: any, targetNode?: any, bubbles?: boolean, cancelable?: boolean): void { }
|
||||
|
||||
cancelUnbindAll(): void { }
|
||||
|
||||
// these are mix in API's.. hacky way to deal with them at the moment.
|
||||
resizableAttachedHandler;
|
||||
resizableDetachedHandler;
|
||||
}
|
||||
|
||||
class AbstractWebComponent extends AbstractPolymerElement {
|
||||
|
||||
public name: string;
|
||||
|
||||
constructor(name: string) {
|
||||
super();
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
protected get(): HTMLElement {
|
||||
return <any>this;
|
||||
}
|
||||
}
|
||||
|
||||
function registerWebComponent(webComponentClass: Function, ...mixins): void {
|
||||
|
||||
// we need a flat object, without prototype in order to polymer to work on our components
|
||||
var flattenedComponent = {};
|
||||
var poly_func = ["async", "job", "fire", "asyncFire", "cancelUnbindAll"];
|
||||
if (mixins) {
|
||||
// apply mixins
|
||||
mixins.forEach(mixin => {
|
||||
for (var i in mixin) {
|
||||
if (mixin.hasOwnProperty(i)) {
|
||||
webComponentClass.prototype[i] = mixin[i];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
var webComponent: AbstractWebComponent = new (<any>webComponentClass)();
|
||||
for (var i in webComponent) {
|
||||
if (!_.contains(poly_func, i)) {
|
||||
flattenedComponent[i] = webComponent[i];
|
||||
}
|
||||
}
|
||||
|
||||
console.debug('registering web component', webComponent, flattenedComponent);
|
||||
Polymer(webComponent.name, flattenedComponent);
|
||||
}
|
||||
|
||||
class Spinner extends AbstractWebComponent {
|
||||
private pendingRequestsCount: number;
|
||||
|
||||
constructor() {
|
||||
super('test-spinner');
|
||||
}
|
||||
|
||||
public ready(): void {
|
||||
this.pendingRequestsCount = 0;
|
||||
this.updateUI();
|
||||
}
|
||||
|
||||
private updateUI(): void {
|
||||
var spinnerHidden: boolean = this.pendingRequestsCount == 0;
|
||||
if (spinnerHidden) {
|
||||
this.get().setAttribute('hidden', 'true');
|
||||
} else {
|
||||
this.get().removeAttribute('hidden');
|
||||
}
|
||||
}
|
||||
}
|
||||
8
polymer/polymer.app-router.d.ts
vendored
Normal file
8
polymer/polymer.app-router.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
declare module PolymerComponents {
|
||||
module App {
|
||||
export interface Router extends HTMLElement {
|
||||
init(): void;
|
||||
go(path: string, options?: { replace?: boolean }): void;
|
||||
}
|
||||
}
|
||||
}
|
||||
70
polymer/polymer.core-drawer-panel.d.ts
vendored
Normal file
70
polymer/polymer.core-drawer-panel.d.ts
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
// Type definitions for polymer's paper-toast
|
||||
// Project: https://github.com/Polymer/core-drawer-panel
|
||||
// Definitions by: Louis Grignon <https://github.com/lgrignon>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module PolymerComponents {
|
||||
export module Core {
|
||||
export interface DrawerPanel extends HTMLElement {
|
||||
/**
|
||||
* Width of the drawer panel. default: '256px'
|
||||
*/
|
||||
drawerWidth: string;
|
||||
|
||||
/**
|
||||
* Max-width when the panel changes to narrow layout. default: '640px'
|
||||
*/
|
||||
responsiveWidth: string;
|
||||
|
||||
/**
|
||||
* The panel that is being selected. drawer for the drawer panel and main for the main panel. default: null
|
||||
*/
|
||||
selected: string;
|
||||
|
||||
/**
|
||||
* The panel to be selected when core-drawer-panel changes to narrow layout. default: 'main'
|
||||
*/
|
||||
defaultSelected: string;
|
||||
|
||||
/**
|
||||
* Returns true if the panel is in narrow layout. This is useful if you need to show/hide elements based on the layout. default: false
|
||||
*/
|
||||
narrow: boolean;
|
||||
|
||||
/**
|
||||
* If true, position the drawer to the right. default: false
|
||||
*/
|
||||
rightDrawer: boolean;
|
||||
|
||||
/**
|
||||
* If true, swipe to open/close the drawer is disabled. default: false
|
||||
*/
|
||||
disableSwipe: boolean;
|
||||
|
||||
/**
|
||||
* If true, ignore responsiveWidth setting and force the narrow layout. default: false
|
||||
*/
|
||||
forceNarrow: boolean;
|
||||
|
||||
/**
|
||||
* If true, swipe from the edge is disabled. default: false
|
||||
*/
|
||||
disableEdgeSwipe: boolean;
|
||||
|
||||
/**
|
||||
* Toggles the panel open and closed.
|
||||
*/
|
||||
togglePanel(): void;
|
||||
|
||||
/**
|
||||
* Opens the drawer.
|
||||
*/
|
||||
openDrawer(): void;
|
||||
|
||||
/**
|
||||
* Closes the drawer.
|
||||
*/
|
||||
closeDrawer(): void;
|
||||
}
|
||||
}
|
||||
}
|
||||
42
polymer/polymer.d.ts
vendored
Normal file
42
polymer/polymer.d.ts
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
// Type definitions for polymer
|
||||
// Project: https://github.com/polymer
|
||||
// Definitions by: Louis Grignon <https://github.com/lgrignon>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface PolymerElement {
|
||||
|
||||
// definition
|
||||
publish?: Object;
|
||||
computed?: Object;
|
||||
// object mapping variable names to functions name
|
||||
observe?: Object;
|
||||
|
||||
// life time API
|
||||
created? (): void;
|
||||
ready? (): void;
|
||||
attached? (): void;
|
||||
domReady? (): void;
|
||||
detached? (): void;
|
||||
attributeChanged? (attrName: string, oldVal: any, newVal: any): void;
|
||||
}
|
||||
|
||||
interface Polymer {
|
||||
|
||||
importElements(node: Node, callback: Function);
|
||||
import(url: string, callback?: () => void): void;
|
||||
|
||||
mixin(target: any, ...obj1): any;
|
||||
waitingFor(): Array<string>;
|
||||
// should be an "integer" for milliseconds
|
||||
forceReady(timeout: number): void;
|
||||
|
||||
(tag_name: string, prototype: PolymerElement): void;
|
||||
(tag_name: string, prototype: any): void;
|
||||
(prototype: PolymerElement): void;
|
||||
(): void;
|
||||
// hacks for mixins
|
||||
CoreResizer: any;
|
||||
CoreResizable: any;
|
||||
}
|
||||
|
||||
declare var Polymer: Polymer;
|
||||
61
polymer/polymer.paper-toast.d.ts
vendored
Normal file
61
polymer/polymer.paper-toast.d.ts
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
// Type definitions for polymer's paper-toast
|
||||
// Project: https://github.com/Polymer/paper-toast
|
||||
// Definitions by: Louis Grignon <https://github.com/lgrignon>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module PolymerComponents {
|
||||
export module Paper {
|
||||
export interface Toast extends HTMLElement {
|
||||
/**
|
||||
* The text shows in a toast.
|
||||
* default: ''
|
||||
*/
|
||||
text: string;
|
||||
|
||||
/**
|
||||
* The duration in milliseconds to show the toast.
|
||||
* default: 3000
|
||||
*/
|
||||
duration: number;
|
||||
|
||||
/**
|
||||
* Set opened to true to show the toast and to false to hide it.
|
||||
* default: false
|
||||
*/
|
||||
opened: boolean;
|
||||
|
||||
/**
|
||||
* Min-width when the toast changes to narrow layout. In narrow layout, the toast fits at the bottom of the screen when opened.
|
||||
* default: '480px'
|
||||
*/
|
||||
responsiveWidth: string;
|
||||
|
||||
/**
|
||||
* If true, the toast can't be swiped.
|
||||
* default: false
|
||||
*/
|
||||
swipeDisabled: boolean;
|
||||
|
||||
/**
|
||||
* By default, the toast will close automatically if the user taps outside it or presses the escape key. Disable this behavior by setting the autoCloseDisabled property to true.
|
||||
* default: false
|
||||
*/
|
||||
autoCloseDisabled: boolean;
|
||||
|
||||
/**
|
||||
* Show the toast for the specified duration
|
||||
*/
|
||||
show(): void;
|
||||
|
||||
/**
|
||||
* Dismiss the toast and hide it.
|
||||
*/
|
||||
dismiss(): void;
|
||||
|
||||
/**
|
||||
* Toggle the opened state of the toast.
|
||||
*/
|
||||
toggle(): void;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user