Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
META-INF.resources.primefaces.core.core.dialog.js Maven / Gradle / Ivy
if (!PrimeFaces.dialog) {
PrimeFaces.dialog = {};
PrimeFaces.dialog.DialogHandler = {
openDialog: function(cfg) {
var rootWindow = this.findRootWindow(),
dialogId = cfg.sourceComponentId + '_dlg';
if(rootWindow.document.getElementById(dialogId)) {
return;
}
var dialogWidgetVar = cfg.sourceComponentId.replace(/:/g, '_') + '_dlgwidget',
dialogDOM = $('
')
.append('');
var titlebar = dialogDOM.children('.ui-dialog-titlebar');
if(cfg.options.closable !== false) {
titlebar.append(' ');
}
if(cfg.options.minimizable) {
titlebar.append(' ');
}
if(cfg.options.maximizable) {
titlebar.append(' ');
}
dialogDOM.append('' +
'' +
'
');
dialogDOM.appendTo(rootWindow.document.body);
var dialogFrame = dialogDOM.find('iframe'),
symbol = cfg.url.indexOf('?') === -1 ? '?' : '&',
frameURL = cfg.url.indexOf('pfdlgcid') === -1 ? cfg.url + symbol + 'pfdlgcid=' + cfg.pfdlgcid: cfg.url,
frameWidth = cfg.options.contentWidth||640;
dialogFrame.width(frameWidth);
dialogFrame.on('load', function() {
var $frame = $(this),
headerElement = $frame.contents().find('title'),
isCustomHeader = false;
if(cfg.options.headerElement) {
var customHeaderId = PrimeFaces.escapeClientId(cfg.options.headerElement),
customHeaderElement = dialogFrame.contents().find(customHeaderId);
if(customHeaderElement.length) {
headerElement = customHeaderElement;
isCustomHeader = true;
}
}
if(!$frame.data('initialized')) {
PrimeFaces.cw.call(rootWindow.PrimeFaces, 'DynamicDialog', dialogWidgetVar, {
id: dialogId,
position: 'center',
sourceComponentId: cfg.sourceComponentId,
sourceWidgetVar: cfg.sourceWidgetVar,
onHide: function() {
var $dialogWidget = this,
dialogFrame = this.content.children('iframe');
if(dialogFrame.get(0).contentWindow.PrimeFaces) {
this.destroyIntervalId = setInterval(function() {
if(dialogFrame.get(0).contentWindow.PrimeFaces.ajax.Queue.isEmpty()) {
clearInterval($dialogWidget.destroyIntervalId);
dialogFrame.attr('src','about:blank');
$dialogWidget.jq.remove();
}
}, 10);
}
else {
dialogFrame.attr('src','about:blank');
$dialogWidget.jq.remove();
}
rootWindow.PF[dialogWidgetVar] = undefined;
},
modal: cfg.options.modal,
resizable: cfg.options.resizable,
hasIframe: true,
draggable: cfg.options.draggable,
width: cfg.options.width,
height: cfg.options.height,
minimizable: cfg.options.minimizable,
maximizable: cfg.options.maximizable,
headerElement: cfg.options.headerElement
});
}
var title = rootWindow.PF(dialogWidgetVar).titlebar.children('span.ui-dialog-title');
if(headerElement.length > 0) {
if(isCustomHeader) {
title.append(headerElement);
headerElement.show();
}
else {
title.text(headerElement.text());
}
dialogFrame.attr('title', title.text());
}
dialogFrame.data('initialized', true);
rootWindow.PF(dialogWidgetVar).show();
//adjust height
var frameHeight = null;
if(cfg.options.contentHeight)
frameHeight = cfg.options.contentHeight;
else
frameHeight = $frame.get(0).contentWindow.document.body.scrollHeight + (PrimeFaces.env.browser.webkit ? 5 : 25);
$frame.css('height', frameHeight);
})
.attr('src', frameURL);
},
closeDialog: function(cfg) {
var rootWindow = this.findRootWindow(),
dlgs = $(rootWindow.document.body).children('div.ui-dialog[data-pfdlgcid="' + cfg.pfdlgcid +'"]').not('[data-queuedforremoval]'),
dlgsLength = dlgs.length,
dlg = dlgs.eq(dlgsLength - 1),
parentDlg = dlgsLength > 1 ? dlgs.eq(dlgsLength - 2) : null,
dlgWidget = rootWindow.PF(dlg.data('widgetvar')),
sourceWidgetVar = dlgWidget.cfg.sourceWidgetVar,
sourceComponentId = dlgWidget.cfg.sourceComponentId,
dialogReturnBehavior = null,
windowContext = null;
dlg.attr('data-queuedforremoval', true);
if(parentDlg) {
var parentDlgFrame = parentDlg.find('> .ui-dialog-content > iframe').get(0),
windowContext = parentDlgFrame.contentWindow||parentDlgFrame;
sourceWidget = windowContext.PF(sourceWidgetVar);
}
else {
windowContext = rootWindow;
}
if(sourceWidgetVar) {
var sourceWidget = windowContext.PF(sourceWidgetVar);
dialogReturnBehavior = sourceWidget.cfg.behaviors ? sourceWidget.cfg.behaviors['dialogReturn']: null;
}
else if(sourceComponentId) {
var dialogReturnBehaviorStr = $(windowContext.document.getElementById(sourceComponentId)).data('dialogreturn');
if(dialogReturnBehaviorStr) {
dialogReturnBehavior = windowContext.eval('(function(ext){this.' + dialogReturnBehaviorStr + '})');
}
}
if(dialogReturnBehavior) {
var ext = {
params: [
{name: sourceComponentId + '_pfdlgcid', value: cfg.pfdlgcid}
]
};
dialogReturnBehavior.call(windowContext, ext);
}
dlgWidget.hide();
},
showMessageInDialog: function(msg) {
if(!this.messageDialog) {
var messageDialogDOM = $('
')
.append('' +
'
')
.appendTo(document.body);
PrimeFaces.cw('Dialog', 'primefacesmessagedialog', {
id: 'primefacesmessagedlg',
modal:true,
draggable: false,
resizable: false,
showEffect: 'fade',
hideEffect: 'fade'
});
this.messageDialog = PF('primefacesmessagedialog');
this.messageDialog.titleContainer = this.messageDialog.titlebar.children('span.ui-dialog-title');
}
this.messageDialog.titleContainer.text(msg.summary);
this.messageDialog.content.html('').append(' ').append(msg.detail);
this.messageDialog.show();
},
confirm: function(msg) {
if(PrimeFaces.confirmDialog) {
PrimeFaces.confirmSource = (typeof(msg.source) === 'string') ? $(PrimeFaces.escapeClientId(msg.source)) : $(msg.source);
PrimeFaces.confirmDialog.showMessage(msg);
}
else {
PrimeFaces.warn('No global confirmation dialog available.');
}
},
findRootWindow: function() {
var w = window;
while(w.frameElement) {
w = w.parent;
};
return w;
}
};
}