function InlineWidget() {
var self = this;
// create the outer wrapper div
this.htmlContent = window.document.createElement("div");
this.$htmlContent = $(this.htmlContent).addClass("inline-widget").attr("tabindex", "-1");
this.$htmlContent.append("<div class='shadow top' />")
.append("<div class='shadow bottom' />")
.append("<a href='#' class='close no-focus'>×</a>");
// create the close button
this.$closeBtn = this.$htmlContent.find(".close");
this.$closeBtn.click(function (e) {
self.close();
e.stopImmediatePropagation();
});
this.$htmlContent.on("keydown", function (e) {
if (e.keyCode === KeyEvent.DOM_VK_ESCAPE) {
self.close();
e.stopImmediatePropagation();
}
});
}
InlineWidget.prototype.htmlContent = null;
InlineWidget.prototype.$htmlContent = null;
InlineWidget.prototype.id = null;
InlineWidget.prototype.hostEditor = null;
EventDispatcher.makeEventDispatcher(InlineWidget.prototype);
Closes this inline widget and all its contained Editors
InlineWidget.prototype.close = function () {
return EditorManager.closeInlineWidget(this.hostEditor, this);
// closeInlineWidget() causes our onClosed() handler to be called
};
InlineWidget.prototype.hasFocus = function () {
var focusedItem = window.document.activeElement,
htmlContent = this.$htmlContent[0];
return $.contains(htmlContent, focusedItem) || htmlContent === focusedItem;
};
InlineWidget.prototype.load = function (hostEditor) {
this.hostEditor = hostEditor;
};
Called once content is parented in the host editor's DOM. Useful for performing tasks like setting focus or measuring content, which require htmlContent to be in the DOM tree.
IMPORTANT: onAdded() MUST be overridden to call hostEditor.setInlineWidgetHeight() at least once to set the initial height (required to animate it open). The widget will never open otherwise.
InlineWidget.prototype.onAdded = function () {
this.trigger("add");
};
Called any time inline is closed, whether manually or automatically.
InlineWidget.prototype.onClosed = function () {
this.trigger("close");
};