Skip to content

Commit efe4ab8

Browse files
robertleeplummerjrrobertleeplummerjr
robertleeplummerjr
authored and
robertleeplummerjr
committed
Partially working inline editor.
1 parent e948054 commit efe4ab8

5 files changed

+84
-20
lines changed

_WP_Editors.php

-5
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ public static function editor($content, $editor_id, $settings)
2020
<textarea id="$editor_id" name="content">$content</textarea>
2121
</div>
2222
<input type="button" class="button" value="Toggle Editor" id="$editor_id-button"/>
23-
<style>
24-
.wikiLingo-bubble {
25-
z-index: 9999;
26-
}
27-
</style>
2823
<script>
2924
var $ = jQuery;
3025
(function($, document) {

composer.lock

+8-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wikiLingoEditor.css

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.wl-bubble {
2+
z-index: 9999;
3+
}
4+
.Medium {
5+
-webkit-box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.42);
6+
-moz-box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.42);
7+
box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.42);
8+
}

wikiLingoInlineEditor.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
var wikiLingoInlineEditor = (function($) {
2+
"use strict";
3+
4+
return function(articleId, editableArea, siteUrl) {
5+
var sourceEditorContainer = $('<div>')
6+
.insertAfter(editableArea),
7+
8+
editableAreaParent = $('<div>')
9+
.insertAfter(editableArea)
10+
.append(editableArea),
11+
12+
sourceEditor = $('<textarea name="content"></textarea>')
13+
.appendTo(sourceEditorContainer),
14+
15+
button = $('<input type="button" class="button" value="Toggle Editor"/>')
16+
.insertAfter(sourceEditorContainer),
17+
18+
reflectUrl = siteUrl + '/wp-content/plugins/wikiLingo/wikiLingoReflect.php',
19+
folderUrl = siteUrl + '/wp-content/plugins/wikiLingo/vendor/wikilingo/wikilingo/',
20+
21+
editor = wikiLingoEditor(reflectUrl, folderUrl, editableArea, sourceEditor[0]),
22+
23+
wikiLingoBubbles = $('nav.wikiLingo-bubble');
24+
25+
button.click(function() {
26+
if (sourceEditorContainer.is(':visible')) {
27+
sourceEditorContainer.hide();
28+
editableAreaParent.show();
29+
wikiLingoBubbles.hide();
30+
} else {
31+
sourceEditorContainer.show();
32+
editableAreaParent.hide();
33+
wikiLingoBubbles.show();
34+
}
35+
});
36+
37+
sourceEditorContainer.hide();
38+
}
39+
})(jQuery);

wp-wikiLingo.php

+29-7
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function can_richedit($bool){
118118

119119
function settings(){
120120
//settings_fields('wikiLingo');
121-
echo '<p>'.__("Select the post types or comments that will support wikiLingo. Comments and bbPress forums can also feature a wikiLingo 'help bar' and previewer. Automatic syntax highlighting can be provided by <a href='http://code.google.com/p/google-code-prettify/' target='_blank'>Prettify</a>.",$this->domain).'</p>';
121+
echo '<p>'.__("Select the post types or comments that will support wikiLingo",$this->domain).'</p>';
122122
}
123123

124124
function settings_posttypes(){
@@ -157,8 +157,32 @@ function get_option( $option ){
157157
}
158158

159159
//For comments & pages
160-
function the_content( $comment ){
161-
$comment = $this->parser->parse( $comment );
160+
function the_content( $content ){
161+
$comment = $this->parser->parse( $content );
162+
163+
$current_user = wp_get_current_user();
164+
if (in_array('administrator', $current_user->roles)) {
165+
add_action('wp_footer', array($this,'register_scripts'), 5);
166+
167+
wp_enqueue_script('wp-wikiLingo-inline-editor', $this->path . 'wikiLingoInlineEditor.js');
168+
169+
$siteUrl = get_site_url();
170+
171+
$this->parser->scripts
172+
->addScript(<<<JS
173+
$('article').each(function() {
174+
var article = this,
175+
articleId = article.getAttribute('id').replace('post-', '') * 1,
176+
editableArea = $(this).find('.entry-content')[0];
177+
178+
$(article).find('a.post-edit-link').click(function() {
179+
wikiLingoInlineEditor(articleId, editableArea, '$siteUrl');
180+
return false;
181+
});
182+
});
183+
JS
184+
);
185+
}
162186

163187
return $comment;
164188
}
@@ -168,10 +192,6 @@ function get_comment_text( $comment ){
168192
return $comment;
169193
}
170194

171-
function admin_head()
172-
{
173-
}
174-
175195
function wp_footer($footer)
176196
{
177197
echo self::$scripts->renderCss();
@@ -214,8 +234,10 @@ function register_scripts() {
214234
wp_enqueue_style('wp-wikiLingo-bubble', $this->path . 'vendor/wikilingo/wikilingo/editor/bubble.css');
215235
wp_enqueue_script('wp-wikiLingo-bubble', $this->path . 'vendor/wikilingo/wikilingo/editor/bubble.js');
216236

237+
wp_enqueue_style('wp-wikiLingo-editor', $this->path . 'wikiLingoEditor.css');
217238
wp_enqueue_script('wp-wikiLingo-editor', $this->path . 'wikiLingoEditor.js');
218239

240+
219241
//load CodeMirror
220242
wp_enqueue_style('wp-wikiLingo-codemirror', $this->path . 'vendor/codemirror/codemirror/lib/codemirror.css');
221243
wp_enqueue_script('wp-wikiLingo-codemirror', $this->path . 'vendor/codemirror/codemirror/lib/codemirror.js');

0 commit comments

Comments
 (0)