-/**
+/**
* mediawiki.Feedback
*
* @author Ryan Kaldari, 2010
* @since 1.19
*
* This is a way of getting simple feedback from users. It's useful
- * for testing new features -- users can give you feedback without
+ * 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
+ * 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
+ * dialog box. Submitting that dialog box appends its contents to a
* wiki page that you specify, as a new section.
*
* Not compatible with LiquidThreads.
- *
+ *
* Minimal example in how to use it:
- *
+ *
* 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.
+ * $( '#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.
*/
( function( mw, $, undefined ) {
-
/**
* Thingy for collecting user feedback on a wiki page
* @param {Array} options -- optional, all properties optional.
- * api: {mw.Api} if omitted, will just create a standard API
+ * api: {mw.Api} if omitted, will just create a standard API
* title: {mw.Title} the title of the page where you collect feedback. Defaults to "Feedback".
* dialogTitleMessageKey: {String} message key for the title of the dialog box
* bugsLink: {mw.Uri|String} url where bugs can be posted
* bugsListLink: {mw.Uri|String} url where bugs can be listed
*/
mw.Feedback = function( options ) {
-
if ( options === undefined ) {
options = {};
}
setup: function() {
var _this = this;
-
var $feedbackPageLink = $( '<a></a>' )
.attr( { 'href': _this.title.getUrl(), 'target': '_blank' } )
.css( { 'white-space': 'nowrap' } );
var $bugsListLink = $( '<a></a>' ).attr( { 'href': _this.bugsListLink, 'target': '_blank' } );
- this.$dialog =
- $( '<div style="position:relative;"></div>' ).append(
+ this.$dialog =
+ $( '<div style="position:relative;"></div>' ).append(
$( '<div class="feedback-mode feedback-form"></div>' ).append(
- $( '<small></small>' ).append(
- $( '<p></p>' ).msg(
- 'feedback-bugornote',
+ $( '<small></small>' ).append(
+ $( '<p></p>' ).msg(
+ 'feedback-bugornote',
$bugNoteLink,
- _this.title.getNameText(),
- $feedbackPageLink.clone()
+ _this.title.getNameText(),
+ $feedbackPageLink.clone()
)
),
- $( '<div style="margin-top:1em;"></div>' ).append(
- mw.msg( 'feedback-subject' ),
- $( '<br/>' ),
- $( '<input type="text" class="feedback-subject" name="subject" maxlength="60" style="width:99%;"/>' )
+ $( '<div style="margin-top:1em;"></div>' ).append(
+ mw.msg( 'feedback-subject' ),
+ $( '<br/>' ),
+ $( '<input type="text" class="feedback-subject" name="subject" maxlength="60" style="width:99%;"/>' )
),
- $( '<div style="margin-top:0.4em;"></div>' ).append(
- mw.msg( 'feedback-message' ),
- $( '<br/>' ),
- $( '<textarea name="message" class="feedback-message" style="width:99%;" rows="5" cols="60"></textarea>' )
+ $( '<div style="margin-top:0.4em;"></div>' ).append(
+ mw.msg( 'feedback-message' ),
+ $( '<br/>' ),
+ $( '<textarea name="message" class="feedback-message" style="width:99%;" rows="5" cols="60"></textarea>' )
)
),
- $( '<div class="feedback-mode feedback-bugs"></div>' ).append(
+ $( '<div class="feedback-mode feedback-bugs"></div>' ).append(
$( '<p>' ).msg( 'feedback-bugcheck', $bugsListLink )
),
- $( '<div class="feedback-mode feedback-submitting" style="text-align:center;margin:3em 0;"></div>' ).append(
- mw.msg( 'feedback-adding' ),
- $( '<br/>' ),
- $( '<img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif" />' )
+ $( '<div class="feedback-mode feedback-submitting" style="text-align:center;margin:3em 0;"></div>' ).append(
+ mw.msg( 'feedback-adding' ),
+ $( '<br/>' ),
+ $( '<img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif" />' )
),
$( '<div class="feedback-mode feedback-thanks" style="text-align:center;margin:1em"></div>' ).msg(
- 'feedback-thanks', _this.title.getNameText(), $feedbackPageLink.clone()
+ 'feedback-thanks', _this.title.getNameText(), $feedbackPageLink.clone()
),
- $( '<div class="feedback-mode feedback-error" style="position:relative;"></div>' ).append(
+ $( '<div class="feedback-mode feedback-error" style="position:relative;"></div>' ).append(
$( '<div class="feedback-error-msg style="color:#990000;margin-top:0.4em;"></div>' )
)
);
title: mw.msg( this.dialogTitleMessageKey ),
modal: true,
buttons: _this.buttons
- });
+ });
this.subjectInput = this.$dialog.find( 'input.feedback-subject' ).get(0);
this.messageInput = this.$dialog.find( 'textarea.feedback-message' ).get(0);
display: function( s ) {
this.$dialog.dialog( { buttons:{} } ); // hide the buttons
this.$dialog.find( '.feedback-mode' ).hide(); // hide everything
- this.$dialog.find( '.feedback-' + s ).show(); // show the desired div
+ this.$dialog.find( '.feedback-' + s ).show(); // show the desired div
},
- displaySubmitting: function() {
+ displaySubmitting: function() {
this.display( 'submitting' );
},
var _this = this;
this.display( 'thanks' );
var closeButton = {};
- closeButton[ mw.msg( 'feedback-close' ) ] = function() { _this.$dialog.dialog( 'close' ); };
+ closeButton[ mw.msg( 'feedback-close' ) ] = function() { _this.$dialog.dialog( 'close' ); };
this.$dialog.dialog( { buttons: closeButton } );
},
var _this = this;
this.subjectInput.value = (contents && contents.subject) ? contents.subject : '';
this.messageInput.value = (contents && contents.message) ? contents.message : '';
-
- this.display( 'form' );
+
+ this.display( 'form' );
// Set up buttons for dialog box. We have to do it the hard way since the json keys are localized
var formButtons = {};
displayError: function( message ) {
this.display( 'error' );
- this.$dialog.find( '.feedback-error-msg' ).msg( message );
+ this.$dialog.find( '.feedback-error-msg' ).msg( message );
},
- cancel: function() {
+ cancel: function() {
this.$dialog.dialog( 'close' );
},
var err = function( code, info ) {
displayError( 'feedback-error3' ); // ajax request failed
};
-
- this.api.newSection( this.title, subject, message, ok, err );
+ this.api.newSection( this.title, subject, message, ok, err );
}, // close submit button function
-
/**
* Modify the display form, and then open it, focusing interface on the subject.
* @param {Object} optional prefilled contents for the feedback form. Object with properties:
this.displayForm( contents );
this.$dialog.dialog( 'open' );
this.subjectInput.focus();
- }
+ }
};
-
} )( window.mediaWiki, jQuery );