MediaWiki:Gadget-ImageAnnotator.js: Difference between revisions

Content deleted Content added
Migrate from legacy globals and hardcoded script paths to using getUrl() and wikiScript(); Also hoist functions that were nested in if() blocks, Javascript doesn't support this and just hoists them unconditonally to the nearest top of a function scope.
spaceywacy
Line 163:
'div', null
, { lineHeight : '0px' // IE
,fontSize : '0px' // IE
,width : '' + Math.max(view_w - 2, 0) + 'px' // -2 to leave space for the border
,height : '' + Math.max(view_h - 2, 0) + 'px'
}
)
Line 433:
new LAPI.Edit(
'' , editor_width, 6
, { box : ImageAnnotator.UI.get('wpImageAnnotatorEditorLabel', false)
,preview : ImageAnnotator.UI.get('wpImageAnnotatorPreview', true).capitalizeFirst()
,save : ImageAnnotator.UI.get('wpImageAnnotatorSave', true).capitalizeFirst()
,revert : ImageAnnotator.UI.get('wpImageAnnotatorRevert', true).capitalizeFirst()
,cancel : ImageAnnotator.UI.get('wpImageAnnotatorCancel', true).capitalizeFirst()
,nullsave : ImageAnnotator_config.mayDelete()
? ImageAnnotator.UI.get('wpImageAnnotatorDelete', true).capitalizeFirst()
: null
,post : ImageAnnotator.UI.get('wpImageAnnotatorCopyright', false)
}
, {
onsave : this.save.bind(this)
,onpreview : this.onpreview.bind(this)
,oncancel : this.cancel.bind(this)
,ongettext: function (text) {
if (text == null) return '';
Line 487:
IA.get_cover()
, this.get_editor.bind(this)
, { activate : Tooltip.NONE // We'll always show it explicitly
,deactivate : Tooltip.ESCAPE
,close_button : null // We have a cancel button anyway
,mode : Tooltip.FIXED
,anchor : Tooltip.TOP_LEFT
,mouse_offset : { x:10, y: 10, dx: 1, dy: 1 } // Misuse this: fixed offset from view
,max_pixels : (box_width ? box_width + 20 : 0) // + 20 gives some slack
,z_index : 2010 // Above the cover.
,open_delay : 0
,hide_delay : 0
,onclose : this.close_tooltip.bind(this)
}
, IA.tooltip_styles
Line 948:
LAPI.make(
'div', null
, { cssFloat : (IA.is_rtl ? 'right' : 'left')
,styleFloat: (IA.is_rtl ? 'right' : 'left') // For IE...
,width : '' + this.thumb.width + 'px'
,position : 'relative' // Fixes IE layout bugs...
}
);
Line 1,374:
// for drawing rectangles onto the image if there is only one image and editing is allowed.
 
haveAjax : false,
 
button_div : null,
add_button : null,
 
cover : null,
border : null,
definer : null,
 
mouse_in : (window.ActiveXObject ? 'mouseenter' : 'mouseover'),
mouse_out : (window.ActiveXObject ? 'mouseleave' : 'mouseout'),
 
annotation_class : 'image_annotation',
 
// Format of notes in Wikitext. Note: there are two formats, an old one and a new one.
Line 1,392:
// important, because the old format also used the ImageNote template, but for a different
// purpose.
note_delim :
[
{ start : '<div id="image_annotation_note_$1"'
,end : '</div><!-- End of annotation $1-->'
,content_start : '<div id="image_annotation_content_$1">\n'
,content_end : '</div>\n<span id="image_annotation_wikitext_$1"'
}
,{ start : '{{ImageNote|id=$1'
,end : '{{ImageNoteEnd|id=$1}}'
,content_start : '}}\n'
,content_end : '{{ImageNoteEnd|id=$1}}'
}
],
Line 1,781:
}
}
return { scope : scope
,file_div : file_div
,img : img
,realName : name
,isThumbnail: is_thumb
,isOther : is_other
,thumb : {width: dim.width, height: dim.height}
,iconOnly : icon_only
,noCaption : no_caption
};
}
Line 1,969:
LAPI.Ajax.apiGet(
'query'
, { titles : titles
,prop : 'info|imageinfo'
,inprop : 'protection'
,iiprop : 'size'
}
, function (request, json_result) {
Line 2,297:
self.base_y = mouse_pos.y - origin.y;
Object.merge(
{ left : '' + self.base_x + 'px'
,top : '' + self.base_y + 'px'
,width : '0px'
,height : '0px'
,display: ''
}
Line 2,330:
LAPI.make(
'div', null
,{ border : '1px solid ' + IA.new_border
,display : 'none'
,position : 'absolute'
,top : '0px'
,left : '0px'
,width : '0px'
,height : '0px'
,padding : '0'
,lineHeight : '0px' // IE needs this, even though there are no lines within
,fontSize : '0px' // IE
,zIndex : cover.style.zIndex - 2 // Below the mouse capture div
}
);
Line 2,731:
if (!self.zoom) {
self.zoom =
LAPI.make('div',
{ id: 'divimage_annotator_zoom' },
, {id : 'image_annotator_zoom'}
, { overflow : 'hidden',
,width : '200px',
,height : '200px',
,position : 'absolute',
,display : 'none',
top: '0px',top
left: '0px',
border: ,left'2px solid : '0px#666',
,border backgroundColor: '2px solid #666666white',
zIndex: ,backgroundColor2050 :// On top of 'white'everything
}
,zIndex : 2050 // On top of everything
}
);
var src = self.viewers[0].img.getAttribute('src', 2);
Line 2,750:
if (self.zoom_factor > self.viewers[0].factors.dx || self.zoom_factor > self.viewers[0].factors.dy)
self.zoom_factor = Math.min(self.viewers[0].factors.dx, self.viewers[0].factors.dy);
self.zoom.appendChild(LAPI.make('div', null, { position : 'relative' }));
// Calculate zoom size and source link
var zoom_width = Math.floor(self.viewers[0].thumb.width * self.zoom_factor);
Line 2,773:
LAPI.make(
'div', null
, { width : '1px'
,height : '200px'
,borderLeft : '1px solid red'
,position : 'absolute'
,top : '0px'
,left : '100px'
}
)
Line 2,785:
LAPI.make(
'div', null
, { width : '200px'
,height : '1px'
,borderTop : '1px solid red'
,position : 'absolute'
,top : '100px'
,left : '0px'
}
)
Line 2,920:
var shim;
if (!self.cover) {
var pos = { position : 'absolute'
,left : '0px'
,top : '0px'
,width : self.viewers[0].thumb.width + 'px'
,height : self.viewers[0].thumb.height + 'px'
};
self.cover = LAPI.make('div', null, pos);
Line 2,946:
shim = LAPI.make('div', null, pos);
Object.merge(
{ top : '0px'
,backgroundImage: 'url(' + self.viewers[0].img.src + ')'
,zIndex : imgZ + 2
}
, shim.style