「MediaWiki:Gadget-ListingEditor.js」の版間の差分

削除された内容 追加された内容
編集の要約なし
更新(ノート
3行目:
*/
/******************************************************************
Listing Editor version : ja 1.2.0
Original author:
- torty3
19行目:
 
TODO
- Add support for mobile devices.
- wrapContent is breaking the expand/collapse logic on the VFD page.
- populate the input-type select list from LISTING_TEMPLATES
48 ⟶ 47行目:
// see http://toddmotto.com/mastering-the-module-pattern/ for an overview
// of the module design pattern being used in this gadget
/* ***********************************************************************
* This part has been configured for the mobile version. The mobile version has
* significant differences from the desktop version,
* such as a narrower screen width. Therefore, it has its own settings here.
* ***********************************************************************/
var isMobile = window.location.href.match(/^https?:\/\/[^.]+\.m\./);
if (isMobile){
mw.loader.load('ext.gadget.ListingEditorMobile', 'text/css');
}
 
/* ***********************************************************************
58 ⟶ 69行目:
// Features unique to the Japanese version
// --------------------------------------------------------------------
// Support the mobile version
var MOBILE_CSS = '//ja.wikivoyage.org/w/index.php?title=User:Tmv/custom/listing editor.js/mobile.css&action=raw&ctype=text/css';
// Specify the icon and text to be shown while loading.
var SAVING_TEXT = '保存中...';
var SAVING_ICON = 'data:image/gif;base64,R0lGODlhIAAgAPMAAP///6qqquvr69XV1ebm5tzc3Lu7u8bGxvHx8fX19ejo6LOzs6urqwAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/hpDcmVhdGVkIHdpdGggYWpheGxvYWQuaW5mbwAh+QQJCgAAACwAAAAAIAAgAAAE5xDISWlhperN52JLhSSdRgwVo1ICQZRUsiwHpTJT4iowNS8vyW2icCF6k8HMMBkCEDskxTBDAZwuAkkqIfxIQyhBQBFvAQSDITM5VDW6XNE4KagNh6Bgwe60smQUB3d4Rz1ZBApnFASDd0hihh12BkE9kjAJVlycXIg7CQIFA6SlnJ87paqbSKiKoqusnbMdmDC2tXQlkUhziYtyWTxIfy6BE8WJt5YJvpJivxNaGmLHT0VnOgSYf0dZXS7APdpB309RnHOG5gDqXGLDaC457D1zZ/V/nmOM82XiHRLYKhKP1oZmADd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VEgULe0NJaxxtYksjh2NLkZISgDgJhHthkpU4mW6blRiYmZOlh4JWkDqILwUGBnE6TYEbCgevr0N1gH4At7gHiRpFaLNrrq8HNgAJA70AWxQIH1+vsYMDAzZQPC9VCNkDWUhGkuE5PxJNwiUK4UfLzOlD4WvzAHaoG9nxPi5d+jYUqfAhhykOFwJWiAAAIfkECQoAAAAsAAAAACAAIAAABPAQyElpUqnqzaciSoVkXVUMFaFSwlpOCcMYlErAavhOMnNLNo8KsZsMZItJEIDIFSkLGQoQTNhIsFehRww2CQLKF0tYGKYSg+ygsZIuNqJksKgbfgIGepNo2cIUB3V1B3IvNiBYNQaDSTtfhhx0CwVPI0UJe0+bm4g5VgcGoqOcnjmjqDSdnhgEoamcsZuXO1aWQy8KAwOAuTYYGwi7w5h+Kr0SJ8MFihpNbx+4Erq7BYBuzsdiH1jCAzoSfl0rVirNbRXlBBlLX+BP0XJLAPGzTkAuAOqb0WT5AH7OcdCm5B8TgRwSRKIHQtaLCwg1RAAAOwAAAAAAAAAAAA==';
 
// --------------------------------------------------------------------
79 ⟶ 88行目:
'add': 'リストを追加',
'edit': '編集',
'saving': SAVING_TEXT'保存中...',
'saved': '保存しました。',
'submit': '投稿',
98 ⟶ 107行目:
'updated': 'ListingEditorでリストを更新 : ',
'removed': 'ListingEditorでリストを削除 : ',
'helpPage': '//ja.wikivoyage.org/wiki/Help:ListingEditor',
'mobileHelpPage': '//ja.m.wikivoyage.org/wiki/Help:ListingEditor',
'enterCaptcha': 'キャプチャを入力してください',
'externalLinks': 'あなたの編集には新しい外部リンクが含まれてます',
117 ⟶ 127行目:
'wikidataShared': '送信されたウィキデータ項目には、以下のデータがありました。この値で共有フィールドを更新しますか?',
'wikidataSharedNotFound': 'ウィキデータのリポジトリに共有データが見つかりませんでした',
'wikidataSyncBlurb': '丸が横に3つ並んでいるうちの、右側を選択するとWikidataのアイコンついているボックスの情報がWikidataWikivoyageのものに置き換わり変更されます。空の値左側を選択すると、内容は削除Wikivoyageの値がWikidataのものに変更されます。どれも真ん中を選択しなければどちらも変更されません。どちらか一方のあ値を選択しましょう。<p>変更したWikidataの参照を追加することを推奨します。',
};
 
156 ⟶ 166行目:
// map section heading ID to the listing template to use for that section
var SECTION_TO_TEMPLATE_TYPE = {
'着く': 'listing|type=go',
'行く': 'listing|type=go',
'移動する': 'listing|type=go',
'困ったときは': 'listing',
'観る': 'see',
'観る・する': 'see',
'する': 'do',
'買う': 'buy',
'食べる': 'eat',
'飲む': 'drink',
'泊まる': 'sleep',
'困ったときは': 'listing',
'待つ': 'listing',
'観る・する': 'see',
'食べる・飲む': 'eat',
'着く飲む': 'listingdrink',
'移動す泊まる': 'listingsleep',
'繋がる': 'listing'
};
// If any of these patterns are present on a page then no 'add listing'
178 ⟶ 187行目:
0, //標準
2, //利用者
4, //Wikivoyage
12, // ヘルプ
102, // プロジェクト
];
 
217 ⟶ 223行目:
// - hideDivIfEmpty: id of a <div> in the EDITOR_FORM_HTML for this
// element that should be hidden if the corresponding template
// parameter has no value. For example, the "fax" field is
// little-used and is not shown by default in the editor form if it
// does not already have a value.
// - skipIfEmpty: Do not include the parameter in the wiki template
// syntax that is saved to the article if the parameter has no
239 ⟶ 243行目:
'phone': { id:'input-phone' },
'tollfree': { id:'input-tollfree' },
'fax': { id:'input-fax', hideDivIfEmpty: 'div_fax', newline: true, skipIfEmpty: true },
'hours': { id:'input-hours' },
'checkin': { id:'input-checkin', hideDivIfEmpty: 'div_checkin', skipIfEmpty: true },
327 ⟶ 331行目:
'<div id="div_name" class="editor-row">' +
'<div class="editor-label-col"><label for="input-name">Name/名前</label></div>' +
'<div class="wikidata-shared-div"><input type="text" class="editor-fullwidth" id="input-name"></div>' +
'</div>' +
'<div id="div_link" class="editor-row">' +
368 ⟶ 372行目:
'<div class="editor-label-col"><label for="input-lastedit">Last Updated</label></div>' +
'<div><input type="text" size="10" id="input-lastedit"></div>' +
'</div>' +;
if (!isMobile){
'<div id="div_wikidata_update" style="display: none">' +
EDITOR_FORM_HTML += '<div id="div_wikidata_update" style="display: none;">' +
'<div class="editor-label-col">&#160;</div>' +
'<div class="editor-label-col">&#160;</div>' +
'<div><span class="wikidata-update"></span><a href="javascript:" id="wikidata-shared">ウィキデータとの共有フィールドの同期</a><small>&nbsp;<a href="javascript:" title="This simply gets the values from Wikidata and replaces the local values. Useful for new listings." class="listing-tooltip" id="wikidata-shared-quick">(quick fetch)</a></small></div>' +
'<div><span class="wikidata-update"></span><a href="javascript:" id="wikidata-shared">ウィキデータとの共有フィールドの同期</a><small>&nbsp;<a href="javascript:" title="This simply gets the values from Wikidata and replaces the local values. Useful for new listings." class="listing-tooltip" id="wikidata-shared-quick">(quick fetch)</a></small></div>';
'</div>' +
}
EDITOR_FORM_HTML += '</div>' +
'</div>' +
'</div>' +
380 ⟶ 386行目:
'<div class="editor-label-col"><label for="input-type">Type/タイプ</label></div>' +
'<div>' +
'<select id="input-type" class="input-type">' +
'<option value="listing">listing</option>' +
'<option value="see">see</option>' +
442 ⟶ 448行目:
'<input type="text" class="editor-partialwidth" id="input-wikidata-label">' +
'<input type="hidden" id="input-wikidata-value">' +
'<a href="javascript:" id="wp-wd" class="wp-wd" title="Get ID from Wikipedia article" style="display: none;"><small>&#160;WP</small></a>' +
'<span id="wikidata-value-display-container" class="wikidata-value-display-container" style="display: none;">' +
'<small>' +
'&#160;<span id="wikidata-value-link" class="wikidata-value-link"></span>' +
'&#160;|&#160;<a href="javascript:" id="wikidata-remove" class="wikidata-remove" title="Delete the Wikidata entry from this listing">remove</a>' +
'</small>' +
'</span>' +
456 ⟶ 462行目:
'<input type="text" class="editor-partialwidth" id="input-wikipedia">' +
'<span id="wikipedia-value-display-container" style="display:none">' +
'<small>&#160;<span id="wikipedia-value-link" class="wikipedia-value-link"></span></small>' +
'</span>' +
'</div>' +
463 ⟶ 469行目:
'<div class="editor-label-col"><label for="input-image">Image/写真<span class="wikidata-update"></span></label></div>' +
'<div>' +
'<input type="text" class="editor-partialwidth input-image" id="input-image">' +
'<span id="image-value-display-container" class="image-value-display-container" style="display:none">' +
'<small>&#160;<span id="image-value-link" class="image-value-link"></span></small>' +
'</span>' +
'</div>' +
'</div>' +;
if(isMobile){
'</div>' +
EDITOR_FORM_HTML += '<div id="div_wikidata_update" style="display: none;">' +
'<div><span class="wikidata-update"></span><a href="javascript:" id="wikidata-shared">ウィキデータとの共有フィールドの同期</a><small>&nbsp;<a href="javascript:" title="This simply gets the values from Wikidata and replaces the local values. Useful for new listings." class="listing-tooltip" id="wikidata-shared-quick">(quick fetch)</a></small></div>';
}
EDITOR_FORM_HTML += '</div>' +
'</div>' +
'</div>' +
'<div id="div_content" class="editor-row">' +
'<div class="editor-label-col"><label for="input-content">Content/内容';
if (SPECIAL_CHARS.length){
EDITOR_FORM_HTML += '<br />(';
481 ⟶ 492行目:
}
EDITOR_FORM_HTML +=
'</label></div>' +
'<div><textarea rows="8" class="editor-fullwidth" id="input-content"></textarea></div>' +
'</div>' +
// update the Callbacks.hideEditOnlyFields method if
// the status row is removed or modified
'<div id="div_status" class="editor-fullwidth">' +
'<div class="editor-label-col"><label>ステータス</label></div>' +
'<div>' +
'<span id="span-closed" class="span-closed">' +
'<input type="checkbox" id="input-closed">' +
'<label for="input-closed" class="listing-tooltip" title="リストの掲載をやめるべき、リストを削除する可きな場合には、チェックボックスにチェックを入れてください。リストが除去されます。">このlistingを削除</label>' +
'</span>' +
// update the Callbacks.updateLastEditDate
// method if the last edit input is removed or modified
'<span id="span-last-edit" class="span-last-edit">' +
'<input type="checkbox" id="input-last-edit" />' +
'<label for="input-last-edit" class="listing-tooltip" title="Check the box if the information in this listing has been verified to be current and accurate, and the last updated date will be changed to the current date">listを最新のものとしてマークする</label>' +
'</span>' +
'</div>' +
'</div>' +
// update the Callbacks.hideEditOnlyFields method if
// update the Callbacks.hideEditOnlyFields method if
// the status row is removed or modified
// the summary table is removed or modified
'<div id="div_status" class="editor-fullwidth">' +
'<div id="div_summary" class="editor-label-colfullwidth"><label>ステータス</label></div>' +
'<div class="listing-divider"></div>' +
'<div class="editor-row">' +
'<div class="editor-label-col"><label for="input-summary">編集の要約</label></div>' +
'<div>' +
'<spaninput type="text" class="editor-partialwidth" id="spaninput-closedsummary">' +
'<span id="span-minor"><input type="checkbox" id="input-minor"><label for="input-minor" class="listing-tooltip" title="Check the box if the change to the listing is minor, such as a typo correction">細部の編集</label></span>' +
'<input type="checkbox" id="input-closed">' +
'<label for="input-closed" class="listing-tooltip" title="リストの掲載をやめるべき、リストを削除する可きな場合には、チェックボックスにチェックを入れてください。リストが除去されます。">このlistingを削除</label>' +
'</span>' +
// update the Callbacks.updateLastEditDate
// method if the last edit input is removed or modified
'<span id="span-last-edit">' +
'<input type="checkbox" id="input-last-edit" />' +
'<label for="input-last-edit" class="listing-tooltip" title="Check the box if the information in this listing has been verified to be current and accurate, and the last updated date will be changed to the current date">listを最新のものとしてマークする</label>' +
'</span>' +
'</div>' +
'</div>' +
'</div>' +
// update the Callbacks.hideEditOnlyFields method if
'<div id="listing-preview" style="display: none;">' +
// the summary table is removed or modified
'<div id="div_summary" class="editorlisting-fullwidthdivider"></div>' +
'<div class="listingeditor-dividerrow"></div>' +
'<div title="Preview" class="editorlisting-rowpreview-title">プレビュー</div>' +;
if(isMobile){
'<div class="editor-label-col"><label for="input-summary">編集の要約</label></div>' +
EDITOR_FORM_HTML += '<divbr />' +;
}
'<input type="text" class="editor-partialwidth" id="input-summary">' +
EDITOR_FORM_HTML += '<div id="listing-preview-text" class="listing-preview-text"></div>' +
'<span id="span-minor"><input type="checkbox" id="input-minor"><label for="input-minor" class="listing-tooltip" title="Check the box if the change to the listing is minor, such as a typo correction">細部の編集</label></span>' +
'</div>' +
'</div>' +
'</div>' +
'<div id="listing-preview" style="display: none;">' +
'<div class="listing-divider"></div>' +
'<div class="editor-row">' +
'<div title="Preview">プレビュー</div>' +
'<div id="listing-preview-text"></div>' +
'</div>' +
'</div>' +
'</formdiv>'; +
'</form>';
 
// expose public members
return {
MOBILE_CSS: MOBILE_CSS,
LANG: LANG,
WIKIDATAID: WIKIDATAID,
809 ⟶ 824行目:
}
}).data("ui-autocomplete")._renderItem = function(ul, item) {
var label = mw.html.escape(item.label) + " <small>" + mw.html.escape(item.id) + "</small>";
if (item.description) {
label += "<br /><small>" + mw.html.escape(item.description) + "</small>";
}
return $("<li>").data('ui-autocomplete-item', item).append($("<a>").html(label)).appendTo(ul);
1,668 ⟶ 1,683行目:
var listingType = listingTemplateAsMap[Config.LISTING_TYPE_PARAMETER];
if (isCustomListingType(listingType)) {
$('#' + listingParameters[Config.LISTING_TYPE_PARAMETER].id, form).append( $( '<option></option>').attr( {value="' +: listingType + '">' +}).text( listingType +) '</option>');
}
// populate the empty form with existing values
1,752 ⟶ 1,767行目:
var insertAddListingPlaceholder = function(parentHeading) {
var editSection = $(parentHeading).next('.mw-editsection');
if (isMobile){
if (window.location.href.match(/^https?:\/\/[^.]+\.m\./)){
// モバイル版のeditsection
// $(editSection).append('<a href="javascript:" classtitle="listingeditor-add"><img' src="https://upload+ Config.wikimediaTRANSLATIONS.org/wikipedia/commons/a/ad/Antu_action-rss_tag.svgadd + '" class="mobilemw-listingeditorui-addicon"icon style="width:mw-ui-icon-element 15px;mw-ui-icon-flush-right mw-ui-button listingeditor-add">' + Config.TRANSLATIONS.add + '</a>');
var pageedit_icon = document.getElementsByClassName('edit-page');
$(".pageedit_icon").removeClass('mw-ui-icon-flush-right');
$(editSection).children('.mw-ui-icon-wikimedia-edit-base20').addClass('shifting-edit-icon');
} else {
editSection.append('<span class="mw-editsection-bracket">[</span><a href="javascript:" class="listingeditor-add">' + Config.TRANSLATIONS.add + '</a><span class="mw-editsection-bracket">]</span>');
}
};
2,100 ⟶ 2,118行目:
var windowWidth = $(window).width();
var dialogWidth = (windowWidth > Config.MAX_DIALOG_WIDTH) ? Config.MAX_DIALOG_WIDTH : 'auto';
var helpPageLink = Config.TRANSLATIONS.helpPage;
if (isMobile){
helpPageLink = Config.TRANSLATIONS.mobileHelpPage;
}
// modal form - must submit or cancel
form.dialog({
2,105 ⟶ 2,127行目:
height: 'auto',
width: dialogWidth,
title: (mode == MODE_ADD) ? Config.TRANSLATIONS.addTitle + '(<a href="' + helpPageLink + '">ヘルプ</a>)' : Config.TRANSLATIONS.editTitle + '(<a href="' + Config.TRANSLATIONS.helpPagehelpPageLink + '">ヘルプ</a>)',
dialogClass: 'listing-editor-dialog',
show: 'number',
hide: 'number',
buttons: [
{
text: '?',
id: 'listing-help',
click: function() { window.open(Config.TRANSLATIONS.helpPage);}
},
{
text: Config.TRANSLATIONS.submit, click: function() {
if ($(Config.EDITOR_CLOSED_SELECTOR).is(':checked')) {
// no need to validate the form upon deletion request
formToText(mode, listingTemplateWikiSyntax, listingTemplateAsMap, sectionNumber);
$(this).dialog('close');
// if a sync editor dialog is open, get rid of it
if ($(Config.SYNC_FORM_SELECTOR).length > 0) {
$(Config.SYNC_FORM_SELECTOR).dialog('close');
}
}
else if (validateForm()) {
formToText(mode, listingTemplateWikiSyntax, listingTemplateAsMap, sectionNumber);
$(this).dialog('close');
// if a sync editor dialog is open, get rid of it
if ($(Config.SYNC_FORM_SELECTOR).length > 0) {
$(Config.SYNC_FORM_SELECTOR).dialog('close');
}
}
}
},
else if (validateForm()) {
{
formToText(mode, listingTemplateWikiSyntax, listingTemplateAsMap, sectionNumber);
text: Config.TRANSLATIONS.preview,
$(this).dialog('close');
title: Config.TRANSLATIONS.preview,
id: 'listing-preview-button',
click: function() {
formToPreview(listingTemplateAsMap);
}
},
{
text: Config.TRANSLATIONS.previewOff,
title: Config.TRANSLATIONS.previewOff,
id: 'listing-previewOff',
style: 'display: none',
click: function() {
hidePreview();
}
},
{
text: Config.TRANSLATIONS.refresh,
title: Config.TRANSLATIONS.refreshTitle,
icon: 'ui-icon-refresh',
id: 'listing-refresh',
style: 'display: none',
click: function() {
refreshPreview(listingTemplateAsMap);
}
},
{
text: Config.TRANSLATIONS.cancel,
click: function() {
$(this).dialog('destroy').remove();
// if a sync editor dialog is open, get rid of it
if ($(Config.SYNC_FORM_SELECTOR).length > 0) {
$(Config.SYNC_FORM_SELECTOR).dialog('closedestroy').remove();
}
}
}
},
{
text: Config.TRANSLATIONS.preview,
title: Config.TRANSLATIONS.preview,
id: 'listing-preview-button',
click: function() {
formToPreview(listingTemplateAsMap);
}
},
{
text: Config.TRANSLATIONS.previewOff,
title: Config.TRANSLATIONS.previewOff,
id: 'listing-previewOff',
style: 'display: none',
click: function() {
hidePreview();
}
},
{
text: Config.TRANSLATIONS.refresh,
title: Config.TRANSLATIONS.refreshTitle,
icon: 'ui-icon-refresh',
id: 'listing-refresh',
style: 'display: none',
click: function() {
refreshPreview(listingTemplateAsMap);
}
},
{
text: Config.TRANSLATIONS.cancel,
click: function() {
$(this).dialog('destroy').remove();
// if a sync editor dialog is open, get rid of it
if ($(Config.SYNC_FORM_SELECTOR).length > 0) {
$(Config.SYNC_FORM_SELECTOR).dialog('destroy').remove();
}
}
}
],
create: function() {
2,250 ⟶ 2,274行目:
// newlines in listing content won't render properly in lists, so replace them with <br> tags
$('#input-content').val($.trim($('#input-content').val()).replace(/\n/g, '<br />'));
// add trailing period in content. Note: replace(/(?<!\.)$/, '.') is not supported by IE
// Trailing period shall not be added if one of the following char is present: ".", "!" or "?"
if ( $('#input-content').val() ) {
$('#input-content').val(($.trim($('#input-content').val())+'.').replace(/([\.\!\?])\.+$/, '$1'));
}
 
// remove trailing period from price and address block
2,474 ⟶ 2,493行目:
var canonicalUrl = $("link[rel='canonical']").attr("href");
var currentUrlWithoutHash = window.location.href.replace(window.location.hash, "");
if (isMobile){
var temporaryCanonicalUrl = $("link[rel='canonical']").attr("href");
canonicalUrl = temporaryCanonicalUrl.replace('ja.wikivoyage.org', 'ja.m.wikivoyage.org');
}
if (canonicalUrl && currentUrlWithoutHash != canonicalUrl) {
var sectionName = mw.util.escapeIdForLink(getSectionName());