ميډياويکي:Gadget-commentr.js

د ويکيپېډيا، وړیا پوهنغونډ له خوا

د نور تفصيل لپاره د غځول په تنۍ کلېک وکړئيادښت: د غوره توبونو د خوندي کولو وروسته، خپل د کتنمل (بروزر) ساتل شوې حافظه تازه کړی.د نور تفصيل لپاره د غځول په تنۍ کلېک وکړئ.

  • فايرفاکس/ سفري: په دې کتنمل کې د Reload د ټکوهلو په وخت د Shift تڼۍ نيولې وساتی، او يا هم Ctrl-F5 يا Ctrl-Rتڼۍ کېښکاږۍ (په Apple Mac کمپيوټر باندې ⌘-R کېښکاږۍ)
  • گووگل کروم: په دې کتنمل کې د Ctrl-Shift-R تڼۍ کېښکاږۍ (د مک لپاره ⌘-Shift-R)
  • انټرنټ اېکسپلورر: په دې کتنمل کې د Refresh د ټکوهلو په وخت کې د Ctrl تڼۍ کېښکاږلې ونيسۍ، او يا هم د Ctrl-F5 تڼۍ کېښکاږۍ
  • اوپرا: په دې کتنمل کې د خپل براوزر ساتل شوې حافظه پدې توگه سپينولی شی Tools→Preferences
لاسوند[جوړول]
/*  _____________________________________________________________________________ * |                                                                             | * |                    === WARNING: GLOBAL GADGET FILE ===                      | * |                  Changes to this page affect many users.                    | * | Please discuss changes on the talk page or on [[WT:Gadget]] before editing. | * |_____________________________________________________________________________| * * Quick comments form, intended for use on help pages * Based on Teahouse "Ask a question" feature ([[MediaWiki:Gadget-teahouse.js]]) by Andrew Garrett */ //<nowiki> (function($,mw) {  mw.commentr = {    addComment : function( sourcePage, text, targetPage ) {      var editSummary = "New comment from [[" + sourcePage + "]]";      var wikitext = "\n\n== Comment from [[" + sourcePage + "]] ==\n" + text;        if ( (/~~~~\s*$/).test(wikitext) ) {        wikitext += " \n"; // if they signed already      } else {        wikitext += " -- ~~~~ \n"; // else add a sig for them      }        $('#wp-commentr-form-save').button({disabled : true });      $('#wp-commentr-form-save .ui-button-text').html('Saving...');        $('#wp-commentr-link')        .find('.selflink')        .empty()        .addClass('mw-ajax-loader');        var api = new mw.Api();        api.get( {        'action' : 'query',        'titles' : targetPage,        'prop'   : 'revisions|info',        'intoken': 'edit',        'rvprop' : 'content',        'indexpageids' : 1      }, {        'ok' : function(result) {          result = result.query;          var page = result.pages[result.pageids[0]];          var oldText = page.revisions[0]['*'];          var newText = oldText + wikitext;            api.post(            {              'action'  : 'edit',              'title'   : targetPage,              'text'    : newText,              'summary' : editSummary,              'token'   : page.edittoken            },            {              'ok' : function() {window.location.reload();}            }          );        }      });    }  };    $(function() {    mw.loader.using( ['jquery.ui', 'mediawiki.api'], function() {      if ( !$('#wp-commentr-link').length ) { // if there's no link on the page, we're done here.        return;      }        var $link = $('#wp-commentr-link');            var $form = $('#wp-commentr-form');      var $saveButton = $form.find('#wp-commentr-form-save');        var targetPage = $form.find('#wp-commentr-form-targetpage').html();        // Add a real textarea, and remove the placeholder      var $textArea = $('<textarea rows="10" cols="20" id="wp-commentr-form-textarea"></textarea>');      $('#wp-commentr-form-textplaceholder').after($textArea).remove();        // Prevent flash      $form.css( 'left', '-10000px' );        // Set up position      setTimeout( function() {        var pos = $link.position();        var hCenter = ( $link.parent().width() / 2 );        $form.css( 'top', pos.top + $link.height() + 'px' );        $form.css( 'left', (hCenter - ($form.width()) / 2) + 'px' );        $form.hide();      }, 0);        $saveButton        .button({          disabled : true // disable until they type something        })        .click( function(e) {          e.preventDefault();            var sourcePage = wgPageName;          var text = $textArea.val();            if ( text ) {  // only submit if something there            mw.commentr.addComment( sourcePage, text, targetPage );          }        })        $textArea.keypress( function(e) {        var $textbox = $(this);        setTimeout( function() {          if ( $textbox.val() !== '' ) {            $saveButton.button( 'option','disabled', false );          } else {            $saveButton.button( 'option','disabled', true );          }        }, 0 );      } );        $link.click(function(e) {        $form.toggle('fast');        e.cancelBubble = true; // for IE        if (e.stopPropagation) {          e.stopPropagation();          e.preventDefault();        }      });        $(document).click( function(e) {        var $target = $(e.target);        if ( ! $target.is('#wp-commentr-form *') && ! $target.is('#wp-commentr-link *') ) {          $form.fadeOut();        }      } );        $(document).keydown( function(e) {        if ( e.keyCode === 27 ) { // ESC          $form.fadeOut();        }      });    } );  } ); } )(jQuery,mediaWiki); //</nowiki>