Участник:Krassotkin/playWithToolbar.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 playWithToolbar() {
 // 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()

$(playWithToolbar);