Ignore:
Timestamp:
04/12/08 19:25:19 (12 years ago)
Author:
ray
Message:

#1172 [LangMarks?] make available languages configurable

Location:
trunk/plugins/LangMarks
Files:
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/plugins/LangMarks/lang-marks.css

    r677 r991  
    1 span.el, span.en, span.fr, span.la { 
    2         color: red; 
    3         padding-right: 25px; 
    4         background-repeat: no-repeat; 
    5         background-position: right top; 
    6         border-bottom: 1px solid red; 
     1span.haslang { 
     2        border-bottom: 1px dashed #aaa; 
    73        white-space : nowrap; 
    84} 
    9 span.el { /*Griechisch*/ 
    10         background-image: url(img/el.gif); 
     5span[LANG]::after { 
     6        content: attr(lang); 
     7        text-transform: uppercase; 
     8        font-family: sans-serif; 
     9        color: white; 
     10        background: red; 
     11        border: 1px solid red; 
     12        font-size: x-small; 
     13        font-weight: normal; 
     14        vertical-align: top; 
    1115} 
    12 span.en { /*Englisch*/ 
    13         background-image: url(img/en.gif); 
    14 } 
    15 span.fr { /*Französisch*/ 
    16         background-image: url(img/fr.gif); 
    17 } 
    18 span.la { /*Latein*/ 
    19         background-image: url(img/la.gif); 
    20 } 
  • trunk/plugins/LangMarks/lang-marks.js

    r850 r991  
    1111  var self = this; 
    1212  var options = {}; 
    13   options[this._lc("— language —")] = ""; 
    14   options[this._lc("Greek")] = "el"; 
    15   options[this._lc("English")] = "en"; 
    16   options[this._lc("French")] = "fr"; 
    17   options[this._lc("Latin")] = "la"; 
     13  options[this._lc("— language —")] = ''; 
     14        for (var i in cfg.LangMarks) 
     15        { 
     16                if (typeof i != 'string') continue; 
     17                options[this._lc(i)] = cfg.LangMarks[i]; 
     18        } 
    1819 
    1920  cfg.registerDropdown({ 
     
    3839}; 
    3940 
     41Xinha.Config.prototype.LangMarks = { 
     42  "Greek" : "el", 
     43  "English" : "en", 
     44  "French" : "fr", 
     45  "Latin" : "la" 
     46}; 
     47 
    4048LangMarks.prototype._lc = function(string) { 
    4149  return Xinha._lc(string, 'LangMarks'); 
     
    4351 
    4452LangMarks.prototype.onGenerate = function() { 
    45   var style_id = "LM-style" 
    46   var style = this.editor._doc.getElementById(style_id); 
    47   if (style == null) { 
    48     style = this.editor._doc.createElement("link"); 
    49     style.id = style_id; 
    50     style.rel = 'stylesheet'; 
    51     style.href = _editor_url + 'plugins/LangMarks/lang-marks.css'; 
    52     this.editor._doc.getElementsByTagName("HEAD")[0].appendChild(style); 
    53   } 
     53         this.editor.addEditorStylesheet(_editor_url + 'plugins/LangMarks/lang-marks.css'); 
    5454}; 
    5555 
     
    5757  var tbobj = editor._toolbarObjects[obj.id]; 
    5858  var index = tbobj.element.selectedIndex; 
    59   var className = tbobj.element.value; 
     59  var language = tbobj.element.value; 
    6060 
    6161  // retrieve parent element of the selection 
     
    6767 
    6868  if (update_parent) { 
    69     parent.className = className; 
    70     parent.lang = className; 
     69    parent.className = "haslang"; 
     70    parent.lang = language; 
    7171    editor.updateToolbar(); 
    7272    return; 
     
    8585    // maybe we could simply change the class of the parent node? 
    8686    if (parent.childNodes.length == 1) { 
    87       parent.className = className; 
    88       parent.lang = className; 
     87      parent.className = "haslang"; 
     88      parent.lang = language; 
    8989      surround = false; 
    9090      // in this case we should handle the toolbar updation 
     
    100100    // it's dangerous when selection spans multiple block-level 
    101101    // elements. 
    102     editor.surroundHTML('<span lang="' + className + '" class="' + className + '">', '</span>'); 
     102    editor.surroundHTML('<span lang="' + language + '" class="haslang">', '</span>'); 
    103103  } 
    104104}; 
     
    106106LangMarks.prototype.updateValue = function(editor, obj) { 
    107107  var select = editor._toolbarObjects[obj.id].element; 
    108   var parent = editor.getParentElement(); 
    109   if (typeof parent.className != "undefined" && /\S/.test(parent.className)) { 
     108  var parents = editor.getAllAncestors(); 
     109  var parent; 
     110        for (var i=0;i<parents.length;i++) 
     111        { 
     112                if (parents[i].lang) parent = parents[i]; 
     113        } 
     114        if (parent) { 
    110115    var options = select.options; 
    111     var value = parent.className; 
     116    var value = parent.lang; 
    112117    for (var i = options.length; --i >= 0;) { 
    113118      var option = options[i]; 
     
    118123    } 
    119124  } 
    120   select.selectedIndex = 0; 
     125  else select.selectedIndex = 0; 
     126 
    121127}; 
Note: See TracChangeset for help on using the changeset viewer.