Diferencia entre revisiones de «MediaWiki:Gadget-Reader.js»

De Vitalinux
Saltar a: navegación, buscar
(typo con titulo)
Línea 1: Línea 1:
 
//<source lang="javascript">
 
//<source lang="javascript">
// read-mostly layout adjustments for vector skin to make left panel into slideout dravtr
+
// read-mostly layout adjustments for vector skin to make left panel into slideout drawer
 
// Based on Jim Tittsler Reader mode for WE
 
// Based on Jim Tittsler Reader mode for WE
 
$(function () {
 
$(function () {
 
   var ppos = -164;
 
   var ppos = -164;
 
   var pmenuheight = $(window).height()-15;
 
   var pmenuheight = $(window).height()-15;
   var vtReaderMode = false;
+
   var weReaderMode = false;
   var vtReaderWidth = window['vtReaderWidth'] || 1024;
+
   var weReaderWidth = mw.user.options.get('userjs-weReader') || 1024;
   function restyleSearch() { // FIXME custom search may not be loaded yet
+
   var pnav = '#p-Navigation';
    $('#p-search').css('margin-bottom', '30px').css('margin-top', '30px');
+
  // es.WE seems to use lower case
     $('#searchInput, #gcse').css('width', '115px');
+
  if ($(pnav).length === 0) {
 +
     pnav = '#p-navigation';
 
   }
 
   }
 
   function reader(){
 
   function reader(){
     if (!vtReaderMode && (window.vtReader || ($(window).width() <= vtReaderWidth))) {
+
     if (!weReaderMode && ($(window).width() <= weReaderWidth)) {
       vtReaderMode = true;
+
       weReaderMode = true;
       $('#mw-panel').css('position', 'fixed')
+
       $('head').append('<style>#p-search {margin-top: 30px !important; margin-bottom: 30px; width: 145px;} #gcse,#simpleSearch {width: 145px !important;} #cse-search-box .searchButton{display: none;}</style>');
                .css('top', '2px')
+
      $('#mw-panel').css({position: 'fixed', top: '2px', left: ppos + 'px', background: '#f3f3f3', 'border-right': 'solid black', 'border-bottom': 'solid black', 'z-index': '10'})
                .css('left', ppos + 'px')
 
                .css('background', '#f3f3f3')
 
                .css('border-right', 'solid black')
 
                .css('border-bottom', 'solid black')
 
                .css('z-index', '10')
 
 
                 .wrapInner('<div id="panelmenu" style="height: ' + pmenuheight + 'px; overflow: auto" />')
 
                 .wrapInner('<div id="panelmenu" style="height: ' + pmenuheight + 'px; overflow: auto" />')
                 .prepend('<div id="panelbutton" style="position: absolute; top: 0px; background:black; color:white; padding: 10px 8px 10px 172px; border-top-right-radius: 8px; border-bottom-right-radius: 8px;">Vitalinux</div>');
+
                 .prepend('<div id="panelbutton" style="position: absolute; top: 0px; background:black; color:white; padding: 10px 8px 10px 172px; border-top-right-radius: 8px; border-bottom-right-radius: 8px;">WikiEducator</div>');
       $('#p-logo,.editsection,#mw-head').hide();
+
       $('#p-logo,.editsection,#n-practice').hide();
 
       $('#content').css('margin-left', '0px').css('border', 'none');
 
       $('#content').css('margin-left', '0px').css('border', 'none');
       $('#p-search').insertBefore('#p-Navigation');
+
       $('#p-search').insertBefore(pnav);
       $('#p-namespaces').insertBefore('#p-Navigation').attr('class', 'portal').find('ul').wrap('<div class="body" />');
+
       $.each(['namespaces', 'views', 'cactions'], function (i, v) {
      $('#p-views').insertAfter('#p-Navigation').attr('class', 'portal').find('ul').wrap('<div class="body" />');
+
        $('#p-' + v + ' ul:first').css({'list-style': 'none', 'margin-bottom': '1em', 'line-height': 2}).insertBefore(pnav);
       if ($('#p-views li').length === 0) $('#p-views').hide();
+
       });
       $('#p-cactions').insertAfter('#p-views').attr('class', 'portal').find('ul').wrap('<div class="body" />');
+
       $('#ca-watch,#ca-unwatch').removeClass('icon');
      if ($('#p-cactions li').length === 0) $('#p-cactions').hide();
+
       $('#p-personal').insertAfter(pnav)
      restyleSearch();  setTimeout(restyleSearch, 2000); // FIXME don't know if search has been added yet
 
       $('#p-personal').insertAfter('#p-cactions')
 
 
                       .addClass('portal')
 
                       .addClass('portal')
 
                       .css('position', 'static')
 
                       .css('position', 'static')
Línea 42: Línea 36:
 
       $('#right-navigation').css('margin-top', '0px');
 
       $('#right-navigation').css('margin-top', '0px');
 
       $('#head-base').css('height', '40px');
 
       $('#head-base').css('height', '40px');
      $('#socialbookmarks').css('padding-left', '0.5em');
 
 
       $('#panelbutton').click(function(e) {
 
       $('#panelbutton').click(function(e) {
 
         e.preventDefault();
 
         e.preventDefault();
Línea 52: Línea 45:
 
   $(window).resize(function() {
 
   $(window).resize(function() {
 
     reader();
 
     reader();
     if (vtReaderMode) {
+
     if (weReaderMode) {
 
       $('#mw-head-base').css('height', '3em');
 
       $('#mw-head-base').css('height', '3em');
 
     }
 
     }

Revisión del 15:38 16 dic 2015

//<source lang="javascript">
// read-mostly layout adjustments for vector skin to make left panel into slideout drawer
// Based on Jim Tittsler Reader mode for WE
$(function () {
  var ppos = -164;
  var pmenuheight = $(window).height()-15;
  var weReaderMode = false;
  var weReaderWidth = mw.user.options.get('userjs-weReader') || 1024;
  var pnav = '#p-Navigation';
  // es.WE seems to use lower case
  if ($(pnav).length === 0) {
    pnav = '#p-navigation';
  }
  function reader(){
    if (!weReaderMode && ($(window).width() <= weReaderWidth)) {
      weReaderMode = true;
      $('head').append('<style>#p-search {margin-top: 30px !important; margin-bottom: 30px; width: 145px;} #gcse,#simpleSearch {width: 145px !important;} #cse-search-box .searchButton{display: none;}</style>');
      $('#mw-panel').css({position: 'fixed', top: '2px', left: ppos + 'px', background: '#f3f3f3', 'border-right': 'solid black', 'border-bottom': 'solid black', 'z-index': '10'})
                 .wrapInner('<div id="panelmenu" style="height: ' + pmenuheight + 'px; overflow: auto" />')
                 .prepend('<div id="panelbutton" style="position: absolute; top: 0px; background:black; color:white; padding: 10px 8px 10px 172px; border-top-right-radius: 8px; border-bottom-right-radius: 8px;">WikiEducator</div>');
      $('#p-logo,.editsection,#n-practice').hide();
      $('#content').css('margin-left', '0px').css('border', 'none');
      $('#p-search').insertBefore(pnav);
      $.each(['namespaces', 'views', 'cactions'], function (i, v) {
        $('#p-' + v + ' ul:first').css({'list-style': 'none', 'margin-bottom': '1em', 'line-height': 2}).insertBefore(pnav);
      });
      $('#ca-watch,#ca-unwatch').removeClass('icon');
      $('#p-personal').insertAfter(pnav)
                      .addClass('portal')
                      .css('position', 'static')
                      .css('right', '0px')
                      .find('ul').wrap('<div class="body" />').end()
                      .find('h5').css('display', 'block').end()
                      .find('li').css('float', 'none');
      $('#left-navigation').css('top', '0px');
      $('#right-navigation').css('margin-top', '0px');
      $('#head-base').css('height', '40px');
      $('#panelbutton').click(function(e) {
        e.preventDefault();
        ppos = (ppos === 0) ? -164 : 0;
        $('#mw-panel').animate( {left: ppos }, 'fast');
      });
    }
  }
  $(window).resize(function() {
    reader();
    if (weReaderMode) {
      $('#mw-head-base').css('height', '3em');
    }
  });
  reader();
});