Участник:Арсений Аграновский/incubatorBeginner.js

Материал из Википедии — свободной энциклопедии
function addToIncubator(variant) {
 var addition;
 switch (variant) {
  case 1:
   addition = "{"+"{Инкубатор, Проверить статью}}";
   break;
  case 2:
   addition = "{"+"{Инкубатор, Прошу помочь}}";
   break;
 };
 addition+="\n";
 document.editform.wpTextbox1.value=addition+document.editform.wpTextbox1.value;
};

function incubatorBeginner() {
// Quick Insert
 var block = document.getElementById ('editpage-specialchars');
 if (!block) return;
 var addition = "<p>";
 addition += "<img src=\"http://www.krassotkin.com/files/2010071500/Songbird-egg.svg.20x.png\" />&nbsp;";
 addition += "<span style=\"border-bottom:1px dotted gray; cursor:help; font-size:1em; font-weight:bold;\" title=\"Эти ссылки служат для быстрой вставки шаблонов Инкубатора\">Быстрая вставка шаблонов Инкубатора</span>:&nbsp;";
 addition += "<span style=\"font-size:1em;\"><a onclick=\"addToIncubator(1);return false;\" href=\"#\">{"+"{Инкубатор, Проверить статью}}</a></span>&nbsp;";  
 addition += "<span style=\"font-size:1em;\"><a onclick=\"addToIncubator(2);return false;\" href=\"#\">{"+"{Инкубатор, Прошу помочь}}</a></span>";
 addition += "</p>";
 block.innerHTML = addition+block.innerHTML;

// Toolbar
 // Check that the toolbar is available
 if(typeof $ != "undefined" && typeof $.fn.wikiEditor!="undefined") {
  // Execute on load
  $(document).ready(
 
   function() { 
    // To add a toolbar section:
    $("#wpTextbox1").wikiEditor( 
     "addToToolbar", {
      "sections": {
       "incubator": {
        "type": "toolbar",
        "label": "Инкубатор"
       }
      }
     } 
    ); 
    // To add a group to an existing toolbar section:
    $('#wpTextbox1').wikiEditor( 
     "addToToolbar", {
      "section": "incubator",
      "groups": {
       "templates": {
        "label": "Вставить шаблон:"
       }
      }
     } 
    );
    // To add a select list to an existing toolbar group:
    $("#wpTextbox1").wikiEditor( 
     "addToToolbar", {
      "section": "incubator",
      "group": "templates",
      "tools": {
       "selectTemplate": {
        label: "Выберите шаблон из списка",
        type: "select",
        list: {
         "selectTemplate-check" : {
          label: "{"+"{Инкубатор, Проверить статью}}",
          action: {type:"callback", execute:function(){addToIncubator(1);}}
         },
         "selectTemplate-help" : {
          label: "{"+"{Инкубатор, Прошу помочь}}",
          action: {type:"callback", execute:function(){addToIncubator(2);}}
         }         
        }
       }
      }
     } 
    ); 
   } // function()   
  ); // $(document).ready(  
 }; // if(typeof $j
}; // function playWithToolbar()

addOnloadHook(incubatorBeginner);