Marc DM avatar Marc DM committed 741c536

added a mini jquery plugin to accomodate for .data not always working for versions of jquery less than 1.7.2

Comments (0)

Files changed (1)

cmsplugin_nivoslider/templates/nivo/slider.html

 <script type="text/javascript">
 //<![CDATA[
 (function($){
-    $('img[id^=nivo-slide]').each(function(){
+    var jqver = $('img[id^=nivo-slide]').each(function(){
         var $img = $(this),
             idrx = /nivo-slide(\d+_\d+)-.+/ ,
             imgid = idrx.exec($img.attr('id'))[1],
             $txt = $('div[id=nivo-slide'+ imgid + '-text]');
         $img.attr('title', $txt.html().trim());
         $txt.remove();
-    });
+    }).jquery;
+    
+    $.fn.dattr = function(e){
+    	if ( jqver > '1.7.1') {
+    		return this.data(e);
+    	} else {
+    		return this.attr('data-'+e);
+    	}
+    };
     
     $('div.nivoSlider').each(function(e){
-		var d = $(this).data(),
+		var $d = $(this),
 		vd = { 
-	        effect: d.effect,
-	        animSpeed: d.speed - 0,
-	        pauseTime: d.pause_time - 0,
-	        directionNav: Boolean(d.arrows-0),
-	        controlNavThumbs: Boolean(d.thumbs-0),
-	        pauseOnHover: Boolean(d.pause_on_hover-0),
-	        manualAdvance: Boolean(d.manual-0),
-	        randomStart: Boolean(d.randomstart-0),
+	        effect: $d.dattr('effect'),
+	        animSpeed: $d.dattr('speed') - 0,
+	        pauseTime: $d.dattr('pause_time') - 0,
+	        directionNav: Boolean($d.dattr('arrows')-0),
+	        controlNavThumbs: Boolean($d.dattr('thumbs')-0),
+	        pauseOnHover: Boolean($d.dattr('pause_on_hover')-0),
+	        manualAdvance: Boolean($d.dattr('manual')-0),
+	        randomStart: Boolean($d.dattr('randomstart')-0),
 	        prevText: '{% trans 'prev'|capfirst %}',
 	        nextText: '{% trans 'next'|capfirst %}'
 		};
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.