「MediaWiki:Gadget-ListingEditor.js」の版間の差分
削除された内容 追加された内容
細編集の要約なし |
更新(ノート) |
||
3行目:
*/
/******************************************************************
Listing Editor version : ja
Original author:
- torty3
19行目:
TODO
- 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';
// --------------------------------------------------------------------
79 ⟶ 88行目:
'add': 'リストを追加',
'edit': '編集',
'saving':
'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': '
};
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',
'食べる・飲む': 'eat',
'
'
};
// If any of these patterns are present on a page then no 'add listing'
178 ⟶ 187行目:
0, //標準
2, //利用者
];
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.
// - 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
'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){
EDITOR_FORM_HTML += '<div id="div_wikidata_update" style="display: none;">' +
'<div class="editor-label-col"> </div>' +
'<div><span class="wikidata-update"></span><a href="javascript:" id="wikidata-shared">ウィキデータとの共有フィールドの同期</a><small> <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>' +
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> WP</small></a>' +
'<span id="wikidata-value-display-container" class="wikidata-value-display-container" style="display: none;">' +
'<small>' +
' <span id="wikidata-value-link" class="wikidata-value-link"></span>' +
' | <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> <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> <span id="image-value-link" class="image-value-link"></span></small>' +
'</span>' +
'</div>' +
'</div>'
if(isMobile){
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> <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">' + if (SPECIAL_CHARS.length){
EDITOR_FORM_HTML += '<br />(';
481 ⟶ 492行目:
}
EDITOR_FORM_HTML +=
'</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
// the summary table is removed or modified
'<div class="listing-divider"></div>' +
'<div class="editor-row">' +
'<div class="editor-label-col"><label for="input-summary">編集の要約</label></div>' +
'<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
'<div title="Preview" class="
if(isMobile){
EDITOR_FORM_HTML += '<
}
EDITOR_FORM_HTML += '<div id="listing-preview-text" class="listing-preview-text"></div>' +
'</div>' +
'</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
}
// populate the empty form with existing values
1,752 ⟶ 1,767行目:
var insertAddListingPlaceholder = function(parentHeading) {
var editSection = $(parentHeading).next('.mw-editsection');
if (isMobile){
// モバイル版のeditsection
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="' +
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');
}
}
}
},
{
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('
}
}
}
],
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 />'));
// 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());
|