contrib: Intro Opportunity, a meetup planner in Nit
[nit.git] / contrib / opportunity / src / templates / meetup_creation.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License
14
15 module meetup_creation
16
17 import boilerplate
18
19 class MeetupCreationPage
20 super OpportunityPage
21
22 init do
23 header.page_js = """
24 function new_answer(sender){
25 var ansdiv = $('#answers');
26 var nb = ansdiv.children()
27 var s = nb.last();
28 var ss = s.attr("id").split('_');
29 var l = ss[ss.length - 1];
30 nb = parseInt(l) + 1;
31 var ch = ansdiv.children();
32 ch.last().after('<input name="answer_' + nb + '" id="answer_' + nb + '" class="form-control" type="text" placeholder="Answer">')
33 ch.last().after('<label for="answer_' + nb + '">' + nb + '</label>');
34 }
35 """
36 body = """
37 <div class="page-header">
38 <center><h1>New meetup</h1></center>
39 </div>
40 <center>
41 <form action="meetup_create" method="POST" role="form">
42 <div class = "form-group">
43 <label for="meetup_name">Meetup Name : </label>
44 <input name="meetup_name" id="meetup_name" type="text" class="form-control" placeholder="Meetup Name"/>
45 <label for="meetup_date">When ? </label>
46 <input name="meetup_date" id="meetup_date" type="text" class="form-control" placeholder="Time of the event">
47 <label for="meetup=place">Where ? </label>
48 <input name="meetup_place" id="meetup_place" type="text" class="form-control" placeholder="Place of the event">
49 </div>
50 <div id="answers" class="form-group">
51 <h2>Answers</h2>
52 <label for="answer_1">1</label>
53 <input name="answer_1" id="answer_1" type="text" class="form-control" placeholder="Answer">
54 </div>
55 <div class="form-group">
56 <button type="button" class="btn btn-lg" onclick="new_answer(this)">Add answer</button>
57 </div>
58 <div class="form-group">
59 <button type="submit" class="btn btn-lg btn-success">Finish</button>
60 </div>
61 </form>
62 </center>
63 """
64 end
65
66 end