Skip to content

Commit

Permalink
docs upd, closes #269
Browse files Browse the repository at this point in the history
  • Loading branch information
dimsemenov committed Nov 15, 2013
1 parent c1ca7bc commit b485bc8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
33 changes: 21 additions & 12 deletions website/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -927,8 +927,11 @@ callbacks: {
console.log('Start of popup initialization');
},
elementParse: function(item) {
// Function will fire for each target element
// "item.el" is a target DOM element (if present)
// "item.src" is a source that you may modify

console.log('Parsing content. Item object that is being parsed:', item);
// feel free to modify here item object
},
change: function() {
console.log('Content changed');
Expand Down Expand Up @@ -964,12 +967,6 @@ callbacks: {
// "data.text" - text that will be displayed (e.g. "Loading...")
// you may modify this properties to change current status or its text dynamically
},
elementParse: function(item) {
console.log('Parsing element:', item);
// triggers only once for each item
// here you may modify URL, type, or any other data
},

imageLoadComplete: function() {
// fires when image in current popup finished loading
// avaiable since v0.9.0
Expand Down Expand Up @@ -1155,17 +1152,29 @@ See [example on CodePen](http://codepen.io/dimsemenov/pen/JGjHK).

### How to override some function without modifying the source files?

Rewrite the function that you wish to modify by editing Magnific Popup class prototype, you can access it like so `$.magnificPopup.proto`. For example to override function that sets focus on some element:
Rewrite the function that you wish to modify by editing Magnific Popup object, you can access it like so `$.magnificPopup.instance`. For example to override function that goes to "next" item in gallery:

{% highlight javascript %}
// add this code after popup JS file is included, but before popup is initialized
$.magnificPopup.proto._setFocus = function() {
(mfp.st.focus ? mfp.content.find(mfp.st.focus).eq(0) : mfp.wrap).focus();
// add this code after popup JS file is included
$.magnificPopup.instance.next = function() {

// Do something

// You may call parent ("original") method like so:
$.magnificPopup.proto.next.call(this /*, optional arguments */);
};
{% endhighlight %}

You may override any public function, just note that this change applies globally.

### Known issues

### Text input in [Select2](http://ivaynberg.github.io/select2/) plugin is inactive when added inside popup

Refer to [this discussion on GitHub](https://github.com/dimsemenov/Magnific-Popup/issues/280).

<h2 id="contribute">Make Magnific Popup better!</h2>

Improve this documentation page <a href="https://github.com/dimsemenov/Magnific-Popup/edit/master/website/documentation.md">via GitHub</a> (simply submit commit). Any improvements, including your own CodePen examples are very welcome.
Improve this documentation page <a href="https://github.com/dimsemenov/Magnific-Popup/edit/master/website/documentation.md">via GitHub</a> (simply submit commit). Any improvements, including your own CodePen examples are very welcome. And, lastly, don't forget to star the script on GitHub:

<iframe src="http://ghbtns.com/github-btn.html?user=dimsemenov&amp;repo=magnific-popup&amp;type=watch&amp;count=true&amp;size=large" allowtransparency="true" frameborder="0" scrolling="0" width="170" height="30"></iframe>
5 changes: 3 additions & 2 deletions website/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h1 id="logo-title">Magnific Popup</h1>
<div>
<h2 class="intro">Magnific Popup is a responsive jQuery lightbox plugin that is focused on performance and providing best experience for user with any device (Zepto.js compatible).</h2>
<div id="header-links">
<a href="documentation.html">Documentation</a> &middot; <a href="https://github.com/dimsemenov/Magnific-Popup">GitHub</a> &middot; <a href="wordpress.html" class="wp-version-link" data-mfp-src="#mc_embed_signup">WordPress plugin</a> &middot; <a href="#mfp-build-tool" class="mfp-build-tool-link">Build tool</a>
<a href="documentation.html">Documentation</a> &middot; <a href="https://github.com/dimsemenov/Magnific-Popup">GitHub</a> &middot; <a href="wordpress.html" class="wp-version-link" data-mfp-src="#mc_embed_signup">WordPress plugin</a> &middot; <a href="#mfp-build-tool" class="mfp-build-tool-link">Build tool</a> &middot; <a class="smashing-link" href="http://coding.smashingmagazine.com/2013/05/02/truly-responsive-lightbox/">How it was made</a>
</div>
</div>

Expand Down Expand Up @@ -81,8 +81,9 @@ <h2>Updates</h2>
<h2>Please spread the word if you find the plugin useful</h2>
<div id="buttons-row">
<a id="tweet" rel="nofollow" href="https://twitter.com/intent/tweet?text=Magnific%20Popup%20-%20responsive%20lightbox%20plugin&amp;url=http%3A%2F%2Fbit.ly%2Fmagnificpopup&amp;via=dimsemenov">Tweet!</a>
<a id="like" rel="nofollow" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fdimsemenov.com%2Fplugins%2Fmagnific-popup%2F%3Futm_source%3Dfb%26utm_medium%3Dsocial%26utm_campaign%3Dmfp">Like? Like!</a>
<a id="like" rel="nofollow" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fdimsemenov.com%2Fplugins%2Fmagnific-popup%2F%3Futm_source%3Dfb%26utm_medium%3Dsocial%26utm_campaign%3Dmfp">Like!</a>
<a id="gplus" rel="nofollow" href="https://plus.google.com/share?url=http%3A%2F%2Fdimsemenov.com%2Fplugins%2Fmagnific-popup%2F%3Futm_source%3Dgplus%26utm_medium%3Dsocial%26utm_campaign%3Dmfp">+1</a>
<iframe src="http://ghbtns.com/github-btn.html?user=dimsemenov&amp;repo=magnific-popup&amp;type=watch&amp;count=true&amp;size=large" allowtransparency="true" frameborder="0" scrolling="0" width="155" height="30" style="transform: translateY(8px);-moz-transform: translateY(8px);-webkit-transform: translateY(8px); margin-left: 9px;"></iframe>
</div>
</div>
<script>
Expand Down

0 comments on commit b485bc8

Please sign in to comment.