',
+ preload: [1, 1],
+ mainClass: "",
+ getNumItemsFn: () => { return 2; },
+ focus: true,
+ isClickableElement: function(el) {
+ return el.tagName === 'A';
+ },
+ mainScrollEndFriction: 0.35,
+ panEndFriction: 0.35
+ };
+
+ var photoSwipe: PhotoSwipe;
+ var uiOptions: PhotoSwipeUI_Default.Options = {
+ barsSize: {top: 44, bottom: 'auto'},
+ timeToIdle: 4000,
+ timeToIdleOutside: 1000,
+ loadingIndicatorDelay: 1000,
+ addCaptionHTMLFn: function(item, captionEl, isFake) {
+ if (!item.title) {
+ ( captionEl.children[0]).innerHTML = '';
+ return false;
+ }
+ ( captionEl.children[0]).innerHTML = item.title;
+ return true;
+ },
+ closeEl: true,
+ captionEl: true,
+ fullscreenEl: true,
+ zoomEl: true,
+ shareEl: true,
+ counterEl: true,
+ arrowEl: true,
+ preloaderEl: true,
+ tapToClose: false,
+ tapToToggleControls: true,
+ clickToCloseNonZoomable: true,
+ closeElClasses: ['item', 'caption', 'zoom-wrap', 'ui', 'top-bar'],
+ indexIndicatorSep: ' / ',
+ shareButtons: [
+ {id: 'facebook', label: 'Share on Facebook', url: 'https://www.facebook.com/sharer/sharer.php?u='},
+ {id: 'twitter', label: 'Tweet', url: 'https://twitter.com/intent/tweet?text=&url='},
+ {id: 'pinterest', label: 'Pin it', url: 'http://www.pinterest.com/pin/create/button/?url=&media=&description='},
+ {id: 'download', label: 'Download image', url: '', download: true}
+ ],
+ getImageURLForShare: function( shareButtonData ) {
+ // `shareButtonData` - object from shareButtons array
+ //
+ // `pswp` is the gallery instance object,
+ // you should define it by yourself
+ //
+ return photoSwipe.currItem.src || '';
+ },
+ getPageURLForShare: function( shareButtonData ) {
+ return window.location.href;
+ },
+ getTextForShare: function( shareButtonData ) {
+ return ( photoSwipe.currItem).title || '';
+ },
+ parseShareButtonOut: function(shareButtonData, shareButtonOut) {
+ return shareButtonOut;
+ }
+ };
+
+ var pswpElement = document.getElementById("gallery");
+ photoSwipe = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, uiOptions);
+
+}
+
+function test_photoSwipeMethods() {
+ var photoSwipe: PhotoSwipe;
+
+ photoSwipe.init();
+
+ alert(photoSwipe.currItem.src);
+ alert(photoSwipe.viewportSize.x);
+ photoSwipe.ui.init();
+ photoSwipe.bg.style.borderStyle = "1px solid red";
+ photoSwipe.container.style.borderStyle = "1px solid red";
+ photoSwipe.options.timeToIdle = 2000;
+ alert(photoSwipe.getCurrentIndex() === 3);
+ alert(photoSwipe.getZoomLevel() === 1);
+ alert(photoSwipe.isDragging());
+
+ photoSwipe.goTo(9);
+ photoSwipe.next();
+ photoSwipe.prev();
+
+ photoSwipe.updateSize(true);
+
+ photoSwipe.close();
+ photoSwipe.zoomTo(2,
+ { x: 250, y: 250 },
+ 2000,
+ (x) => { return x*x*(3-2*x); },
+ (zoomValue) => { console.log("zoom value is now" + zoomValue); });
+ photoSwipe.applyZoomPan(1, 0, 0);
+
+ photoSwipe.items[photoSwipe.getCurrentIndex()].src = "new/path/to/image.jpg";
+ photoSwipe.invalidateCurrItems();
+}
+
+function test_photoSwipeEvents() {
+ var photoSwipe: PhotoSwipe;
+
+ photoSwipe.listen('beforeChange', () => {});
+ photoSwipe.listen('afterChange', () => {});
+ photoSwipe.listen('beforeChange', () => {});
+ photoSwipe.listen('imageLoadComplete', (idx: number, item: PhotoSwipeUI_Default.Item) => {
+ item.w *= 2;
+ });
+ photoSwipe.listen('resize', () => {});
+ photoSwipe.listen('gettingData', (idx: number, item: PhotoSwipeUI_Default.Item) => {
+ item.title = "abc";
+ });
+ photoSwipe.listen('mouseUsed', () => {});
+ photoSwipe.listen('initialZoomIn', () => {});
+ photoSwipe.listen('initialZoomInEnd', () => {});
+ photoSwipe.listen('initialZoomOut', () => {});
+ photoSwipe.listen('initialZoomOutEnd', () => {});
+ photoSwipe.listen('parseVerticalMargin', (item: PhotoSwipeUI_Default.Item) => {
+ item.vGap.top = 20;
+ item.vGap.bottom = 40;
+ });
+ photoSwipe.listen('close', () => {});
+ photoSwipe.listen('unbindEvents', () => {});
+ photoSwipe.listen('destroy', () => {});
+ photoSwipe.listen('preventDragEvent', (e: MouseEvent, isDown: boolean, preventObj: {prevent: boolean}) => {
+ if (e.x > 50 && isDown) {
+ preventObj.prevent = true;
+ }
+ });
+
+ photoSwipe.listen('foo', (a, b, c) => {
+ alert(a + b + c);
+ });
+ photoSwipe.shout('foo', 1, 2, 3);
+}
+
+function test_customUI() {
+ var pswpElement = document.getElementById("gallery2");
+ var myPhotoSwipe = new PhotoSwipe(pswpElement, MyUI, [], {
+ bgOpacity: 0,
+ index: 3,
+ foo: 123,
+ bar: "abc"
+ });
+}
+
+interface MyUIOptions extends PhotoSwipe.Options {
+ foo: number;
+ bar: string;
+}
+
+class MyUI implements PhotoSwipe.UI {
+ constructor(pswp: PhotoSwipe, framework: PhotoSwipe.UIFramework) {
+ // dummy
+ }
+
+ init() {
+ // dummy
+ }
+}
diff --git a/photoswipe/photoswipe.d.ts b/photoswipe/photoswipe.d.ts
new file mode 100644
index 0000000000..b09fe75ddf
--- /dev/null
+++ b/photoswipe/photoswipe.d.ts
@@ -0,0 +1,898 @@
+// Type definitions for PhotoSwipe 4.0.7
+// Project: http://photoswipe.com/
+// Definitions by: Xiaohan Zhang
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare module PhotoSwipe {
+ /**
+ * A specific slide in the PhotoSwipe gallery. The terms "item", "slide", and "slide object" are used interchangeably.
+ */
+ interface Item {
+ /**
+ * The url of this image.
+ */
+ src: string;
+ /**
+ * The width of this image.
+ */
+ w: number;
+ /**
+ * The height of this image.
+ */
+ h: number;
+
+ /**
+ * Internal property added by PhotoSwipe.
+ */
+ loadError?: boolean;
+
+ /**
+ * Internal property added by PhotoSwipe.
+ */
+ vGap?: {top: number; bottom: number};
+
+ /**
+ * Internal property added by PhotoSwipe.
+ * This number is computed to be this item's smaller dimension divided by the larger dimension.
+ */
+ fitRatio?: number;
+
+ /**
+ * Internal property added by PhotoSwipe.
+ */
+ initialZoomLevel?: number;
+
+ /**
+ * Internal property added by PhotoSwipe.
+ */
+ bounds?: any;
+
+ /**
+ * Internal property added by PhotoSwipe.
+ */
+ initialPosition?: any;
+ }
+
+ /**
+ * Options for the base PhotoSwipe class. Derived from http://photoswipe.com/documentation/options.html
+ */
+ interface Options {
+ /**
+ * Start slide index. 0 is the first slide. Must be integer, not a string.
+ *
+ * Default 0.
+ */
+ index?: number;
+
+ /**
+ * Function should return an object with coordinates from which initial zoom-in animation will start (or zoom-out animation will end).
+ * Object should contain three properties: x (X position, relative to document), y (Y position, relative to document), w (width of the element).
+ * Height will be calculated automatically based on size of large image.
+ * For example if you return {x:0,y:0,w:50} zoom animation will start in top left corner of your page.
+ * Function has one argument - index of the item that is opening or closing.
+ *
+ * Default undefined.
+ */
+ getThumbBoundsFn?: (index: number) => { x: number; y: number; w: number };
+
+ /**
+ * Initial zoom-in transition duration in milliseconds. Set to 0 to disable. Besides this JS option, you need also to change transition duration in PhotoSwipe CSS file:
+ * .pswp--animate_opacity,
+ * .pswp__bg,
+ * .pswp__caption,
+ * .pswp__top-bar,
+ * .pswp--has_mouse .pswp__button--arrow--left,
+ * .pswp--has_mouse .pswp__button--arrow--right{
+ * -webkit-transition: opacity 333ms cubic-bezier(.4,0,.22,1);
+ * transition: opacity 333ms cubic-bezier(.4,0,.22,1);
+ * }
+ *
+ * Default 333.
+ */
+ showAnimationDuration?: number;
+
+ /**
+ * The same as the previous option, just for closing (zoom-out) transition.
+ * After PhotoSwipe is opened pswp--open class will be added to the root element, you may use it to apply different transition duration in CSS.
+ *
+ * Default 333.
+ */
+ hideAnimationDuration?: number;
+
+ /**
+ * If set to false background opacity and image scale will be animated (image opacity is always 1).
+ * If set to true root PhotoSwipe element opacity and image scale will be animated.
+ * Enable it when dimensions of your small thumbnail don't match dimensions of large image.
+ *
+ * Default false.
+ */
+ showHideOpacity?: boolean;
+
+ /**
+ * Background (.pswp__bg) opacity.
+ * Should be a number from 0 to 1, e.g. 0.7.
+ * This style is defined via JS, not via CSS, as this value is used for a few gesture-based transitions.
+ *
+ * Default 1.
+ */
+ bgOpacity?: number;
+
+ /**
+ * Spacing ratio between slides. For example, 0.12 will render as a 12% of sliding viewport width (rounded).
+ *
+ * Default 0.12.
+ */
+ spacing?: number;
+
+ /**
+ * Allow swipe navigation to next/prev item when current item is zoomed.
+ * Option is always false on devices that don't have hardware touch support.
+ *
+ * Default true.
+ */
+ allowNoPanText?: boolean;
+
+ /**
+ * Maximum zoom level when performing spread (zoom) gesture. 2 means that image can be zoomed 2x from original size.
+ * Try to avoid huge values here, as too big image may cause memory issues on mobile (especially on iOS).
+ *
+ * Default 2.
+ */
+ maxSpreadZoom?: number;
+
+ /**
+ * Function should return zoom level to which image will be zoomed after double-tap gesture, or when user clicks on zoom icon, or mouse-click on image itself.
+ * If you return 1 image will be zoomed to its original size.
+ * Function is called each time zoom-in animation is initiated. So feel free to return different values for different images based on their size or screen DPI.
+ *
+ * Default is:
+ *
+ * function(isMouseClick, item) {
+ *
+ * // isMouseClick - true if mouse, false if double-tap
+ * // item - slide object that is zoomed, usually current
+ * // item.initialZoomLevel - initial scale ratio of image
+ * // e.g. if viewport is 700px and image is 1400px,
+ * // initialZoomLevel will be 0.5
+ *
+ * if(isMouseClick) {
+ *
+ * // is mouse click on image or zoom icon
+ *
+ * // zoom to original
+ * return 1;
+ *
+ * // e.g. for 1400px image:
+ * // 0.5 - zooms to 700px
+ * // 2 - zooms to 2800px
+ *
+ * } else {
+ *
+ * // is double-tap
+ *
+ * // zoom to original if initial zoom is less than 0.7x,
+ * // otherwise to 1.5x, to make sure that double-tap gesture always zooms image
+ * return item.initialZoomLevel < 0.7 ? 1 : 1.5;
+ * }
+ * }
+ */
+ getDoubleTapZoom?: (isMouseClick: boolean, item: Item) => number;
+
+ /**
+ * Loop slides when using swipe gesture.If set to true you'll be able to swipe from last to first image.
+ * Option is always false when there are less than 3 slides.
+ * This option has no relation to arrows navigation. Arrows loop is turned on permanently. You can modify this behavior by making custom UI.
+ *
+ * Default true.
+ */
+ loop?: boolean;
+
+ /**
+ * Pinch to close gallery gesture. The gallery’s background will gradually fade out as the user zooms out. When the gesture is complete, the gallery will close.
+ *
+ * Default true.
+ */
+ pinchToClose?: boolean;
+
+ /**
+ * Close gallery on page scroll. Option works just for devices without hardware touch support.
+ *
+ * Default true.
+ */
+ closeOnScroll?: boolean;
+
+ /**
+ * Close gallery when dragging vertically and when image is not zoomed. Always false when mouse is used.
+ *
+ * Default true.
+ */
+ closeOnVerticalDrag?: boolean;
+
+ /**
+ * Option allows you to predefine if mouse was used or not.
+ * Some PhotoSwipe feature depend on it, for example default UI left/right arrows will be displayed only after mouse is used.
+ * If set to false, PhotoSwipe will start detecting when mouse is used by itself, mouseUsed event triggers when mouse is found.
+ *
+ * default false.
+ */
+ mouseUsed?: boolean;
+
+ /**
+ * esc keyboard key to close PhotoSwipe. Option can be changed dynamically (yourPhotoSwipeInstance.options.escKey = false;).
+ *
+ * Default true.
+ */
+ escKey?: boolean;
+
+ /**
+ * Keyboard left or right arrow key navigation. Option can be changed dynamically (yourPhotoSwipeInstance.options.arrowKeys = false;).
+ *
+ * Default true.
+ */
+ arrowKeys?: boolean;
+
+ /**
+ * If set to false disables history module (back button to close gallery, unique URL for each slide). You can also just exclude history.js module from your build.
+ *
+ * Default true.
+ */
+ history?: boolean;
+
+ /**
+ * Gallery unique ID. Used by History module when forming URL. For example, second picture of gallery with UID 1 will have URL: http://example.com/#&gid=1&pid=2.
+ *
+ * Default 1.
+ */
+ galleryUID?: number;
+
+ /**
+ * Error message when image was not loaded. %url% will be replaced by URL of image.
+ *
+ * Default is:
+ *
+ *
+ */
+ errorMsg?: string;
+
+ /**
+ * Lazy loading of nearby slides based on direction of movement.
+ * Should be an array with two integers, first one - number of items to preload before current image, second one - after the current image.
+ * E.g. if you set it to [1,3], it'll load 1 image before the current, and 3 images after current. Values can not be less than 1.
+ *
+ * Default [1, 1].
+ */
+ preload?: number[];
+
+ /**
+ * String with name of class that will be added to root element of PhotoSwipe (.pswp). Can contain multiple classes separated by space.
+ */
+ mainClass?: string;
+
+ /**
+ * Function that should return total number of items in gallery. Don't put very complex code here, function is executed very often.
+ *
+ * By default it returns length of slides array.
+ */
+ getNumItemsFn?: () => number;
+
+ /**
+ * Will set focus on PhotoSwipe element after it's open.
+ *
+ * Default true.
+ */
+ focus?: boolean;
+
+ /**
+ * Function should check if the element (el) is clickable.
+ * If it is – PhotoSwipe will not call preventDefault and click event will pass through.
+ * Function should be as light is possible, as it's executed multiple times on drag start and drag release.
+ *
+ * Default is:
+ *
+ * function(el) {
+ * return el.tagName === 'A';
+ * }
+ */
+ isClickableElement?: (el: HTMLElement) => boolean;
+ }
+
+ interface UIFramework {
+ [name: string]: any;
+ }
+
+ /**
+ * Base type for PhotoSwipe user interfaces.
+ * T is the type of options that this PhotoSwipe.UI uses.
+ *
+ * To build your own PhotoSwipe.UI class:
+ *
+ * (1) Write an interface for the custom UI's Options that extends PhotoSwipe.Options.
+ * (2) Write your custom class, implementing the PhotoSwipe.UI interface.
+ * (3) Pass in your custom interface to the type parameter T of the PhotoSwipe.UI interface.
+ *
+ * Example:
+ *
+ * // (1)
+ * interface MyUIOptions extends PhotoSwipe.Options {
+ * foo: number;
+ * bar: string;
+ * }
+ *
+ * // (2) and (3)
+ * class MyUI implements PhotoSwipe.UI {
+ * constructor(pswp: PhotoSwipe, framework: PhotoSwipe.UIFramework) {
+ * }
+ * }
+ *
+ * var pswpWithMyUI = new PhotoSwipe(element, MyUI, items, {foo: 1, bar: "abc"});
+ */
+ interface UI {
+ /**
+ * Called by PhotoSwipe after it constructs the UI.
+ */
+ init: () => void;
+ }
+}
+
+/**
+ * Base PhotoSwipe class. Derived from http://photoswipe.com/documentation/api.html
+ */
+declare class PhotoSwipe {
+ /**
+ * Constructs a PhotoSwipe.
+ *
+ * Note: By default Typescript will not correctly typecheck the options parameter. Make sure to
+ * explicitly annotate the type of options being passed into the constructor like so:
+ *
+ * new PhotoSwipe( element, PhotoSwipeUI_Default, items, options );
+ *
+ * It accepts 4 arguments:
+ *
+ * (1) PhotoSwipe element (it must be added to DOM).
+ * (2) PhotoSwipe UI class. If you included default photoswipe-ui-default.js, class will be PhotoSwipeUI_Default. Can be "false".
+ * (3) Array with objects (slides).
+ * (4) Options.
+ */
+ constructor(pswpElement: HTMLElement,
+ uiConstructor: (new (pswp: PhotoSwipe, framework: PhotoSwipe.UIFramework) => PhotoSwipe.UI) | boolean,
+ items: PhotoSwipe.Item[],
+ options: T);
+
+ /**
+ * Current slide object.
+ */
+ currItem: PhotoSwipe.Item;
+
+ /**
+ * Items in this gallery. PhotoSwipe will (almost) dynamically respond to changes in this array.
+ * To add, edit, or remove slides after PhotoSwipe is opened, you just need to modify the items array.
+ *
+ * For example, you can push new slide objects into the items array:
+ *
+ * pswp.items.push({
+ * src: "path/to/image.jpg",
+ * w:1200,
+ * h:500
+ * });
+ *
+ * If you changed slide that is CURRENT, NEXT or PREVIOUS (which you should try to avoid) – you need to call method that will update their content:
+ *
+ * // sets a flag that slides should be updated
+ * pswp.invalidateCurrItems();
+ * // updates the content of slides
+ * pswp.updateSize(true);
+ *
+ * If you're using the DefaultUI, call pswp.ui.update() to update that as well. Also note:
+ *
+ * (1) You can't reassign whole array, you can only modify it (e.g. use splice to remove elements).
+ * (2) If you're going to remove current slide – call goTo method before.
+ * (3) There must be at least one slide.
+ * (4) This technique is used to serve responsive images.
+ */
+ items: PhotoSwipe.Item[];
+
+ /**
+ * Size of the current viewport.
+ */
+ viewportSize: {
+ x: number;
+ y: number;
+ };
+
+ /**
+ * The Framework. Holds utility methods.
+ */
+ framework: PhotoSwipe.UIFramework;
+
+ /**
+ * The ui instance constructed by PhotoSwipe.
+ */
+ ui: PhotoSwipe.UI;
+
+ /**
+ * The background element (with class .pswp__bg).
+ */
+ bg: HTMLElement;
+
+ /**
+ * The container element (with class .pswp__container).
+ */
+ container: HTMLElement;
+
+ /**
+ * Options for this PhotoSwipe. This object is a copy of the options parameter passed into the constructor.
+ * Some properties in options are dynamically modifiable.
+ */
+ options: T;
+
+ /**
+ * Current item index.
+ */
+ getCurrentIndex(): number;
+
+ /**
+ * Current zoom level.
+ */
+ getZoomLevel(): number;
+
+ /**
+ * Whether one (or more) pointer is used.
+ */
+ isDragging(): boolean;
+
+ /**
+ * Whether two (or more) pointers are used.
+ */
+ isZooming(): boolean;
+
+ /**
+ * true wehn transition between is running (after swipe).
+ */
+ isMainScrollAnimating(): boolean;
+
+ /**
+ * Initialize and open gallery (you can bind events before this method).
+ */
+ init(): void;
+
+ /**
+ * Go to slide by index.
+ */
+ goTo(index: number): void;
+
+ /**
+ * Go to the next slide.
+ */
+ next(): void;
+
+ /**
+ * Go to the previous slide.
+ */
+ prev(): void;
+
+ /**
+ * Update gallery size
+ * @param {boolean} `force` If you set it to `true`, size of the gallery will be updated even if viewport size hasn't changed.
+ */
+ updateSize(force: boolean): void;
+
+ /**
+ * Close gallery. Calls destroy() after closing.
+ */
+ close(): void;
+
+ /**
+ * Destroy gallery (unbind listeners, free memory). Automatically called after close().
+ */
+ destroy(): void;
+
+ /**
+ * Zoom in/out the current slide to a specified zoom level, optionally with animation.
+ *
+ * @param {number} `destZoomLevel` Destination scale number. Set to 1 for unzoomed.
+ * Use `pswp.currItem.fitRatio - image` to zoom the image to perfectly fit into the viewport.
+ * @param {object} `centerPoint` The center of the zoom, relative to viewport.
+ * @param {number} `speed` Animation duration in milliseconds. Can be 0.
+ * @param {function} `easingFn` Easing function (optional). Set to false to use default easing.
+ * This method is passed in the percentage that the animation is finished (from 0 to 1) and should return an eased value (which should be 0 at the start and 1 at the end).
+ * @param {function} `updateFn` Function will be called on each update frame (optional).
+ * This method is passed the eased zoom level.
+ *
+ * Example below will 2x zoom to center of slide:
+ *
+ * pswp.zoomTo(2, {x:pswp.viewportSize.x/2,y:pswp.viewportSize.y/2}, 2000, false, function(now) {});
+ *
+ */
+ zoomTo(destZoomLevel: number,
+ centerPoint: {x: number; y: number},
+ speed: number,
+ easingFn?: (k: number) => number,
+ updateFn?: (now: number) => void): void;
+
+ /**
+ * Apply zoom and pan to the current slide
+ *
+ * @param {number} `zoomLevel`
+ * @param {int} `panX`
+ * @param {int} `panY`
+ *
+ * For example: `pswp.applyZoomPan(1, 0, 0)`
+ * will zoom current image to the original size
+ * and will place it on top left corner.
+ *
+ */
+ applyZoomPan(zoomLevel: number, panX: number, panY: number): void;
+
+ /**
+ * Call this method after dynamically modifying the current, next, or previous slide in the items array.
+ */
+ invalidateCurrItems(): void;
+
+ /**
+ * PhotoSwipe uses very simple Event/Messaging system.
+ * It has two methods shout (triggers event) and listen (handles event).
+ * For now there is no method to unbind listener, but all of them are cleared when PhotoSwipe is closed.
+ */
+ listen(eventName: string, callback: (...args: any[]) => void): void;
+
+ /**
+ * Called before slides change (before the content is changed ,but after navigation). Update UI here.
+ */
+ listen(eventName: 'beforeChange', callback: () => void): void;
+ /**
+ * Called after slides change (after content has changed).
+ */
+ listen(eventName: 'afterChange', callback: () => void): void;
+ /**
+ * Called when an image is loaded.
+ */
+ listen(eventName: 'imageLoadComplete', callback: (index: number, item: PhotoSwipe.Item) => void): void;
+ /**
+ * Called when the viewport size changes.
+ */
+ listen(eventName: 'resize', callback: () => void): void;
+ /**
+ * Triggers when PhotoSwipe reads slide object data, which happens before content is set, or before lazy-loading is initiated.
+ * Use it to dynamically change properties of the slide object.
+ */
+ listen(eventName: 'gettingData', callback: (index: number, item: PhotoSwipe.Item) => void): void;
+ /**
+ * Called when mouse is first used (triggers only once).
+ */
+ listen(eventName: 'mouseUsed', callback: () => void): void;
+ /**
+ * Called when opening zoom in animation starting.
+ */
+ listen(eventName: 'initialZoomIn', callback: () => void): void;
+ /**
+ * Called when opening zoom in animation finished.
+ */
+ listen(eventName: 'initialZoomInEnd', callback: () => void): void;
+ /**
+ * Called when closing zoom out animation started.
+ */
+ listen(eventName: 'initialZoomOut', callback: () => void): void;
+ /**
+ * Called when closing zoom out animation finished.
+ */
+ listen(eventName: 'initialZoomOutEnd', callback: () => void): void;
+ /**
+ * Allows overriding vertical margin for individual items.
+ *
+ * Example:
+ *
+ * pswp.listen('parseVerticalMargin', function(item) {
+ * var gap = item.vGap;
+ *
+ * gap.top = 50; // There will be 50px gap from top of viewport
+ * gap.bottom = 100; // and 100px gap from the bottom
+ * });
+ */
+ listen(eventName: 'parseVerticalMargin', callback: (item: PhotoSwipe.Item) => void): void;
+ /**
+ * Called when the gallery starts closing.
+ */
+ listen(eventName: 'close', callback: () => void): void;
+ /**
+ * Gallery unbinds events (triggers before closing animation).
+ */
+ listen(eventName: 'unbindEvents', callback: () => void): void;
+ /**
+ * Called after the gallery is closed and the closing animation finishes.
+ * Clean up your stuff here.
+ */
+ listen(eventName: 'destroy', callback: () => void): void;
+ /**
+ * Allow to call preventDefault on down and up events.
+ */
+ listen(eventName: 'preventDragEvent', callback: (e: MouseEvent, isDown: boolean, preventObj: {prevent: boolean}) => void): void;
+
+ /**
+ * Triggers eventName event with args passed through to listeners.
+ */
+ shout(eventName: string, ...args: any[]): void;
+}
+
+/**
+ * Default UI class for PhotoSwipe. This class is largely undocumented and doesn't seem to have a public facing API.
+ */
+declare class PhotoSwipeUI_Default implements PhotoSwipe.UI {
+ constructor(pswp: PhotoSwipe, framework: PhotoSwipe.UIFramework);
+ init(): void;
+
+ /**
+ * Call this method to update the UI after the items array has been modified in the original PhotoSwipe element.
+ */
+ update(): void;
+}
+
+declare module PhotoSwipeUI_Default {
+ /**
+ * Options for the PhotoSwipe Default UI. Derived from http://photoswipe.com/documentation/options.html
+ */
+ interface Options extends PhotoSwipe.Options {
+ /**
+ * Size of top & bottom bars in pixels. "bottom" parameter can be 'auto' (will calculate height of caption).
+ * Option applies only when mouse is used, or when width of screen is more than 1200px.
+ * Also look at `parseVerticalMargin` event.
+ *
+ * Default {top: 44, bottom: "auto"}.
+ */
+ barsSize?: { top: number; bottom: number | string };
+
+ /**
+ * Adds class pswp__ui--idle to pswp__ui element when mouse isn't moving for timeToIdle milliseconds.
+ *
+ * Default 4000.
+ */
+ timeToIdle?: number;
+
+ /**
+ * Adds class pswp__ui--idle to pswp__ui element when mouse leaves the window for timeToIdleOutside milliseconds.
+ *
+ * Default 1000.
+ */
+ timeToIdleOutside?: number;
+
+ /**
+ * Delay in milliseconds until loading indicator is displayed.
+ *
+ * Default 1000.
+ */
+ loadingIndicatorDelay?: number;
+
+ /**
+ * Function to build caption markup. The function takes three parameters:
+ *
+ * item - slide object
+ * captionEl - caption DOM element
+ * isFake - true when content is added to fake caption container
+ * (used to get size of next or previous caption)
+ *
+ * Return whether to show the caption or not.
+ *
+ * Default is:
+ *
+ * function(item, captionEl, isFake) {
+ * if(!item.title) {
+ * captionEl.children[0].innerHTML = '';
+ * return false;
+ * }
+ * captionEl.children[0].innerHTML = item.title;
+ * return true;
+ * }
+ *
+ */
+ addCaptionHTMLFn?: (item: Item, captionEl: HTMLElement, isFake: boolean) => boolean;
+
+ /**
+ * Whether to show the close button.
+ *
+ * Default true.
+ */
+ closeEl?: boolean;
+
+ /**
+ * Whether to show the caption.
+ *
+ * Default true.
+ */
+ captionEl?: boolean;
+
+ /**
+ * Whether to show the fullscreen button.
+ *
+ * Default true.
+ */
+ fullscreenEl?: boolean;
+
+ /**
+ * Whether to show the zoom button.
+ *
+ * Default true.
+ */
+ zoomEl?: boolean;
+
+ /**
+ * Whether to show the share button.
+ *
+ * Default true.
+ */
+ shareEl?: boolean;
+
+ /**
+ * Whether to show the current image's index in the gallery (located in top-left corner by default).
+ *
+ * Default true.
+ */
+ counterEl?: boolean;
+
+ /**
+ * Whether to show the left/right directional arrows.
+ *
+ * Default true.
+ */
+ arrowEl?: boolean;
+
+ /**
+ * Whether to show the preloader element.
+ *
+ * Default true.
+ */
+ preloaderEl?: boolean;
+
+ /**
+ * Tap on sliding area should close gallery.
+ *
+ * Default false.
+ */
+ tapToClose?: boolean;
+
+ /**
+ * Tap should toggle visibility of controls.
+ *
+ * Default true.
+ */
+ tapToToggleControls?: boolean;
+
+ /**
+ * Mouse click on image should close the gallery, only when image is smaller than size of the viewport.
+ *
+ * Default true.
+ */
+ clickToCloseNonZoomable?: boolean;
+
+ /**
+ * Element classes that should close PhotoSwipe when clicked on.
+ * In HTML markup, class should always start with "pswp__", e.g.: "pswp__item", "pswp__caption".
+ *
+ * "pswp__ui--over-close" class will be added to root element of UI when mouse is over one of these elements
+ * By default it's used to highlight the close button.
+ *
+ * Default ['item', 'caption', 'zoom-wrap', 'ui', 'top-bar'].
+ */
+ closeElClasses?: string[];
+
+ /**
+ * Separator for "1 of X" counter.
+ *
+ * Default ' / '.
+ */
+ indexIndicatorSep?: string;
+
+ /**
+ * The entries that show up when you click the Share button.
+ *
+ * Default is:
+ *
+ * [
+ * {id:'facebook', label:'Share on Facebook', url:'https://www.facebook.com/sharer/sharer.php?u='},
+ * {id:'twitter', label:'Tweet', url:'https://twitter.com/intent/tweet?text=&url='},
+ * {id:'pinterest', label:'Pin it', url:'http://www.pinterest.com/pin/create/button/?url=&media=&description='},
+ * {id:'download', label:'Download image', url:'', download:true}
+ * ]
+ *
+ */
+ shareButtons?: ShareButtonData[];
+
+ /**
+ * A callback that should return the URL for the currently selected image. The callback is passed
+ * the shareButtonData entry that was clicked on.
+ *
+ * Default is:
+ *
+ * function( shareButtonData ) {
+ * // `shareButtonData` - object from shareButtons array
+ * //
+ * // `pswp` is the gallery instance object,
+ * // you should define it by yourself
+ * //
+ * return pswp.currItem.src || '';
+ * }
+ *
+ */
+ getImageURLForShare?: (shareButtonData: ShareButtonData) => string;
+
+ /**
+ * A callback that should return the "Page" associated with the selected image. (e.g. on Facebook, the shared
+ * content will be associated with the returned page). The callback is passed the shareButtonData entry that
+ * was clicked on.
+ *
+ * Default is:
+ *
+ * function( shareButtonData ) {
+ * return window.location.href;
+ * }
+ *
+ */
+ getPageURLForShare?: (shareButtonData: ShareButtonData) => string;
+
+ /**
+ * A callback that should return the Text associated with the selected image. The callback is passed
+ * the shareButtonData entry that was clicked on.
+ *
+ * Default is:
+ *
+ * function( shareButtonData ) {
+ * return pswp.currItem.title || '';
+ * }
+ *
+ */
+ getTextForShare?: (shareButtonData: ShareButtonData) => string;
+
+ /**
+ * A final output callback that you can use to further modify the share button's HTML. The callback is passed
+ * (1) the shareButtonData entry being generated, and (2) the default HTML generated by PhotoSwipUI_Default.
+ *
+ * Default is:
+ *
+ * function(shareButtonData, shareButtonOut) {
+ * return shareButtonOut;
+ * }
+ *
+ */
+ parseShareButtonOut?: (shareButtonData: ShareButtonData, shareButtonOut: string) => string;
+ }
+
+ interface ShareButtonData {
+ /**
+ * An id for this share button entry. The share element associated with this entry will be classed with
+ * 'pswp__share--' + id
+ */
+ id: string;
+
+ /**
+ * The user-visible text to display for this entry.
+ */
+ label: string;
+
+ /**
+ * The full sharing endpoint URL for this social media site (e.g. Facebook's is facebook.com/sharer/sharer.php), with URL parameters.
+ * PhotoSwipUI_Default treats the URL specially. In the url string, any of the following text is treated specially:
+ * '{{url}}', '{{image_url}}, '{{raw_image_url}}, '{{text}}'. PhotoSwipeUI_Default will replace each of them with the following value:
+ *
+ * {{url}} becomes the (URIEncoded) url to the current "Page" (as returned by getPageURLForShare).
+ * {{image_url}} becomes the (URIEncoded) url of the selected image (as returned by getImageURLForShare).
+ * {{raw_image_url}} becomes the raw url of the selected image (as returned by getImageURLForShare).
+ * {{text}} becomes the (URIEncoded) share text of the selected image (as returned by getTextForShare).
+ */
+ url: string;
+
+ /**
+ * Whether this link is a direct download button or not.
+ *
+ * Default false.
+ */
+ download?: boolean;
+ }
+
+ /**
+ * Extra properties that the Default UI accepts.
+ */
+ interface Item extends PhotoSwipe.Item {
+ /**
+ * The caption for this item.
+ */
+ title?: string;
+ }
+}
diff --git a/polymer/polymer-tests.ts b/polymer/polymer-tests.ts
index a606692fd3..f594b4f226 100644
--- a/polymer/polymer-tests.ts
+++ b/polymer/polymer-tests.ts
@@ -10,6 +10,31 @@ class AbstractPolymerElement implements PolymerElement {
asyncFire(eventName: string, details?: any, targetNode?: any, bubbles?: boolean, cancelable?: boolean): void { }
cancelUnbindAll(): void { }
+
+ /**
+ * User must call from attached callback
+ */
+ resizableAttachedHandler(): void {}
+
+ /**
+ * User must call from detached callback
+ */
+ resizableDetachedHandler(): void {}
+
+ /**
+ * User must call from attached callback
+ */
+ resizerAttachedHandler(): void {}
+
+ /**
+ * User must call from detached callback
+ */
+ resizerDetachedHandler(): void {}
+
+ /**
+ * User should call when resizing or un-hiding children
+ */
+ notifyResize(): void {}
}
class AbstractWebComponent extends AbstractPolymerElement {
diff --git a/polymer/polymer.app-router.d.ts b/polymer/polymer.app-router.d.ts
index 633479ba2b..adf2f8d3b9 100644
--- a/polymer/polymer.app-router.d.ts
+++ b/polymer/polymer.app-router.d.ts
@@ -3,9 +3,11 @@
// Definitions by: Louis Grignon
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+///
+
declare module PolymerComponents {
module App {
- export interface Router extends HTMLElement {
+ export interface Router extends PolymerElement, HTMLElement {
init(): void;
go(path: string, options?: { replace?: boolean }): void;
}
diff --git a/polymer/polymer.core-drawer-panel.d.ts b/polymer/polymer.core-drawer-panel.d.ts
index 2bad7b633a..f219b4d0bc 100644
--- a/polymer/polymer.core-drawer-panel.d.ts
+++ b/polymer/polymer.core-drawer-panel.d.ts
@@ -3,9 +3,11 @@
// Definitions by: Louis Grignon
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+///
+
declare module PolymerComponents {
export module Core {
- export interface DrawerPanel extends HTMLElement {
+ export interface DrawerPanel extends PolymerElement, HTMLElement {
/**
* Width of the drawer panel. default: '256px'
*/
diff --git a/polymer/polymer.core-overlay.d.ts b/polymer/polymer.core-overlay.d.ts
new file mode 100644
index 0000000000..706dee8990
--- /dev/null
+++ b/polymer/polymer.core-overlay.d.ts
@@ -0,0 +1,92 @@
+// Type definitions for polymer's paper-toast
+// Project: https://github.com/Polymer/core-selector
+// Definitions by: Louis Grignon
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module PolymerComponents {
+ export module Core {
+ export interface Overlay extends PolymerElement, HTMLElement {
+ /**
+ * The target element that will be shown when the overlay is opened. If unspecified, the core-overlay itself is the target.
+ * default: the overlay element
+ */
+ target: Object;
+
+ /**
+ * A core-overlay's size is guaranteed to be constrained to the window size. To achieve this, the sizingElement is sized with a max-height/width. By default this element is the target element, but it can be specifically set to a specific element inside the target if that is more appropriate. This is useful, for example, when a region inside the overlay should scroll if needed.
+ * default: the target element
+ */
+ sizingTarget: Object;
+
+ /**
+ * Set opened to true to show an overlay and to false to hide it. A core-overlay may be made initially opened by setting its opened attribute.
+ * default: false
+ */
+ opened: boolean;
+
+ /**
+ * If true, the overlay has a backdrop darkening the rest of the screen. The backdrop element is attached to the document body and may be styled with the class core-overlay-backdrop. When opened the core-opened class is applied.
+ * default: false
+ */
+ backdrop: boolean;
+
+ /**
+ * If true, the overlay is guaranteed to display above page content.
+ * default: false
+ */
+ layered: boolean;
+
+ /**
+ * By default an overlay 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;
+
+ /**
+ * By default an overlay will focus its target or an element inside it with the autoFocus attribute. Disable this behavior by setting the autoFocusDisabled property to true.
+ * default: false
+ */
+ autoFocusDisabled: boolean;
+
+ /**
+ * This property specifies an attribute on elements that should close the overlay on tap. Should not set closeSelector if this is set.
+ * default: "core-overlay-toggle"
+ */
+ closeAttribute: string;
+
+ /**
+ * This property specifies a selector matching elements that should close the overlay on tap. Should not set closeAttribute if this is set.
+ * default: ''
+ */
+ closeSelector: string;
+
+ /**
+ * The transition property specifies a string which identifies a core-transition element that will be used to help the overlay open and close. The default core-transition-fade will cause the overlay to fade in and out.
+ * default: 'core-transition-fade'
+ */
+ transition: string;
+
+ /**
+ * Toggle the opened state of the overlay.
+ */
+ toggle(): void;
+
+ /**
+ * Open the overlay. This is equivalent to setting the opened property to true.
+ */
+ open(): void;
+
+ /**
+ * Close the overlay. This is equivalent to setting the opened property to false.
+ */
+ close(): void;
+
+ /**
+ * Extensions of core-overlay should implement the resizeHandler method to adjust the size and position of the overlay when the browser window resizes.
+ */
+ resizeHandler(): void;
+ }
+ }
+}
\ No newline at end of file
diff --git a/polymer/polymer.core-selector.d.ts b/polymer/polymer.core-selector.d.ts
new file mode 100644
index 0000000000..c7941cdde7
--- /dev/null
+++ b/polymer/polymer.core-selector.d.ts
@@ -0,0 +1,20 @@
+// Type definitions for polymer's paper-toast
+// Project: https://github.com/Polymer/core-selector
+// Definitions by: Louis Grignon
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module PolymerComponents {
+ export module Core {
+ export interface Selector extends PolymerElement, HTMLElement {
+ }
+
+ export interface SelectorOnSelectEvent extends Event {
+ detail: {
+ item: HTMLElement;
+ isSelected: boolean;
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/polymer/polymer.d.ts b/polymer/polymer.d.ts
index dfb812f8c0..ed084a4485 100644
--- a/polymer/polymer.d.ts
+++ b/polymer/polymer.d.ts
@@ -18,6 +18,31 @@ interface PolymerElement {
domReady? (): void;
detached? (): void;
attributeChanged? (attrName: string, oldVal: any, newVal: any): void;
+
+ /**
+ * User must call from attached callback
+ */
+ resizableAttachedHandler(): void;
+
+ /**
+ * User must call from detached callback
+ */
+ resizableDetachedHandler(): void;
+
+ /**
+ * User must call from attached callback
+ */
+ resizerAttachedHandler(): void;
+
+ /**
+ * User must call from detached callback
+ */
+ resizerDetachedHandler(): void;
+
+ /**
+ * User should call when resizing or un-hiding children
+ */
+ notifyResize(): void;
}
interface Polymer {
@@ -34,9 +59,6 @@ interface Polymer {
(tagName: string, prototype: any): void;
(prototype: PolymerElement): void;
(): void;
- // hacks for mixins
- CoreResizer: any;
- CoreResizable: any;
}
declare var Polymer: Polymer;
diff --git a/polymer/polymer.paper-dialog.d.ts b/polymer/polymer.paper-dialog.d.ts
new file mode 100644
index 0000000000..51758e42cb
--- /dev/null
+++ b/polymer/polymer.paper-dialog.d.ts
@@ -0,0 +1,30 @@
+// Type definitions for polymer's paper-dialog
+// Project: https://github.com/Polymer/paper-dialog
+// Definitions by: Louis Grignon
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+///
+
+declare module PolymerComponents {
+ export module Paper {
+ export interface Dialog extends PolymerComponents.Core.Overlay, HTMLElement {
+ /**
+ * The title of the dialog.
+ * default: ''
+ */
+ heading: string;
+
+ /**
+ * See paper-dialog-transition
+ * default: ''
+ */
+ transition: string;
+
+ /**
+ * default: true
+ */
+ layered: boolean;
+ }
+ }
+}
\ No newline at end of file
diff --git a/polymer/polymer.paper-toast.d.ts b/polymer/polymer.paper-toast.d.ts
index fbf8cd7a65..6e29c1c8b6 100644
--- a/polymer/polymer.paper-toast.d.ts
+++ b/polymer/polymer.paper-toast.d.ts
@@ -3,9 +3,11 @@
// Definitions by: Louis Grignon
// Definitions: https://github.com/borisyankov/DefinitelyTyped
+///
+
declare module PolymerComponents {
export module Paper {
- export interface Toast extends HTMLElement {
+ export interface Toast extends PolymerElement, HTMLElement {
/**
* The text shows in a toast.
* default: ''
diff --git a/slickgrid/slick.autotooltips-tests.ts b/slickgrid/slick.autotooltips-tests.ts
new file mode 100644
index 0000000000..f2e7f6f39c
--- /dev/null
+++ b/slickgrid/slick.autotooltips-tests.ts
@@ -0,0 +1,8 @@
+///
+
+var grid = new Slick.Grid("#myGrid", [], [], {});
+grid.registerPlugin(new Slick.AutoTooltips({
+ enableForCells: true,
+ enableForHeaderCells: true,
+ maxToolTipLength: 100
+}));
diff --git a/slickgrid/slick.autotooltips.d.ts b/slickgrid/slick.autotooltips.d.ts
new file mode 100644
index 0000000000..34e761754a
--- /dev/null
+++ b/slickgrid/slick.autotooltips.d.ts
@@ -0,0 +1,35 @@
+// Type definitions for SlickGrid AutoToolTips Plugin 2.1.0
+// Project: https://github.com/mleibman/SlickGrid
+// Definitions by: Ryo Iwamoto
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module Slick {
+ export interface SlickGridAutoTooltipsOption extends PluginOptions {
+ /**
+ * Enable tooltip for grid cells
+ * @default true
+ */
+ enableForCells?: boolean;
+
+ /**
+ * Enable tooltip for header cells
+ * @default false
+ */
+ enableForHeaderCells?: boolean;
+
+ /**
+ * The maximum length for a tooltip
+ * @default null
+ */
+ maxToolTipLength?: number;
+ }
+
+ /**
+ * AutoTooltips plugin to show/hide tooltips when columns are too narrow to fit content.
+ */
+ export class AutoTooltips extends Plugin {
+ constructor(option?: SlickGridAutoTooltipsOption);
+ }
+}
diff --git a/squirejs/squirejs-tests.ts b/squirejs/squirejs-tests.ts
new file mode 100644
index 0000000000..fc1701fbf6
--- /dev/null
+++ b/squirejs/squirejs-tests.ts
@@ -0,0 +1,37 @@
+///
+
+import Squire = require('Squire');
+
+// Default Configuration
+var injector = new Squire();
+
+// Different Context
+injector = new Squire('other-requirejs-context');
+
+// require(Array dependencies, Function callback, Function errback)
+injector.require(['a'], function(A: any) {}, function(err: any) {});
+
+// mock(String name | Object(name: mock), Object mock)
+injector.mock("a", {});
+injector.mock({a: {}});
+
+// store(String name | Array names)
+injector.store('a');
+injector.store(['a', 'b']);
+
+// clean(Optional (String name | Array names))
+injector.clean('a');
+injector.clean(['a', 'b']);
+injector.clean();
+
+// remove()
+injector.remove();
+
+// run()
+injector.run(['a'], function test(a: any) {})(function done() {});
+
+// Squire.Helpers.returns(Any what)
+Squire.Helpers.returns({});
+
+// Squire.Helpers.constructs(Any what)
+Squire.Helpers.constructs({});
diff --git a/squirejs/squirejs.d.ts b/squirejs/squirejs.d.ts
new file mode 100644
index 0000000000..693ca7d907
--- /dev/null
+++ b/squirejs/squirejs.d.ts
@@ -0,0 +1,28 @@
+// Type definitions for Squire 0.2.1
+// Project: https://github.com/iammerrick/Squire.js
+// Definitions by: Bradley Ayers
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare module 'Squire' {
+ class Squire {
+ constructor();
+ constructor(context: string);
+ mock(name: string, mock: any): Squire;
+ mock(mocks: {[name: string]: any}): Squire;
+ require(dependencies: string[], callback: Function, errback: Function): Squire;
+ store(name: string | string[]): Squire;
+ clean(): Squire;
+ clean(name: string | string[]): Squire;
+ remove(): String;
+ run(dependencies: string[], test: Function): (done: Function) => void;
+ }
+
+ module Squire {
+ module Helpers {
+ export function returns(what: T): () => T;
+ export function constructs(what: T): () => (() => T);
+ }
+ }
+
+ export = Squire;
+}
diff --git a/switchery/switchery-tests.ts b/switchery/switchery-tests.ts
new file mode 100644
index 0000000000..2a06795027
--- /dev/null
+++ b/switchery/switchery-tests.ts
@@ -0,0 +1,71 @@
+///
+
+//
+// Examples from https://github.com/abpetkov/switchery
+//
+
+function multipleSwitches() {
+
+ var elems = Array.prototype.slice.call( document.querySelectorAll( '.js-switch' ) );
+
+ elems.forEach( (html: Element) => {
+ var switchery = new Switchery( html );
+ } );
+}
+
+
+function disabledSwitch() {
+
+ var elem = document.querySelector( '.js-switch' )
+
+ //inactive switch
+ var switchery = new Switchery( elem, {disabled: true} );
+
+ //Customize the default opacity of the disabled switch, using the disabledOpacity option.
+ switchery = new Switchery( elem, {disabled: true, disabledOpacity: 0.75} );
+}
+
+
+function coloredSwitch() {
+
+ var elem = document.querySelector( '.js-switch' )
+
+ //You can change the primary color of the switch to fit your design perfectly:
+ var switchery = new Switchery( elem, {color: '#41b7f1'} );
+
+ //Or the secondary color, which will change the switch background color and border color:
+ switchery = new Switchery( elem, {secondaryColor: '#bbf0f0'} );
+
+ //Since version 0.6.3, you're even allowed to change the jack color from JS, as follows:
+ switchery = new Switchery( elem, {jackColor: '#fffc00'} );
+}
+
+function switchSizes() {
+
+ var elem = document.querySelector( '.js-switch' )
+
+ var switchery = new Switchery( elem, {size: 'small'} );
+ switchery = new Switchery( elem, {size: 'large'} );
+}
+
+function checkingState() {
+
+ var elem = document.querySelector( '.js-switch' )
+
+ //On click:
+
+ var clickCheckbox = document.querySelector( '.js-check-click' )
+ var clickButton = document.querySelector( '.js-check-click-button' );
+
+ clickButton.addEventListener( 'click', () => {
+ alert( clickCheckbox.checked );
+ } );
+
+ //On change:
+
+ var changeCheckbox = document.querySelector( '.js-check-change' );
+
+ changeCheckbox.onchange = function () {
+ alert( changeCheckbox.checked );
+ };
+}
\ No newline at end of file
diff --git a/switchery/switchery.d.ts b/switchery/switchery.d.ts
new file mode 100644
index 0000000000..4d953aff88
--- /dev/null
+++ b/switchery/switchery.d.ts
@@ -0,0 +1,64 @@
+// Type definitions for switchery 0.7.0
+// Project: https://github.com/abpetkov/switchery
+// Definitions by: Bruno Grieder
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare module Switchery {
+
+ export interface Options {
+
+ /**
+ * color of the switch element (HEX or RGB value)
+ * @default '#64bd63'
+ */
+ color? : string;
+ /**
+ * secondary color for background color and border, when the switch is off
+ * @default '#dfdfdf'
+ */
+ secondaryColor? : string;
+ /**
+ * color of the jack/handle element
+ * @default '#fff'
+ */
+ jackColor? : string;
+ /**
+ * class name for the switch element (by default styled in switchery.css)
+ * @default 'switchery'
+ */
+ className? : string;
+ /**
+ * enable or disable click events and changing the state of the switch (boolean value)
+ * @default false
+ */
+ disabled? : boolean;
+ /**
+ * opacity of the switch when it's disabled (0 to 1)
+ * @default 0.5
+ */
+ disabledOpacity? : number;
+ /**
+ * length of time that the transition will take, ex. '0.4s', '1s', '2.2s' (Note: transition speed of the handle is twice shorter)
+ * @default '0.4s'
+ */
+ speed? : string;
+ /**
+ * size of the switch element (small or large)
+ * @default 'default'
+ */
+ size? : string;
+ }
+
+
+}
+
+declare class Switchery {
+
+ constructor(node: Node, options?: Switchery.Options);
+
+}
+
+declare module "switchery" {
+
+ export = Switchery
+}
\ No newline at end of file
diff --git a/titanium/titanium-tests.ts b/titanium/titanium-tests.ts
index a4057b80cb..087ba05c27 100644
--- a/titanium/titanium-tests.ts
+++ b/titanium/titanium-tests.ts
@@ -26,7 +26,7 @@ function test_window() {
}
function test_tableview() {
- var data = [];
+ var data : Ti.UI.View[] = [];
for (var i = 0; i < 10; i++) {
var row = Ti.UI.createTableViewRow();
var label = Ti.UI.createLabel({
@@ -73,12 +73,12 @@ function test_network() {
var url = "http://www.appcelerator.com";
var client = Ti.Network.createHTTPClient({
// function called when the response data is available
- onload : function(e) {
+ onload : function(e: SuccessResponse) {
alert(this.responseText);
},
// function called when an error occurs, including a timeout
- onerror : function(e) {
- alert(e.rror);
+ onerror : function(e: FailureResponse) {
+ alert(e.error);
},
timeout : 5000 // in milliseconds
});
diff --git a/titanium/titanium.d.ts b/titanium/titanium.d.ts
index 5ebe930241..a325611df3 100644
--- a/titanium/titanium.d.ts
+++ b/titanium/titanium.d.ts
@@ -1,33 +1,36 @@
-// Type definitions for Titanium Movile 3.1.3.GA
+// Type definitions for Titanium Mobile 3.5.0
// Project: http://www.appcelerator.com/
-// Definitions by: Airam Rguez
+// Definitions by: Craig Younkins
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-// This file has been automatically generated.
declare module Ti {
+ export var apiName : string;
export var bubbleParent : boolean;
export var buildDate : string;
export var buildHash : string;
export var userAgent : string;
- export var version : number;
+ export var version : string;
export function addEventListener (name: string, callback: (...args : any[]) => any) : void;
export function applyProperties (props: Dictionary