Added makeSwitchable Dynano method for textareas; enabled support for makeSwitchable in comment runtime
--- a/includes/clientside/static/comments.js Thu Nov 20 22:58:30 2008 -0500
+++ b/includes/clientside/static/comments.js Thu Nov 20 22:59:11 2008 -0500
@@ -154,6 +154,10 @@
}
document.getElementById('ajaxEditContainer').innerHTML = html;
+ if ( document.getElementById('commentform_message') )
+ {
+ document.getElementById('commentform_message').allow_wysiwyg = data.auth_edit_wysiwyg
+ }
for ( i = 0; i < data.comments.length; i++ )
{
@@ -261,6 +265,8 @@
{
document.getElementById('leave_comment_button').style.display = 'none';
document.getElementById('comment_form').style.display = 'block';
+ if ( $dynano('commentform_message').object.allow_wysiwyg )
+ $dynano('commentform_message').makeSwitchable();
}
window.hideCommentForm = function()
@@ -289,6 +295,7 @@
ta.value = src;
ta.id = 'comment_edit_'+id;
cmt.appendChild(ta);
+ $dynano(ta).makeSwitchable();
link.style.fontWeight = 'bold';
link.innerHTML = $lang.get('comment_btn_save');
@@ -336,7 +343,7 @@
{
var name = document.getElementById('commentform_name').value;
var subj = document.getElementById('commentform_subject').value;
- var text = document.getElementById('commentform_message').value;
+ var text = $dynano('commentform_message').getContent();
if ( document.getElementById('commentform_captcha') )
{
var captcha_code = document.getElementById('commentform_captcha').value;
@@ -349,11 +356,15 @@
}
if ( subj == '' )
{
+ load_component('messagebox');
+ load_component('fadefilter');
new MessageBox(MB_OK|MB_ICONSTOP, 'Input validation failed', 'Please enter a subject for your comment.');
return false;
}
if ( text == '' )
{
+ load_component('messagebox');
+ load_component('fadefilter');
new MessageBox(MB_OK|MB_ICONSTOP, 'Input validation failed', 'Please enter some text for the body of your comment .');
return false;
}
--- a/includes/clientside/static/dynano.js Thu Nov 20 22:58:30 2008 -0500
+++ b/includes/clientside/static/dynano.js Thu Nov 20 22:59:11 2008 -0500
@@ -1,4 +1,4 @@
-// The "Dynano" Javascript framework. Similar in syntax to JQuery but only has what Enano needs.
+// The "Dynano" Javascript framework. Similar in syntax to JQuery but highly Enano-specific (TinyMCE, etc).
var $ = function(id)
{
@@ -19,6 +19,12 @@
this.object = false;
return this;
}
+ if ( this.object.Dynano )
+ {
+ return this.object.Dynano;
+ }
+ this.object.Dynano = this;
+
this.height = __DNObjGetHeight(this.object);
this.width = __DNObjGetWidth(this.object);
@@ -29,6 +35,7 @@
this.destroyMCE = DN_destroyMCE;
this.getContent = DN_mceFetchContent;
this.setContent = DN_mceSetContent;
+ this.makeSwitchable = DN_makeSwitchableTA;
}
}
function __DNObjGetHeight(o) {
@@ -182,6 +189,91 @@
}
}
+var P_BOTTOM = 1;
+var P_TOP = 2;
+
+function DN_makeSwitchableTA(pos)
+{
+ if ( this.toggler )
+ return false;
+
+ if ( !pos )
+ pos = P_BOTTOM;
+
+ load_component('l10n');
+ var cookiename = 'enano_editor_mode';
+
+ var toggler = document.createElement('div');
+ toggler.dynano = this;
+ this.toggler = toggler;
+
+ if ( !this.object.id )
+ this.object.id = 'dynano_auto_' + Math.floor(Math.random() * 1000000);
+
+ toggler.s_mode_text = $lang.get('editor_btn_wikitext');
+ toggler.s_mode_graphical = $lang.get('editor_btn_graphical');
+
+ toggler.set_text = function()
+ {
+ if ( this.dynano.object.dnIsMCE == 'yes' )
+ this.dynano.destroyMCE();
+
+ this.innerHTML = '';
+ this.appendChild(document.createTextNode(this.s_mode_text + ' | '));
+
+ var link = document.createElement('a');
+ link.href = '#';
+ link.onclick = function()
+ {
+ this.parentNode.set_graphical();
+ return false;
+ }
+ link.appendChild(document.createTextNode(this.s_mode_graphical));
+ this.appendChild(link);
+
+ createCookie('enano_editor_mode', 'text', 365);
+ }
+
+ toggler.set_graphical = function()
+ {
+ this.dynano.switchToMCE();
+ this.innerHTML = '';
+
+ var link = document.createElement('a');
+ link.href = '#';
+ link.onclick = function()
+ {
+ this.parentNode.set_text();
+ return false;
+ }
+ link.appendChild(document.createTextNode(this.s_mode_text));
+ this.appendChild(link);
+
+ this.appendChild(document.createTextNode(' | ' + this.s_mode_graphical));
+ createCookie('enano_editor_mode', 'tinymce', 365);
+ }
+
+ toggler.style.styleFloat = 'right';
+ toggler.style.cssFloat = 'right';
+ if ( pos == P_BOTTOM )
+ {
+ insertAfter(this.object.parentNode, toggler, this.object);
+ }
+ else
+ {
+ this.object.parentNode.insertBefore(toggler, this.object);
+ }
+
+ if ( readCookie(cookiename) == 'tinymce' )
+ {
+ toggler.set_graphical();
+ }
+ else
+ {
+ toggler.set_text();
+ }
+}
+
// A basic Wikitext to XHTML converter
function DN_WikitextToXHTML(text)
{
--- a/includes/comment.php Thu Nov 20 22:58:30 2008 -0500
+++ b/includes/comment.php Thu Nov 20 22:59:11 2008 -0500
@@ -171,6 +171,7 @@
$ret['auth_mod_comments'] = $this->perms->get_permissions('mod_comments');
$ret['auth_post_comments'] = $this->perms->get_permissions('post_comments');
$ret['auth_edit_comments'] = $this->perms->get_permissions('edit_comments');
+ $ret['auth_edit_wysiwyg'] = $this->perms->get_permissions('edit_wysiwyg');
$ret['user_id'] = $session->user_id;
$ret['username'] = $session->username;
$ret['logged_in'] = $session->user_logged_in;
--- a/includes/paths.php Thu Nov 20 22:58:30 2008 -0500
+++ b/includes/paths.php Thu Nov 20 22:59:11 2008 -0500
@@ -59,7 +59,7 @@
$session->register_acl_type('post_comments', AUTH_ALLOW, 'perm_post_comments', Array('read'), 'Article|User|Project|Template|File|Help|System|Category');
$session->register_acl_type('edit_comments', AUTH_ALLOW, 'perm_edit_comments', Array('post_comments'), 'Article|User|Project|Template|File|Help|System|Category');
$session->register_acl_type('edit_page', AUTH_WIKIMODE, 'perm_edit_page', Array('view_source'), 'Article|User|Project|Template|File|Help|System|Category');
- $session->register_acl_type('edit_wysiwyg', AUTH_ALLOW, 'perm_edit_wysiwyg', Array('edit_page'), 'Article|User|Project|Template|File|Help|System|Category');
+ $session->register_acl_type('edit_wysiwyg', AUTH_ALLOW, 'perm_edit_wysiwyg', Array(), 'Article|User|Project|Template|File|Help|System|Category');
$session->register_acl_type('view_source', AUTH_WIKIMODE, 'perm_view_source', Array('read'), 'Article|User|Project|Template|File|Help|System|Category'); // Only used if the page is protected
$session->register_acl_type('mod_comments', AUTH_DISALLOW, 'perm_mod_comments', Array('edit_comments'), 'Article|User|Project|Template|File|Help|System|Category');
$session->register_acl_type('history_view', AUTH_WIKIMODE, 'perm_history_view', Array('read'), 'Article|User|Project|Template|File|Help|System|Category');