Skip to content

Commit

Permalink
Item8117: last checkin before actually detwikifying it
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk/EditChapterPlugin@3488 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
MichaelDaum authored and MichaelDaum committed Apr 17, 2009
1 parent e1ec61f commit 5e9ff89
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
16 changes: 10 additions & 6 deletions lib/Foswiki/Plugins/EditChapterPlugin.pm
Expand Up @@ -28,18 +28,18 @@ $VERSION = '$Rev$';
$RELEASE = '2.00';
$SHORTDESCRIPTION = 'An easy sectional edit facility';

$header = <<'HERE';
<link rel="stylesheet" href="%PUBURLPATH%/%SYSTEMWEB%/EditChapterPlugin/ecpstyles.css" type="text/css" media="all" />
<script type="text/javascript" src="%PUBURLPATH%/%SYSTEMWEB%/EditChapterPlugin/ecpjavascript.js"></script>
HERE


###############################################################################
sub initPlugin {
($baseTopic, $baseWeb) = @_;

$sharedCore = undef;
my $jqPluginName = "JQueryCompatibilityModePlugin";
my $output = "<script language='javascript' type='text/javascript' src='%PUBURLPATH%/%SYSTEMWEB%/EditChapterPlugin/ecpjavascript.js'></script>";
Foswiki::Func::addToHEAD('EditChapterPlugin_init',$output, $jqPluginName."_jq_init");

$output = '<link rel="stylesheet" href="%PUBURLPATH%/%SYSTEMWEB%/EditChapterPlugin/ecpstyles.css" type="text/css" media="all" />';
Foswiki::Func::addToHEAD('EditChapterPlugin_css',$output);
$doneHeader = 0;

Foswiki::Func::registerTagHandler('EXTRACTCHAPTER', \&EXTRACTCHAPTER);

Expand Down Expand Up @@ -68,6 +68,10 @@ sub initCore {
sub commonTagsHandler {
### my ( $text, $topic, $web, $meta ) = @_;

unless ($doneHeader) {
$doneHeader = 1 if ($_[0] =~ s/<head>(.*?[\r\n]+)/<head>$1$header/o);
}

my $context = Foswiki::Func::getContext();
return unless $context->{'view'};
return unless $context->{'authenticated'};
Expand Down
3 changes: 3 additions & 0 deletions lib/Foswiki/Plugins/EditChapterPlugin/Core.pm
Expand Up @@ -85,6 +85,9 @@ sub commonTagsHandler {

my $topic = $_[1];
my $web = $_[2];

return unless $topic;

my $insideInclude = $_[3] || Foswiki::Func::getContext()->{insideInclude} || 0;
my $key = $web.'.'.$topic;

Expand Down
18 changes: 9 additions & 9 deletions pub/System/EditChapterPlugin/ecpjavascript.js
@@ -1,21 +1,21 @@
function beforeSubmitHandler(script, action) {
//alert("called beforeSubmitHandler");
var before = document.getElementById('beforetext');
var after = document.getElementById('aftertext');
var chapter = document.getElementById('topic');
var before = jQuery('#beforetext');
var after = jQuery('#aftertext');
var chapter = jQuery('#topic');

if (!before || !after || !chapter)
if (!before.length || !after.length || !chapter.length)
return;

var chapterText = chapter.value;
var chapterText = chapter.val();
var lastChar = chapterText.substr(chapterText.length-1, 1);
if (lastChar != '\n') {
chapterText += '\n';
}
var text = document.getElementById('text');
text.value = before.value+chapterText+after.value;
jQuery("#text").val(before.val()+chapterText+after.val());
}
;(function($) {

(function($) {
/* init gui */
if (true) {
$(function() {
Expand All @@ -38,4 +38,4 @@ if (true) {
});
});
}
})(jQuery);
})(jQuery);
2 changes: 1 addition & 1 deletion templates/edit.chapter.tmpl
@@ -1,8 +1,8 @@
%TMPL:INCLUDE{"edit"}%<!-- template: edit.chapter.tmpl -->
%TMPL:INCLUDE{"editjavascript"}%<!-- editjavascript// -->
%TMPL:DEF{"textarea"}%<!-- textarea -->
<textarea id="topic" name="paragraph" class="foswikiTextarea natedit" rows="%EDITBOXHEIGHT%" cols="%EDITBOXWIDTH%" style='%EDITBOXSTYLE%' wrap="virtual">%EXTRACTCHAPTER{from="%URLPARAM{"from" default="0"}%" to="%URLPARAM{"to"}%" encode="on" id="1"}%</textarea>
<textarea id="beforetext" name="beforetext" style="display:none" >%EXTRACTCHAPTER{before="%URLPARAM{"from" default="0"}%" encode="on" id="2"}%</textarea>
<textarea id="topic" name="paragraph" class="foswikiTextarea natedit" rows="%EDITBOXHEIGHT%" cols="%EDITBOXWIDTH%" style='%EDITBOXSTYLE%' wrap="virtual">%EXTRACTCHAPTER{from="%URLPARAM{"from" default="0"}%" to="%URLPARAM{"to"}%" encode="on" id="1"}%</textarea>
<textarea id="aftertext" name="aftertext" style="display:none">%EXTRACTCHAPTER{after="%URLPARAM{"to"}%" encode="on" id="3"}%</textarea>
<textarea id="text" name="text" style="display:none" ></textarea>
<input type="hidden" name="from" value="%URLPARAM{"from" default="0"}%" />
Expand Down

0 comments on commit 5e9ff89

Please sign in to comment.