Add LTR/RTL toggle in notes

Initialize the note editor with the default directionality based on the current locale, and add a single button for the opposite direction that functions as a toggle. This avoids needing two buttons.

We should also add locales to TinyMCE, but we can do that separately.

Closes #157
This commit is contained in:
Dan Stillman 2013-03-05 17:51:30 -05:00
parent a27d57d7b9
commit 61aef48381
4 changed files with 17 additions and 4 deletions

View file

@ -355,6 +355,9 @@
.getService(Components.interfaces.nsIChromeRegistry);
uri = cr.convertChromeURL(uri);
// Pass directionality (LTR/RTL) in URL
uri.spec += "?dir=" + Zotero.dir;
Zotero.debug("Loading " + uri.spec);
// Register handler for deferred setting of content

View file

@ -25,6 +25,15 @@
},
setup : function (ed) {
// Set text direction
var dir = window.location.href.match(/dir=(ltr|rtl)/)[1];
ed.settings.directionality = dir;
// Include button for opposite direction, to function as a toggle
ed.settings.theme_advanced_buttons1 = ed.settings.theme_advanced_buttons1.replace(
"%DIR%",
"," + dir.split("").reverse().join("")
);
ed.onInit.add(function (ed) {
zoteroInit(ed);
});
@ -40,10 +49,10 @@
fix_list_elements : true,
fix_table_elements : true,
plugins : "paste,contextmenu",
plugins : "paste,contextmenu,directionality",
// Theme options
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,sub,sup,|,forecolor,backcolor,|,blockquote,|,link,unlink",
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,sub,sup,|,forecolor,backcolor,|,blockquote,|,link,unlink,|,%DIR%",
theme_advanced_buttons2 : "formatselect,|,justifyleft,justifycenter,justifyright,|,bullist,numlist,outdent,indent,|,removeformat,code",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",

View file

@ -0,0 +1 @@
(function(){tinymce.create("tinymce.plugins.Directionality",{init:function(b,c){var d=this;d.editor=b;function a(e){var h=b.dom,g,f=b.selection.getSelectedBlocks();if(f.length){g=h.getAttrib(f[0],"dir");tinymce.each(f,function(i){if(!h.getParent(i.parentNode,"*[dir='"+e+"']",h.getRoot())){if(g!=e){h.setAttrib(i,"dir",e)}else{h.setAttrib(i,"dir",null)}}});b.nodeChanged()}}b.addCommand("mceDirectionLTR",function(){a("ltr")});b.addCommand("mceDirectionRTL",function(){a("rtl")});b.addButton("ltr",{title:"directionality.ltr_desc",cmd:"mceDirectionLTR"});b.addButton("rtl",{title:"directionality.rtl_desc",cmd:"mceDirectionRTL"});b.onNodeChange.add(d._nodeChange,d)},getInfo:function(){return{longname:"Directionality",author:"Moxiecode Systems AB",authorurl:"http://tinymce.moxiecode.com",infourl:"http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/directionality",version:tinymce.majorVersion+"."+tinymce.minorVersion}},_nodeChange:function(b,a,e){var d=b.dom,c;e=d.getParent(e,d.isBlock);if(!e){a.setDisabled("ltr",1);a.setDisabled("rtl",1);return}c=d.getAttrib(e,"dir");a.setActive("ltr",c=="ltr");a.setDisabled("ltr",0);a.setActive("rtl",c=="rtl");a.setDisabled("rtl",0)}});tinymce.PluginManager.add("directionality",tinymce.plugins.Directionality)})();

View file

@ -226,8 +226,8 @@
#zotero-item-pane
{
width: 335px;
min-width: 335px;
width: 338px;
min-width: 338px;
}
#zotero-pane .toolbar