| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
ve.ui.MWHelpListToolGroup = function VeUiMwHelpListToolGroup() { |
| 22 |
this.$footer = $( '<div>' ).addClass( 've-ui-mwHelpListToolGroup-tools-footer' ); |
| 23 |
|
| 24 |
|
| 25 |
ve.ui.MWHelpListToolGroup.super.apply( this, arguments ); |
| 26 |
|
| 27 |
|
| 28 |
this.$element.addClass( 've-ui-mwHelpListToolGroup' ); |
| 29 |
this.$group.addClass( 've-ui-mwHelpListToolGroup-tools' ); |
| 30 |
}; |
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
OO.inheritClass( ve.ui.MWHelpListToolGroup, OO.ui.ListToolGroup ); |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
ve.ui.MWHelpListToolGroup.static.name = 'mwHelpList'; |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
ve.ui.MWHelpListToolGroup.prototype.insertItemElements = function () { |
| 47 |
|
| 48 |
OO.ui.mixin.GroupElement.prototype.insertItemElements.apply( this, arguments ); |
| 49 |
|
| 50 |
this.$group.append( this.$footer ); |
| 51 |
}; |
| 52 |
|
| 53 |
ve.ui.MWHelpListToolGroup.prototype.setActive = function () { |
| 54 |
|
| 55 |
ve.ui.MWHelpListToolGroup.super.prototype.setActive.apply( this, arguments ); |
| 56 |
|
| 57 |
if ( this.active && !this.versionPromise ) { |
| 58 |
const $version = $( '<div>' ).addClass( 'oo-ui-pendingElement-pending' ).text( '\u00a0' ); |
| 59 |
this.$footer.append( $version ); |
| 60 |
this.versionPromise = ve.init.target.getLocalApi().get( { |
| 61 |
action: 'query', |
| 62 |
meta: 'siteinfo', |
| 63 |
siprop: 'extensions' |
| 64 |
} ).then( ( response ) => { |
| 65 |
const extension = response.query.extensions.filter( ( ext ) => ext.name === 'VisualEditor' )[ 0 ]; |
| 66 |
|
| 67 |
if ( extension && extension[ 'vcs-version' ] ) { |
| 68 |
$version |
| 69 |
.removeClass( 'oo-ui-pendingElement-pending' ) |
| 70 |
.empty() |
| 71 |
.append( $( '<a>' ) |
| 72 |
.addClass( 've-ui-mwHelpListToolGroup-version-link' ) |
| 73 |
.attr( 'target', '_blank' ) |
| 74 |
.attr( 'rel', 'noopener' ) |
| 75 |
.attr( 'href', extension[ 'vcs-url' ] ) |
| 76 |
.append( $( '<span>' ) |
| 77 |
.addClass( 've-ui-mwHelpListToolGroup-version-label' ) |
| 78 |
.text( ve.msg( 'visualeditor-version-label' ) + ' ' + extension[ 'vcs-version' ].slice( 0, 7 ) ) |
| 79 |
) |
| 80 |
) |
| 81 |
.append( ' ' ) |
| 82 |
.append( $( '<span>' ) |
| 83 |
.addClass( 've-ui-mwHelpListToolGroup-version-date' ) |
| 84 |
.text( extension[ 'vcs-date' ] ) |
| 85 |
); |
| 86 |
} else { |
| 87 |
$version.remove(); |
| 88 |
} |
| 89 |
}, () => { |
| 90 |
$version.remove(); |
| 91 |
} ); |
| 92 |
} |
| 93 |
}; |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
ve.ui.toolGroupFactory.register( ve.ui.MWHelpListToolGroup ); |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
ve.ui.MWUserGuideTool = function VeUiMWUserGuideTool() { |
| 109 |
ve.ui.MWUserGuideTool.super.apply( this, arguments ); |
| 110 |
|
| 111 |
this.setDisabled( false ); |
| 112 |
}; |
| 113 |
OO.inheritClass( ve.ui.MWUserGuideTool, ve.ui.Tool ); |
| 114 |
ve.ui.MWUserGuideTool.static.name = 'mwUserGuide'; |
| 115 |
ve.ui.MWUserGuideTool.static.group = 'help'; |
| 116 |
ve.ui.MWUserGuideTool.static.icon = 'help'; |
| 117 |
ve.ui.MWUserGuideTool.static.title = |
| 118 |
OO.ui.deferMsg( 'visualeditor-help-label' ); |
| 119 |
ve.ui.MWUserGuideTool.static.autoAddToCatchall = false; |
| 120 |
|
| 121 |
|
| 122 |
ve.ui.MWUserGuideTool.prototype.onUpdateState = function () {}; |
| 123 |
|
| 124 |
ve.ui.MWUserGuideTool.prototype.onSelect = function () { |
| 125 |
this.setActive( false ); |
| 126 |
const urlOrTitle = ve.msg( 'visualeditor-help-link' ); |
| 127 |
if ( urlOrTitle.indexOf( '//' ) !== -1 ) { |
| 128 |
window.open( urlOrTitle ); |
| 129 |
} else { |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
window.open( new mw.Title( urlOrTitle ).getUrl() ); |
| 134 |
} |
| 135 |
}; |
| 136 |
|
| 137 |
ve.ui.toolFactory.register( ve.ui.MWUserGuideTool ); |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
ve.ui.MWFeedbackDialogTool = function VeUiMWFeedbackDialogTool() { |
| 149 |
ve.ui.MWFeedbackDialogTool.super.apply( this, arguments ); |
| 150 |
|
| 151 |
this.setDisabled( false ); |
| 152 |
}; |
| 153 |
OO.inheritClass( ve.ui.MWFeedbackDialogTool, ve.ui.Tool ); |
| 154 |
ve.ui.MWFeedbackDialogTool.static.name = 'mwFeedbackDialog'; |
| 155 |
ve.ui.MWFeedbackDialogTool.static.group = 'help'; |
| 156 |
ve.ui.MWFeedbackDialogTool.static.icon = 'speechBubble'; |
| 157 |
ve.ui.MWFeedbackDialogTool.static.title = |
| 158 |
OO.ui.deferMsg( 'visualeditor-feedback-tool' ); |
| 159 |
ve.ui.MWFeedbackDialogTool.static.autoAddToCatchall = false; |
| 160 |
|
| 161 |
|
| 162 |
ve.ui.MWFeedbackDialogTool.prototype.onUpdateState = function () {}; |
| 163 |
|
| 164 |
ve.ui.MWFeedbackDialogTool.prototype.onSelect = function () { |
| 165 |
this.setActive( false ); |
| 166 |
|
| 167 |
if ( !this.feedbackPromise ) { |
| 168 |
this.feedbackPromise = mw.loader.using( 'mediawiki.feedback' ).then( () => { |
| 169 |
const mode = this.toolbar.getSurface().getMode(); |
| 170 |
|
| 171 |
|
| 172 |
const feedbackConfig = { |
| 173 |
bugsLink: 'https://phabricator.wikimedia.org/maniphest/task/edit/form/1/?projects=VisualEditor', |
| 174 |
showUseragentCheckbox: true, |
| 175 |
useragentCheckboxMandatory: true |
| 176 |
}; |
| 177 |
|
| 178 |
|
| 179 |
const veConfig = mw.config.get( 'wgVisualEditorConfig' ); |
| 180 |
if ( veConfig.feedbackApiUrl ) { |
| 181 |
feedbackConfig.apiUrl = veConfig.feedbackApiUrl; |
| 182 |
feedbackConfig.title = new mw.Title( |
| 183 |
mode === 'source' ? |
| 184 |
veConfig.sourceFeedbackTitle : veConfig.feedbackTitle |
| 185 |
); |
| 186 |
} else { |
| 187 |
feedbackConfig.title = new mw.Title( |
| 188 |
mode === 'source' ? |
| 189 |
ve.msg( 'visualeditor-feedback-source-link' ) : ve.msg( 'visualeditor-feedback-link' ) |
| 190 |
); |
| 191 |
} |
| 192 |
|
| 193 |
return new mw.Feedback( feedbackConfig ); |
| 194 |
} ); |
| 195 |
} |
| 196 |
this.feedbackPromise.done( ( feedback ) => { |
| 197 |
feedback.launch( { |
| 198 |
message: ve.msg( 'visualeditor-feedback-defaultmessage', location.toString() ) |
| 199 |
} ); |
| 200 |
} ); |
| 201 |
}; |
| 202 |
|
| 203 |
ve.ui.toolFactory.register( ve.ui.MWFeedbackDialogTool ); |