diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 4c71b3a25..5feedd4ae 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -373,6 +373,7 @@ All definitions files include a header with the author and editors, so at some p * [Store.js](https://github.com/marcuswestin/store.js/) (by [Vincent Bortone](https://github.com/vbortone)) * [stylus](https://github.com/LearnBoost/stylus) (by [Maxime LUCE](https://github.com/SomaticIT)) * [Sugar](http://sugarjs.com/) (by [Josh Baldwin](https://github.com/jbaldwin/)) +* [swfobject](https://code.google.com/p/swfobject/) (by [rou](https://github.com/rou)) * [Swiper](http://www.idangero.us/sliders/swiper) (by [Sebastián Galiano](https://github.com/sgaliano)) * [SwipeView](http://cubiq.org/swipeview) (by [Boris Yankov](https://github.com/borisyankov)) * [Swiz](https://github.com/racker/node-swiz) (by [Jeff Goddard](https://github.com/jedigo)) diff --git a/swfobject/swfobject-tests.ts b/swfobject/swfobject-tests.ts new file mode 100644 index 000000000..87c14eb4c --- /dev/null +++ b/swfobject/swfobject-tests.ts @@ -0,0 +1,46 @@ +/// + +// access to user agent. +var userAgent = swfobject.ua; +console.log(userAgent.w3, userAgent.pv, userAgent.mac, userAgent.win, userAgent.ie, userAgent.wk); + +// get flash player version. +var version = swfobject.getFlashPlayerVersion(); +console.log(version.major, version.minor); +console.log('hasPlayerVersion', swfobject.hasFlashPlayerVersion('10.0.0')); + +// listen to dom load event. +swfobject.addDomLoadEvent(() => { + console.log('dom load event.'); +}); + +// listen to load event. +swfobject.addLoadEvent((event?: Event) => { + console.log(event); +}); + +// embed swf +swfobject.embedSWF( + 'test.swf', + 'myContent', + '300', + '120', + '10.0.0', + 'expressInstall.swf', + {}, + {}, + {}, + () => { + console.log('embedded.'); + console.log(swfobject.getObjectById('myContent')); + } +); + +// show express install +swfobject.showExpressInstall( + {}, + {}, + 'expressInstall', + () => { + } +); diff --git a/swfobject/swfobject.d.ts b/swfobject/swfobject.d.ts new file mode 100644 index 000000000..98c748d7a --- /dev/null +++ b/swfobject/swfobject.d.ts @@ -0,0 +1,105 @@ +// Type definitions for swfobject v2.2 +// Project: https://code.google.com/p/swfobject/ +// Definitions by: rou +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module swfobject { + export var ua: { + w3: boolean; + pv: number[]; + wk: any; // number or boolean + ie: boolean; + win: boolean; + mac: boolean; + }; + + export function registerObject( + objectIdStr: string, + swfVersionStr: string, + xiSwfUrlStr?: string, + callbackFn?: (callbackObj: ICallbackObj) => void + ): void; + + export function getObjectById( + objectIdStr: string + ): HTMLElement; + + export function embedSWF( + swfUrlStr: string, + replaceElemIdStr: string, + widthStr: string, + heightStr: string, + swfVersionStr: string, + xiSwfUrlStr?: string, + flashvarsObj?: Object, + parObj?: Object, + attObj?: Object, + callbackFn?: (callbackObj: ICallbackObj) => void + ): void; + + export function switchOffAutoHideShow(): void; + + export function getFlashPlayerVersion(): IFlashPlayerVersion; + + interface IFlashPlayerVersion { + major: number; + minor: number; + release: number; + } + + export function hasFlashPlayerVersion( + rv: string + ): void; + + export function createSWF( + attObj: ISwfObjectAttribute, + parObj: ISwfObjectParameter, + replaceElemIdStr: string + ): HTMLElement; + + export function showExpressInstall( + att: ISwfObjectAttribute, + par: ISwfObjectParameter, + replaceElemIdStr: string, + callbackFn?: (callbackObj: ICallbackObj) => void + ): void; + + export function removeSWF( + objElemIdStr: string + ): void; + + export function createCSS( + selStr: string, + declStr: string, + mediaStr?: string, + newStyleBoolean?: boolean + ): void; + + export function addDomLoadEvent( + fn: () => void + ): void; + + export function addLoadEvent( + fn: (event?: Event) => void + ): void; + + export function getQueryParamValue( + param?: string + ): string; + + export interface ISwfObjectAttribute { + id?: string; + width?: string; + height?: string; + } + + export interface ISwfObjectParameter { + flashvars?: string; + } + + export interface ICallbackObj { + success: boolean; + id: string; + ref?: HTMLElement; + } +}