From ce2cbc6372688072b14b7e955ad85c38029cc4fa Mon Sep 17 00:00:00 2001 From: Adil Houmadi Date: Thu, 19 Feb 2015 13:37:34 +0100 Subject: [PATCH 01/10] [IMP] : - Rename the module to web_widget_color - Remove special type (Color) and use (Char) instead of. --- web_widget_color/README.rst | 104 ++ web_widget_color/__init__.py | 25 + web_widget_color/__openerp__.py | 44 + web_widget_color/images/form_view.png | Bin 0 -> 1826 bytes web_widget_color/images/list_view.png | Bin 0 -> 13773 bytes web_widget_color/images/picker.png | Bin 0 -> 5998 bytes web_widget_color/static/description/icon.png | Bin 0 -> 3454 bytes web_widget_color/static/lib/jscolor/arrow.gif | Bin 0 -> 66 bytes web_widget_color/static/lib/jscolor/cross.gif | Bin 0 -> 83 bytes web_widget_color/static/lib/jscolor/demo.html | 12 + web_widget_color/static/lib/jscolor/hs.png | Bin 0 -> 2684 bytes web_widget_color/static/lib/jscolor/hv.png | Bin 0 -> 2865 bytes .../static/lib/jscolor/jscolor.js | 1010 +++++++++++++++++ web_widget_color/static/src/css/widget.css | 23 + web_widget_color/static/src/js/widget.js | 59 + web_widget_color/static/src/xml/widget.xml | 24 + .../view/web_widget_color_view.xml | 12 + 17 files changed, 1313 insertions(+) create mode 100644 web_widget_color/README.rst create mode 100644 web_widget_color/__init__.py create mode 100644 web_widget_color/__openerp__.py create mode 100644 web_widget_color/images/form_view.png create mode 100644 web_widget_color/images/list_view.png create mode 100644 web_widget_color/images/picker.png create mode 100644 web_widget_color/static/description/icon.png create mode 100644 web_widget_color/static/lib/jscolor/arrow.gif create mode 100644 web_widget_color/static/lib/jscolor/cross.gif create mode 100644 web_widget_color/static/lib/jscolor/demo.html create mode 100644 web_widget_color/static/lib/jscolor/hs.png create mode 100644 web_widget_color/static/lib/jscolor/hv.png create mode 100644 web_widget_color/static/lib/jscolor/jscolor.js create mode 100644 web_widget_color/static/src/css/widget.css create mode 100644 web_widget_color/static/src/js/widget.js create mode 100644 web_widget_color/static/src/xml/widget.xml create mode 100644 web_widget_color/view/web_widget_color_view.xml diff --git a/web_widget_color/README.rst b/web_widget_color/README.rst new file mode 100644 index 00000000..a163f899 --- /dev/null +++ b/web_widget_color/README.rst @@ -0,0 +1,104 @@ +Color widget for Odoo web client +================================ + +This module aims to add a color picker to Odoo. + +It's a `jsColor `_ lib integration. + + +Features +======== + +* The picker allow the user to quickly select a color on edit mode + + |picker| + + .. note:: + + Notice how html code and the background color is updating when selecting a color. + + +* Display the color on form view when you are not editing it + + |formview| + +* Display the color on list view to quickly find what's wrong! + + |listview| + + +Requirements +============ + +This module has been ported to 8.0 + + +Usage +===== + +You need to declare a char field of at least size 7:: + + _columns = { + 'color': fields.char( + u"Couleur", + help=u"Toutes couleur valid css, exemple blue ou #f57900" + ), + } + + OR + + color = fields.Char( + string="Color", + help="Choose your color" + ) + + +In the view declaration, put widget='color' attribute in the field tag:: + + ... + + + ... + + + ... + + + ... + +.. |picker| image:: ./images/picker.png +.. |formview| image:: ./images/form_view.png +.. |listview| image:: ./images/list_view.png + + +Bug Tracker +=========== + +Bugs are tracked on `GitHub Issues `_. +In case of trouble, please check there if your issue has already been reported. +If you spotted it first, help us smashing it by providing a detailed and welcomed feedback +`here `_. + + +Credits +======= + +Contributors +------------ + +* Adil Houmadi + +Maintainer +---------- + +.. image:: http://odoo-community.org/logo.png + :alt: Odoo Community Association + :target: http://odoo-community.org + +This module is maintained by the OCA. + +OCA, or the Odoo Community Association, is a nonprofit organization whose +mission is to support the collaborative development of Odoo features and +promote its widespread use. + +To contribute to this module, please visit http://odoo-community.org. diff --git a/web_widget_color/__init__.py b/web_widget_color/__init__.py new file mode 100644 index 00000000..c18661e9 --- /dev/null +++ b/web_widget_color/__init__.py @@ -0,0 +1,25 @@ +# -*- encoding: utf-8 -*- +############################################################################ +# +# Odoo, Open Source Web Color +# Copyright (C) 2012 Savoir-faire Linux (). +# Copyright (C) 2014 Anybox +# Copyright (C) 2015 Taktik SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# @author Étienne Beaudry Auger +# @author Adil Houmadi +# +############################################################################## diff --git a/web_widget_color/__openerp__.py b/web_widget_color/__openerp__.py new file mode 100644 index 00000000..50838cc8 --- /dev/null +++ b/web_widget_color/__openerp__.py @@ -0,0 +1,44 @@ +# -*- encoding: utf-8 -*- +############################################################################ +# +# Odoo, Open Source Web Widget Color +# Copyright (C) 2012 Savoir-faire Linux (). +# Copyright (C) 2014 Anybox +# Copyright (C) 2015 Taktik SA +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# @author Étienne Beaudry Auger +# @author Adil Houmadi +# +############################################################################## +{ + 'name': "Web Widget Color", + 'category': "web", + 'version': "8.0.1.0.0", + "author": "Savoir-faire Linux, " + "Anybox, " + "Taktik SA, " + "Odoo Community Association (OCA)", + 'depends': ['base', 'web'], + 'data': [ + 'view/web_widget_color_view.xml' + ], + 'qweb': [ + 'static/src/xml/widget.xml', + ], + 'auto_install': False, + 'installable': True, + 'web_preload': True, +} diff --git a/web_widget_color/images/form_view.png b/web_widget_color/images/form_view.png new file mode 100644 index 0000000000000000000000000000000000000000..db1026b949db66d3d1d447af5316c69de7cc40db GIT binary patch literal 1826 zcmah~doD4PB-gRLN!ud3B`(_ zeZ{p~8)?whr5bmQmL=4+m!NHkXhZGSowGl7&U@aS=RCLXr?xMUsC{DRO5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0=)EA32MTF+2 zBq<+OZ7>Xz&4sm-v5HDrdqMjJM|c^V%Vqt%_uE!fz!z;>DB~OcR(w9+$;IVV(^2qn zKv!R%Cs%tNEgSEa_Nh~a**Gdg9V=#Xfn3yYHMq46w;NIm7L$cDWWIm z6ML>OuU$iDWO#s81VyAil>1{pxnymzS}=bqJp6}=34*-Os^isY4L4=Q^3b6}AkUcj z`G`uQkFRe92!Hm&2Qtai8Zj(&PXf~WtG<^nYZbB4R4R4iqUhumY*tnl7~V1cFk388 zQ&$IZKFSH1nVE4-e*1j?-7SI~;o(tQU=zGrJCAiE?y7W_3i=WiXB8l48!oJ#o@A^-m}{|~R|qcVFVTEEIa;tTLM0}gxp KqwBrGfBX}-*=$_^ literal 0 HcmV?d00001 diff --git a/web_widget_color/images/list_view.png b/web_widget_color/images/list_view.png new file mode 100644 index 0000000000000000000000000000000000000000..f4965fd5e97f4a4e4b562dabcb6c001ffcc97d57 GIT binary patch literal 13773 zcmdUWbzD_lx9$d%kQOARUjb6Tf-*fJ{_xsMhzx(I?iR@U5wdb5`%rTzl8P9%kUsWFe3e^<^0)c-|K}G|CKo^4N zKd~|4_f4#%uke6rrX(+eI7j_UZ_JH_cW@jPbe|#+xFo3mXo#d_3V0LC<(`Tx)+9DH z5djzeNly#{L65j6BdO&vx|ZT;ptW~)Zfs>aatTfH@|~9&1AKQ9##M+kHF3V*kv6#f zW6iB->`#)OZ`D{&dH>Z$h1cje-vk*E}-h>o) z>~DA_3v-|6z9sh@`E&~{?4+U|iHqan!}Ee!!~4^WN6cfgOZUC(S-bQ%J*sV^YaziP`j_L{iuctv4`eY$c=19)#vtC*@ezHR)Tb zy)yS&>GV*F`1_s7`Z{%;w)8faUxNvu(V4cx1a=rqaE&lzdZ`t&c|>;{yG~8}#V4Hx zs=Cs=es{+fQ(V0H1pQJC&!xI>wOuYDX3v?PxLAV&U z(~?B!X9CpN41{`757(KYcKfZ+kdXIzd3oCL zl;q@Ch`0O>v|fA57I!%X1rz0yh@{pr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G<}9;w6#rasxQ218jeC1#=5K=uJZ{jp1T~J* zb>B_)wzbxn>umiNosZv(^4!m2&}f)Z@Vw}yspSG@V9Nfu_i$>5-UwUV@QlFc@M-Ied!p8o#_ZaU)ugyitj6;Hh|2JQoi^b8f z)q_U#T6l5NE>)3b6#>^VPB_l{uW~#uIQakP#mSloL!vrC+rp=kY0Fw_Nghs g$1B$F@Y{_41yuss%Nc1x5&!@I07*qoM6N<$g0nBi^Z)<= literal 0 HcmV?d00001 diff --git a/web_widget_color/static/lib/jscolor/arrow.gif b/web_widget_color/static/lib/jscolor/arrow.gif new file mode 100644 index 0000000000000000000000000000000000000000..246478a864f812d93d4cd0e0d0ad1c8e2d09c825 GIT binary patch literal 66 zcmZ?wbhEHbWM|-JSjfZx1poj4Utv=LM2bII7`Ygj7<53QAbAERVV@R>f}L*~a`L;Z PKCZl?^}@uHk--`OML81Y literal 0 HcmV?d00001 diff --git a/web_widget_color/static/lib/jscolor/cross.gif b/web_widget_color/static/lib/jscolor/cross.gif new file mode 100644 index 0000000000000000000000000000000000000000..0ee9c7ac517bee40b78aea03afa809631f0b69fa GIT binary patch literal 83 zcmZ?wbhEHb + + jscolor demo + + + + + + Click here: + + + diff --git a/web_widget_color/static/lib/jscolor/hs.png b/web_widget_color/static/lib/jscolor/hs.png new file mode 100644 index 0000000000000000000000000000000000000000..3d94486cedaf7111d010fdaf2cefad45fd1f878b GIT binary patch literal 2684 zcmXArc_0(~AIBXrHY{E4t*qoJ#GWM;%`sPsQg|ZI9OX`l9COTa&5?Dua<6nb(vY&6 z6?>3k<8jPQJQ=fuv5eVo^ZVob{r>y?yxzz6n|{I3RuQNUl#q~6w6{Y!i_W*AbzM$M zv?qg)_ee+pt?W@2m!pR{B_p?CM-{APX1sq0k!v%Dx?=2xC6f&jlZz_Dn#dT_Y>InI z6zGP*0qIZBM5F|EZW=wONLxZCI;oxx8efxF<=55NtkzwRuA@S|$OSZUS~0 zbSDgzxPwEAll?BgdT}XWOAZOcMD`pUO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Y5ieq)J$^evnrYxC3DF5rA^JvXg$)Z@TW4d~?c5Fm1;n8+WV9n3A zREIvTfx}B&q+1AP^S|orTG__8w)t@5vGN(1#THk!CKLHp`#)!zH7z`x^Y2abdkC%N zVpo9#I|*N>2gAEStK;2nH>2-d8UgV}Ce62}O-VSnpIx1GP7~)f>xpwmI^Gq>t9ccs zdo47kYWW=g+WUVuK=)o4jL>*SZet8NcRq)42(#4#7K&?jfMC8bH5#uho9aCC9Sc8| z&eN*3Xr9L%twp11piU_UMd7cxt!d0dy(tNJ+3&*_^j;1X9gV|DYj@pg2={0^wT+T5 z?Xw4UzW(|>jIRGsKJaB+PUaLZQP!rJ26J1VGh%$e>x-WKf|{S*YSJH@EETJjsGMoT zZ6{6eiS3#V@YL5Z@Hgy9@bEpRGI;>Z_}tQa8IhV#m14ak_?Dm8Rb(N8c>8!Bbg8nV z@Fnflx2C1NJLL_>Z|O7~CV@n+T&C@vpgqh~t(`X)qaj=ypFdgdNZsNlmAwU7;S#iO z`J>RxSlI>*l1c;-I(BztG~ID9hmZHLX}mTDprkNW`2*nM`NCrG^K)aoYd*>U5=8}T zz<8Trh(5#1==-ntBY@u7k%!+X7o>B<{Wf^*@YzUESz$bKtAufemd7|St0063A+%|% YzFqsNg>|5V=vOIWZ|#VBZRvIQe;Bk#LI3~& literal 0 HcmV?d00001 diff --git a/web_widget_color/static/lib/jscolor/hv.png b/web_widget_color/static/lib/jscolor/hv.png new file mode 100644 index 0000000000000000000000000000000000000000..1c5e01f8bcecc4cf835e8eeeaa43ef2c06789022 GIT binary patch literal 2865 zcmX9=3pmqV7@teXHB3Y-6(VIKN(`gs(lEJ2EJSn5Crm8<3KhyeDHUOICnT3LV_lSr zSZ;GyqBJp=+1PCR_SJKqbI$X;=RD_m-{1TDz3)kPaYD#Qs!D=DAQ^i*TUWu}ESNzO z!h$tb?&uc~NOHs8*4pjL*kZxr-PxxyX>x_gxykAYer+%xw7GJL6<~$lv;J_uukT@e zT+7b}$(pn*(JJ8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B+Y!@Lhy1GSwWwEi=Q+}{?yp8BIm>I-u0&;G(EAzl`dWB zRwuQl%yBKwtv`^NR}gNuzg>8Y(x1DoZboBm7h9&Lhd6FL<64*y8ZDcoR+2S>La>P{ zdT}{ovrGh|#CyWM!R~Nh2aG>ZjO+}-icsKGb<8`S26!F3nT0k<6$)RZuei(y1^m-V z`FzfUFvRX2AB~LzUAD`t4sh4+X?+2kj20+cq*#lahA)7AosJ-k#=;GD*U}97uFLKj zo^@6(zQe&aeK^$2IN*IzWO-uxdlY3#5IvJ?Va5_yC8^$xf6c)Wz8!vpPzq^I#s8-J zYyM?GrR0`h}1un-M;JJa=H9Ncb^MF#<$~pqrt4epF8nadCmVNKJuIWM9YdYW&cwO1A~wUN zrd-jpV#03i+W0W%1&nO}Uy!h7u>^0`~OuH_{)(AjBe;hsQ!*)mO_DzpGRC zyox}(f&d2Gpi6^iw#eB7bVT;3FFa@cC>tM0 zh`Tj?={tK()4_woqpfX-$RrW>1rj>)NVFkyuySiiw7RSW_`4Px7jCb2c4SAc`*^t$*(d zB&ak&1Rbch68*E0=N1vmji9yfXFnH>R$*ue>|7dPIO)*efxInfOwf5~K+Ou1gVxLJ znHJS9zagvG#*KbWDL=8YuMi#xgFQZk9Mq{0A}gF)8u?-xvaEZdtqyUFRTrLq*p?!~??u&DrIz2ow@FRy0XX+-+%7G>uU0&kTN1W1G| zr>H6)4|9Ji%2`d{EBb%`9?5PNx968;9+OmY4|DC?&+M;;jN=L6in4xY&Q$twq0QFAeZuQ15|q?2tO{QUL* E0LKozl>h($ literal 0 HcmV?d00001 diff --git a/web_widget_color/static/lib/jscolor/jscolor.js b/web_widget_color/static/lib/jscolor/jscolor.js new file mode 100644 index 00000000..d56e1839 --- /dev/null +++ b/web_widget_color/static/lib/jscolor/jscolor.js @@ -0,0 +1,1010 @@ +/** + * jscolor, JavaScript Color Picker + * + * @version 1.4.4 + * @license GNU Lesser General Public License, http://www.gnu.org/copyleft/lesser.html + * @author Jan Odvarko, http://odvarko.cz + * @created 2008-06-15 + * @updated 2014-12-09 + * @link http://jscolor.com + */ + + +var jscolor = { + + + dir : '', // location of jscolor directory (leave empty to autodetect) + bindClass : 'color', // class name + binding : true, // automatic binding via + preloading : true, // use image preloading? + + + install : function() { + jscolor.addEvent(window, 'load', jscolor.init); + }, + + + init : function() { + if(jscolor.binding) { + jscolor.bind(); + } + if(jscolor.preloading) { + jscolor.preload(); + } + }, + + + getDir : function() { + if(!jscolor.dir) { + var detected = jscolor.detectDir(); + jscolor.dir = detected!==false ? detected : 'jscolor/'; + } + return jscolor.dir; + }, + + + detectDir : function() { + var base = location.href; + + var e = document.getElementsByTagName('base'); + for(var i=0; i vs[a] ? + (-vp[a]+tp[a]+ts[a]/2 > vs[a]/2 && tp[a]+ts[a]-ps[a] >= 0 ? tp[a]+ts[a]-ps[a] : tp[a]) : + tp[a], + -vp[b]+tp[b]+ts[b]+ps[b]-l+l*c > vs[b] ? + (-vp[b]+tp[b]+ts[b]/2 > vs[b]/2 && tp[b]+ts[b]-l-l*c >= 0 ? tp[b]+ts[b]-l-l*c : tp[b]+ts[b]-l+l*c) : + (tp[b]+ts[b]-l+l*c >= 0 ? tp[b]+ts[b]-l+l*c : tp[b]+ts[b]-l-l*c) + ]; + } + drawPicker(pp[a], pp[b]); + } + }; + + + this.importColor = function() { + if(!valueElement) { + this.exportColor(); + } else { + if(!this.adjust) { + if(!this.fromString(valueElement.value, leaveValue)) { + styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage; + styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor; + styleElement.style.color = styleElement.jscStyle.color; + this.exportColor(leaveValue | leaveStyle); + } + } else if(!this.required && /^\s*$/.test(valueElement.value)) { + valueElement.value = ''; + styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage; + styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor; + styleElement.style.color = styleElement.jscStyle.color; + this.exportColor(leaveValue | leaveStyle); + + } else if(this.fromString(valueElement.value)) { + // OK + } else { + this.exportColor(); + } + } + }; + + + this.exportColor = function(flags) { + if(!(flags & leaveValue) && valueElement) { + var value = this.toString(); + if(this.caps) { value = value.toUpperCase(); } + if(this.hash) { value = '#'+value; } + valueElement.value = value; + } + if(!(flags & leaveStyle) && styleElement) { + styleElement.style.backgroundImage = "none"; + styleElement.style.backgroundColor = + '#'+this.toString(); + styleElement.style.color = + 0.213 * this.rgb[0] + + 0.715 * this.rgb[1] + + 0.072 * this.rgb[2] + < 0.5 ? '#FFF' : '#000'; + } + if(!(flags & leavePad) && isPickerOwner()) { + redrawPad(); + } + if(!(flags & leaveSld) && isPickerOwner()) { + redrawSld(); + } + }; + + + this.fromHSV = function(h, s, v, flags) { // null = don't change + if(h !== null) { h = Math.max(0.0, this.minH, Math.min(6.0, this.maxH, h)); } + if(s !== null) { s = Math.max(0.0, this.minS, Math.min(1.0, this.maxS, s)); } + if(v !== null) { v = Math.max(0.0, this.minV, Math.min(1.0, this.maxV, v)); } + + this.rgb = HSV_RGB( + h===null ? this.hsv[0] : (this.hsv[0]=h), + s===null ? this.hsv[1] : (this.hsv[1]=s), + v===null ? this.hsv[2] : (this.hsv[2]=v) + ); + + this.exportColor(flags); + }; + + + this.fromRGB = function(r, g, b, flags) { // null = don't change + if(r !== null) { r = Math.max(0.0, Math.min(1.0, r)); } + if(g !== null) { g = Math.max(0.0, Math.min(1.0, g)); } + if(b !== null) { b = Math.max(0.0, Math.min(1.0, b)); } + + var hsv = RGB_HSV( + r===null ? this.rgb[0] : r, + g===null ? this.rgb[1] : g, + b===null ? this.rgb[2] : b + ); + if(hsv[0] !== null) { + this.hsv[0] = Math.max(0.0, this.minH, Math.min(6.0, this.maxH, hsv[0])); + } + if(hsv[2] !== 0) { + this.hsv[1] = hsv[1]===null ? null : Math.max(0.0, this.minS, Math.min(1.0, this.maxS, hsv[1])); + } + this.hsv[2] = hsv[2]===null ? null : Math.max(0.0, this.minV, Math.min(1.0, this.maxV, hsv[2])); + + // update RGB according to final HSV, as some values might be trimmed + var rgb = HSV_RGB(this.hsv[0], this.hsv[1], this.hsv[2]); + this.rgb[0] = rgb[0]; + this.rgb[1] = rgb[1]; + this.rgb[2] = rgb[2]; + + this.exportColor(flags); + }; + + + this.fromString = function(hex, flags) { + var m = hex.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i); + if(!m) { + return false; + } else { + if(m[1].length === 6) { // 6-char notation + this.fromRGB( + parseInt(m[1].substr(0,2),16) / 255, + parseInt(m[1].substr(2,2),16) / 255, + parseInt(m[1].substr(4,2),16) / 255, + flags + ); + } else { // 3-char notation + this.fromRGB( + parseInt(m[1].charAt(0)+m[1].charAt(0),16) / 255, + parseInt(m[1].charAt(1)+m[1].charAt(1),16) / 255, + parseInt(m[1].charAt(2)+m[1].charAt(2),16) / 255, + flags + ); + } + return true; + } + }; + + + this.toString = function() { + return ( + (0x100 | Math.round(255*this.rgb[0])).toString(16).substr(1) + + (0x100 | Math.round(255*this.rgb[1])).toString(16).substr(1) + + (0x100 | Math.round(255*this.rgb[2])).toString(16).substr(1) + ); + }; + + + function RGB_HSV(r, g, b) { + var n = Math.min(Math.min(r,g),b); + var v = Math.max(Math.max(r,g),b); + var m = v - n; + if(m === 0) { return [ null, 0, v ]; } + var h = r===n ? 3+(b-g)/m : (g===n ? 5+(r-b)/m : 1+(g-r)/m); + return [ h===6?0:h, m/v, v ]; + } + + + function HSV_RGB(h, s, v) { + if(h === null) { return [ v, v, v ]; } + var i = Math.floor(h); + var f = i%2 ? h-i : 1-(h-i); + var m = v * (1 - s); + var n = v * (1 - s*f); + switch(i) { + case 6: + case 0: return [v,n,m]; + case 1: return [n,v,m]; + case 2: return [m,v,n]; + case 3: return [m,n,v]; + case 4: return [n,m,v]; + case 5: return [v,m,n]; + } + } + + + function removePicker() { + delete jscolor.picker.owner; + document.getElementsByTagName('body')[0].removeChild(jscolor.picker.boxB); + } + + + function drawPicker(x, y) { + if(!jscolor.picker) { + jscolor.picker = { + box : document.createElement('div'), + boxB : document.createElement('div'), + pad : document.createElement('div'), + padB : document.createElement('div'), + padM : document.createElement('div'), + sld : document.createElement('div'), + sldB : document.createElement('div'), + sldM : document.createElement('div'), + btn : document.createElement('div'), + btnS : document.createElement('span'), + btnT : document.createTextNode(THIS.pickerCloseText) + }; + for(var i=0,segSize=4; i 0) { + var val = $input.val(); + var isOk = /^#[0-9A-F]{6}$/i.test(val); + if (!isOk) { + return false; + } + try { + this.parse_value(this.$('input').val(), ''); + return true; + } catch (e) { + return false; + } + } + return true; + }, + render_value: function () { + var show_value = this.format_value(this.get('value'), ''); + if (!this.get("effective_readonly")) { + var $input = this.$el.find('input'); + $input.val(show_value); + $input.css("background-color", show_value) + jscolor.init(this.$el[0]); + } else { + this.$(".oe_form_char_content").text(show_value); + this.$('div').css("background-color", show_value) + } + } + }); + + /* + * Init jscolor for each editable mode on view form + */ + instance.web.FormView.include({ + to_edit_mode: function () { + this._super(); + jscolor.init(this.$el[0]); + } + }); +}; diff --git a/web_widget_color/static/src/xml/widget.xml b/web_widget_color/static/src/xml/widget.xml new file mode 100644 index 00000000..c62ae1cf --- /dev/null +++ b/web_widget_color/static/src/xml/widget.xml @@ -0,0 +1,24 @@ + + + + + + + + +
+ + + + + +
+ + diff --git a/web_widget_color/view/web_widget_color_view.xml b/web_widget_color/view/web_widget_color_view.xml new file mode 100644 index 00000000..7c2c8d0f --- /dev/null +++ b/web_widget_color/view/web_widget_color_view.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file From 85c08dac58380b19151005acce0ba17f3515d75c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Faure-Lacroix?= Date: Thu, 3 Dec 2015 21:06:37 +0300 Subject: [PATCH 02/10] Made web_widget_color installable and remove the search field. The search field doesn't seem to exist anymore --- web_widget_color/static/src/js/widget.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/web_widget_color/static/src/js/widget.js b/web_widget_color/static/src/js/widget.js index 44299752..5c2d2c21 100644 --- a/web_widget_color/static/src/js/widget.js +++ b/web_widget_color/static/src/js/widget.js @@ -11,8 +11,6 @@ openerp.web_widget_color = function (instance) { instance.web.form.widgets.add('color', 'instance.web.form.FieldColor'); - instance.web.search.fields.add('color', 'instance.web.search.CharField'); - instance.web.form.FieldColor = instance.web.form.FieldChar.extend({ template: 'FieldColor', widget_class: 'oe_form_field_color', From 2b5d7e83e3c2300e097098ce14ece9fdc2862918 Mon Sep 17 00:00:00 2001 From: Nicolas JEUDY Date: Wed, 13 Jan 2016 09:17:26 +0100 Subject: [PATCH 03/10] fix: update to new js api - Force store_dom_value - add clean colored square in tree view - update readme and __openerp__.py for maintainers --- web_widget_color/README.rst | 1 + web_widget_color/__openerp__.py | 1 + web_widget_color/static/src/css/widget.css | 7 ++++ web_widget_color/static/src/js/widget.js | 39 ++++++++++++++++++---- web_widget_color/static/src/xml/widget.xml | 2 +- 5 files changed, 43 insertions(+), 7 deletions(-) diff --git a/web_widget_color/README.rst b/web_widget_color/README.rst index a163f899..ad79a61a 100644 --- a/web_widget_color/README.rst +++ b/web_widget_color/README.rst @@ -87,6 +87,7 @@ Contributors ------------ * Adil Houmadi +* Nicolas JEUDY (Sudokeys) Maintainer ---------- diff --git a/web_widget_color/__openerp__.py b/web_widget_color/__openerp__.py index 50838cc8..74e7a798 100644 --- a/web_widget_color/__openerp__.py +++ b/web_widget_color/__openerp__.py @@ -30,6 +30,7 @@ "author": "Savoir-faire Linux, " "Anybox, " "Taktik SA, " + "Sudokeys, " "Odoo Community Association (OCA)", 'depends': ['base', 'web'], 'data': [ diff --git a/web_widget_color/static/src/css/widget.css b/web_widget_color/static/src/css/widget.css index 06201af1..9a701ad1 100644 --- a/web_widget_color/static/src/css/widget.css +++ b/web_widget_color/static/src/css/widget.css @@ -21,3 +21,10 @@ top: 3px; width: 40px; } + +.color_box { + width: 10px; + height: 10px; + display: inline-block; + margin-right: 5px; +} diff --git a/web_widget_color/static/src/js/widget.js b/web_widget_color/static/src/js/widget.js index 5c2d2c21..aad55279 100644 --- a/web_widget_color/static/src/js/widget.js +++ b/web_widget_color/static/src/js/widget.js @@ -1,4 +1,12 @@ -openerp.web_widget_color = function (instance) { +odoo.define('web.web_widget_color', function(require) { + "use strict"; + + var core = require('web.core'); + var widget = require('web.form_widgets'); + var FormView = require('web.FormView'); + + var QWeb = core.qweb; + var _lt = core._lt; var _super_getDir = jscolor.getDir.prototype; jscolor.getDir = function () { @@ -9,9 +17,7 @@ openerp.web_widget_color = function (instance) { return jscolor.dir; }; - instance.web.form.widgets.add('color', 'instance.web.form.FieldColor'); - - instance.web.form.FieldColor = instance.web.form.FieldChar.extend({ + var FieldColor = widget.FieldChar.extend({ template: 'FieldColor', widget_class: 'oe_form_field_color', is_syntax_valid: function () { @@ -31,6 +37,21 @@ openerp.web_widget_color = function (instance) { } return true; }, + store_dom_value: function() { + if (!this.silent) { + if (!this.get('effective_readonly') && + this.$('input').val() !== '' && + this.is_syntax_valid()) { + // We use internal_set_value because we were called by + // ``.commit_value()`` which is called by a ``.set_value()`` + // itself called because of a ``onchange`` event + this.internal_set_value( + this.parse_value( + this.$('input').val()) + ); + } + } + }, render_value: function () { var show_value = this.format_value(this.get('value'), ''); if (!this.get("effective_readonly")) { @@ -45,13 +66,19 @@ openerp.web_widget_color = function (instance) { } }); + core.form_widget_registry.add('color', FieldColor); + /* * Init jscolor for each editable mode on view form */ - instance.web.FormView.include({ + FormView.include({ to_edit_mode: function () { this._super(); jscolor.init(this.$el[0]); } }); -}; + + return { + FieldColor: FieldColor + }; +}); diff --git a/web_widget_color/static/src/xml/widget.xml b/web_widget_color/static/src/xml/widget.xml index c62ae1cf..82c043b4 100644 --- a/web_widget_color/static/src/xml/widget.xml +++ b/web_widget_color/static/src/xml/widget.xml @@ -19,6 +19,6 @@ -
+
From ff4d9d225eb4662676b07e4333facfed85de1dd4 Mon Sep 17 00:00:00 2001 From: Alexandre Fayolle Date: Tue, 9 Aug 2016 09:47:43 +0200 Subject: [PATCH 04/10] short headers, bump up version number --- web_widget_color/README.rst | 6 ----- web_widget_color/__init__.py | 25 +------------------ web_widget_color/__openerp__.py | 25 +++---------------- web_widget_color/static/src/js/widget.js | 4 +-- .../view/web_widget_color_view.xml | 20 +++++++-------- 5 files changed, 16 insertions(+), 64 deletions(-) diff --git a/web_widget_color/README.rst b/web_widget_color/README.rst index ad79a61a..5cf105a9 100644 --- a/web_widget_color/README.rst +++ b/web_widget_color/README.rst @@ -27,12 +27,6 @@ Features |listview| -Requirements -============ - -This module has been ported to 8.0 - - Usage ===== diff --git a/web_widget_color/__init__.py b/web_widget_color/__init__.py index c18661e9..ec51c5a2 100644 --- a/web_widget_color/__init__.py +++ b/web_widget_color/__init__.py @@ -1,25 +1,2 @@ -# -*- encoding: utf-8 -*- -############################################################################ +# -*- coding: utf-8 -*- # -# Odoo, Open Source Web Color -# Copyright (C) 2012 Savoir-faire Linux (). -# Copyright (C) 2014 Anybox -# Copyright (C) 2015 Taktik SA -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# @author Étienne Beaudry Auger -# @author Adil Houmadi -# -############################################################################## diff --git a/web_widget_color/__openerp__.py b/web_widget_color/__openerp__.py index 74e7a798..3f2298bf 100644 --- a/web_widget_color/__openerp__.py +++ b/web_widget_color/__openerp__.py @@ -1,32 +1,14 @@ -# -*- encoding: utf-8 -*- -############################################################################ -# +# -*- coding: utf-8 -*- # Odoo, Open Source Web Widget Color # Copyright (C) 2012 Savoir-faire Linux (). # Copyright (C) 2014 Anybox # Copyright (C) 2015 Taktik SA # -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . -# -# @author Étienne Beaudry Auger -# @author Adil Houmadi -# -############################################################################## +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).# { 'name': "Web Widget Color", 'category': "web", - 'version': "8.0.1.0.0", + 'version': "9.0.1.0.0", "author": "Savoir-faire Linux, " "Anybox, " "Taktik SA, " @@ -39,6 +21,7 @@ 'qweb': [ 'static/src/xml/widget.xml', ], + 'license': 'AGPL-3', 'auto_install': False, 'installable': True, 'web_preload': True, diff --git a/web_widget_color/static/src/js/widget.js b/web_widget_color/static/src/js/widget.js index aad55279..548eb7a4 100644 --- a/web_widget_color/static/src/js/widget.js +++ b/web_widget_color/static/src/js/widget.js @@ -57,11 +57,11 @@ odoo.define('web.web_widget_color', function(require) { if (!this.get("effective_readonly")) { var $input = this.$el.find('input'); $input.val(show_value); - $input.css("background-color", show_value) + $input.css("background-color", show_value); jscolor.init(this.$el[0]); } else { this.$(".oe_form_char_content").text(show_value); - this.$('div').css("background-color", show_value) + this.$('div').css("background-color", show_value); } } }); diff --git a/web_widget_color/view/web_widget_color_view.xml b/web_widget_color/view/web_widget_color_view.xml index 7c2c8d0f..82300a00 100644 --- a/web_widget_color/view/web_widget_color_view.xml +++ b/web_widget_color/view/web_widget_color_view.xml @@ -1,12 +1,10 @@ - - - - - \ No newline at end of file + + + From 174b3094918ad2c73ffd09f7e57110028b8b54b9 Mon Sep 17 00:00:00 2001 From: "Adrien Peiffer (ACSONE)" Date: Wed, 12 Oct 2016 10:54:45 +0200 Subject: [PATCH 05/10] Migration of web_widget_color to 10.0 (#439) [MIG] web_widget_color: Migration to 10.0 --- web_widget_color/README.rst | 18 ++++++++++-------- .../{__openerp__.py => __manifest__.py} | 2 +- web_widget_color/static/src/js/widget.js | 8 ++++++-- 3 files changed, 17 insertions(+), 11 deletions(-) rename web_widget_color/{__openerp__.py => __manifest__.py} (96%) diff --git a/web_widget_color/README.rst b/web_widget_color/README.rst index 5cf105a9..dfa955c3 100644 --- a/web_widget_color/README.rst +++ b/web_widget_color/README.rst @@ -64,15 +64,17 @@ In the view declaration, put widget='color' attribute in the field tag:: .. |formview| image:: ./images/form_view.png .. |listview| image:: ./images/list_view.png +.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas + :alt: Try me on Runbot + :target: https://runbot.odoo-community.org/runbot/162/10.0 Bug Tracker =========== -Bugs are tracked on `GitHub Issues `_. -In case of trouble, please check there if your issue has already been reported. -If you spotted it first, help us smashing it by providing a detailed and welcomed feedback -`here `_. - +Bugs are tracked on `GitHub Issues +`_. In case of trouble, please +check there if your issue has already been reported. If you spotted it first, +help us smashing it by providing a detailed and welcomed feedback. Credits ======= @@ -86,9 +88,9 @@ Contributors Maintainer ---------- -.. image:: http://odoo-community.org/logo.png +.. image:: https://odoo-community.org/logo.png :alt: Odoo Community Association - :target: http://odoo-community.org + :target: https://odoo-community.org This module is maintained by the OCA. @@ -96,4 +98,4 @@ OCA, or the Odoo Community Association, is a nonprofit organization whose mission is to support the collaborative development of Odoo features and promote its widespread use. -To contribute to this module, please visit http://odoo-community.org. +To contribute to this module, please visit https://odoo-community.org. diff --git a/web_widget_color/__openerp__.py b/web_widget_color/__manifest__.py similarity index 96% rename from web_widget_color/__openerp__.py rename to web_widget_color/__manifest__.py index 3f2298bf..e90ef2d0 100644 --- a/web_widget_color/__openerp__.py +++ b/web_widget_color/__manifest__.py @@ -8,7 +8,7 @@ { 'name': "Web Widget Color", 'category': "web", - 'version': "9.0.1.0.0", + 'version': "10.0.1.0.0", "author": "Savoir-faire Linux, " "Anybox, " "Taktik SA, " diff --git a/web_widget_color/static/src/js/widget.js b/web_widget_color/static/src/js/widget.js index 548eb7a4..589ff364 100644 --- a/web_widget_color/static/src/js/widget.js +++ b/web_widget_color/static/src/js/widget.js @@ -61,7 +61,7 @@ odoo.define('web.web_widget_color', function(require) { jscolor.init(this.$el[0]); } else { this.$(".oe_form_char_content").text(show_value); - this.$('div').css("background-color", show_value); + this.$('span').css("background-color", show_value); } } }); @@ -72,7 +72,11 @@ odoo.define('web.web_widget_color', function(require) { * Init jscolor for each editable mode on view form */ FormView.include({ - to_edit_mode: function () { + on_button_edit: function () { + this._super(); + jscolor.init(this.$el[0]); + }, + on_button_create: function () { this._super(); jscolor.init(this.$el[0]); } From 44f14d3cac19ec76178eb104f133dac5c85dafa2 Mon Sep 17 00:00:00 2001 From: Enric Tobella Date: Mon, 23 Oct 2017 13:54:00 +0200 Subject: [PATCH 06/10] [MIG] web_widget_color: Migration to 11.0 --- web_widget_color/README.rst | 23 +++--- web_widget_color/__manifest__.py | 4 +- .../static/lib/jscolor/jscolor.js | 2 +- web_widget_color/static/src/js/widget.js | 77 +++++-------------- web_widget_color/static/src/xml/widget.xml | 16 ++-- 5 files changed, 42 insertions(+), 80 deletions(-) diff --git a/web_widget_color/README.rst b/web_widget_color/README.rst index dfa955c3..439c8fba 100644 --- a/web_widget_color/README.rst +++ b/web_widget_color/README.rst @@ -30,16 +30,7 @@ Features Usage ===== -You need to declare a char field of at least size 7:: - - _columns = { - 'color': fields.char( - u"Couleur", - help=u"Toutes couleur valid css, exemple blue ou #f57900" - ), - } - - OR +You need to declare a char field:: color = fields.Char( string="Color", @@ -53,12 +44,19 @@ In the view declaration, put widget='color' attribute in the field tag:: ... - ... ... + +
+ ... + + ... + +
+ ... .. |picker| image:: ./images/picker.png .. |formview| image:: ./images/form_view.png @@ -66,7 +64,7 @@ In the view declaration, put widget='color' attribute in the field tag:: .. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas :alt: Try me on Runbot - :target: https://runbot.odoo-community.org/runbot/162/10.0 + :target: https://runbot.odoo-community.org/runbot/162/11.0 Bug Tracker =========== @@ -83,6 +81,7 @@ Contributors ------------ * Adil Houmadi +* Enric Tobella * Nicolas JEUDY (Sudokeys) Maintainer diff --git a/web_widget_color/__manifest__.py b/web_widget_color/__manifest__.py index e90ef2d0..ebcd0f40 100644 --- a/web_widget_color/__manifest__.py +++ b/web_widget_color/__manifest__.py @@ -4,11 +4,11 @@ # Copyright (C) 2014 Anybox # Copyright (C) 2015 Taktik SA # -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).# +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).# { 'name': "Web Widget Color", 'category': "web", - 'version': "10.0.1.0.0", + 'version': "11.0.1.0.0", "author": "Savoir-faire Linux, " "Anybox, " "Taktik SA, " diff --git a/web_widget_color/static/lib/jscolor/jscolor.js b/web_widget_color/static/lib/jscolor/jscolor.js index d56e1839..659ab208 100644 --- a/web_widget_color/static/lib/jscolor/jscolor.js +++ b/web_widget_color/static/lib/jscolor/jscolor.js @@ -2,7 +2,7 @@ * jscolor, JavaScript Color Picker * * @version 1.4.4 - * @license GNU Lesser General Public License, http://www.gnu.org/copyleft/lesser.html + * @license GNU Lesser General Public License, https://www.gnu.org/copyleft/lesser.html * @author Jan Odvarko, http://odvarko.cz * @created 2008-06-15 * @updated 2014-12-09 diff --git a/web_widget_color/static/src/js/widget.js b/web_widget_color/static/src/js/widget.js index 589ff364..98a19c17 100644 --- a/web_widget_color/static/src/js/widget.js +++ b/web_widget_color/static/src/js/widget.js @@ -1,88 +1,53 @@ odoo.define('web.web_widget_color', function(require) { "use strict"; - var core = require('web.core'); - var widget = require('web.form_widgets'); - var FormView = require('web.FormView'); - - var QWeb = core.qweb; - var _lt = core._lt; + var basic_fields = require('web.basic_fields'); + var field_registry = require('web.field_registry'); + var FormController = require('web.FormController'); + var field_utils = require('web.field_utils'); var _super_getDir = jscolor.getDir.prototype; jscolor.getDir = function () { var dir = _super_getDir.constructor(); if (dir.indexOf('web_widget_color') === -1) { - jscolor.dir = 'web_widget_color/static/lib/jscolor/'; + jscolor.dir = '/web_widget_color/static/lib/jscolor/'; } return jscolor.dir; }; - var FieldColor = widget.FieldChar.extend({ + var FieldColor = basic_fields.FieldChar.extend({ template: 'FieldColor', widget_class: 'oe_form_field_color', - is_syntax_valid: function () { - var $input = this.$('input'); - if (!this.get("effective_readonly") && $input.size() > 0) { - var val = $input.val(); - var isOk = /^#[0-9A-F]{6}$/i.test(val); - if (!isOk) { - return false; - } - try { - this.parse_value(this.$('input').val(), ''); - return true; - } catch (e) { - return false; - } - } - return true; + _getValue: function() { + return field_utils.format.char(this.$('input').val()); }, - store_dom_value: function() { - if (!this.silent) { - if (!this.get('effective_readonly') && - this.$('input').val() !== '' && - this.is_syntax_valid()) { - // We use internal_set_value because we were called by - // ``.commit_value()`` which is called by a ``.set_value()`` - // itself called because of a ``onchange`` event - this.internal_set_value( - this.parse_value( - this.$('input').val()) - ); - } - } - }, - render_value: function () { - var show_value = this.format_value(this.get('value'), ''); - if (!this.get("effective_readonly")) { + _render: function () { + var show_value = field_utils.format.char(this.value); + jscolor.init(this.$el[0]); + if (this.mode !== 'readonly') { var $input = this.$el.find('input'); $input.val(show_value); $input.css("background-color", show_value); - jscolor.init(this.$el[0]); + this.$input = $input; + this.$(".oe_form_char_content").text(show_value); + this.$('span').css("background-color", show_value); } else { this.$(".oe_form_char_content").text(show_value); this.$('span').css("background-color", show_value); + } } }); - - core.form_widget_registry.add('color', FieldColor); + field_registry.add('color', FieldColor); /* * Init jscolor for each editable mode on view form */ - FormView.include({ - on_button_edit: function () { - this._super(); - jscolor.init(this.$el[0]); - }, - on_button_create: function () { - this._super(); + FormController.include({ + _updateEnv : function (parentID) { + this._super(parentID); jscolor.init(this.$el[0]); } }); - - return { - FieldColor: FieldColor - }; + return FieldColor }); diff --git a/web_widget_color/static/src/xml/widget.xml b/web_widget_color/static/src/xml/widget.xml index 82c043b4..6112ab43 100644 --- a/web_widget_color/static/src/xml/widget.xml +++ b/web_widget_color/static/src/xml/widget.xml @@ -1,18 +1,16 @@ - - + - - + class="color {hash:true} o_input" + t-if="widget.mode !== 'readonly'"/> +
From 2244f9133571edc94484917b78e7825c9d261a57 Mon Sep 17 00:00:00 2001 From: oca-travis Date: Sun, 24 Jun 2018 10:28:17 +0000 Subject: [PATCH 07/10] [UPD] Update web_widget_color.pot --- web_widget_color/i18n/web_widget_color.pot | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 web_widget_color/i18n/web_widget_color.pot diff --git a/web_widget_color/i18n/web_widget_color.pot b/web_widget_color/i18n/web_widget_color.pot new file mode 100644 index 00000000..447d3bb3 --- /dev/null +++ b/web_widget_color/i18n/web_widget_color.pot @@ -0,0 +1,14 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 11.0\n" +"Report-Msgid-Bugs-To: \n" +"Last-Translator: <>\n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: \n" +"Plural-Forms: \n" + From d167289bbcc609a1e87e0aaefbc79759bf555c22 Mon Sep 17 00:00:00 2001 From: QS5ELkMu Date: Tue, 7 Aug 2018 09:08:01 +0200 Subject: [PATCH 08/10] [IMP] web_widget_color: Refactor Module (#992) --- web_widget_color/__init__.py | 1 - web_widget_color/__manifest__.py | 2 +- web_widget_color/readme/CONTRIBUTORS.rst | 4 + web_widget_color/readme/DESCRIPTION.rst | 29 + web_widget_color/readme/USAGE.rst | 43 + web_widget_color/static/lib/jscolor/arrow.gif | Bin 66 -> 0 bytes web_widget_color/static/lib/jscolor/cross.gif | Bin 83 -> 0 bytes web_widget_color/static/lib/jscolor/demo.html | 12 - web_widget_color/static/lib/jscolor/hs.png | Bin 2684 -> 0 bytes web_widget_color/static/lib/jscolor/hv.png | Bin 2865 -> 0 bytes .../static/lib/jscolor/jscolor-example.html | 40 + .../static/lib/jscolor/jscolor.js | 2257 +++++++++++------ web_widget_color/static/src/css/widget.css | 30 - web_widget_color/static/src/js/widget.js | 67 +- web_widget_color/static/src/less/widget.less | 13 + web_widget_color/static/src/xml/widget.xml | 26 +- .../view/web_widget_color_view.xml | 2 +- 17 files changed, 1724 insertions(+), 802 deletions(-) create mode 100644 web_widget_color/readme/CONTRIBUTORS.rst create mode 100644 web_widget_color/readme/DESCRIPTION.rst create mode 100644 web_widget_color/readme/USAGE.rst delete mode 100644 web_widget_color/static/lib/jscolor/arrow.gif delete mode 100644 web_widget_color/static/lib/jscolor/cross.gif delete mode 100644 web_widget_color/static/lib/jscolor/demo.html delete mode 100644 web_widget_color/static/lib/jscolor/hs.png delete mode 100644 web_widget_color/static/lib/jscolor/hv.png create mode 100644 web_widget_color/static/lib/jscolor/jscolor-example.html delete mode 100644 web_widget_color/static/src/css/widget.css create mode 100644 web_widget_color/static/src/less/widget.less diff --git a/web_widget_color/__init__.py b/web_widget_color/__init__.py index ec51c5a2..792d6005 100644 --- a/web_widget_color/__init__.py +++ b/web_widget_color/__init__.py @@ -1,2 +1 @@ -# -*- coding: utf-8 -*- # diff --git a/web_widget_color/__manifest__.py b/web_widget_color/__manifest__.py index ebcd0f40..c808113c 100644 --- a/web_widget_color/__manifest__.py +++ b/web_widget_color/__manifest__.py @@ -1,8 +1,8 @@ -# -*- coding: utf-8 -*- # Odoo, Open Source Web Widget Color # Copyright (C) 2012 Savoir-faire Linux (). # Copyright (C) 2014 Anybox # Copyright (C) 2015 Taktik SA +# Copyright (C) 2018 Alexandre Díaz # # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).# { diff --git a/web_widget_color/readme/CONTRIBUTORS.rst b/web_widget_color/readme/CONTRIBUTORS.rst new file mode 100644 index 00000000..8dde46b4 --- /dev/null +++ b/web_widget_color/readme/CONTRIBUTORS.rst @@ -0,0 +1,4 @@ +* Adil Houmadi +* Enric Tobella +* Nicolas JEUDY (Sudokeys) +* Alexandre Díaz diff --git a/web_widget_color/readme/DESCRIPTION.rst b/web_widget_color/readme/DESCRIPTION.rst new file mode 100644 index 00000000..37f59486 --- /dev/null +++ b/web_widget_color/readme/DESCRIPTION.rst @@ -0,0 +1,29 @@ +This module aims to add a color picker to Odoo. + +It's a `jsColor `_ lib integration. + + +Features +======== + +* The picker allow the user to quickly select a color on edit mode + + |picker| + + .. note:: + + Notice how html code and the background color is updating when selecting a color. + + +* Display the color on form view when you are not editing it + + |formview| + +* Display the color on list view to quickly find what's wrong! + + |listview| + + +.. |picker| image:: ./images/picker.png +.. |formview| image:: ./images/form_view.png +.. |listview| image:: ./images/list_view.png diff --git a/web_widget_color/readme/USAGE.rst b/web_widget_color/readme/USAGE.rst new file mode 100644 index 00000000..9fa48220 --- /dev/null +++ b/web_widget_color/readme/USAGE.rst @@ -0,0 +1,43 @@ +You need to declare a char field:: + + color = fields.Char( + string="Color", + help="Choose your color" + ) + + +In the view declaration, put widget='color' attribute in the field tag:: + + ... + + + ... + + ... + + + ... + +
+ ... + + ... + +
+ ... + +Widget Options:: + + - readonly_mode + - 'default' > Color Box + text + - 'color' > Only Color Box + - 'text' > Only Text + ... + + + ... + + ... + + + ... diff --git a/web_widget_color/static/lib/jscolor/arrow.gif b/web_widget_color/static/lib/jscolor/arrow.gif deleted file mode 100644 index 246478a864f812d93d4cd0e0d0ad1c8e2d09c825..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 66 zcmZ?wbhEHbWM|-JSjfZx1poj4Utv=LM2bII7`Ygj7<53QAbAERVV@R>f}L*~a`L;Z PKCZl?^}@uHk--`OML81Y diff --git a/web_widget_color/static/lib/jscolor/cross.gif b/web_widget_color/static/lib/jscolor/cross.gif deleted file mode 100644 index 0ee9c7ac517bee40b78aea03afa809631f0b69fa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 83 zcmZ?wbhEHb - - jscolor demo - - - - - - Click here: - - - diff --git a/web_widget_color/static/lib/jscolor/hs.png b/web_widget_color/static/lib/jscolor/hs.png deleted file mode 100644 index 3d94486cedaf7111d010fdaf2cefad45fd1f878b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2684 zcmXArc_0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OmY4|DC?&+M;;jN=L6in4xY&Q$twq0QFAeZuQ15|q?2tO{QUL* E0LKozl>h($ diff --git a/web_widget_color/static/lib/jscolor/jscolor-example.html b/web_widget_color/static/lib/jscolor/jscolor-example.html new file mode 100644 index 00000000..99ba84f3 --- /dev/null +++ b/web_widget_color/static/lib/jscolor/jscolor-example.html @@ -0,0 +1,40 @@ + + + + jscolor Example + + + + + + + + + +

Example 1

+ Color: + + + +

Example 2

+ + + + HEX value: + + + + + +

Check out more examples at jscolor.com!

+ + + + + diff --git a/web_widget_color/static/lib/jscolor/jscolor.js b/web_widget_color/static/lib/jscolor/jscolor.js index 659ab208..e650a69b 100644 --- a/web_widget_color/static/lib/jscolor/jscolor.js +++ b/web_widget_color/static/lib/jscolor/jscolor.js @@ -1,477 +1,1152 @@ /** - * jscolor, JavaScript Color Picker + * jscolor - JavaScript Color Picker * - * @version 1.4.4 - * @license GNU Lesser General Public License, https://www.gnu.org/copyleft/lesser.html - * @author Jan Odvarko, http://odvarko.cz - * @created 2008-06-15 - * @updated 2014-12-09 * @link http://jscolor.com + * @license For open source use: GPLv3 + * For commercial use: JSColor Commercial License + * @author Jan Odvarko + * @version 2.0.5 + * + * See usage examples at http://jscolor.com/examples/ */ -var jscolor = { +"use strict"; + +if (!window.jscolor) { window.jscolor = (function () { - dir : '', // location of jscolor directory (leave empty to autodetect) - bindClass : 'color', // class name - binding : true, // automatic binding via - preloading : true, // use image preloading? +var jsc = { - install : function() { - jscolor.addEvent(window, 'load', jscolor.init); + + register : function () { + jsc.attachDOMReadyEvent(jsc.init); + jsc.attachEvent(document, 'mousedown', jsc.onDocumentMouseDown); + jsc.attachEvent(document, 'touchstart', jsc.onDocumentTouchStart); + jsc.attachEvent(window, 'resize', jsc.onWindowResize); }, - init : function() { - if(jscolor.binding) { - jscolor.bind(); + init : function () { + if (jsc.jscolor.lookupClass) { + jsc.jscolor.installByClassName(jsc.jscolor.lookupClass); } - if(jscolor.preloading) { - jscolor.preload(); + }, + + + tryInstallOnElements : function (elms, className) { + var matchClass = new RegExp('(^|\\s)(' + className + ')(\\s*(\\{[^}]*\\})|\\s|$)', 'i'); + + for (var i = 0; i < elms.length; i += 1) { + if (elms[i].type !== undefined && elms[i].type.toLowerCase() == 'color') { + if (jsc.isColorAttrSupported) { + // skip inputs of type 'color' if supported by the browser + continue; + } + } + var m; + if (!elms[i].jscolor && elms[i].className && (m = elms[i].className.match(matchClass))) { + var targetElm = elms[i]; + var optsStr = null; + + var dataOptions = jsc.getDataAttr(targetElm, 'jscolor'); + if (dataOptions !== null) { + optsStr = dataOptions; + } else if (m[4]) { + optsStr = m[4]; + } + + var opts = {}; + if (optsStr) { + try { + opts = (new Function ('return (' + optsStr + ')'))(); + } catch(eParseError) { + jsc.warn('Error parsing jscolor options: ' + eParseError + ':\n' + optsStr); + } + } + targetElm.jscolor = new jsc.jscolor(targetElm, opts); + } } }, - getDir : function() { - if(!jscolor.dir) { - var detected = jscolor.detectDir(); - jscolor.dir = detected!==false ? detected : 'jscolor/'; + isColorAttrSupported : (function () { + var elm = document.createElement('input'); + if (elm.setAttribute) { + elm.setAttribute('type', 'color'); + if (elm.type.toLowerCase() == 'color') { + return true; + } } - return jscolor.dir; + return false; + })(), + + + isCanvasSupported : (function () { + var elm = document.createElement('canvas'); + return !!(elm.getContext && elm.getContext('2d')); + })(), + + + fetchElement : function (mixed) { + return typeof mixed === 'string' ? document.getElementById(mixed) : mixed; }, - detectDir : function() { - var base = location.href; + isElementType : function (elm, type) { + return elm.nodeName.toLowerCase() === type.toLowerCase(); + }, + - var e = document.getElementsByTagName('base'); - for(var i=0; i vs[a] ? + (-vp[a]+tp[a]+ts[a]/2 > vs[a]/2 && tp[a]+ts[a]-ps[a] >= 0 ? tp[a]+ts[a]-ps[a] : tp[a]) : + tp[a], + -vp[b]+tp[b]+ts[b]+ps[b]-l+l*c > vs[b] ? + (-vp[b]+tp[b]+ts[b]/2 > vs[b]/2 && tp[b]+ts[b]-l-l*c >= 0 ? tp[b]+ts[b]-l-l*c : tp[b]+ts[b]-l+l*c) : + (tp[b]+ts[b]-l+l*c >= 0 ? tp[b]+ts[b]-l+l*c : tp[b]+ts[b]-l-l*c) + ]; + } + + var x = pp[a]; + var y = pp[b]; + var positionValue = thisObj.fixed ? 'fixed' : 'absolute'; + var contractShadow = + (pp[0] + ps[0] > tp[0] || pp[0] < tp[0] + ts[0]) && + (pp[1] + ps[1] < tp[1] + ts[1]); + + jsc._drawPosition(thisObj, x, y, positionValue, contractShadow); + } + }, + + + _drawPosition : function (thisObj, x, y, positionValue, contractShadow) { + var vShadow = contractShadow ? 0 : thisObj.shadowBlur; // px + + jsc.picker.wrap.style.position = positionValue; + jsc.picker.wrap.style.left = x + 'px'; + jsc.picker.wrap.style.top = y + 'px'; + + jsc.setBoxShadow( + jsc.picker.boxS, + thisObj.shadow ? + new jsc.BoxShadow(0, vShadow, thisObj.shadowBlur, 0, thisObj.shadowColor) : + null); + }, + + + getPickerDims : function (thisObj) { + var displaySlider = !!jsc.getSliderComponent(thisObj); + var dims = [ + 2 * thisObj.insetWidth + 2 * thisObj.padding + thisObj.width + + (displaySlider ? 2 * thisObj.insetWidth + jsc.getPadToSliderPadding(thisObj) + thisObj.sliderSize : 0), + 2 * thisObj.insetWidth + 2 * thisObj.padding + thisObj.height + + (thisObj.closable ? 2 * thisObj.insetWidth + thisObj.padding + thisObj.buttonHeight : 0) + ]; + return dims; + }, + + + getPickerOuterDims : function (thisObj) { + var dims = jsc.getPickerDims(thisObj); + return [ + dims[0] + 2 * thisObj.borderWidth, + dims[1] + 2 * thisObj.borderWidth + ]; + }, + + + getPadToSliderPadding : function (thisObj) { + return Math.max(thisObj.padding, 1.5 * (2 * thisObj.pointerBorderWidth + thisObj.pointerThickness)); + }, + + + getPadYComponent : function (thisObj) { + switch (thisObj.mode.charAt(1).toLowerCase()) { + case 'v': return 'v'; break; + } + return 's'; + }, + + + getSliderComponent : function (thisObj) { + if (thisObj.mode.length > 2) { + switch (thisObj.mode.charAt(2).toLowerCase()) { + case 's': return 's'; break; + case 'v': return 'v'; break; + } + } + return null; + }, + + + onDocumentMouseDown : function (e) { + if (!e) { e = window.event; } + var target = e.target || e.srcElement; + + if (target._jscLinkedInstance) { + if (target._jscLinkedInstance.showOnClick) { + target._jscLinkedInstance.show(); + } + } else if (target._jscControlName) { + jsc.onControlPointerStart(e, target, target._jscControlName, 'mouse'); } else { - return [0, 0]; + // Mouse is outside the picker controls -> hide the color picker! + if (jsc.picker && jsc.picker.owner) { + jsc.picker.owner.hide(); + } } }, - getViewSize : function() { - if(typeof window.innerWidth === 'number') { - return [window.innerWidth, window.innerHeight]; - } else if(document.body && (document.body.clientWidth || document.body.clientHeight)) { - return [document.body.clientWidth, document.body.clientHeight]; - } else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) { - return [document.documentElement.clientWidth, document.documentElement.clientHeight]; + onDocumentTouchStart : function (e) { + if (!e) { e = window.event; } + var target = e.target || e.srcElement; + + if (target._jscLinkedInstance) { + if (target._jscLinkedInstance.showOnClick) { + target._jscLinkedInstance.show(); + } + } else if (target._jscControlName) { + jsc.onControlPointerStart(e, target, target._jscControlName, 'touch'); } else { - return [0, 0]; + if (jsc.picker && jsc.picker.owner) { + jsc.picker.owner.hide(); + } + } + }, + + + onWindowResize : function (e) { + jsc.redrawPosition(); + }, + + + onParentScroll : function (e) { + // hide the picker when one of the parent elements is scrolled + if (jsc.picker && jsc.picker.owner) { + jsc.picker.owner.hide(); } }, - URI : function(uri) { // See RFC3986 + _pointerMoveEvent : { + mouse: 'mousemove', + touch: 'touchmove' + }, + _pointerEndEvent : { + mouse: 'mouseup', + touch: 'touchend' + }, + + + _pointerOrigin : null, + _capturedTarget : null, + + + onControlPointerStart : function (e, target, controlName, pointerType) { + var thisObj = target._jscInstance; - this.scheme = null; - this.authority = null; - this.path = ''; - this.query = null; - this.fragment = null; + jsc.preventDefault(e); + jsc.captureTarget(target); - this.parse = function(uri) { - var m = uri.match(/^(([A-Za-z][0-9A-Za-z+.-]*)(:))?((\/\/)([^\/?#]*))?([^?#]*)((\?)([^#]*))?((#)(.*))?/); - this.scheme = m[3] ? m[2] : null; - this.authority = m[5] ? m[6] : null; - this.path = m[7]; - this.query = m[9] ? m[10] : null; - this.fragment = m[12] ? m[13] : null; - return this; + var registerDragEvents = function (doc, offset) { + jsc.attachGroupEvent('drag', doc, jsc._pointerMoveEvent[pointerType], + jsc.onDocumentPointerMove(e, target, controlName, pointerType, offset)); + jsc.attachGroupEvent('drag', doc, jsc._pointerEndEvent[pointerType], + jsc.onDocumentPointerEnd(e, target, controlName, pointerType)); }; - this.toString = function() { - var result = ''; - if(this.scheme !== null) { result = result + this.scheme + ':'; } - if(this.authority !== null) { result = result + '//' + this.authority; } - if(this.path !== null) { result = result + this.path; } - if(this.query !== null) { result = result + '?' + this.query; } - if(this.fragment !== null) { result = result + '#' + this.fragment; } - return result; + registerDragEvents(document, [0, 0]); + + if (window.parent && window.frameElement) { + var rect = window.frameElement.getBoundingClientRect(); + var ofs = [-rect.left, -rect.top]; + registerDragEvents(window.parent.window.document, ofs); + } + + var abs = jsc.getAbsPointerPos(e); + var rel = jsc.getRelPointerPos(e); + jsc._pointerOrigin = { + x: abs.x - rel.x, + y: abs.y - rel.y }; - this.toAbsolute = function(base) { - var base = new jscolor.URI(base); - var r = this; - var t = new jscolor.URI; + switch (controlName) { + case 'pad': + // if the slider is at the bottom, move it up + switch (jsc.getSliderComponent(thisObj)) { + case 's': if (thisObj.hsv[1] === 0) { thisObj.fromHSV(null, 100, null); }; break; + case 'v': if (thisObj.hsv[2] === 0) { thisObj.fromHSV(null, null, 100); }; break; + } + jsc.setPad(thisObj, e, 0, 0); + break; - if(base.scheme === null) { return false; } + case 'sld': + jsc.setSld(thisObj, e, 0); + break; + } - if(r.scheme !== null && r.scheme.toLowerCase() === base.scheme.toLowerCase()) { - r.scheme = null; + jsc.dispatchFineChange(thisObj); + }, + + + onDocumentPointerMove : function (e, target, controlName, pointerType, offset) { + return function (e) { + var thisObj = target._jscInstance; + switch (controlName) { + case 'pad': + if (!e) { e = window.event; } + jsc.setPad(thisObj, e, offset[0], offset[1]); + jsc.dispatchFineChange(thisObj); + break; + + case 'sld': + if (!e) { e = window.event; } + jsc.setSld(thisObj, e, offset[1]); + jsc.dispatchFineChange(thisObj); + break; } + } + }, + + + onDocumentPointerEnd : function (e, target, controlName, pointerType) { + return function (e) { + var thisObj = target._jscInstance; + jsc.detachGroupEvents('drag'); + jsc.releaseTarget(); + // Always dispatch changes after detaching outstanding mouse handlers, + // in case some user interaction will occur in user's onchange callback + // that would intrude with current mouse events + jsc.dispatchChange(thisObj); + }; + }, + + + dispatchChange : function (thisObj) { + if (thisObj.valueElement) { + if (jsc.isElementType(thisObj.valueElement, 'input')) { + jsc.fireEvent(thisObj.valueElement, 'change'); + } + } + }, - if(r.scheme !== null) { - t.scheme = r.scheme; - t.authority = r.authority; - t.path = removeDotSegments(r.path); - t.query = r.query; + + dispatchFineChange : function (thisObj) { + if (thisObj.onFineChange) { + var callback; + if (typeof thisObj.onFineChange === 'string') { + callback = new Function (thisObj.onFineChange); } else { - if(r.authority !== null) { - t.authority = r.authority; - t.path = removeDotSegments(r.path); - t.query = r.query; - } else { - if(r.path === '') { - t.path = base.path; - if(r.query !== null) { - t.query = r.query; - } else { - t.query = base.query; - } - } else { - if(r.path.substr(0,1) === '/') { - t.path = removeDotSegments(r.path); - } else { - if(base.authority !== null && base.path === '') { - t.path = '/'+r.path; - } else { - t.path = base.path.replace(/[^\/]+$/,'')+r.path; - } - t.path = removeDotSegments(t.path); - } - t.query = r.query; - } - t.authority = base.authority; + callback = thisObj.onFineChange; + } + callback.call(thisObj); + } + }, + + + setPad : function (thisObj, e, ofsX, ofsY) { + var pointerAbs = jsc.getAbsPointerPos(e); + var x = ofsX + pointerAbs.x - jsc._pointerOrigin.x - thisObj.padding - thisObj.insetWidth; + var y = ofsY + pointerAbs.y - jsc._pointerOrigin.y - thisObj.padding - thisObj.insetWidth; + + var xVal = x * (360 / (thisObj.width - 1)); + var yVal = 100 - (y * (100 / (thisObj.height - 1))); + + switch (jsc.getPadYComponent(thisObj)) { + case 's': thisObj.fromHSV(xVal, yVal, null, jsc.leaveSld); break; + case 'v': thisObj.fromHSV(xVal, null, yVal, jsc.leaveSld); break; + } + }, + + + setSld : function (thisObj, e, ofsY) { + var pointerAbs = jsc.getAbsPointerPos(e); + var y = ofsY + pointerAbs.y - jsc._pointerOrigin.y - thisObj.padding - thisObj.insetWidth; + + var yVal = 100 - (y * (100 / (thisObj.height - 1))); + + switch (jsc.getSliderComponent(thisObj)) { + case 's': thisObj.fromHSV(null, yVal, null, jsc.leavePad); break; + case 'v': thisObj.fromHSV(null, null, yVal, jsc.leavePad); break; + } + }, + + + _vmlNS : 'jsc_vml_', + _vmlCSS : 'jsc_vml_css_', + _vmlReady : false, + + + initVML : function () { + if (!jsc._vmlReady) { + // init VML namespace + var doc = document; + if (!doc.namespaces[jsc._vmlNS]) { + doc.namespaces.add(jsc._vmlNS, 'urn:schemas-microsoft-com:vml'); + } + if (!doc.styleSheets[jsc._vmlCSS]) { + var tags = ['shape', 'shapetype', 'group', 'background', 'path', 'formulas', 'handles', 'fill', 'stroke', 'shadow', 'textbox', 'textpath', 'imagedata', 'line', 'polyline', 'curve', 'rect', 'roundrect', 'oval', 'arc', 'image']; + var ss = doc.createStyleSheet(); + ss.owningElement.id = jsc._vmlCSS; + for (var i = 0; i < tags.length; i += 1) { + ss.addRule(jsc._vmlNS + '\\:' + tags[i], 'behavior:url(#default#VML);'); } - t.scheme = base.scheme; } - t.fragment = r.fragment; + jsc._vmlReady = true; + } + }, - return t; + + createPalette : function () { + + var paletteObj = { + elm: null, + draw: null }; - function removeDotSegments(path) { - var out = ''; - while(path) { - if(path.substr(0,3)==='../' || path.substr(0,2)==='./') { - path = path.replace(/^\.+/,'').substr(1); - } else if(path.substr(0,3)==='/./' || path==='/.') { - path = '/'+path.substr(3); - } else if(path.substr(0,4)==='/../' || path==='/..') { - path = '/'+path.substr(4); - out = out.replace(/\/?[^\/]*$/, ''); - } else if(path==='.' || path==='..') { - path = ''; - } else { - var rm = path.match(/^\/?[^\/]*/)[0]; - path = path.substr(rm.length); - out = out + rm; + if (jsc.isCanvasSupported) { + // Canvas implementation for modern browsers + + var canvas = document.createElement('canvas'); + var ctx = canvas.getContext('2d'); + + var drawFunc = function (width, height, type) { + canvas.width = width; + canvas.height = height; + + ctx.clearRect(0, 0, canvas.width, canvas.height); + + var hGrad = ctx.createLinearGradient(0, 0, canvas.width, 0); + hGrad.addColorStop(0 / 6, '#F00'); + hGrad.addColorStop(1 / 6, '#FF0'); + hGrad.addColorStop(2 / 6, '#0F0'); + hGrad.addColorStop(3 / 6, '#0FF'); + hGrad.addColorStop(4 / 6, '#00F'); + hGrad.addColorStop(5 / 6, '#F0F'); + hGrad.addColorStop(6 / 6, '#F00'); + + ctx.fillStyle = hGrad; + ctx.fillRect(0, 0, canvas.width, canvas.height); + + var vGrad = ctx.createLinearGradient(0, 0, 0, canvas.height); + switch (type.toLowerCase()) { + case 's': + vGrad.addColorStop(0, 'rgba(255,255,255,0)'); + vGrad.addColorStop(1, 'rgba(255,255,255,1)'); + break; + case 'v': + vGrad.addColorStop(0, 'rgba(0,0,0,0)'); + vGrad.addColorStop(1, 'rgba(0,0,0,1)'); + break; } - } - return out; + ctx.fillStyle = vGrad; + ctx.fillRect(0, 0, canvas.width, canvas.height); + }; + + paletteObj.elm = canvas; + paletteObj.draw = drawFunc; + + } else { + // VML fallback for IE 7 and 8 + + jsc.initVML(); + + var vmlContainer = document.createElement('div'); + vmlContainer.style.position = 'relative'; + vmlContainer.style.overflow = 'hidden'; + + var hGrad = document.createElement(jsc._vmlNS + ':fill'); + hGrad.type = 'gradient'; + hGrad.method = 'linear'; + hGrad.angle = '90'; + hGrad.colors = '16.67% #F0F, 33.33% #00F, 50% #0FF, 66.67% #0F0, 83.33% #FF0' + + var hRect = document.createElement(jsc._vmlNS + ':rect'); + hRect.style.position = 'absolute'; + hRect.style.left = -1 + 'px'; + hRect.style.top = -1 + 'px'; + hRect.stroked = false; + hRect.appendChild(hGrad); + vmlContainer.appendChild(hRect); + + var vGrad = document.createElement(jsc._vmlNS + ':fill'); + vGrad.type = 'gradient'; + vGrad.method = 'linear'; + vGrad.angle = '180'; + vGrad.opacity = '0'; + + var vRect = document.createElement(jsc._vmlNS + ':rect'); + vRect.style.position = 'absolute'; + vRect.style.left = -1 + 'px'; + vRect.style.top = -1 + 'px'; + vRect.stroked = false; + vRect.appendChild(vGrad); + vmlContainer.appendChild(vRect); + + var drawFunc = function (width, height, type) { + vmlContainer.style.width = width + 'px'; + vmlContainer.style.height = height + 'px'; + + hRect.style.width = + vRect.style.width = + (width + 1) + 'px'; + hRect.style.height = + vRect.style.height = + (height + 1) + 'px'; + + // Colors must be specified during every redraw, otherwise IE won't display + // a full gradient during a subsequential redraw + hGrad.color = '#F00'; + hGrad.color2 = '#F00'; + + switch (type.toLowerCase()) { + case 's': + vGrad.color = vGrad.color2 = '#FFF'; + break; + case 'v': + vGrad.color = vGrad.color2 = '#000'; + break; + } + }; + + paletteObj.elm = vmlContainer; + paletteObj.draw = drawFunc; } - if(uri) { - this.parse(uri); + return paletteObj; + }, + + + createSliderGradient : function () { + + var sliderObj = { + elm: null, + draw: null + }; + + if (jsc.isCanvasSupported) { + // Canvas implementation for modern browsers + + var canvas = document.createElement('canvas'); + var ctx = canvas.getContext('2d'); + + var drawFunc = function (width, height, color1, color2) { + canvas.width = width; + canvas.height = height; + + ctx.clearRect(0, 0, canvas.width, canvas.height); + + var grad = ctx.createLinearGradient(0, 0, 0, canvas.height); + grad.addColorStop(0, color1); + grad.addColorStop(1, color2); + + ctx.fillStyle = grad; + ctx.fillRect(0, 0, canvas.width, canvas.height); + }; + + sliderObj.elm = canvas; + sliderObj.draw = drawFunc; + + } else { + // VML fallback for IE 7 and 8 + + jsc.initVML(); + + var vmlContainer = document.createElement('div'); + vmlContainer.style.position = 'relative'; + vmlContainer.style.overflow = 'hidden'; + + var grad = document.createElement(jsc._vmlNS + ':fill'); + grad.type = 'gradient'; + grad.method = 'linear'; + grad.angle = '180'; + + var rect = document.createElement(jsc._vmlNS + ':rect'); + rect.style.position = 'absolute'; + rect.style.left = -1 + 'px'; + rect.style.top = -1 + 'px'; + rect.stroked = false; + rect.appendChild(grad); + vmlContainer.appendChild(rect); + + var drawFunc = function (width, height, color1, color2) { + vmlContainer.style.width = width + 'px'; + vmlContainer.style.height = height + 'px'; + + rect.style.width = (width + 1) + 'px'; + rect.style.height = (height + 1) + 'px'; + + grad.color = color1; + grad.color2 = color2; + }; + + sliderObj.elm = vmlContainer; + sliderObj.draw = drawFunc; } + return sliderObj; }, + leaveValue : 1<<0, + leaveStyle : 1<<1, + leavePad : 1<<2, + leaveSld : 1<<3, + + + BoxShadow : (function () { + var BoxShadow = function (hShadow, vShadow, blur, spread, color, inset) { + this.hShadow = hShadow; + this.vShadow = vShadow; + this.blur = blur; + this.spread = spread; + this.color = color; + this.inset = !!inset; + }; + + BoxShadow.prototype.toString = function () { + var vals = [ + Math.round(this.hShadow) + 'px', + Math.round(this.vShadow) + 'px', + Math.round(this.blur) + 'px', + Math.round(this.spread) + 'px', + this.color + ]; + if (this.inset) { + vals.push('inset'); + } + return vals.join(' '); + }; + + return BoxShadow; + })(), + + // - // Usage example: - // var myColor = new jscolor.color(myInputElement) + // Usage: + // var myColor = new jscolor( [, ]) // - color : function(target, prop) { - - - this.required = true; // refuse empty values? - this.adjust = true; // adjust value to uniform notation? - this.hash = false; // prefix color with # symbol? - this.caps = true; // uppercase? - this.slider = true; // show the value/saturation slider? - this.valueElement = target; // value holder - this.styleElement = target; // where to reflect current color - this.onImmediateChange = null; // onchange callback (can be either string or function) - this.hsv = [0, 0, 1]; // read-only 0-6, 0-1, 0-1 - this.rgb = [1, 1, 1]; // read-only 0-1, 0-1, 0-1 - this.minH = 0; // read-only 0-6 - this.maxH = 6; // read-only 0-6 - this.minS = 0; // read-only 0-1 - this.maxS = 1; // read-only 0-1 - this.minV = 0; // read-only 0-1 - this.maxV = 1; // read-only 0-1 - - this.pickerOnfocus = true; // display picker on focus? - this.pickerMode = 'HSV'; // HSV | HVS - this.pickerPosition = 'bottom'; // left | right | top | bottom - this.pickerSmartPosition = true; // automatically adjust picker position when necessary - this.pickerButtonHeight = 20; // px - this.pickerClosable = false; - this.pickerCloseText = 'Close'; - this.pickerButtonColor = 'ButtonText'; // px - this.pickerFace = 10; // px - this.pickerFaceColor = 'ThreeDFace'; // CSS color - this.pickerBorder = 1; // px - this.pickerBorderColor = 'ThreeDHighlight ThreeDShadow ThreeDShadow ThreeDHighlight'; // CSS color - this.pickerInset = 1; // px - this.pickerInsetColor = 'ThreeDShadow ThreeDHighlight ThreeDHighlight ThreeDShadow'; // CSS color - this.pickerZIndex = 10000; - - - for(var p in prop) { - if(prop.hasOwnProperty(p)) { - this[p] = prop[p]; - } - } - - - this.hidePicker = function() { - if(isPickerOwner()) { - removePicker(); + jscolor : function (targetElement, options) { + + // General options + // + this.value = null; // initial HEX color. To change it later, use methods fromString(), fromHSV() and fromRGB() + this.valueElement = targetElement; // element that will be used to display and input the color code + this.styleElement = targetElement; // element that will preview the picked color using CSS backgroundColor + this.required = true; // whether the associated text can be left empty + this.refine = true; // whether to refine the entered color code (e.g. uppercase it and remove whitespace) + this.hash = false; // whether to prefix the HEX color code with # symbol + this.uppercase = true; // whether to show the color code in upper case + this.onFineChange = null; // called instantly every time the color changes (value can be either a function or a string with javascript code) + this.activeClass = 'jscolor-active'; // class to be set to the target element when a picker window is open on it + this.overwriteImportant = false; // whether to overwrite colors of styleElement using !important + this.minS = 0; // min allowed saturation (0 - 100) + this.maxS = 100; // max allowed saturation (0 - 100) + this.minV = 0; // min allowed value (brightness) (0 - 100) + this.maxV = 100; // max allowed value (brightness) (0 - 100) + + // Accessing the picked color + // + this.hsv = [0, 0, 100]; // read-only [0-360, 0-100, 0-100] + this.rgb = [255, 255, 255]; // read-only [0-255, 0-255, 0-255] + + // Color Picker options + // + this.width = 181; // width of color palette (in px) + this.height = 101; // height of color palette (in px) + this.showOnClick = true; // whether to display the color picker when user clicks on its target element + this.mode = 'HSV'; // HSV | HVS | HS | HV - layout of the color picker controls + this.position = 'bottom'; // left | right | top | bottom - position relative to the target element + this.smartPosition = true; // automatically change picker position when there is not enough space for it + this.sliderSize = 16; // px + this.crossSize = 8; // px + this.closable = false; // whether to display the Close button + this.closeText = 'Close'; + this.buttonColor = '#000000'; // CSS color + this.buttonHeight = 18; // px + this.padding = 12; // px + this.backgroundColor = '#FFFFFF'; // CSS color + this.borderWidth = 1; // px + this.borderColor = '#BBBBBB'; // CSS color + this.borderRadius = 8; // px + this.insetWidth = 1; // px + this.insetColor = '#BBBBBB'; // CSS color + this.shadow = true; // whether to display shadow + this.shadowBlur = 15; // px + this.shadowColor = 'rgba(0,0,0,0.2)'; // CSS color + this.pointerColor = '#4C4C4C'; // px + this.pointerBorderColor = '#FFFFFF'; // px + this.pointerBorderWidth = 1; // px + this.pointerThickness = 2; // px + this.zIndex = 1000; + this.container = null; // where to append the color picker (BODY element by default) + + + for (var opt in options) { + if (options.hasOwnProperty(opt)) { + this[opt] = options[opt]; + } + } + + + this.hide = function () { + if (isPickerOwner()) { + detachPicker(); } }; - this.showPicker = function() { - if(!isPickerOwner()) { - var tp = jscolor.getElementPos(target); // target pos - var ts = jscolor.getElementSize(target); // target size - var vp = jscolor.getViewPos(); // view pos - var vs = jscolor.getViewSize(); // view size - var ps = getPickerDims(this); // picker size - var a, b, c; - switch(this.pickerPosition.toLowerCase()) { - case 'left': a=1; b=0; c=-1; break; - case 'right':a=1; b=0; c=1; break; - case 'top': a=0; b=1; c=-1; break; - default: a=0; b=1; c=1; break; - } - var l = (ts[b]+ps[b])/2; + this.show = function () { + drawPicker(); + }; - // picker pos - if (!this.pickerSmartPosition) { - var pp = [ - tp[a], - tp[b]+ts[b]-l+l*c - ]; - } else { - var pp = [ - -vp[a]+tp[a]+ps[a] > vs[a] ? - (-vp[a]+tp[a]+ts[a]/2 > vs[a]/2 && tp[a]+ts[a]-ps[a] >= 0 ? tp[a]+ts[a]-ps[a] : tp[a]) : - tp[a], - -vp[b]+tp[b]+ts[b]+ps[b]-l+l*c > vs[b] ? - (-vp[b]+tp[b]+ts[b]/2 > vs[b]/2 && tp[b]+ts[b]-l-l*c >= 0 ? tp[b]+ts[b]-l-l*c : tp[b]+ts[b]-l+l*c) : - (tp[b]+ts[b]-l+l*c >= 0 ? tp[b]+ts[b]-l+l*c : tp[b]+ts[b]-l-l*c) - ]; - } - drawPicker(pp[a], pp[b]); + + this.redraw = function () { + if (isPickerOwner()) { + drawPicker(); } }; - this.importColor = function() { - if(!valueElement) { + this.importColor = function () { + if (!this.valueElement) { this.exportColor(); } else { - if(!this.adjust) { - if(!this.fromString(valueElement.value, leaveValue)) { - styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage; - styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor; - styleElement.style.color = styleElement.jscStyle.color; - this.exportColor(leaveValue | leaveStyle); + if (jsc.isElementType(this.valueElement, 'input')) { + if (!this.refine) { + if (!this.fromString(this.valueElement.value, jsc.leaveValue)) { + if (this.styleElement) { + this.styleElement.style.backgroundImage = this.styleElement._jscOrigStyle.backgroundImage; + this.styleElement.style.backgroundColor = this.styleElement._jscOrigStyle.backgroundColor; + this.styleElement.style.color = this.styleElement._jscOrigStyle.color; + } + this.exportColor(jsc.leaveValue | jsc.leaveStyle); + } + } else if (!this.required && /^\s*$/.test(this.valueElement.value)) { + this.valueElement.value = ''; + if (this.styleElement) { + this.styleElement.style.backgroundImage = this.styleElement._jscOrigStyle.backgroundImage; + this.styleElement.style.backgroundColor = this.styleElement._jscOrigStyle.backgroundColor; + this.styleElement.style.color = this.styleElement._jscOrigStyle.color; + } + this.exportColor(jsc.leaveValue | jsc.leaveStyle); + + } else if (this.fromString(this.valueElement.value)) { + // managed to import color successfully from the value -> OK, don't do anything + } else { + this.exportColor(); } - } else if(!this.required && /^\s*$/.test(valueElement.value)) { - valueElement.value = ''; - styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage; - styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor; - styleElement.style.color = styleElement.jscStyle.color; - this.exportColor(leaveValue | leaveStyle); - - } else if(this.fromString(valueElement.value)) { - // OK } else { + // not an input element -> doesn't have any value this.exportColor(); } } }; - this.exportColor = function(flags) { - if(!(flags & leaveValue) && valueElement) { + this.exportColor = function (flags) { + if (!(flags & jsc.leaveValue) && this.valueElement) { var value = this.toString(); - if(this.caps) { value = value.toUpperCase(); } - if(this.hash) { value = '#'+value; } - valueElement.value = value; - } - if(!(flags & leaveStyle) && styleElement) { - styleElement.style.backgroundImage = "none"; - styleElement.style.backgroundColor = - '#'+this.toString(); - styleElement.style.color = - 0.213 * this.rgb[0] + - 0.715 * this.rgb[1] + - 0.072 * this.rgb[2] - < 0.5 ? '#FFF' : '#000'; - } - if(!(flags & leavePad) && isPickerOwner()) { + if (this.uppercase) { value = value.toUpperCase(); } + if (this.hash) { value = '#' + value; } + + if (jsc.isElementType(this.valueElement, 'input')) { + this.valueElement.value = value; + } else { + this.valueElement.innerHTML = value; + } + } + if (!(flags & jsc.leaveStyle)) { + if (this.styleElement) { + var bgColor = '#' + this.toString(); + var fgColor = this.isLight() ? '#000' : '#FFF'; + + this.styleElement.style.backgroundImage = 'none'; + this.styleElement.style.backgroundColor = bgColor; + this.styleElement.style.color = fgColor; + + if (this.overwriteImportant) { + this.styleElement.setAttribute('style', + 'background: ' + bgColor + ' !important; ' + + 'color: ' + fgColor + ' !important;' + ); + } + } + } + if (!(flags & jsc.leavePad) && isPickerOwner()) { redrawPad(); } - if(!(flags & leaveSld) && isPickerOwner()) { + if (!(flags & jsc.leaveSld) && isPickerOwner()) { redrawSld(); } }; - this.fromHSV = function(h, s, v, flags) { // null = don't change - if(h !== null) { h = Math.max(0.0, this.minH, Math.min(6.0, this.maxH, h)); } - if(s !== null) { s = Math.max(0.0, this.minS, Math.min(1.0, this.maxS, s)); } - if(v !== null) { v = Math.max(0.0, this.minV, Math.min(1.0, this.maxV, v)); } + // h: 0-360 + // s: 0-100 + // v: 0-100 + // + this.fromHSV = function (h, s, v, flags) { // null = don't change + if (h !== null) { + if (isNaN(h)) { return false; } + h = Math.max(0, Math.min(360, h)); + } + if (s !== null) { + if (isNaN(s)) { return false; } + s = Math.max(0, Math.min(100, this.maxS, s), this.minS); + } + if (v !== null) { + if (isNaN(v)) { return false; } + v = Math.max(0, Math.min(100, this.maxV, v), this.minV); + } this.rgb = HSV_RGB( h===null ? this.hsv[0] : (this.hsv[0]=h), @@ -483,23 +1158,36 @@ var jscolor = { }; - this.fromRGB = function(r, g, b, flags) { // null = don't change - if(r !== null) { r = Math.max(0.0, Math.min(1.0, r)); } - if(g !== null) { g = Math.max(0.0, Math.min(1.0, g)); } - if(b !== null) { b = Math.max(0.0, Math.min(1.0, b)); } + // r: 0-255 + // g: 0-255 + // b: 0-255 + // + this.fromRGB = function (r, g, b, flags) { // null = don't change + if (r !== null) { + if (isNaN(r)) { return false; } + r = Math.max(0, Math.min(255, r)); + } + if (g !== null) { + if (isNaN(g)) { return false; } + g = Math.max(0, Math.min(255, g)); + } + if (b !== null) { + if (isNaN(b)) { return false; } + b = Math.max(0, Math.min(255, b)); + } var hsv = RGB_HSV( r===null ? this.rgb[0] : r, g===null ? this.rgb[1] : g, b===null ? this.rgb[2] : b ); - if(hsv[0] !== null) { - this.hsv[0] = Math.max(0.0, this.minH, Math.min(6.0, this.maxH, hsv[0])); + if (hsv[0] !== null) { + this.hsv[0] = Math.max(0, Math.min(360, hsv[0])); } - if(hsv[2] !== 0) { - this.hsv[1] = hsv[1]===null ? null : Math.max(0.0, this.minS, Math.min(1.0, this.maxS, hsv[1])); + if (hsv[2] !== 0) { + this.hsv[1] = hsv[1]===null ? null : Math.max(0, this.minS, Math.min(100, this.maxS, hsv[1])); } - this.hsv[2] = hsv[2]===null ? null : Math.max(0.0, this.minV, Math.min(1.0, this.maxV, hsv[2])); + this.hsv[2] = hsv[2]===null ? null : Math.max(0, this.minV, Math.min(100, this.maxV, hsv[2])); // update RGB according to final HSV, as some values might be trimmed var rgb = HSV_RGB(this.hsv[0], this.hsv[1], this.hsv[2]); @@ -511,264 +1199,417 @@ var jscolor = { }; - this.fromString = function(hex, flags) { - var m = hex.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i); - if(!m) { - return false; - } else { - if(m[1].length === 6) { // 6-char notation + this.fromString = function (str, flags) { + var m; + if (m = str.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i)) { + // HEX notation + // + + if (m[1].length === 6) { + // 6-char notation this.fromRGB( - parseInt(m[1].substr(0,2),16) / 255, - parseInt(m[1].substr(2,2),16) / 255, - parseInt(m[1].substr(4,2),16) / 255, + parseInt(m[1].substr(0,2),16), + parseInt(m[1].substr(2,2),16), + parseInt(m[1].substr(4,2),16), flags ); - } else { // 3-char notation + } else { + // 3-char notation this.fromRGB( - parseInt(m[1].charAt(0)+m[1].charAt(0),16) / 255, - parseInt(m[1].charAt(1)+m[1].charAt(1),16) / 255, - parseInt(m[1].charAt(2)+m[1].charAt(2),16) / 255, + parseInt(m[1].charAt(0) + m[1].charAt(0),16), + parseInt(m[1].charAt(1) + m[1].charAt(1),16), + parseInt(m[1].charAt(2) + m[1].charAt(2),16), flags ); } return true; + + } else if (m = str.match(/^\W*rgba?\(([^)]*)\)\W*$/i)) { + var params = m[1].split(','); + var re = /^\s*(\d*)(\.\d+)?\s*$/; + var mR, mG, mB; + if ( + params.length >= 3 && + (mR = params[0].match(re)) && + (mG = params[1].match(re)) && + (mB = params[2].match(re)) + ) { + var r = parseFloat((mR[1] || '0') + (mR[2] || '')); + var g = parseFloat((mG[1] || '0') + (mG[2] || '')); + var b = parseFloat((mB[1] || '0') + (mB[2] || '')); + this.fromRGB(r, g, b, flags); + return true; + } } + return false; + }; + + + this.toString = function () { + return ( + (0x100 | Math.round(this.rgb[0])).toString(16).substr(1) + + (0x100 | Math.round(this.rgb[1])).toString(16).substr(1) + + (0x100 | Math.round(this.rgb[2])).toString(16).substr(1) + ); + }; + + + this.toHEXString = function () { + return '#' + this.toString().toUpperCase(); + }; + + + this.toRGBString = function () { + return ('rgb(' + + Math.round(this.rgb[0]) + ',' + + Math.round(this.rgb[1]) + ',' + + Math.round(this.rgb[2]) + ')' + ); }; - this.toString = function() { + this.isLight = function () { return ( - (0x100 | Math.round(255*this.rgb[0])).toString(16).substr(1) + - (0x100 | Math.round(255*this.rgb[1])).toString(16).substr(1) + - (0x100 | Math.round(255*this.rgb[2])).toString(16).substr(1) + 0.213 * this.rgb[0] + + 0.715 * this.rgb[1] + + 0.072 * this.rgb[2] > + 255 / 2 ); }; - function RGB_HSV(r, g, b) { + this._processParentElementsInDOM = function () { + if (this._linkedElementsProcessed) { return; } + this._linkedElementsProcessed = true; + + var elm = this.targetElement; + do { + // If the target element or one of its parent nodes has fixed position, + // then use fixed positioning instead + // + // Note: In Firefox, getComputedStyle returns null in a hidden iframe, + // that's why we need to check if the returned style object is non-empty + var currStyle = jsc.getStyle(elm); + if (currStyle && currStyle.position.toLowerCase() === 'fixed') { + this.fixed = true; + } + + if (elm !== this.targetElement) { + // Ensure to attach onParentScroll only once to each parent element + // (multiple targetElements can share the same parent nodes) + // + // Note: It's not just offsetParents that can be scrollable, + // that's why we loop through all parent nodes + if (!elm._jscEventsAttached) { + jsc.attachEvent(elm, 'scroll', jsc.onParentScroll); + elm._jscEventsAttached = true; + } + } + } while ((elm = elm.parentNode) && !jsc.isElementType(elm, 'body')); + }; + + + // r: 0-255 + // g: 0-255 + // b: 0-255 + // + // returns: [ 0-360, 0-100, 0-100 ] + // + function RGB_HSV (r, g, b) { + r /= 255; + g /= 255; + b /= 255; var n = Math.min(Math.min(r,g),b); var v = Math.max(Math.max(r,g),b); var m = v - n; - if(m === 0) { return [ null, 0, v ]; } + if (m === 0) { return [ null, 0, 100 * v ]; } var h = r===n ? 3+(b-g)/m : (g===n ? 5+(r-b)/m : 1+(g-r)/m); - return [ h===6?0:h, m/v, v ]; + return [ + 60 * (h===6?0:h), + 100 * (m/v), + 100 * v + ]; } - function HSV_RGB(h, s, v) { - if(h === null) { return [ v, v, v ]; } + // h: 0-360 + // s: 0-100 + // v: 0-100 + // + // returns: [ 0-255, 0-255, 0-255 ] + // + function HSV_RGB (h, s, v) { + var u = 255 * (v / 100); + + if (h === null) { + return [ u, u, u ]; + } + + h /= 60; + s /= 100; + var i = Math.floor(h); var f = i%2 ? h-i : 1-(h-i); - var m = v * (1 - s); - var n = v * (1 - s*f); - switch(i) { + var m = u * (1 - s); + var n = u * (1 - s * f); + switch (i) { case 6: - case 0: return [v,n,m]; - case 1: return [n,v,m]; - case 2: return [m,v,n]; - case 3: return [m,n,v]; - case 4: return [n,m,v]; - case 5: return [v,m,n]; + case 0: return [u,n,m]; + case 1: return [n,u,m]; + case 2: return [m,u,n]; + case 3: return [m,n,u]; + case 4: return [n,m,u]; + case 5: return [u,m,n]; } } - function removePicker() { - delete jscolor.picker.owner; - document.getElementsByTagName('body')[0].removeChild(jscolor.picker.boxB); + function detachPicker () { + jsc.unsetClass(THIS.targetElement, THIS.activeClass); + jsc.picker.wrap.parentNode.removeChild(jsc.picker.wrap); + delete jsc.picker.owner; } - function drawPicker(x, y) { - if(!jscolor.picker) { - jscolor.picker = { + function drawPicker () { + + // At this point, when drawing the picker, we know what the parent elements are + // and we can do all related DOM operations, such as registering events on them + // or checking their positioning + THIS._processParentElementsInDOM(); + + if (!jsc.picker) { + jsc.picker = { + owner: null, + wrap : document.createElement('div'), box : document.createElement('div'), - boxB : document.createElement('div'), + boxS : document.createElement('div'), // shadow area + boxB : document.createElement('div'), // border pad : document.createElement('div'), - padB : document.createElement('div'), - padM : document.createElement('div'), + padB : document.createElement('div'), // border + padM : document.createElement('div'), // mouse/touch area + padPal : jsc.createPalette(), + cross : document.createElement('div'), + crossBY : document.createElement('div'), // border Y + crossBX : document.createElement('div'), // border X + crossLY : document.createElement('div'), // line Y + crossLX : document.createElement('div'), // line X sld : document.createElement('div'), - sldB : document.createElement('div'), - sldM : document.createElement('div'), + sldB : document.createElement('div'), // border + sldM : document.createElement('div'), // mouse/touch area + sldGrad : jsc.createSliderGradient(), + sldPtrS : document.createElement('div'), // slider pointer spacer + sldPtrIB : document.createElement('div'), // slider pointer inner border + sldPtrMB : document.createElement('div'), // slider pointer middle border + sldPtrOB : document.createElement('div'), // slider pointer outer border btn : document.createElement('div'), - btnS : document.createElement('span'), - btnT : document.createTextNode(THIS.pickerCloseText) + btnT : document.createElement('span') // text }; - for(var i=0,segSize=4; i