-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
454708f
commit a899e80
Showing
6 changed files
with
248 additions
and
123 deletions.
There are no files selected for viewing
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Name: k-description - Plugin jQuery. | ||
* home: https://github.com/filipelinhares/k-description | ||
* version: 1.0.1 | ||
* author: Filipe Linhares | ||
*/ | ||
|
||
(function($) { | ||
$.fn.description = function(options) { | ||
|
||
//Define defaults values | ||
var defaults = { | ||
kheight: '100px' | ||
, kwidth: '100%' | ||
, kmarginTop: "100px" | ||
, kduration: 1000 | ||
, kin: 'down' | ||
, kout: 'down' | ||
, kopacity: 1 | ||
, kease: '' | ||
, kcontent: "k-description jQuery" | ||
}, | ||
|
||
//Extend defaults and user options | ||
settings = $.extend( | ||
{} | ||
, defaults | ||
, options | ||
); | ||
|
||
//Return | ||
return this.each(function() { | ||
|
||
//Create class kp to paragraph, kcontent to span and style. | ||
$(this) | ||
.css('overflow', 'hidden') | ||
.append('<p class="kp"><span class="kcontent"></span></p>'); | ||
$("p.kp span.kcontent") | ||
.css('display', 'block') | ||
.text(settings.kcontent); | ||
|
||
//Manipule down and up value to kin | ||
if (settings.kin == 'down') | ||
settings.kin = '+'; | ||
else if (settings.kin == 'up') | ||
settings.kin = '-'; | ||
|
||
//Style kp with user options | ||
$("p.kp").css({ | ||
display: "block" | ||
, width: settings.kwidth | ||
, height: settings.kheight | ||
, opacity: settings.kopacity | ||
, marginTop: settings.kin + settings.kheight | ||
}); | ||
|
||
//Add event mouseover to element, and show description. | ||
$(this).on({ | ||
mouseover: function() { | ||
$(this) | ||
.find("p.kp") | ||
.stop() | ||
.animate({ | ||
width: settings.kwidth | ||
, height: settings.kheight, | ||
marginTop: settings.kmarginTop | ||
}, settings.kduration, settings.kease); | ||
}, | ||
|
||
//Add evente mouseleave to element, and hide description | ||
mouseleave: function() { | ||
|
||
//Manipulate down and up value to kout. | ||
if (settings.kout == 'down') | ||
settings.kout = '+'; | ||
else if (settings.kout == 'up') | ||
settings.kout = '-'; | ||
|
||
//Clear animation from description. | ||
$(this) | ||
.find("p.kp") | ||
.stop() | ||
.animate({ | ||
marginTop: settings.kout + settings.kheight | ||
}, settings.kduration, settings.kease); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
})(jQuery); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.