Created
July 9, 2013 12:07
-
-
Save alnutile/5956853 to your computer and use it in GitHub Desktop.
Example of plugin to swap out an image to point left or right as the user clicks the "link"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Example of file using it | |
$(document).ready(function () { | |
$('h2').on('click', function(){ | |
var location = window.location.origin; | |
var url = "/sites/all/themes/chroma-blue/images"; | |
var down = "down.jpg"; | |
var right = "right.jpg"; | |
//Look in plugins.js | |
$(this).arrow({ | |
location: location, | |
url: url, | |
down: down, | |
right: right | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$.fn.arrow = function(options){ | |
var settings = $.extend({ | |
location: window.location.origin, | |
url: '/sites/all/themes/chroma-blue/images', | |
down: 'down.jpg', | |
right: 'right.jpg' | |
}); | |
if( $(this).css('background-image') === 'url('+settings.location+settings.url+'/'+settings.down+')' ) { | |
$(this).css('background-image', 'url("'+settings.url+'/'+settings.right+'")'); | |
} else { | |
$(this).css('background-image', 'url("'+settings.url+'/'+settings.down+'")'); | |
} | |
return this; | |
}; | |
}(jQuery)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment