@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
87 lines (86 loc) • 2.65 kB
JavaScript
Object.defineProperties(exports, {
__esModule: { value: true },
[Symbol.toStringTag]: { value: "Module" }
});
require("./kendo.core-kmRaf_Lg.js");
require("./kendo.html.button.js");
//#region ../src/kendo.checkpoint.js
const __meta__ = {
id: "checkpoint",
name: "Checkpoint",
category: "web",
description: "The Checkpoint component.",
depends: ["core", "html.button"]
};
(function($, undefined) {
const kendo = window.kendo;
const Widget = kendo.ui.Widget;
const encode = kendo.htmlEncode;
const NS = ".kendoCheckpoint";
const ACTION = "action";
const Checkpoint = Widget.extend({
init: function(element, options) {
const that = this;
Widget.fn.init.call(that, element, options);
that._render();
that._bindEvents();
kendo.notify(that);
},
options: {
name: "Checkpoint",
state: null,
displayMode: "hover",
template: null,
messages: {
startOver: "Start Over",
restore: "Restore Checkpoint",
redo: "Redo",
checkpointRestoredText: "Checkpoint Restored"
}
},
events: [ACTION],
_render: function() {
const that = this;
const opts = that.options;
that.element.addClass("k-checkpoint").toggleClass("k-checkpoint-visible", opts.displayMode === "always");
const lineHtml = `<span class="k-checkpoint-line" aria-hidden="true"></span>`;
if (opts.template !== null) {
const tmpl = opts.template;
that.element.html(lineHtml + tmpl({}) + lineHtml);
} else {
const label = opts.state ? opts.messages[opts.state] || opts.state : "";
const stampHtml = opts.state === "redo" ? `<span class="k-checkpoint-stamp">${encode(opts.messages.checkpointRestoredText || "Checkpoint Restored")}</span><span>·</span>` : "";
const buttonHtml = kendo.html.renderButton(`<button class="k-checkpoint-button">${encode(label)}</button>`, {
fillMode: "flat",
size: "xsmall"
});
that.element.html(lineHtml + stampHtml + buttonHtml + lineHtml);
}
},
_bindEvents: function() {
const that = this;
that.element.on("click.kendoCheckpoint", ".k-checkpoint-button", that._onClick.bind(that));
},
_onClick: function() {
const that = this;
that.trigger(ACTION, { action: that.options.state });
},
setState: function(state) {
const that = this;
that.element.off(NS);
that.options.state = state;
that._render();
that._bindEvents();
},
destroy: function() {
const that = this;
that.element.off(NS);
Widget.fn.destroy.call(that);
}
});
kendo.ui.plugin(Checkpoint);
})(window.kendo.jQuery);
var kendo_checkpoint_default = kendo;
//#endregion
exports.__meta__ = __meta__;
exports.default = kendo_checkpoint_default;