Jump to content
  • 0

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


Odrin
 Share

Question

Добрый день.

Копаюсь в исходниках Leaflet и нашел там немного магии, которую никак не могу понять =)

А именно Class.js.

В методе extend:


var F = function () {};
F.prototype = this.prototype;

var proto = new F();
proto.constructor = NewClass;

NewClass.prototype = proto;

Что здесь происходит и для чего эта магия с прототипами? Для чего тут переменная F?

И что такое и какую функцию выполняют InitHooks? (это уже дальше по коду)

Edited by Odrin
Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Similar Content

    • By doox911
      <!DOCTYPE html> <html> <head> <title></title> <meta charset="utf-8" /> <!-- Необходимо для того, чтобы страница отображалась в 100% масштабе.--> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"> <!-- Подключаем различный таблицы стилей. Выбор подключаемой таблицы зависит от расширерения экрана. --> <link rel="stylesheet" type="text/css" media="screen and (min-device-width: 800px)" href="kub_pc.css" /> <link rel="stylesheet" type="text/css" media="screen and (max-device-width: 799px)" href="kub_mobile.css" /> <!-- Подключаем JQuery, JQuery Mobile и JQuery Mobile CSS --> <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script> <script src="http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js"></script> <link rel="stylesheet" href="css/themes/mJQuery.css" /> <link rel="stylesheet" href="css/themes/jquery.mobile.icons.min.css" /> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.0/jquery.mobile.structure-1.4.0.min.css" /> <!-- Подключаем leaflet JS и leaflet CSS, для отображения карты --> <script src="http://cdn.leafletjs.com/leaflet-0.7.1/leaflet.js"></script> <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.1/leaflet.css" /> </head><body> <div data-role="page"> <!-- header --> <div data-role="header"> </div> <!-- /header --> <!-- content --> <div data-role="content"> <div id="map"> <style>#map{ width: 100%; height: 100%; position:relative; top:0px;}#adm_hatun{ margin:0; padding:0; width: 300px; height: 100px; }#adm_hatun i{ font: 10px Arial;}#church{}#school{}#circle{} </style> <script> var MAP = new L.map('map', { center: [55.00568744289998,37.83303327379225], zoom: 13, zoomControl: false, attributionControl: false, scrollWheelZoom: false });// Создали объект карта с параметрами var OSMLayer = new L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', { attribution:'' } ); // Создали объект слоя OSM var adm_hatun = new L.marker([55.00568744289998,37.83303327379225]).addTo(MAP); var church = new L.marker([55.00629042601082,37.83461041269301]).addTo(MAP); var school = new L.marker([55.00896067082531,37.83561892328261]).addTo(MAP); var circle = L.circle([55.002115505025856,37.83243245897292], 50, { color: 'red', fillColor: '#f03', fillOpacity: 0.5}).addTo(MAP); adm_hatun.bindPopup('<div id="adm_hatun"><table><tr><td><i>Администрация - Сельское поселение Семёновское</i></td><td></td></tr></table></div>'); church.bindPopup('<div id="adm_hatun"><table><tr><td><i>Церковь Рождества Пресвятой Богородицы</i></td><td><img src="cherch.jpeg" /></td></tr></table></div>'); school.bindPopup("Школа"); circle.bindPopup("Торговая площадь"); var zoom = L.control.zoom({ position: 'topright', zoomInText: '+', zoomOutText: '-', zoomInTitle: 'Увеличить', zoomOutTitle: 'Уменьшить' }).addTo(MAP); var scale = L.control.scale({ position: 'bottomleft', metric: true, imperial: false }).addTo(MAP); MAP.addLayer(OSMLayer); </script> </div> </div> <!-- /content --> <!-- footer --> <div data-role="footer"> <h4>Page Footer</h4> </div> <!-- /footer --> </div> <!-- /page --> </body></html>Если не использовать данную библиотеку, всё работает. Но с ней нет, почему?
  • Обсуждения

    • Актуальные контакты: Telegram: @Nikker_web E-Mail:   tarasevich.email@gmail.com Портфолио https://www.behance.net/d4d4186e Разрабатываю дизайн групп в соц сетях, сайтов, приложений, другой дизайн под заказ    
    • Актуальные контакты: Telegram: @Nikker_web E-Mail:   tarasevich.email@gmail.com   Разрабатываю дизайн групп в соц сетях, сайтов, приложений, другой дизайн под заказ   Портфолио https://www.behance.net/d4d4186e
    • Доброго всем времени суток. Прошу помощи. Научите принципу изменения футера. Движок Xenforo. Версия 2.2.10. Стиль дефолтный. Что именно нужно в итоге на фото примере. Мой шаблон app.footer less имеет следующее значение.  .p-footer { .xf-publicFooter(); a { .xf-publicFooterLink(); } } .p-footer-inner { .m-pageWidth(); .m-pageInset(); padding-top: @xf-paddingMedium; padding-bottom: @xf-paddingLarge; } .p-footer-row { .m-clearFix(); margin-bottom: -@xf-paddingLarge; } .p-footer-row-main { float: left; margin-bottom: @xf-paddingLarge; } .p-footer-row-opposite { float: right; margin-bottom: @xf-paddingLarge; } .p-footer-linkList { .m-listPlain(); .m-clearFix(); > li { float: left; margin-right: .5em; &:last-child { margin-right: 0; } a { padding: 2px 4px; border-radius: @xf-borderRadiusSmall; &:hover { text-decoration: none; background-color: fade(@xf-publicFooterLink--color, 10%); } } } } .p-footer-rssLink { > span { position: relative; top: -1px; display: inline-block; width: 1.44em; height: 1.44em; line-height: 1.44em; text-align: center; font-size: .8em; background-color: #4682B4; border-radius: 2px; } .fa-rss { color: white; } } .p-footer-copyright { margin-top: @xf-elementSpacer; text-align: center; font-size: @xf-fontSizeSmallest; } .p-footer-debug { margin-top: @xf-paddingLarge; text-align: right; font-size: @xf-fontSizeSmallest; .pairs > dt { color: inherit; } } @media (max-width: @xf-responsiveMedium) { .p-footer-row-main, .p-footer-row-opposite { float: none; } .p-footer-copyright { text-align: left; padding: 0 4px; // aligns with other links } }  
    • Нужны сайты с примерами верстки, типа https://css-tricks.com/. Типовые приемы и нестандартные на все случаи жизни. Накидайте ссылок.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy