jquery-simplecolorpicker-rails 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,8 @@
|
|
1
1
|
/**
|
2
2
|
* Very simple jQuery Color Picker.
|
3
|
+
* https://github.com/tkrotoff/jquery-simplecolorpicker
|
3
4
|
*
|
4
|
-
* Copyright (C) 2012 Tanguy Krotoff
|
5
|
+
* Copyright (C) 2012-2013 Tanguy Krotoff <tkrotoff@gmail.com>
|
5
6
|
*
|
6
7
|
* Licensed under the MIT license.
|
7
8
|
*/
|
@@ -41,7 +42,10 @@
|
|
41
42
|
|
42
43
|
if (self.options.picker) {
|
43
44
|
var selectText = self.$select.find('option:selected').text();
|
44
|
-
self.$icon = $('<span class="simplecolorpicker icon"
|
45
|
+
self.$icon = $('<span class="simplecolorpicker icon"'
|
46
|
+
+ ' title="' + selectText + '"'
|
47
|
+
+ ' style="background-color: ' + selectValue + '"'
|
48
|
+
+ ' role="button" tabindex="0">'
|
45
49
|
+ fakeText
|
46
50
|
+ '</span>').insertAfter(self.$select);
|
47
51
|
self.$icon.on('click.' + self.type, $.proxy(self.showPicker, self));
|
@@ -68,7 +72,11 @@
|
|
68
72
|
if (option.prop('selected') === true || selectValue === color) {
|
69
73
|
selected = 'class="selected"';
|
70
74
|
}
|
71
|
-
colors += '<div ' + selected
|
75
|
+
colors += '<div ' + selected
|
76
|
+
+ ' title="' + title + '"'
|
77
|
+
+ ' style="background-color: ' + color + '"'
|
78
|
+
+ ' data-color="' + color + '"'
|
79
|
+
+ ' role="button" tabindex="0">'
|
72
80
|
+ fakeText
|
73
81
|
+ '</div>';
|
74
82
|
});
|
@@ -86,8 +94,7 @@
|
|
86
94
|
var self = this;
|
87
95
|
|
88
96
|
var colorDiv = self.$colorList.find('div').filter(function() {
|
89
|
-
|
90
|
-
return self.rgb2hex(col) === color;
|
97
|
+
return $(this).data('color') === color;
|
91
98
|
});
|
92
99
|
|
93
100
|
if (colorDiv.length > 0) {
|
@@ -119,7 +126,7 @@
|
|
119
126
|
* It also changes the HTML select value, this will emit the 'change' event.
|
120
127
|
*/
|
121
128
|
selectColorDiv: function(colorDiv) {
|
122
|
-
var color = colorDiv.
|
129
|
+
var color = colorDiv.data('color');
|
123
130
|
var title = colorDiv.prop('title');
|
124
131
|
|
125
132
|
// Mark this div as the selected one
|
@@ -133,7 +140,7 @@
|
|
133
140
|
}
|
134
141
|
|
135
142
|
// Change HTML select value
|
136
|
-
this.$select.val(
|
143
|
+
this.$select.val(color);
|
137
144
|
},
|
138
145
|
|
139
146
|
/**
|
@@ -158,26 +165,6 @@
|
|
158
165
|
e.preventDefault();
|
159
166
|
},
|
160
167
|
|
161
|
-
/**
|
162
|
-
* Converts a RGB color to its hexadecimal value.
|
163
|
-
*
|
164
|
-
* See http://stackoverflow.com/questions/1740700/get-hex-value-rather-than-rgb-value-using-jquery
|
165
|
-
*/
|
166
|
-
rgb2hex: function(rgb) {
|
167
|
-
function hex(x) {
|
168
|
-
return ('0' + parseInt(x, 10).toString(16)).slice(-2);
|
169
|
-
}
|
170
|
-
|
171
|
-
var matches = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
172
|
-
if (matches === null) {
|
173
|
-
// Fix for Internet Explorer < 9
|
174
|
-
// Variable rgb is already a hexadecimal value
|
175
|
-
return rgb;
|
176
|
-
} else {
|
177
|
-
return '#' + hex(matches[1]) + hex(matches[2]) + hex(matches[3]);
|
178
|
-
}
|
179
|
-
},
|
180
|
-
|
181
168
|
destroy: function() {
|
182
169
|
if (this.options.picker) {
|
183
170
|
this.$icon.off('.' + this.type);
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jquery-simplecolorpicker-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &26790048 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,12 +21,7 @@ dependencies:
|
|
21
21
|
version: 3.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
none: false
|
26
|
-
requirements:
|
27
|
-
- - ! '>='
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
version: 3.1.0
|
24
|
+
version_requirements: *26790048
|
30
25
|
description: simplecolorpicker jQuery plugin
|
31
26
|
email:
|
32
27
|
- tkrotoff@gmail.com
|
@@ -64,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
59
|
version: '0'
|
65
60
|
requirements: []
|
66
61
|
rubyforge_project:
|
67
|
-
rubygems_version: 1.8.
|
62
|
+
rubygems_version: 1.8.16
|
68
63
|
signing_key:
|
69
64
|
specification_version: 3
|
70
65
|
summary: simplecolorpicker packaged for the Rails 3.1+ asset pipeline
|