/** * Inizializza una seri e di variabile globali Javascript che * riportano le define PHP in Javascript */ var SCO_VERSION = '1.2.3'; var SCO_PATH_APPS = 'apps/'; var SCO_GATEWAY = 'index.php'; var SCO_OBJECTS = new Array(); /** * jQuery document ready */ $(document).ready( sco_init ); function sco_register( obj ) { SCO_OBJECTS.push( obj ); } /** * Funzione di inizializzazione del sistema */ function sco_init() { /** * jQuery UI patch (localizzazione) */ jQuery(function($){ $.datepicker.regional['it'] = { closeText: 'Chiudi', prevText: '<Prec', nextText: 'Succ>', currentText: 'Oggi', monthNames: ['Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno', 'Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'], monthNamesShort: ['Gen','Feb','Mar','Apr','Mag','Giu', 'Lug','Ago','Set','Ott','Nov','Dic'], dayNames: ['Domenica','Lunedì','Martedì','Mercoledì','Giovedì','Venerdì','Sabato'], dayNamesShort: ['Dom','Lun','Mar','Mer','Gio','Ven','Sab'], dayNamesMin: ['Do','Lu','Ma','Me','Gio','Ve','Sa'], dateFormat: 'dd/mm/yy', firstDay: 1, isRTL: false}; $.datepicker.setDefaults($.datepicker.regional['it']); }); /** * jQuery UI Dialog global options setting */ // $.ui.dialog.defaults.shadow = false; $.extend($.ui.dialog.defaults, { bgiframe : true, closeOnEscape : false, modal : false }); // Shadowbox.init(); // sco_initNavigation(); // for( var i = 0; i < SCO_OBJECTS.length; i++ ) SCO_OBJECTS[i].main(); } /** * Eventi sulla barra di navigazione principale */ function sco_initNavigation() { // $('div#sco_navigation ul li a img') // .hover( // function() { // $(this).stop().animate( {width: '128px', height: '128px', marginTop: '-64px' } ); // }, // function() { // $(this).stop().animate( {width: '64px', height: '64px', marginTop: '0' } ); // } // ); //$('div#sco_navigation ul li a img') $('img.sco_icon') .css( { opacity: '.5' } ) .hover( function() { $(this).stop().animate( { opacity: '1' } ); }, function() { $(this).stop().animate( { opacity: '.6' } ); } ); } /** * Carica una particolare applicazione in base all'id */ function sco_loadApplication( id ) { document.location = "/?SCO_APP_ID=" + id; } /** * Inizializza eventuali listview di sistema. Questa funzione * si preoccupa di generare le righe alternate nel background * associa l'effetto di mouseover e gestisce la selezione di * un elemento in lista. * * TODO:in futuro potrebbe gestire dei parametri * */ function scoLV_initListView() { $('table.sco_listview tbody tr:even') .css( 'background-color', '#eee' ) .data( 'bgcolor','#eee' ) .next() .css( 'background-color', '#fff' ) .data( 'bgcolor','#fff' ); $('table.sco_listview tbody tr') .data("selected", false) .click( function() { var num_sel = ( $('table.sco_listview').data('selectedRows') == undefined ) ? 0 : $('table.sco_listview').data('selectedRows'); if( !$(this).data("selected") ) { $(this).data( "selected", true); $(this).stop().animate( { backgroundColor: '#cdf' } ).css("fontWeight","bold"); num_sel++; } else { $(this).data( "selected", false); $(this).stop().animate( { backgroundColor: $(this).data('bgcolor') } ).css("fontWeight","normal"); num_sel--; } $('table.sco_listview').data('selectedRows', num_sel ); scoLV_updateRowsStatus(); } ) .hover( function() { if( !$(this).data("selected") ) $(this).stop().animate( { backgroundColor: '#cdf' } ); }, function() { if( !$(this).data("selected") ) $(this).stop().animate( { backgroundColor: $(this).data('bgcolor') } ); } ) .css( "cursor", "pointer"); scoLV_updateRowsStatus(); } /** * Seleziona tutti gli elementi di una lista * */ function scoLV_selectAllItems() { $('table.sco_listview tbody tr').data( "selected", true ).animate( { backgroundColor: '#cdf' } ).css("fontWeight","bold"); $('table.sco_listview').data('selectedRows', Number( $('table.sco_listview tbody tr').length ) ); scoLV_updateRowsStatus(); } /** * Aggiorna la "statusbar" di un ListView */ function scoLV_updateRowsStatus() { var tot = $('table.sco_listview tbody tr').length; var sel = ( $('table.sco_listview').data('selectedRows') > 0) ? ', Selezionati: ' + $('table.sco_listview').data('selectedRows') : ', Nessun elemento selezionato'; $('table.sco_listview tfoot th').eq(0).html( 'Totale: ' + tot + sel ); } /** * Rimuove dal List View le righe selezionate, cio� * che hanno data( "selected" ) = true */ function scoLV_removeSelectedItems() { $('table.sco_listview tbody tr').each( function(i,e) { if( $(e).data( "selected" ) ) { $(e).remove(); var tot = $('table.sco_listview').data('selectedRows') - 1; $('table.sco_listview').data('selectedRows', tot); } } ); scoLV_updateRowsStatus(); } /** * Mostra il box modale */ function sco_show_modal( v, cb ) { if( v ) $('div#sco_modal') .css( { height: $(document).height() + 'px' } ) .fadeIn( cb ); if( !v ) $('div#sco_modal').fadeOut(); } /** * Apre ua window modale */ function sco_open_modal_window( c ) { $('div#sco_modal') .css( { height: $(document).height() + 'px' } ) .fadeIn( function() { $('div#sco_extra') .html( '