PageSourceSearch

https://neptun.or-zse.hu/oktato/javascript/SDAModal.js

js or-zse.hu collected 2026-10-01 12:18:52 UTC 21,494 bytes, 633 lines download raw bytes

1var dialogclass = "dialog_modal";
2var dialogclassdisplaynone = "dialog_modal_displaynone";
3var modallevel = 0;
4var szulo = "";
5var CloseSender = "x";
6var OpenedDialogs = new Array();
7var modalCaption = "";
8
9function SetModalTitle(behaviorID, title) {
10  modalCaption = title;
11  $('.' + behaviorID).dialog('option', 'title', title);
12}
13
14// ModalPopup létrehozása
15function createModal(behaviorID, footerId, caption, uniqueID, width, height, headerTooltip, helpURL, hideclosebutton, defaultbuttonforenter, mustdopostback, openMaximized, iframemaximalize/*, hidemaximizebutton*/, serverTimeString) {
16  var classIndex = modallevel + 1; // pl: '1'
17  var uj = dialogclass + classIndex; // pl: 'dialog_modal1'
18
19  var overlayZIndex = 100 + (modallevel * 4);
20  var modalZIndex = overlayZIndex + 1;
21
22  modalCaption = caption;
23
24  while (modalCaption.indexOf('%27') > -1) {
25    modalCaption = modalCaption.replace("%27", "'");
26  }
27
28  var up = $('.' + behaviorID);
29
30  // ez a sor a firefox escape-el valo becsukasa miatt kell
31  up.attr('tabindex', '-1');
32
33  // Ezzel felül definiálom a title generálását, mert enélkül nem lehet html a title-ben
34  // ez a szerkeszthetőséghez kell
35  $.widget("ui.dialog", $.extend({}, $.ui.dialog.prototype, {
36    _title: function (title) {
37      title.empty();
38
39      var caption = $("<span>");
40      caption.css("float", "left");
41
42      if (modalCaption.length == 0)
43        caption.html('&nbsp;');
44      else {
45        caption.html(modalCaption);
46      }
47
48      caption.prependTo(title);
49
50      var serverTime = $("<span>");
51      serverTime.css("float", "right");
52      serverTime.css("font-weight", "100");
53      serverTime.html(serverTimeString);
54      serverTime.prependTo(title);
55    }
56  }));
57
58  up.dialog({
59    autoOpen: false,
60    modal: true,
61    //dialogClass: uj + classIndex, // dupla index, pl: 'dialog_modal11'
62    stack: true,
63    //title: newcaption,
64    draggable: true,
65    resizable: true,
66    closeOnEscape: !(hideclosebutton == "True"),
67    dragStart: function (event, ui) {
68      if (BrowserDetect.browser == "Chrome") {
69        //$(document).scrollTop('0');
70      }
71    },
72    open: function (type, data) {
73      var modal = $(this).parent();
74      var modalStyle = "";
75      if (modal.attr("style") != undefined) { modalStyle = modal.attr("style"); }
76      modal.attr("style", modalStyle + "z-index: " + modalZIndex + " !important;");
77
78      var overlay = $(".ui-widget-overlay").last();
79      var overlayStyle = "";
80      if (overlay.attr("style") != undefined) { overlayStyle = overlay.attr("style"); }
81      overlay.attr("style", overlayStyle + "z-index: " + overlayZIndex + " !important;");
82
83      $(".ui-widget-overlay").last().attr('modallevel', classIndex);
84
85      $('#' + footerId).parent().appendTo($(this).parent());
86
87      if (modallevel == 0) {
88        szulo = $('.' + behaviorID).parent().parent();
89      }
90      else {
91        $(this).parent().parent().appendTo(szulo);
92      }
93
94      $(this).parent().appendTo('form');
95
96      if (typeof (hideclosebutton) != "undefined" && hideclosebutton == "True")
97        // this azért kell, mert ha több modal van nyitva, akkor csak erről töntesse el
98        $(this).find(".ui-dialog-titlebar-close").hide();
99
100      modallevel = modallevel + 1;
101
102      if (!Array.contains(OpenedDialogs, behaviorID)) {
103        Array.add(OpenedDialogs, behaviorID);
104
105        var modals = "";
106        for (var i = 0; i < OpenedDialogs.length; i++) {
107          modals = modals + OpenedDialogs[i];
108          if (i != OpenedDialogs.length - 1)
109            modals = modals + ",";
110        }
111
112        $('#ActiveModalBehaviourID').val(modals);
113      }
114
115      if (behaviorID == "behaviorupNewsDetails_modal_NewsDetails") {
116        $(this).parent().offset({ top: 50 });
117        $('html, body').animate({
118          scrollTop: 0
119        }, 1);
120      }
121
122      // ha van előző modál és kisebb nála a mostani, akkor azt fókuszálnom kell az előző fölé
123      if (modallevel - 1 > 0) {
124        try {
125          var elozomodal = $('.' + dialogclass + (modallevel - 1) + (modallevel - 1))[0];
126
127          if (elozomodal) {
128            // ha kisebb a modál , mint az előző
129            if ($(this).parent()[0].offsetHeight < elozomodal.offsetHeight) {
130              var topp = elozomodal.offsetTop + elozomodal.offsetHeight / 2 - ($(this).parent()[0].offsetHeight / 2) + $(document).scrollTop;
131              $(this).parent().offset({ top: topp });
132            }
133          }
134        }
135        catch (error) { }
136      }
137
138      $(this).focus();
139
140      let inputs = modal.find('input');
141      if (inputs && inputs.length) {
142        inputs[0].focus();
143      }
144    },
145    beforeClose: function (type, data) {
146      if (modallevel == 1) {
147        szulo = "";
148      }
149      // Tooltip eltüntetése
150      $('div.tooltip').remove();
151      modallevel = modallevel - 1;
152      //SetPositionLogoutLink();
153      if (CloseSender == "x") {
154        DoPostBackModal(null, "close", null, uniqueID, null, null, null, null, mustdopostback, true);
155      }
156      CloseSender = "x";
157      var gridtooltip = $('.tooltipbase');
158      if (gridtooltip.length > 0) {
159        gridtooltip.css('display', 'none');
160      }
161    },
162    close: function (type, data) {
163      $(this).dialog('destroy');
164      if (Array.contains(OpenedDialogs, behaviorID)) {
165        Array.remove(OpenedDialogs, behaviorID);
166        var modals = "";
167        for (var i = 0; i < OpenedDialogs.length; i++) {
168          modals = modals + OpenedDialogs[i];
169
170          if (i != OpenedDialogs.length - 1)
171            modals = modals + ",";
172        }
173      }
174      $('#ActiveModalBehaviourID').val(modals);
175
176      // csak firefox-nal escape-re nem csukta be pl. a masodik csukando modalt
177      // GyP - 20131106 - háromszintű modál esetén is működik, ja és IE-n is kell, mert ott is csak az első modál csukódott be
178      //if (BrowserDetect.browser == "Firefox") {
179      try {
180        if (modals.length > 0) {
181          if (modals.split(',').length > 0)
182            var $mod = $('.' + modals.split(',')[modals.split(',').length - 1]).find("[aria-selected='true']");
183          if ($mod.length > 0) {
184            // mindig 0-dik a legfelső becsukandó modál
185            $mod[0].focus();
186          }
187        }
188        else if (behaviorID == "behaviorupNewsDetails_modal_NewsDetails") { // ha loginon news-t nyit meg    
189          document.forms[0].user.focus();
190          $("html, body").animate({ scrollTop: 0 }, 1);
191        }
192      }
193      catch (error) { }
194    },
195    resize: function (event, ui) {
196      if (iframemaximalize)
197        SetIframeStyle(this);
198    }
199  }).dialogExtend({
200    "close": !(hideclosebutton == "True"),
201    "maximize": true,//!(hidemaximizebutton== "True"),
202    "help": helpURL != "",
203    "helpUrl": helpURL,
204    "events": {
205      "maximize": function (event, ui) {
206        if (iframemaximalize)
207          SetIframeStyle(this);
208      },
209      "restore": function (event, ui) {
210        if (iframemaximalize)
211          SetIframeStyle(this);
212      }
213    }
214  }).keypress(function (e) {
215    // Textarea-ban figyelmen kívül kell hagyni, mivel ott sortöréseket szeretnénk tenni...
216    if (e.keyCode == $.ui.keyCode.ENTER && $(e.target).is('textarea') == false) {
217      $(this).parent().find('.ui-dialog-footerbar input[commandname="' + defaultbuttonforenter + '"]').click();
218      return false;
219    }
220    //else if (e.keyCode == $.ui.keyCode.ESCAPE) {
221    //    //   $(this).parent().find('.ui-dialog-footerbar input[commandname="' + defaultbuttonforenter + '"]').click();
222    //    alert('hhh');
223    //    return false;
224    //}
225    //}).keyup(function (e) {
226    //if (e.keyCode == $.ui.keyCode.ESCAPE) {
227    //alert('keyup');
228    //}
229  });
230
231  // Szélesség, magasság, min. szélesség, min magasság beállítás
232  if (height > 0) {
233    up.dialog("option", "height", height);
234    up.dialog("option", "minHeight", height);
235  }
236  if (width > 0) {
237    up.dialog("option", "width", width);
238    up.dialog("option", "minWidth", width);
239  }
240  if (typeof (headerTooltip) != undefined && headerTooltip != null && headerTooltip != '')
241    Modaltoolip(behaviorID, headerTooltip);
242
243  // Maximum meretben nyitjuk meg
244  if (openMaximized == "True") {
245    up.dialogExtend('maximize');
246    // le kell vonni a lablec magassaga miatt
247    var _height = up.dialog("option", "height");
248    up.dialog("option", "height", _height - 25);
249  }
250
251  // Neptun.js-ben van, validálásnál nem IE alatt a popup eltolásához kell
252  //eltolasegyszer = true;
253
254  if (iframemaximalize)
255    SetIframeStyle(up);
256
257  //    $('.ui-dialog-footerbar').focus();
258  // $('.ui-dialog-footerbar').attr('tabindex','-1');
259}
260
261function SetIframeStyle(caller) {
262  if ($(caller).find('iframe').length > 0)
263    $(caller).find('iframe').css('height', $(caller).find('iframe').parent().parent().css('height').replace('px', '') - 10 + 'px');
264}
265
266//var timerModal = null;
267//var $modalForFocus = null;
268//function SetFocus($modal) {
269//    if (timerModal != null) {
270//        window.clearTimeout(timerModal);
271//        timerModal = null;
272//    }
273
274//    //$modalForFocus.attr('tabindex', 1);
275
276//    if ($modalForFocus)
277//        $modalForFocus.focus();
278
279//    //$('.ui-dialog-footerbar').attr('tabindex', -1);
280//}
281
282function SetPositionLogoutLink(classIndexAct) {
283
284  var parentTag = $('.top_logout_link').parent().get(0).tagName;
285  if (parentTag.toLowerCase() != 'form')
286    $('.top_logout_link').appendTo('form');
287
288  var ujAct = dialogclass + classIndexAct;
289
290  var zInd = "99";
291  var overl = $("." + ujAct);
292
293  // ha megvan a keresett overlay
294  if (overl.length > 0) {
295    $('.top_logout_link').insertAfter(overl);
296    zInd = overl.css('z-index');
297  }
298
299  if ($(".ui-widget-overlay").length > 0) {
300    $("#lbtnQuit").addClass('top_logout_link_modal');
301  }
302  else {
303    $("#lbtnQuit").removeClass('top_logout_link_modal');
304    // ha nincs tobb overlay, visszateszem a kijelentkezest a helyere
305    $('.top_logout_link').appendTo('.mainPageHeader');
306  }
307
308  $(".top_logout_link").css('z-index', parseInt(zInd));
309}
310
311var modalCreated = [];
312var footer = [];
313function ShowDialog2(behaviorID) {
314  CloseSender = "x";
315
316  //Ha még nincs a tömbben
317  if ($.inArray(behaviorID, modalCreated) == -1) {
318    x = 'CallCreateModal_' + behaviorID;
319    eval(x + "()");
320
321    modalCreated.push(behaviorID);
322
323    // Ez a sor kell a lablec tarolasahoz az ujabb megnyitas miatt
324    var waitfooter = document.getElementById($('.' + behaviorID).parent().attr('id'));
325
326    //$('.' + behaviourID).parent().find('.ui-dialog-footerbar').parent().clone();
327
328    if (footer[behaviorID] != undefined && waitfooter == null)
329      $('.' + behaviorID).append(footer[behaviorID]);
330
331    $('.' + behaviorID).dialog("open");
332    //footer.push($footer);  Elvileg a login.js-ben már beletesszük, ha még nem volt ott, a behaviorID indexe alapján
333    if (behaviorID == 'loginwaitbehaviour')
334      starttimer();
335  }
336}
337
338
339
340
341
342// ModalPopup megjelenítése
343function ShowDialog(behaviorID) {
344  CloseSender = "x";
345  $('.' + behaviorID).dialog("open");
346}
347
348// ModalPopup bezárása
349function closeModal(behaviorID, updatepanelclientid) {
350  CloseSender = "button";
351  // csak akkor zárjuk be, ha még látható (pl.kliens oldali x után már ne akarjuk mégegyszer)
352  if ($('.' + behaviorID).length > 0 && $('.' + behaviorID)[0].style.display == '')
353    $('.' + behaviorID).dialog('close');
354}
355
356var ModalPopupIds = [];
357// Kiteszem a modalban lévő user control id-jét fentre
358function WriteModalId(userctrlcaption, csakkiirni) {
359  var destination = $('#upTraining_lblPageInfoText');
360  if (destination) {
361    var divModalUserCtrl = destination.find('#divModalUserCtrl');
362    if (csakkiirni == 'False')
363      ModalPopupIds[modallevel] = userctrlcaption;
364    else
365      if (modallevel > 0)
366        userctrlcaption = ModalPopupIds[modallevel - 1];
367      else
368        userctrlcaption = '';
369    if (divModalUserCtrl.length == 0)
370      destination.html(destination.html() + ' <div id="divModalUserCtrl" style="position:absolute; z-index:10001;"><strong>' + userctrlcaption + '</strong></div>');
371    else
372      divModalUserCtrl.text(userctrlcaption);
373  }
374}
375
376// Dialog ModalPopup létrehozása
377function DialogConfirmationModal(title, description, okText, cancelText, btnUniqueID, imagename, okTextForAlert, e, Mod
377alUniqueID, CommandName, ConfirmationCausePostback) {
378  CancelEvent(e);
379
380  var ujclass = 'dialog_confirm' + modallevel;
381
382  $("<div title=\"" + title + "\" id=\"confirm\"><img src=\"App_Themes/Common_Images/" + imagename + "\" /><p>" + description + "</p></div>").dialog({
383    autoOpen: true,
384    modal: true,
385    resizable: false,
386    width: 500,
387    height: 160,
388    //zIndex: 101,
389    dialogClass: ujclass + modallevel,
390    open: function (event, ui) {
391      $("div.ui-dialog-buttons").on('keydown', function (event) {
392        if (event.keyCode == $.ui.keyCode.ESCAPE) {
393          $("div.ui-dialog-buttons").off('keydown');
394          jquerydialogclosed = true;
395        }
396      });
397
398      $(".ui-widget-overlay").last().addClass(ujclass);
399    },
400    close: function (ev, ui) {
401      $(this).remove();
402    },
403    buttons: [
404      {
405        text: okText,
406        click: function () {
407          $(document).off('keydown');
408          $(this).dialog("close");
409          if (ConfirmationCausePostback == "True")
410            __doPostBack(ModalUniqueID, CommandName);
411        }
412      },
413      {
414        text: cancelText,
415        click: function () {
416          $(document).off('keydown');
417          $(this).dialog("close");
418          return false;
419        }
420      }
421    ]
422  });
423
424}
425
426// RaisePostBack hívása a megfelelő paraméterrel
427function DoPostBackModal(clientid, postbackarg, bezarni, uniqueID, e, validationgroup, javascript, fullpostbackid, mustdopostback, callfromx, behaviorid) {
428  if (fullpostbackid != "" && fullpostbackid != undefined) {
429    $('#' + fullpostbackid).click();
430    return;
431  }
432  if (postbackarg === 'close' && mustdopostback == "False") {
433    var names = uniqueID.split('$');
434    var name = names[names.length - 1];
435    $('.' + name).val('Visible:false');
436  }
437
438  if (validationgroup != null && validationgroup != "") {
439    if (DoValidateGroupModalPopup(validationgroup) == false) {
440      //var qwe = $('.ajax__validatorcallout_');
441      //var qwe = $('.modify_directory');
442      selectedtabforvalidator(true, behaviorid, $('.' + behaviorid).find('.ajax__tab_panel:visible').find($('.ajax__validatorcallout_')).parent());
443      //$('.ajax__validatorcallout_').appendTo($('.' + behaviorid).parent());
444      return;
445    }
446  }
447  else {
448    DoValidateGroupModalPopup("ModalFakeValidation");
449  }
450
451  if (javascript != null && javascript.length > 0) {
452    var seged = javascript.split('|');
453    var HtmlEditorStr = "";
454    if (seged.length > 1)
455      javascript = seged[0];
456
457    if (javascript.indexOf("HtmlEditor2") !== -1) {
458      for (var i = 1; i < seged.length; i++) {
459        HtmlEditorStr += eval('CKEDITOR.instances.' + seged[i] + '.getData()');
460        if (seged.length - 1 != i)
461          HtmlEditorStr += "♣♣♣";
462      }
463      jhtmlAreaChangedText = false;
464    }
465    else if ((javascript.indexOf("HtmlEditor") !== -1) && javascript !== "HtmlEditor" && javascript !== "HtmlEditoronhtmleditormodal") {
466      for (var i = 0; i < seged.length; i++) {
467        eval("$('#" + seged[i] + "').htmlarea('updateTextArea');")
468        HtmlEditorStr += eval("$('#" + seged[i] + "').val();")
469        if (seged.length - 1 != i)
470          HtmlEditorStr += "♣♣♣";
471      }
472
473      jhtmlAreaChangedText = false;
474    }
475    else if (javascript == "HtmlEditor") {
476      $('#HtmlEditor').htmlarea("updateTextArea");
477      javascript = "$('#HtmlEditor').val();";
478    }
479    else if (javascript == "HtmlEditoronhtmleditormodal") {
480      $('#HtmlEditoronhtmleditormodal').htmlarea("updateTextArea");
481      javascript = "$('#HtmlEditoronhtmleditormodal').val();";
482    }
483    else if (javascript == "filedownload")
484      javascript = "Sys.WebForms.PageRequestManager.getInstance().add_endRequest(FileDownloadEndRequest); theForm.setAttribute('encType', 'multipart/form-data');";
485    else if (javascript == "print1")
486      javascript = "/print.aspx?gridid=signin_print1_cSignInPrint&header=&printheader=&footer=&session=true";
487    else if (javascript == "updateall") {
488      javascript = "UpdateAll('" + uniqueID + "','save');";
489      eval(javascript);
490      return;
491    }
492    else if (javascript == "updateallrefuse") {
493      javascript = "UpdateAll('" + uniqueID + "','refuse');";
494      eval(javascript);
495      return;
496    }
497    else if (javascript.indexOf("WebEditorWorkAround") != -1) // ha ezzel kezdodik
498    {
499      var params = javascript.split(":");
500      var descriptionID = params[1];
501
502      javascript = "WebEditorWorkAround('" + descriptionID + "'); cleanCurrentEditorXhtml('" + descriptionID + "');";
503      eval(javascript);
504    }
505    else if (javascript == "ValidateEmaterialRow") {
506      javascript = "ValidateEmaterialRow('" + seged[1] + "','" + seged[2] + "','" + seged[3] + "','" + seged[4] + "');";
507    }
508    else if (javascript == "KervenyFelfuggesztes") {
509      javascript = /*StopStayAlive();*/ "DisableKervenyButtons(postbackarg);";
510    }
511    else if (javascript == "KervenyPageChange") {
512      //StopStayAlive();
513      javascript = "";
514      if (CheckControls() == false) {
515        mustdopostback = 'False';
516      } else {
517        DisableKervenyButtons(postbackarg);
518      }
519    }
520    else if (javascript == "KervenyLeadas") {
521      javascript = "";
522      DisableKervenyButtons(postbackarg);
523    }
524    else if (javascript.indexOf("multiselect") != -1) {
525      var temp = javascript.split(':');
526      javascript = "multiselectReturnValues('" + temp[1] + "');";
527    }
528    else if (javascript.indexOf("nyomtatasikep") != -1) {
529      var temp = javascript.split(';');
530      javascript = "Nyomtatasikep('" + temp[1] + "');";
531    }
532    if (HtmlEditorStr.length == 0) {
533      if (javascript != "HtmlEditor2") {
534        postbackarg = postbackarg + "|" + eval(javascript) + "|" + validationgroup;
535      }
536      else {
537        postbackarg = postbackarg + "|" + "|" + validationgroup;
538      }
539    }
540    else
541      postbackarg = postbackarg + "|" + HtmlEditorStr + "|" + validationgroup;
542  } else {
543    postbackarg = postbackarg + "|" + "" + "|" + validationgroup;
544  }
545
546  var prm = Sys.WebForms.PageRequestManager.getInstance();
547
548  if (mustdopostback == "True") {
549    __doPostBack(uniqueID, postbackarg);
550  }
551  else {
552    if (callfromx != true) {
553      $($('#' + clientid)[0]).dialog("close");
554    }
555  }
556};
557
558function Nyomtatasikep(url) {
559  myWindow = window.open(url);
560  myWindow.focus();
561}
562
563//function CancelEvent(e) {
564//    var i, j;
565//    if (e != undefined)
566//    {
567//        e.returnValue = false;
568//        e.cancelBubble = true;
569//        if (e.preventDefault) { e.preventDefault(); }
570//        if (e.stopPropagation) { e.stopPropagation(); } 
571//    }
572//    return false;
573//}
574
575//ValidationGroupra hiv kliens oldali validalast
576//ModalPopup-oknal hivjuk a btn ClientClickre
577function DoValidateGroupModalPopup(validationGroup) {
578  Page_InvalidControlToBeFocused = null;
579  if (typeof (Page_Validators) != "undefined") {
580    if (typeof (Page_ClientValidate) == 'function') {
581      Page_ClientValidate(validationGroup);
582    }
583    return Page_IsValid;
584  }
585  return true;
586}
587
588// Toolitp a ModalPopup fejlécében
589function Modaltoolip(behaviorID, headerTooltip, unbind) {
590  var changeTooltipPosition = function (event) {
591    var tooltipX = event.pageX - 8;
592    var tooltipY = event.pageY + 10;
593
594    var spaceOnRight = 5; //px
595
596    if ((tooltipX + spaceOnRight + $(".tooltip").width()) > $("body").width()) {
597      tooltipX = $("body").width() - $(".tooltip").width() - spaceOnRight;
598    }
599    $('div.tooltip').css({ top: tooltipY, left: tooltipX, display: 'block', width: 'auto' });
600  };
601
602  var showTooltip = function (event) {
603    $('div.tooltip').remove();
604    $('<div class="tooltip">' + headerTooltip + '</div>').appendTo(szulo);
605    changeTooltipPosition(event);
606  };
607
608  var hideTooltip = function () {
609    $('div.tooltip').remove();
610  };
611
612  var elsogyerek = $('.' + behaviorID).parent().children()[0];
613  $(elsogyerek).bind({
614    mousemove: changeTooltipPosition,
615    mouseenter: showTooltip,
616    mouseleave: hideTooltip
617  });
618};
619
620function ShowPasswordTask() {
621  var $tds = $("table#Table1").find("input.inputtext").last();
622  var txtPassword = $tds;
623  if (txtPassword.is(':visible')) {
624    txtPassword.after('<input onchange="PasswordChangedTask(this);" class="passwordtext" id = "txt_' + txtPassword.attr("id") + '" type = "text" value = "' + txtPassword.val() + '" autocomplete="off" />');
625    txtPassword.hide();
626  } else {
627    txtPassword.val(txtPassword.next("[id = 'txt_" + txtPassword.attr("id") + "']").val());
628    txtPassword.next("[id = 'txt_" + txtPassword.attr("id") + "']").remove();
629    txtPassword.show();
630  };
631};
632
633function PasswordChangedTask(txt) { $(txt).prev().val($(txt).val()); };

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.