-
Notifications
You must be signed in to change notification settings - Fork 0
/
qrcodereader-jquery.js
44 lines (35 loc) · 1.04 KB
/
qrcodereader-jquery.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
(function ($) {
'use strict';
var QRCodeReader=window.QRCodeReader;
delete window.QRCodeReader;
function Plugin(option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('qrcodereader')
var options = typeof option == 'object' && option;
if (!data && typeof option == 'string') return
if (!data) {
$this.data('qrcodereader', (data = new QRCodeReader(this, options)))
$this.bind('qrcodereader.decode',function(){
data.decode();
});
$this.bind('qrcodereader.scan-start',function(e,options){
data.startScanner(options);
});
$this.bind('qrcodereader.scan-stop',function(){
data.stopScanner();
});
}
if (typeof option == 'string') data[option]()
})
}
var old = $.fn.qrcodeReader
$.fn.qrcodeReader = Plugin
$.fn.qrcodeReader.Constructor = QRCodeReader
// NO CONFLICT
// ===================
$.fn.qrcodeReader.noConflict = function () {
$.fn.qrcodeReader = old
return this
}
}(jQuery));