diff --git a/_src/ui/colorbutton.js b/_src/ui/colorbutton.js index 6bb3d90ae185c57fec6f863978831ddb1b88a400..7a5986259016cc4d3d16c152e892e40108c8b4da 100644 --- a/_src/ui/colorbutton.js +++ b/_src/ui/colorbutton.js @@ -25,18 +25,9 @@ }, onpicknocolor: function (t, color){ me._onPickNoColor(color); - }, - onchangeheight:function(){ - var color = this.getPreview().style.backgroundColor, - popbody = me.popup.getDom("body"); - domUtils.setStyle(popbody,"height",me.popup.getDom("content").offsetHeight+"px"); - me.setColor(color); } }), - editor:me.editor, - onhide:function(){ - this.content.toggleAdv(1); - } + editor:me.editor }); this.initSplitButton(); }, @@ -45,7 +36,7 @@ this._SplitButton_postRender(); this.getDom('button_body').appendChild( uiUtils.createElementByHtml('
') - ); + ); this.getDom().className += ' edui-colorbutton'; }, setColor: function (color){ diff --git a/_src/ui/colorpicker.js b/_src/ui/colorpicker.js index f78b3748942b15f9c0d02aa76a43e31c2af7e690..9cb29afba220ae6aa3714f897b4299271473fe23 100644 --- a/_src/ui/colorpicker.js +++ b/_src/ui/colorpicker.js @@ -2,7 +2,6 @@ ///import uicore (function (){ var utils = baidu.editor.utils, - uiUtils = baidu.editor.ui.uiUtils, UIBase = baidu.editor.ui.UIBase, ColorPicker = baidu.editor.ui.ColorPicker = function (options){ this.initOptions(options); @@ -11,28 +10,9 @@ }; ColorPicker.prototype = { - hue:360, - ishide : true, - saturation:100, - brightness:100, getHtmlTpl: function (){ return genColorPicker(this.noColorText,this.editor); }, - getPad:function(){ - return this.getDom("pad"); - }, - getSliderMain:function(){ - return this.getDom("sliderMain"); - }, - getThumb:function(){ - return this.getDom("thumb"); - }, - getPreview:function(){ - return this.getDom('preview'); - }, - getAdv:function(){ - return this.getDom("adv"); - }, _onTableClick: function (evt){ var tgt = evt.target || evt.srcElement; var color = tgt.getAttribute('data-color'); @@ -44,214 +24,20 @@ var tgt = evt.target || evt.srcElement; var color = tgt.getAttribute('data-color'); if (color) { - this.getPreview().style.backgroundColor = color; + this.getDom('preview').style.backgroundColor = color; } }, _onTableOut: function (){ - this.getPreview().style.backgroundColor = ''; + this.getDom('preview').style.backgroundColor = ''; }, _onPickNoColor: function (){ this.fireEvent('picknocolor'); - }, - _onShowAdv:function(){ - if(browser.ie && browser.version<=6){ - alert("您的浏览器版本太低,请使用高级版本的浏览器") - return; - } - this.toggleAdv(); - }, - toggleAdv:function(ishide){ - var obj = this.getDom("togglehandle"); - if(ishide&&this.ishide){ - return; - } - this.getAdv().style.display=this.ishide?"block":"none"; - domUtils.removeClasses(obj,["arrow_down","arrow_up"]); - this.ishide?domUtils.addClass(obj,"arrow_up"):domUtils.addClass(obj,"arrow_down"); - this.ishide = !this.ishide; - this.fireEvent("changeheight"); - }, - _onPadDotMouseDown:function(evt){ - var me = this; - uiUtils.startDrag(evt, { - ondragstart: function (){}, - ondragmove: function (x, y,evt){ - me._onClickPad(evt); - }, - ondragstop:function(){} - }); - }, - /** - * 校准value值,保证它在合理范围内 - * @private - * @param {Number} x 范围上限,被校准的数值不能超过这个数值. - * @param {Number} y 需要校准的数值. - * @return {Number} 校准过的数值. - */ - _adjustValue: function(x, y) { - return Math.max(0, Math.min(x, y)); - }, - _onClickPad:function(evt){ - var me = this, - paddot = me.getDom("paddot"), - pdrect = uiUtils.getClientRect(paddot), - rect = uiUtils.getClientRect(me.getPad()), - evtoffset = uiUtils.getViewportOffsetByEvent(evt); - //计算鼠标坐标相对调色板左上角距离 - me.padDotY = me._adjustValue(rect.height, evtoffset.top - rect.top); - me.padDotX = me._adjustValue(rect.width, evtoffset.left - rect.left); - - me.safeSetOffset(paddot,{ - top: me.padDotY-pdrect.height/2 , - left: me.padDotX-pdrect.width/2 - }); - - me.saturation = parseInt(100 * me.padDotX / rect.width, 10); //根据调色块top值计算饱和度 - me.brightness = parseInt(100 * (rect.height - me.padDotY) / rect.height, 10); //根据调色块left值计算亮度 - me._setNewColor(); - - }, - /** - * 将rgb格式转成hex格式 - * @private - * @param {Object} rgb rgb格式颜色值. - * @return {String} hex格式颜色值. - */ - _RGBToHex: function(rgb) { - var hex = [rgb.r.toString(16), rgb.g.toString(16), rgb.b.toString(16)]; - for(var i= 0;i vpRect.right) { - left = vpRect.right - rect.width; - } - var top = offset.top||0; - if (top + rect.height > vpRect.bottom) { - top = vpRect.bottom - rect.height; - } - domUtils.setStyle(el,"left",Math.max(left, 0) + 'px'); - domUtils.setStyle(el,"top",Math.max(top, 0) + 'px'); - }, - /** - * 设置pad背景色 - */ - setPadBackground:function(){ - var me = this, - pad = me.getPad(), - thumb = me.getThumb(), - sliderMainRect = uiUtils.getClientRect(me.getSliderMain()); - me.hue = parseInt(360 * (sliderMainRect.height - Math.min(me.value,sliderMainRect.height)) / sliderMainRect.height,10); - //设置面板背景色 - domUtils.setStyle(pad,'background-color','#' + me._HSBToHex({ - h: Math.max(me.hue,0), - s: 100, - b: 100 - })); - me._setNewColor(); } }; utils.inherits(ColorPicker, UIBase); var COLORS = ( - 'ffffff,000000,eeece1,1f497d,4f81bd,c0504d,9bbb59,8064a2,4bacc6,f79646,' + + 'ffffff,000000,eeece1,1f497d,4f81bd,c0504d,9bbb59,8064a2,4bacc6,f79646,' + 'f2f2f2,7f7f7f,ddd9c3,c6d9f0,dbe5f1,f2dcdb,ebf1dd,e5e0ec,dbeef3,fdeada,' + 'd8d8d8,595959,c4bd97,8db3e2,b8cce4,e5b9b7,d7e3bc,ccc1d9,b7dde8,fbd5b5,' + 'bfbfbf,3f3f3f,938953,548dd4,95b3d7,d99694,c3d69b,b2a2c7,92cddc,fac08f,' + @@ -262,8 +48,8 @@ function genColorPicker(noColorText,editor){ var html = '
' + '
' + - '
' + - '
'+ noColorText +'
' + + '
' + + '
'+ noColorText +'
' + '
' + '' + ''+ @@ -273,36 +59,16 @@ html += ''+(i==60?'':'')+''; } html += i<70 ? '':''; + '"' + + '>':''; } - html += '
'+editor.getLang("themeColor")+'
'+editor.getLang("standardColor")+'
'; - //高级按钮 - html += ''; - html += getAdvColorPicker(); - html += '
'; - return html; - } - - - function getAdvColorPicker(){ - var html = '
' + - '
' + - '
' + - '
'+ - '
' + - '
' + - '
' + - '
' + - '
' + - '
' + - '
'; + html += ''; return html; } })();