Project

General

Profile

« Previous | Next » 

Revision 78e178e2

Added by Andreas Kohlbecker over 11 years ago

related to: javascript at the and of the page

View differences:

7.x/modules/cdm_dataportal/cdm_dataportal.module
89 89
          });
90 90

  
91 91
      });
92
    ", array('type' => 'inline'));
92
    ",
93
    array(
94
      'type' => 'inline',
95
      'scope' => 'footer'
96
    )
97
  );
93 98
}
94 99

  
95 100
/**
......
1440 1445

  
1441 1446
  $taxonPager = cdm_dataportal_search_execute();
1442 1447

  
1448
  $showThumbnails = do_showThumbnails();
1449

  
1450
  $setSessionUri = url('cdm_api/setvalue/session', array(
1451
      'query' => array('var' => '[pageoption][searchtaxa][showThumbnails]', 'val' => ''),
1452
  ));
1453

  
1454
  drupal_add_js('jQuery(document).ready(function() {
1455

  
1456
      // init
1457
      if(' . $showThumbnails . ' == 1){
1458
      jQuery(\'.media_gallery\').show(20);
1459
  } else {
1460
      jQuery(\'.media_gallery\').hide(20);
1461
  }
1462
      // add change hander
1463
      jQuery(\'#showThumbnails\').change(
1464
      function(event){
1465
      var state = 0;
1466
      if(jQuery(this).is(\':checked\')){
1467
      jQuery(\'.media_gallery\').show(20);
1468
      state = 1;
1469
  } else {
1470
      jQuery(\'.media_gallery\').hide(20);
1471
  }
1472
      // store state in session variable
1473
      var uri = \'' . $setSessionUri . '\' + state;
1474
      jQuery.get(uri);
1475
  });
1476
  });',
1477
  array('type' => "inline", 'scope' => JS_DEFAULT));
1478

  
1479
  drupal_set_title(t('Search results'), PASS_THROUGH);
1480

  
1443 1481
  return theme('cdm_search_results', array(
1444 1482
    'pager' => $taxonPager,
1445 1483
    'path' => 'cdm_dataportal/search/results/taxon',
......
1447 1485
    ));
1448 1486
}
1449 1487

  
1488
/**
1489
 * Returns the state of the the showThumbnails flag set in the
1490
 * users session ($_SESSION['pageoption']['searchtaxa']['showThumbnails']).
1491
 *
1492
 * @return Ambigous <boolean, number>
1493
 *    returns 1 if the flag is set
1494
 */
1495
function do_showThumbnails() {
1496
  static $showThumbnails = null;
1497

  
1498
  if($showThumbnails == null) {
1499
    $showThumbnails = FALSE;
1500
    if (isset($_SESSION['pageoption']['searchtaxa']['showThumbnails'])) {
1501
      $showThumbnails = $_SESSION['pageoption']['searchtaxa']['showThumbnails'];
1502
    }
1503
    if (!is_numeric($showThumbnails)) {
1504
      $showThumbnails = 1;
1505
    }
1506
  }
1507

  
1508
  return $showThumbnails;
1509
}
1510

  
1450 1511
/**
1451 1512
 * View which transforms XML output from a given webservice endpoint into JSON.
1452 1513
 */

Also available in: Unified diff