aboutsummaryrefslogtreecommitdiff
path: root/mod/ckeditor/views/default
diff options
context:
space:
mode:
Diffstat (limited to 'mod/ckeditor/views/default')
-rw-r--r--mod/ckeditor/views/default/ckeditor/css.php30
-rw-r--r--mod/ckeditor/views/default/ckeditor/embed_custom_insert_js.php8
-rw-r--r--mod/ckeditor/views/default/ckeditor/init.php8
-rw-r--r--mod/ckeditor/views/default/css/wysiwyg.php36
-rw-r--r--mod/ckeditor/views/default/js/ckeditor.php77
5 files changed, 159 insertions, 0 deletions
diff --git a/mod/ckeditor/views/default/ckeditor/css.php b/mod/ckeditor/views/default/ckeditor/css.php
new file mode 100644
index 000000000..8c8790722
--- /dev/null
+++ b/mod/ckeditor/views/default/ckeditor/css.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * CKEditor CSS
+ *
+ * Overrides on the default CKEditor skin
+ * Gives the textarea and buttons rounded corners
+ *
+ * The rules are extra long in order to have enough
+ * weight to override the CKEditor rules
+ */
+?>
+
+.cke_top {
+ width: 100% !important;
+}
+
+.cke_bottom .cke_wordcount {
+ float: left;
+ padding-top: 1px;
+ padding-left: 5px;
+ font-family: Arial,Helvetica,Tahoma,Verdana,Sans-Serif;
+ font-size: 11px;
+ font-weight: 700;
+ color: #5F5F5F;
+}
+
+.cke_bottom .cke_path {
+ float: right;
+}
+
diff --git a/mod/ckeditor/views/default/ckeditor/embed_custom_insert_js.php b/mod/ckeditor/views/default/ckeditor/embed_custom_insert_js.php
new file mode 100644
index 000000000..2b72e58c6
--- /dev/null
+++ b/mod/ckeditor/views/default/ckeditor/embed_custom_insert_js.php
@@ -0,0 +1,8 @@
+ if (CKEDITOR) {
+ try {
+ CKEDITOR.instances[textAreaId].insertHtml(content, 'html');
+ } catch (e) {
+ // do nothing.
+ }
+ }
+
diff --git a/mod/ckeditor/views/default/ckeditor/init.php b/mod/ckeditor/views/default/ckeditor/init.php
new file mode 100644
index 000000000..f78a5a64d
--- /dev/null
+++ b/mod/ckeditor/views/default/ckeditor/init.php
@@ -0,0 +1,8 @@
+<?php
+/**
+ * Initialize the CKEditor script
+ */
+
+elgg_load_js('ckeditor');
+elgg_load_js('jquery-ckeditor');
+elgg_load_js('elgg.ckeditor');
diff --git a/mod/ckeditor/views/default/css/wysiwyg.php b/mod/ckeditor/views/default/css/wysiwyg.php
new file mode 100644
index 000000000..f696729ab
--- /dev/null
+++ b/mod/ckeditor/views/default/css/wysiwyg.php
@@ -0,0 +1,36 @@
+/* CSS for CKEditor content iframe */
+
+<?php // The Elgg CSS reset forces the scrollbar which we don't want ?>
+html, body {
+ height: auto;
+ margin: 0;
+}
+
+body {
+ margin: 8px;
+}
+
+dt { font-weight: bold }
+dd { margin: 0 0 1em 1em }
+
+ul, ol {
+ margin: 0 1.5em 1.5em 0;
+ padding-left: 1.5em;
+}
+ul {
+ list-style-type: disc;
+}
+ol {
+ list-style-type: decimal;
+}
+table {
+ border: 1px solid #ccc;
+}
+table td {
+ border: 1px solid #ccc;
+ padding: 3px 5px;
+}
+img {
+ max-width: 100%;
+ height: auto;
+} \ No newline at end of file
diff --git a/mod/ckeditor/views/default/js/ckeditor.php b/mod/ckeditor/views/default/js/ckeditor.php
new file mode 100644
index 000000000..9e02496ac
--- /dev/null
+++ b/mod/ckeditor/views/default/js/ckeditor.php
@@ -0,0 +1,77 @@
+<?php
+/**
+ * CKEditor JavaScript
+ */
+
+$css_url = elgg_get_simplecache_url('css', 'wysiwyg');
+
+?>
+elgg.provide('elgg.ckeditor');
+
+/**
+ * Toggles the CKEditor
+ *
+ * @param {Object} event
+ * @return void
+ */
+elgg.ckeditor.toggleEditor = function(event) {
+ event.preventDefault();
+
+ var target = $(this).attr('href').substr(1);
+
+ if (!CKEDITOR.instances[target]) {
+ CKEDITOR.replace($('#'+target)[0], elgg.ckeditor.config).on('key', elgg.ckeditor.wordCount);
+ $(this).html(elgg.echo('ckeditor:remove'));
+ } else {
+ CKEDITOR.instances[target].destroy();
+ $(this).html(elgg.echo('ckeditor:add'));
+ }
+}
+
+/**
+ * Counts the number of words into an editor
+ *
+ * @param {Object} event
+ * @return void
+ */
+elgg.ckeditor.wordCount = function(evt) {
+ var matches = evt.editor.getData().replace(/<[^<|>]+?>|&nbsp;/gi,' ').match(/\b/g);
+ var words = matches ? matches.length / 2 : 0;
+ var text = elgg.echo('ckeditor:word_count') + words;
+ $('.cke_wordcount', evt.editor.container.$).text(text);
+}
+
+/**
+ * CKEditor configuration
+ *
+ * You can find configuration information here:
+ * http://docs.ckeditor.com/#!/api/CKEDITOR.config
+ */
+elgg.ckeditor.config = {
+ toolbar : [['Bold', 'Italic', 'Underline', '-', 'Strike', 'NumberedList', 'BulletedList', 'Undo', 'Redo', 'Link', 'Unlink', 'Image', 'Blockquote', 'Paste', 'PasteFromWord', 'Maximize']],
+ toolbarCanCollapse : false,
+ baseHref : elgg.config.wwwroot,
+ extraPlugins : 'autogrow',
+ removePlugins : 'contextmenu,showborders,tabletools,resize',
+ uiColor : '#EEEEEE',
+ contentsCss : '<?php echo $css_url; ?>',
+ disableNativeSpellChecker : false,
+ removeDialogTabs: 'image:advanced;image:Link;link:advanced;link:target',
+ autoGrow_maxHeight : 800,
+};
+
+elgg.ckeditor.init = function() {
+
+ elgg.ckeditor.config.language = elgg.get_language();
+
+ $('.ckeditor-toggle-editor').live('click', elgg.ckeditor.toggleEditor);
+ $('.elgg-input-longtext').each(function() {
+ CKEDITOR.replace(this, elgg.ckeditor.config).on('key', elgg.ckeditor.wordCount);
+ });
+ CKEDITOR.on('instanceReady', function(evt) {
+ $('.cke_bottom', evt.editor.container.$).prepend('<div class="cke_wordcount" />');
+ elgg.ckeditor.wordCount(evt);
+ });
+}
+
+elgg.register_hook_handler('init', 'system', elgg.ckeditor.init);