Project

General

Profile

« Previous | Next » 

Revision 78e178e2

Added by Andreas Kohlbecker over 9 years ago

related to: javascript at the and of the page

View differences:

7.x/modules/cdm_dataportal/cdm_dataportal.css
118 118
}
119 119
ul.typeDesignations li {
120 120
  background-image: none;
121
  list-style-type: none;
122
  list-style-image: none;
121 123
}
122 124

  
123 125
.form-item fieldset {
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
 */
7.x/modules/cdm_dataportal/theme/cdm_dataportal.taxon.theme
52 52
    }
53 53
    $pager->records = $taxa;
54 54
  }
55
  $showThumbnails = FALSE;
56
  if (isset($_SESSION['pageoption']['searchtaxa']['showThumbnails'])) {
57
    $showThumbnails = $_SESSION['pageoption']['searchtaxa']['showThumbnails'];
58
  }
59
  if (!is_numeric($showThumbnails)) {
60
    $showThumbnails = 1;
61
  }
62
  $setSessionUri = url('cdm_api/setvalue/session', array(
63
    'query' => array('var' => '[pageoption][searchtaxa][showThumbnails]', 'val' => ''),
64
  ));
65
  drupal_add_js('jQuery(document).ready(function() {
66

  
67
        // init
68
        if(' . $showThumbnails . ' == 1){
69
              jQuery(\'.media_gallery\').show(20);
70
        } else {
71
          jQuery(\'.media_gallery\').hide(20);
72
        }
73
        // add change hander
74
        jQuery(\'#showThumbnails\').change(
75
          function(event){
76
            var state = 0;
77
            if(jQuery(this).is(\':checked\')){
78
              jQuery(\'.media_gallery\').show(20);
79
              state = 1;
80
            } else {
81
              jQuery(\'.media_gallery\').hide(20);
82
            }
83
            // store state in session variable
84
            var uri = \'' . $setSessionUri . '\' + state;
85
            jQuery.get(uri);
86
          });
87
        });', array('type' => "inline", 'scope' => JS_DEFAULT));
88

  
89
  drupal_set_title(t('Search results'), PASS_THROUGH);
90 55

  
91 56
  $out = '';
92

  
93 57
  // Add thumbnails checkbox and refine search link.
94 58
  $out = '<div class="page_options">';
95 59
  if (isset($_REQUEST['ws'])) {
......
97 61
      $out .= '<div id="backButton">' . l(t('Modify search'), cdm_dataportal_search_form_path_for_ws($_REQUEST['ws'])) . '</div>';
98 62
    }
99 63
  }
100
  $out .= '<form name="pageoptions"><input id="showThumbnails" type="checkbox" name="showThumbnails" ' . ($showThumbnails == 1 ? 'checked="checked"' : '') . '> ' . t('Show Thumbnails') . '</form>';
64
  $out .= '<form name="pageoptions"><input id="showThumbnails" type="checkbox" name="showThumbnails" ' . (do_showThumbnails() == 1 ? 'checked="checked"' : '') . '> ' . t('Show Thumbnails') . '</form>';
101 65
  $out .= '</div>';
102 66

  
103 67
  // List results.

Also available in: Unified diff