wcolorpicker-rails 1.3.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YjFmMDBhYzk1NzI4YjYzNzQyNmZiNGMxZTI2NTU0OTg1MTMzY2EzOA==
5
+ data.tar.gz: !binary |-
6
+ ZDU5ODE3ZjViNmE5MTcyNjg5NGE0ZWEwOTc4ZTI5MDRkZTRjN2VmNg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ MDBlNzFmMTA1NTJhMzZlMzQ0MGRiYjc3NTMzNmQ2NTM3N2MzZThjOGM5NWI5
10
+ MjQ1YzdmOWE0NDI3NzhmMDRmODQ3ZTJkOGMyNDU0MmI0MDEyMDc1Mjg4OTAy
11
+ MWI1YjdiNmRiYmM4MWRkN2EwNjUxNmFiY2MwMzAxMmUwYjY0ZWQ=
12
+ data.tar.gz: !binary |-
13
+ MjFmODA5OTkyOGRhNzNmMjhiMTAyNjEwYjgyZjAwODc0NTI4MWZiZGQwZTZm
14
+ NzNmM2ZjZGVjNjMyODM3Y2M1NWM2YjE5NDM3OGI4OTEzYTMzOTI5ODhmMjBm
15
+ M2MzOGRkMTQzNThkNzkyZDc2ODc5ODc5MzIxOWNmYzcxYzNmNTM=
data/README.md CHANGED
@@ -16,21 +16,19 @@ For the orignal javascript and css files go to their [Github repository](https:/
16
16
  In your Gemfile, add:
17
17
 
18
18
  ```ruby
19
- group :assets do
20
- gem 'wcolorpicker-rails'
21
- end
19
+ gem 'wcolorpicker-rails'
22
20
  ```
23
21
 
24
22
  You can include it by adding the following to your javascript file:
25
23
 
26
24
  ```javascript
27
- //= require wcolorpicker
25
+ //= require wColorPicker.min
28
26
  ```
29
27
 
30
28
  And to the css file:
31
29
 
32
30
  ```css
33
31
  /*
34
- *= require wcolorpicker
32
+ *= require wColorPicker.min
35
33
  */
36
34
  ```
@@ -1,5 +1,5 @@
1
1
  module Wcolorpicker
2
2
  module Rails
3
- VERSION = "1.3.4"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
@@ -0,0 +1,2 @@
1
+ /*! rgbHex - v1.1.1 - 2013-08-01 */window.rgbHex=function(){function a(a){return!isNaN(parseFloat(a))&&isFinite(a)}function b(a){return a.replace(/^\s+|\s+$/g,"")}function c(c){return c=b(c),a(c)&&c>=0&&255>=c}function d(a){return/^[0-9a-f]{3}$|^[0-9a-f]{6}$/i.test(b(a))}function e(a){return a=parseInt(a,10).toString(16),1===a.length?"0"+a:a}function f(a){return parseInt(a,16).toString()}function g(b){return b=b.split(","),(3===b.length||4===b.length)&&c(b[0])&&c(b[1])&&c(b[2])?4!==b.length||a(b[3])?"#"+e(b[0]).toUpperCase()+e(b[1]).toUpperCase()+e(b[2]).toUpperCase():null:null}function h(a){return d(a)?(3===a.length&&(a=a.charAt(0)+a.charAt(0)+a.charAt(1)+a.charAt(1)+a.charAt(2)+a.charAt(2)),"rgb("+f(a.substr(0,2))+","+f(a.substr(2,2))+","+f(a.substr(4,2))+")"):void 0}return function(a){if(!a)return null;var c=null,d=/^rgba?\((.*)\);?$/,e=/^#/;return a=b(a.toString()),"transparent"===a?a:d.test(a)?g(a.match(d)[1]):e.test(a)?h(a.split("#").reverse()[0]):(c=a.split(","),1===c.length?h(a):3===c.length||4===c.length?g(a):void 0)}}(),jQuery&&jQuery.extend({rgbHex:function(a){return window.rgbHex(a)}});
2
+ /*! wColorPicker - v2.0.0 - 2013-08-02 */!function(a){function b(b,c){this.$el=a(b),this.options=c,this.init=!1,this.generate()}b.prototype={generate:function(){return this.$colorPicker||(this.$noneColorPalette=this._createPalette("none",[["transparent"]]),this.$simpleColorPalette=this._createPalette("simple",a.fn.wColorPicker.simpleColors),this.$mixedColorPalette=this._createPalette("mixed",a.fn.wColorPicker.mixedColors),this.$colorTarget=a('<div class="wColorPicker-color-target"></div>'),this.$customInput=a('<input type="text" class="wColorPicker-custom-input"/>').keyup(a.proxy(this._customInputKeyup,this)),this.$colorPickerPalettesHolder=a('<div class="wColorPicker-palettes-holder"></div>').append(this.$noneColorPalette).append(this.$colorTarget).append(this.$customInput).append("<br/>").append(this.$simpleColorPalette).append(this.$mixedColorPalette),this.$colorPickerHolder=a('<div class="wColorPicker-holder"></div>').append(this.$colorPickerPalettesHolder),this.$colorPickerBg=a('<div class="wColorPicker-bg"></div>'),this.$colorPicker=a('<div class="wColorPicker"></div>').append(this.$colorPickerBg).append(this.$colorPickerHolder),this.setOpacity(this.options.opacity),this.setTheme(this.options.theme),this.setColor(this.options.color),a("body").append(this.$colorPicker),this.width=this.$colorPickerPalettesHolder.width(),this.height=this.$colorPickerPalettesHolder.height(),this.$colorPickerPalettesHolder.width(this.width),this.$colorPickerPalettesHolder.height(this.height),this.$el.append(this.$colorPicker),this.setMode(this.options.mode),this.setPosition(this.options.position)),this.init=!0,this},setTheme:function(a){this.$colorPicker.attr("class",this.$colorPicker.attr("class").replace(/wColorPicker-theme-.+\s|wColorPicker-theme-.+$/,"")),this.$colorPicker.addClass("wColorPicker-theme-"+a)},setOpacity:function(a){this.$colorPickerBg.css("opacity",a)},setColor:function(a){return window.rgbHex(a)?(this.currentColor=a,this.$colorTarget.css("backgroundColor",a),this.$customInput.val(a),this.init&&this.options.onSelect&&this.options.onSelect.apply(this,[a]),void 0):!0},setMode:function(b){var c=this,d=function(){c._toggleEffect("show")},e=function(){c._toggleEffect("hide")};if("flat"===b?this.$colorPicker.removeClass("wColorPicker-zindex").css({position:"relative",display:""}):this.$colorPicker.addClass("wColorPicker-zindex").css({position:"absolute"}).hide(),this.$el.find("wColorPicker-button").remove(),this.$el.unbind("mouseenter",d).unbind("mouseleave",e),a(document).unbind("click",e),"flat"!==b&&this.options.generateButton){var f=this.options.onSelect,g=a('<div class="wColorPicker-button"></div>'),h=a('<div class="wColorPicker-button-color"></div>').css("backgroundColor",this.options.color);this.$el.append(g),g.append(h.height(this.$el.height()-g.outerHeight(!0))),this.options.onSelect=function(a){h.css("backgroundColor",a),c._toggleEffect(),f&&f.apply(c,arguments)}}"click"===b?(this.$el.click(function(a){c._toggleEffect(),a.stopPropagation()}),this.$colorPicker.click(function(a){a.stopPropagation()}),a(document).bind("click",e)):"hover"===b&&this.$el.bind("mouseenter",d).bind("mouseleave",e)},setEffect:function(a){return"flat"===this.options.mode?!0:(this.$colorPicker.css("opacity",1),this.$colorPickerHolder.width(this.width).height(this.height),"fade"===a?this.$colorPicker.css("opacity",0):"slide"===a&&this.$colorPickerHolder.width("x"===this.positionAxis?0:this.width).height("y"===this.positionAxis?0:this.height),void 0)},setPosition:function(a){if("flat"===this.options.mode)return!0;var b=this.$el.outerWidth(),c=this.$el.outerHeight(),d=this.$el.outerWidth()/2-this.$colorPicker.outerWidth()/2,e=this.$el.outerHeight()/2-this.$colorPicker.outerHeight()/2,f={left:"",right:"",top:"",bottom:""},g=this.options.position.charAt(0);switch("t"===g||"b"===g?this.positionAxis="y":("l"===g||"r"===g)&&(this.positionAxis="x"),a){case"tl":f.left=0,f.bottom=c;break;case"tc":f.left=d,f.bottom=c;break;case"tr":f.right=0,f.bottom=c;break;case"rt":f.left=b,f.top=0;break;case"rm":f.left=b,f.top=e;break;case"rb":f.left=b,f.bottom=0;break;case"br":f.right=0,f.top=c;break;case"bc":f.left=d,f.top=c;break;case"bl":f.left=0,f.top=c;break;case"lb":f.right=b,f.bottom=0;break;case"lm":f.right=b,f.top=e;break;case"lt":f.right=b,f.top=0}this.$colorPicker.css(f),this.setEffect(this.options.effect)},_customInputKeyup:function(b){var c=a(b.target).val();window.rgbHex(c)&&(this.$colorTarget.css("backgroundColor",c),13===b.keyCode&&this.setColor(c))},_createPalette:function(b,c){var d=0,e=0,f=0,g=0,h=null,i=a('<div class="wColorPicker-palette wColorPicker-palette-'+b+'"></div>');for(d=0,e=c.length;e>d;d++){for(f=0,g=c[d].length;g>f;f++)h=this._createColor(f,c[d][f]),0===d&&h.addClass("wColorPicker-palette-color-top"),0===f&&h.addClass("wColorPicker-palette-color-left"),i.append(h);e>d&&i.append("<br/>")}return i},_createColor:function(b,c){var d=this;return a('<div class="wColorPicker-palette-color"></div>').attr("id","wColorPicker-palette-color-"+b).addClass("wColorPicker-palette-color-"+b).css("backgroundColor",c).hover(function(){d._colorHoverOn(a(this))},function(){d._colorHoverOff(a(this))}).click(function(b){b.stopPropagation(),d.setColor(window.rgbHex(a(this).css("backgroundColor")))})},_colorHoverOn:function(a){var b=window.rgbHex(a.css("backgroundColor"));a.addClass("active").prev().addClass("active-right"),a.prevAll("."+a.attr("id")+":first").addClass("active-bottom"),this.$colorTarget.css("backgroundColor",b),this.$customInput.val(b),this.options.onMouseover&&this.options.onMouseover.apply(this,[b])},_colorHoverOff:function(a){a.removeClass("active").prev().removeClass("active-right"),a.prevAll("."+a.attr("id")+":first").removeClass("active-bottom"),this.$colorTarget.css("backgroundColor",this.currentColor),this.$customInput.val(this.currentColor),this.options.onMouseout&&this.options.onMouseout.apply(this,[this.currentColor])},_toggleEffect:function(a){var b=this.$colorPicker.hasClass("wColorPicker-visible");(!a||"show"===a&&b===!1||"hide"===a&&b===!0)&&(this["_"+this.options.effect+"Effect"+(b?"Hide":"Show")](),this.$colorPicker.toggleClass("wColorPicker-visible"))},_noneEffectShow:function(){this.$colorPicker.css("display","inline-block")},_noneEffectHide:function(){this.$colorPicker.hide()},_fadeEffectShow:function(){this.$colorPicker.stop(!0,!1).css({display:"inline-block"}).animate({opacity:1},this.options.showSpeed)},_fadeEffectHide:function(){this.$colorPicker.stop(!0,!1).animate({opacity:0},this.options.hideSpeed,a.proxy(function(){this.$colorPicker.hide()},this))},_slideEffectShow:function(){var a="y"===this.positionAxis?{height:this.height}:{width:this.width};this.$colorPicker.css("display","inline-block"),this.$colorPickerHolder.stop(!0,!1).animate(a,this.options.showSpeed)},_slideEffectHide:function(){var b="y"===this.positionAxis?{height:0}:{width:0};this.$colorPickerHolder.stop(!0,!1).animate(b,this.options.hideSpeed,a.proxy(function(){this.$colorPicker.hide()},this))}},a.fn.wColorPicker=function(c,d){function e(d){var e,f=a.data(d,"wColorPicker");return f||(e=a.extend({},a.fn.wColorPicker.defaults,c),e.color=window.rgbHex(e.color)?e.color:"transparent",f=new b(d,e),a.data(d,"wColorPicker",f)),f}if("string"==typeof c){var f=[],g=null,h=null,i=null;return h=this.each(function(){g=a(this).data("wColorPicker"),g&&(i=(d?"set":"get")+c.charAt(0).toUpperCase()+c.substring(1).toLowerCase(),g[c]?f.push(g[c].apply(g,[d])):d?(g[i]&&g[i].apply(g,[d]),g.options[c]&&(g.options[c]=d)):g[i]?f.push(g[i].apply(g,[d])):g.options[c]?f.push(g.options[c]):f.push(null))}),1===f.length?f[0]:f.length>0?f:h}return this.each(function(){e(this)})},a.fn.wColorPicker.defaults={theme:"classic",opacity:.8,color:"#FF0000",mode:"flat",position:"bl",generateButton:!0,effect:"slide",showSpeed:500,hideSpeed:500,onMouseover:null,onMouseout:null,onSelect:null},a.fn.wColorPicker.mixedColors=[["#000000","#003300","#006600","#009900","#00CC00","#00FF00","#330000","#333300","#336600","#339900","#33CC00","#33FF00","#660000","#663300","#666600","#669900","#66CC00","#66FF00"],["#000033","#003333","#006633","#009933","#00CC33","#00FF33","#330033","#333333","#336633","#339933","#33CC33","#33FF33","#660033","#663333","#666633","#669933","#66CC33","#66FF33"],["#000066","#003366","#006666","#009966","#00CC66","#00FF66","#330066","#333366","#336666","#339966","#33CC66","#33FF66","#660066","#663366","#666666","#669966","#66CC66","#66FF66"],["#000099","#003399","#006699","#009999","#00CC99","#00FF99","#330099","#333399","#336699","#339999","#33CC99","#33FF99","#660099","#663399","#666699","#669999","#66CC99","#66FF99"],["#0000CC","#0033CC","#0066CC","#0099CC","#00CCCC","#00FFCC","#3300CC","#3333CC","#3366CC","#3399CC","#33CCCC","#33FFCC","#6600CC","#6633CC","#6666CC","#6699CC","#66CCCC","#66FFCC"],["#0000FF","#0033FF","#0066FF","#0099FF","#00CCFF","#00FFFF","#3300FF","#3333FF","#3366FF","#3399FF","#33CCFF","#33FFFF","#6600FF","#6633FF","#6666FF","#6699FF","#66CCFF","#66FFFF"],["#990000","#993300","#996600","#999900","#99CC00","#99FF00","#CC0000","#CC3300","#CC6600","#CC9900","#CCCC00","#CCFF00","#FF0000","#FF3300","#FF6600","#FF9900","#FFCC00","#FFFF00"],["#990033","#993333","#996633","#999933","#99CC33","#99FF33","#CC0033","#CC3333","#CC6633","#CC9933","#CCCC33","#CCFF33","#FF0033","#FF3333","#FF6633","#FF9933","#FFCC33","#FFFF33"],["#990066","#993366","#996666","#999966","#99CC66","#99FF66","#CC0066","#CC3366","#CC6666","#CC9966","#CCCC66","#CCFF66","#FF0066","#FF3366","#FF6666","#FF9966","#FFCC66","#FFFF66"],["#990099","#993399","#996699","#999999","#99CC99","#99FF99","#CC0099","#CC3399","#CC6699","#CC9999","#CCCC99","#CCFF99","#FF0099","#FF3399","#FF6699","#FF9999","#FFCC99","#FFFF99"],["#9900CC","#9933CC","#9966CC","#9999CC","#99CCCC","#99FFCC","#CC00CC","#CC33CC","#CC66CC","#CC99CC","#CCCCCC","#CCFFCC","#FF00CC","#FF33CC","#FF66CC","#FF99CC","#FFCCCC","#FFFFCC"],["#9900FF","#9933FF","#9966FF","#9999FF","#99CCFF","#99FFFF","#CC00FF","#CC33FF","#CC66FF","#CC99FF","#CCCCFF","#CCFFFF","#FF00FF","#FF33FF","#FF66FF","#FF99FF","#FFCCFF","#FFFFFF"]],a.fn.wColorPicker.simpleColors=[["#000000"],["#333333"],["#666666"],["#999999"],["#CCCCCC"],["#FFFFFF"],["#FF0000"],["#00FF00"],["#0000FF"],["#FFFF00"],["#00FFFF"],["#FF00FF"]]}(jQuery);
@@ -0,0 +1,40 @@
1
+ .wColorPicker{position:relative;display:inline-block;*display:inline;zoom:1;line-height:0;font-size:0}
2
+ .wColorPicker-bg{position:absolute;left:0;top:0;width:100%;height:100%}
3
+ .wColorPicker-holder{position:relative;display:inline-block;*display:inline;zoom:1;overflow:hidden}
4
+ .wColorPicker-palettes-holder{position:relative;display:inline-block;*display:inline;zoom:1}
5
+ .wColorPicker-zindex{z-index:1000}
6
+ .wColorPicker-palette{position:relative;display:inline-block;*display:inline;zoom:1;margin:0 10px 10px 0}
7
+ .wColorPicker-palette-none,.wColorPicker-palette-simple{margin-left:10px}
8
+ .wColorPicker-palette-color{display:inline-block;*display:inline;zoom:1;vertical-align:middle;width:10px;height:10px;border-right:solid 1px;border-bottom:solid 1px;cursor:pointer}
9
+ .wColorPicker-palette-color-left{border-left:solid 1px}
10
+ .wColorPicker-palette-color-top{border-top:solid 1px}
11
+ .wColorPicker-color-target{position:relative;display:inline-block;*display:inline;zoom:1;vertical-align:middle;width:40px;height:16px;border:solid 1px}
12
+ .wColorPicker-custom-input{position:relative;display:inline-block;*display:inline;zoom:1;vertical-align:middle;width:70px;height:16px;line-height:16px;font-size:9px;font-family:verdana;padding:0 2px;border:solid 1px}
13
+ .wColorPicker-color-target,.wColorPicker-custom-input{margin:10px 10px 10px 0}
14
+ .wColorPicker-button{position:relative;-webkit-border-radius:5px;border-radius:5px;border:solid #cacaca 1px;padding:1px}
15
+ .wColorPicker-button-color{position:relative;-webkit-border-radius:5px;border-radius:5px}
16
+ .wColorPicker-holder{border:solid 1px}
17
+ .wColorPicker-bg,.wColorPicker-holder{-webkit-border-radius:5px;border-radius:5px}
18
+ .wColorPicker-bg{-webkit-box-shadow:inset 0 0 9px #fff;box-shadow:inset 0 0 9px #fff}
19
+ .wColorPicker-custom-input{opacity:.5;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";filter:alpha(opacity=50)}
20
+ .wColorPicker-theme-classic .wColorPicker-custom-input,.wColorPicker-theme-classic .wColorPicker-color-target,.wColorPicker-theme-classic .wColorPicker-palette-color{border-color:#3a3a3a}
21
+ .wColorPicker-theme-classic .wColorPicker-holder{border-color:#bababa}
22
+ .wColorPicker-theme-classic .wColorPicker-bg{background-color:#aaa}
23
+ .wColorPicker-theme-black .wColorPicker-color-target,.wColorPicker-theme-black .wColorPicker-color-input,.wColorPicker-theme-black .wColorPicker-palette-color{border-color:#3f3f3f}
24
+ .wColorPicker-theme-black .wColorPicker-holder{border-color:#7f7f7f}
25
+ .wColorPicker-theme-black .wColorPicker-bg{background-color:#363636}
26
+ .wColorPicker-theme-blue .wColorPicker-color-target,.wColorPicker-theme-blue .wColorPicker-color-input,.wColorPicker-theme-blue .wColorPicker-palette-color{border-color:#002f4d}
27
+ .wColorPicker-theme-blue .wColorPicker-holder{border-color:#49afcd}
28
+ .wColorPicker-theme-blue .wColorPicker-bg{background-color:#2f96b4}
29
+ .wColorPicker-theme-red .wColorPicker-color-target,.wColorPicker-theme-red .wColorPicker-color-input,.wColorPicker-theme-red .wColorPicker-palette-color{border-color:#8a0f09}
30
+ .wColorPicker-theme-red .wColorPicker-holder{border-color:#da4f49}
31
+ .wColorPicker-theme-red .wColorPicker-bg{background-color:#bd362f}
32
+ .wColorPicker-theme-green .wColorPicker-color-target,.wColorPicker-theme-green .wColorPicker-color-input,.wColorPicker-theme-green .wColorPicker-palette-color{border-color:#0b670b}
33
+ .wColorPicker-theme-green .wColorPicker-holder{border-color:#5bb75b}
34
+ .wColorPicker-theme-green .wColorPicker-bg{background-color:#51a351}
35
+ .wColorPicker-theme-orange .wColorPicker-color-target,.wColorPicker-theme-orange .wColorPicker-color-input,.wColorPicker-theme-orange .wColorPicker-palette-color{border-color:#9a5700}
36
+ .wColorPicker-theme-orange .wColorPicker-holder{border-color:#faa732}
37
+ .wColorPicker-theme-orange .wColorPicker-bg{background-color:#f89406}
38
+ .wColorPicker-palette-color.active{border-color:#f00}
39
+ .wColorPicker-palette-color.active-right{border-right-color:#f00}
40
+ .wColorPicker-palette-color.active-bottom{border-bottom-color:#f00}
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wcolorpicker-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
5
- prerelease:
4
+ version: 2.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - RogerE
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-24 00:00:00.000000000 Z
11
+ date: 2013-08-06 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: This gem Provides the Websanova Color Picker assets for your Rails application
15
14
  .
@@ -25,31 +24,30 @@ files:
25
24
  - Rakefile
26
25
  - lib/wcolorpicker-rails.rb
27
26
  - lib/wcolorpicker-rails/version.rb
28
- - vendor/assets/javascripts/wcolorpicker.js
29
- - vendor/assets/stylesheets/wcolorpicker.css
27
+ - vendor/assets/javascripts/wColorPicker.min.js
28
+ - vendor/assets/stylesheets/wColorPicker.min.css
30
29
  - wcolorpicker-rails.gemspec
31
30
  homepage: https://github.com/RogerE/wcolorpicker-rails
32
31
  licenses: []
32
+ metadata: {}
33
33
  post_install_message:
34
34
  rdoc_options: []
35
35
  require_paths:
36
36
  - lib
37
37
  required_ruby_version: !ruby/object:Gem::Requirement
38
- none: false
39
38
  requirements:
40
39
  - - ! '>='
41
40
  - !ruby/object:Gem::Version
42
41
  version: '0'
43
42
  required_rubygems_version: !ruby/object:Gem::Requirement
44
- none: false
45
43
  requirements:
46
44
  - - ! '>='
47
45
  - !ruby/object:Gem::Version
48
46
  version: '0'
49
47
  requirements: []
50
48
  rubyforge_project:
51
- rubygems_version: 1.8.24
49
+ rubygems_version: 2.0.6
52
50
  signing_key:
53
- specification_version: 3
51
+ specification_version: 4
54
52
  summary: Use Websanova Color Picker with Rails Asset Pipeline
55
53
  test_files: []
@@ -1,394 +0,0 @@
1
- /******************************************
2
- * Websanova.com
3
- *
4
- * Resources for web entrepreneurs
5
- *
6
- * @author Websanova
7
- * @copyright Copyright (c) 2012 Websanova.
8
- * @license This wChar jQuery plug-in is dual licensed under the MIT and GPL licenses.
9
- * @link http://www.websanova.com
10
- * @github http://github.com/websanova/wColorPicker
11
- * @version Version 1.3.4
12
- *
13
- ******************************************/
14
- (function($)
15
- {
16
- $.fn.wColorPicker = function(option, settings)
17
- {
18
- if(typeof option === 'object')
19
- {
20
- settings = option;
21
- }
22
- else if(typeof option === 'string')
23
- {
24
- var values = [];
25
-
26
- var elements = this.each(function()
27
- {
28
- var data = $(this).data('_wColorPicker');
29
-
30
- if(data)
31
- {
32
- if($.fn.wColorPicker.defaultSettings[option] !== undefined)
33
- {
34
- if(settings !== undefined) { data.settings[option] = settings; }
35
- else { values.push(data.settings[option]); }
36
- }
37
- }
38
- });
39
-
40
- if(values.length === 1) { return values[0]; }
41
- if(values.length > 0) { return values; }
42
- else { return elements; }
43
- }
44
-
45
- settings = $.extend({}, $.fn.wColorPicker.defaultSettings, settings || {});
46
-
47
- return this.each(function()
48
- {
49
- var elem = $(this);
50
- var $settings = jQuery.extend(true, {}, settings);
51
-
52
- var cp = new ColorPicker($settings, elem);
53
-
54
- cp.generate();
55
-
56
- cp.appendToElement(elem);
57
-
58
- cp.colorSelect(cp, $settings.initColor);
59
-
60
- elem.data('_wColorPicker', cp);
61
- });
62
- };
63
-
64
- $.fn.wColorPicker.defaultSettings = {
65
- theme : 'black', // colors - black, white, cream, red, green, blue, yellow, orange, plum
66
- opacity : 0.8, // opacity level
67
- initColor : '#FF0000', // initial colour to set palette to
68
- onMouseover : null, // function to run when palette color is moused over
69
- onMouseout : null, // function to run when palette color is moused out
70
- onSelect : null, // function to run when palette color is selected
71
- mode : 'flat', // flat mode inserts the palette to container, other modes insert button into container - hover, click
72
- buttonSize : 20, // size of button if mode is ohter than flat
73
- effect : 'slide', // none/slide/fade
74
- showSpeed : 500, // time to run the effects on show
75
- hideSpeed : 500 // time to run the effects on hide
76
- };
77
-
78
- /**
79
- * ColorPicker class definition
80
- */
81
- function ColorPicker(settings, elem)
82
- {
83
- this.colorPicker = null;
84
- this.settings = settings;
85
- this.$elem = elem;
86
- this.currentColor = settings.initColor;
87
-
88
- this.height = null; // init this, need to get height/width proper while element is still showing
89
- this.width = null;
90
- this.slideTopToBottom = null; // used to assist with sliding in proper direction
91
-
92
- this.customTarget = null;
93
- this.buttonColor = null;
94
- this.paletteHolder = null;
95
-
96
- return this;
97
- }
98
-
99
- ColorPicker.prototype =
100
- {
101
- generate: function ()
102
- {
103
- if(this.colorPicker) return this.colorPicker;
104
-
105
- var $this = this;
106
-
107
- var clearFloats = {clear: 'both', height: 0, lineHeight: 0, fontSize: 0};
108
-
109
- //custom colors
110
- this.customTarget = $('<div class="_wColorPicker_customTarget"></div>');
111
- this.customInput =
112
- $('<input type="text" class="_wColorPicker_customInput" value=""/>').keyup(function(e)
113
- {
114
- var code = (e.keyCode ? e.keyCode : e.which);
115
-
116
- var hex = $this.validHex($(this).val());
117
-
118
- $(this).val(hex)
119
-
120
- //auto set color in target if it's valid hex code
121
- if(hex.length == 7) $this.customTarget.css('backgroundColor', hex);
122
-
123
- if(code == 13)//set color if user hits enter while on input
124
- {
125
- $this.colorSelect($this, $(this).val());
126
- if($this.buttonColor) $this.hidePalette($this)
127
- }
128
- })
129
- .click(function(e){e.stopPropagation();});
130
-
131
- //setup custom area
132
- var custom =
133
- $('<div class="_wColorPicker_custom"></div>')
134
- .append(this.appendColors($('<div class="_wColorPicker_noColor">'), [''], 1))
135
- .append(this.customTarget)
136
- .append(this.customInput)
137
- //clear floats
138
- .append($('<div></div>').css(clearFloats))
139
-
140
- //grays/simple palette
141
- var simpleColors = ['000000', '333333', '666666', '999999', 'CCCCCC', 'FFFFFF', 'FF0000', '00FF00', '0000FF', 'FFFF00', '00FFFF', 'FF00FF'];
142
- var simplePalette = this.appendColors($('<div class="_wColorPicker_palette_simple"></div>'), simpleColors, 1);
143
-
144
- //colors palette
145
- var mixedColors = [
146
- '000000', '003300', '006600', '009900', '00CC00', '00FF00', '330000', '333300', '336600', '339900', '33CC00', '33FF00', '660000', '663300', '666600', '669900', '66CC00', '66FF00',
147
- '000033', '003333', '006633', '009933', '00CC33', '00FF33', '330033', '333333', '336633', '339933', '33CC33', '33FF33', '660033', '663333', '666633', '669933', '66CC33', '66FF33',
148
- '000066', '003366', '006666', '009966', '00CC66', '00FF66', '330066', '333366', '336666', '339966', '33CC66', '33FF66', '660066', '663366', '666666', '669966', '66CC66', '66FF66',
149
- '000099', '003399', '006699', '009999', '00CC99', '00FF99', '330099', '333399', '336699', '339999', '33CC99', '33FF99', '660099', '663399', '666699', '669999', '66CC99', '66FF99',
150
- '0000CC', '0033CC', '0066CC', '0099CC', '00CCCC', '00FFCC', '3300CC', '3333CC', '3366CC', '3399CC', '33CCCC', '33FFCC', '6600CC', '6633CC', '6666CC', '6699CC', '66CCCC', '66FFCC',
151
- '0000FF', '0033FF', '0066FF', '0099FF', '00CCFF', '00FFFF', '3300FF', '3333FF', '3366FF', '3399FF', '33CCFF', '33FFFF', '6600FF', '6633FF', '6666FF', '6699FF', '66CCFF', '66FFFF',
152
- '990000', '993300', '996600', '999900', '99CC00', '99FF00', 'CC0000', 'CC3300', 'CC6600', 'CC9900', 'CCCC00', 'CCFF00', 'FF0000', 'FF3300', 'FF6600', 'FF9900', 'FFCC00', 'FFFF00',
153
- '990033', '993333', '996633', '999933', '99CC33', '99FF33', 'CC0033', 'CC3333', 'CC6633', 'CC9933', 'CCCC33', 'CCFF33', 'FF0033', 'FF3333', 'FF6633', 'FF9933', 'FFCC33', 'FFFF33',
154
- '990066', '993366', '996666', '999966', '99CC66', '99FF66', 'CC0066', 'CC3366', 'CC6666', 'CC9966', 'CCCC66', 'CCFF66', 'FF0066', 'FF3366', 'FF6666', 'FF9966', 'FFCC66', 'FFFF66',
155
- '990099', '993399', '996699', '999999', '99CC99', '99FF99', 'CC0099', 'CC3399', 'CC6699', 'CC9999', 'CCCC99', 'CCFF99', 'FF0099', 'FF3399', 'FF6699', 'FF9999', 'FFCC99', 'FFFF99',
156
- '9900CC', '9933CC', '9966CC', '9999CC', '99CCCC', '99FFCC', 'CC00CC', 'CC33CC', 'CC66CC', 'CC99CC', 'CCCCCC', 'CCFFCC', 'FF00CC', 'FF33CC', 'FF66CC', 'FF99CC', 'FFCCCC', 'FFFFCC',
157
- '9900FF', '9933FF', '9966FF', '9999FF', '99CCFF', '99FFFF', 'CC00FF', 'CC33FF', 'CC66FF', 'CC99FF', 'CCCCFF', 'CCFFFF', 'FF00FF', 'FF33FF', 'FF66FF', 'FF99FF', 'FFCCFF', 'FFFFFF',
158
- ];
159
- var mixedPalette = this.appendColors($('<div class="_wColorPicker_palette_mixed"></div>'), mixedColors, 18);
160
-
161
- //palette container
162
- var bg = $('<div class="_wColorPicker_bg"></div>').css({opacity: this.settings.opacity});
163
- var content =
164
- $('<div class="_wColorPicker_content"></div>')
165
- .append(custom)
166
- .append(simplePalette)
167
- .append(mixedPalette)
168
- .append($('<div></div>').css(clearFloats));
169
-
170
- //put it all together
171
- this.colorPicker =
172
- $('<div class="_wColorPicker_holder"></div>')
173
- .click(function(e){e.stopPropagation();})
174
- .append(
175
- $('<div class="_wColorPicker_outer"></div>')
176
- .append(
177
- $('<div class="_wColorPicker_inner"></div>')
178
- .append( bg )
179
- .append( content )
180
- )
181
- )
182
- .addClass('_wColorPicker_' + this.settings.theme)
183
-
184
- return this.colorPicker;
185
- },
186
-
187
- appendColors: function($palette, colors, lineCount)
188
- {
189
- var counter = 1;
190
- var $this = this;
191
-
192
- for(index in colors)
193
- {
194
- $palette.append(
195
- $('<div id="_wColorPicker_color_' + counter + '" class="_wColorPicker_color _wColorPicker_color_' + counter + '"></div>').css('backgroundColor', '#' + colors[index])
196
- .click(function(){$this.colorSelect($this, $(this).css('backgroundColor'));})
197
- .mouseout(function(e){$this.colorHoverOff($this, $(this));})
198
- .mouseover(function(){$this.colorHoverOn($this, $(this));})
199
- );
200
-
201
- if(counter == lineCount)
202
- {
203
- $palette.append($('<div></div>').css({clear:'both', height:0, fontSize:0, lineHeight:0, marginTop:-1}))
204
- counter = 0;
205
- }
206
-
207
- counter++;
208
- }
209
-
210
- return $palette;
211
- },
212
-
213
- colorSelect: function($this, color)
214
- {
215
- color = $this.toHex(color);;
216
-
217
- $this.customTarget.css('backgroundColor', color);
218
- $this.currentColor = color;
219
- $this.customInput.val(color);
220
-
221
- if($this.settings.onSelect) $this.settings.onSelect.apply(this, [color]);
222
-
223
- if($this.buttonColor)
224
- {
225
- $this.buttonColor.css('backgroundColor', color);
226
- $this.hidePalette($this);
227
- }
228
- },
229
-
230
- colorHoverOn: function($this, $element)
231
- {
232
- $element.parent().children('active').removeClass('active');
233
- $element.addClass('active').next().addClass('activeLeft');
234
- $element.nextAll('.' + $element.attr('id') + ':first').addClass('activeTop');
235
-
236
- var color = $this.toHex($element.css('backgroundColor'));
237
-
238
- $this.customTarget.css('backgroundColor', color);
239
- $this.customInput.val(color);
240
-
241
- if($this.settings.onMouseover) $this.settings.onMouseover.apply(this, [color]);
242
- },
243
-
244
- colorHoverOff: function($this, $element)
245
- {
246
- $element.removeClass('active').next().removeClass('activeLeft')
247
- $element.nextAll('.' + $element.attr('id') + ':first').removeClass('activeTop')
248
-
249
- $this.customTarget.css('backgroundColor', $this.currentColor);
250
- $this.customInput.val($this.currentColor);
251
-
252
- if($this.settings.onMouseout) $this.settings.onMouseout.apply(this, [$this.currentColor]);
253
- },
254
-
255
- appendToElement: function($element)
256
- {
257
- var $this = this;
258
-
259
- if($this.settings.mode == 'flat') $element.append($this.colorPicker);
260
- else
261
- {
262
- //setup button
263
- $this.paletteHolder = $('<div class="_wColorPicker_paletteHolder"></div>').css({position: 'absolute', overflow: 'hidden', width: 1000}).append($this.colorPicker);
264
-
265
- $this.buttonColor = $('<div class="_wColorPicker_buttonColor"></div>').css({width: $this.settings.buttonSize, height: $this.settings.buttonSize});
266
-
267
- var buttonHolder =
268
- $('<div class="_wColorPicker_buttonHolder"></div>')
269
- .css({position: 'relative'})
270
- .append($('<div class="_wColorPicker_buttonBorder"></div>').append($this.buttonColor))
271
- .append($this.paletteHolder);
272
-
273
- $element.append(buttonHolder);
274
-
275
- $this.width = $this.colorPicker.outerWidth(true);
276
- $this.height = $this.colorPicker.outerHeight(true);
277
- $this.paletteHolder.css({width: $this.width, height: $this.height}).hide();
278
-
279
- if($this.settings.effect == 'fade') $this.paletteHolder.css({opacity: 0});
280
-
281
- //setup events
282
- if($this.settings.mode == 'hover')
283
- {
284
- buttonHolder.hover(
285
- function(e){$this.showPalette(e, $this);},
286
- function(e){$this.hidePalette($this);}
287
- )
288
- }
289
- else if($this.settings.mode == 'click')
290
- {
291
- $(document).click(function(){if($this.paletteHolder.hasClass('active'))$this.hidePalette($this);});
292
-
293
- buttonHolder
294
- .click(function(e)
295
- {
296
- e.stopPropagation();
297
- $this.paletteHolder.hasClass('active') ? $this.hidePalette($this) : $this.showPalette(e, $this);
298
- });
299
- }
300
-
301
- $this.colorSelect($this, $this.settings.initColor);
302
- }
303
- },
304
-
305
- showPalette: function(e, $this)
306
- {
307
- var offset = $this.paletteHolder.parent().offset();
308
-
309
- //init some vars
310
- var left = 0;
311
- var top = $this.paletteHolder.parent().outerHeight(true);
312
- $this.slideTopToBottom = top;
313
-
314
- if(offset.left - $(window).scrollLeft() + $this.width > $(window).width()) left = -1 * ($this.width - $this.paletteHolder.parent().outerWidth(true));
315
- if(offset.top - $(window).scrollTop() + $this.height > $(window).height())
316
- {
317
- $this.slideTopToBottom = 0;
318
- top = -1 * ($this.height);
319
- }
320
-
321
- $this.paletteHolder.css({left: left, top: top});
322
-
323
- $this.paletteHolder.addClass('active')
324
-
325
- if($this.settings.effect == 'slide')
326
- {
327
- $this.paletteHolder.stop(true, false).css({height: 0, top: ($this.slideTopToBottom == 0 ? 0 : top)}).show().animate({height: $this.height, top: top}, $this.settings.showSpeed);
328
- }
329
- else if($this.settings.effect == 'fade')
330
- {
331
- $this.paletteHolder.stop(true, false).show().animate({opacity: 1}, $this.settings.showSpeed);
332
- }
333
- else
334
- {
335
- $this.paletteHolder.show();
336
- }
337
- },
338
-
339
- hidePalette: function($this)
340
- {
341
- //need this to avoid the double hide when you click on colour (once on click, once on mouse out) - this way it's only triggered once
342
- if($this.paletteHolder.hasClass('active'))
343
- {
344
- $this.paletteHolder.removeClass('active');
345
-
346
- if($this.settings.effect == 'slide')
347
- {
348
- $this.paletteHolder.stop(true, false).animate({height: 0, top: ($this.slideTopToBottom == 0 ? 0 : $this.slideTopToBottom)}, $this.settings.hideSpeed, function(){$this.paletteHolder.hide()});
349
- }
350
- else if($this.settings.effect == 'fade')
351
- {
352
- $this.paletteHolder.stop(true, false).animate({opacity: 0}, $this.settings.hideSpeed, function(){$this.paletteHolder.hide()});
353
- }
354
- else
355
- {
356
- $this.paletteHolder.hide();
357
- }
358
- }
359
- },
360
-
361
- toHex: function(color)
362
- {
363
- if(color.substring(0,4) === 'rgba')
364
- {
365
- hex = 'transparent';
366
- }
367
- else if(color.substring(0,3) === 'rgb')
368
- {
369
- var rgb = color.substring(4, color.length - 1).replace(/\s/g, '').split(',');
370
-
371
- for(i in rgb)
372
- {
373
- rgb[i] = parseInt(rgb[i]).toString(16);
374
- if(rgb[i] == '0') rgb[i] = '00';
375
- }
376
-
377
- var hex = '#' + rgb.join('').toUpperCase();
378
- }
379
- else
380
- {
381
- hex = color;
382
- }
383
-
384
- return hex;
385
- },
386
-
387
- validHex: function(hex)
388
- {
389
- return '#' + hex.replace(/[^0-9a-f]/ig, '').substring(0,6).toUpperCase();
390
- }
391
- }
392
-
393
- })(jQuery);
394
-
@@ -1,70 +0,0 @@
1
- /*** layout/positioning - stuff you probably won't need to change ***/
2
- ._wColorPicker_holder{display:inline-block; position:static; z-index:999999; cursor:default;}
3
- ._wColorPicker_outer{position:relative;}
4
- ._wColorPicker_inner{position:relative;}
5
- ._wColorPicker_bg{position:absolute; left:0; top:0; width:100%; height:100%;}
6
- ._wColorPicker_content{position:relative;}
7
-
8
- /*** palettes layout ***/
9
- ._wColorPicker_custom{margin-bottom:10px;}
10
- ._wColorPicker_noColor{float:left; padding-top:6px;}
11
- ._wColorPicker_customTarget{float:left; width:40px; height:18px; margin:0 5px 0 10px; border:solid black 1px;}
12
- ._wColorPicker_customInput{float:left; position:relative; width:65px; height:18px; line-height:18px; padding:0 5px; font-size:10px; font-family:arial; border: solid black 1px;}
13
-
14
- ._wColorPicker_palette_simple,
15
- ._wColorPicker_palette_mixed{float:left; line-height:0px; font-size:0px;}
16
- ._wColorPicker_palette_simple{margin-right:10px;}
17
- ._wColorPicker_color{float:left; width:10px; height:10px; border-width:1px; border-style:solid; margin-left:-1px; margin-top:-1px; cursor:pointer; font-size:0px; line-height:0px;}
18
-
19
- /*** visuals ***/
20
- ._wColorPicker_holder{border-width:2px; border-style:solid; border-radius:6px;}/*outer border*/
21
- ._wColorPicker_outer{border-width:1px; border-style:solid; border-radius:5px; margin:1px; }/*inner border*/
22
- ._wColorPicker_content{padding:5px; font-weight:bold; font-family:verdana; font-size:11px; line-height:15px;}/*content*/
23
-
24
- ._wColorPicker_color{border-color:#000000;}
25
- ._wColorPicker_color.active{border-color:#FF0000;}
26
- ._wColorPicker_color.activeLeft{border-left-color:#FF0000;}
27
- ._wColorPicker_color.activeTop{border-top-color:#FF0000;}
28
-
29
- /*** palette button ***/
30
- ._wColorPicker_buttonHolder{display:inline-block; cursor:pointer;}
31
- ._wColorPicker_buttonBorder{border:solid #9A9A9A 1px; border-radius:5px;}
32
- ._wColorPicker_buttonColor{margin:2px; border-radius:4px;}
33
- ._wColorPicker_paletteHolder{z-index:999999;}
34
-
35
- /*** colors ***/
36
- ._wColorPicker_red, ._wColorPicker_red ._wColorPicker_outer{border-color:#CE6F6F;}
37
- ._wColorPicker_red ._wColorPicker_bg{background-color:#F79992;}
38
- ._wColorPicker_red ._wColorPicker_inner{color:#9C2F2F;}
39
-
40
- ._wColorPicker_green, ._wColorPicker_green ._wColorPicker_outer{border-color:#A9DB66;}
41
- ._wColorPicker_green ._wColorPicker_bg{background-color:#CDE6AC;}
42
- ._wColorPicker_green ._wColorPicker_inner{color:#58792E;}
43
-
44
- ._wColorPicker_blue, ._wColorPicker_blue ._wColorPicker_outer{border-color:#ADD9ED;}
45
- ._wColorPicker_blue ._wColorPicker_bg{background-color:#E5F6FE;}
46
- ._wColorPicker_blue ._wColorPicker_inner{color:#4D9FBF;}
47
-
48
- ._wColorPicker_white, ._wColorPicker_white ._wColorPicker_outer{border-color:#E2E2E2;}
49
- ._wColorPicker_white ._wColorPicker_bg{ background-color:#FFFFFF;}
50
- ._wColorPicker_white ._wColorPicker_inner{color:#454545;}
51
-
52
- ._wColorPicker_black, ._wColorPicker_black ._wColorPicker_outer{border-color:#303030;}
53
- ._wColorPicker_black ._wColorPicker_bg{background-color:#505050;}
54
- ._wColorPicker_black ._wColorPicker_inner{color:#F3F3F3;}
55
-
56
- ._wColorPicker_cream, ._wColorPicker_cream ._wColorPicker_outer{border-color:#F9E98E;}
57
- ._wColorPicker_cream ._wColorPicker_bg{background-color:#FBF7AA;}
58
- ._wColorPicker_cream ._wColorPicker_inner{color: #A27D35;}
59
-
60
- ._wColorPicker_yellow, ._wColorPicker_yellow ._wColorPicker_outer{border-color:#E9D315;}
61
- ._wColorPicker_yellow ._wColorPicker_bg{background-color:#F9F2BA;}
62
- ._wColorPicker_yellow ._wColorPicker_inner{color:#5B5316;}
63
-
64
- ._wColorPicker_orange, ._wColorPicker_orange ._wColorPicker_outer{border-color:#E56717;}
65
- ._wColorPicker_orange ._wColorPicker_bg{background-color:#F87217;}
66
- ._wColorPicker_orange ._wColorPicker_inner{color:#9C2F2F;}
67
-
68
- ._wColorPicker_plum, ._wColorPicker_plum ._wColorPicker_outer{border-color:#7E354D;}
69
- ._wColorPicker_plum ._wColorPicker_bg{background-color:#B93B8F;}
70
- ._wColorPicker_plum ._wColorPicker_inner{color:#F9B7FF;}