Plugin Directory

Changeset 1347228


Ignore:
Timestamp:
02/10/2016 07:21:28 AM (10 years ago)
Author:
pdamsten
Message:

infinite scroll support

Location:
fullscreen-galleria
Files:
4 deleted
3 edited
14 copied

Legend:

Unmodified
Added
Removed
  • fullscreen-galleria/tags/1.5.0/galleria-fs.js

    r1237853 r1347228  
    2525    $('[data-imgid="' + imgid + '"][data-postid="' + postid + '"]', this).first().click();
    2626  }
     27  $(document.body).on('post-load', function() {
     28    //console.log('post-load');
     29    $("[data-imgid]", this).each(function() {
     30      $(this).off('click').on('click', fsg_show_galleria);
     31    });
     32  });
    2733});
    2834
     
    119125
    120126fsg_show_galleria = function(event) {
     127  //console.log("fsg_show_galleria");
    121128  event.preventDefault();
    122129  var elem = $("#galleria");
     
    126133  var postid = $(this).attr("data-postid");
    127134  var imgid = $(this).attr("data-imgid");
     135
    128136  id = 0;
    129137  for (var i = 0; i < fsg_json[postid].length; ++i) {
     
    215223randomize_photos = function()
    216224{
    217   $(".galleria-photobox").each(function(index) {
    218     var ID = 'fsg_photobox_' + index;
     225  $(".galleria-photobox").each(function() {
     226    var ID = $(this).attr("id");
    219227    var BORDER = fsg_photobox[ID]['border'];
    220228    var COLS = fsg_photobox[ID]['cols'];
  • fullscreen-galleria/tags/1.5.0/galleria-fs.php

    r1294950 r1347228  
    55Plugin URI: http://torturedmind.org/
    66Description: Fullscreen gallery for Wordpress
    7 Version: 1.4.12
     7Version: 1.5.0
    88Author: Petri Damstén
    99Author URI: http://torturedmind.org/
     
    1212******************************************************************************/
    1313
    14 $fsg_ver = '1.4.12';
     14$fsg_ver = '1.5.0';
    1515$fsg_db_key = 'fsg_plugin_settings';
    1616
     
    3636
    3737class FSGPlugin {
    38   protected $photobox = "";
    39   protected $json = "";
    4038  protected $options = array();
    4139  protected $gps = FALSE;
     
    157155    add_filter('the_content', array(&$this, 'content'), 99);
    158156    add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
    159     //add_action('wp_head', array(&$this, 'header'));
     157    add_action('wp_head', array(&$this, 'header'));
    160158    add_action('wp_footer', array(&$this, 'footer'));
    161159    add_filter('attachment_fields_to_edit', array(&$this, 'fields_to_edit'), 10, 2);
     
    563561                'permalink' => get_permalink($val->ID).'#0');
    564562    }
    565     $id = 'fsg_photobox_'.$this->photoboxid;
    566     if (empty($this->photobox)) {
    567       $this->photobox = "fsg_photobox = {\n";
    568     }   
    569     $this->photobox .= $id.": {rows: ".$rows.", cols: ".$cols.", border: ".
     563    $id = 'fsg_photobox_'.$post->ID.'_'.$this->photoboxid;
     564    $photobox = "fsg_photobox['".$id."'] = {rows: ".$rows.", cols: ".$cols.", border: ".
    570565                       $border.", maxtiles: ".$maxtiles.", tile: ".
    571                        $tile.", repeat: ".$repeat."},\n";
     566                       $tile.", repeat: ".$repeat."};";
    572567    $this->append_json($id, $images, true);
    573568    ++$this->photoboxid;
    574     return "<div id='".$id."' class='galleria-photobox'></div>";
     569    return "<div id='".$id."' class='galleria-photobox'></div><script>".$photobox."</script>";
    575570  }
    576571
     
    716711  function header()
    717712  {
     713    //error_log('header');
    718714    if ($this->options['load_in_header']) {
    719715      // We don't know in header if we need this or not so always include.
    720716      wp_print_scripts('open-layers');
    721717    }
     718    echo "<script>fsg_json = {}; fsg_photobox = {};</script>";
    722719  }
    723720
    724721  function footer()
    725722  {
     723    //error_log('footer');
    726724    global $post;
    727725    // We call wp_print_scripts here also when gps is false so scripts get printed before
     
    733731      wp_print_scripts(($this->gps) ? 'open-layers' : '');
    734732    }
    735     if (!empty($this->json)) {
    736       $this->json = rtrim($this->json, ",\n");
    737       $this->json .= "\n};\n";
    738         $options = 'fsg_settings = '.json_encode($this->options).";\n";
    739     }
    740     if (!empty($this->photobox)) {
    741       $this->photobox = rtrim($this->photobox, ",\n");
    742       $this->photobox .= "\n};\n";
    743     }
     733    $options = 'fsg_settings = '.json_encode($this->options).";\n";
    744734    if ($this->gps) { // Open layers needs this
    745735      $url = "fullscreen_galleria_url='".plugin_dir_url(__FILE__)."';\n";
     
    760750    }
    761751    echo "<div id=\"galleria\"></div><script>".
    762          $url.$postid.$options.$attachment.$this->photobox.$this->json."</script>";
     752         $url.$postid.$options.$attachment."</script>";
    763753  }
    764754
     
    796786      return;
    797787    }
    798     if (empty($this->json)) {
    799       $this->json = "fsg_json = {\n";
    800     }
    801     $this->json .= $id.": [\n";
     788    $json = "<script>fsg_json['".$id."'] = [\n";
    802789    foreach ($images as $key => $val) {
    803790      if (!in_array($val['post_id'], $this->used)) {
     
    826813            }
    827814            if (function_exists('fsg_description')) {
     815              $d = $this->js_string(fsg_description($val['data']->post_title));
     816              if ($description != '' and $d != '') {
     817                $description .= '<br/>';
     818              }
    828819              $description .= $this->js_string(fsg_description($val['data']->post_title));
    829820            }
     
    908899          }
    909900        }
    910         $this->json .= "{id: ".$val['post_id'].
     901        $json .= "{id: ".$val['post_id'].
    911902                       ", image: '".$key.
    912903                       "', thumb: '".$thumb.
    913904                       "', permalink: '".$bookmark."'";
    914905        if ($layer_has_info) {
    915           $this->json .= ', layer: \'<div class="galleria-infolayer">'.
     906          $json .= ', layer: \'<div class="galleria-infolayer">'.
    916907                     '<div class="galleria-layeritem" style="padding-right: 20px;">'.
    917908                     $title.$caption.$description.$info.'</div>'.
     
    923914          foreach (array("thumbnail", "medium", "large", "full") as $size) {
    924915            $img = wp_get_attachment_image_src($val['post_id'], $size);
    925             $this->json .= ", ".$size.": ['".$img[0]."', ".$img[1].", ".$img[2]."]";
     916            $json .= ", ".$size.": ['".$img[0]."', ".$img[1].", ".$img[2]."]";
    926917          }
    927918        }
    928         $this->json .= "},\n";
     919        $json .= "},\n";
    929920        $images[$key]['id'] = $val['post_id'];
    930921      }
    931922    }
    932     $this->json = rtrim($this->json, ",\n");
    933     $this->json .= "\n],\n";
     923    $json = rtrim($json, ",\n");
     924    $json .= "\n];</script>\n";
     925    echo $json;
    934926  }
    935927
     
    937929  function content($content)
    938930  {
     931    //error_log('content');
    939932    global $post;
    940933    if ($this->firstpostid == -1) {
  • fullscreen-galleria/tags/1.5.0/readme.txt

    r1294950 r1347228  
    8787
    8888== Changelog ==
     89= 1.5.0 =
     90* Support for infinite scroll (jetpack)
     91
    8992= 1.4.12 =
    9093* Tested with WP 4.4
  • fullscreen-galleria/trunk/galleria-fs.js

    r1237853 r1347228  
    2525    $('[data-imgid="' + imgid + '"][data-postid="' + postid + '"]', this).first().click();
    2626  }
     27  $(document.body).on('post-load', function() {
     28    //console.log('post-load');
     29    $("[data-imgid]", this).each(function() {
     30      $(this).off('click').on('click', fsg_show_galleria);
     31    });
     32  });
    2733});
    2834
     
    119125
    120126fsg_show_galleria = function(event) {
     127  //console.log("fsg_show_galleria");
    121128  event.preventDefault();
    122129  var elem = $("#galleria");
     
    126133  var postid = $(this).attr("data-postid");
    127134  var imgid = $(this).attr("data-imgid");
     135
    128136  id = 0;
    129137  for (var i = 0; i < fsg_json[postid].length; ++i) {
     
    215223randomize_photos = function()
    216224{
    217   $(".galleria-photobox").each(function(index) {
    218     var ID = 'fsg_photobox_' + index;
     225  $(".galleria-photobox").each(function() {
     226    var ID = $(this).attr("id");
    219227    var BORDER = fsg_photobox[ID]['border'];
    220228    var COLS = fsg_photobox[ID]['cols'];
  • fullscreen-galleria/trunk/galleria-fs.php

    r1294950 r1347228  
    55Plugin URI: http://torturedmind.org/
    66Description: Fullscreen gallery for Wordpress
    7 Version: 1.4.12
     7Version: 1.5.0
    88Author: Petri Damstén
    99Author URI: http://torturedmind.org/
     
    1212******************************************************************************/
    1313
    14 $fsg_ver = '1.4.12';
     14$fsg_ver = '1.5.0';
    1515$fsg_db_key = 'fsg_plugin_settings';
    1616
     
    3636
    3737class FSGPlugin {
    38   protected $photobox = "";
    39   protected $json = "";
    4038  protected $options = array();
    4139  protected $gps = FALSE;
     
    157155    add_filter('the_content', array(&$this, 'content'), 99);
    158156    add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
    159     //add_action('wp_head', array(&$this, 'header'));
     157    add_action('wp_head', array(&$this, 'header'));
    160158    add_action('wp_footer', array(&$this, 'footer'));
    161159    add_filter('attachment_fields_to_edit', array(&$this, 'fields_to_edit'), 10, 2);
     
    563561                'permalink' => get_permalink($val->ID).'#0');
    564562    }
    565     $id = 'fsg_photobox_'.$this->photoboxid;
    566     if (empty($this->photobox)) {
    567       $this->photobox = "fsg_photobox = {\n";
    568     }   
    569     $this->photobox .= $id.": {rows: ".$rows.", cols: ".$cols.", border: ".
     563    $id = 'fsg_photobox_'.$post->ID.'_'.$this->photoboxid;
     564    $photobox = "fsg_photobox['".$id."'] = {rows: ".$rows.", cols: ".$cols.", border: ".
    570565                       $border.", maxtiles: ".$maxtiles.", tile: ".
    571                        $tile.", repeat: ".$repeat."},\n";
     566                       $tile.", repeat: ".$repeat."};";
    572567    $this->append_json($id, $images, true);
    573568    ++$this->photoboxid;
    574     return "<div id='".$id."' class='galleria-photobox'></div>";
     569    return "<div id='".$id."' class='galleria-photobox'></div><script>".$photobox."</script>";
    575570  }
    576571
     
    716711  function header()
    717712  {
     713    //error_log('header');
    718714    if ($this->options['load_in_header']) {
    719715      // We don't know in header if we need this or not so always include.
    720716      wp_print_scripts('open-layers');
    721717    }
     718    echo "<script>fsg_json = {}; fsg_photobox = {};</script>";
    722719  }
    723720
    724721  function footer()
    725722  {
     723    //error_log('footer');
    726724    global $post;
    727725    // We call wp_print_scripts here also when gps is false so scripts get printed before
     
    733731      wp_print_scripts(($this->gps) ? 'open-layers' : '');
    734732    }
    735     if (!empty($this->json)) {
    736       $this->json = rtrim($this->json, ",\n");
    737       $this->json .= "\n};\n";
    738         $options = 'fsg_settings = '.json_encode($this->options).";\n";
    739     }
    740     if (!empty($this->photobox)) {
    741       $this->photobox = rtrim($this->photobox, ",\n");
    742       $this->photobox .= "\n};\n";
    743     }
     733    $options = 'fsg_settings = '.json_encode($this->options).";\n";
    744734    if ($this->gps) { // Open layers needs this
    745735      $url = "fullscreen_galleria_url='".plugin_dir_url(__FILE__)."';\n";
     
    760750    }
    761751    echo "<div id=\"galleria\"></div><script>".
    762          $url.$postid.$options.$attachment.$this->photobox.$this->json."</script>";
     752         $url.$postid.$options.$attachment."</script>";
    763753  }
    764754
     
    796786      return;
    797787    }
    798     if (empty($this->json)) {
    799       $this->json = "fsg_json = {\n";
    800     }
    801     $this->json .= $id.": [\n";
     788    $json = "<script>fsg_json['".$id."'] = [\n";
    802789    foreach ($images as $key => $val) {
    803790      if (!in_array($val['post_id'], $this->used)) {
     
    826813            }
    827814            if (function_exists('fsg_description')) {
     815              $d = $this->js_string(fsg_description($val['data']->post_title));
     816              if ($description != '' and $d != '') {
     817                $description .= '<br/>';
     818              }
    828819              $description .= $this->js_string(fsg_description($val['data']->post_title));
    829820            }
     
    908899          }
    909900        }
    910         $this->json .= "{id: ".$val['post_id'].
     901        $json .= "{id: ".$val['post_id'].
    911902                       ", image: '".$key.
    912903                       "', thumb: '".$thumb.
    913904                       "', permalink: '".$bookmark."'";
    914905        if ($layer_has_info) {
    915           $this->json .= ', layer: \'<div class="galleria-infolayer">'.
     906          $json .= ', layer: \'<div class="galleria-infolayer">'.
    916907                     '<div class="galleria-layeritem" style="padding-right: 20px;">'.
    917908                     $title.$caption.$description.$info.'</div>'.
     
    923914          foreach (array("thumbnail", "medium", "large", "full") as $size) {
    924915            $img = wp_get_attachment_image_src($val['post_id'], $size);
    925             $this->json .= ", ".$size.": ['".$img[0]."', ".$img[1].", ".$img[2]."]";
     916            $json .= ", ".$size.": ['".$img[0]."', ".$img[1].", ".$img[2]."]";
    926917          }
    927918        }
    928         $this->json .= "},\n";
     919        $json .= "},\n";
    929920        $images[$key]['id'] = $val['post_id'];
    930921      }
    931922    }
    932     $this->json = rtrim($this->json, ",\n");
    933     $this->json .= "\n],\n";
     923    $json = rtrim($json, ",\n");
     924    $json .= "\n];</script>\n";
     925    echo $json;
    934926  }
    935927
     
    937929  function content($content)
    938930  {
     931    //error_log('content');
    939932    global $post;
    940933    if ($this->firstpostid == -1) {
  • fullscreen-galleria/trunk/readme.txt

    r1294950 r1347228  
    8787
    8888== Changelog ==
     89= 1.5.0 =
     90* Support for infinite scroll (jetpack)
     91
    8992= 1.4.12 =
    9093* Tested with WP 4.4
Note: See TracChangeset for help on using the changeset viewer.