<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="he">
	<id>https://zitut.chabadpedia.com/index.php?action=history&amp;feed=atom&amp;title=%D7%9E%D7%93%D7%99%D7%94_%D7%95%D7%99%D7%A7%D7%99%3AGadget-ondemand-Imagemap-Highlight.js</id>
	<title>מדיה ויקי:Gadget-ondemand-Imagemap-Highlight.js - היסטוריית גרסאות</title>
	<link rel="self" type="application/atom+xml" href="https://zitut.chabadpedia.com/index.php?action=history&amp;feed=atom&amp;title=%D7%9E%D7%93%D7%99%D7%94_%D7%95%D7%99%D7%A7%D7%99%3AGadget-ondemand-Imagemap-Highlight.js"/>
	<link rel="alternate" type="text/html" href="https://zitut.chabadpedia.com/index.php?title=%D7%9E%D7%93%D7%99%D7%94_%D7%95%D7%99%D7%A7%D7%99:Gadget-ondemand-Imagemap-Highlight.js&amp;action=history"/>
	<updated>2026-05-16T04:54:44Z</updated>
	<subtitle>היסטוריית הגרסאות של הדף הזה בוויקי</subtitle>
	<generator>MediaWiki 1.40.3</generator>
	<entry>
		<id>https://zitut.chabadpedia.com/index.php?title=%D7%9E%D7%93%D7%99%D7%94_%D7%95%D7%99%D7%A7%D7%99:Gadget-ondemand-Imagemap-Highlight.js&amp;diff=6636&amp;oldid=prev</id>
		<title>מ. רובין: יצירת דף עם התוכן &quot;$(document).ready(function() {      var //add this class to all elements created by the script. the reason is that we call the script again on //window resize, and use the class to remove all the &quot;artefacts&quot; we created in the previous run. 		myClassName = &#039;imageMapHighlighterArtefacts&#039; 		, liHighlightClass = &#039;liHighlighting&#039; 		, specialAreaMark = &#039;area_mark&#039; 		, specialLiClassesMark = &#039;list_classes&#039; // &quot;2d context&quot; attributes used for highlighting. 		, area...&quot;</title>
		<link rel="alternate" type="text/html" href="https://zitut.chabadpedia.com/index.php?title=%D7%9E%D7%93%D7%99%D7%94_%D7%95%D7%99%D7%A7%D7%99:Gadget-ondemand-Imagemap-Highlight.js&amp;diff=6636&amp;oldid=prev"/>
		<updated>2025-07-17T16:22:53Z</updated>

		<summary type="html">&lt;p&gt;יצירת דף עם התוכן &amp;quot;$(document).ready(function() {      var //add this class to all elements created by the script. the reason is that we call the script again on //window resize, and use the class to remove all the &amp;quot;artefacts&amp;quot; we created in the previous run. 		myClassName = &amp;#039;imageMapHighlighterArtefacts&amp;#039; 		, liHighlightClass = &amp;#039;liHighlighting&amp;#039; 		, specialAreaMark = &amp;#039;area_mark&amp;#039; 		, specialLiClassesMark = &amp;#039;list_classes&amp;#039; // &amp;quot;2d context&amp;quot; attributes used for highlighting. 		, area...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;דף חדש&lt;/b&gt;&lt;/p&gt;&lt;div&gt;$(document).ready(function() {&lt;br /&gt;
&lt;br /&gt;
    var&lt;br /&gt;
//add this class to all elements created by the script. the reason is that we call the script again on&lt;br /&gt;
//window resize, and use the class to remove all the &amp;quot;artefacts&amp;quot; we created in the previous run.&lt;br /&gt;
		myClassName = &amp;#039;imageMapHighlighterArtefacts&amp;#039;&lt;br /&gt;
		, liHighlightClass = &amp;#039;liHighlighting&amp;#039;&lt;br /&gt;
		, specialAreaMark = &amp;#039;area_mark&amp;#039;&lt;br /&gt;
		, specialLiClassesMark = &amp;#039;list_classes&amp;#039;&lt;br /&gt;
// &amp;quot;2d context&amp;quot; attributes used for highlighting.&lt;br /&gt;
		, areaHighLighting = {fillStyle: &amp;#039;rgba(0,0,0,0.35)&amp;#039;, strokeStyle: &amp;#039;yellow&amp;#039;, lineJoin: &amp;#039;round&amp;#039;, lineWidth: 2}&lt;br /&gt;
//every imagemap that wants highlighting, should reside in a div of this &amp;#039;class&amp;#039;:&lt;br /&gt;
		, hilightDivMarker = &amp;#039;.imageMapHighlighter&amp;#039;&lt;br /&gt;
// specifically for wikis - redlinks tooltip adds this message&lt;br /&gt;
		, he = mw &amp;amp;&amp;amp; mw.config &amp;amp;&amp;amp; mw.config.get(&amp;#039;wgUserLanguage&amp;#039;) == &amp;#039;he&amp;#039;&lt;br /&gt;
		, expandLegend = he ? &amp;#039;הצגת מקרא&amp;#039; : &amp;#039;ּShow Legend&amp;#039;&lt;br /&gt;
		, collapseLegend = he ? &amp;#039;הסתרת המקרא&amp;#039; : &amp;#039;Hide Legend&amp;#039;&lt;br /&gt;
		;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
	function drawMarker(context, areas) { // mthis is where the magic is done.&lt;br /&gt;
&lt;br /&gt;
		function drawPoly(coords) {&lt;br /&gt;
			context.moveTo(coords.shift(), coords.shift());&lt;br /&gt;
			while (coords.length)&lt;br /&gt;
				context.lineTo(coords.shift(), coords.shift());&lt;br /&gt;
		}&lt;br /&gt;
&lt;br /&gt;
		for (var i in areas) {&lt;br /&gt;
			var coords = areas[i].coords.split(&amp;#039;,&amp;#039;);&lt;br /&gt;
			context.beginPath();&lt;br /&gt;
			switch (areas[i].shape) {&lt;br /&gt;
				case &amp;#039;rect&amp;#039;: drawPoly([coords[0], coords[1], coords[0], coords[3], coords[2], coords[3], coords[2], coords[1]]); break;&lt;br /&gt;
				case &amp;#039;circle&amp;#039;: context.arc(coords[0],coords[1],coords[2],0,Math.PI*2);  break;//x,y,r,startAngle,endAngle&lt;br /&gt;
				case &amp;#039;poly&amp;#039;: drawPoly(coords); break;&lt;br /&gt;
			}&lt;br /&gt;
			context.closePath();&lt;br /&gt;
			context.stroke();&lt;br /&gt;
			context.fill();&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	function mouseAction(e) {&lt;br /&gt;
		var $this = $(this),&lt;br /&gt;
			activate = e.type == &amp;#039;mouseover&amp;#039;,&lt;br /&gt;
			caption = $this.text(),&lt;br /&gt;
			ol = $this.parent(),&lt;br /&gt;
			context = ol.data(&amp;#039;context&amp;#039;),&lt;br /&gt;
			special = ol.data(specialAreaMark);&lt;br /&gt;
		&lt;br /&gt;
		$this.toggleClass(liHighlightClass, activate); // mark/unmark the list item. &lt;br /&gt;
		&lt;br /&gt;
		context.clearRect(0, 0, context.canvas.width, context.canvas.height); // prepare for a new day.&lt;br /&gt;
		&lt;br /&gt;
		ol.find(&amp;#039;li&amp;#039;).each(function() {&lt;br /&gt;
			var $li = $(this);&lt;br /&gt;
			var licap = $li.text();&lt;br /&gt;
			var param;&lt;br /&gt;
			if (activate &amp;amp;&amp;amp; licap === caption) { // highlight!!!&lt;br /&gt;
				param = special &amp;amp;&amp;amp; special.hover  || areaHighLighting;&lt;br /&gt;
			} else {&lt;br /&gt;
				param = special &amp;amp;&amp;amp; special.nover &amp;amp;&amp;amp; (special.nover[licap] || special.nover.default);&lt;br /&gt;
			}&lt;br /&gt;
			if (param) {&lt;br /&gt;
				$.extend(context, param);&lt;br /&gt;
				drawMarker(context, $li.data(&amp;#039;areas&amp;#039;));&lt;br /&gt;
			}&lt;br /&gt;
		});&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	function handleOneMap() {&lt;br /&gt;
		var img = $(this), &lt;br /&gt;
			w = img.width(), &lt;br /&gt;
			h = img.height(),&lt;br /&gt;
			map = img.siblings(&amp;#039;map:first&amp;#039;),&lt;br /&gt;
			dims = {position: &amp;#039;absolute&amp;#039;, width: w + &amp;#039;px&amp;#039;, height: h + &amp;#039;px&amp;#039;, border: 0, top:0, left:0},&lt;br /&gt;
			specialHighlight = img.closest(hilightDivMarker).data(specialAreaMark),&lt;br /&gt;
			specialLiClasses = img.closest(hilightDivMarker).data(specialLiClassesMark);&lt;br /&gt;
		&lt;br /&gt;
		&lt;br /&gt;
		if (!(&amp;#039;area&amp;#039;, map).length)&lt;br /&gt;
			return;	//not an imagemap. inside &amp;quot;each&amp;quot; anonymous function, &amp;#039;return&amp;#039; means &amp;quot;continue&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
		var jcanvas = $(&amp;#039;&amp;lt;canvas&amp;gt;&amp;#039;, {&amp;#039;class&amp;#039;: myClassName})&lt;br /&gt;
			.css(dims)&lt;br /&gt;
			.attr({width: w, height: h});&lt;br /&gt;
		var bgimg = $(&amp;#039;&amp;lt;img&amp;gt;&amp;#039;, {&amp;#039;class&amp;#039;: myClassName, src: img.attr(&amp;#039;src&amp;#039;)})&lt;br /&gt;
			.css(dims);//completely inert image. this is what we see.&lt;br /&gt;
		var context = $.extend(jcanvas[0].getContext(&amp;quot;2d&amp;quot;), areaHighLighting);&lt;br /&gt;
		&lt;br /&gt;
	// this is where the magic is done: prepare a sandwich of the inert bgimg at the bottom,&lt;br /&gt;
	// the canvas above it, and the original image on top,&lt;br /&gt;
	// so canvas won&amp;#039;t steal the mouse events.&lt;br /&gt;
	// pack them all TIGHTLY in a newly minted &amp;quot;relative&amp;quot; div, so when page chnage&lt;br /&gt;
	// (other scripts adding elements, window resize etc.), canvas and imagese remain aligned.&lt;br /&gt;
		var div = $(&amp;#039;&amp;lt;div&amp;gt;&amp;#039;).css({position: &amp;#039;relative&amp;#039;, width: w + &amp;#039;px&amp;#039;, height: h + &amp;#039;px&amp;#039;});&lt;br /&gt;
		img.before(div);	// put the div just above the image, and ...&lt;br /&gt;
		div.append(bgimg)	// place the background image in the div&lt;br /&gt;
			.append(jcanvas)// and the canvas. both are &amp;quot;absolute&amp;quot;, so they don&amp;#039;t occupy space in the div&lt;br /&gt;
			.append(img);	// now yank the original image from the window and place it on the div.&lt;br /&gt;
		img.fadeTo(1, 0);	// make the image transparent - we see canvas and bgimg through it. &lt;br /&gt;
							// the original, now transparent image is creating our mouse events&lt;br /&gt;
		&lt;br /&gt;
		var ol = $(&amp;#039;&amp;lt;ol&amp;gt;&amp;#039;, {&amp;#039;class&amp;#039;: myClassName})&lt;br /&gt;
			.css({clear: &amp;#039;both&amp;#039;, margin: 0, listStyle: &amp;#039;none&amp;#039;, maxWidth: w + &amp;#039;px&amp;#039;, float: &amp;#039;left&amp;#039;, position: &amp;#039;relative&amp;#039;})&lt;br /&gt;
			.attr({&amp;#039;data-expandtext&amp;#039; : expandLegend, &amp;#039;data-collapsetext&amp;#039;: collapseLegend})&lt;br /&gt;
			.data(specialAreaMark, specialHighlight)&lt;br /&gt;
			.data(&amp;#039;context&amp;#039;, context);&lt;br /&gt;
&lt;br /&gt;
		// ol below image, hr below ol. original caption pushed below hr.&lt;br /&gt;
		div.after($(&amp;#039;&amp;lt;hr&amp;gt;&amp;#039;, {&amp;#039;class&amp;#039;: myClassName}).css(&amp;#039;clear&amp;#039;, &amp;#039;both&amp;#039;))&lt;br /&gt;
			.after(ol);&lt;br /&gt;
		var lis = {};	//collapse areas with same caption to one list item&lt;br /&gt;
		var someli; // select arbitrary one&lt;br /&gt;
		$(&amp;#039;area&amp;#039;, map).each(function() {&lt;br /&gt;
			var text = this.title;&lt;br /&gt;
			var li = lis[text];	// title already met? use the same li&lt;br /&gt;
			if (!li) {			//no? create a new one.&lt;br /&gt;
				var href = this.href;&lt;br /&gt;
				lis[text] = li = $(&amp;#039;&amp;lt;li&amp;gt;&amp;#039;, {&amp;#039;class&amp;#039;: myClassName})&lt;br /&gt;
					.append($(&amp;#039;&amp;lt;a&amp;gt;&amp;#039;, {href: href, text: text})) &lt;br /&gt;
					.on(&amp;#039;mouseover mouseout&amp;#039;, mouseAction)&lt;br /&gt;
					.data(&amp;#039;areas&amp;#039;, [])&lt;br /&gt;
					.addClass(specialLiClasses &amp;amp;&amp;amp; (specialLiClasses[text] || specialLiClasses[&amp;#039;default&amp;#039;]))&lt;br /&gt;
					.appendTo(ol);&lt;br /&gt;
			}&lt;br /&gt;
			li.data(&amp;#039;areas&amp;#039;).push(this);	//add the area to the li&lt;br /&gt;
			someli = li; // whichever - we just want one...&lt;br /&gt;
			$(this).on(&amp;#039;mouseover mouseout&amp;#039;, &lt;br /&gt;
				function(e) {&lt;br /&gt;
					li.trigger(e.type);&lt;br /&gt;
				});&lt;br /&gt;
		});&lt;br /&gt;
		if (someli) someli.trigger(&amp;#039;mouseout&amp;#039;);&lt;br /&gt;
		mw.loader.using(&amp;#039;jquery.makeCollapsible&amp;#039;).then( function () {&lt;br /&gt;
			ol.addClass(&amp;#039;mw-collapsed&amp;#039;)&lt;br /&gt;
				.makeCollapsible();&lt;br /&gt;
		});&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	function init() {&lt;br /&gt;
		mw.util.addCSS(&amp;#039;li.&amp;#039; + myClassName + &amp;#039;{white-space:nowrap;border:solid 1px transparent;border-radius:6px;}\n&amp;#039; + //css for li element&lt;br /&gt;
					&amp;#039;li.&amp;#039; +  myClassName + &amp;#039;.&amp;#039; + liHighlightClass + &amp;#039;{background-color:yellow;border-color:green;}\n&amp;#039; + //css for highlighted li element.&lt;br /&gt;
					&amp;#039;.rtl li.&amp;#039; + myClassName + &amp;#039;{float: right; margin-left: 3em;}\n&amp;#039; +&lt;br /&gt;
					&amp;#039;.ltr li.&amp;#039; + myClassName + &amp;#039;{float: left; margin-right: 3em;}&amp;#039;);&lt;br /&gt;
		$(hilightDivMarker+ &amp;#039; img&amp;#039;).each(handleOneMap);&lt;br /&gt;
	}&lt;br /&gt;
&lt;br /&gt;
	//has at least one &amp;quot;imagehighlight&amp;quot; div, and canvas-capable browser:&lt;br /&gt;
	if ( $(hilightDivMarker).length &amp;amp;&amp;amp; $(&amp;#039;&amp;lt;canvas&amp;gt;&amp;#039;)[0].getContext )&lt;br /&gt;
		mw.loader.using( [&amp;#039;jquery.makeCollapsible&amp;#039;, &amp;#039;mediawiki.util&amp;#039;] ).done( init );&lt;br /&gt;
});&lt;/div&gt;</summary>
		<author><name>מ. רובין</name></author>
	</entry>
</feed>