Section |
---|
Column |
---|
| This page will walk you through an example of adding the Fluid CropperUI component to your application. This tutorial assumes that: - you are already familiar with HTML, Javascript and CSS
- you are familiar with what the CropperUI is and does
- now you just want to know how to add it to your file.
Note |
---|
title | Important note about the compatibility of Cropper UI |
---|
| It uses the HTML5 canvas element and therefore requires a browser that supports HTML5. |
Tutorial: How to Use the Cropper UIScenarioSuppose you are developing a tool for editing images on a web page. This tutorial will show you how to use the Fluid CropperUI for this. There are four basic steps to adding the Cropper UI to your application: - Setup: Download and install the Fluid Infusion library
- Step 1: Prepare your markup
- Step 2: Write the script
- Step 3: Add the script to your HTML
The rest of this tutorial will explain each of these steps in detail. |
Column |
---|
Panel |
---|
borderColor | #566b30 |
---|
bgColor | #fff |
---|
titleBGColor | #D3E3C4 |
---|
borderStyle | solid |
---|
title | On This Page | borderStyle
---|
| | solid |
Panel |
---|
borderColor | #321137 |
---|
bgColor | #fff |
---|
titleBGColor | #c1b7c3 |
---|
borderStyle | solid |
---|
title | See Also |
---|
borderStyle | solid |
---|
| |
Panel |
---|
borderColor | #321137 |
---|
bgColor | #fff |
---|
titleBGColor | #cccccc |
---|
borderStyle | solid |
---|
title | Still need help? |
---|
borderStyle | solid |
---|
| Join the infusion-users mailing list and ask your questions there. |
|
|
...
- canvas: The canvas object with which the cropper UI should associate.
- resizeFactor: The factor with which the image has been resized to fit in the canvas. e.g. if the original image width is 1000px and the canvas width is 500px, then the resize factor would be 2.
- image: The image to be drawn in canvas.
- imageX: The x coordinate for image to be drawn in canvas.
- imageY: The y coordinate for image to be drawn in canvas.
After the init method is called, the user can use the cropper to select the bounding box from the image. You can also activate the keyboard accessibility for cropper by calling the following method:
Code Block |
---|
|
myCropper.activateKeyboardAccessibility();
|
To confirm the crop action, call the following method:
Code Block |
---|
|
var croppingReturnValues = myCropper.reset();
var croppedImageDataURL = croppingReturnValues[0];
var croppingDimensions = croppingReturnValues[1]; |
To cancel the crop action without actually cropping the image:
Code Block |
---|
|
myCropper.reset(true); |
...
Anchor |
---|
| Step 3: Add the script to your HTML |
---|
| Step 3: Add the script to your HTML |
---|
|
Step 3: Add the script to your HTML
...
Code Block |
---|
|
<link rel="stylesheet" type="text/css" href="../../../framework/fss/css/fss-reset-global.css" />
<link rel="stylesheet" type="text/css" href="../../../framework/fss/css/fss-base-global.css" />
<link rel="stylesheet" type="text/css" href="../../../framework/fss/css/fss-text.css" />
<link rel="stylesheet" type="text/css" href="../../../framework/fss/css/fss-layout.css" />
<link rel="stylesheet" type="text/css" href="../../inlineEdit/css/InlineEdit.css" />
<link rel="stylesheet" type="text/css" href="../css/ImageEditor.css" />
<link rel="stylesheet" type="text/css" href="../../taggerUI/css/TaggerUI.css" />
<!-- Fluid and jQuery Dependencies -->
<script type="text/javascript" src="infusion/src/webapp/lib/jquery/core/js/jquery.js"></script>
<script type="text/javascript" src="infusion/src/webapp/lib/jquery/ui/js/jquery.ui.core.js"></script>
<script type="text/javascript" src="infusion/src/webapp/framework/core/js/jquery.keyboard-a11y.js"></script>
<script type="text/javascript" src="infusion/src/webapp/lib/jquery/plugins/scrollTo/js/jquery.scrollTo.js"></script>
<script type="text/javascript" src="infusion/src/webapp/lib/swfobject/js/swfobject.js"></script>
<script type="text/javascript" src="infusion/src/webapp/lib/swfupload/js/swfupload.js"></script>
<script type="text/javascript" src="infusion/src/webapp/framework/core/js/Fluid.js"></script>
<script type="text/javascript" src="infusion/src/webapp/framework/core/js/FluidDocument.js"></script>
<script type="text/javascript" src="infusion/src/webapp/framework/core/js/FluidView.js"></script>
<script type="text/javascript" src="infusion/src/webapp/framework/core/js/DataBinding.js"></script>
<script type="text/javascript" src="infusion/src/webapp/framework/core/js/FluidIoC.js"></script>
<script type="text/javascript" src="infusion/src/webapp/framework/enhancement/js/ProgressiveEnhancement.js"></script>
<!-- Cropper UI dependencies -->
<script type="text/javascript" src="infusion/src/webapp/components/cropperUI/js/CropperUI.js"></script>
|
...