magnific-popup-rails 0.8.3 → 0.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5483a4804ef5103dce66e64b1b6769b76e2afdeb
|
4
|
+
data.tar.gz: 9d7fe3fe758cefa4d4da62a6b221f786a4ec1ecd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 502d9ad0db09e8cc5c0bdf38eb94723adb1d62860ed9aaddb3bfcc8e149d383bdac51efc6b7121f535deedbe290af0a0d4265accab57431b271bd42ff2550ee4
|
7
|
+
data.tar.gz: 69283604406c21571262468117a734fdde23f5b150a83c13e98db34187e71b147587401594bd77d529fa589272cb10eebf703614f1dd10827a33508d185dd285
|
@@ -1,4 +1,4 @@
|
|
1
|
-
/*! Magnific Popup - v0.8.
|
1
|
+
/*! Magnific Popup - v0.8.4 - 2013-05-13
|
2
2
|
* http://dimsemenov.com/plugins/magnific-popup/
|
3
3
|
* Copyright (c) 2013 Dmitry Semenov; */
|
4
4
|
;(function($) {
|
@@ -31,6 +31,7 @@ var CLOSE_EVENT = 'Close',
|
|
31
31
|
*/
|
32
32
|
var mfp, // As we have only one instance of MagnificPopup object, we define it locally to not to use 'this'
|
33
33
|
MagnificPopup = function(){},
|
34
|
+
_isJQ = !!(window.jQuery),
|
34
35
|
_prevStatus,
|
35
36
|
_window = $(window),
|
36
37
|
_body,
|
@@ -82,6 +83,14 @@ var _mfpOn = function(name, f) {
|
|
82
83
|
_currPopupType = type;
|
83
84
|
}
|
84
85
|
return mfp.currTemplate.closeBtn;
|
86
|
+
},
|
87
|
+
// Initialize Magnific Popup only when called at least once
|
88
|
+
_checkInstance = function() {
|
89
|
+
if(!$.magnificPopup.instance) {
|
90
|
+
mfp = new MagnificPopup();
|
91
|
+
mfp.init();
|
92
|
+
$.magnificPopup.instance = mfp;
|
93
|
+
}
|
85
94
|
};
|
86
95
|
|
87
96
|
|
@@ -118,7 +127,12 @@ MagnificPopup.prototype = {
|
|
118
127
|
*/
|
119
128
|
open: function(data) {
|
120
129
|
|
121
|
-
|
130
|
+
mfp.items = data.items.length ? data.items : [data.items];
|
131
|
+
|
132
|
+
if(mfp.isOpen) {
|
133
|
+
mfp.updateItemHTML();
|
134
|
+
return;
|
135
|
+
}
|
122
136
|
|
123
137
|
var i;
|
124
138
|
|
@@ -160,7 +174,7 @@ MagnificPopup.prototype = {
|
|
160
174
|
mfp.st = $.extend(true, {}, $.magnificPopup.defaults, data );
|
161
175
|
mfp.fixedContentPos = mfp.st.fixedContentPos === 'auto' ? !mfp.probablyMobile : mfp.st.fixedContentPos;
|
162
176
|
|
163
|
-
|
177
|
+
|
164
178
|
|
165
179
|
// Building markup
|
166
180
|
// main containers are created only once
|
@@ -427,7 +441,6 @@ MagnificPopup.prototype = {
|
|
427
441
|
|
428
442
|
},
|
429
443
|
|
430
|
-
|
431
444
|
/**
|
432
445
|
* Set content of popup based on current index
|
433
446
|
*/
|
@@ -435,8 +448,6 @@ MagnificPopup.prototype = {
|
|
435
448
|
var item = mfp.items[mfp.index];
|
436
449
|
|
437
450
|
// Detach and perform modifications
|
438
|
-
|
439
|
-
|
440
451
|
mfp.contentContainer.detach();
|
441
452
|
|
442
453
|
if(mfp.content)
|
@@ -540,7 +551,7 @@ MagnificPopup.prototype = {
|
|
540
551
|
}
|
541
552
|
}
|
542
553
|
|
543
|
-
item.type = type || mfp.st.type;
|
554
|
+
item.type = type || mfp.st.type || 'inline';
|
544
555
|
item.index = index;
|
545
556
|
item.parsed = true;
|
546
557
|
mfp.items[index] = item;
|
@@ -555,32 +566,8 @@ MagnificPopup.prototype = {
|
|
555
566
|
*/
|
556
567
|
addGroup: function(el, options) {
|
557
568
|
var eHandler = function(e) {
|
558
|
-
|
559
|
-
|
560
|
-
if( midClick || e.which !== 2 ) {
|
561
|
-
var disableOn = options.disableOn !== undefined ? options.disableOn : $.magnificPopup.defaults.disableOn;
|
562
|
-
|
563
|
-
if(disableOn) {
|
564
|
-
if($.isFunction(disableOn)) {
|
565
|
-
if( !disableOn.call(mfp) ) {
|
566
|
-
return true;
|
567
|
-
}
|
568
|
-
} else { // else it's number
|
569
|
-
if( $(window).width() < disableOn ) {
|
570
|
-
return true;
|
571
|
-
}
|
572
|
-
}
|
573
|
-
}
|
574
|
-
|
575
|
-
e.preventDefault();
|
576
|
-
options.el = $(this);
|
577
|
-
options.mainEl = el;
|
578
|
-
if(options.delegate) {
|
579
|
-
options.items = el.find(options.delegate);
|
580
|
-
}
|
581
|
-
mfp.open(options);
|
582
|
-
}
|
583
|
-
|
569
|
+
e.mfpEl = this;
|
570
|
+
mfp._openClick(e, el, options);
|
584
571
|
};
|
585
572
|
|
586
573
|
if(!options) {
|
@@ -588,6 +575,8 @@ MagnificPopup.prototype = {
|
|
588
575
|
}
|
589
576
|
|
590
577
|
var eName = 'click.magnificPopup';
|
578
|
+
options.mainEl = el;
|
579
|
+
|
591
580
|
if(options.items) {
|
592
581
|
options.isObj = true;
|
593
582
|
el.off(eName).on(eName, eHandler);
|
@@ -601,6 +590,33 @@ MagnificPopup.prototype = {
|
|
601
590
|
}
|
602
591
|
}
|
603
592
|
},
|
593
|
+
_openClick: function(e, el, options) {
|
594
|
+
var midClick = options.midClick !== undefined ? options.midClick : $.magnificPopup.defaults.midClick;
|
595
|
+
if( midClick || e.which !== 2 ) {
|
596
|
+
var disableOn = options.disableOn !== undefined ? options.disableOn : $.magnificPopup.defaults.disableOn;
|
597
|
+
|
598
|
+
if(disableOn) {
|
599
|
+
if($.isFunction(disableOn)) {
|
600
|
+
if( !disableOn.call(mfp) ) {
|
601
|
+
return true;
|
602
|
+
}
|
603
|
+
} else { // else it's number
|
604
|
+
if( _window.width() < disableOn ) {
|
605
|
+
return true;
|
606
|
+
}
|
607
|
+
}
|
608
|
+
}
|
609
|
+
|
610
|
+
if(e.type)
|
611
|
+
e.preventDefault();
|
612
|
+
|
613
|
+
options.el = $(e.mfpEl);
|
614
|
+
if(options.delegate) {
|
615
|
+
options.items = el.find(options.delegate);
|
616
|
+
}
|
617
|
+
mfp.open(options);
|
618
|
+
}
|
619
|
+
},
|
604
620
|
|
605
621
|
|
606
622
|
/**
|
@@ -639,13 +655,6 @@ MagnificPopup.prototype = {
|
|
639
655
|
},
|
640
656
|
|
641
657
|
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
658
|
/*
|
650
659
|
"Private" helpers that aren't private at all
|
651
660
|
*/
|
@@ -729,18 +738,13 @@ $.magnificPopup = {
|
|
729
738
|
modules: [],
|
730
739
|
|
731
740
|
open: function(options, index) {
|
732
|
-
|
733
|
-
mfp = new MagnificPopup();
|
734
|
-
mfp.init();
|
735
|
-
$.magnificPopup.instance = mfp;
|
736
|
-
}
|
741
|
+
_checkInstance();
|
737
742
|
|
738
|
-
if(!options)
|
743
|
+
if(!options)
|
739
744
|
options = {};
|
740
|
-
|
741
|
-
|
745
|
+
|
742
746
|
options.isObj = true;
|
743
|
-
options.index = index
|
747
|
+
options.index = index || 0;
|
744
748
|
return this.instance.open(options);
|
745
749
|
},
|
746
750
|
|
@@ -758,7 +762,7 @@ $.magnificPopup = {
|
|
758
762
|
|
759
763
|
defaults: {
|
760
764
|
|
761
|
-
// Info about options is docs:
|
765
|
+
// Info about options is in docs:
|
762
766
|
// http://dimsemenov.com/plugins/magnific-popup/documentation.html#options
|
763
767
|
|
764
768
|
disableOn: 0,
|
@@ -799,15 +803,50 @@ $.magnificPopup = {
|
|
799
803
|
|
800
804
|
|
801
805
|
$.fn.magnificPopup = function(options) {
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
806
|
+
_checkInstance();
|
807
|
+
|
808
|
+
var jqEl = $(this);
|
809
|
+
|
810
|
+
// We call some API method of first param is a string
|
811
|
+
if (typeof options === "string" ) {
|
812
|
+
|
813
|
+
if(options === 'open') {
|
814
|
+
var items,
|
815
|
+
itemOpts = _isJQ ? jqEl.data('magnificPopup') : jqEl[0].magnificPopup,
|
816
|
+
index = parseInt(arguments[1], 10) || 0;
|
817
|
+
|
818
|
+
if(itemOpts.items) {
|
819
|
+
items = itemOpts.items[index];
|
820
|
+
} else {
|
821
|
+
items = jqEl;
|
822
|
+
if(itemOpts.delegate) {
|
823
|
+
items = items.find(itemOpts.delegate);
|
824
|
+
}
|
825
|
+
items = items.eq( index );
|
826
|
+
}
|
827
|
+
mfp._openClick({mfpEl:items}, jqEl, itemOpts);
|
828
|
+
} else {
|
829
|
+
if(mfp.isOpen)
|
830
|
+
mfp[options].apply(mfp, Array.prototype.slice.call(arguments, 1));
|
831
|
+
}
|
832
|
+
|
833
|
+
} else {
|
834
|
+
|
835
|
+
/*
|
836
|
+
* As Zepto doesn't support .data() method for objects
|
837
|
+
* and it works only in normal browsers
|
838
|
+
* we assign "options" object directly to the DOM element. FTW!
|
839
|
+
*/
|
840
|
+
if(_isJQ) {
|
841
|
+
jqEl.data('magnificPopup', options);
|
842
|
+
} else {
|
843
|
+
jqEl[0].magnificPopup = options;
|
844
|
+
}
|
845
|
+
|
846
|
+
mfp.addGroup(jqEl, options);
|
808
847
|
|
809
|
-
|
810
|
-
return
|
848
|
+
}
|
849
|
+
return jqEl;
|
811
850
|
};
|
812
851
|
|
813
852
|
|
@@ -834,11 +873,19 @@ console.log('Test #2:', performance.now() - start);
|
|
834
873
|
/*>>inline*/
|
835
874
|
|
836
875
|
var INLINE_NS = 'inline',
|
837
|
-
|
876
|
+
_hiddenClass,
|
877
|
+
_inlinePlaceholder,
|
878
|
+
_lastInlineElement,
|
879
|
+
_putInlineElementsBack = function() {
|
880
|
+
if(_lastInlineElement) {
|
881
|
+
_inlinePlaceholder.after( _lastInlineElement.addClass(_hiddenClass) ).detach();
|
882
|
+
_lastInlineElement = null;
|
883
|
+
}
|
884
|
+
};
|
838
885
|
|
839
886
|
$.magnificPopup.registerModule(INLINE_NS, {
|
840
887
|
options: {
|
841
|
-
hiddenClass:
|
888
|
+
hiddenClass: 'hide', // will be appended with `mfp-` prefix
|
842
889
|
markup: '',
|
843
890
|
tNotFound: 'Content not found'
|
844
891
|
},
|
@@ -846,60 +893,46 @@ $.magnificPopup.registerModule(INLINE_NS, {
|
|
846
893
|
|
847
894
|
initInline: function() {
|
848
895
|
mfp.types.push(INLINE_NS);
|
849
|
-
_hasPlaceholder = false;
|
850
896
|
|
851
897
|
_mfpOn(CLOSE_EVENT+'.'+INLINE_NS, function() {
|
852
|
-
|
853
|
-
if(item.type === INLINE_NS) {
|
854
|
-
if(_hasPlaceholder) {
|
855
|
-
for(var i = 0; i < mfp.items.length; i++) {
|
856
|
-
item = mfp.items[i];
|
857
|
-
if(item && item.inlinePlaceholder){
|
858
|
-
item.inlinePlaceholder.after( item.inlineElement.addClass(mfp.st.inline.hiddenClass) ).detach();
|
859
|
-
}
|
860
|
-
}
|
861
|
-
}
|
862
|
-
item.inlinePlaceholder = item.inlineElement = null;
|
863
|
-
}
|
898
|
+
_putInlineElementsBack();
|
864
899
|
});
|
865
900
|
},
|
866
901
|
|
867
902
|
getInline: function(item, template) {
|
868
|
-
|
903
|
+
|
904
|
+
_putInlineElementsBack();
|
869
905
|
|
870
906
|
if(item.src) {
|
871
|
-
var inlineSt = mfp.st.inline
|
872
|
-
|
873
|
-
if(typeof item.src !== 'string') {
|
874
|
-
item.isElement = true;
|
875
|
-
}
|
907
|
+
var inlineSt = mfp.st.inline,
|
908
|
+
el = $(item.src);
|
876
909
|
|
877
|
-
if(
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
910
|
+
if(el.length) {
|
911
|
+
|
912
|
+
// If target element has parent - we replace it with placeholder and put it back after popup is closed
|
913
|
+
if(el[0].parentNode !== null) {
|
914
|
+
if(!_inlinePlaceholder) {
|
915
|
+
_hiddenClass = inlineSt.hiddenClass;
|
916
|
+
_inlinePlaceholder = _getEl(_hiddenClass);
|
917
|
+
_hiddenClass = 'mfp-'+_hiddenClass;
|
918
|
+
}
|
919
|
+
// replace target inline element with placeholder
|
920
|
+
_lastInlineElement = el.after(_inlinePlaceholder).detach().removeClass(_hiddenClass);
|
888
921
|
}
|
889
|
-
}
|
890
922
|
|
891
|
-
|
892
|
-
|
923
|
+
mfp.updateStatus('ready');
|
924
|
+
} else {
|
925
|
+
mfp.updateStatus('error', inlineSt.tNotFound);
|
926
|
+
el = $('<div>');
|
893
927
|
}
|
894
928
|
|
895
|
-
|
896
|
-
|
897
|
-
item.inlineElement.after(item.inlinePlaceholder).detach().removeClass(inlineSt.hiddenClass);
|
898
|
-
return item.inlineElement;
|
899
|
-
} else {
|
900
|
-
mfp._parseMarkup(template, {}, item);
|
901
|
-
return template;
|
929
|
+
item.inlineElement = el;
|
930
|
+
return el;
|
902
931
|
}
|
932
|
+
|
933
|
+
mfp.updateStatus('ready');
|
934
|
+
mfp._parseMarkup(template, {}, item);
|
935
|
+
return template;
|
903
936
|
}
|
904
937
|
}
|
905
938
|
});
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magnific-popup-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Jansen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|