[Jifty-commit] jifty branch, master, updated. jifty-1.10228-16-g4349918
Jifty commits
jifty-commit at lists.jifty.org
Mon Apr 25 12:19:38 EDT 2011
The branch, master has been updated
via 434991816a1f760c37ea805325a2e4fd1dae2b17 (commit)
from 9d0795c7f83ffe49d8bc693dbecdf56db0c92287 (commit)
Summary of changes:
lib/Jifty/Web/Form/Element.pm | 13 ++++---------
share/web/static/js/jifty.js | 8 +++++++-
2 files changed, 11 insertions(+), 10 deletions(-)
- Log -----------------------------------------------------------------
commit 434991816a1f760c37ea805325a2e4fd1dae2b17
Author: Alex Vandiver <alexmv at bestpractical.com>
Date: Mon Apr 25 12:18:26 2011 -0400
Shorten onclick handlers by removing repeated boilerplate
This reduces page size significantly on pages which use them frequently.
diff --git a/lib/Jifty/Web/Form/Element.pm b/lib/Jifty/Web/Form/Element.pm
index 853072b..e554a8b 100644
--- a/lib/Jifty/Web/Form/Element.pm
+++ b/lib/Jifty/Web/Form/Element.pm
@@ -560,15 +560,10 @@ sub javascript_attrs {
preload_key => $trigger_structure->{preload_key},
});
- my $update = "Jifty.update($update_json, this);";
-
- $string .=
- 'if(event.ctrlKey||event.metaKey||event.altKey||event.shiftKey) return true; '
- if ( $trigger eq 'onclick' );
-
- $string .= $self->javascript_preempt
- ? "return $update"
- : "$update; return true;";
+ my $update = $trigger eq "onclick" ? "Jifty.c(event,$update_json,this)"
+ : "Jifty.update($update_json,this);";
+ $string .= "return $update";
+ $string .= " || true" unless $self->javascript_preempt;
}
if ($trigger_structure->{confirm}) {
diff --git a/share/web/static/js/jifty.js b/share/web/static/js/jifty.js
index 6d8529a..7427431 100644
--- a/share/web/static/js/jifty.js
+++ b/share/web/static/js/jifty.js
@@ -1630,7 +1630,13 @@ Jifty.update = function () {
// Disable regular browser form submission (we're Ajaxing instead)
return false;
-}
+};
+
+Jifty.c = function (event, update, obj) {
+ if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey)
+ return true;
+ return Jifty.update(update, obj);
+};
// A cache of preload_key to XMLresponse objects
Jifty.preloaded_regions = {};
-----------------------------------------------------------------------
More information about the Jifty-commit
mailing list