bernard
authored
|
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich"
xmlns:imageSelectTool="http://richfaces.org/sandbox/imageSelectTool"
>
<head>
<title>ImageSelectTool sample</title>
<style type="text/css">
input.short {
width: 30px;
}
</style>
</head>
<body class="rich-container">
<ui:include src="menu.xhtml"/>
<p>
</p>
<rich:messages ajaxRendered="true"/>
<h:panelGrid columns="3">
<h:panelGroup>
<h:form>
<h:panelGrid columns="2">
<h:outputLabel value="srcImage" for="srcImage"/>
<h:inputText value="#{cropper.srcImage}" id="srcImage"/>
<h:outputLabel value="minWidth" for="minWidth"/>
<h:inputText value="#{cropper.minWidth}" id="minWidth"/>
<h:outputLabel value="minHeight" for="minHeight"/>
<h:inputText value="#{cropper.minHeight}" id="minHeight"/>
<h:outputLabel value="maxWidth" for="maxWidth"/>
<h:inputText value="#{cropper.maxWidth}" id="maxWidth"/>
<h:outputLabel value="maxHeight" for="maxHeight"/>
<h:inputText value="#{cropper.maxHeight}" id="maxHeight"/>
<h:outputLabel value="backgroundColor" for="backgroundColor"/>
<h:inputText value="#{cropper.backgroundColor}" id="backgroundColor"/>
<h:outputLabel value="backgroundOpacity" for="backgroundOpacity"/>
<h:inputText value="#{cropper.backgroundOpacity}" id="backgroundOpacity"/>
<h:outputLabel value="aspectRatio" for="aspectRatio"/>
<h:inputText value="#{cropper.aspectRatio}" id="aspectRatio"/>
</h:panelGrid>
<h:commandButton value="Submit"/>
</h:form>
<div id="coords"/>
<input type="text" id="x" class="short"/>
<input type="text" id="y" class="short"/>
<input type="text" id="width" class="short"/>
<input type="text" id="height" class="short"/>
<input type="button" id="setSelection" value="Set selection"/>
<input type="button" id="animateTo" value="Animate to"/>
<h:form>
</h:form>
</h:panelGroup>
<h:graphicImage value="#{cropper.srcImage}" id="image"/>
<rich:panel id="result">
#{cropper.selection}
</rich:panel>
</h:panelGrid>
<script type="text/javascript">
function updateInputs(event) {
jQuery('#coords').html('selected:' + event.x + ';' + event.y + ';' + event.width + ';' + event.height);
jQuery('#x').val(event.x);
jQuery('#y').val(event.y);
jQuery('#width').val(event.width);
jQuery('#height').val(event.height);
}
jQuery('#setSelection').click(function() {
selector.setSelection(
parseInt(jQuery('#x').val()),
parseInt(jQuery('#y').val()),
parseInt(jQuery('#width').val()),
parseInt(jQuery('#height').val())
);
});
jQuery('#animateTo').click(function() {
selector.animateTo(
parseInt(jQuery('#x').val()),
parseInt(jQuery('#y').val()),
parseInt(jQuery('#width').val()),
parseInt(jQuery('#height').val())
);
});
</script>
<h:form>
<imageSelectTool:imageSelectTool id="selector"
for="image"
var="selector"
value="#{cropper.selection}"
aspectRatio="#{cropper.aspectRatio}"
backgroundColor="#{cropper.backgroundColor}"
backgroundOpacity="#{cropper.backgroundOpacity}"
maxHeight="#{cropper.maxHeight}"
maxWidth="#{cropper.maxWidth}"
minWidth="#{cropper.minWidth}"
minHeight="#{cropper.minHeight}"
onchange="updateInputs(event);"
onselect="updateInputs(event);reRenderResult()"/>
<a4j:jsFunction name="reRenderResult" reRender="result"/>
<a4j:commandButton value="ReRender image" reRender="image"/>
<a4j:commandButton value="ReRender imageSelectTool" reRender="selector"/>
<a4j:commandButton value="ReRender both" reRender="selector,image"/>
</h:form>
<rich:insert src="/index.xhtml" highlight="xhtml" rendered="#{showSource!=false}"/>
</body>
</html>
|