Skip to content

Instantly share code, notes, and snippets.

@soen
Last active July 6, 2016 16:21
Show Gist options
  • Save soen/30895e327c62040acd4527455b57ecbd to your computer and use it in GitHub Desktop.
Save soen/30895e327c62040acd4527455b57ecbd to your computer and use it in GitHub Desktop.
define(["sitecore"], function (Sitecore) {
Sitecore.Commands.SetDateAndTime =
{
// code omitted...
execute: function (context) {
// When the dialog is being opened a request to the 'ExperienceEditor.PreviewDate.GetPreviewDateUrl' processor
// is made. In essence, this gets the currently set preview date which is used from within the dialog.
Sitecore.ExperienceEditor.PipelinesUtil.generateRequestProcessor("ExperienceEditor.PreviewDate.GetPreviewDateUrl", function (response) {
Sitecore.ExperienceEditor.Dialogs.showModalDialog(response.responseValue.value, '', '', null, function (result) {
if (!result) {
return;
}
// Once the dialog is being closed, the datetime set is stored in the current context
context.currentContext.value = result;
// And a request to the 'ExperienceEditor.PreviewDate.SetDateValue' processor is made
Sitecore.ExperienceEditor.PipelinesUtil.generateRequestProcessor("ExperienceEditor.PreviewDate.SetDateValue", function () {
Sitecore.ExperienceEditor.modifiedHandling(null, function(isOk) {
// Once the preview date is set, Sitecore reloads the window
window.top.location.reload();
});
}).execute(context);
});
}).execute(context);
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment