Skip to content

Commit

Permalink
Item14444: initial release of packery bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Jul 27, 2017
0 parents commit d80fe35
Show file tree
Hide file tree
Showing 12 changed files with 7,199 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitignore
@@ -0,0 +1,13 @@
git
*.swp
*,v
*.gz
/JQPackeryContrib.md5
/JQPackeryContrib.sha1
/JQPackeryContrib.tgz
/JQPackeryContrib.txt
/JQPackeryContrib.zip
/JQPackeryContrib_installer
/JQPackeryContrib_installer.pl
pub/System/JQPackeryContrib/packery.js
pub/System/JQPackeryContrib/pkg.js
156 changes: 156 additions & 0 deletions data/System/JQPackeryContrib.txt
@@ -0,0 +1,156 @@
%META:TOPICINFO{author="micha" comment="reprev" date="1480001662" format="1.1" reprev="2" version="2"}%
---+!! %TOPIC%
%$SHORTDESCRIPTION%

%TOC%

[[http://packery.metafizzy.co/][Packery]] is a <nop>JavaScript library and jQuery plugin that makes gapless and
draggable layouts. It uses a bin-packing algorithm to fill in empty gaps.
Packery layouts can be intelligently ordered or organically wild. Elements can
be stamped in place, fit in a specific spot, or dragged around. It’s perfect
for draggable dashboard and seamless Masonry image galleries.

See also [[%SYSTEMWEB%.JQueryMasonry][JQueryMasonry]].

---++ Usage

---+++ <nop>JavaScript API

Configuring Packery is fairly easy. Simply attach the =.packery()= method
to the wrapping container element in your jQuery script. Depending on the layout,
you&#8217;ll most likely need to specify one option.

For layouts with elements that span multiple widths:

<verbatim class="js">
$('#wrapper').packery({
itemSelector: '.grid-item',
gutter: 10
});
</verbatim>

---+++ Foswiki integration

All containers classified as =jqPackery= will be processed by this plugin. Options can be specified
using HTML5 data attributes.

<verbatim class="tml">
<div class="jqPackery" data-item-selector=".grid-item">
<div class="grid-item">...</div>
<div class="grid-item">...</div>
<div class="grid-item">...</div>
...
</div>
</verbatim>

---++ Examples
%JQREQUIRE{"packery"}%
%JQREQUIRE{"autocolor" warn="off"}%

See more demos at http://packery.metafizzy.co/

<div class="jqPackery" data-draggable="true" data-percent-position="true" data-gutter="10" data-item-selector='.grid-item' data-column-width=".grid-sizer">
<div class="grid-sizer"></div>
<div class="grid-item jqAutoColor">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio.
Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna
nibh, viverra non, semper suscipit, posuere a, pede.
</div>
<div class="grid-item jqAutoColor">
Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris
sit amet orci.
</div>
<div class="grid-item jqAutoColor">
Fusce accumsan mollis eros. Pellentesque a diam sit amet mi ullamcorper
vehicula
</div>
<div class="grid-item jqAutoColor">
Suspendisse ac urna. Sit amet mi ullamcorper vehicula
</div>
<div class="grid-item jqAutoColor">
adipiscing in, lacinia vel, tellus. Suspendisse ac urna. Etiam pellentesque
mauris ut lectus.
</div>
<div class="grid-item jqAutoColor">
Sit amet mi ullamcorper vehicula lacinia vel, tellus
</div>
<div class="grid-item jqAutoColor">
Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.
</div>
<div class="grid-item jqAutoColor">
Sit amet mi ullamcorper vehicula
</div>
<div class="grid-item grid-item-width2 jqAutoColor">
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio.
Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna.
</div>
<div class="grid-item jqAutoColor">
Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris
sit amet orci.
</div>
<div class="grid-item jqAutoColor">
Fusce accumsan mollis eros. Pellentesque a diam sit amet mi
</div>

<div class="grid-item jqAutoColor">
Etiam pellentesque maurislectus. adipiscing in, lacinia vel, tellus. Suspendisse ac urna.
</div>
<div class="grid-item jqAutoColor">
Sit amet mi ullamcorper vehicula dapibus eu, fermentum et, dapibus sed, urna
</div>
<div class="grid-item jqAutoColor">
Phasellus pede arcu, dapibus eu, fermentum et, dapibus sed, urna.
</div>
</div>

<literal>
<style type="text/css">
.jqPackery {
visibility:hidden;
}
.grid-item,
.grid-sizer {
width:10%;
box-sizing:border-box;
padding: 0.5em;
}
.grid-item {
background: #D8D5D2;
-moz-border-radius: 0.5em;
-webkit-border-radius: 0.5em;
border-radius: 0.5em;
cursor:move;
}
.grid-sizer {
width:11%;
}
.grid-item {
width:22%;
}
.grid-item-width2 {
width:44%;
}
</style>
</literal>

---++ Installation Instructions

%$INSTALL_INSTRUCTIONS%

---++ Dependencies
%$DEPENDENCIES%

---++ Change History

| | |

%META:FORM{name="PackageForm"}%
%META:FIELD{name="Author" title="Author" value="MichaelDaum"}%
%META:FIELD{name="Version" title="Version" value="%25$VERSION%25"}%
%META:FIELD{name="Release" title="Release" value="%25$RELEASE%25"}%
%META:FIELD{name="Description" title="Description" value=""}%
%META:FIELD{name="Repository" title="Repository" value="https://github.com/foswiki/%25$ROOTMODULE%25"}%
%META:FIELD{name="Copyright" title="Copyright" value="2016, MichaelDaum, All Rights Reserved"}%
%META:FIELD{name="License" title="License" value="GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]])"}%
%META:FIELD{name="Home" title="Home" value="http://foswiki.org/Extensions/%25$ROOTMODULE%25"}%
%META:FIELD{name="Support" title="Support" value="http://foswiki.org/Support/%25$ROOTMODULE%25"}%
33 changes: 33 additions & 0 deletions lib/Foswiki/Contrib/JQPackeryContrib.pm
@@ -0,0 +1,33 @@
# Extension for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# JQPackeryContrib is Copyright (C) 2016 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details, published at
# http://www.gnu.org/copyleft/gpl.html

package Foswiki::Contrib::JQPackeryContrib;

use strict;
use warnings;

use Foswiki::Func ();

our $VERSION = '0.02';
our $RELEASE = '24 Nov 2016';
our $SHORTDESCRIPTION = 'Gapless, draggable grid layouts';
our $NO_PREFS_IN_TOPIC = 1;

sub init {
require Foswiki::Plugins::JQueryPlugin;
Foswiki::Plugins::JQueryPlugin::registerPlugin("JQPackeryContrib", "Foswiki::Contrib::JQPackeryContrib::Core");
}

1;
10 changes: 10 additions & 0 deletions lib/Foswiki/Contrib/JQPackeryContrib/Config.spec
@@ -0,0 +1,10 @@
# ---+ Extensions
# ---++ JQueryPlugin
# ---+++ Extra plugins
# **STRING**
$Foswiki::cfg{JQueryPlugin}{Plugins}{Packery}{Module} = 'Foswiki::Contrib::JQPackeryContrib::Core';

# **BOOLEAN**
$Foswiki::cfg{JQueryPlugin}{Plugins}{Packery}{Enabled} = 1;

1;
51 changes: 51 additions & 0 deletions lib/Foswiki/Contrib/JQPackeryContrib/Core.pm
@@ -0,0 +1,51 @@
# Extension for Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# JQPackeryContrib is Copyright (C) 2016 Michael Daum http://michaeldaumconsulting.com
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details, published at
# http://www.gnu.org/copyleft/gpl.html

package Foswiki::Contrib::JQPackeryContrib::Core;

use strict;
use warnings;

use Foswiki::Func ();

use constant TRACE => 0; # toggle me

sub writeDebug {
Foswiki::Func::writeDebug("JQPackeryContrib::Core - $_[0]") if TRACE;
}

use Foswiki::Plugins::JQueryPlugin::Plugin ();
our @ISA = qw( Foswiki::Plugins::JQueryPlugin::Plugin );

sub new {
my $class = shift;

my $this = bless(
$class->SUPER::new(
name => 'JQPackeryContrib',
version => '2.1.1',
author => 'Metafizzy',
homepage => 'http://packery.metafizzy.co/',
javascript => ['pkg.js'],
puburl => '%PUBURLPATH%/%SYSTEMWEB%/JQPackeryContrib',
dependencies => ['livequery', 'imagesloaded', 'JQUERYPLUGIN::STARS'],
),
$class
);

return $this;
}

1;
4 changes: 4 additions & 0 deletions lib/Foswiki/Contrib/JQPackeryContrib/DEPENDENCIES
@@ -0,0 +1,4 @@
# Dependencies for JQPackeryContrib
# Example:
# Time::ParseDate,>=2003.0211,cpan,Required.
# Foswiki::Plugins,>=1.2,perl,Requires version 1.2 of handler API.
13 changes: 13 additions & 0 deletions lib/Foswiki/Contrib/JQPackeryContrib/MANIFEST
@@ -0,0 +1,13 @@
data/System/JQPackeryContrib.txt 0644
lib/Foswiki/Contrib/JQPackeryContrib/Config.spec 0644
lib/Foswiki/Contrib/JQPackeryContrib/Core.pm 0644
lib/Foswiki/Contrib/JQPackeryContrib/DEPENDENCIES 0644
lib/Foswiki/Contrib/JQPackeryContrib.pm 0644
pub/System/JQPackeryContrib/Makefile 0644
pub/System/JQPackeryContrib/packery.init.uncompressed.js 0644
pub/System/JQPackeryContrib/packery.js 0644
pub/System/JQPackeryContrib/packery.js.gz 0644
pub/System/JQPackeryContrib/packery.uncompressed.js 0644
pub/System/JQPackeryContrib/pkg.js 0644
pub/System/JQPackeryContrib/pkg.js.gz 0644
pub/System/JQPackeryContrib/pkg.uncompressed.js 0644
15 changes: 15 additions & 0 deletions lib/Foswiki/Contrib/JQPackeryContrib/build.pl
@@ -0,0 +1,15 @@
#!/usr/bin/env perl

use strict;
use warnings;;

BEGIN {
unshift @INC, split( /:/, $ENV{FOSWIKI_LIBS} );
}

use Foswiki::Contrib::Build ();

my $build = new Foswiki::Contrib::Build('JQPackeryContrib');
$build->build($build->{target});

1;
20 changes: 20 additions & 0 deletions pub/System/JQPackeryContrib/Makefile
@@ -0,0 +1,20 @@
FOSWIKI_ROOT?=~/foswiki/core
TARGET=pkg.js

PKG_SOURCE=packery.uncompressed.js packery.init.uncompressed.js

-include $(FOSWIKI_ROOT)/pub/System/JQueryPlugin/Makefile.include

clean:
rm -f $(TARGET) *.gz

git:
git clone https://github.com/metafizzy/packery.git $@

ifneq (,$(wildcard git))
packery.uncompressed.js: git/dist/packery.pkgd.js
cp $^ $@
endif

pkg.uncompressed.js: $(PKG_SOURCE)
cat $^ > $@
32 changes: 32 additions & 0 deletions pub/System/JQPackeryContrib/packery.init.uncompressed.js
@@ -0,0 +1,32 @@
"use strict";
jQuery(function($) {
var defaults = {
waitForImages: true
};

$(".jqPackery:not(.jqPackeryInited)").livequery(function() {
var $this = $(this),
opts = $.extend({}, defaults, $this.data()),
$items;

$this.one('layoutComplete', function() {
$this.css('visibility', 'visible');//.hide().fadeIn();
});

if (opts.waitForImages) {
$this.imagesLoaded(function() {
$this.packery(opts);
});
} else {
$this.packery(opts);
}

if (opts.draggable) {
$items = $($this.packery('getItemElements')).draggable();
$this.packery( 'bindUIDraggableEvents', $items );
}

$this.addClass("jqPackeryInited");
});
});

0 comments on commit d80fe35

Please sign in to comment.