?? rico_change.js
字號(hào):
else {
this._terminateEvent(e);
new Rico.Effect.Position( this.dragElement,
this.origPos.x,
this.origPos.y,
200,
20,
{ complete : this._doCancelDragProcessing.bind(this) } );
}
Event.stopObserving(document.body, "mousemove", this._mouseMove);
Event.stopObserving(document.body, "mouseup", this._mouseUp);
},
_retTrue: function () {
return true;
},
_completeDropOperation: function(e) {
if ( this.dragElement != this.currentDragObjects[0].getMouseDownHTMLElement() ) {
if ( this.dragElement.parentNode != null )
this.dragElement.parentNode.removeChild(this.dragElement);
}
this._deactivateRegisteredDropZones();
this._endDrag();
this.clearSelection();
this.dragElement = null;
this.currentDragObjectVisible = false;
this._terminateEvent(e);
},
_doCancelDragProcessing: function() {
this._cancelDrag();
if ( this.dragElement != this.currentDragObjects[0].getMouseDownHTMLElement() && this.dragElement)
if ( this.dragElement.parentNode != null )
this.dragElement.parentNode.removeChild(this.dragElement);
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.js
Rico.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.js
Rico.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
Rico.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;
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -