[Pkg-javascript-commits] [jquery-minicolors] 01/28: Updated to support Bootstrap 3

David Prévot taffit at alioth.debian.org
Sun Sep 8 14:57:18 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 479616d0da7f4058eabc355ea122576cf53bc04b
Author: Cory LaViska <cory at abeautifulsite.net>
Date:   Thu Aug 8 12:51:40 2013 -0400

    Updated to support Bootstrap 3
    
    - removed swatchPosition in lieu of position
    - removed textField option
    - changed $.minicolors.defaultSettings to $.minicolors.defaultss
    - new markup for swatch
---
 jquery.minicolors.js |   68 +++++++++++++++++++++-----------------------------
 1 file changed, 29 insertions(+), 39 deletions(-)

diff --git a/jquery.minicolors.js b/jquery.minicolors.js
index 69aac18..3d4864d 100644
--- a/jquery.minicolors.js
+++ b/jquery.minicolors.js
@@ -8,11 +8,10 @@
 */
 if(jQuery) (function($) {
 	
-	// Yay, MiniColors!
+	// Defaults
 	$.minicolors = {
-		// Default settings
-		defaultSettings: {
-			animationSpeed: 100,
+		defaults: {
+			animationSpeed: 50,
 			animationEasing: 'swing',
 			change: null,
 			changeDelay: 0,
@@ -23,11 +22,9 @@ if(jQuery) (function($) {
 			inline: false,
 			letterCase: 'lowercase',
 			opacity: false,
-			position: 'default',
+			position: 'bottom left',
 			show: null,
 			showSpeed: 100,
-			swatchPosition: 'left',
-			textfield: true,
 			theme: 'default'
 		}
 	};
@@ -121,20 +118,18 @@ if(jQuery) (function($) {
 	// Initialize input elements
 	function init(input, settings) {
 		
-		var minicolors = $('<span class="minicolors" />'),
-			defaultSettings = $.minicolors.defaultSettings;
+		var minicolors = $('<div class="minicolors" />'),
+			defaults = $.minicolors.defaults;
 		
 		// Do nothing if already initialized
 		if( input.data('minicolors-initialized') ) return;
 		
 		// Handle settings
-		settings = $.extend(true, {}, defaultSettings, settings);
+		settings = $.extend(true, {}, defaults, settings);
 		
 		// The wrapper
 		minicolors
 			.addClass('minicolors-theme-' + settings.theme)
-			.addClass('minicolors-swatch-position-' + settings.swatchPosition)
-			.toggleClass('minicolors-swatch-left', settings.swatchPosition === 'left')
 			.toggleClass('minicolors-with-opacity', settings.opacity);
 		
 		// Custom positioning
@@ -150,37 +145,33 @@ if(jQuery) (function($) {
 			.data('minicolors-initialized', true)
 			.data('minicolors-settings', settings)
 			.prop('size', 7)
-			.prop('maxlength', 7)
 			.wrap(minicolors)
 			.after(
-				'<span class="minicolors-panel minicolors-slider-' + settings.control + '">' + 
-					'<span class="minicolors-slider">' + 
-						'<span class="minicolors-picker"></span>' +
-					'</span>' + 
-					'<span class="minicolors-opacity-slider">' + 
-						'<span class="minicolors-picker"></span>' +
-					'</span>' +
-					'<span class="minicolors-grid">' +
-						'<span class="minicolors-grid-inner"></span>' +
-						'<span class="minicolors-picker"><span></span></span>' +
-					'</span>' +
-				'</span>'
+				'<div class="minicolors-panel minicolors-slider-' + settings.control + '">' + 
+					'<div class="minicolors-slider">' + 
+						'<div class="minicolors-picker"></div>' +
+					'</div>' + 
+					'<div class="minicolors-opacity-slider">' + 
+						'<div class="minicolors-picker"></div>' +
+					'</div>' +
+					'<div class="minicolors-grid">' +
+						'<div class="minicolors-grid-inner"></div>' +
+						'<div class="minicolors-picker"><div></div></div>' +
+					'</div>' +
+				'</div>'
 			);
 		
-		// Prevent text selection in IE
-		input.parent().find('.minicolors-panel').on('selectstart', function() { return false; }).end();
-		
-		// Detect swatch position
-		if( settings.swatchPosition === 'left' ) {
-			// Left
-			input.before('<span class="minicolors-swatch"><span></span></span>');
-		} else {
-			// Right
-			input.after('<span class="minicolors-swatch"><span></span></span>');
+		// The swatch
+		if( !settings.inline ) {
+			input.after('<a href="#" class="minicolors-swatch"><span class="minicolors-swatch-color"></span></a>');
+			input.next('.minicolors-swatch').on('click', function(event) {
+				event.preventDefault();
+				input.focus();
+			});
 		}
 		
-		// Disable textfield
-		if( !settings.textfield ) input.addClass('minicolors-hidden');
+		// Prevent text selection in IE
+		input.parent().find('.minicolors-panel').on('selectstart', function() { return false; }).end();
 		
 		// Inline controls
 		if( settings.inline ) input.parent().addClass('minicolors-inline');
@@ -199,7 +190,6 @@ if(jQuery) (function($) {
 			.removeData('minicolors-initialized')
 			.removeData('minicolors-settings')
 			.removeProp('size')
-			.prop('maxlength', null)
 			.removeClass('minicolors-input');
 		
 		// Remove the wrap and destroy whatever remains
@@ -858,4 +848,4 @@ if(jQuery) (function($) {
 			}, 1);
 		});
 	
-})(jQuery);
+})(jQuery);
\ No newline at end of file

-- 
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