Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
242 naveen 1
<!DOCTYPE html PUBLIC 
2
    "-//W3C//DTD XHTML 1.1 Transitional//EN"
3
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
 
5
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
<head>
7
<title>Select Slides - $action.getId()</title>
8
 
9
 
10
<script type="text/javascript" src="/content/jquery/jquery-1.4.2.js"></script>
11
<script type="text/javascript" src="/content/jquery/jqueryui/ui/jquery.ui.core.js"></script>
12
<script type="text/javascript" src="/content/jquery/jqueryui/ui/jquery.ui.widget.js"></script>
13
<script type="text/javascript" src="/content/jquery/jqueryui/ui/jquery.ui.position.js"></script>
14
<script type="text/javascript" src="/content/jquery/validation/jquery.validate.js"></script>
15
 
16
<style>
17
 
18
* { font-family: Verdana; font-size: 96%; }
19
label { width: 10em; float: left; }
20
label.error { float: none; color: red; padding-left: .5em; vertical-align: top; }
21
p { clear: both; }
22
.submit { margin-left: 12em; }
23
em { font-weight: bold; padding-right: 1em; vertical-align: top; }
24
 
25
a.selected {
26
  background-color:#1F75CC;
27
  color:white;
28
  z-index:100;
29
}
30
 
31
.pop {
32
  background-color:#FFFFFF;
33
  border:1px solid #999999;
34
  cursor:default;
35
  display:none;
36
  margin-top: 15px;
37
  position:absolute;
38
  text-align:left;
39
  width:394px;
40
  z-index:50;
41
  padding: 25px 25px 20px;
42
}
43
 
44
label {
45
  display: block;
46
  margin-bottom: 3px;
47
  padding-left: 15px;
48
  text-indent: -15px;
49
}
50
 
51
.pop p, .pop.div {
52
  border-bottom: 1px solid #EFEFEF;
53
  margin: 8px 0;
54
  padding-bottom: 8px;
55
}
56
</style>
57
 
58
#set ($allslidesdata = $action.getAllSlidesData())
59
#set ($mandatoryLabels = $action.getMandatorySlideLabels())
60
<script>
61
 
62
var required = [
63
#foreach ($label in $mandatoryLabels)
64
"$label"#if($velocityHasNext),#end
65
#end
66
];
67
 
68
$(document).ready(function() {
69
    //alert("document ready");
70
    $('.cancelbutton').click(function(e) {
71
        //alert("Cancel clicked");
72
        window.location.href = '/content/entity';
73
    });
74
 
75
    $('#slidesform').submit(function(e) {
76
        allchecked = new Array();
77
 
78
        // Clear old error messages
79
        $('#error').html("");
80
 
81
        $(':checked').each(function(index) {
82
            //alert($(this).attr('title'));
83
 
84
            allchecked[index] = $(this).attr('title');
85
        });
86
 
87
        //alert('allchecked:' + allchecked);
88
        missingrequired = jQuery.grep(required, function(n, i) {
89
            //alert('n:' + n + ' index:' + jQuery.inArray(n, allchecked));
90
            return (jQuery.inArray(n, allchecked) == -1);
91
        });
92
 
93
        if(missingrequired && missingrequired.length > 0) {
94
            //alert('missingrequired:' + missingrequired);
95
            $('#error').append('<span style="color:red">Missing required slides: ' + missingrequired + '</span>');
96
            return false;
97
        }
98
 
99
        // FIXME - Is not the most efficient way
100
        alldups = new Array();
101
        j = 0;
102
        for(i=0;i<allchecked.length;i++) {
103
            duplicates = jQuery.grep(allchecked, function(n, index) {
104
                return (n == allchecked[i]);
105
            });
106
            //alert("duplicates:" + duplicates);
107
 
108
            if(duplicates.length > 1 && (jQuery.inArray(duplicates[0], alldups) == -1)) {
109
                alldups[j] = duplicates[0];
110
                j++;
111
            }
112
        }
113
 
114
        if(alldups.length > 0) {
115
            //alert("alldups:" + alldups);
116
            $('#error').append('<span style="color:red">Duplicate slides: ' + alldups + '</span>');
117
            return false;
118
        }
119
 
120
        return true;
121
    });
122
});
123
</script>
124
</head>
125
<body>
126
<h1>Select Slides - $action.getId()</h1>
127
<form name="f" id="slidesform" action="/content/slides/$action.getId()" method="post">
128
 
129
#showbuttons()
130
 
131
<p id="error"/>
132
 
133
#foreach ($slidesdata in $allslidesdata)
134
#if($velocityCount == 1)
135
#showslides ($slidesdata, 1)
136
#else
137
#showslides ($slidesdata, 0)
138
#end
139
#end
140
 
141
<input type="hidden" name="_method" value="put"/>
142
 
143
#showbuttons()
144
 
145
</form>
146
</body>
147
</html>
148
 
149
#macro (showslides $slidesdata $count)
150
 
151
#set ($firstslidedata = $slidesdata.get(0))
152
<p/>
153
<h3>$firstslidedata.get(1) ($firstslidedata.get(0))</h3>
154
 
155
#foreach ($data in $slidesdata)
250 naveen 156
    <input type="checkbox" id="$data.get(2)" name="$firstslidedata.get(0)" #if($data.get(5) == "1") checked="checked" #end value="$data.get(2)" title="$data.get(3)">&nbsp;$data.get(2) - $data.get(3) #if($count == 1)<span style="font-style:italic">($data.get(4))</span>#end<br/>
242 naveen 157
#end
158
 
159
#end
160
 
161
#macro (showbuttons)
162
<p/>
163
<input type="button" class="cancelbutton" name="cancel" value="Cancel"/>
250 naveen 164
<input type="submit" name="save" value="Save & Exit"/>
242 naveen 165
<input type="submit" name="next" value="Save & Next >>"/>
166
#end