PageSourceSearch

https://www.i-programmer.info/media/system/js/caption.js

js i-programmer.info collected 2026-09-24 08:40:01 UTC 2,150 bytes, 76 lines download raw bytes

1/**
2* @version		$Id: caption.js 5263 2006-10-02 01:25:24Z webImagery $
3* @copyright	Copyright (C) 2005 - 2009 Open Source Matters. All rights reserved.
4* @license		GNU/GPL, see LICENSE.php
5* Joomla! is free software. This version may have been modified pursuant
6* to the GNU General Public License, and as distributed it includes or
7* is derivative of works licensed under the GNU General Public License or
8* other free or open source software licenses.
9* See COPYRIGHT.php for copyright notices and details.
10*/
11
12/**
13* JCaption javascript behavior
14*
15* Used for displaying image captions
16*
17* @package	Joomla
18* @since	1.5
19* @version	1.0
20*/
21var JCaption = new Class({
22	initialize: function(selector)
23	{
24		this.selector = selector;
25
26		var images = $$(selector);
27		images.each(function(image){ this.createCaption(image); }, this);
28	},
29
30	createCaption: function(element)
31	{
32		var caption   = document.createTextNode(element.title);
33		var container = document.createElement("div");
34		var text      = document.createElement("p");
35		var width     = element.getAttribute("width");
36		var align     = element.getAttribute("align");
37		var docMode = document.documentMode;
38
39		//Windows fix
40		if (!align)
41			align = element.getStyle("float");  // Rest of the world fix
42		if (!align) // IE DOM Fix
43			align = element.style.styleFloat;
44
45		text.appendChild(caption);
46		text.className = this.selector.replace('.', '_');
47
48		if (align=="none") {
49			if (element.title != "") {
50				element.parentNode.replaceChild(text, element);
51				text.parentNode.insertBefore(element, text);
52			}
53		} else {
54			element.parentNode.insertBefore(container, element);
55			container.appendChild(element);
56			if ( element.title != "" ) {
57				container.appendChild(text);
58			}
59			container.className   = this.selector.replace('.', '_');
60			container.className   = container.className + " " + align;
61			container.setAttribute("style","float:"+align);
62
63			//IE8 fix
64			if (!docMode|| docMode < 8) {
65				container.style.width = width + "px";
66			}
67		}
68
69	}
70});
71
72document.caption = null;
73window.addEvent('load', function() {
74	var caption = new JCaption('img.caption')
75	document.caption = caption
76});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.