MediaWiki:Gadget-ImageAnnotator.js: Difference between revisions
Content deleted Content added
spaceywacy |
Verified a few more type coercion cases to be safe |
||
Line 2:
/*
ImageAnnotator v3.0.0-alpha
Requires an environment running MediaWiki 1.23 or later.
Line 23:
See http://commons.wikimedia.org/wiki/Help:Gadget-ImageAnnotator for documentation.
*/
/*jshint eqeqeq:true, undef:true, unused:true, browser:true, eqnull:true, laxbreak:true, laxcomma:true */
/*global prompt */ // discouraged browser globals
/*global wgServer, wgContentLanguage */ // legacy config site globals
Line 212:
}
}
if (this.viewer.tip === tooltip) this.viewer.tip = null;
// Hide all boxes if we're outside the image. Relies on hide checking the
// coordinates! (Otherwise, we'd always hide...)
Line 315:
, function (doc, editForm, failureFunc, revision_id) {
try {
if (revision_id && revision_id !== conf.wgCurRevisionId)
throw new Error('#Page version (revision ID) mismatch: edit conflict.');
Line 506:
function () {
Array.forEach(IA.viewers, (function (viewer) {
if (viewer !== this.viewer && viewer.visible) viewer.hide();
}).bind(this));
}
Line 546:
if (p && p.revisions && p.revisions.length) {
var rev = p.revisions[0];
if (rev.revid === conf.wgCurRevisionId && rev["*"] && rev["*"].length)
IA.setWikitext(rev["*"]);
}
Line 710:
function (doc, editForm, failureFunc, revision_id) {
try {
if (revision_id && revision_id !== conf.wgCurRevisionId)
// Page was edited since the user loaded it.
throw new Error('#Page version (revision ID) mismatch: edit conflict.');
Line 946:
LAPI.make('div', null, {position: 'relative', width: '' + this.thumb.width + 'px'});
var floater =
LAPI.make('div', null, {
cssFloat: (IA.is_rtl ? '
position:
});
floater.appendChild(this.img_div);
this.img.parentNode.parentNode.insertBefore(floater, this.img.parentNode);
Line 965:
} else if (this.isOther || isEnabledImage) {
this.img_div =
LAPI.make('div', null, { position: 'relative', width: '' + this.thumb.width + 'px' });
this.img.parentNode.parentNode.insertBefore(this.img_div, this.img.parentNode);
this.img_div.appendChild(this.img.parentNode);
// Insert one more to have a file_div, so that we can align the message text correctly
this.file_div = LAPI.make('div', null, { width: '' + this.thumb.width + 'px' });
this.img_div.parentNode.insertBefore(this.file_div, this.img_div);
this.file_div.appendChild(this.img_div);
} else { // Thumbnail
this.img_div =
LAPI.make('div',
{ className: '
width: '' + this.thumb.width + 'px' }
);
this.img.parentNode.parentNode.insertBefore(this.img_div, this.img.parentNode);
Line 1,045 ⟶ 1,047:
var w = IA.getIntItem('full_width_' + id, this.scope);
var h = IA.getIntItem('full_height_' + id, this.scope);
if ( w === this.full_img.width && h === this.full_img.height
&& !Array.exists(this.annotations, function (note) { return note.model.id == id; })
) {
Line 1,104 ⟶ 1,106:
);
var curStyle = null;
for (var up = this.img.parentNode.parentNode; up !== document.body; up = up.parentNode) {
curStyle = (simple ? window.getComputedStyle(up, null) : (up.currentStyle || up.style));
// "up.style" is actually incorrect, but a best-effort fallback.
Line 1,826 ⟶ 1,828:
// need them. This has in particular a benefit if we do have to query for the file sizes below.
if (self.imgs.length === 1 && self.imgs[0].scope === document && !self.haveAjax) {
// Try to get the full size without Ajax.
self.imgs[0].full_img = LAPI.WP.fullImageSizeFromPage();
Line 1,900 ⟶ 1,902:
self.imgs[i].has_page = (typeof info.missing === 'undefined');
self.imgs[i].isLocal = !info.imagerepository || info.imagerepository === 'local';
if (i !== 0 || !self.may_edit || !info.protection || wgNamespaceNumber !== 6) return;
// Care about the protection settings
var protection = Array.any(info.protection, function (e) {
Line 3,017 ⟶ 3,019:
},
/** @return {number|null} */
getIntItem: function (what, scope) {
var x = IA.getItem(what, scope);
|