var BrowserDetect = { init: function () { this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version"; this.OS = this.searchString(this.dataOS) || "an unknown OS"; }, searchString: function (data) { for (var i=0;i= version; }; /** * Is the minor version greater than or equal to a specified version. * * @param {Number} version The minimum required minor version. * @type Boolean */ self.minorAtLeast = function(version){ return self.minor >= version; }; /** * Is the revision version greater than or equal to a specified version. * * @param {Number} version The minimum required revision version. * @type Boolean */ self.revisionAtLeast = function(version){ return self.revision >= version; }; /** * Is the version greater than or equal to a specified major, minor and revision. * * @param {Number} major The minimum required major version. * @param {Number} (Optional) minor The minimum required minor version. * @param {Number} (Optional) revision The minimum required revision version. * @type Boolean */ self.versionAtLeast = function(major){ var properties = [self.major, self.minor, self.revision]; var len = Math.min(properties.length, arguments.length); for(i=0; i=arguments[i]){ if(i+10){ var type = 'application/x-shockwave-flash'; var mimeTypes = navigator.mimeTypes; if(mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin && mimeTypes[type].enabledPlugin.description){ var version = mimeTypes[type].enabledPlugin.description; var versionObj = parseStandardVersion(version); self.raw = versionObj.raw; self.major = versionObj.major; self.minor = versionObj.minor; self.revisionStr = versionObj.revisionStr; self.revision = versionObj.revision; self.installed = true; } }else if(navigator.appVersion.indexOf("Mac")==-1 && window.execScript){ var version = -1; for(var i=0; i this.vars['minY']){ diff = (window.pageYOffset+height)-this.vars['minY']; } } else { if((document.documentElement.scrollTop+height) > this.vars['minY']){ diff = (document.documentElement.scrollTop+height)-this.vars['minY']; } } this.maskDiv.style.top = this.vars['minY']+diff+"px"; }, __clearDiv : function(){ var clear = document.createElement("div"); clear.style.clear = "both"; return clear; } } // Portal anim // Copyright 2010 Iomnis. All rights reserved. portal.anim = function(ele,params,snap){ this.init(ele,params,snap); } portal.anim.prototype = { root : null, data : null, snap : false, init : function(ele,params,snap){ this.root = document.getElementById(ele) ? document.getElementById(ele) : ele; if(!this.root) this.root = ele; this.data = new Array(); if(BrowserDetect.browser == "Explorer") snap = true; this.snap = snap ? snap : false; this.anim(params); }, anim : function(p){ var df = this; var delay = false; if(p){ if(p['delay']) delay = p['delay']; if(p['flipX']) this.data['flipX'] = true; if(p['flipY']) this.data['flipY'] = true; } if(this.snap){ p['step'] = 1; } if(delay) setTimeout(function(){df.animate(p)},delay*1000); else this.animate(p); }, stop : function(){ clearInterval(this.data['portal.anim']); }, animate : function(p){ var df = this; if(!this.root) return false; // get padding and border widths var dw = parseInt(this.getStyle('padding-left'))+parseInt(this.getStyle('padding-right'))+parseInt(this.getStyle('border-left-width'))+parseInt(this.getStyle('border-right-width')); var dh = parseInt(this.getStyle('padding-top'))+parseInt(this.getStyle('padding-bottom'))+parseInt(this.getStyle('border-top-width'))+parseInt(this.getStyle('border-bottom-width')); if(!dw) dw = 0; if(!dh) dh = 0; // get current values var w = parseInt(this.getStyle('width'))-dw; var h = parseInt(this.getStyle('height'))-dh; var x = this.data['flipX'] ? parseInt(this.getStyle('right')) : parseInt(this.getStyle('left')); var y = this.data['flipY'] ? parseInt(this.getStyle('bottom')) : parseInt(this.getStyle('top')); // default step this.data['portal.anim.step'] = 100; // get what we are animating if(p){ this.data['portal.anim.x'] = typeof p['x'] ? p['x'] : x; this.data['portal.anim.y'] = typeof p['y'] ? p['y'] : y; this.data['portal.anim.w'] = typeof p['width'] ? p['width'] : w; this.data['portal.anim.h'] = typeof p['height'] ? p['height'] : h; if(p['step']) this.data['portal.anim.step'] = p['step']; if(p['done']) this.data['portal.anim.onDone'] = p['done']; } // get the directions we need to go this.data['portal.anim.stepY'] = Math.abs(this.data['portal.anim.y']-y)/(this.data['portal.anim.y']-y); this.data['portal.anim.stepX'] = Math.abs(this.data['portal.anim.x']-x)/(this.data['portal.anim.x']-x); this.data['portal.anim.stepW'] = Math.abs(this.data['portal.anim.w']-w)/(this.data['portal.anim.w']-w); this.data['portal.anim.stepH'] = Math.abs(this.data['portal.anim.h']-h)/(this.data['portal.anim.h']-h); // get the appends this.data['portal.anim.appendW'] = Math.ceil(Math.abs(this.data['portal.anim.w']-w))/this.data['portal.anim.step']; this.data['portal.anim.appendH'] = Math.ceil(Math.abs(this.data['portal.anim.h']-h))/this.data['portal.anim.step']; this.data['portal.anim.appendX'] = Math.ceil(Math.abs(this.data['portal.anim.x']-x))/this.data['portal.anim.step']; this.data['portal.anim.appendY'] = Math.ceil(Math.abs(this.data['portal.anim.y']-y))/this.data['portal.anim.step']; this.data['portal.anim.currentStep'] = 0; this.data['portal.anim.log'] = ""; this.data['portal.anim'] = setInterval(function(){df.__anim()},1); }, __anim : function(){ this.data['portal.anim.currentStep']++; this.data['portal.anim.doneCount'] = 0; var w, h; //if(this.root.tagName != "IMG"){ w = this.root.style.width.replace("px","")*1; h = this.root.style.height.replace("px","")*1; //} else { //w = parseInt(this.root.width); //h = parseInt(this.root.height); //} var x = this.data['flipX'] ? this.root.style.right.replace("px","")*1 : this.root.style.left.replace("px","")*1; var y = this.data['flipY'] ? this.root.style.bottom.replace("px","")*1 : this.root.style.top.replace("px","")*1; w += this.data['portal.anim.stepW']*this.data['portal.anim.appendW']; h += this.data['portal.anim.stepH']*this.data['portal.anim.appendH']; x += this.data['portal.anim.stepX']*this.data['portal.anim.appendX']; y += this.data['portal.anim.stepY']*this.data['portal.anim.appendY']; if(this.data['portal.anim.currentStep'] > this.data['portal.anim.step']){ this.data['portal.anim.stepW'] = 0; this.data['portal.anim.stepH'] = 0; this.data['portal.anim.stepX'] = 0; this.data['portal.anim.stepY'] = 0; } if(this.data['portal.anim.stepW'] < 0 && w <= this.data['portal.anim.w'] || this.data['portal.anim.stepW'] > 0 && w >= this.data['portal.anim.w'] || !this.data['portal.anim.stepW']){ w = this.data['portal.anim.w']; this.data['portal.anim.doneCount']++; } if(this.data['portal.anim.stepH'] < 0 && h <= this.data['portal.anim.h'] || this.data['portal.anim.stepH'] > 0 && h >= this.data['portal.anim.h'] || !this.data['portal.anim.stepH']){ h = this.data['portal.anim.h']; this.data['portal.anim.doneCount']++; } if(this.data['portal.anim.stepX'] < 0 && x <= this.data['portal.anim.x'] || this.data['portal.anim.stepX'] > 0 && x >= this.data['portal.anim.x'] || !this.data['portal.anim.stepX']){ x = this.data['portal.anim.x']; this.data['portal.anim.doneCount']++; } if(this.data['portal.anim.stepY'] < 0 && y <= this.data['portal.anim.y'] || this.data['portal.anim.stepY'] > 0 && y >= this.data['portal.anim.y'] || !this.data['portal.anim.stepY']){ y = this.data['portal.anim.y']; this.data['portal.anim.doneCount']++; } //if(this.root.tagName == "IMG"){ //if(w != null) //this.root.width = w; //if(h != null) //this.root.height = h; //} else { if(w != null) this.root.style.width = w+"px"; if(h != null) this.root.style.height = h+"px"; //} if(x != null){ if(this.data['flipX']) this.root.style.right = x+"px"; else this.root.style.left = x+"px"; } if(y != null){ if(this.data['flipY']) this.root.style.bottom = y+"px"; else this.root.style.top = y+"px"; } if(this.data['portal.anim.doneCount'] == 4){ if(this.data['portal.anim.onDone']){ this.data['portal.anim.onDone'](); } clearInterval(this.data['portal.anim']); return true; } }, getStyle : function(styleProp){ if (this.root.currentStyle) var y = this.root.currentStyle[styleProp]; else if (window.getComputedStyle && window.getComputedStyle(this.root,null)) var y = window.getComputedStyle(this.root,null).getPropertyValue(styleProp); return y; } } // Color Picker // Copyright 2011 Iomnis. All rights reserved. portal.colorPicker = function(params){ this.init(params); } portal.colorPicker.prototype = { selectedColor : "rgb(0, 102, 153)", currentColor : null, hsvValues : {"h":200,"s":100,"v":60}, layout : {}, vars : {}, colors : false, done : null, init : function(params){ this.layout['content'] = document.createElement("div"), cp = this; this.layout['content'].className = "colorContent"; this.createPaneHeader(this.layout['content'],"Choose Color",""); var customizer = document.createElement("div"); this.layout['content'].appendChild(customizer); var grid = document.createElement("div"); grid.className = "colorGrid"; var x = 0, y = 0; customizer.appendChild(grid); this.layout['cg.fade'] = document.createElement("div"); this.layout['cg.fade'].className = "colorFade"; this.layout['cg.grad'] = document.createElement("div"); this.layout['cg.grad'].className = "colorGradient"; events.register(this.layout['cg.grad'],"mousedown",function(){cp.selectHue()}); events.register(this.layout['cg.fade'],"mousedown",function(){cp.selectSV()}); grid.appendChild(this.layout['cg.fade']); grid.appendChild(this.layout['cg.grad']); var colorInputs = document.createElement("div"); colorInputs.className = "colorInputs"; this.layout['colorSaves'] = document.createElement("div"); this.layout['colorSaves'].className = "colorSaves"; this.layout['colorSaves.content'] = document.createElement("div"); this.layout['colorSaves'].appendChild(this.layout['colorSaves.content']); customizer.appendChild(colorInputs); customizer.appendChild(this.layout['colorSaves']); customizer.appendChild(this.createClear()); // new this.layout['cg.new'] = document.createElement("div"); this.layout['cg.new'].className = "currentColor"; events.register(this.layout['cg.new'],"mousedown",function(){cp.dragNewColor()}); var newColorLbl = document.createElement("div"); newColorLbl.className = "currentColorLbl"; newColorLbl.innerHTML = "New Color"; // current this.layout['cg.current'] = document.createElement("div"); this.layout['cg.current'].className = "currentColor"; this.layout['cg.new'].style.background = this.selectedColor; this.layout['cg.current'].style.background = this.selectedColor; var currentColorLbl = document.createElement("div"); currentColorLbl.className = "currentColorLbl"; currentColorLbl.innerHTML = "Current Color"; colorInputs.appendChild(this.layout['cg.new']); colorInputs.appendChild(newColorLbl); colorInputs.appendChild(this.layout['cg.current']); colorInputs.appendChild(currentColorLbl); // add more inputs var inputs = document.createElement("div"); inputs.className = "inputs"; var inputs2 = document.createElement("div"); inputs2.className = "inputs"; var inputs3 = document.createElement("div"); inputs3.className = "inputs"; this.layout['h.input'] = document.createElement("input"); this.layout['s.input'] = document.createElement("input"); this.layout['v.input'] = document.createElement("input"); this.layout['h.input'].setAttribute("maxlength",3); this.layout['s.input'].setAttribute("maxlength",3); this.layout['v.input'].setAttribute("maxlength",3); events.register(this.layout['h.input'],"focus",function(){b.readHsv()}); events.register(this.layout['s.input'],"focus",function(){b.readHsv()}); events.register(this.layout['v.input'],"focus",function(){b.readHsv()}); this.layout['r.input'] = document.createElement("input"); this.layout['g.input'] = document.createElement("input"); this.layout['b.input'] = document.createElement("input"); this.layout['r.input'].setAttribute("maxlength",3); this.layout['g.input'].setAttribute("maxlength",3); this.layout['b.input'].setAttribute("maxlength",3); events.register(this.layout['r.input'],"focus",function(){b.readRgb()}); events.register(this.layout['g.input'],"focus",function(){b.readRgb()}); events.register(this.layout['b.input'],"focus",function(){b.readRgb()}); this.layout['hex.input'] = document.createElement("input"); this.layout['hex.input'].className = "hex"; this.layout['hex.input'].setAttribute("maxlength",6); events.register(this.layout['hex.input'],"focus",function(){b.readHex()}); this.layout['hex.div'] = document.createElement("div"); this.layout['hex.div'].innerHTML = "#"; this.layout['hex.div'].appendChild(this.layout['hex.input']); this.layout['h.div'] = document.createElement("div"); this.layout['h.div'].innerHTML = "H"; this.layout['h.div'].appendChild(this.layout['h.input']); this.layout['s.div'] = document.createElement("div"); this.layout['s.div'].innerHTML = "S"; this.layout['s.div'].appendChild(this.layout['s.input']); this.layout['v.div'] = document.createElement("div"); this.layout['v.div'].innerHTML = "V"; this.layout['v.div'].appendChild(this.layout['v.input']); this.layout['r.div'] = document.createElement("div"); this.layout['r.div'].innerHTML = "R"; this.layout['r.div'].appendChild(this.layout['r.input']); this.layout['g.div'] = document.createElement("div"); this.layout['g.div'].innerHTML = "G"; this.layout['g.div'].appendChild(this.layout['g.input']); this.layout['b.div'] = document.createElement("div"); this.layout['b.div'].innerHTML = "B"; this.layout['b.div'].appendChild(this.layout['b.input']); inputs.appendChild(this.layout['h.div']); inputs.appendChild(this.layout['s.div']); inputs.appendChild(this.layout['v.div']); inputs2.appendChild(this.layout['r.div']); inputs2.appendChild(this.layout['g.div']); inputs2.appendChild(this.layout['b.div']); inputs3.appendChild(this.layout['hex.div']); colorInputs.appendChild(inputs); colorInputs.appendChild(inputs2); grid.appendChild(inputs3); //this.layout['disp.pane'] = new portal.pane({"width":500,"height":325,"content":this.layout['content'],"buttons":{"Cancel":function(){},"OK":function(){b.setColor()}}}).mode("popup"); this.layout['color.sv.pointer'] = document.createElement("div"); this.layout['color.sv.pointer'].className = "svPointer"; this.layout['cg.fade'].appendChild(this.layout['color.sv.pointer']); this.layout['color.h.pointer'] = document.createElement("div"); this.layout['color.h.pointer'].className = "hPointer"; this.layout['cg.grad'].appendChild(this.layout['color.h.pointer']); }, dragNewColor : function(stopDrag){ var b = this; if(stopDrag){ dragger.drag(null); events.unregister(this.vars['newColor.drag.mouseup']); if(dragger.hitTest(this.layout['clone'],this.layout['colorSaves'])){ if(!this.colors[this.currentColor]){ this.colors[this.currentColor] = true; if(this.vars['dragNewColorFunc']) this.vars['dragNewColorFunc'](); this.renderSavedColors(); } } document.body.removeChild(this.layout['clone']); } else { this.layout['clone'] = events.target.cloneNode(true); this.layout['clone'].className = " dragColor"; var mouse = events.getMouse(); document.body.appendChild(this.layout['clone']); this.layout['clone'].style.left = (mouse.x-(this.layout['clone'].offsetWidth/2))+"px"; this.layout['clone'].style.top = (mouse.y-(this.layout['clone'].offsetHeight/2))+"px"; dragger.drag(this.layout['clone'],document.body); this.vars['newColor.drag.mouseup'] = events.register(document.body,"mouseup",function(){b.dragNewColor(true)}); } }, renderSavedColors : function(){ var b = this; this.layout['colorSaves.content'].innerHTML = ""; var x = 12, y = 5, count = 0; for(c=count;c<32;c++){ if(c%4 == 0 && c > 0){ x = 12; y += 30; } var swatch = document.createElement("div"); swatch.className = "swatch"; this.layout['colorSaves.content'].appendChild(swatch); swatch.style.left = x+"px"; swatch.style.top = y+"px"; x += swatch.offsetWidth+5; } x = 12, y = 5, count = 0; for(var c in this.colors){ if(count%4 == 0 && count > 0){ x = 12; y += 30; } var swatch = document.createElement("div"); swatch.className = "swatch selectable"; this.layout['colorSaves.content'].appendChild(swatch); swatch.style.background = c; swatch.style.left = x+"px"; swatch.style.top = y+"px"; x += swatch.offsetWidth+5; events.register(swatch,"mousedown",function(c){b.dragSwatch(c)},c); //events.register(swatch,"click",function(c){b.selectSwatch(c)},c); count++; if(count == 32) break; } }, dragSwatch : function(color,end){ var target = events.target, mouse = events.getMouse(), b = this; if(end){ events.unregister(this.vars['swatch.mousemove']); events.unregister(this.vars['swatch.mouseup']); if(!dragger.hitTest(this.layout['swatch'],this.layout['colorSaves'])){ delete this.colors[color]; if(this.vars['deleteColorFunc']) this.vars['deleteColorFunc'](); } else{ this.selectSwatch(color); } dragger.drag(null); document.body.removeChild(this.layout['swatch']); this.renderSavedColors(); } else { var t = site.offsetTop(target), l = site.offsetLeft(target); this.layout['colorSaves.content'].removeChild(target); this.layout['swatch'] = target.cloneNode(true); this.layout['swatch'].className = "dragSwatch"; document.body.appendChild(this.layout['swatch']); this.layout['swatch'].style.left = (mouse.x-(this.layout['swatch'].offsetWidth/2))+"px"; this.layout['swatch'].style.top = (mouse.y-(this.layout['swatch'].offsetHeight/2))+"px"; //this.layout['swatch'].style.left = l+"px"; //this.layout['swatch'].style.top = t+"px"; dragger.drag(this.layout['swatch'],document.body); this.vars['swatch.mousemove'] = events.register(document.body,"mousemove",function(){b.updateDragSwatch()}); this.vars['swatch.mouseup'] = events.register(document.body,"mouseup",function(c){b.dragSwatch(c,true)},color); } }, updateDragSwatch : function(){ var mouse = events.getMouse(); this.layout['swatch'].style.left = (mouse.x-(this.layout['swatch'].offsetWidth/2))+"px"; this.layout['swatch'].style.top = (mouse.y-(this.layout['swatch'].offsetHeight/2))+"px"; }, selectSwatch : function(color){ this.currentColor = color; var rgb = this.currentColor.match(/rgb\((\d+), (\d+), (\d+)\)/); var hsv = this.rgbToHSV(parseInt(rgb[1]),parseInt(rgb[2]),parseInt(rgb[3])); if(hsv){ this.hsvValues.h = hsv.h; this.hsvValues.s = hsv.s; this.hsvValues.v = hsv.v; this.layout['r.input'].value = rgb[1]; this.layout['g.input'].value = rgb[2]; this.layout['b.input'].value = rgb[3]; this.layout['h.input'].value = hsv.h; this.layout['s.input'].value = hsv.s; this.layout['v.input'].value = hsv.v; this.layout['hex.input'].value = this.rgbToHex(parseInt(this.layout['r.input'].value),parseInt(this.layout['g.input'].value),parseInt(this.layout['b.input'].value)); this.renderPointers(); } }, readHex : function(){ var b = this; this.vars['readHex'] = setInterval(function(){b.readingHex()},1); events.register(this.layout['hex.input'],"blur",function(){b.stopReadingHex()}); }, readingHex : function(){ var rgb = this.hexToRgb(this.layout['hex.input'].value); if(rgb){ this.layout['r.input'].value = rgb.r; this.layout['g.input'].value = rgb.g; this.layout['b.input'].value = rgb.b; this.currentColor = "rgb("+rgb.r+", "+rgb.g+", "+rgb.b+")"; var hsv = this.rgbToHSV(parseInt(rgb.r),parseInt(rgb.g),parseInt(rgb.b)); this.hsvValues.h = hsv.h; this.hsvValues.s = hsv.s; this.hsvValues.v = hsv.v; this.layout['h.input'].value = hsv.h; this.layout['s.input'].value = hsv.s; this.layout['v.input'].value = hsv.v; this.renderPointers(); } }, stopReadingHex : function(){ clearInterval(this.vars['readHex']); events.unregister(this.layout['hex.input'],"blur"); this.renderPointers(); }, readHsv : function(){ var b = this; this.vars['readHsv'] = setInterval(function(){b.readingHsv()},1); events.register(this.layout['h.input'],"blur",function(){b.stopReadingHsv()}); events.register(this.layout['s.input'],"blur",function(){b.stopReadingHsv()}); events.register(this.layout['v.input'],"blur",function(){b.stopReadingHsv()}); }, readingHsv : function(){ this.hsvValues.h = parseInt(this.layout['h.input'].value) ? parseInt(this.layout['h.input'].value) : 0; this.hsvValues.s = parseInt(this.layout['s.input'].value) ? parseInt(this.layout['s.input'].value) : 0; this.hsvValues.v = parseInt(this.layout['v.input'].value) ? parseInt(this.layout['v.input'].value) : 0; if(this.hsvValues.h >= 360) this.hsvValues.h = 0; if(this.hsvValues.s > 100) this.hsvValues.s = 100; if(this.hsvValues.v > 100) this.hsvValues.v = 100; var rgb = this.hsvToRGB(this.hsvValues.h,this.hsvValues.s,this.hsvValues.v); if(rgb){ this.layout['r.input'].value = rgb[0]; this.layout['g.input'].value = rgb[1]; this.layout['b.input'].value = rgb[2]; this.currentColor = "rgb("+rgb[0]+", "+rgb[1]+", "+rgb[2]+")"; this.layout['hex.input'].value = this.rgbToHex(rgb[0],rgb[1],rgb[2]); this.renderPointers(); } }, stopReadingHsv : function(){ clearInterval(this.vars['readHsv']); events.unregister(this.layout['h.input'],"blur"); events.unregister(this.layout['s.input'],"blur"); events.unregister(this.layout['v.input'],"blur"); this.renderPointers(); }, readRgb : function(){ var b = this; this.vars['readHsv'] = setInterval(function(){b.readingRgb()},1); events.register(this.layout['r.input'],"blur",function(){b.stopReadingRgb()}); events.register(this.layout['g.input'],"blur",function(){b.stopReadingRgb()}); events.register(this.layout['b.input'],"blur",function(){b.stopReadingRgb()}); }, readingRgb : function(){ if(this.layout['r.input'].value > 255) this.layout['r.input'].value = 255; if(this.layout['g.input'].value > 255) this.layout['g.input'].value = 255; if(this.layout['b.input'].value > 255) this.layout['b.input'].value = 255; var r = parseInt(this.layout['r.input'].value) ? parseInt(this.layout['r.input'].value) : 0; var g = parseInt(this.layout['g.input'].value) ? parseInt(this.layout['g.input'].value) : 0; var b = parseInt(this.layout['b.input'].value) ? parseInt(this.layout['b.input'].value) : 0; var hsv = this.rgbToHSV(r,g,b); if(hsv){ this.hsvValues.h = hsv.h; this.hsvValues.s = hsv.s; this.hsvValues.v = hsv.v; this.layout['h.input'].value = hsv.h; this.layout['s.input'].value = hsv.s; this.layout['v.input'].value = hsv.v; this.currentColor = "rgb("+parseInt(this.layout['r.input'].value)+", "+parseInt(this.layout['g.input'].value)+", "+parseInt(this.layout['b.input'].value)+")"; this.layout['hex.input'].value = this.rgbToHex(parseInt(this.layout['r.input'].value),parseInt(this.layout['g.input'].value),parseInt(this.layout['b.input'].value)); this.renderPointers(); } }, stopReadingRgb : function(){ clearInterval(this.vars['readRbg']); events.unregister(this.layout['r.input'],"blur"); events.unregister(this.layout['g.input'],"blur"); events.unregister(this.layout['b.input'],"blur"); this.renderPointers(); }, renderPointers : function(){ var l =(2*this.hsvValues.v)-(this.layout['color.sv.pointer'].offsetWidth/2); var tmpA = this.hsvValues.s; var tmpB = this.layout['color.sv.pointer'].offsetHeight; var t = (200-(2*this.hsvValues.s))-(this.layout['color.sv.pointer'].offsetHeight/2); /* if(t < (0+this.layout['color.sv.pointer'].offsetHeight)) t = (0+this.layout['color.sv.pointer'].offsetHeight); else if(t > 200-this.layout['color.sv.pointer'].offsetHeight) t = 200-this.layout['color.sv.pointer'].offsetHeight;*/ if(l) this.layout['color.sv.pointer'].style.left = l+"px"; if(t) this.layout['color.sv.pointer'].style.top = t+"px"; l = (this.hsvValues.h*(5/9)); if(l < (0+this.layout['color.h.pointer'].offsetWidth)) l = (0+this.layout['color.h.pointer'].offsetWidth); else if(l > 200-this.layout['color.h.pointer'].offsetWidth) l = 200-this.layout['color.h.pointer'].offsetWidth; this.layout['color.h.pointer'].style.left = l+"px"; this.layout['color.h.pointer'].style.top = ((this.layout['cg.grad'].offsetHeight-(this.layout['color.h.pointer'].offsetHeight+4))/2)+"px"; this.layout['cg.new'].style.background = this.currentColor; var color = "rgb("+this.hsvToRGB(this.hsvValues.h,100,100).join(", ")+")"; this.layout['cg.fade'].style.backgroundColor = color; }, launch : function(params){ var b = this; if(params['parent']){ this.layout['tools-color'] = params['parent']; } if(params['done']) this.done = params['done']; if(params['color']){ this.currentColor = params['color']; } if(params['dragNewColorFunc']){ this.vars['dragNewColorFunc'] = params['dragNewColorFunc']; } if(params['deleteColorFunc']){ this.vars['deleteColorFunc'] = params['deleteColorFunc']; } if(params['colors']) this.colors = params['colors']; else this.colors = {"rgb(255, 255, 255)":true,"rgb(0, 0, 0)":true}; // default if(!this.currentColor){ this.currentColor = this.selectedColor; } var rgb = this.currentColor.match(/rgb\(([0-9]+), ([0-9]+), ([0-9]+)\)/), hsv = this.rgbToHSV(parseInt(rgb[1]),parseInt(rgb[2]),parseInt(rgb[3])); this.hsvValues.h = hsv.h; this.hsvValues.s = hsv.s; this.hsvValues.v = hsv.v; var color = "rgb("+this.hsvToRGB(this.hsvValues.h,100,100).join(", ")+")"; this.layout['cg.fade'].style.backgroundColor = color; this.layout['cg.current'].style.background = this.selectedColor; this.layout['disp.pane'] = new portal.pane({"width":500,"height":370,"content":this.layout['content'],"buttons":{"Cancel":function(){b.purge()},"OK":function(){b.setColor()}}}).mode("popup"); this.renderPointers(); this.updateInputs(); this.renderSavedColors(); }, createPaneHeader : function(content,title,txt){ var hdr = document.createElement("div"); hdr.className = "pane-header"; var ptxt = document.createElement("div"); ptxt.className = "pane-txt"; hdr.innerHTML = ""+title+""; ptxt.innerHTML = txt; content.appendChild(hdr); //content.appendChild(ptxt); }, createClear : function(){ var clear = document.createElement("div"); clear.style.clear = "both"; return clear; }, selectSV : function(off){ var b = this; var mouse = events.getMouse(); this.stopReading(); if(!this.vars['fade.mousemove']){ this.vars['fade.mousemove'] = events.register(this.layout['cg.fade'],"mousemove",function(){b.selectSV()}); this.vars['fade.mouseup'] = events.register(document.body,"mouseup",function(){b.selectSV(true)}); } if(!off) dragger.drag(events.target,events.target); else { dragger.drag(null); events.unregister(this.vars['fade.mouseup']); events.unregister(this.vars['fade.mousemove']); this.vars['fade.mousemove'] = null; } // hsv var x = Math.abs(mouse.x-site.offsetLeft(this.layout['cg.fade'])); var y = Math.abs(mouse.y-site.offsetTop(this.layout['cg.fade'])); if(x < 0) x = 0; else if(x > 200) x = 200; if(y < 0) y = 0; else if(y > 200) y = 200; var s = Math.floor(100-((y/200)*100)); var v = Math.floor((x/200)*100); this.hsvValues.s = s; this.hsvValues.v = v; this.currentColor = "rgb("+this.hsvToRGB(this.hsvValues.h,this.hsvValues.s,this.hsvValues.v).join(", ")+")"; this.layout['cg.new'].style.backgroundColor = this.currentColor; this.layout['color.sv.pointer'].style.left = (x-(this.layout['color.sv.pointer'].offsetWidth/2))+"px"; this.layout['color.sv.pointer'].style.top = (y-(this.layout['color.sv.pointer'].offsetHeight/2))+"px"; this.updateInputs(); }, updateInputs : function(){ this.layout['h.input'].value = this.hsvValues.h; this.layout['s.input'].value = this.hsvValues.s; this.layout['v.input'].value = this.hsvValues.v; var rgb = this.currentColor.match(/rgb\(([0-9]+), ([0-9]+), ([0-9]+)\)/); this.layout['r.input'].value = rgb[1]; this.layout['g.input'].value = rgb[2]; this.layout['b.input'].value = rgb[3]; this.layout['hex.input'].value = this.rgbToHex(rgb[1],rgb[2],rgb[3]); }, selectHue : function(off){ var b = this; var mouse = events.getMouse(); this.stopReading(); if(!this.vars['grad.mousemove']){ this.vars['grad.mousemove'] = events.register(this.layout['cg.grad'],"mousemove",function(){b.selectHue()}); this.vars['grad.mouseup'] = events.register(document.body,"mouseup",function(){b.selectHue(true)}); } if(!off) dragger.drag(events.target,events.target); else { dragger.drag(null); events.unregister(this.vars['grad.mouseup']); events.unregister(this.vars['grad.mousemove']); this.vars['grad.mousemove'] = null; } // hsv var x = (mouse.x-site.offsetLeft(this.layout['cg.grad'])); if(x < 0) x = 0; else if(x > 200) x = 200; var h = Math.floor((x/200)*360); if(h >= 360) h = 0; this.hsvValues.h = h; var color = "rgb("+this.hsvToRGB(this.hsvValues.h,100,100).join(", ")+")"; this.layout['cg.fade'].style.backgroundColor = color; this.currentColor = "rgb("+this.hsvToRGB(this.hsvValues.h,this.hsvValues.s,this.hsvValues.v).join(", ")+")"; this.layout['cg.new'].style.backgroundColor = this.currentColor; this.layout['color.h.pointer'].style.left = (x-(this.layout['color.h.pointer'].offsetWidth/2))+"px"; this.layout['color.h.pointer'].style.top = ((this.layout['cg.grad'].offsetHeight-(this.layout['color.h.pointer'].offsetHeight+4))/2)+"px"; this.updateInputs(); }, rgbToHSV : function (r, g, b){ r = r/255, g = g/255, b = b/255; var max = Math.max(r, g, b), min = Math.min(r, g, b); var h, s, v = max; var d = max - min; s = max == 0 ? 0 : d / max; if(max == min){ h = 0; // achromatic }else{ switch(max){ case r: h = (g - b) / d + (g < b ? 6 : 0); break; case g: h = (b - r) / d + 2; break; case b: h = (r - g) / d + 4; break; } h /= 6; } return {"h":Math.round(h*360), "s":Math.round(s*100), "v":Math.round(v*100)}; }, hexToRgb : function (hex_string, default_){ if (default_ == undefined) { default_ = null; } if (hex_string.substr(0, 1) == '#') { hex_string = hex_string.substr(1); } var r; var g; var b; if (hex_string.length == 3) { r = hex_string.substr(0, 1); r += r; g = hex_string.substr(1, 1); g += g; b = hex_string.substr(2, 1); b += b; } else if (hex_string.length == 6) { r = hex_string.substr(0, 2); g = hex_string.substr(2, 2); b = hex_string.substr(4, 2); } else { return default_; } r = parseInt(r, 16); g = parseInt(g, 16); b = parseInt(b, 16); if (isNaN(r) || isNaN(g) || isNaN(b)) { return default_; } else { return {r: r, g: g, b: b}; } }, rgbToHex : function (r,g,b) { return this.toHex(r)+this.toHex(g)+this.toHex(b) }, toHex : function (N) { if (N==null) return "00"; N=parseInt(N); if (N==0 || isNaN(N)) return "00"; N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N); return "0123456789ABCDEF".charAt((N-N%16)/16) + "0123456789ABCDEF".charAt(N%16); }, hsvToRGB : function(h,s,v){ /* Ported from the java algorithm by Eugene Vishnevsky at: * http://www.cs.rit.edu/~ncs/color/t_convert.html */ var r, g, b, i, f, p, q, t; h = Math.max(0, Math.min(360, h)); s = Math.max(0, Math.min(100, s)); v = Math.max(0, Math.min(100, v)); s /= 100; v /= 100; if(s == 0) { r = g = b = v; return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; } h /= 60; i = Math.floor(h); f = h - i; p = v * (1 - s); q = v * (1 - s * f); t = v * (1 - s * (1 - f)); switch(i) { case 0: r = v; g = t; b = p; break; case 1: r = q; g = v; b = p; break; case 2: r = p; g = v; b = t; break; case 3: r = p; g = q; b = v; break; case 4: r = t; g = p; b = v; break; default: // case 5: r = v; g = p; b = q; } return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; }, purge : function(){ this.currentColor = null; this.stopReading(); if(this.done) this.done(); }, stopReading : function(){ if(this.vars['readHex']) clearInterval(this.vars['readHex']); if(this.vars['readHsv']) clearInterval(this.vars['readHsv']); if(this.vars['readRgb']) clearInterval(this.vars['readRgb']); this.layout['h.input'].blur(); this.layout['s.input'].blur(); this.layout['v.input'].blur(); this.layout['r.input'].blur(); this.layout['g.input'].blur(); this.layout['b.input'].blur(); this.layout['hex.input'].blur(); }, close : function(){ this.layout['disp.pane'].dismiss(); }, setColor : function(){ this.selectedColor = "rgb("+this.hsvToRGB(this.hsvValues.h,this.hsvValues.s,this.hsvValues.v).join(", ")+")"; this.layout['tools-color'].childNodes[0].style.background = this.selectedColor; this.purge(); }, isActive : function(){ return this.layout['disp.pane'] ? this.layout['disp.pane'].isActive() : false; } } // JavaScript Document Connector = function(params){ // menu div this.init(params); } Connector.prototype = { form : null, frame : null, params : null, formAction : null, formTarget : null, oldFormAction : null, oldFormTarget : null, inputsAllowed: "text", _dataLoadFunc : null, suffix : "", init : function(params){ var c = this; this.config(params); while(document.getElementById('connector-form-iframe'+this.suffix)){ if(this.suffix == "") this.suffix = 0; this.suffix += 1; } // create an invisible iframe try { this.frame = document.createElement('