[Jifty-commit] r3421 - in jifty/trunk/plugins/CodePress: .
share/web/static/js
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sat Jun 9 19:06:30 EDT 2007
Author: dpavlin
Date: Sat Jun 9 19:06:29 2007
New Revision: 3421
Modified:
jifty/trunk/plugins/CodePress/Makefile.PL
jifty/trunk/plugins/CodePress/lib/Jifty/Plugin/CodePress.pm
jifty/trunk/plugins/CodePress/share/web/static/js/codepress.js
Log:
bump version to 0.02, remove requirement to modify submit form button (and
in process break next_page after it, because it turns normal form submit
into Ajax form submit which doesn't handle redirects very well -- because it
usually redirects to page which isn't valid XML)
Modified: jifty/trunk/plugins/CodePress/Makefile.PL
==============================================================================
--- jifty/trunk/plugins/CodePress/Makefile.PL (original)
+++ jifty/trunk/plugins/CodePress/Makefile.PL Sat Jun 9 19:06:29 2007
@@ -1,6 +1,6 @@
use inc::Module::Install;
name('Jifty-Plugin-CodePress');
-version('0.01');
+version('0.02');
requires('Jifty' => '0.70422');
install_share;
Modified: jifty/trunk/plugins/CodePress/lib/Jifty/Plugin/CodePress.pm
==============================================================================
--- jifty/trunk/plugins/CodePress/lib/Jifty/Plugin/CodePress.pm (original)
+++ jifty/trunk/plugins/CodePress/lib/Jifty/Plugin/CodePress.pm Sat Jun 9 19:06:29 2007
@@ -27,14 +27,6 @@
render_as => 'Jifty::Plugin::CodePress::Textarea',
);
- Jifty->web->submit(
- label => _("Save"),
- onclick => [
- { beforeclick => "CodePress.beforeSubmit();" },
- { args => .... }
- ]
- );
-
or if you are using L<Template::Declare>
render_param(
@@ -44,14 +36,6 @@
render_as => 'Jifty::Plugin::CodePress::Textarea',
);
- form_submit(
- label => _("Save"),
- onclick => [
- { beforeclick => "CodePress.beforeSubmit();" },
- { args => .... },
- ],
- );
-
=head1 VERSION
Created from L<https://codepress.svn.sourceforge.net/svnroot/codepress/trunk/stable>
@@ -60,7 +44,10 @@
This involved some hard-coding of paths (because automatic path detection
from CodePress doesn't work well with Jifty's expectation of JavaScript code
in C</js/>), addition of C<CodePress.instances> object to track all
-instances and CodePress.beforeSubmit which prepare form for submission.
+instances and additional JavaScript event handling using C<DOM.Events>
+to remove requirement to call C<CodePress.beforeSubmit> from form submit
+(If you want you can still call it, and it will turn all CodePress editors
+back to textarea).
This also side-stepped problem with original calling schematic which created
functions with names from element ids. This was problematic with Jifty
Modified: jifty/trunk/plugins/CodePress/share/web/static/js/codepress.js
==============================================================================
--- jifty/trunk/plugins/CodePress/share/web/static/js/codepress.js (original)
+++ jifty/trunk/plugins/CodePress/share/web/static/js/codepress.js Sat Jun 9 19:06:29 2007
@@ -35,6 +35,28 @@
self.style.position = 'static';
self.style.visibility = 'visible';
self.style.display = 'inline';
+
+ // where blur event is delivered?
+ var iframe = self;
+ if (self.contentDocument) { // For NS6
+ iframe = self.contentDocument;
+ } else if (self.contentWindow) { // For IE5.5 and IE6
+ //iframe = self.contentWindow.document;
+ } else if (self.document) { // For IE5
+ iframe = self.document;
+ } else {
+ alert("can't find frame");
+ }
+
+ DOM.Events.addListener( iframe, 'blur', function () {
+ self.textarea.value = self.getCode();
+ self.textarea.disabled = false;
+ return self;
+ });
+ DOM.Events.addListener( iframe, 'focus', function () {
+ self.textarea.disabled = true;
+ return self;
+ });
}
// obj can by a textarea id or a string (code)
@@ -43,8 +65,9 @@
if(!self.textarea.disabled) return;
self.language = language ? language : self.getLanguage();
self.src = '/static/codepress/codepress.html?language='+self.language+'&ts='+(new Date).getTime();
- if(self.attachEvent) self.attachEvent('onload',self.initialize);
- else self.addEventListener('load',self.initialize,false);
+ //if(self.attachEvent) self.attachEvent('onload',self.initialize);
+ //else self.addEventListener('load',self.initialize,false);
+ DOM.Events.addListener(self, 'load', self.initialize);
}
self.getLanguage = function() {
@@ -134,15 +157,15 @@
CodePress.beforeSubmit = function() {
for (instance in CodePress.instances) {
- //CodePress.instances[ instance ].toggleEditor();
- var i = CodePress.instances[ instance ];
- i.textarea.value = i.getCode();
- i.textarea.disabled = false;
- i.style.display = 'none';
- i.textarea.style.display = 'inline';
+ // consider just Jifty fields
+ if ( instance.substr(0,5) == 'J:A:F' ) {
+ CodePress.instances[ instance ].toggleEditor();
+ }
}
}
//if(window.attachEvent) window.attachEvent('onload',CodePress.run);
//else window.addEventListener('DOMContentLoaded',CodePress.run,false);
-DOM.Events.addListener(window, "load", CodePress.run);
+//DOM.Events.addListener(window, "load", CodePress.run);
+// Jifty-specific onLoad hook
+onLoadHook( 'CodePress.run();' );
More information about the Jifty-commit
mailing list