forked from springload/HoverState.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.hoverState.min.js
More file actions
executable file
·20 lines (20 loc) · 1.41 KB
/
jquery.hoverState.min.js
File metadata and controls
executable file
·20 lines (20 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
* hoverState, A handy jQuery plugin that preloads your images hover state, then displays it "onHover"
* Instructions: http://www.springload.co.nz/love-the-web/hoverstatejs-another-jquery-plugin
* By: James Player, http://springload.co.nz
* Version: 1.1
* Updated: November 25, 2011
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
;(function(f,d,b,h){var e="hoverState",g={hoverExt:"-on"};var a=[];function c(j,i){this.element=f(j);this.options=f.extend({},g,i);this._defaults=g;this._name=e;this.init()}c.prototype.init=function(){var l=this.element.attr("src");if(l){var k=l.match(/^(.+)(\.[^.]+)$/i);if(k.length==3){var j=b.createElement("img");var i=k[1]+this.options.hoverExt+k[2];j.src=i;a.push(j);this.element.hover(function(){f(this).attr("src",i)},function(){f(this).attr("src",l)})}}};f.fn[e]=function(i){return this.each(function(){if(!f.data(this,"plugin_"+e)){f.data(this,"plugin_"+e,new c(this,i))}})}})(jQuery,window,document);