Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Option to set close url to dialog widget #5117

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions js/widgets/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ $.widget( "mobile.dialog", $.mobile.widget, {
options: {
closeBtnText: "Close",
overlayTheme: "a",
initSelector: ":jqmData(role='dialog')"
initSelector: ":jqmData(role='dialog')",
closeUrl: undefined
},
_create: function() {
var self = this,
Expand Down Expand Up @@ -81,21 +82,27 @@ $.widget( "mobile.dialog", $.mobile.widget, {
});
},

// Close method goes back in history
// Close method goes back in history unless closeUrl option is set
close: function() {
var dst;

if ( this._isCloseable ) {
this._isCloseable = false;
if ( $.mobile.hashListeningEnabled ) {
$.mobile.back();
} else {
dst = $.mobile.urlHistory.getPrev().url;
if ( !$.mobile.path.isPath( dst ) ) {
dst = $.mobile.path.makeUrlAbsolute( "#" + dst );

if (this.options.closeUrl !== undefined) {
$.mobile.changePage( this.options.closeUrl );
} else {

if ( $.mobile.hashListeningEnabled ) {
$.mobile.back();
} else {
dst = $.mobile.urlHistory.getPrev().url;
if ( !$.mobile.path.isPath( dst ) ) {
dst = $.mobile.path.makeUrlAbsolute( "#" + dst );
}

$.mobile.changePage( dst, { changeHash: false, fromHashChange: true } );
}

$.mobile.changePage( dst, { changeHash: false, fromHashChange: true } );
}
}
}
Expand Down