Jump to content

MediaWiki:Common.js: Difference between revisions

From The Austrian Economics Wiki, the global repository of classical-liberal thought
m comment out copied
import new jquery collapsible elements
 
(14 intermediate revisions by 2 users not shown)
Line 52: Line 52:
/* dynamic layouts from en.wikisource.org*/
/* dynamic layouts from en.wikisource.org*/
self.ws_layouts = {
self.ws_layouts = {
  'Layout 1':{'text-wrap':"",  
  'Layout 1':{'text-wrap':"position:relative;margin-left:3em;margin-right:3em;",
      '#text-container':"width:36em;margin:0px auto;font-family:Georgia,serif;" ,
      '#text':"text-align:justify;",
      '.sidenote-right':"position:absolute; left:37em;width:16em;text-indent:0em;text-align:left;",
      '.sidenote-left':"position:absolute; right:37em;width:16em;text-indent:0em;text-align:right;",
      '.editsection':"display:none",
      '#headertemplate':"" },
'Layout 2':{'text-wrap':"",  
       '#text-container':"" ,  
       '#text-container':"" ,  
       '#text':"",  
       '#text':"",  
       '.sidenote-right':"float:right;margin:0.5em;padding:3px;border:solid 1px gray;max-width:9em;text-indent:0em;text-align:left;",
       '.sidenote-right':"float:right;margin:0.5em;padding:3px;border:solid 1px gray;max-width:9em;text-indent:0em;text-align:left;",
       '.sidenote-left':"float:left;margin:0.5em;padding:3px;border:solid 1px gray;max-width:9em;text-indent:0em;text-align:left;",
       '.sidenote-left':"float:left;margin:0.5em;padding:3px;border:solid 1px gray;max-width:9em;text-indent:0em;text-align:left;",
      '.editsection':"display:none",
      '#headertemplate':"" },
'Layout 2':{'text-wrap':"position:relative;margin-left:3em;margin-right:3em;",
      '#text-container':"width:36em;margin:0px auto;font-family:Georgia,serif;" ,
      '#text':"text-align:justify;",
      '.sidenote-right':"position:absolute; left:37em;width:16em;text-indent:0em;text-align:left;",
      '.sidenote-left':"position:absolute; right:37em;width:16em;text-indent:0em;text-align:right;",
       '.editsection':"display:none",
       '.editsection':"display:none",
       '#headertemplate':"" },
       '#headertemplate':"" },
Line 78: Line 78:
self.proofreadpage_add_container = true;
self.proofreadpage_add_container = true;
   
   
//importScriptURI('http://wiki.mises.org/mediawiki/index.php?title=MediaWiki:Base.js&action=raw&ctype=text/javascript');
importScriptURI('http://wiki.mises.org/mediawiki/index.php?title=MediaWiki:Base.js&action=raw&ctype=text/javascript');
//importScriptURI('http://wiki.mises.org/mediawiki/index.php?title=MediaWiki:OCR.js&action=raw&ctype=text/javascript');
//importScriptURI('http://wiki.mises.org/mediawiki/index.php?title=MediaWiki:OCR.js&action=raw&ctype=text/javascript');
importScriptURI('http://wiki.mises.org/mediawiki/index.php?title=MediaWiki:DisplayFooter.js&action=raw&ctype=text/javascript');
importScriptURI('http://wiki.mises.org/mediawiki/index.php?title=MediaWiki:DisplayFooter.js&action=raw&ctype=text/javascript');
importScriptURI('http://wiki.mises.org/mediawiki/index.php?title=MediaWiki:PageNumbers.js&action=raw&ctype=text/javascript');
importScriptURI('http://wiki.mises.org/mediawiki/index.php?title=MediaWiki:PageNumbers.js&action=raw&ctype=text/javascript');
importScriptURI('http://wiki.mises.org/mediawiki/index.php?title=MediaWiki:Corrections.js&action=raw&ctype=text/javascript');
importScriptURI('http://wiki.mises.org/mediawiki/index.php?title=MediaWiki:Corrections.js&action=raw&ctype=text/javascript');
//importScriptURI('http://wiki.mises.org/mediawiki/index.php?title=MediaWiki:IndexForm.js&action=raw&ctype=text/javascript');  
importScriptURI('http://wiki.mises.org/mediawiki/index.php?title=MediaWiki:IndexForm.js&action=raw&ctype=text/javascript');  
   
   
/*
/*
Line 93: Line 93:
self.proofreadpage_disable_wheelzoom=true;
self.proofreadpage_disable_wheelzoom=true;


/* Direct copy from MediaWiki:IndexForm.js and MediaWiki:Base.js, for testing */
// makeCollapsible
importStylesheet('MediaWiki:JQuery-makeCollapsible.css');
importScript('MediaWiki:JQuery-makeCollapsible.js');


var page_ns_prefixes= {
/** Collapsible tables *********************************************************
'en':'Page',
*
'fr':'Page',
*  Description: Allows tables to be collapsed, showing only the header. See
'de':'Seite',
*              [[w:Wikipedia:NavFrame]].
'it':'Pagina',
*/
'la':'Pagina',
'no':'Side',
'es':'Página',
'pt':'Página',
'sv':'Sida',
'pl':'Strona',
'hy':'Էջ',
'ru':'Страница',
'hr':'Stranica',
'hu':'Oldal',
'ca':'Pàgina',
'vi':'Trang',
'sl':'Stran',
'zh':'Page',
'vec':'Pagina',
'br':'Pajenn'
}
   
   
var index_ns_prefixes= {
var autoCollapse = 2;
'en':'Index',
var collapseCaption = "hide";
'fr':'Livre',
var expandCaption = "show";
'de':'Index',
'it':'Indice',
'la':'Liber',
'no':'Indeks',
'es':'Índice',
'pt':'Galeria',
'sv':'Index',
'hy':'Ինդեքս',
'ru':'Индекс',
'br':'Meneger',
'vec':'Indice'
}
   
   
/* messages to be moved
window.collapseTable = function( tableIndex ){
'it':'Il testo proviene da',
    var Button = document.getElementById( "collapseButton" + tableIndex );
'la':'Hic textus visibils est in',
    var Table = document.getElementById( "collapsibleTable" + tableIndex );
'es':'Su texto procede de',
'ca':'El seu text procedeix de'
*/
   
   
    if ( !Table || !Button ) {
        return false;
    }
   
   
if(!self.ws_messages) self.ws_messages = { }
    var Rows = Table.rows;
   
   
function ws_msg(name) {
    if ( Button.firstChild.data == collapseCaption ) {
  var m = self.ws_messages[name];
        for ( var i = 1; i < Rows.length; i++ ) {
  if(m) return m; else return name;
            Rows[i].style.display = "none";
}
        }
        Button.firstChild.data = expandCaption;
/* Note : there is a similar function in wikibits.js, but it does not work for me pn page numbers */
    } else {
function get_elements_by_classname(classname, tagname) {
        for ( var i = 1; i < Rows.length; i++ ) {
if(document.getElementsByClassName) return document.getElementsByClassName(classname);
            Rows[i].style.display = Rows[0].style.display;
var ml = new Array();
var l = document.getElementsByTagName(tagname);
for (var i=0; i< l.length; i++) {
var a = l[i];
if( a.className.indexOf(classname) !=-1 ) ml[ml.length] = l[i];
}
return ml;
}
function get_optlist() {
var optlist = document.getElementById("optlist");
if(!optlist) {
var displayOptions = document.createElement("div");
                if (self.skin=='vector') displayOptions.className = "portal"; else displayOptions.className = "portlet";
if (self.skin=='vector') cl="body"; else cl="pBody";
displayOptions.innerHTML = '<h5>' + ws_msg('optlist') + '<\/h5><div class="'+cl+'"><ul id="optlist"> </ul><\/div>';
                var ptb = document.getElementById("p-tb");
                ptb.parentNode.insertBefore(displayOptions,ptb);
                displayOptions.setAttribute("id","p-displayOptions");
                displayOptions.id="p-displayOptions"; /* */
optlist = document.getElementById("optlist");
}
return optlist;
}
/*** Cookies ***/
function SetCookie(name,value) {
document.cookie = name + "=" + escape(value);
}
function GetCookie(name) {
var i =0;
while (i < document.cookie.length) {
if (document.cookie.substr(i,name.length) == name) {
var valend = document.cookie.indexOf(";",i+name.length+1);
                        if (valend == -1) {
                                valend = document.cookie.length;
                        }
                        return unescape(document.cookie.substring(i+name.length+1,valend));
                }
                i = document.cookie.indexOf(" ", i) + 1;
                if (i == 0) break;
         }
         }
        Button.firstChild.data = collapseCaption;
    }
}
}
   
   
function createCollapseButtons(){
    var tableIndex = 0;
    var NavigationBoxes = new Object();
    var Tables = document.getElementsByTagName( "table" );
   
   
/**** Display options ****/
    for ( var i = 0; i < Tables.length; i++ ) {
        if ( hasClass( Tables[i], "collapsible" ) ) {
   
   
function OptionText() {
            /* only add button and increment count if there is a header row to work with */
  var indexNavigationBar = 0;
            var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0];
  // iterate over all < span >-elements until class "OptionText" is found
            if (!HeaderRow) continue;
  for(
            var Header = HeaderRow.getElementsByTagName( "th" )[0];
          var i=0;
            if (!Header) continue;
          SpanElem = document.getElementsByTagName("span")[i];  
          i++
      ) {
      // if found an option span
      if (SpanElem.className == "OptionText") {
          //SpanElem.style.display = 'none';
          OptionTitle = SpanElem.title;
          OptionStyle = SpanElem.firstChild.getAttribute('style');
   
   
          //check if option was already encountered...
            NavigationBoxes[ tableIndex ] = Tables[i];
          if(!document.getElementById(OptionTitle)){
            Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
   
   
            //read cookie
             var Button    = document.createElement( "span" );
             var DisplayOptionDefault = true;
             var ButtonLink = document.createElement( "a" );
             CookieDisplayOption = GetCookie ("Display"+OptionTitle)
             var ButtonText = document.createTextNode( collapseCaption );
             if (CookieDisplayOption ) {
            if (CookieDisplayOption == "false") DisplayOptionDefault = false; }
   
   
             var PageDisplay = document.createElement("li");
             Button.className = "collapseButton"; //Styles are declared in Common.css
            PageDisplay.setAttribute('id', OptionTitle);
            var PageDisplayLink = document.createElement("a");
   
   
             OptionText = document.createTextNode("Désactiver "+OptionTitle);
             ButtonLink.style.color = Header.style.color;
             PageDisplayLink.appendChild(OptionText);
            ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
             PageDisplayLink.setAttribute('href','javascript:displayOptionText("'+OptionTitle+'","' + OptionStyle +'", '+DisplayOptionDefault+');');
             ButtonLink.setAttribute( "href", "#" );
             PageDisplay.appendChild(PageDisplayLink);
             addHandler( ButtonLink,  "click", new Function( "evt", "collapseTable(" + tableIndex + " ); return killEvt( evt );") );
             ButtonLink.appendChild( ButtonText );
   
   
             var optlist = get_optlist();
             Button.appendChild( document.createTextNode( "[" ) );
             optlist.appendChild(PageDisplay);
             Button.appendChild( ButtonLink );
            Button.appendChild( document.createTextNode( "]" ) );
   
   
             displayOptionText(OptionTitle,OptionStyle,DisplayOptionDefault);
             Header.insertBefore( Button, Header.firstChild );
          }
            tableIndex++;
      }
        }
  }
    }
}
   
   
function displayOptionText(optiontitle, optionstyle, bool) {
    for ( var i = 0; i < tableIndex; i++ ) {
         if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
  SetCookie ("Display"+optiontitle,bool);
             collapseTable( i );
  if( ! document.getElementById(optiontitle) ) return;
        }  
  var PageDisplayLink =  document.getElementById(optiontitle).firstChild;
         else if ( hasClass( NavigationBoxes[i], "innercollapse" ) ) {
             var element = NavigationBoxes[i];
  // iterate over all < span >-elements
             while (element = element.parentNode) {
  for(
                if ( hasClass( element, "outercollapse" ) ) {
          var i=0;  
                    collapseTable ( i );
          SpanElem = document.getElementsByTagName("span")[i];  
                    break;
          i++
                }
      ) {
             }
        // if found an option text
         if ((SpanElem.className == "OptionText") && (SpanElem.title == optiontitle)) {
          if(bool==true ) {
            SpanElem.setAttribute('style',optionstyle);
            PageDisplayLink.firstChild.data = (optiontitle);
            PageDisplayLink.setAttribute('href', 'javascript:displayOptionText("'+optiontitle+'","'+optionstyle+'", false);');
          }
          if(bool==false) {
             SpanElem.setAttribute('style','null');
            PageDisplayLink.firstChild.data = (optiontitle);
            PageDisplayLink.setAttribute('href', 'javascript:displayOptionText("'+optiontitle+'","'+optionstyle+'", true);');
        }       
      }
  }
}
addOnloadHook(OptionText);
function restore_lst(){
         var editbox = document.getElementById('wpTextbox1');
        var search = /##[\s]*(.*?)[\s]*##[\s]*\n/;
        var a = editbox.value.split(search);
        var s = a[0];
        var ok = true;
        var m = parseInt(a.length/2);
        for( var i = 0 ; i < m ; i++ ) {
             var title = a[i*2+1];
             /*title = title.replace(' ','_');*/
            var content = a[i*2+2];
            if( title && content.substring(0,2)=='{|' ) content = '\n' + content;
            if(title) s = s + "<section begin="+title+"/>" + content + "<section end="+title+"/>\n";
            else s = s + content;
             /* if( i < m-1 ) s = s + "----\n"; */
         }
         }
        editbox.value = s;
    }
}
}
   
   
/*
$( createCollapseButtons );
  * easy lst : hide section markers
 
/** Test if an element has a certain class **************************************
*
  * Description: Uses regular expressions and caching for better performance.
  */
  */
function easy_lst() {
        if(self.proofreadpage_raw_lst) return;
        var editbox = document.getElementById('wpTextbox1');
        if(editbox && self.proofreadPageIsEdit) {
   
   
var search = /<section begin=[\s]*(.*?)[\s]*\/>/;
var hasClass = ( function() {
        var a = editbox.value.split(search);
         var reCache = {};
         var s = a[0];  
         return function( element, className ) {
         var ok = true;
                return ( reCache[className] ? reCache[className] : ( reCache[className] = new RegExp( "(?:\\s|^)" + className + "(?:\\s|$)" ) ) ).test( element.className );
        for( var i = 0 ; i < parseInt(a.length/2) ; i++ ) {
         };
            var title = a[i*2+1];
})();
            var content = a[i*2+2];
 
            var r2 = /^([\s\S]*?)<section end=(.*?)\/>(\n|)[\s]*([\s\S]*?)$/;
 
            var m2 = content.match(r2);
/** Dynamic Navigation Bars *************************************
            if( m2 ) {
*
              if(s && s.charAt(s.length-1)!='\n' && s.charAt(s.length-1)!='|' ) s = s+'\n';
*  Description: See [[Wikipedia:NavFrame]].
              s = s + "## " + title + " ##\n"+ m2[1] ;
*/
              if( m2[4] ) {
                  if( m2[4]!='----\n' ) {
                    if(s && s.charAt(s.length-1)!='\n' ) s = s+'\n';
                    s = s + "####\n" + m2[4] ;
                  }
              }
            } else {
              ok = false; /* alert("error"+title);*/
            }
         }
if(ok) {
            editbox.value = s;  
        }  
var saveButton = document.getElementById("wpSave");
var previewButton = document.getElementById("wpPreview");  
var diffButton = document.getElementById("wpDiff");
if(saveButton){
                saveButton.onclick = restore_lst;
previewButton.onclick = restore_lst;
diffButton.onclick = restore_lst;
        }
  }
}
   
   
addOnloadHook(easy_lst);
// set up the words in your language
 
var NavigationBarHide = '[' + collapseCaption + ']';
/********************************
var NavigationBarShow = '[' + expandCaption + ']';
  enhanced form for index pages
*********************************/
   
   
// shows and hides content and picture (if available) of navigation bars
// Parameters:
//    indexNavigationBar: the index of navigation bar to be toggled
function toggleNavigationBar(indexNavigationBar){
    var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
    var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
   
   
function set_index_field(name,value,on_book,on_collection,on_journal,on_phdthesis, on_dictionary){
    if (!NavFrame || !NavToggle) {
var f = document.getElementsByName(name)[0];
        return false;
if(!f) return;
    }
f = f[0];
if(f) {
if( (value=="book" && on_book) || (value=="journal" && on_journal) || (value=="collection" && on_collection) || (value=="phdthesis" && on_phdthesis) || value=="dictionary" && on_dictionary ) {
f.disabled=false;
f.parentNode.parentNode.style.display="";
} else {
f.disabled=true;
f.parentNode.parentNode.style.display="none";
}
}
}
   
   
    // if shown now
    if (NavToggle.firstChild.data == NavigationBarHide) {
        for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
            if (hasClass(NavChild, 'NavContent') || hasClass(NavChild, 'NavPic')) {
                NavChild.style.display = 'none';
            }
        }
    NavToggle.firstChild.data = NavigationBarShow;
   
   
/*specifies which fields should appear for each material type */
    // if hidden now
function type_changed(f,value) {
    } else if (NavToggle.firstChild.data == NavigationBarShow) {
//see http://www.easybib.com/reference/guide/apa/dictionary
        for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
set_index_field( ws_msg('author'),     value, 1, 1, 0, 1, 0);
            if (hasClass(NavChild, 'NavContent') || hasClass(NavChild, 'NavPic')) {
set_index_field( ws_msg('translator'), value, 1, 1, 0, 0, 0);
                NavChild.style.display = 'block';
set_index_field( ws_msg('editor'),    value, 1, 1, 1, 0, 1);
            }
set_index_field( ws_msg('place'),      value, 1, 1, 1, 0, 1);
        }
set_index_field( ws_msg('editor'),    value, 1, 1, 1, 0, 1);
        NavToggle.firstChild.data = NavigationBarHide;
set_index_field( ws_msg('volume'),    value, 1, 1, 1, 0, 1);
     }
set_index_field( ws_msg('school'),     value, 0, 0, 0, 1, 0);
}
}
   
   
/*replaced if( wgCanonicalNamespace == self.index_ns_prefixes[wgContentLanguage] ) { */
// adds show/hide-button to navigation bars
function index_choices(){
function createNavigationBarToggleButton(){
if( wgCanonicalNamespace == 'Index' ) {
    var indexNavigationBar = 0;
var f = document.editform;
    // iterate over all < div >-elements
                var value = "book"; //fixme: understand this
    var divs = document.getElementsByTagName("div");
if(f) {
    for (var i = 0; NavFrame = divs[i]; i++) {
var a = f.Type;
        // if found a navigation bar
if(a) {
        if (hasClass(NavFrame, "NavFrame")) {
   
   
value = a.value;
            indexNavigationBar++;
a.parentNode.innerHTML="<select onchange=\"type_changed(this.form,this.options[this.selectedIndex].value);\" name=\"Type\">"
            var NavToggle = document.createElement("a");
+"<option value=\"book\" selected=true>" + ws_msg('book') + "</option>"
            NavToggle.className = 'NavToggle';
+"<option value=\"collection\">" + ws_msg('collection') + "</option>"
            NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
+"<option value=\"journal\">" + ws_msg('journal') + "</option>"
            NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');
+"<option value=\"phdthesis\">" + ws_msg('phdthesis') + "</option>"
+"<option value=\"dictionary\">" + ws_msg('dictionary') + "</option>"
+"</select>";
a = f.Type;
for (var i=0; i < a.length; i++) {
if (a[i].value == value) a[i].selected = true;
}
if(value=="") value="book";
type_changed(f,value);
}
   
   
var suffix = wgPageName.substring(wgPageName.length-4,wgPageName.length).toLowerCase();
            var isCollapsed = hasClass( NavFrame, "collapsed" );
if( suffix=='djvu' || suffix=='.pdf') {
            /*
var m_source = ws_msg('Source');
            * Check if any children are already hidden. This loop is here for backwards compatibility:
set_index_field( m_source, value, 0, 0, 0, 0, 0);
            * the old way of making NavFrames start out collapsed was to manually add style="display:none"
f = document.getElementsByName(m_source)[0];
            * to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
if(f) {
            * the content visible without JavaScript support), the new recommended way is to add the class
if( suffix=='djvu' ) f.value='djvu';
            * "collapsed" to the NavFrame itself, just like with collapsible tables.
if( suffix=='.pdf' ) f.value='pdf';
            */
                                }
            for (var NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling) {
f = document.getElementsByName( ws_msg('Image'))[0];
                if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) {
if(f && f.value=="") f.value="1";
                    if ( NavChild.style.display == 'none' ) {
f = document.getElementsByName( ws_msg('Pages'))[0];
                        isCollapsed = true;
if(f && f.value=="") f.value="<pagelist />";
                    }
}
                }
var a = document.getElementsByName(ws_msg('progress'))[0];
            }
if(a) {
            if (isCollapsed) {
value = a.value;
                for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
a.parentNode.innerHTML="<select name=\""+ ws_msg('progress') + "\">"
                    if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) {
+"<option value=\"\" selected=true></option>"
                        NavChild.style.display = 'none';
+"<option value=\"T\">" + ws_msg('progress_T') + "</option>"
                    }
+"<option value=\"V\">" + ws_msg('progress_V') + "</option>"
                }
+"<option value=\"C\">" + ws_msg('progress_C') + "</option>"
            }
+"<option value=\"MS\">"+ ws_msg('progress_MS')+ "</option>"
            var NavToggleText = document.createTextNode(isCollapsed ? NavigationBarShow : NavigationBarHide);
+"<option value=\"OCR\">"+ws_msg('progress_OCR')+"</option>"
            NavToggle.appendChild(NavToggleText);
+"<option value=\"X\">" + ws_msg('progress_X') + "</option>"
+"<option value=\"L\">" + ws_msg('progress_L') + "</option>"
+"</select>";
a = document.getElementsByName(ws_msg('progress'))[0];
for (var i=0; i < a.length; i++) {
if (a[i].value == value) a[i].selected = true;
}
}
   
   
}
            // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
}
            for(var j=0; j < NavFrame.childNodes.length; j++) {
                if (hasClass(NavFrame.childNodes[j], "NavHead")) {
                    NavToggle.style.color = NavFrame.childNodes[j].style.color;
                    NavFrame.childNodes[j].appendChild(NavToggle);
                }
            }
            NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
        }
    }
}
}
hookEvent("load",index_choices);
$( createNavigationBarToggleButton );

Latest revision as of 23:57, 8 September 2012

/* Import more specific scripts if necessary */

if (wgAction == "edit" || wgAction == "submit" || wgPageName == "Special:Upload") //scripts specific to editing pages {

   importScript("MediaWiki:Common.js/edit.js")

}


/*

* scripts imported from en.wikisource.org and wikisource.org
*/

/* messages are configurable here */ self.ws_messages = { 'optlist':'Display options', 'hide_page_numbers':'Hide page links', 'show_page_numbers':'Show page links', 'layout':'Layout', 'author':'Author', 'translator':'Translator', 'editor':'Editor', 'publisher':'Publisher', 'place':'Place', 'volume':'Volume', 'school':'School', 'book':'Book', 'collection':'Collection', 'journal':'Journal or magazine', 'phdthesis':'Thesis, report', 'dictionary':'Dictionary', 'progress':'Progress', 'progress_T':'Done', 'progress_V':'To be validated', 'progress_C':'To be proofread', 'progress_MS':'Ready for Match & Split', 'progress_OCR':'Needs an OCR text layer', 'progress_X':'Source file is an excerpt of a larger volume, or a mixture of several sources', 'progress_L':'Source file is incorrect (missing pages, unordered pages, etc)', '▲':'Return to the top of the page.',


'corr_list':"List of corrections performed on this page" , 'corr_link':"Corrections" , 'corr_one':"One typo </a> has been corrected." , 'corr_many':" typos</a> have been corrected." , 'corr_close':"Close." ,

'iwtrans':'Its text comes from', 'iwtrans2':'Its text comes from other Wikisource subdomains.' }

/* dynamic layouts from en.wikisource.org*/ self.ws_layouts = {

'Layout 1':{'text-wrap':"position:relative;margin-left:3em;margin-right:3em;", 
     '#text-container':"width:36em;margin:0px auto;font-family:Georgia,serif;" , 
     '#text':"text-align:justify;", 
     '.sidenote-right':"position:absolute; left:37em;width:16em;text-indent:0em;text-align:left;",
     '.sidenote-left':"position:absolute; right:37em;width:16em;text-indent:0em;text-align:right;",
     '.editsection':"display:none",
     '#headertemplate':"" },
'Layout 2':{'text-wrap':"", 
     '#text-container':"" , 
     '#text':"", 
     '.sidenote-right':"float:right;margin:0.5em;padding:3px;border:solid 1px gray;max-width:9em;text-indent:0em;text-align:left;",
     '.sidenote-left':"float:left;margin:0.5em;padding:3px;border:solid 1px gray;max-width:9em;text-indent:0em;text-align:left;",
     '.editsection':"display:none",
     '#headertemplate':"" },
'Layout 3':{'text-wrap':"margin-left:3em",
     '#text-container':"position:relative; min-width:60em; float:left; width:100%; margin-right:-23em;" , 
     '#text':"text-align:justify;margin-right:23em; text-indent:0em; padding-left:0px; padding-right:0px;width:auto;",
     '.sidenote-right':"position:absolute; right:-10em; width:9em; background-color:#eeeeee;text-indent:0em;text-align:left;",
     '.sidenote-left': "position:absolute; right:-10em; width:9em; background-color:#eeeeee;text-indent:0em;text-align:left;",
     '.editsection':"display:none",
     '#headertemplate':"position:absolute; top:0em; right:-23em; width:21em;float:right; text-align:left;" }

}


self.proofreadpage_add_container = true;

importScriptURI('http://wiki.mises.org/mediawiki/index.php?title=MediaWiki:Base.js&action=raw&ctype=text/javascript'); //importScriptURI('http://wiki.mises.org/mediawiki/index.php?title=MediaWiki:OCR.js&action=raw&ctype=text/javascript'); importScriptURI('http://wiki.mises.org/mediawiki/index.php?title=MediaWiki:DisplayFooter.js&action=raw&ctype=text/javascript'); importScriptURI('http://wiki.mises.org/mediawiki/index.php?title=MediaWiki:PageNumbers.js&action=raw&ctype=text/javascript'); importScriptURI('http://wiki.mises.org/mediawiki/index.php?title=MediaWiki:Corrections.js&action=raw&ctype=text/javascript'); importScriptURI('http://wiki.mises.org/mediawiki/index.php?title=MediaWiki:IndexForm.js&action=raw&ctype=text/javascript');

/* From en.wikisource.org Disabling mouse wheel until the problem is fixed. Users that have a configurations where zoom wheel works can override this, by adding "self.proofreadpage_disable_wheelzoom=false;" to their javascript.

  • /

self.proofreadpage_disable_wheelzoom=true;

// makeCollapsible importStylesheet('MediaWiki:JQuery-makeCollapsible.css'); importScript('MediaWiki:JQuery-makeCollapsible.js');

/** Collapsible tables *********************************************************

*
*  Description: Allows tables to be collapsed, showing only the header. See
*               w:Wikipedia:NavFrame.
*/

var autoCollapse = 2; var collapseCaption = "hide"; var expandCaption = "show";

window.collapseTable = function( tableIndex ){

   var Button = document.getElementById( "collapseButton" + tableIndex );
   var Table = document.getElementById( "collapsibleTable" + tableIndex );

   if ( !Table || !Button ) {
       return false;
   }

   var Rows = Table.rows;

   if ( Button.firstChild.data == collapseCaption ) {
       for ( var i = 1; i < Rows.length; i++ ) {
           Rows[i].style.display = "none";
       }
       Button.firstChild.data = expandCaption;
   } else {
       for ( var i = 1; i < Rows.length; i++ ) {
           Rows[i].style.display = Rows[0].style.display;
       }
       Button.firstChild.data = collapseCaption;
   }

}

function createCollapseButtons(){

   var tableIndex = 0;
   var NavigationBoxes = new Object();
   var Tables = document.getElementsByTagName( "table" );

   for ( var i = 0; i < Tables.length; i++ ) {
       if ( hasClass( Tables[i], "collapsible" ) ) {

           /* only add button and increment count if there is a header row to work with */
           var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0];
           if (!HeaderRow) continue;
           var Header = HeaderRow.getElementsByTagName( "th" )[0];
           if (!Header) continue;

           NavigationBoxes[ tableIndex ] = Tables[i];
           Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );

           var Button     = document.createElement( "span" );
           var ButtonLink = document.createElement( "a" );
           var ButtonText = document.createTextNode( collapseCaption );

           Button.className = "collapseButton";  //Styles are declared in Common.css

           ButtonLink.style.color = Header.style.color;
           ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
           ButtonLink.setAttribute( "href", "#" );
           addHandler( ButtonLink,  "click", new Function( "evt", "collapseTable(" + tableIndex + " ); return killEvt( evt );") );
           ButtonLink.appendChild( ButtonText );

           Button.appendChild( document.createTextNode( "[" ) );
           Button.appendChild( ButtonLink );
           Button.appendChild( document.createTextNode( "]" ) );

           Header.insertBefore( Button, Header.firstChild );
           tableIndex++;
       }
   }

   for ( var i = 0;  i < tableIndex; i++ ) {
       if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
           collapseTable( i );
       } 
       else if ( hasClass( NavigationBoxes[i], "innercollapse" ) ) {
           var element = NavigationBoxes[i];
           while (element = element.parentNode) {
               if ( hasClass( element, "outercollapse" ) ) {
                   collapseTable ( i );
                   break;
               }
           }
       }
   }

}

$( createCollapseButtons );

/** Test if an element has a certain class **************************************

*
* Description: Uses regular expressions and caching for better performance.
*/

var hasClass = ( function() {

       var reCache = {};
       return function( element, className ) {
               return ( reCache[className] ? reCache[className] : ( reCache[className] = new RegExp( "(?:\\s|^)" + className + "(?:\\s|$)" ) ) ).test( element.className );
       };

})();


/** Dynamic Navigation Bars *************************************

*
*  Description: See Wikipedia:NavFrame.
*/

// set up the words in your language var NavigationBarHide = '[' + collapseCaption + ']'; var NavigationBarShow = '[' + expandCaption + ']';

// shows and hides content and picture (if available) of navigation bars // Parameters: // indexNavigationBar: the index of navigation bar to be toggled function toggleNavigationBar(indexNavigationBar){

   var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
   var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);

   if (!NavFrame || !NavToggle) {
       return false;
   }

   // if shown now
   if (NavToggle.firstChild.data == NavigationBarHide) {
       for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
           if (hasClass(NavChild, 'NavContent') || hasClass(NavChild, 'NavPic')) {
               NavChild.style.display = 'none';
           }
       }
   NavToggle.firstChild.data = NavigationBarShow;

   // if hidden now
   } else if (NavToggle.firstChild.data == NavigationBarShow) {
       for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
           if (hasClass(NavChild, 'NavContent') || hasClass(NavChild, 'NavPic')) {
               NavChild.style.display = 'block';
           }
       }
       NavToggle.firstChild.data = NavigationBarHide;
   }

}

// adds show/hide-button to navigation bars function createNavigationBarToggleButton(){

   var indexNavigationBar = 0;
   // iterate over all < div >-elements 
   var divs = document.getElementsByTagName("div");
   for (var i = 0; NavFrame = divs[i]; i++) {
       // if found a navigation bar
       if (hasClass(NavFrame, "NavFrame")) {

           indexNavigationBar++;
           var NavToggle = document.createElement("a");
           NavToggle.className = 'NavToggle';
           NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
           NavToggle.setAttribute('href', 'javascript:toggleNavigationBar(' + indexNavigationBar + ');');

           var isCollapsed = hasClass( NavFrame, "collapsed" );
           /*
            * Check if any children are already hidden.  This loop is here for backwards compatibility:
            * the old way of making NavFrames start out collapsed was to manually add style="display:none"
            * to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
            * the content visible without JavaScript support), the new recommended way is to add the class
            * "collapsed" to the NavFrame itself, just like with collapsible tables.
            */
           for (var NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling) {
               if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) {
                   if ( NavChild.style.display == 'none' ) {
                       isCollapsed = true;
                   }
               }
           }
           if (isCollapsed) {
               for (var NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling) {
                   if ( hasClass( NavChild, 'NavPic' ) || hasClass( NavChild, 'NavContent' ) ) {
                       NavChild.style.display = 'none';
                   }
               }
           }
           var NavToggleText = document.createTextNode(isCollapsed ? NavigationBarShow : NavigationBarHide);
           NavToggle.appendChild(NavToggleText);

           // Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
           for(var j=0; j < NavFrame.childNodes.length; j++) {
               if (hasClass(NavFrame.childNodes[j], "NavHead")) {
                   NavToggle.style.color = NavFrame.childNodes[j].style.color;
                   NavFrame.childNodes[j].appendChild(NavToggle);
               }
           }
           NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
       }
   }

}

$( createNavigationBarToggleButton );