Skip to content

Commit

Permalink
Item13021: make sure "use strict" isn't removed
Browse files Browse the repository at this point in the history
Item13021: support arbitrary MathModePlugin as well as MathJaxPlugin
  • Loading branch information
MichaelDaum committed Sep 22, 2014
1 parent e0ce843 commit ef1be93
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 43 deletions.
5 changes: 1 addition & 4 deletions NatEditPlugin/lib/Foswiki/Plugins/NatEditPlugin/DEPENDENCIES
@@ -1,8 +1,5 @@
Foswiki::Plugins::JQueryPlugin,>=5.00,perl,Required.
Foswiki::Plugins::JQueryPlugin,>=6.00,perl,Required.
JSON,>=2.59,cpan,Required.
Foswiki::Plugins::TopicInteractionPlugin,>=3.20,perl,Optional, require to upload attachments from within the editor.
Foswiki::Plugins::ImagePlugin,>=3.20,perl,Optional
Foswiki::Plugins::MathModePlugin,>=4.20,perl,Optional
ONLYIF ( $Foswiki::Plugins::VERSION < 2.1)
Foswiki::Plugins::SetVariablePlugin,>=2.33,perl,Required. required for Foswiki < 1.2
ONLYIF ( $Foswiki::Plugins::VERSION < 2.1)
Expand Down
7 changes: 4 additions & 3 deletions NatEditPlugin/lib/Foswiki/Plugins/NatEditPlugin/NATEDIT.pm
Expand Up @@ -58,7 +58,7 @@ sub new {
'ui::tooltip', 'tabpane',
'ui::autocomplete', 'ui::button',
'button', 'loader',
'uploader', 'blockui',
'JQUERYPLUGIN::UPLOADER', 'blockui',
'tmpl',
],
),
Expand All @@ -82,10 +82,11 @@ sub init {
return unless $this->SUPER::init();

Foswiki::Func::addToZone(
"script", "NATEDIT::ENABLEDPLUGINS",
"script", "NATEDIT::PREFERENCES",
<<'HERE', "JQUERYPLUGIN::FOSWIKI::PREFERENCES" );
<script>jQuery.extend(foswiki.preferences, {
'MathModePluginEnabled': %IF{"context MathModePluginEnabled" then="true" else="false"}%,
'NatEditEngine': '%NATEDIT_ENGINE{default="raw"}%',
'MathEnabled': %IF{"context MathModePluginEnabled or context MathJaxPluginEnabled" then="true" else="false"}%,
'ImagePluginEnabled': %IF{"context ImagePluginEnabled" then="true" else="false"}%,
'TopicInteractionPluginEnabled': %IF{"context TopicInteractionPluginEnabled" then="true" else="false"}%,
'FarbtasticEnabled': %IF{"context FarbtasticEnabled" then="true" else="false"}%
Expand Down
@@ -1,7 +1,7 @@
/*
* jQuery NatEdit plugin
*
* Copyright (c) 2008-2013 Michael Daum http://michaeldaumconsulting.com
* Copyright (c) 2008-2014 Michael Daum http://michaeldaumconsulting.com
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
Expand All @@ -11,7 +11,7 @@

/*global FoswikiTiny:false, tinyMCE:false, StrikeOne:false, plupload:false */
(function($) {
"use strict";
"use strict";

/*****************************************************************************
* class TextareaState
Expand Down Expand Up @@ -250,15 +250,14 @@ $.NatEditor = function(txtarea, opts) {
$txtarea.addClass("ui-natedit ui-widget");

self.initGui();
self.undoManager = new UndoManager(self);

if (self.opts.showToolbar) {
self.initToolbar();
}

self.initForm();

self.undoManager = new UndoManager(self);

/* establish auto max expand */
if (self.opts.autoMaxExpand) {
$txtarea.addClass("ui-natedit-autoexpand");
Expand Down Expand Up @@ -1208,38 +1207,6 @@ $.NatEditor.prototype.remove = function() {
return selection;
};

/*************************************************************************
* Transform selected text with a provided function
*/
$.NatEditor.prototype.transformSelection = function(transformer) {
var self = this,
startPos, endPos,
text, scrollTop, theSelection,
subst;

self.getSelectionRange();
startPos = self.txtarea.selectionStart;
endPos = self.txtarea.selectionEnd;
text = self.txtarea.value;
scrollTop = self.txtarea.scrollTop;
theSelection = text.substring(startPos, endPos);

subst = transformer.call(self, theSelection);

self.txtarea.value =
text.substring(0, startPos) + subst +
text.substring(endPos, text.length);

// set new selection
endPos = startPos + subst.length;
self.txtarea.scrollTop = scrollTop;
self.setSelectionRange(startPos, endPos);

self.undoManager.saveState("command");
};



/*************************************************************************
* compatibility method for IE: this sets txtarea.selectionStart and
* txtarea.selectionEnd of the current selection in the given textarea
Expand Down

0 comments on commit ef1be93

Please sign in to comment.