/*!
* mediawiki.feedback
*
* @author Ryan Kaldari, 2010
* @author Neil Kandalgaonkar, 2010-11
* @since 1.19
*/
( function ( mw, $ ) {
/**
* This is a way of getting simple feedback from users. It's useful
* for testing new features -- users can give you feedback without
* the difficulty of opening a whole new talk page. For this reason,
* it also tends to collect a wider range of both positive and negative
* comments. However you do need to tend to the feedback page. It will
* get long relatively quickly, and you often get multiple messages
* reporting the same issue.
*
* It takes the form of thing on your page which, when clicked, opens a small
* dialog box. Submitting that dialog box appends its contents to a
* wiki page that you specify, as a new section.
*
* This feature works with classic MediaWiki pages
* and is not compatible with LiquidThreads or Flow.
*
* Minimal usage example:
*
* var feedback = new mw.Feedback();
* $( '#myButton' ).click( function () { feedback.launch(); } );
*
* You can also launch the feedback form with a prefilled subject and body.
* See the docs for the #launch() method.
*
* @class
* @constructor
* @param {Object} [options]
* @param {mw.Api} [options.api] if omitted, will just create a standard API
* @param {mw.Title} [options.title="Feedback"] The title of the page where you collect
* feedback.
* @param {string} [options.dialogTitleMessageKey="feedback-submit"] Message key for the
* title of the dialog box
* @param {string} [options.bugsLink="//bugzilla.wikimedia.org/enter_bug.cgi"] URL where
* bugs can be posted
* @param {mw.Uri|string} [options.bugsListLink="//bugzilla.wikimedia.org/query.cgi"]
* URL where bugs can be listed
*/
mw.Feedback = function ( options ) {
if ( options === undefined ) {
options = {};
}
if ( options.api === undefined ) {
options.api = new mw.Api();
}
if ( options.title === undefined ) {
options.title = new mw.Title( 'Feedback' );
}
if ( options.dialogTitleMessageKey === undefined ) {
options.dialogTitleMessageKey = 'feedback-submit';
}
if ( options.bugsLink === undefined ) {
options.bugsLink = '//bugzilla.wikimedia.org/enter_bug.cgi';
}
if ( options.bugsListLink === undefined ) {
options.bugsListLink = '//bugzilla.wikimedia.org/query.cgi';
}
$.extend( this, options );
this.setup();
};
mw.Feedback.prototype = {
/**
* Sets up interface
*/
setup: function () {
var $feedbackPageLink,
$bugNoteLink,
$bugsListLink,
fb = this;
$feedbackPageLink = $( '' )
.attr( {
href: fb.title.getUrl(),
target: '_blank'
} )
.css( {
whiteSpace: 'nowrap'
} );
$bugNoteLink = $( '' ).attr( { href: '#' } ).click( function () {
fb.displayBugs();
} );
$bugsListLink = $( '' ).attr( {
href: fb.bugsListLink,
target: '_blank'
} );
// TODO: Use a stylesheet instead of these inline styles
this.$dialog =
$( '' ).append(
$( '' ).append(
$( '' ).append(
$( '