From 313b6952ae27ef2afbdb9f6d0763315b72934ca7 Mon Sep 17 00:00:00 2001 From: Guille Date: Sun, 17 Jul 2016 20:07:49 +0200 Subject: [PATCH] refactor(screenshot): --- src/plugins/screenshot.ts | 123 +++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 60 deletions(-) diff --git a/src/plugins/screenshot.ts b/src/plugins/screenshot.ts index 710efc09f..a712151b6 100644 --- a/src/plugins/screenshot.ts +++ b/src/plugins/screenshot.ts @@ -1,60 +1,63 @@ -import {Cordova, Plugin} from './plugin'; -declare var navigator: any; -@Plugin({ - plugin: 'https://github.com/gitawego/cordova-screenshot.git', - pluginRef: 'navigator.screenshot', - repo: 'https://github.com/gitawego/cordova-screenshot.git' -}) -export class Screenshot { - -/** - * Takes screenshot and saves the image - * - * @param {string} format. Format can take the value of either 'jpg' or 'png' - * On ios, only 'jpg' format is supported - * @param {number} quality. Determines the quality of the screenshot. - * Default quality is set to 100. - * @param {string} filename. Name of the file as stored on the storage - */ - static save (format?: string, quality?: number, filename?: string): Promise { - return new Promise( - (resolve, reject) => { - navigator.screenshot.save( - (error, result) => { - if (error) { - reject(error); - }else { - resolve(result); - } - }, - format, - quality, - filename - ); - } - ); - } - -/** - * Takes screenshot and returns the image as an URI - * - * @param {number} quality. Determines the quality of the screenshot. - * Default quality is set to 100. - */ - static URI (quality?: number): Promise { - return new Promise( - (resolve, reject) => { - navigator.screenshot.URI( - (error, result) => { - if (error) { - reject(error); - }else { - resolve(result); - } - }, - quality - ); - } - ); - } -} +import { Cordova, Plugin } from './plugin'; + + +declare var navigator: any; + +@Plugin({ + plugin: 'https://github.com/gitawego/cordova-screenshot.git', + pluginRef: 'navigator.screenshot', + repo: 'https://github.com/gitawego/cordova-screenshot.git' +}) +export class Screenshot { + + /** + * Takes screenshot and saves the image + * + * @param {string} format. Format can take the value of either 'jpg' or 'png' + * On ios, only 'jpg' format is supported + * @param {number} quality. Determines the quality of the screenshot. + * Default quality is set to 100. + * @param {string} filename. Name of the file as stored on the storage + */ + static save(format?: string, quality?: number, filename?: string): Promise { + return new Promise( + (resolve, reject) => { + navigator.screenshot.save( + (error, result) => { + if (error) { + reject(error); + } else { + resolve(result); + } + }, + format, + quality, + filename + ); + } + ); + } + + /** + * Takes screenshot and returns the image as an URI + * + * @param {number} quality. Determines the quality of the screenshot. + * Default quality is set to 100. + */ + static URI(quality?: number): Promise { + return new Promise( + (resolve, reject) => { + navigator.screenshot.URI( + (error, result) => { + if (error) { + reject(error); + } else { + resolve(result); + } + }, + quality + ); + } + ); + } +}