var KretaWindowHelper = (function () { var kretaWindowHelper = function () {}; var MIN_HEIGHT = 125; var MIN_WIDTH = 320; kretaWindowHelper.getWindowConfigContainer = function () { return { actions: null, content: null, resizable: false, closeFunction: null, width: '90%', height: '90%', maxWidth: null, maxHeight: null, minWidth: MIN_WIDTH + 'px', minHeight: MIN_HEIGHT + 'px', title: '' }; }; kretaWindowHelper.createWindow = function (id, config) { var element = getOrCreateWindowElement(id); var position = getPosition(); var modal = element.data('kendoWindow'); if (!modal) { modal = createModal(element, position, config); } else { modal.setOptions({ position: position }); } return modal; }; kretaWindowHelper.confirmWindow = function ( title, content, jsFunction, jsFunctionParameter, jsFunctionClose, okString, closeString, isNestedConfirm, showCloseButton, isNote, isNoteRequired, noteCaption, width, height ) { var wind = $('#KretaGeneratedConfrimWindowNest').data('kendoWindow'); if (wind != undefined) { wind.destroy(); } var confirmWindowId = 'KretaGeneratedConfrimWindow'; if (isNestedConfirm) { confirmWindowId += 'Nest'; } if ($('#' + confirmWindowId).length > 0) { return false; } var actions = []; if (showCloseButton) { actions = ['Close']; } var kendoWindow = $('
').kendoWindow({ title: title, actions: actions, resizable: false, modal: true, minHeight: MIN_HEIGHT, minWidth: MIN_WIDTH }); if (!CommonUtils.isNullOrUndefined(height)) { kendoWindow.data('kendoWindow').setOptions({ height: height }); } if (!CommonUtils.isNullOrUndefined(width)) { kendoWindow.data('kendoWindow').setOptions({ width: width }); } var okBtnMsg = Globalization.Igen, closeBtnMsg = Globalization.Nem; if (typeof okString !== 'undefined') { okBtnMsg = okString; } if (typeof closeString !== 'undefined') { closeBtnMsg = closeString; } var data = '
 ' + content + '
'; if (isNote) { data += "
"; data += "
" + noteCaption + "
" + Globalization.KotelezoMegadni + '
'; data += '
'; } data += '
'; data += '
' + okBtnMsg + '
'; data += ' 
' + closeBtnMsg + '
'; data += '
'; kendoWindow.data('kendoWindow').content(data).center().open(); kendoWindow .find('.closeNoConfirm') .click(function () { if (CommonUtils.isFunction(jsFunctionClose)) { jsFunctionClose(); } var wind = kendoWindow.data('kendoWindow'); if (wind != undefined) { wind.destroy(); } }) .end(); kendoWindow .find('.closeYesConfirm') .click(function () { if (isNote) { var note = $('#modalNote').val(); if (isNoteRequired && CommonUtils.isNullOrWhiteSpace(note)) { $('#modalNote').addClass('required'); $('div.noteValidation').addClass('noteRequired'); return; } if (CommonUtils.parseBool(isNestedConfirm)) { jsFunction(jsFunctionParameter, note); } else { setTimeout(function () { jsFunction(jsFunctionParameter, note); }, 1); } } else if (CommonUtils.isFunction(jsFunction)) { if (CommonUtils.parseBool(isNestedConfirm)) { jsFunction(jsFunctionParameter); } else { setTimeout(function () { jsFunction(jsFunctionParameter); }, 1); } } var wind = kendoWindow.data('kendoWindow'); if (wind != undefined) { wind.destroy(); } }) .end(); }; kretaWindowHelper.errorHandlerWindow = function ( title, content, closejsFunction, reportErrorJsFunction, name ) { var element; if (!CommonUtils.isUndefined(name)) { element = $('
', { name: name }); } else { element = $('
'); } var kendoWindow = element.kendoWindow({ title: title, actions: [], resizable: false, modal: true, minHeight: MIN_HEIGHT, minWidth: MIN_WIDTH }); var data = '
 ' + content + '
' + ''; kendoWindow.data('kendoWindow').content(data).center().open(); kendoWindow .find('.reportError') .click(function () { if (CommonUtils.isFunction(reportErrorJsFunction)) { reportErrorJsFunction(); } }) .end(); kendoWindow .find('.closeFeedback') .click(function () { kendoWindow.data('kendoWindow').destroy(); if (CommonUtils.isFunction(closejsFunction)) { closejsFunction(); } }) .end(); }; kretaWindowHelper.feedbackWindow = function ( title, content, isError, jsFunction, backButtonText, name, newHeight, closeButtonId ) { var element; if (!CommonUtils.isNullOrUndefined(name)) { element = $('
', { name: name }); } else { element = $('
'); } var kendoWindow = element.kendoWindow({ title: title, actions: [], resizable: false, modal: true, minHeight: MIN_HEIGHT, minWidth: MIN_WIDTH }); if (!CommonUtils.isNullOrUndefined(newHeight)) { kendoWindow.data('kendoWindow').setOptions({ height: newHeight }); } var closeId = CommonUtils.isNullOrUndefined(closeButtonId) ? '' : ' id ="' + closeButtonId + '"'; var backText = CommonUtils.isNullOrUndefined(backButtonText) ? Globalization.Vissza : backButtonText; var data = '
' + '
' + '
' + '
' + ' ' + content + '
' + ''; kendoWindow.data('kendoWindow').content(data).center().open(); kendoWindow .find('.closeFeedback') .click(function () { kendoWindow.data('kendoWindow').destroy(); if (CommonUtils.isFunction(jsFunction)) { jsFunction(); } }) .end(); }; kretaWindowHelper.feedbackWindowWithLink = function ( title, content, linkText, linkUrl, isError, jsFunction, backButtonText, name, newHeight ) { var element; if (!CommonUtils.isUndefined(name)) { element = $('
', { name: name }); } else { element = $('
'); } var kendoWindow = element.kendoWindow({ title: title, actions: [], resizable: false, modal: true, minHeight: MIN_HEIGHT, minWidth: MIN_WIDTH }); if (!CommonUtils.isNullOrUndefined(newHeight)) { kendoWindow.data('kendoWindow').setOptions({ height: newHeight }); } var data = '
 ' + content + '
'; data += ''; kendoWindow.data('kendoWindow').content(data).center().open(); kendoWindow .find('.closeFeedback') .click(function () { kendoWindow.data('kendoWindow').destroy(); if (CommonUtils.isFunction(jsFunction)) { jsFunction(); } }) .end(); }; kretaWindowHelper.warningWindow = function ( title, content, jsFunction, name, newHeight, customButtonText = null ) { var element; if (!CommonUtils.isUndefined(name)) { element = $('
', { name: name }); } else { element = $('
'); } var buttonText = ''; if (CommonUtils.isNullOrUndefined(customButtonText)) { buttonText = Globalization.Vissza; } else { buttonText = customButtonText; } var kendoWindow = element.kendoWindow({ title: title, actions: [], resizable: false, modal: true, minHeight: MIN_HEIGHT, minWidth: MIN_WIDTH }); if (!CommonUtils.isNullOrUndefined(newHeight)) { kendoWindow.data('kendoWindow').setOptions({ height: newHeight }); } var data = '
 ' + content + '
'; data += '
'; kendoWindow.data('kendoWindow').content(data).center().open(); kendoWindow .find('.closeWarning') .click(function () { if (CommonUtils.isFunction(jsFunction)) { jsFunction(); } kendoWindow.data('kendoWindow').destroy(); }) .end(); }; kretaWindowHelper.defaultWindow = function (title, content, name, newHeight) { var element; if (!CommonUtils.isUndefined(name)) { element = $('
', { name: name }); } else { element = $('
'); } var kendoWindow = element.kendoWindow({ title: title, actions: [], resizable: false, modal: true, minHeight: MIN_HEIGHT, minWidth: MIN_WIDTH }); if (!CommonUtils.isNullOrUndefined(newHeight)) { kendoWindow.data('kendoWindow').setOptions({ height: newHeight }); } var data = '
 ' + content + '
'; data += '
'; kendoWindow.data('kendoWindow').content(data).center().open(); kendoWindow .find('.closeFeedback') .click(function () { kendoWindow.data('kendoWindow').destroy(); }) .end(); }; kretaWindowHelper.destroyAllWindow = function () { $('.k-window-content').each(function () { $(this).data('kendoWindow').destroy(); }); }; kretaWindowHelper.getKendoWindowData = function (id) { var modal = $('#' + id).data('kendoWindow'); return modal; }; kretaWindowHelper.setWindowHeight = function (id, height) { var kendoWindowData = kretaWindowHelper.getKendoWindowData(id); kendoWindowData.setOptions({ height: height }); }; kretaWindowHelper.openWindow = function (modal, center) { openWindow(modal, center); }; kretaWindowHelper.destroyWindow = function (id) { destroyWindow(id); }; kretaWindowHelper.successFeedBackWindow = function ( jsFunction, customMessageText ) { if (!GlobalSystemParams.SuccessFeedBackWindowNeeded) { if (CommonUtils.isUndefined(customMessageText)) { customMessageText = Globalization.SikeresMentes; } KretaWindowHelper.notification(customMessageText, 'success'); } if (CommonUtils.isFunction(jsFunction)) { jsFunction(); } }; kretaWindowHelper.notification = function (customMessageText, type) { var element = getOrCreateWindowElement('kretaNotification'); element.kendoNotification({ show: notificationShow }); var widget = element.data('kendoNotification'); widget.show(customMessageText, type); }; function notificationShow(e) { var highest = 10000; $('body') .children() .each(function () { var current = parseInt($(this).css('z-index'), 10); if (current && highest < current) highest = current; }); e.element.parent().css('z-index', highest + 1); } function getOrCreateWindowElement(id) { var element = $('#' + id); if (!element.length) { element = $('
', { id: id }).appendTo('body'); } else { element.remove(); element = $('
', { id: id }).appendTo('body'); } return element; } function getPosition() { var position = { top: function () { return 0; }, left: function () { return 0; } }; return position; } function createModal(element, position, config) { modal = element .kendoWindow({ title: config.title, width: config.width, height: config.height, minWidth: config.minWidth, minHeight: config.minHeight, maxHeight: config.maxHeight == null ? undefined : config.maxHeight, maxWidth: config.maxWidth == null ? undefined : config.maxWidth, actions: config.actions ? config.actions : ['Maximize', 'Close'], visible: false, modal: true, resizable: config.resizable, position: position, close: function () { if (CommonUtils.isFunction(config.closeFunction)) { config.closeFunction(); } element.empty(); this.destroy(); } }) .data('kendoWindow') .content(config.content); $.validator.unobtrusive.parse('form'); return modal; } function openWindow(modal, center) { if (modal) { if (center) { modal.center(); } modal.open(); } } function destroyWindow(id) { var modal = $('#' + id).data('kendoWindow'); if (modal) { modal.destroy(); } } kretaWindowHelper.feedbackWindowWithThreeButton = function ( title, content, isError, firstButtonText, secondButtonText, thirdButtonText, jsFirstFunction, jsSecondFunction, jsThirdFunction, firstButtonId, secondButtonId, thirdButtonId, name, newHeight, firstFnData, secondFnData, thirdFnData ) { var element; if (!CommonUtils.isNullOrUndefined(name)) { element = $('
', { name: name }); } else { element = $('
'); } var kendoWindow = element.kendoWindow({ title: title, actions: [], resizable: false, modal: true, minHeight: MIN_HEIGHT, minWidth: MIN_WIDTH }); if (!CommonUtils.isNullOrUndefined(newHeight)) { kendoWindow.data('kendoWindow').setOptions({ height: newHeight }); } var firstId = CommonUtils.isNullOrUndefined(firstButtonId) ? '' : ' id ="' + firstButtonId + '"'; var firstText = CommonUtils.isNullOrUndefined(firstButtonText) ? Globalization.Vissza : firstButtonText; var secondId = CommonUtils.isNullOrUndefined(secondButtonId) ? '' : ' id ="' + secondButtonId + '"'; var secondText = CommonUtils.isNullOrUndefined(secondButtonText) ? Globalization.Vissza : secondButtonText; var thirdId = CommonUtils.isNullOrUndefined(thirdButtonId) ? '' : ' id ="' + thirdButtonId + '"'; var thirdText = CommonUtils.isNullOrUndefined(thirdButtonText) ? Globalization.Vissza : thirdButtonText; var data = '
' + '
' + '
' + '
' + ' ' + content + '
' + ''; kendoWindow.data('kendoWindow').content(data).center().open(); kendoWindow .find('.firstFeedback') .click(function () { kendoWindow.data('kendoWindow').destroy(); if (CommonUtils.isFunction(jsFirstFunction)) { if (firstFnData !== undefined) { jsFirstFunction(firstFnData); } jsFirstFunction(); } }) .end(); kendoWindow .find('.secondFeedback') .click(function () { kendoWindow.data('kendoWindow').destroy(); if (CommonUtils.isFunction(jsSecondFunction)) { if (secondFnData !== undefined) { jsSecondFunction(secondFnData); } jsSecondFunction(); } }) .end(); kendoWindow .find('.thirdFeedback') .click(function () { kendoWindow.data('kendoWindow').destroy(); if (CommonUtils.isFunction(jsThirdFunction)) { if (thirdFnData !== undefined) { jsThirdFunction(thirdFnData); } jsThirdFunction(); } }) .end(); }; return kretaWindowHelper; })();