Added basic support for right-to-left languages. Set meta_direction to "rtl" in core.json.
authorDan Fuhry <dan@enanocms.org>
Mon, 28 Jun 2010 13:31:21 -0400
changeset 1254 221d14331ebe
parent 1253 13f8d373da67
child 1255 98954eecc5f8
Added basic support for right-to-left languages. Set meta_direction to "rtl" in core.json.
includes/clientside/static/dropdown.js
includes/clientside/static/tinymce-init.js
language/english/core.json
themes/enanium/css-extra/ltr.css
themes/enanium/css-extra/rtl.css
themes/enanium/css/babygrand.css
themes/enanium/header.tpl
--- a/includes/clientside/static/dropdown.js	Mon Jun 28 10:43:04 2010 -0400
+++ b/includes/clientside/static/dropdown.js	Mon Jun 28 13:31:21 2010 -0400
@@ -61,6 +61,9 @@
 	$dynano(obj).addClass('menu');
 	removeTextNodes(obj);
 	
+	var html = document.getElementsByTagName('html')[0];
+	var direction = typeof(html.dir) != 'undefined' ? html.dir : 'ltr';
+	
 	for ( var i = 0; i < obj.childNodes.length; i++ )
 	{
 		/* normally this would be done in about 2 lines of code, but javascript is so picky..... */
@@ -101,11 +104,18 @@
 									ul.id = 'jBoxmenuobj_' + Math.floor(Math.random() * 10000000);
 								jBoxMenuHeights[ul.id] = parseInt(dim['h']) - 2; // subtract 2px for border width
 								
-								if ( dim['w'] + $dynano(ul).Left() > getWidth() || $dynano(ul).hasClass('jbox_right') )
+								// this is a little bit of a hack
+								var should_be_right = ( direction == 'ltr' && $dynano(ul).hasClass('jbox_right') ) || ( direction == 'rtl' && !$dynano(ul).hasClass('jbox_right') );
+								
+								if ( ( direction == 'ltr' && dim['w'] + $dynano(ul).Left() > getWidth() ) || should_be_right )
 								{
 									$dynano(ul).addClass('jbox_right');
 									ul.jbox_width = $dynano(ul).Width();
 								}
+								else
+								{
+									$dynano(ul).rmClass('jbox_right');
+								}
 								
 								ul.style.display = 'none';
 								domObjChangeOpac(100, ul);
@@ -174,6 +184,7 @@
 		var dimh = parseInt(dim['h']);
 		var offtop = parseInt(off['top']);
 		var top = dimh + offtop;
+		
 		if ( $dynano(ul).hasClass('jbox_right') )
 		{
 			left = $dynano(obj).Left() + $dynano(obj).Width() - ul.jbox_width; // ( link left + link width ) - ul width
--- a/includes/clientside/static/tinymce-init.js	Mon Jun 28 10:43:04 2010 -0400
+++ b/includes/clientside/static/tinymce-init.js	Mon Jun 28 13:31:21 2010 -0400
@@ -32,6 +32,9 @@
 var _skin = ( typeof(tinymce_skin) == 'string' ) ? tinymce_skin : 'default';
 var tinymce_initted = false;
 
+var html = document.getElementsByTagName('html')[0];
+var direction = typeof(html.dir) != 'undefined' ? html.dir : 'ltr';
+
 var enano_tinymce_options = {
 	mode : "none",
 	plugins : 'table,save,safari,pagebreak,style,layer,advhr,insertdatetime,searchreplace,spellchecker,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,wordcount' + do_popups,
@@ -47,7 +50,8 @@
 	theme_advanced_statusbar_location : 'bottom',
 	noneditable_noneditable_class : 'mce_readonly',
 	content_css : css_url,
-	spellchecker_rpc_url : scriptPath + '/includes/clientside/tinymce/plugins/spellchecker/rpc.php'
+	spellchecker_rpc_url : scriptPath + '/includes/clientside/tinymce/plugins/spellchecker/rpc.php',
+	directionality : direction
 };
 
 var enano_tinymce_gz_options = {
--- a/language/english/core.json	Mon Jun 28 10:43:04 2010 -0400
+++ b/language/english/core.json	Mon Jun 28 13:31:21 2010 -0400
@@ -1,4 +1,4 @@
-/*
+i/*
  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
  * Version 1.1.6 (Caoineag beta 1)
  * Copyright (C) 2006-2007 Dan Fuhry
@@ -47,7 +47,8 @@
 			enano_about_lbl_serverplatform: 'Server platform:',
 			enano_about_lbl_phpversion: '<a href="http://www.php.net/">PHP</a> version:',
 			enano_about_lbl_mysqlversion: '<a href="http://www.mysql.com/">MySQL</a> version:',
-			enano_about_lbl_pgsqlversion: '<a href="http://www.postgresql.org/">PostgreSQL</a> version:'
+			enano_about_lbl_pgsqlversion: '<a href="http://www.postgresql.org/">PostgreSQL</a> version:',
+			direction: 'rtl'
 		},
 		page: {
 			sitedisabled_admin_msg_title: 'The site is currently disabled and thus is only accessible to administrators.',
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/enanium/css-extra/ltr.css	Mon Jun 28 13:31:21 2010 -0400
@@ -0,0 +1,1 @@
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/themes/enanium/css-extra/rtl.css	Mon Jun 28 13:31:21 2010 -0400
@@ -0,0 +1,75 @@
+/**
+ * Enanium - Right-To-Left (RTL) tweaks
+ * Polished black default theme for Enano CMS
+ * Copyright (C) 2009 Dan Fuhry
+ */
+
+div.logo {
+	float: right;
+	margin: 0 -13px 0 7px;
+}
+
+div#header h1 a {
+	padding-left: 20px;
+	padding-right: 0;
+}
+
+div#header h1 a:hover {
+	background-position: left center;
+}
+
+form.searchform {
+	left: 10px;
+	right: auto;
+}
+ul.useropts {
+	left: 10px;
+	right: auto;
+}
+
+ul.useropts li {
+	float: right;
+}
+
+div.menu a, div.menu div.label, div.menu_nojs a, div.menu_nojs div.label {
+	float: right;
+	margin-right: 0;
+	margin-left: 3px;
+}
+
+div.menu.global_menu, div.menu_nojs.global_menu {
+	float: left;
+	margin-right: 0;
+	margin-left: 10px;
+}
+
+div.sidebar.right {
+	float: left;
+	margin: 0 20px 0 0;
+}
+
+div.sidebar a.closebtn {
+	float: left;
+	margin-right: 0;
+	margin-left: 10px;
+}
+
+div.sidebar.left a.closebtn {
+	-moz-border-radius: 0 0 4px 0;
+	border-radius: 0 0 4px 0;
+	margin-left: 0;
+}
+
+div.left-sidebar-hidden a.openbtn {
+	-moz-border-radius: 4px 0 0 4px;
+	border-radius: 4px 0 0 4px;
+	float: right;
+}
+
+div.right-sidebar-hidden a.openbtn {
+	float: left;
+	margin-right: 0;
+	margin-left: -30px;
+	-moz-border-radius: 0 4px 4px 0;
+	border-radius: 0 4px 4px 0;
+}
--- a/themes/enanium/css/babygrand.css	Mon Jun 28 10:43:04 2010 -0400
+++ b/themes/enanium/css/babygrand.css	Mon Jun 28 13:31:21 2010 -0400
@@ -568,6 +568,11 @@
 	margin: 0;
 }
 
+div.menu.global_menu, div.menu_nojs.global_menu {
+	float: right;
+	margin-right: 10px;
+}
+
 /* toolbar */
 
 div.toolbar {
--- a/themes/enanium/header.tpl	Mon Jun 28 10:43:04 2010 -0400
+++ b/themes/enanium/header.tpl	Mon Jun 28 13:31:21 2010 -0400
@@ -1,11 +1,12 @@
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
+<html xmlns="http://www.w3.org/1999/xhtml" dir="{lang:meta_direction}">
 	<head>
 		<title>{PAGE_NAME} &bull; {SITE_NAME}</title>
 		<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
 		{JS_DYNAMIC_VARS}
 		<link rel="stylesheet" type="text/css" href="{CDNPATH}/includes/clientside/css/enano-shared.css?{ENANO_VERSION}" />
 		<link id="mdgCss" rel="stylesheet" type="text/css" href="{CDNPATH}/themes/{THEME_ID}/css/{STYLE_ID}.css?{ENANO_VERSION}" />
+		<link id="mdgCss" rel="stylesheet" type="text/css" href="{CDNPATH}/themes/{THEME_ID}/css-extra/{lang:meta_direction}.css?{ENANO_VERSION}" />
 		<!--[if lte IE 6]>
 		<link rel="stylesheet" type="text/css" href="{CDNPATH}/themes/{THEME_ID}/css-extra/ie6.css" />
 		<![endif]-->
@@ -73,7 +74,7 @@
 			</td>
 			<td valign="top" id="cell-content">
 				<!-- BEGINNOT stupid_mode -->
-				<div class="menu_nojs" style="float: right; margin-right: 10px;">
+				<div class="menu_nojs global_menu">
 					<a href="#" onclick="return false;">{lang:onpage_lbl_changes}</a>
 					<ul class="jbox_right">
 						<li><a href="{url:Special:Log/user={USERNAME}|escape}">{lang:onpage_btn_changes_mine}</a></li>