За последние 24 часа нас посетили 17599 программистов и 1724 робота. Сейчас ищут 962 программиста ...

Помогите разобраться в коде

Тема в разделе "Прочие вопросы по PHP", создана пользователем Alex63, 3 апр 2015.

  1. Alex63

    Alex63 Новичок

    С нами с:
    3 апр 2015
    Сообщения:
    1
    Симпатии:
    0
    Здравствуйте, я новичок в php, и не совсем понимаю что нужно делать.
    В общем стоял ява скрипт на открытие окна авторизации (движок DLE), как только обновил DLE и php, скрипт перестал открывать окно, но затемнение фона всё равно происходит. Подскажите пожалуйста, что нужно исправить в коде, чтобы всё работало как и раньше?
    Код (PHP):
    1. (function($) {
    2.     var openedPopups = [];
    3.     var popupLayerScreenLocker = false;
    4.     var focusableElement = [];
    5.     var setupJqueryMPopups = {
    6.         screenLockerBackground: "#000",
    7.         screenLockerOpacity: "0.7"
    8.     };
    9.  
    10.     $.setupJMPopups = function(settings) {
    11.         setupJqueryMPopups = jQuery.extend(setupJqueryMPopups, settings);
    12.         return this;
    13.     }
    14.  
    15.     $.openPopupLayer = function(settings) {
    16.         if (typeof(settings.name) != "undefined" && !checkIfItExists(settings.name)) {
    17.             settings = jQuery.extend({
    18.                 width: "auto",
    19.                 height: "auto",
    20.                 parameters: {},
    21.                 target: "",
    22.                 success: function() {},
    23.                 error: function() {},
    24.                 beforeClose: function() {},
    25.                 afterClose: function() {},
    26.                 reloadSuccess: null,
    27.                 cache: false
    28.             }, settings);
    29.             loadPopupLayerContent(settings, true);
    30.             return this;
    31.         }
    32.     }
    33.     
    34.     $.closePopupLayer = function(name) {
    35.         if (name) {
    36.             for (var i = 0; i < openedPopups.length; i++) {
    37.                 if (openedPopups[i].name == name) {
    38.                     var thisPopup = openedPopups[i];
    39.                     
    40.                     openedPopups.splice(i,1)
    41.                     
    42.                     thisPopup.beforeClose();
    43.                     
    44.                     $("#popupLayer_" + name).fadeOut(function(){
    45.                         $("#popupLayer_" + name).remove();
    46.                     
    47.                         focusableElement.pop();
    48.     
    49.                         if (focusableElement.length > 0) {
    50.                             $(focusableElement[focusableElement.length-1]).focus();
    51.                         }
    52.     
    53.                         thisPopup.afterClose();
    54.                         hideScreenLocker(name);
    55.                     });
    56.                     
    57.                     
    58.    
    59.                     break;
    60.                 }
    61.             }
    62.         } else {
    63.             if (openedPopups.length > 0) {
    64.                 $.closePopupLayer(openedPopups[openedPopups.length-1].name);
    65.             }
    66.         }
    67.         
    68.         return this;
    69.     }
    70.     
    71.     $.reloadPopupLayer = function(name, callback) {
    72.         if (name) {
    73.             for (var i = 0; i < openedPopups.length; i++) {
    74.                 if (openedPopups[i].name == name) {
    75.                     if (callback) {
    76.                         openedPopups[i].reloadSuccess = callback;
    77.                     }
    78.                     
    79.                     loadPopupLayerContent(openedPopups[i], false);
    80.                     break;
    81.                 }
    82.             }
    83.         } else {
    84.             if (openedPopups.length > 0) {
    85.                 $.reloadPopupLayer(openedPopups[openedPopups.length-1].name);
    86.             }
    87.         }
    88.         
    89.         return this;
    90.     }
    91.  
    92.     function setScreenLockerSize() {
    93.         if (popupLayerScreenLocker) {
    94.             $('#popupLayerScreenLocker').height($(document).height() + "px");
    95.             $('#popupLayerScreenLocker').width($(document.body).outerWidth(true) + "px");
    96.         }
    97.     }
    98.     
    99.     function checkIfItExists(name) {
    100.         if (name) {
    101.             for (var i = 0; i < openedPopups.length; i++) {
    102.                 if (openedPopups[i].name == name) {
    103.                     return true;
    104.                 }
    105.             }
    106.         }
    107.         return false;
    108.     }
    109.     
    110.     function showScreenLocker() {
    111.         if ($("#popupLayerScreenLocker").length) {
    112.             if (openedPopups.length == 1) {
    113.                 popupLayerScreenLocker = true;
    114.                 setScreenLockerSize();
    115.                 $('#popupLayerScreenLocker').fadeIn();
    116.             }
    117.    
    118.             if ($.browser.msie && $.browser.version < 7) {
    119.                 $("select:not(.hidden-by-jmp)").addClass("hidden-by-jmp hidden-by-" + openedPopups[openedPopups.length-1].name).css("visibility","hidden");
    120.             }
    121.                
    122.             $('#popupLayerScreenLocker').css("z-index",parseInt(openedPopups.length == 1 ? 999 : $("#popupLayer_" + openedPopups[openedPopups.length - 2].name).css("z-index")) + 1);
    123.         } else {
    124.             $("body").append("<div id='popupLayerScreenLocker'></div>");
    125.             $("#popupLayerScreenLocker").css({
    126.                 position: "absolute",
    127.                 background: setupJqueryMPopups.screenLockerBackground,
    128.                 left: "0",
    129.                 top: "0",
    130.                 opacity: setupJqueryMPopups.screenLockerOpacity,
    131.                 display: "none"
    132.             });
    133.             showScreenLocker();
    134.  
    135.             $("#popupLayerScreenLocker").click(function() {
    136.                 $.closePopupLayer();
    137.             });
    138.         }
    139.     }
    140.     
    141.     function hideScreenLocker(popupName) {
    142.         if (openedPopups.length == 0) {
    143.             screenlocker = false;
    144.             $('#popupLayerScreenLocker').fadeOut();
    145.         } else {
    146.             $('#popupLayerScreenLocker').css("z-index",parseInt($("#popupLayer_" + openedPopups[openedPopups.length - 1].name).css("z-index")) - 1);
    147.         }
    148.    
    149.         if ($.browser.msie && $.browser.version < 7) {
    150.             $("select.hidden-by-" + popupName).removeClass("hidden-by-jmp hidden-by-" + popupName).css("visibility","visible");
    151.         }
    152.     }
    153.     
    154.     function setPopupLayersPosition(popupElement, animate) {
    155.         if (popupElement) {
    156.             if (popupElement.width() < $(window).width()) {
    157.                 var leftPosition = (document.documentElement.offsetWidth - popupElement.width()) / 2;
    158.             } else {
    159.                 var leftPosition = document.documentElement.scrollLeft + 5;
    160.             }
    161.  
    162.             if (popupElement.height() < $(window).height()) {
    163.                 var topPosition = document.documentElement.scrollTop + ($(window).height() - popupElement.height()) / 2;
    164.             } else {
    165.                 var topPosition = document.documentElement.scrollTop + 5;
    166.             }
    167.             
    168.             var positions = {
    169.                 left: leftPosition + "px",
    170.                 top: topPosition + "px"
    171.             };
    172.             
    173.             if (!animate) {
    174.                 popupElement.css(positions);
    175.             } else {
    176.                 popupElement.animate(positions, "slow");
    177.             }
    178.                         
    179.             setScreenLockerSize();
    180.         } else {
    181.             for (var i = 0; i < openedPopups.length; i++) {
    182.                 setPopupLayersPosition($("#popupLayer_" + openedPopups[i].name), true);
    183.             }
    184.         }
    185.     }
    186.  
    187.     function showPopupLayerContent(popupObject, newElement, data) {
    188.         var idElement = "popupLayer_" + popupObject.name;
    189.  
    190.         if (newElement) {
    191.             showScreenLocker();
    192.             
    193.             $("body").append("<div id='" + idElement + "'></div>");
    194.             
    195.             var zIndex = parseInt(openedPopups.length == 1 ? 1000 : $("#popupLayer_" + openedPopups[openedPopups.length - 2].name).css("z-index")) + 2;
    196.         }  else {
    197.             var zIndex = $("#" + idElement).css("z-index");
    198.         }
    199.  
    200.         var popupElement = $("#" + idElement);
    201.         
    202.         popupElement.css({
    203.             visibility: "hidden",
    204.             width: popupObject.width == "auto" ? "" : popupObject.width + "px",
    205.             height: popupObject.height == "auto" ? "" : popupObject.height + "px",
    206.             position: "absolute",
    207.             "z-index": zIndex
    208.         });
    209.         
    210.         var linkAtTop = "<a href='#' class='jmp-link-at-top' style='position:absolute; left:-9999px; top:-1px;'> </a><input class='jmp-link-at-top' style='position:absolute; left:-9999px; top:-1px;' />";
    211.         var linkAtBottom = "<a href='#' class='jmp-link-at-bottom' style='position:absolute; left:-9999px; bottom:-1px;'> </a><input class='jmp-link-at-bottom' style='position:absolute; left:-9999px; top:-1px;' />";
    212.  
    213.         popupElement.html(linkAtTop + data + linkAtBottom);
    214.         
    215.         setPopupLayersPosition(popupElement);
    216.  
    217.         popupElement.css("display","none");
    218.         popupElement.css("visibility","visible");
    219.         
    220.         if (newElement) {
    221.             popupElement.fadeIn();
    222.         } else {
    223.             popupElement.show();
    224.         }
    225.  
    226.         $("#" + idElement + " .jmp-link-at-top, " +
    227.           "#" + idElement + " .jmp-link-at-bottom").focus(function(){
    228.             $(focusableElement[focusableElement.length-1]).focus();
    229.         });
    230.         
    231.         var jFocusableElements = $("#" + idElement + " a:visible:not(.jmp-link-at-top, .jmp-link-at-bottom), " +
    232.                                    "#" + idElement + " *:input:visible:not(.jmp-link-at-top, .jmp-link-at-bottom)");
    233.                            
    234.         if (jFocusableElements.length == 0) {
    235.             var linkInsidePopup = "<a href='#' class='jmp-link-inside-popup' style='position:absolute; left:-9999px;'> </a>";
    236.             popupElement.find(".jmp-link-at-top").after(linkInsidePopup);
    237.             focusableElement.push($(popupElement).find(".jmp-link-inside-popup")[0]);
    238.         } else {
    239.             jFocusableElements.each(function(){
    240.                 if (!$(this).hasClass("jmp-link-at-top") && !$(this).hasClass("jmp-link-at-bottom")) {
    241.                     focusableElement.push(this);
    242.                     return false;
    243.                 }
    244.             });
    245.         }
    246.         
    247.         $(focusableElement[focusableElement.length-1]).focus();
    248.  
    249.         popupObject.success();
    250.         
    251.         if (popupObject.reloadSuccess) {
    252.             popupObject.reloadSuccess();
    253.             popupObject.reloadSuccess = null;
    254.         }
    255.     }
    256.     
    257.     function loadPopupLayerContent(popupObject, newElement) {
    258.         if (newElement) {
    259.             openedPopups.push(popupObject);
    260.         }
    261.         
    262.         if (popupObject.target != "") {
    263.             showPopupLayerContent(popupObject, newElement, $("#" + popupObject.target).html());
    264.         } else {
    265.             $.ajax({
    266.                 url: popupObject.url,
    267.                 data: popupObject.parameters,
    268.                 cache: popupObject.cache,
    269.                 dataType: "html",
    270.                 method: "GET",
    271.                 success: function(data) {
    272.                     showPopupLayerContent(popupObject, newElement, data);
    273.                 },
    274.                 error: popupObject.error
    275.             });
    276.         }
    277.     }
    278.     
    279.     $(window).resize(function(){
    280.         setScreenLockerSize();
    281.         setPopupLayersPosition();
    282.     });
    283.     
    284.     $(document).keydown(function(e){
    285.         if (e.keyCode == 27) {
    286.             $.closePopupLayer();
    287.         }
    288.     });
    289. })(jQuery);
    290.  
    291.  
    292.             function openStaticPopup() {
    293.                 $.openPopupLayer({
    294.                     name: "loginPopup",
    295.                     width: 222,
    296.                     target: "loginform"
    297.                 });
    298.             }
     
  2. runcore

    runcore Старожил

    С нами с:
    12 окт 2012
    Сообщения:
    3.625
    Симпатии:
    158
    Re: Перевод js c php5.1 на 5.4

    Эпичное название темы.
    всё равно что сказать: я стал заправлять машину 95-ым вместо 92-го, педаль тормоза стала мягче
     
  3. rodent90

    rodent90 Новичок

    С нами с:
    26 мар 2015
    Сообщения:
    533
    Симпатии:
    37
    А вы гляньте..., что обновилось в движке DLE.
     
  4. Fell-x27

    Fell-x27 Суперстар
    Команда форума Модератор

    С нами с:
    25 июл 2013
    Сообщения:
    12.156
    Симпатии:
    1.771
    Адрес:
    :сердА
    Первым делом, автор, посмотри в консоль браузера. Там наверняка россыпь ошибок, показывающих, что к чему. Если, конечно, дело именно в клиентском коде.