PageSourceSearch

https://svi.nl/lib/jquery_tiki/iconsets.js

js svi.nl collected 2026-09-24 09:16:18 UTC 2,057 bytes, 72 lines download raw bytes

1/* (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
2 *
3 * All Rights Reserved. See copyright.txt for details and a complete list of authors.
4 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
5 *
6 *
7 *
8 * Support for client side iconsets
9 */
10
11(function ($) {
12
13    /**
14     * Get the element object for an icon depending on the current iconset
15     *
16     * @param name {string}        Name of the icon as defined in the iconset
17     * @returns {*|HTMLElement}
18     */
19    $.fn.getIcon = function (name) {
20        var icon = jqueryTiki.iconset.icons[name],
21            $output = $(), attr = "";
22        if (! icon) {
23            if (jqueryTiki.iconset.defaults.indexOf(name) > -1) {
24                icon = { id: name };
25            }
26        }
27
28
29        if (icon) {
30            icon.tag     =  icon.tag     || jqueryTiki.iconset.tag;
31            icon.prepend =  icon.prepend || jqueryTiki.iconset.prepend;
32            icon.append  =  icon.append  || jqueryTiki.iconset.append;
33
34            $output = $("<" + icon.tag + ">");
35            attr = icon.prepend + icon.id + icon.append;
36
37            if (icon.tag === "img") {
38                $output.attr("src", attr);
39                $output = $("<span>")
40                    .addClass("icon")
41                    .addClass("icon-" + name)
42                    .append($output);
43            } else {
44                $output.addClass(attr)
45                    .addClass("icon")
46                    .addClass("icon-" + name);
47            }
48
49        } else {
50            $output = $().getIcon("warning");
51            console.log("iconset: icon not found:" + name);
52        }
53
54        return $output;
55    };
56
57    /**
58     * Change an existing icon's icon
59     * Could be a span for a font-icon or an img for legacy
60     *
61     * @param name string    Name of the icon as defined in the iconset
62     *
63     */
64
65    $.fn.setIcon = function(name) {
66        return $(this)
67            .replaceWith(
68                $(this).getIcon(name)
69            );
70    };
71
72})(jQuery);

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.