Skip to content
This repository
Browse code

Added option jsonDataParser allowing jsonData parser function to be o…

…verridden on per-instance level.

Signed-off-by: Warren Krewenki <krewenki@gmail.com>
  • Loading branch information...
commit 811e83656ef53cb443c5491cfc40527813aa4955 1 parent 63ac577
authored March 17, 2009 krewenki committed March 25, 2009

Showing 1 changed file with 7 additions and 7 deletions. Show diff stats Hide diff stats

  1. 14  jquery.lightbox.js
14  jquery.lightbox.js
@@ -18,10 +18,9 @@
18 18
 		// build main options
19 19
 		var opts = $.extend({}, $.fn.lightbox.defaults, options);
20 20
         
21  
-		// initalize the lightbox
22  
-		
23 21
 		return this.each(function(){
24 22
 			$(this).click(function(){
  23
+    		    // initalize the lightbox
25 24
     		    initialize();
26 25
 				start(this);
27 26
 				return false;
@@ -42,8 +41,9 @@
42 41
 		    
43 42
 		    // if jsonData, build the imageArray from data provided in JSON format
44 43
             if(opts.jsonData && opts.jsonData.length > 0) {
  44
+                var parser = opts.jsonDataParser ? opts.jsonDataParser : $.fn.lightbox.parseJsonData;                
45 45
                 opts.imageArray = [];
46  
-                opts.imageArray = $.fn.lightbox.parseJsonData(opts.jsonData);
  46
+                opts.imageArray = parser(opts.jsonData);
47 47
 	        }
48 48
 		    
49 49
 		    var outerImage = '<div id="outerImageContainer"><div id="imageContainer"><iframe id="lightboxIframe" /><img id="lightboxImage"><div id="hoverNav"><a href="javascript://" title="' + opts.strings.prevLinkTitle + '" id="prevLink"></a><a href="javascript://" id="nextLink" title="' + opts.strings.nextLinkTitle + '"></a></div><div id="loading"><a href="javascript://" id="loadingLink"><img src="'+opts.fileLoadingImage+'"></a></div></div></div>';
@@ -105,7 +105,7 @@
105 105
 		    var date = new Date();
106 106
 		    var curDate = null;
107 107
 		    do{curDate = new Date();}
108  
-		    while( curDate - date < ms);
  108
+		    while(curDate - date < ms);
109 109
 	    };
110 110
 	    
111 111
 	    function start(imageLink) {
@@ -114,8 +114,7 @@
114 114
 		    $("#overlay").hide().css({width: '100%', height: arrayPageSize[1]+'px', opacity : opts.overlayOpacity}).fadeIn();
115 115
 		    imageNum = 0;
116 116
 
117  
-
118  
-		    // if data is provided by jsonData parameter
  117
+		    // if data is not provided by jsonData parameter
119 118
             if(!opts.jsonData) {
120 119
                 opts.imageArray = [];
121 120
 		        // if image is NOT part of a set..
@@ -440,7 +439,8 @@
440 439
         disableNavbarLinks: false,
441 440
         loopImages: false,
442 441
         imageClickClose: true,
443  
-        jsonData: null
  442
+        jsonData: null,
  443
+        jsonDataParser: null
444 444
 	};
445 445
 	
446 446
 })(jQuery);

0 notes on commit 811e836

Please sign in to comment.
Something went wrong with that request. Please try again.