jquery-simplecolorpicker-rails 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,10 @@
|
|
1
|
-
|
2
|
-
* Very simple jQuery Color Picker
|
1
|
+
/*
|
2
|
+
* Very simple jQuery Color Picker
|
3
3
|
* https://github.com/tkrotoff/jquery-simplecolorpicker
|
4
4
|
*
|
5
5
|
* Copyright (C) 2012-2013 Tanguy Krotoff <tkrotoff@gmail.com>
|
6
6
|
*
|
7
|
-
* Licensed under the MIT license
|
7
|
+
* Licensed under the MIT license
|
8
8
|
*/
|
9
9
|
|
10
10
|
(function($) {
|
@@ -44,7 +44,7 @@
|
|
44
44
|
var selectText = self.$select.find('option:selected').text();
|
45
45
|
self.$icon = $('<span class="simplecolorpicker icon"'
|
46
46
|
+ ' title="' + selectText + '"'
|
47
|
-
+ ' style="background-color: ' + selectValue + '"'
|
47
|
+
+ ' style="background-color: ' + selectValue + ';"'
|
48
48
|
+ ' role="button" tabindex="0">'
|
49
49
|
+ fakeText
|
50
50
|
+ '</span>').insertAfter(self.$select);
|
@@ -62,7 +62,7 @@
|
|
62
62
|
}
|
63
63
|
|
64
64
|
// Build the list of colors
|
65
|
-
// <
|
65
|
+
// <span class="selected" title="Green" style="background-color: #7bd148;" role="button"></span>
|
66
66
|
var colors = '';
|
67
67
|
$('option', self.$select).each(function() {
|
68
68
|
var option = $(this);
|
@@ -72,13 +72,13 @@
|
|
72
72
|
if (option.prop('selected') === true || selectValue === color) {
|
73
73
|
selected = 'class="selected"';
|
74
74
|
}
|
75
|
-
colors += '<
|
75
|
+
colors += '<span ' + selected
|
76
76
|
+ ' title="' + title + '"'
|
77
|
-
+ ' style="background-color: ' + color + '"'
|
77
|
+
+ ' style="background-color: ' + color + ';"'
|
78
78
|
+ ' data-color="' + color + '"'
|
79
79
|
+ ' role="button" tabindex="0">'
|
80
80
|
+ fakeText
|
81
|
-
+ '</
|
81
|
+
+ '</span>';
|
82
82
|
});
|
83
83
|
|
84
84
|
self.$colorList.html(colors);
|
@@ -93,12 +93,12 @@
|
|
93
93
|
selectColor: function(color) {
|
94
94
|
var self = this;
|
95
95
|
|
96
|
-
var
|
97
|
-
return $(this).data('color') === color;
|
96
|
+
var colorSpan = self.$colorList.find('span').filter(function() {
|
97
|
+
return $(this).data('color').toLowerCase() === color.toLowerCase();
|
98
98
|
});
|
99
99
|
|
100
|
-
if (
|
101
|
-
self.
|
100
|
+
if (colorSpan.length > 0) {
|
101
|
+
self.selectColorSpan(colorSpan);
|
102
102
|
} else {
|
103
103
|
console.error("The given color '" + color + "' could not be found");
|
104
104
|
}
|
@@ -120,18 +120,18 @@
|
|
120
120
|
},
|
121
121
|
|
122
122
|
/**
|
123
|
-
* Selects the given
|
123
|
+
* Selects the given span inside $colorList.
|
124
124
|
*
|
125
|
-
* The given
|
125
|
+
* The given span becomes the selected one.
|
126
126
|
* It also changes the HTML select value, this will emit the 'change' event.
|
127
127
|
*/
|
128
|
-
|
129
|
-
var color =
|
130
|
-
var title =
|
128
|
+
selectColorSpan: function(colorSpan) {
|
129
|
+
var color = colorSpan.data('color');
|
130
|
+
var title = colorSpan.prop('title');
|
131
131
|
|
132
|
-
// Mark this
|
133
|
-
|
134
|
-
|
132
|
+
// Mark this span as the selected one
|
133
|
+
colorSpan.siblings().removeClass('selected');
|
134
|
+
colorSpan.addClass('selected');
|
135
135
|
|
136
136
|
if (this.options.picker) {
|
137
137
|
this.$icon.css('background-color', color);
|
@@ -144,14 +144,14 @@
|
|
144
144
|
},
|
145
145
|
|
146
146
|
/**
|
147
|
-
* The user clicked on a
|
147
|
+
* The user clicked on a span inside $colorList.
|
148
148
|
*/
|
149
149
|
click: function(e) {
|
150
150
|
var target = $(e.target);
|
151
151
|
if (target.length === 1) {
|
152
|
-
if (target[0].nodeName.toLowerCase() === '
|
152
|
+
if (target[0].nodeName.toLowerCase() === 'span') {
|
153
153
|
// When you click on a color, make it the new selected one
|
154
|
-
this.
|
154
|
+
this.selectColorSpan(target);
|
155
155
|
this.$select.trigger('change');
|
156
156
|
}
|
157
157
|
}
|
@@ -1,11 +1,13 @@
|
|
1
|
-
|
2
|
-
* Very simple jQuery Color Picker
|
1
|
+
/*
|
2
|
+
* Very simple jQuery Color Picker
|
3
3
|
* https://github.com/tkrotoff/jquery-simplecolorpicker
|
4
4
|
*
|
5
5
|
* Copyright (C) 2012-2013 Tanguy Krotoff <tkrotoff@gmail.com>
|
6
6
|
*
|
7
|
-
* Licensed under the MIT license
|
8
|
-
|
7
|
+
* Licensed under the MIT license
|
8
|
+
*/
|
9
|
+
|
10
|
+
/**
|
9
11
|
* Inspired by Bootstrap Twitter.
|
10
12
|
* See https://github.com/twitter/bootstrap/blob/master/less/dropdowns.less
|
11
13
|
* See http://twitter.github.com/bootstrap/assets/css/bootstrap.css
|
@@ -76,7 +78,7 @@
|
|
76
78
|
}
|
77
79
|
|
78
80
|
.simplecolorpicker.icon,
|
79
|
-
.simplecolorpicker
|
81
|
+
.simplecolorpicker span {
|
80
82
|
cursor: pointer;
|
81
83
|
display: inline-block;
|
82
84
|
|
@@ -86,11 +88,11 @@
|
|
86
88
|
|
87
89
|
border: 1px solid transparent;
|
88
90
|
}
|
89
|
-
.simplecolorpicker
|
91
|
+
.simplecolorpicker span {
|
90
92
|
margin: 0 4px 4px 0;
|
91
93
|
}
|
92
94
|
|
93
|
-
.simplecolorpicker
|
94
|
-
.simplecolorpicker
|
95
|
+
.simplecolorpicker span:hover,
|
96
|
+
.simplecolorpicker span.selected {
|
95
97
|
border: 1px solid black;
|
96
98
|
}
|
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.4.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-
|
12
|
+
date: 2013-06-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,12 @@ dependencies:
|
|
21
21
|
version: 3.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.1.0
|
25
30
|
description: simplecolorpicker jQuery plugin
|
26
31
|
email:
|
27
32
|
- tkrotoff@gmail.com
|
@@ -59,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
64
|
version: '0'
|
60
65
|
requirements: []
|
61
66
|
rubyforge_project:
|
62
|
-
rubygems_version: 1.8.
|
67
|
+
rubygems_version: 1.8.23
|
63
68
|
signing_key:
|
64
69
|
specification_version: 3
|
65
70
|
summary: simplecolorpicker packaged for the Rails 3.1+ asset pipeline
|