MediaWiki:Gadget-ImageAnnotator.js: Difference between revisions
Content deleted Content added
Scope wgNamespaceNumber |
mNo edit summary |
||
Line 95:
if (x < 0 || x >= viewer.full_img.width || y < 0 || y >= viewer.full_img.height)
throw new Error('Invalid note: origin invalid on note ' + id);
if (
|| y + h > viewer.full_img.height + 10
) {
Line 340:
if (span.start > 0) char_before = pagetext.charCodeAt(span.start - 1);
if (span.end < pagetext.length) char_after = pagetext.charCodeAt(span.end);
if (
&& String.fromCharCode(char_after) === '\n')
span.start = span.start - 1;
Line 425:
var editor_width = 50;
// Respect potential user-defined width setting
if (
&& !isNaN (window.ImageAnnotationEditor_columns)
&& window.ImageAnnotationEditor_columns >= 30
Line 986:
this.img_div.appendChild(this.img.parentNode);
}
if (
&& (
|| this.iconOnly
|| ImageAnnotator_config.inlineImageUsesIndicator
Line 999:
if (this.icon) this.icon = this.icon.firstChild; // Skip the message container span or div
// Guard against misconfigurations
if (
&& this.icon.nodeName.toLowerCase() === 'a'
&& this.icon.firstChild.nodeName.toLowerCase() === 'img'
Line 1,046:
var w = IA.getIntItem('full_width_' + id, this.scope);
var h = IA.getIntItem('full_height_' + id, this.scope);
if (
&& !Array.exists(this.annotations, function (note) { return note.model.id === id; })
) {
Line 1,083:
}
}
if (
|| !this.noCaption
&& !IA.hideCaptions
Line 1,194:
}
// Now set position and width and height, subtracting cumulated border widths
if (
|| view_w !== node.offsetWidth || view_h !== node.offsetHeight
) {
Line 1,287:
}
is_within = !(
);
if (is_within) {
Line 1,297:
for (i = this.annotations.length - 1; i >= 0; i--) {
display = this.annotations[i].view.style.display;
if (
&& LAPI.Pos.isWithin(this.annotations[i].view.firstChild, mouse_pos.x, mouse_pos.y)
) {
Line 1,451:
// Determine whether we have XmlHttp. We try to determine this here to be able to avoid
// doing too much work.
if (
&& typeof LAPI !== 'undefined'
&& typeof LAPI.Ajax !== 'undefined'
Line 1,485:
// but overrideable by per-image rules. If set, it's not overrideable by per-image rules.
//
if (
|| !config.generalImagesEnabled()
|| namespaceCheck(window.ImageAnnotator_no_images)
Line 1,493:
self.rules.shared.show = false;
} else {
if (
|| !config.thumbsEnabled()
|| namespaceCheck(window.ImageAnnotator_no_thumbs)
Line 1,501:
if (conf.wgNamespaceNumber === 6)
self.rules.shared.show = true;
else if (
|| namespaceCheck(window.ImageAnnotator_no_shared)
) {
Line 1,526:
self.rules.shared.show = false;
}
if (
&& rules.className.indexOf('wpImageAnnotatorDisplay') >= 0
) {
Line 1,534:
self.rules.thumbs.show = false;
}
if (
&& rules.className.indexOf('wpImageAnnotatorThumbDisplay') >= 0
) {
Line 1,649:
self.is_rtl =
LAPI.DOM.hasClass(document.body, 'rtl')
|| (
&& LAPI.DOM.currentStyle(document.body, 'direction') === 'rtl'
)
Line 1,742:
if (!dim) return null;
// Conditionally exclude shared images.
if (
&& !self.rules.shared.show
&& ImageAnnotator_config.imageIsFromSharedRepository(img.src)
Line 1,956:
// script (and call the callback) synchronously before the assignment is done. Clean
// up in that case.
if (
&& ImageAnnotator.info_callbacks[idx].done && ImageAnnotator.info_callbacks[idx].script
) {
Line 2,100:
if (typeof html_text_or_json === 'string')
text = html_text_or_json;
else if (
text = html_text_or_json.parse.text['*'];
else
Line 2,333:
cover.style.cursor = 'crosshair';
self.definer =
LAPI.make('div', null, {
border: '1px solid '
// IE needs this,
fontSize: '0px',
,zIndex: cover.style.zIndex - 2 // Below the mouse capture div▼
// Below
});
self.viewers[0].img_div.appendChild(self.definer);
// Enter mouse-tracking mode to define extent of view. Mouse cursor is outside of image,
Line 2,380 ⟶ 2,381:
if (self.may_edit && typeof wgRestrictionEdit !== 'undefined' ) {
self.may_edit =
(
|| (
&& wgUserGroups && wgUserGroups.join(' ').contains('confirmed') // confirmed & autoconfirmed
)
Line 2,411 ⟶ 2,412:
if (self.may_edit) {
// Respect user override for zoom, if any▼
self.zoom_threshold = ImageAnnotator_config.zoom_threshold;▼
▲ // Respect user override for zoom, if any
▲ self.zoom_threshold = ImageAnnotator_config.zoom_threshold;
▲ if ( typeof window.ImageAnnotator_zoom_threshold !== 'undefined'
&&
▲ && window.ImageAnnotator_zoom_threshold >= 0.0
) {▼
// If somebody sets it to a nonsensical high value, that's his or her problem: there won't be any▼
// zooming.▼
self.zoom_threshold = window.ImageAnnotator_zoom_threshold;▼
}▼
// Adapt zoom threshold for small thumbnails or images with a very lopsided width/height ratio,▼
// but only if we *can* zoom at least twice▼
if ( self.viewers[0].full_img.width > 300▼
&& Math.min(self.viewers[0].factors.dx, self.viewers[0].factors.dy) >= 2.0▼
) {▼
if ( self.viewers[0].thumb.width < 400▼
|| self.viewers[0].thumb.width / self.viewers[0].thumb.height > 2.0▼
|| self.viewers[0].thumb.height / self.viewers[0].thumb.width > 2.0▼
) {
▲ // If somebody sets it to a nonsensical high value, that's his or her problem: there won't be any
self.zoom_threshold = 0; // Force zooming▼
▲ // zooming.
▲ self.zoom_threshold = window.ImageAnnotator_zoom_threshold;
▲ }
▲ // Adapt zoom threshold for small thumbnails or images with a very lopsided width/height ratio,
▲ // but only if we *can* zoom at least twice
▲ && Math.min(self.viewers[0].factors.dx, self.viewers[0].factors.dy) >= 2.0
▲ ) {
▲ || self.viewers[0].thumb.width / self.viewers[0].thumb.height > 2.0
▲ || self.viewers[0].thumb.height / self.viewers[0].thumb.width > 2.0
▲ ) {
▲ self.zoom_threshold = 0; // Force zooming
}▼
}
▲ }
self.editor = new ImageAnnotationEditor();
self.button_div = LAPI.make('div');▼
self.viewers[0].main_div.appendChild(self.button_div);▼
self.add_button =▼
LAPI.DOM.makeButton(▼
'ImageAnnotationAddButton'▼
, ImageAnnotator.UI.get('wpImageAnnotatorAddButtonText', true)▼
, add_new▼
);▼
var add_plea = ImageAnnotator.UI.needs_plea;▼
self.button_div.appendChild(self.add_button);▼
self.help_link = self.createHelpLink();▼
if (self.help_link) {▼
self.button_div.appendChild(document.createTextNode('\xa0'));▼
self.button_div.appendChild(self.help_link);▼
}▼
if (add_plea && wgServer.contains('/commons'))▼
self.button_div.appendChild(ImageAnnotator.UI.get_plea());▼
▲ self.button_div = LAPI.make('div');
▲ self.viewers[0].main_div.appendChild(self.button_div);
▲ self.add_button =
▲ LAPI.DOM.makeButton(
▲ 'ImageAnnotationAddButton'
▲ , ImageAnnotator.UI.get('wpImageAnnotatorAddButtonText', true)
▲ , add_new
▲ );
▲ var add_plea = ImageAnnotator.UI.needs_plea;
▲ self.button_div.appendChild(self.add_button);
▲ self.help_link = self.createHelpLink();
▲ if (self.help_link) {
▲ self.button_div.appendChild(document.createTextNode('\xa0'));
▲ self.button_div.appendChild(self.help_link);
▲ }
▲ if (add_plea && wgServer.contains('/commons'))
▲ self.button_div.appendChild(ImageAnnotator.UI.get_plea());
} // end if may_edit
Line 2,609 ⟶ 2,608:
if (rules && rules.length) {
rules = rules[0];
if (
&& LAPI.DOM.hasClass(rules, 'wpImageAnnotatorNoInlineDisplay')
) {
local_rules.inline.show = false;
}
if (
&& LAPI.DOM.hasClass(rules, 'wpImageAnnotatorInlineDisplayIcon')
) {
local_rules.inline.icon = true;
}
if (
&& LAPI.DOM.hasClass(rules, 'wpImageAnnotatorNoThumbs')
) {
local_rules.thumbs.show = false;
}
if (
&& LAPI.DOM.hasClass(rules, 'wpImageAnnotatorThumbDisplayIcon')
) {
Line 2,648 ⟶ 2,647:
if (!self.viewers[v].isThumbnail || local_rules.thumbs.show) {
self.viewers[v].scope = pages[i];
self.viewers[v].setup(
|| self.viewers[v].isOther && local_rules.inline.icon);
}
Line 2,687 ⟶ 2,686:
, true // No local caching!
);
if (
&& ImageAnnotator.script_callbacks[idx].done && ImageAnnotator.script_callbacks[idx].script
) {
Line 2,726 ⟶ 2,725:
show_zoom: function () {
var self = IA;
if (
&& self.viewers[0].factors.dy < self.zoom_threshold
)
Line 2,877 ⟶ 2,876:
}
}
if (
&& msg.firstChild.nodeName.toLowerCase() === 'a'
&& !LAPI.DOM.hasClass(msg.firstChild, 'image')
|