UI, List creator: move hoverhighlight to its own module

This commit is contained in:
Carl Eberhard
2015-04-14 10:29:22 -04:00
parent b1d3a41a63
commit ef484e648c
9 changed files with 48 additions and 68 deletions
@@ -5,7 +5,8 @@ define([
"mvc/base-mvc",
"mvc/ui/ui-modal",
"utils/natural-sort",
"utils/localization"
"utils/localization",
"ui/hoverhighlight"
], function( HDCA, STATES, BASE_MVC, UI_MODAL, naturalSort, _l ){
/*==============================================================================
@@ -844,37 +845,6 @@ ListCollectionCreator.templates = ListCollectionCreator.templates || {
};
//=============================================================================
(function(){
/** plugin that will highlight an element when this element is hovered over */
jQuery.fn.extend({
hoverhighlight : function $hoverhighlight( scope, color ){
scope = scope || 'body';
if( !this.size() ){ return this; }
$( this ).each( function(){
var $this = $( this ),
targetSelector = $this.data( 'target' );
if( targetSelector ){
$this.mouseover( function( ev ){
$( targetSelector, scope ).css({
background: color
});
})
.mouseout( function( ev ){
$( targetSelector ).css({
background: ''
});
});
}
});
return this;
}
});
}());
//=============================================================================
var collectionCreatorModal = function _collectionCreatorModal( elements, options, CreatorClass ){
@@ -3,7 +3,8 @@ define([
"utils/natural-sort",
"mvc/collection/list-collection-creator",
"mvc/base-mvc",
"utils/localization"
"utils/localization",
"ui/hoverhighlight"
], function( levenshteinDistance, naturalSort, LIST_COLLECTION_CREATOR, baseMVC, _l ){
/* ============================================================================
TODO:
@@ -1656,37 +1657,6 @@ PairedCollectionCreator.templates = PairedCollectionCreator.templates || {
};
//=============================================================================
(function(){
/** plugin that will highlight an element when this element is hovered over */
jQuery.fn.extend({
hoverhighlight : function $hoverhighlight( scope, color ){
scope = scope || 'body';
if( !this.size() ){ return this; }
$( this ).each( function(){
var $this = $( this ),
targetSelector = $this.data( 'target' );
if( targetSelector ){
$this.mouseover( function( ev ){
$( targetSelector, scope ).css({
background: color
});
})
.mouseout( function( ev ){
$( targetSelector ).css({
background: ''
});
});
}
});
return this;
}
});
}());
//=============================================================================
/** a modal version of the paired collection creator */
var pairedCollectionCreatorModal = function _pairedCollectionCreatorModal( datasets, options ){
@@ -0,0 +1,37 @@
(function (factory) {
if (typeof define === 'function' && define.amd) {
define([], factory);
} else {
// Browser globals
factory(jQuery);
}
}(function () {
//=============================================================================
jQuery.fn.extend({
hoverhighlight : function $hoverhighlight( scope, color ){
scope = scope || 'body';
if( !this.size() ){ return this; }
$( this ).each( function(){
var $this = $( this ),
targetSelector = $this.data( 'target' );
if( targetSelector ){
$this.mouseover( function( ev ){
$( targetSelector, scope ).css({
background: color
});
})
.mouseout( function( ev ){
$( targetSelector ).css({
background: ''
});
});
}
});
return this;
}
});
}));
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"hoverhighlight.js","sources":["../../src/ui/hoverhighlight.js"],"names":["factory","define","amd","jQuery","fn","extend","hoverhighlight","scope","color","this","size","$","each","$this","targetSelector","data","mouseover","css","background","mouseout"],"mappings":"CAAC,SAAUA,GACe,kBAAXC,SAAyBA,OAAOC,IACvCD,UAAWD,GAGXA,EAAQG,SAGd,WAGEA,OAAOC,GAAGC,QACNC,eAAiB,SAA0BC,EAAOC,GAE9C,MADAD,GAAQA,GAAS,OACZE,KAAKC,QAEVC,EAAGF,MAAOG,KAAM,WACZ,GAAIC,GAAQF,EAAGF,MACXK,EAAiBD,EAAME,KAAM,SAE7BD,IACAD,EAAMG,UAAW,WACbL,EAAGG,EAAgBP,GAAQU,KACvBC,WAAYV,MAGnBW,SAAU,WACPR,EAAGG,GAAiBG,KAChBC,WAAY,SAKrBT,MAnBoBA"}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+2
View File
@@ -0,0 +1,2 @@
!function(a){"function"==typeof define&&define.amd?define([],a):a(jQuery)}(function(){jQuery.fn.extend({hoverhighlight:function(a,b){return a=a||"body",this.size()?($(this).each(function(){var c=$(this),d=c.data("target");d&&c.mouseover(function(){$(d,a).css({background:b})}).mouseout(function(){$(d).css({background:""})})}),this):this}})});
//# sourceMappingURL=../../maps/ui/hoverhighlight.js.map