twitter-colour-picker 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 68e7923594c0a0913fb6a32e4017e4c4d955e1e4
4
+ data.tar.gz: c270c6fd9bfab58be8c4f4ff1001c3dcfad20435
5
+ SHA512:
6
+ metadata.gz: c46f6a8e1c9eb224c82518c6b566718a83f595730e9d6bf6a44310d5d41793cd3d2a6aa7ca07ab8c53dfbdd03c9a869a12caa7bed75702959ba0d0719d03fe1f
7
+ data.tar.gz: 4c16fb564adb28416160fc3e85d434aca65201b9bbbe33d9a5c8dce0d77b2d2e60bf9250fd11c2943ac3ff2deab830a385823371d634b2b771a56a94358731a5
Binary file
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in twitter-colour-picker.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 TODO: Write your name
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,69 @@
1
+ # Twitter::Colour::Picker
2
+
3
+ ![alt tag](https://lh3.googleusercontent.com/-cT0tI6qB43M/VweT2VMAk2I/AAAAAAAAAbw/E1BBFI81KkMU2oAxRhcQSS8YoDh78eabwCCo/s144-Ic42/Screen%2BShot%2B1395-01-20%2Bat%2B15.17.26.png)
4
+
5
+ ## Installation
6
+
7
+ 1.Add gem 'twitter-colour-picker' to your Gemfile.
8
+
9
+ ```ruby
10
+ gem 'twitter-colour-picker'
11
+ ```
12
+
13
+ 2.And then execute:
14
+ ```bash
15
+ $ bundle install
16
+ ```
17
+ Or install it yourself as(local):
18
+ ```bash
19
+ $ gem install twitter-colour-picker
20
+ ```
21
+ ## Usage
22
+
23
+
24
+ | Format | Require |
25
+ | --- | --- |
26
+ | CSS | *= require colour-picker |
27
+ | JS | //= require colour-picker |
28
+
29
+
30
+ choice color on controller :
31
+ ```ruby
32
+ #flat colors , source https://flatuicolors.com/
33
+ @colors = ["3097d1","1abc9c", "2ecc71","3498db","9b59b6","34495e","f39c12","d35400","c0392b","bdc3c7","7f8c8d","f1c40f"]
34
+ ```
35
+ views:
36
+ ```html
37
+ <select id='theme_color' style="display:none;">
38
+ <% @colors.each do |color|%>
39
+ <option value="<%= color %>"><%= color %></option>
40
+ <% end %>
41
+ </select>
42
+
43
+ ```
44
+ OR:
45
+ ```ruby
46
+ <%= form.select(:theme_color, options_for_select(@colors, selected: 'user selected'),{},{:class=>"...",:id=>'theme_color',:style=>'display:none;'}) %>
47
+ ```
48
+
49
+
50
+ ```javascript
51
+ <script>
52
+ $(document).ready(function(e){
53
+ $('#theme_color').colorpicker({
54
+ size: 35,
55
+ label: 'Theme Color: ',
56
+ hide: false
57
+ });
58
+ });
59
+ </script>
60
+ ```
61
+
62
+ ## Contributing
63
+
64
+ For reporting bug, contact me on [twitter](https://twitter.com/mm580486)
65
+
66
+
67
+ ## License
68
+
69
+ Copyright (c) 2015 [Mohammad Mahmoudi](https://twitter.com/mm580486).
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "twitter/colour/picker"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
Binary file
Binary file
@@ -0,0 +1,9 @@
1
+ require "twitter/colour/picker/version"
2
+ require 'twitter/colour/picker/engine'
3
+ module Twitter
4
+ module Colour
5
+ module Picker
6
+ # Your code goes here...
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ module Twitter
2
+ module Colour
3
+ module Picker
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ module Twitter
2
+ module Colour
3
+ module Picker
4
+ VERSION = "0.1.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'twitter/colour/picker/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "twitter-colour-picker"
8
+ spec.version = Twitter::Colour::Picker::VERSION
9
+ spec.authors = ["Mohammad Mahmoudi"]
10
+ spec.email = ["mm580486@icloud.com"]
11
+
12
+ spec.summary = %q{choices colour picker like twitter}
13
+ spec.description = %q{choices colour picker like twitter}
14
+ spec.homepage = "https://github.com/mm580486/twitter-color-picker"
15
+ spec.license = "Mohammad Mahmoudi(@mm580486)"
16
+ spec.add_dependency "jquery-rails"
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.10"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ end
Binary file
Binary file
@@ -0,0 +1,96 @@
1
+ $(document).ready(function(e){
2
+
3
+ $.fn.extend({
4
+ colorpicker: function(options) {
5
+ var defaults = {
6
+ label: '',
7
+ size: 20,
8
+ count: 6,
9
+ hide: true
10
+ };
11
+ var options = $.extend(defaults, options);
12
+ var obj;
13
+ var colors = {};
14
+ var wrap = $('<div class="colorpicker-wrap"></div>');
15
+ var label = $('<div class="colorpicker-label"></div>');
16
+ var trigger = $('<div class="colorpicker-trigger"></div>');
17
+ var picker = $('<div style="z-index: 999999;width: ' + (options.size + 4) * options.count + 'px" class="colorpicker-picker"></div>');
18
+ var info = $('<div class="colorpicker-picker-info"></div>');
19
+ var clear = $('<div style="clear:both;"></div>');
20
+ return this.each(function() {
21
+ obj = this;
22
+ $(obj).children('option').each(function(i, elm) {
23
+ colors[i] = {};
24
+ colors[i].color = $(elm).text();
25
+ colors[i].value = $(elm).val();
26
+ });
27
+ create_wrap();
28
+ if (options.label != '')
29
+ create_label();
30
+ create_trigger();
31
+ create_picker();
32
+ wrap.append(label);
33
+ wrap.append(trigger);
34
+ wrap.append(picker);
35
+ wrap.append(clear);
36
+ $(obj).after(wrap);
37
+ if (options.hide)
38
+ $(obj).css({
39
+ position: 'absolute',
40
+ left: -10000
41
+ });
42
+ });
43
+ function create_wrap() {
44
+ wrap.mouseleave(function() {
45
+ picker.fadeOut('slow');
46
+ });
47
+ }
48
+
49
+ function create_label() {
50
+ label.text(options.label);
51
+ label.click(function() {
52
+ trigger.click()
53
+ });
54
+ }
55
+
56
+ function create_trigger() {
57
+ trigger.click(function() {
58
+ var offset = $(this).position();
59
+ var top = offset.top;
60
+ var left = offset.left + $(this).width() + 5;
61
+ $(picker).css({
62
+ 'top': top,
63
+ 'left': left
64
+ }).fadeIn('slow');
65
+ });
66
+ }
67
+
68
+ function create_picker() {
69
+ picker.append(info);
70
+ for (var i in colors) {
71
+ picker.append('<span class="colorpicker-picker-span ' + (colors[i].color == $(obj).children(":selected").text() ? ' active' : '') + '" rel="' + colors[i].value + '" style="background-color: #' + colors[i].color + '; width: ' + options.size + 'px; height: ' + options.size + 'px;"></span>');
72
+ }
73
+ trigger.css('background-color', '#'+$(obj).children(":selected").text());
74
+ info.text('#'+$(obj).children(":selected").text());
75
+ picker.children(".colorpicker-picker-span").hover(function() {
76
+ info.text('#' + $(this).attr('rel'));
77
+ }, function() {
78
+ info.text('#' + picker.children('.colorpicker-picker-span.active').attr('rel'));
79
+ });
80
+ picker.delegate(".colorpicker-picker-span", "click", function() {
81
+ $(obj).val($(this).attr('rel'));
82
+ $(obj).change();
83
+ });
84
+ $(obj).change(function(){
85
+ var val = $(obj).val();
86
+ info.text('#' + val);
87
+ picker.children('.colorpicker-picker-span.active').removeClass('active');
88
+ var active = $(picker).find('span.colorpicker-picker-span[rel="' +val+ '"]');
89
+ $(active).addClass('active');
90
+ trigger.css('background-color', '#'+val);
91
+ });
92
+ $(obj).after(picker);
93
+ }
94
+ }
95
+ });
96
+ });
@@ -0,0 +1,68 @@
1
+ body{
2
+ background-color: lightgreen;
3
+ }
4
+ .colorpicker-picker-span{
5
+ background-color: transparent;
6
+ cursor: pointer;
7
+ display: inline-block;
8
+ height: 29px;
9
+ padding-right: 6px;
10
+ padding-top: 6px;
11
+ width: 29px;
12
+ border-radius: 4px;
13
+ background: transparent;
14
+ font-style: normal;
15
+ position: relative;
16
+ text-align: center;
17
+ vertical-align: top;
18
+ }
19
+
20
+ .colorpicker-picker-info{
21
+ padding: 0 0 2px;
22
+ color: #fff;
23
+ text-align: center;
24
+ text-transform: uppercase;
25
+ }
26
+
27
+ .colorpicker-picker-span:hover {
28
+ border: 1px solid #fff;
29
+ }
30
+
31
+ .colorpicker-picker-span.active {
32
+ border: 1px solid #fff;
33
+ }
34
+
35
+ .colorpicker-picker {
36
+ background-color: white;
37
+ border-radius: 4px;
38
+ -moz-box-sizing: border-box;
39
+ box-sizing: border-box;
40
+ height: 98px;
41
+
42
+ position: absolute;
43
+ width: 273px;
44
+ z-index: 1;
45
+ display: none;
46
+ }
47
+
48
+ .colorpicker-trigger {
49
+ display: block;
50
+ width: 110px;
51
+ height: 30px;
52
+ border-radius: 4px;
53
+ float: left;
54
+ cursor: pointer;
55
+ background-color: #808080;
56
+ padding-left: 20px;
57
+
58
+ }
59
+
60
+
61
+ .colorpicker-wrap {
62
+ font-family: 'Trebuchet MS', Verdana, Arial, Geneva, sans-serif
63
+ }
64
+
65
+ .colorpicker-label {
66
+ float: left;
67
+ margin-right: 2px;
68
+ }
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twitter-colour-picker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mohammad Mahmoudi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-04-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jquery-rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: choices colour picker like twitter
56
+ email:
57
+ - mm580486@icloud.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".DS_Store"
63
+ - ".gitignore"
64
+ - CODE_OF_CONDUCT.md
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/setup
71
+ - lib/.DS_Store
72
+ - lib/twitter/.DS_Store
73
+ - lib/twitter/colour/.DS_Store
74
+ - lib/twitter/colour/picker.rb
75
+ - lib/twitter/colour/picker/.DS_Store
76
+ - lib/twitter/colour/picker/engine.rb
77
+ - lib/twitter/colour/picker/version.rb
78
+ - twitter-colour-picker.gemspec
79
+ - vendor/.DS_Store
80
+ - vendor/assets/.DS_Store
81
+ - vendor/assets/javascripts/.DS_Store
82
+ - vendor/assets/javascripts/colour-picker.js
83
+ - vendor/assets/stylesheets/.DS_Store
84
+ - vendor/assets/stylesheets/colour-picker.css
85
+ homepage: https://github.com/mm580486/twitter-color-picker
86
+ licenses:
87
+ - Mohammad Mahmoudi(@mm580486)
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.4.5.1
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: choices colour picker like twitter
109
+ test_files: []