Debian Codegraph @

extensions/WikiEditor/modules/insertlink/TitleOptionWidget.js

raw symbols SCIP
1 /**
2 * A custom TitleOptionWidget that knows about external links.
3 *
4 * @class
5 * @extends mw.widgets.TitleOptionWidget
6 *
7 * @constructor
8 * @param {Object} config Configuration options.
9 * @param {boolean} [config.external=false] Page title is an external link.
10 * @param {boolean} [config.disambiguation=false]
11 * @param {boolean} [config.missing=false]
12 */
13 function InsertLinkTitleOptionWidget( config ) {
14 this.external = config.external || false;
15 if ( this.external ) {
16 config.icon = 'linkExternal';
17 config.description = mw.msg( 'wikieditor-toolbar-tool-link-int-target-status-external' );
18 // Lowercase the first character; it was uppercased by the API.
19 config.url = config.data.slice( 0, 1 ).toLowerCase() + config.data.slice( 1 );
20 config.data = config.url;
21 // Prepend http:// if there is no protocol (i.e. if it starts with "www.").
22 // @TODO This is repeated when the link is inserted (in jquery.wikiEditor.dialogs.config.js).
23 if ( !/^[a-z]+:\/\/./.test( config.url ) ) {
24 config.url = 'http://' + config.url;
25 }
26 config.missing = false;
27 }
28 this.disambiguation = config.disambiguation || false;
29 this.missing = config.missing || false;
30 InsertLinkTitleOptionWidget.super.call( this, config );
31 }
32
33 OO.inheritClass( InsertLinkTitleOptionWidget, mw.widgets.TitleOptionWidget );
34
35 /**
36 * @return {boolean}
37 */
38 InsertLinkTitleOptionWidget.prototype.isExternal = function () {
39 return this.external;
40 };
41
42 /**
43 * @return {boolean}
44 */
45 InsertLinkTitleOptionWidget.prototype.isMissing = function () {
46 return this.missing;
47 };
48
49 /**
50 * @return {boolean}
51 */
52 InsertLinkTitleOptionWidget.prototype.isDisambiguation = function () {
53 return this.disambiguation;
54 };
55
56 module.exports = InsertLinkTitleOptionWidget;