aboutsummaryrefslogtreecommitdiffstats
path: root/ui/effects/effect-drop.js
blob: c7e3d7a6ebd4c09a137839b2659e738491795d4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*!
 * jQuery UI Effects Drop @VERSION
 * http://jqueryui.com
 *
 * Copyright jQuery Foundation and other contributors
 * Released under the MIT license.
 * http://jquery.org/license
 */

//>>label: Drop Effect
//>>group: Effects
//>>description: Moves an element in one direction and hides it at the same time.
//>>docs: http://api.jqueryui.com/drop-effect/
//>>demos: http://jqueryui.com/effect/

( function( factory ) {
	if ( typeof define === "function" && define.amd ) {

		// AMD. Register as an anonymous module.
		define( [
			"jquery",
			"../version",
			"../effect"
		], factory );
	} else {

		// Browser globals
		factory( jQuery );
	}
}( function( $ ) {

return $.effects.define( "drop", "hide", function( options, done ) {

	var distance,
		element = $( this ),
		mode = options.mode,
		show = mode === "show",
		direction = options.direction || "left",
		ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
		motion = ( direction === "up" || direction === "left" ) ? "-=" : "+=",
		oppositeMotion = ( motion === "+=" ) ? "-=" : "+=",
		animation = {
			opacity: 0
		};

	$.effects.createPlaceholder( element );

	distance = options.distance ||
		element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;

	animation[ ref ] = motion + distance;

	if ( show ) {
		element.css( animation );

		animation[ ref ] = oppositeMotion + distance;
		animation.opacity = 1;
	}

	// Animate
	element.animate( animation, {
		queue: false,
		duration: options.duration,
		easing: options.easing,
		complete: done
	} );
} );

} ) );
String id; private LengthRangeProperty inlineProgressionDimension; private KeepProperty keepTogether; private KeepProperty keepWithNext; private KeepProperty keepWithPrevious; private Length width; private int wrapOption; // End of property values // used for FO validation private boolean blockOrInlineItemFound = false; private boolean canHaveBlockLevelChildren = true; /** * @param parent FONode that is the parent of this object */ public Inline(FONode parent) { super(parent); } /** * @see org.apache.fop.fo.FObj#bind(PropertyList) */ public void bind(PropertyList pList) throws FOPException { super.bind(pList); commonRelativePosition = pList.getRelativePositionProps(); alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength(); alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum(); baselineShift = pList.get(PR_BASELINE_SHIFT).getLength(); blockProgressionDimension = pList.get(PR_BLOCK_PROGRESSION_DIMENSION).getLengthRange(); dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum(); height = pList.get(PR_HEIGHT).getLength(); id = pList.get(PR_ID).getString(); inlineProgressionDimension = pList.get(PR_INLINE_PROGRESSION_DIMENSION).getLengthRange(); keepTogether = pList.get(PR_KEEP_TOGETHER).getKeep(); keepWithNext = pList.get(PR_KEEP_WITH_NEXT).getKeep(); keepWithPrevious = pList.get(PR_KEEP_WITH_PREVIOUS).getKeep(); width = pList.get(PR_WIDTH).getLength(); wrapOption = pList.get(PR_WRAP_OPTION).getEnum(); } /** * @see org.apache.fop.fo.FONode#startOfNode */ protected void startOfNode() throws FOPException { /* Check to see if this node can have block-level children. * See validateChildNode() below. */ int lvlLeader = findAncestor(FO_LEADER); int lvlFootnote = findAncestor(FO_FOOTNOTE); int lvlInCntr = findAncestor(FO_INLINE_CONTAINER); if (lvlLeader > 0) { if (lvlInCntr < 0 || (lvlInCntr > 0 && lvlInCntr > lvlLeader)) { canHaveBlockLevelChildren = false; } } else if (lvlFootnote > 0) { if (lvlInCntr < 0 || lvlInCntr > lvlFootnote) { canHaveBlockLevelChildren = false; } } checkId(id); getFOEventHandler().startInline(this); } /** * @see org.apache.fop.fo.FONode#endOfNode */ protected void endOfNode() throws FOPException { super.endOfNode(); getFOEventHandler().endInline(this); } /** * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String) * XSL Content Model: marker* (#PCDATA|%inline;|%block;)* * Additionally: " An fo:inline that is a descendant of an fo:leader * or fo:footnote may not have block-level children, unless it has a * nearer ancestor that is an fo:inline-container." (paraphrased) */ protected void validateChildNode(Locator loc, String nsURI, String localName) throws ValidationException { if (FO_URI.equals(nsURI) && localName.equals("marker")) { if (blockOrInlineItemFound) { nodesOutOfOrderError(loc, "fo:marker", "(#PCDATA|%inline;|%block;)"); } } else if (!isBlockOrInlineItem(nsURI, localName)) { invalidChildError(loc, nsURI, localName); } else if (!canHaveBlockLevelChildren && isBlockItem(nsURI, localName)) { String ruleViolated = " An fo:inline that is a descendant of an fo:leader" + " or fo:footnote may not have block-level children," + " unless it has a nearer ancestor that is an" + " fo:inline-container."; invalidChildError(loc, nsURI, localName, ruleViolated); } else { blockOrInlineItemFound = true; } } /** * Return the "id" property. */ public String getId() { return id; } /** * @return the "alignment-adjust" property */ public Length getAlignmentAdjust() { return alignmentAdjust; } /** * @return the "alignment-baseline" property */ public int getAlignmentBaseline() { return alignmentBaseline; } /** * @return the "baseline-shift" property */ public Length getBaselineShift() { return baselineShift; } /** * @return the "dominant-baseline" property */ public int getDominantBaseline() { return dominantBaseline; } /** * @see org.apache.fop.fo.FObjMixed#charIterator */ public CharIterator charIterator() { return new InlineCharIterator(this, commonBorderPaddingBackground); } /** * @see org.apache.fop.fo.FObj#getName() */ public String getName() { return "fo:inline"; } /** * @see org.apache.fop.fo.FObj#getNameId() */ public int getNameId() { return FO_INLINE; } }