数字滚动插件
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

43 lines
1.5 KiB

;
(function ($) {
FR.DigitRoll = FR.extend(FR.Widget, {
_defaultConfig: function () {
return $.extend(FR.DigitRoll.superclass._defaultConfig.apply(), {
baseName: 'fr-digitRoll',
baseClass: 'fr-digitRoll'
});
},
_init: function () {
FR.DigitRoll.superclass._init.apply(this, arguments);
FR.$defaultImport('/com/fr/plugin/widget/digitroll/web/countUp.js', 'js');
var o = this.options;
var element = this.element;
var widget = '<div id="' + o.widgetName + '" style=' + o.css + '></div>';
var widgetId = $(widget).appendTo(element);
o.options.prefix = o.prefix;
o.options.suffix = o.suffix;
var digitRoll = new CountUp(widgetId, 0, o.value, 0/*o.decimals*/, o.duration, o.options);
var callback = function () {
$.ajax({
type: "POST",
url: o.widgetUrl,
success: function (res) {
var data = FR.jsonDecode(res);
o.data = data[0];
var v = data[0].value;
digitRoll.update(v);
}
});
};
if (!digitRoll.error) {
digitRoll.start(callback);
} else {
console.error(digitRoll.error);
}
}
});
$.shortcut("digitRoll", FR.DigitRoll);
})(jQuery);