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

📄 rico.js

📁 Ajax经典实例大全,关于ajax非常多的实例,适合下载学习
💻 JS
📖 第 1 页 / 共 5 页
字号:
      this._deactivateRegisteredDropZones();      this.dragElement = null;      this.currentDragObjectVisible = false;   },   _placeDraggableInDropZone: function(e) {      var foundDropZone = false;      var n = this.dropZones.length;      for ( var i = 0 ; i < n ; i++ ) {         if ( this._mousePointInDropZone( e, this.dropZones[i] ) ) {            if ( this.dropZones[i].canAccept(this.currentDragObjects) ) {               this.dropZones[i].hideHover();               this.dropZones[i].accept(this.currentDragObjects);               foundDropZone = true;               break;            }         }      }      return foundDropZone;   },   _cancelDrag: function() {      for ( var i = 0 ; i < this.currentDragObjects.length ; i++ )         this.currentDragObjects[i].cancelDrag();   },   _endDrag: function() {      for ( var i = 0 ; i < this.currentDragObjects.length ; i++ )         this.currentDragObjects[i].endDrag();   },   _mousePointInDropZone: function( e, dropZone ) {      var absoluteRect = dropZone.getAbsoluteRect();      return e.clientX  > absoluteRect.left + this._leftOffset(e) &&             e.clientX  < absoluteRect.right + this._leftOffset(e) &&             e.clientY  > absoluteRect.top + this._topOffset(e)   &&             e.clientY  < absoluteRect.bottom + this._topOffset(e);   },   _addMouseDownHandler: function( aDraggable )   {       htmlElement  = aDraggable.getMouseDownHTMLElement();      if ( htmlElement  != null ) {          htmlElement.draggable = aDraggable;         Event.observe(htmlElement , "mousedown", this._onmousedown.bindAsEventListener(this));         Event.observe(htmlElement, "mousedown", this._mouseDown);      }   },   _activateRegisteredDropZones: function() {      var n = this.dropZones.length;      for ( var i = 0 ; i < n ; i++ ) {         var dropZone = this.dropZones[i];         if ( dropZone.canAccept(this.currentDragObjects) )            dropZone.activate();      }      this.activatedDropZones = true;   },   _deactivateRegisteredDropZones: function() {      var n = this.dropZones.length;      for ( var i = 0 ; i < n ; i++ )         this.dropZones[i].deactivate();      this.activatedDropZones = false;   },   _onmousedown: function () {     Event.observe(document.body, "mousemove", this._mouseMove);     Event.observe(document.body, "mouseup",  this._mouseUp);   },   _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.jsRico.Effect = {};Rico.Effect.SizeAndPosition = Class.create();Rico.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";   }}Rico.Effect.Size = Class.create();Rico.Effect.Size.prototype = {   initialize: function(element, w, h, duration, steps, options) {      new Rico.Effect.SizeAndPosition(element, null, null, w, h, duration, steps, options);  }}Rico.Effect.Position = Class.create();Rico.Effect.Position.prototype = {   initialize: function(element, x, y, duration, steps, options) {      new Rico.Effect.SizeAndPosition(element, x, y, null, null, duration, steps, options);  }}Rico.Effect.Round = Class.create();Rico.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 );   }};Rico.Effect.FadeTo = Class.create();

⌨️ 快捷键说明

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