1 | /// |
---|
2 | // Use jquery |
---|
3 | |
---|
4 | /** |
---|
5 | * This method indicates if an element is included in a list |
---|
6 | * @param list |
---|
7 | * @param element |
---|
8 | * |
---|
9 | */ |
---|
10 | function content( elementList, element ) |
---|
11 | { |
---|
12 | var index = jQuery.inArray( element, elementList ); |
---|
13 | return (-1 != index); |
---|
14 | } |
---|
15 | |
---|
16 | function getJSONUser() |
---|
17 | { |
---|
18 | return getLoginModule().getJSONUser(); |
---|
19 | } |
---|
20 | |
---|
21 | function getJSONUserRole() |
---|
22 | { |
---|
23 | return getLoginModule().getJSONUserRole(); |
---|
24 | } |
---|
25 | |
---|
26 | function getPath() |
---|
27 | { |
---|
28 | return InterfaceTemplate.path; |
---|
29 | } |
---|
30 | |
---|
31 | function setPath( path ) |
---|
32 | { |
---|
33 | InterfaceTemplate.path = path; |
---|
34 | } |
---|
35 | |
---|
36 | function getLoginModule() |
---|
37 | { |
---|
38 | return InterfaceTemplate.loginModule; |
---|
39 | } |
---|
40 | |
---|
41 | function setLoginModule( loginModule ) |
---|
42 | { |
---|
43 | InterfaceTemplate.loginModule = loginModule; |
---|
44 | } |
---|
45 | |
---|
46 | function neededLogin( href ) |
---|
47 | { |
---|
48 | $( "#signin_menu" ).ready( function() |
---|
49 | { |
---|
50 | if( !getJSONUser() ) |
---|
51 | getLoginModule().showLogin( loginTexts["login.text"] ); |
---|
52 | else |
---|
53 | document.location.href = getPath() + href; |
---|
54 | } ); |
---|
55 | } |
---|
56 | |
---|
57 | // Si besoin pour afficher le module dÚs le chargement de la page |
---|
58 | //window.onload = function() |
---|
59 | //{ |
---|
60 | // getLoginModule().showLogin( "<bean:message key="login.text"/>" ); |
---|
61 | //} |
---|
62 | |
---|
63 | |
---|
64 | // Need to import javascript librairy "calendar/anytime.js" |
---|
65 | function formatDate( date, formatDate ) |
---|
66 | { |
---|
67 | var format = formatDate ? formatDate : "%Y-%m-%d %H:%i"; |
---|
68 | var calendarConverter = new AnyTime.Converter( { format: format } ); |
---|
69 | return calendarConverter.format( date ); |
---|
70 | } |
---|
71 | |
---|
72 | // PAGINATION |
---|
73 | function decrementPage( pageContainer, maxPageContainer ) |
---|
74 | { |
---|
75 | var value = parseInt( $( pageContainer ).html() ); |
---|
76 | setPage( value - 1, pageContainer, maxPageContainer ); |
---|
77 | } |
---|
78 | |
---|
79 | function incrementPage( pageContainer, maxPageContainer ) |
---|
80 | { |
---|
81 | var value = parseInt( $( pageContainer ).html() ); |
---|
82 | setPage( value + 1, pageContainer, maxPageContainer ); |
---|
83 | } |
---|
84 | |
---|
85 | function resetPage( pageContainer, maxPageContainer ) |
---|
86 | { |
---|
87 | var maxPages = parseInt( $( maxPageContainer ).html() ); |
---|
88 | var page = Math.min( 1, maxPages ); |
---|
89 | $( pageContainer ).textContent = Math.max( 1, page ); |
---|
90 | } |
---|
91 | |
---|
92 | function setPage( page, pageContainer, maxPageContainer ) |
---|
93 | { |
---|
94 | var maxPages = parseInt( $( maxPageContainer ).html() ); |
---|
95 | page = Math.min( page, maxPages ); |
---|
96 | $( pageContainer ).html( Math.max( 1, page ) ); |
---|
97 | } |
---|