Skip to content

Commit

Permalink
Sync with Kendo UI Professional
Browse files Browse the repository at this point in the history
  • Loading branch information
Kendo Bot committed Feb 21, 2018
1 parent 1dae839 commit 36a97fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 109 deletions.
58 changes: 10 additions & 48 deletions src/kendo.dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,33 +124,6 @@
}
},

setOptions: function(options) {
var that = this;

Widget.fn.setOptions.call(that, options);

if (options.content) {
kendo.destroy(that.element.children());
that.element.html(options.content);
}

if (options.actions) {
that.wrapper.children(KBUTTONGROUP).remove();
that._createActionbar(that.wrapper);
}

that._closable(that.wrapper);
that._dimensions();

if (options.modal !== undefined) {
that._overlay(that.wrapper.is(VISIBLE)).css({ opacity: 0.5 });
}

if (options.title !== undefined) {
that.title(options.title);
}
},

_dimensions: function() {
var that = this,
wrapper = that.wrapper,
Expand Down Expand Up @@ -321,6 +294,7 @@
options = that.options,
isRtl = kendo.support.isRtl(content),
titlebar = $(templates.titlebar(options)),
titlebarActions = titlebar.find(".k-window-actions"),
titleId = (content.id || kendo.guid()) + "_title",
wrapper = $(that.wrapperTemplate(options));

Expand All @@ -329,6 +303,15 @@
content.addClass(KCONTENTCLASS);
that.appendTo.append(wrapper);

if (options.closable !== false) {
if (options.title !== false) {
titlebarActions.append(templates.close(options));
}
else {
wrapper.append(templates.close(options));
}
}

if (options.title !== false) {
wrapper.append(titlebar);
titlebar.attr("id", titleId);
Expand All @@ -337,8 +320,6 @@
wrapper.addClass(KTITLELESS);
}

that._closable(wrapper);

wrapper.append(content);

if (options.content) {
Expand All @@ -351,25 +332,6 @@
}
},

_closable: function (wrapper) {
var that = this;
var options = that.options;
var titlebar = wrapper.children(KDIALOGTITLEBAR);
var titlebarActions = titlebar.find(".k-window-actions");
var closeAction = titlebarActions.length ? titlebarActions.find(".k-dialog-close") : wrapper.find(".k-dialog-close");

closeAction.remove();

if (options.closable !== false) {
if (options.title !== false) {
titlebarActions.append(templates.close(options));
}
else {
wrapper.prepend(templates.close(options));
}
}
},

_createActionbar: function(wrapper) {
var isStretchedLayout = (this.options.buttonLayout === "stretched");
var buttonLayout = isStretchedLayout ? "stretched" : "normal";
Expand Down
61 changes: 0 additions & 61 deletions tests/dialog/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,67 +312,6 @@
ok(dialog.wrapper.is(":visible"));
});

test("setOptions modifies actions", function() {
var dialog = createDialog({
actions: [{
text: "OK"
}]
});

dialog.setOptions({
actions:[
{ text: "OK" },
{ text: "Cancel" }
]
});

equal(dialog.wrapper.find(".k-dialog-buttongroup .k-button").length, 2);
});

test("setOptions modifies title", function() {
var dialog = createDialog({
actions: [{
text: "OK"
}]
});

dialog.setOptions({
title: "Test"
});

equal(dialog.title(), "Test");
});

test("setOptions modifies modality", function() {
var dialog = createDialog({
actions: [{
text: "OK"
}],
modal: true
});

dialog.setOptions({
modal: false
});

equal(dialog.options.modal, false);
});

test("setOptions modifies modality", function() {
var dialog = createDialog({
actions: [{
text: "OK"
}],
modal: true
});

dialog.setOptions({
content: "test"
});

equal(dialog.element.html(), "test");
});

test("center should track for resize", function() {
var dialog = createDialog({ visible: false });
trackMethodCall(dialog, "_centerOnResize");
Expand Down

0 comments on commit 36a97fc

Please sign in to comment.