forked from price-format/Jquery-Price-Format
-
Notifications
You must be signed in to change notification settings - Fork 1
/
jquery.price_format.unobtrusive.js
38 lines (31 loc) · 1.1 KB
/
jquery.price_format.unobtrusive.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
(function ($) {
var $jQpft = $.fn.priceFormat
$jQpft.unobtrusive = {
parseElement: function (element) {
var $element = $(element)
var options = {
prefix: $element.data('priceformat-prefix'),
suffix: $element.data('priceformat-suffix'),
centsSeparator: $element.data('priceformat-centsseparator'),
thousandsSeparator: $element.data('priceformat-thousandsseparator'),
limit: $element.data('priceformat-limit'),
centsLimit: $element.data('priceformat-centslimit'),
clearPrefix: $element.data('priceformat-clearprefix'),
clearSufix: $element.data('priceformat-clearsufix'),
allowNegative: $element.data('priceformat-allownegative'),
insertPlusSign: $element.data('priceformat-insertplussign'),
clearOnEmpty: $element.data('priceformat-clearonempty')
}
$element.priceFormat(options)
},
parse: function (selector) {
var $selector = $(selector)
$selector.find("[data-priceformat=true], [data-priceformat=True]").each(function () {
$jQpft.unobtrusive.parseElement(this)
})
}
}
$(function () {
$jQpft.unobtrusive.parse(document);
})
}(jQuery));