Dołącz do zespołu ekspertów! Backend lub Frontend Developer?

Sprawdź najnowsze oferty pracy naszego partnera - 8lines.io!

Ikona font-awesome zamiast obrazka collapse

Inne  Założony przez  Kacper Wojciechowski.

wersja skryptu MyBB: 1.8.5
adres forum: http://bpp24.eu/index.php
na czym polega problem (screen, opis, komunikaty, nazwa stylu/theme/szablonu):

Witam, chciałbym się zapytać jak dodać ikonę (Zależna od rozsuniętego/zwiniętego działu) font awesome. Tzn zamiast klasycznego obrazka na belce żeby była ikona.
Bez edycji pliku *.js tego nie zrobisz (o ile ma nie być pliku graficznego). Ewentualnie obrazek + ikona font-awesome.
Wtedy dodajesz po <img ...> w szablonie forum_depth2_forum <i class="fa"></i>. Zostanie Ci tylko kwestia CSS, powodzenia.
Prośby na PW dotyczące wsparcia z problemami będą ignorowane. Pomoc poza forum - odpłatna; kontakt: snakemybboard@gmail.com.
W którym pliku *.js znajdę funkcję odpowiadającą za zwijanie działów?
general.js
Prośby na PW dotyczące wsparcia z problemami będą ignorowane. Pomoc poza forum - odpłatna; kontakt: snakemybboard@gmail.com.
Dzięki, mam tak:
var expandables = {

    init: function()
    {
        var expanders = $(".expcolimage .expander");
        if(expanders.length)
        {
            expanders.each(function()
            {
                var expander = $(this);
                if(expander.attr("id") == false)
                {
                    return;
                }

                expander.click(function()
                {
                    controls = expander.attr("id").replace("_img", "");
                    expandables.expandCollapse(this, controls);
                });

                if(MyBB.browser == "ie")
                {
                    expander.css("cursor", "hand");
                }
                else
                {
                    expander.css("cursor", "pointer");
                }
            });
        }
    },

    expandCollapse: function(e, controls)
    {
        element = $(e);

        if(!element || controls == false)
        {
            return false;
        }
        var expandedItem = $("#"+controls+"_e");
        var collapsedItem = $("#"+controls+"_c");

        if(expandedItem.length && collapsedItem.length)
        {
            // Expanding
            if(expandedItem.is(":hidden"))
            {
                expandedItem.slideToggle("fast");
                collapsedItem.slideToggle("fast");
                this.saveCollapsed(controls);
            }
            // Collapsing
            else
            {
                expandedItem.slideToggle("fast");
                collapsedItem.slideToggle("fast");
                this.saveCollapsed(controls, 1);
            }
        }
        else if(expandedItem.length && !collapsedItem.length)
        {
            // Expanding
            if(expandedItem.is(":hidden"))
            {
                expandedItem.slideToggle("fast");
                element.attr("src", element.attr("src").replace(<i class="fa fa-plus-square"></i>$/i, "collapse.$1"))
                                    .attr("alt", "[-]")
                                    .attr("title", "[-]");
                element.parent().parent('td').removeClass('tcat_collapse_collapsed');
                element.parent().parent('.thead').removeClass('thead_collapsed');
                this.saveCollapsed(controls);
            }
            // Collapsing
            else
            {
                expandedItem.slideToggle("fast");
                element.attr("src", element.attr("src").replace(<i class="fa fa-minus-square"></i>$/i, "collapse_collapsed.$1"))
                                    .attr("alt", "[+]")
                                    .attr("title", "[+]");
                element.parent().parent('td').addClass('tcat_collapse_collapsed');
                element.parent().parent('.thead').addClass('thead_collapsed');
                this.saveCollapsed(controls, 1);
            }
        }
        return true;
    },

    saveCollapsed: function(id, add)
    {
        var saved = [];
        var newCollapsed = [];
        var collapsed = Cookie.get('collapsed');

        if(collapsed)
        {
            saved = collapsed.split("|");

            $.each(saved, function(intIndex, objValue)
            {
                if(objValue != id && objValue != "")
                {
                    newCollapsed[newCollapsed.length] = objValue;
                }
            });
        }

        if(add == 1)
        {
            newCollapsed[newCollapsed.length] = id;
        }
        Cookie.set('collapsed', newCollapsed.join("|"));
    }
};
i nie działa
bo to nie ma prawa dzialac
w scr wstawiasz kod html
tu trzeba by uzyc funkcji html()
Teraz tak mam:
var expandables = {

    init: function()
    {
        var expanders = $(".expcolimage .expander");
        if(expanders.length)
        {
            expanders.each(function()
            {
                var expander = $(this);
                if(expander.attr("id") == false)
                {
                    return;
                }

                expander.click(function()
                {
                    controls = expander.attr("id").replace("_img", "");
                    expandables.expandCollapse(this, controls);
                });

                if(MyBB.browser == "ie")
                {
                    expander.css("cursor", "hand");
                }
                else
                {
                    expander.css("cursor", "pointer");
                }
            });
        }
    },

    expandCollapse: function(e, controls)
    {
        element = $(e);

        if(!element || controls == false)
        {
            return false;
        }
        var expandedItem = $("#"+controls+"_e");
        var collapsedItem = $("#"+controls+"_c");

        if(expandedItem.length && collapsedItem.length)
        {
            // Expanding
            if(expandedItem.is(":hidden"))
            {
                expandedItem.slideToggle("fast");
                collapsedItem.slideToggle("fast");
                this.saveCollapsed(controls);
            }
            // Collapsing
            else
            {
                expandedItem.slideToggle("fast");
                collapsedItem.slideToggle("fast");
                this.saveCollapsed(controls, 1);
            }
        }
        else if(expandedItem.length && !collapsedItem.length)
        {
            // Expanding
            if(expandedItem.is(":hidden"))
            {
                expandedItem.slideToggle("fast");
                element.attr("src", element.attr("src").replace(html(<i class="fa fa-plus-square"></i>)$/i, "collapse.$1"))
                                    .attr("alt", "[-]")
                                    .attr("title", "[-]");
                element.parent().parent('td').removeClass('tcat_collapse_collapsed');
                element.parent().parent('.thead').removeClass('thead_collapsed');
                this.saveCollapsed(controls);
            }
            // Collapsing
            else
            {
                expandedItem.slideToggle("fast");
                element.attr("src", element.attr("src").replace(html(<i class="fa fa-minus-square"></i>)$/i, "collapse_collapsed.$1"))
                                    .attr("alt", "[+]")
                                    .attr("title", "[+]");
                element.parent().parent('td').addClass('tcat_collapse_collapsed');
                element.parent().parent('.thead').addClass('thead_collapsed');
                this.saveCollapsed(controls, 1);
            }
        }
        return true;
    },

    saveCollapsed: function(id, add)
    {
        var saved = [];
        var newCollapsed = [];
        var collapsed = Cookie.get('collapsed');

        if(collapsed)
        {
            saved = collapsed.split("|");

            $.each(saved, function(intIndex, objValue)
            {
                if(objValue != id && objValue != "")
                {
                    newCollapsed[newCollapsed.length] = objValue;
                }
            });
        }

        if(add == 1)
        {
            newCollapsed[newCollapsed.length] = id;
        }
        Cookie.set('collapsed', newCollapsed.join("|"));
    }
};

I konflikt
nadal to za malo

zobacz

element.attr("src", element.attr("src").replace(html(<i class="fa fa-plus-square"></i>)$/i, "collapse.$1"))
                                    .attr("alt", "[-]")
                                    .attr("title", "[-]");

pierwsza sprawa to to że sama składnia języka jest dla Ciebie problemem



Użytkownicy przeglądający ten wątek:

2 gości