Skip to content

Commit

Permalink
Item12000: save to wysiwygPlugin on deactivate - dangerous unless you…
Browse files Browse the repository at this point in the history
…r topic happens to be pure prose

git-svn-id: http://svn.foswiki.org/trunk/Html5EditContrib@15168 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
SvenDowideit authored and SvenDowideit committed Jul 16, 2012
1 parent 6a36c21 commit 6d1be38
Showing 1 changed file with 36 additions and 15 deletions.
51 changes: 36 additions & 15 deletions lib/Foswiki/Contrib/Html5EditContrib/Hallojs.pm
Expand Up @@ -6,13 +6,13 @@ use Foswiki::Plugins::JQueryPlugin ();
our @ISA = qw( Foswiki::Plugins::JQueryPlugin::Plugin );

use Foswiki::Plugins::JQueryPlugin::Plugin ();
use Foswiki::Contrib::Html5EditContrib ();
use Foswiki::Contrib::Html5EditContrib ();

sub new {
my $class = shift;
my $session = shift || $Foswiki::Plugins::SESSION;
my $this = $class->SUPER::new(

my $this = $class->SUPER::new(
$session,
name => 'hallojs',
version => $Foswiki::Contrib::Html5EditContrib::RELEASE,
Expand All @@ -21,15 +21,14 @@ sub new {
puburl => '%PUBURLPATH%/%SYSTEMWEB%/Html5EditContrib',
documentation => "$Foswiki::cfg{SystemWebName}.Html5EditContrib",
summary => $Foswiki::Contrib::Html5EditContrib::SHORTDESCRIPTION,
dependencies => ['bootstrap', 'JQUERYPLUGIN', 'UI', 'UI::Button'],
javascript => [ "hallo.js" ],
css => [ "hallo.css" ]
);
dependencies => [ 'bootstrap', 'JQUERYPLUGIN', 'UI', 'UI::Button' ],
javascript => ["hallo.js"],
css => ["hallo.css"]
);

return $this;
}


sub renderCSS {
my ( $this, $text ) = @_;

Expand All @@ -44,13 +43,13 @@ sub renderCSS {
sub renderJS {
my ( $this, $text ) = @_;

# $text =~ s/\.min//
# if ( $this->{debug} );
# $text =~ s/\.min//
# if ( $this->{debug} );

$text .= '?version=' . $this->{version} if ( $this->{version} =~ '$Rev$' );
$text =
"<script type='text/javascript' src='$this->{puburl}/$text'></script>\n".
"<script type='text/javascript'>jQuery(function(){jQuery('.foswikiTopicText').hallo({
"<script type='text/javascript' src='$this->{puburl}/$text'></script>\n"
. "<script type='text/javascript'>jQuery(function(){jQuery('.foswikiTopicText').hallo({
toolbar: 'halloToolbarFixed',
plugins: {
'halloformat': {},
Expand All @@ -59,7 +58,29 @@ sub renderJS {
'halloreundo': {},
'hallolink': {}
}
}).bind('hallodeactivated', function(){return false;});
}).bind('hallodeactivated', function(event, data){
var item = jQuery(this).data('hallo');
if (item.isModified()) {
jQuery.post('%SCRIPTURL{save}%/%BASEWEB%/%BASETOPIC%', { text: this.innerHTML, wysiwyg_edit: 'go' },
function(data) {
alert('Data saved: ' + data);
}).error(function(event, data) {
//TODO: this darstadly hack is because i've not made a POST form and used that to submit the save, so strikeone has a hissyfit
//OH BOY YOU CANT BE SERIOUS - and it relies on the strikeone.js being loaded due to the bootstrap search being POST..
var entirehtml = jQuery(event.responseText).filter('.foswikiMain');
var last = entirehtml[0];
var message = jQuery(last.innerHTML).filter('.container-fluid');
message.dialog({
height: 410,
width: 600,
modal: true,
title: 'confirm change'
});
jQuery('.s1js_available').show();
});
}
}).bind('halloactivated', function(event, data){
});
})</script>\n";
return $text;
}
Expand Down

0 comments on commit 6d1be38

Please sign in to comment.