Added definitions for jQuery.qrcode. Closes #6292

This commit is contained in:
Dan Manastireanu 2015-10-24 16:27:55 +03:00
parent 3191f6e008
commit d47706e0a6
2 changed files with 200 additions and 0 deletions

View File

@ -0,0 +1,73 @@
/// <reference path="../jquery/jquery.d.ts"/>
/// <reference path="jquery.qrcode.d.ts"/>
// Examples from website (note: the examples use color instead of fill, which is not supported)
$('.container').qrcode();
$('.container').qrcode({
"size": 100,
"fill": "#3a3",
"text": "http://larsjung.de/qrcode"
});
$('.container').qrcode({
"render": "div",
"size": 100,
"fill": "#3a3",
"text": "http://larsjung.de/qrcode"
});
// defaults
$('.container').qrcode({
// render method: `'canvas'`, `'image'` or `'div'`
render: 'canvas',
// version range somewhere in 1 .. 40
minVersion: 1,
maxVersion: 40,
// error correction level: `'L'`, `'M'`, `'Q'` or `'H'`
ecLevel: 'L',
// offset in pixel if drawn onto existing canvas
left: 0,
top: 0,
// size in pixel
size: 200,
// code color or image element
fill: '#000',
// background color or image element, `null` for transparent background
background: null,
// content
text: 'no text',
// corner radius relative to module width: 0.0 .. 0.5
radius: 0,
// quiet zone in modules
quiet: 0,
// modes
// 0: normal
// 1: label strip
// 2: label box
// 3: image strip
// 4: image box
mode: JQueryQRCode.Mode.NORMAL,
mSize: 0.1,
mPosX: 0.5,
mPosY: 0.5,
label: 'no label',
fontname: 'sans',
fontcolor: '#000',
image: null
});

127
jquery.qrcode/jquery.qrcode.d.ts vendored Normal file
View File

@ -0,0 +1,127 @@
// Type definitions for jQuery.qrcode v0.12.0
// Project: https://github.com/lrsjng/jquery-qrcode
// Definitions by: Dan Manastireanu <https://github.com/danmana>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts" />
declare module JQueryQRCode {
/**
* One of the possible mode types.
*/
export const enum Mode {
NORMAL,
LABEL_STRIP,
LABEL_BOX,
IMAGE_STRIP,
IMAGE_BOX
}
interface Options {
/**
* Render method: 'canvas', 'image' or 'div'
* @default 'canvas'
*/
render?: string,
/**
* Start of version range, somewhere in 1 .. 40
* @default 1
*/
minVersion?: number,
/**
* End of version range, somewhere in 1 .. 40
* @default 40
*/
maxVersion?: number,
/**
* Error correction level: 'L', 'M', 'Q' or 'H'
* @default 'L'
*/
ecLevel?: string,
/**
* Left offset in pixels, if drawn onto existing canvas
* @default 0
*/
left?: number,
/**
* Top offset in pixels, if drawn onto existing canvas
* @default 0
*/
top?: number,
/**
* Size in pixel
* @default 200
*/
size?: number,
/**
* Code color or image element
* @default '#000'
*/
fill?: string,
/**
* Background color or image element, null for transparent background
* @default null
*/
background?: string,
/**
* The text content of the QR code.
* @default 'no text'
*/
text?: string,
/**
* Corner radius relative to module width: 0.0 .. 0.5
* @default 0
*/
radius?: number,
/**
* Quiet zone in modules
* @default 0
*/
quiet?: number,
/**
* Mode
* @default Mode.NORMAL
*/
mode?: Mode,
/** @default 0.1 */
mSize?: number,
/** @default 0.5 */
mPosX?: number,
/** @default 0.5 */
mPosY?: number,
/** @default 'no label' */
label?: string,
/** @default 'sans' */
fontname?: string,
/** @default '#000' */
fontcolor?: string,
/** @default null */
image?: string
}
}
interface JQuery {
/**
* Create a QR Code inside the selected container.
* @param options
*/
qrcode(options?: JQueryQRCode.Options): JQuery;
}