wc-usage.js
1.3 KB
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
45
46
47
48
49
50
( function ( $ ) {
"use strict";
var WC_Usage = function (options) {
this.init( 'wc_usage', options, WC_Usage.defaults );
};
$.fn.editableutils.inherit( WC_Usage, $.fn.editabletypes.abstractinput );
$.extend( WC_Usage.prototype, {
value2input: function( value ) {
if ( ! value ) {
return;
}
this.$input.find( '[name="usage_limit"]' ).val( value.usage_limit );
this.$input.find( '[name="usage_limit_per_user"]' ).val( value.usage_limit_per_user );
},
input2value: function() {
return {
usage_limit: this.$input.find( '[name="usage_limit"]' ).val(),
usage_limit_per_user: this.$input.find( '[name="usage_limit_per_user"]' ).val()
};
}
} );
var template = '';
template += '<div>';
template += '<div>';
template += '<label>Usage limit per coupon</label>';
template += '<input type="text" class="form-control input-sm small-text" name="usage_limit">';
template += '</div>';
template += '<div>';
template += '<label>Usage limit per user</label>';
template += '<input type="text" class="form-control input-sm small-text" name="usage_limit_per_user">';
template += '</div>';
template += '</div>';
WC_Usage.defaults = $.extend( {}, $.fn.editabletypes.abstractinput.defaults, {
tpl: template
} );
$.fn.editabletypes.wc_usage = WC_Usage;
} ( window.jQuery ) );