PageSourceSearch

http://ksam.org/content/media/system/js/caption.js

js ksam.org collected 2026-09-25 07:44:52 UTC 1,963 bytes, 73 lines download raw bytes

1/**
2* @version		$Id: caption.js 5263 2006-10-02 01:25:24Z webImagery $
3* @copyright	Copyright (C) 2005 - 2010 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
38		if(!width) {
39			width = element.width;
40		}
41
42		//Windows fix
43		if (!align)
44			align = element.getStyle("float");  // Rest of the world fix
45		if (!align) // IE DOM Fix
46			align = element.style.styleFloat;
47
48		if (align=="") {
49			align="none";
50		}
51
52		text.appendChild(caption);
53		text.className = this.selector.replace('.', '_');
54
55		element.parentNode.insertBefore(container, element);
56		container.appendChild(element);
57		if ( element.title != "" ) {
58			container.appendChild(text);
59		}
60		container.className   = this.selector.replace('.', '_');
61		container.className   = container.className + " " + align;
62		container.setAttribute("style","float:"+align);
63
64		container.style.width = width + "px";
65
66	}
67});
68
69document.caption = null;
70window.addEvent('load', function() {
71	var caption = new JCaption('img.caption')
72	document.caption = caption
73});

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.