[Jifty-commit] r1082 - in jifty/trunk: . lib/Jifty/Web
lib/Jifty/Web/Form share/web/static/js
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri May 19 13:31:51 EDT 2006
Author: alexmv
Date: Fri May 19 13:31:50 2006
New Revision: 1082
Added:
jifty/trunk/share/web/templates/__jifty/empty
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Web/Form/Clickable.pm
jifty/trunk/lib/Jifty/Web/Form/Element.pm
jifty/trunk/lib/Jifty/Web/PageRegion.pm
jifty/trunk/share/web/static/js/jifty.js
Log:
r13084 at zoq-fot-pik: chmrr | 2006-05-19 13:31:40 -0400
* 'toggle' flag on fragment requests
* Remove old _bootstrap code from PageRegions
* Pageregions now default to the 'empty' region as a path
Modified: jifty/trunk/lib/Jifty/Web/Form/Clickable.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Clickable.pm (original)
+++ jifty/trunk/lib/Jifty/Web/Form/Clickable.pm Fri May 19 13:31:50 2006
@@ -482,9 +482,17 @@
for my $hook (@hooks) {
$hook->{region} ||= $hook->{refresh} || Jifty->web->qualified_region;
$hook->{args} ||= {};
+ my $region = ref $hook->{region} ? $hook->{region} : Jifty->web->get_region( $hook->{region} );
- $self->region_fragment( $hook->{region}, $hook->{replace_with} )
- if $hook->{replace_with};
+ if ($hook->{replace_with}) {
+ # Toggle region if the toggle flag is set, and clicking wouldn't change path
+ if ($hook->{toggle} and $region and $hook->{replace_with} eq $region->path) {
+ $self->region_fragment( $hook->{region}, "/__jifty/empty" )
+ } else {
+ $self->region_fragment( $hook->{region}, $hook->{replace_with} )
+ }
+
+ }
$self->region_argument( $hook->{region}, $_ => $hook->{args}{$_} )
for keys %{ $hook->{args} };
if ( $hook->{submit} ) {
Modified: jifty/trunk/lib/Jifty/Web/Form/Element.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/Form/Element.pm (original)
+++ jifty/trunk/lib/Jifty/Web/Form/Element.pm Fri May 19 13:31:50 2006
@@ -61,6 +61,12 @@
=over
+=item toggle => BOOLEAN
+
+If set to true, then the link will possibly toggle the region to
+empty, if the region's current path is the same as the path the region
+is trying to be set to.
+
=item region => REGION
The region that should be updated. This defaults to the current
@@ -187,6 +193,9 @@
$args{region} = $args{element} =~ /^#region-(\S+)/ ? "$1-".Jifty->web->serial : Jifty->web->serial;
}
+ # Toggle functionality
+ $args{toggle} = 1 if $hook->{toggle};
+
# Arguments
$args{args} = $hook->{args} || {};
Modified: jifty/trunk/lib/Jifty/Web/PageRegion.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Web/PageRegion.pm (original)
+++ jifty/trunk/lib/Jifty/Web/PageRegion.pm Fri May 19 13:31:50 2006
@@ -32,7 +32,8 @@
=item path
-The path to the fragment that this page region contains.
+The path to the fragment that this page region contains. Defaults to
+C</__jifty/empty>, which, as its name implies, is empty.
=item defaults (optional)
@@ -59,17 +60,16 @@
my %args = (
name => undef,
- path => undef,
+ path => "/__jifty/empty",
defaults => {},
- _bootstrap => undef,
parent => undef,
region_wrapper => 1,
@_
);
- # Name and path are required
- if (not $args{_bootstrap} and (not defined $args{name} or not defined $args{path})) {
- warn "Name and path are required for page regions. We got ".join(",", %args);
+ # Name is required
+ if (not defined $args{name}) {
+ warn "Name is required for page regions.";
return;
}
@@ -86,7 +86,7 @@
$self->default_arguments($args{defaults});
$self->arguments({});
$self->parent($args{parent} || Jifty->web->current_region);
- $self->region_wrapper(not $args{_bootstrap} and $args{region_wrapper});
+ $self->region_wrapper($args{region_wrapper});
# Keep track of the fully qualified name (which should be unique)
$self->log->warn("Repeated region: " . $self->qualified_name)
Modified: jifty/trunk/share/web/static/js/jifty.js
==============================================================================
--- jifty/trunk/share/web/static/js/jifty.js (original)
+++ jifty/trunk/share/web/static/js/jifty.js Fri May 19 13:31:50 2006
@@ -393,7 +393,7 @@
var request = $H();
// Set request base path
- request['path'] = document.URL;
+ request['path'] = '/__jifty/empty';
// Build actions structure
request['actions'] = {};
@@ -456,6 +456,11 @@
// Make the region (for now)
new Region(name, f['args'], f['path'], f['parent']);
+ } else if ((f['path'] != null) && f['toggle'] && (f['path'] == fragments[name].path)) {
+ // If they set the 'toggle' flag, and clicking wouldn't change the path
+ Element.update(element, '');
+ fragments[name].path = null;
+ continue;
} else if (f['path'] == null) {
// If they didn't know tha path, fill it in now
f['path'] == fragments[name].path;
Added: jifty/trunk/share/web/templates/__jifty/empty
==============================================================================
More information about the Jifty-commit
mailing list