This is a standalone executable protected bit of code. Let me break it:
(function(window, PhotoSwipe){
...
}(window, window.Code.PhotoSwipe));
In parentheses, our code will be executed by itself, without any additional links.
window window.Code.PhotoSwipe, . , PhotoSwipe window.Code.PhotoSwipe. window, , window.
, addEventListener, , :
function myFunc() {
var options = {},
instance = PhotoSwipe.attach( window.document.querySelectorAll('#Gallery a'), options );
}
document.addEventListener('DOMContentLoaded', myFunc, false);
: , , addEventListener .
addEventListener . DOMContentLoaded. document. , , , myFunc.
false . , DOM. Capturing, DOM . Bubbling, DOM . false , bubbling.
myFunct, , DOMContentLoaded document, , options. , .
-, attach PhotoSwipe. - . DOM , #Gallery a, "". :
<div id="Gallery"><a href="#">Foo</a></div>
<div id="Gallery">
<div class="picture">
<a href="#">Open</a>
</div>
<div class="picture">
<a href="#">Open</a>
</div>
</div>
, . , PhotoSwipe , .