⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rico.js

📁 一个为 Java/J2EE生成的最简化CAPTCHA的框架
💻 JS
📖 第 1 页 / 共 5 页
字号:
      this.activatedDropZones = false;   },   _addMouseDownEvent: function( htmlElement ) {      if ( typeof document.implementation != "undefined" &&         document.implementation.hasFeature("HTML",   "1.0") &&         document.implementation.hasFeature("Events", "2.0") &&         document.implementation.hasFeature("CSS",    "2.0") ) {         htmlElement.addEventListener("mousedown", this._mouseDownHandler.bindAsEventListener(this), false);      }      else {         htmlElement.attachEvent( "onmousedown", this._mouseDownHandler.bindAsEventListener(this) );      }   },   _terminateEvent: function(e) {      if ( e.stopPropagation != undefined )         e.stopPropagation();      else if ( e.cancelBubble != undefined )         e.cancelBubble = true;      if ( e.preventDefault != undefined )         e.preventDefault();      else         e.returnValue = false;   },   initializeEventHandlers: function() {      if ( typeof document.implementation != "undefined" &&         document.implementation.hasFeature("HTML",   "1.0") &&         document.implementation.hasFeature("Events", "2.0") &&         document.implementation.hasFeature("CSS",    "2.0") ) {         document.addEventListener("mouseup",   this._mouseUpHandler.bindAsEventListener(this),  false);         document.addEventListener("mousemove", this._mouseMoveHandler.bindAsEventListener(this), false);      }      else {         document.attachEvent( "onmouseup",   this._mouseUpHandler.bindAsEventListener(this) );         document.attachEvent( "onmousemove", this._mouseMoveHandler.bindAsEventListener(this) );      }   }}//var dndMgr = new Rico.DragAndDrop();//dndMgr.initializeEventHandlers();//-------------------- ricoDraggable.jsRico.Draggable = Class.create();Rico.Draggable.prototype = {   initialize: function( type, htmlElement ) {      this.type          = type;      this.htmlElement   = $(htmlElement);      this.selected      = false;   },   /**    *   Returns the HTML element that should have a mouse down event    *   added to it in order to initiate a drag operation    *    **/   getMouseDownHTMLElement: function() {      return this.htmlElement;   },   select: function() {      this.selected = true;      if ( this.showingSelected )         return;      var htmlElement = this.getMouseDownHTMLElement();      var color = Rico.Color.createColorFromBackground(htmlElement);      color.isBright() ? color.darken(0.033) : color.brighten(0.033);      this.saveBackground = RicoUtil.getElementsComputedStyle(htmlElement, "backgroundColor", "background-color");      htmlElement.style.backgroundColor = color.asHex();      this.showingSelected = true;   },   deselect: function() {      this.selected = false;      if ( !this.showingSelected )         return;      var htmlElement = this.getMouseDownHTMLElement();      htmlElement.style.backgroundColor = this.saveBackground;      this.showingSelected = false;   },   isSelected: function() {      return this.selected;   },   startDrag: function() {   },   cancelDrag: function() {   },   endDrag: function() {   },   getSingleObjectDragGUI: function() {      return this.htmlElement;   },   getMultiObjectDragGUI: function( draggables ) {      return this.htmlElement;   },   getDroppedGUI: function() {      return this.htmlElement;   },   toString: function() {      return this.type + ":" + this.htmlElement + ":";   }}//-------------------- ricoDropzone.jsRico.Dropzone = Class.create();Rico.Dropzone.prototype = {   initialize: function( htmlElement ) {      this.htmlElement  = $(htmlElement);      this.absoluteRect = null;   },   getHTMLElement: function() {      return this.htmlElement;   },   clearPositionCache: function() {      this.absoluteRect = null;   },   getAbsoluteRect: function() {      if ( this.absoluteRect == null ) {         var htmlElement = this.getHTMLElement();         var pos = RicoUtil.toViewportPosition(htmlElement);         this.absoluteRect = {            top:    pos.y,            left:   pos.x,            bottom: pos.y + htmlElement.offsetHeight,            right:  pos.x + htmlElement.offsetWidth         };      }      return this.absoluteRect;   },   activate: function() {      var htmlElement = this.getHTMLElement();      if (htmlElement == null  || this.showingActive)         return;      this.showingActive = true;      this.saveBackgroundColor = htmlElement.style.backgroundColor;      var fallbackColor = "#ffea84";      var currentColor = Rico.Color.createColorFromBackground(htmlElement);      if ( currentColor == null )         htmlElement.style.backgroundColor = fallbackColor;      else {         currentColor.isBright() ? currentColor.darken(0.2) : currentColor.brighten(0.2);         htmlElement.style.backgroundColor = currentColor.asHex();      }   },   deactivate: function() {      var htmlElement = this.getHTMLElement();      if (htmlElement == null || !this.showingActive)         return;      htmlElement.style.backgroundColor = this.saveBackgroundColor;      this.showingActive = false;      this.saveBackgroundColor = null;   },   showHover: function() {      var htmlElement = this.getHTMLElement();      if ( htmlElement == null || this.showingHover )         return;      this.saveBorderWidth = htmlElement.style.borderWidth;      this.saveBorderStyle = htmlElement.style.borderStyle;      this.saveBorderColor = htmlElement.style.borderColor;      this.showingHover = true;      htmlElement.style.borderWidth = "1px";      htmlElement.style.borderStyle = "solid";      //htmlElement.style.borderColor = "#ff9900";      htmlElement.style.borderColor = "#ffff00";   },   hideHover: function() {      var htmlElement = this.getHTMLElement();      if ( htmlElement == null || !this.showingHover )         return;      htmlElement.style.borderWidth = this.saveBorderWidth;      htmlElement.style.borderStyle = this.saveBorderStyle;      htmlElement.style.borderColor = this.saveBorderColor;      this.showingHover = false;   },   canAccept: function(draggableObjects) {      return true;   },   accept: function(draggableObjects) {      var htmlElement = this.getHTMLElement();      if ( htmlElement == null )         return;      n = draggableObjects.length;      for ( var i = 0 ; i < n ; i++ )      {         var theGUI = draggableObjects[i].getDroppedGUI();         if ( RicoUtil.getElementsComputedStyle( theGUI, "position" ) == "absolute" )         {            theGUI.style.position = "static";            theGUI.style.top = "";            theGUI.style.top = "";         }         htmlElement.appendChild(theGUI);      }   }}//-------------------- ricoEffects.js/**  *  Use the Effect namespace for effects.  If using scriptaculous effects  *  this will already be defined, otherwise we'll just create an empty  *  object for it... **/if ( window.Effect == undefined )   Effect = {};Effect.SizeAndPosition = Class.create();Effect.SizeAndPosition.prototype = {   initialize: function(element, x, y, w, h, duration, steps, options) {      this.element = $(element);      this.x = x;      this.y = y;      this.w = w;      this.h = h;      this.duration = duration;      this.steps    = steps;      this.options  = arguments[7] || {};      this.sizeAndPosition();   },   sizeAndPosition: function() {      if (this.isFinished()) {         if(this.options.complete) this.options.complete(this);         return;      }      if (this.timer)         clearTimeout(this.timer);      var stepDuration = Math.round(this.duration/this.steps) ;      // Get original values: x,y = top left corner;  w,h = width height      var currentX = this.element.offsetLeft;      var currentY = this.element.offsetTop;      var currentW = this.element.offsetWidth;      var currentH = this.element.offsetHeight;      // If values not set, or zero, we do not modify them, and take original as final as well      this.x = (this.x) ? this.x : currentX;      this.y = (this.y) ? this.y : currentY;      this.w = (this.w) ? this.w : currentW;      this.h = (this.h) ? this.h : currentH;      // how much do we need to modify our values for each step?      var difX = this.steps >  0 ? (this.x - currentX)/this.steps : 0;      var difY = this.steps >  0 ? (this.y - currentY)/this.steps : 0;      var difW = this.steps >  0 ? (this.w - currentW)/this.steps : 0;      var difH = this.steps >  0 ? (this.h - currentH)/this.steps : 0;      this.moveBy(difX, difY);      this.resizeBy(difW, difH);      this.duration -= stepDuration;      this.steps--;      this.timer = setTimeout(this.sizeAndPosition.bind(this), stepDuration);   },   isFinished: function() {      return this.steps <= 0;   },   moveBy: function( difX, difY ) {      var currentLeft = this.element.offsetLeft;      var currentTop  = this.element.offsetTop;      var intDifX     = parseInt(difX);      var intDifY     = parseInt(difY);      var style = this.element.style;      if ( intDifX != 0 )         style.left = (currentLeft + intDifX) + "px";      if ( intDifY != 0 )         style.top  = (currentTop + intDifY) + "px";   },   resizeBy: function( difW, difH ) {      var currentWidth  = this.element.offsetWidth;      var currentHeight = this.element.offsetHeight;      var intDifW       = parseInt(difW);      var intDifH       = parseInt(difH);      var style = this.element.style;      if ( intDifW != 0 )         style.width   = (currentWidth  + intDifW) + "px";      if ( intDifH != 0 )         style.height  = (currentHeight + intDifH) + "px";   }}Effect.Size = Class.create();Effect.Size.prototype = {   initialize: function(element, w, h, duration, steps, options) {      new Effect.SizeAndPosition(element, null, null, w, h, duration, steps, options);  }}Effect.Position = Class.create();Effect.Position.prototype = {   initialize: function(element, x, y, duration, steps, options) {      new Effect.SizeAndPosition(element, x, y, null, null, duration, steps, options);  }}Effect.Round = Class.create();Effect.Round.prototype = {   initialize: function(tagName, className, options) {      var elements = document.getElementsByTagAndClassName(tagName,className);      for ( var i = 0 ; i < elements.length ; i++ )         Rico.Corner.round( elements[i], options );   }};Effect.FadeTo = Class.create();Effect.FadeTo.prototype = {   initialize: function( element, opacity, duration, steps, options) {      this.element  = $(element);      this.opacity  = opacity;      this.duration = duration;      this.steps    = steps;      this.options  = arguments[4] || {};      this.fadeTo();   },   fadeTo: function() {      if (this.isFinished()) {         if(this.options.complete) this.options.complete(this);         return;      }      if (this.timer)         clearTimeout(this.timer);      var stepDuration = Math.round(this.duration/this.steps) ;      var currentOpacity = this.getElementOpacity();      var delta = this.steps > 0 ? (this.opacity - currentOpacity)/this.steps : 0;      this.changeOpacityBy(delta);      this.duration -= stepDuration;      this.steps--;      this.timer = setTimeout(this.fadeTo.bind(this), stepDuration);   },   changeOpacityBy: function(v) {      var currentOpacity = this.getElementOpacity();      var newOpacity = Math.max(0, Math.min(currentOpacity+v, 1));      this.element.ricoOpacity = newOpacity;      this.element.style.filter = "alpha(opacity:"+Math.round(newOpacity*100)+")";      this.element.style.opacity = newOpacity; /*//*/;   },   isFinished: function() {      return this.steps <= 0;   },   getElementOpacity: function() {      if ( this.element.ricoOpacity == undefined ) {         var opacity;         if ( this.element.currentStyle ) {            opacity = this.element.currentStyle.opacity;         }         else if ( document.defaultView.getComputedStyle != undefined ) {            var computedStyle = document.defaultView.getComputedStyle;            opacity = computedStyle(this.element, null).getPropertyValue('opacity');         }         this.element.ricoOpacity = opacity != undefined ? opacity : 1.0;      }      return parseFloat(this.element.ricoOpacity);   }}Effect.AccordionSize = Class.create();Effect.AccordionSize.prototype = {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -