source: tapas/web/resources/js/classesForJQuery/etherHelper.js @ 382

Last change on this file since 382 was 382, checked in by vmipsl, 12 years ago

clean

File size: 2.2 KB
Line 
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 */
10function content( elementList, element )
11{
12    var index = jQuery.inArray( element, elementList );
13    return (-1 != index);
14}
15
16function getJSONUser()
17{
18    return getLoginModule().getJSONUser();
19}
20
21function getJSONUserRole()
22{
23    return getLoginModule().getJSONUserRole();
24}
25
26function getPath()
27{
28    return InterfaceTemplate.path;
29}
30
31function setPath( path )
32{
33    InterfaceTemplate.path = path;
34}
35
36function getLoginModule()
37{
38    return InterfaceTemplate.loginModule;
39}
40
41function setLoginModule( loginModule )
42{
43    InterfaceTemplate.loginModule = loginModule;
44}
45
46function 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"
65function 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
73function decrementPage( pageContainer, maxPageContainer )
74{
75    var value = parseInt( $( pageContainer ).html() );
76    setPage( value - 1, pageContainer, maxPageContainer );
77}
78
79function incrementPage( pageContainer, maxPageContainer )
80{
81    var value = parseInt( $( pageContainer ).html() );
82    setPage( value + 1, pageContainer, maxPageContainer );
83}
84
85function 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
92function 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}
Note: See TracBrowser for help on using the repository browser.