[Pkg-javascript-commits] [jquery-minicolors] 15/28: Fixed bug where change event would be fired initially even when no changes were made; clicking on swatch always shows panel

David Prévot taffit at alioth.debian.org
Sun Sep 8 14:57:29 UTC 2013


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository jquery-minicolors.

commit a77485f15403ddb99a9ddb86b7dfdbf727c84371
Author: Cory LaViska <cory at abeautifulsite.net>
Date:   Tue Aug 20 11:54:23 2013 -0400

    Fixed bug where change event would be fired initially even when no changes were made; clicking on swatch always shows panel
---
 jquery.minicolors.js |   27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/jquery.minicolors.js b/jquery.minicolors.js
index bb5d431..fe0913b 100644
--- a/jquery.minicolors.js
+++ b/jquery.minicolors.js
@@ -178,6 +178,12 @@ if(jQuery) (function($) {
 		
 		updateFromInput(input, false, true);
 		
+		// Populate lastChange to prevent change event from firing initially
+		input.data('minicolors-lastChange', {
+			hex: input.val(),
+			opacity: input.attr('data-opacity')
+		})
+		
 	}
 	
 	// Returns the input back to its original state
@@ -598,13 +604,17 @@ if(jQuery) (function($) {
 	// Runs the change and changeDelay callbacks
 	function doChange(input, hex, opacity) {
 		
-		var settings = input.data('minicolors-settings');
+		var settings = input.data('minicolors-settings'),
+			lastChange = input.data('minicolors-lastChange');
 		
 		// Only run if it actually changed
-		if( hex + opacity !== input.data('minicolors-lastChange') ) {
+		if( lastChange.hex !== hex || lastChange.opacity !== opacity ) {
 			
 			// Remember last-changed value
-			input.data('minicolors-lastChange', hex + opacity);
+			input.data('minicolors-lastChange', {
+				hex: hex,
+				opacity: opacity
+			});
 			
 			// Fire change event
 			if( settings.change ) {
@@ -785,16 +795,11 @@ if(jQuery) (function($) {
 		.on('mouseup.minicolors touchend.minicolors', function() {
 			$(this).removeData('minicolors-target');
 		})
-		// Toggle panel when swatch is clicked
+		// Show panel when swatch is clicked
 		.on('mousedown.minicolors touchstart.minicolors', '.minicolors-swatch', function(event) {
+			var input = $(this).parent().find('.minicolors-input');
 			event.preventDefault();
-			var input = $(this).parent().find('.minicolors-input'),
-				minicolors = input.parent();
-			if( minicolors.hasClass('minicolors-focus') ) {
-				hide(input);
-			} else {
-				show(input);
-			}
+			show(input);
 		})
 		// Show on focus
 		.on('focus.minicolors', '.minicolors-input', function(event) {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/jquery-minicolors.git



More information about the Pkg-javascript-commits mailing list