Giter Club home page Giter Club logo

Comments (11)

sorccu avatar sorccu commented on June 13, 2024

Hard to say without seeing the HTML. Do you have it online somewhere?

One possibility is that you're using a class name with the word "cufon" in it. If so, you're going to have to change the name.

from cufon.

rvwoens avatar rvwoens commented on June 13, 2024

I've made an example page for you. You can find it at:

http://www.makelaarsbasis.nl/cufontest/

After some more investigation, i found out that with IE7 it works correctly! It seems to be a firefox problem. Firefox on OSX (3.0.11) gives an error and the page hangs. Firefox on windows (latest update) does not give an error, but the page hangs here as well.

and no.. i have no other class named 'cufon'

from cufon.

sorccu avatar sorccu commented on June 13, 2024

Ok, I think I know what's going on:

There's a hidden (display: none) fancybox template (#popid7) on the page. This doesn't prevent it from being replaced however. Fancybox then retrieves the HTML of the template with jQuery's .html() and fills the "real" fancybox with it (not a very wise thing to do in my opinion). The problem is that Cufón injects an expando property to some of the elements it creates. These properties cannot be retrieved with .html() in all browsers, so they are simply lost and the internal structure breaks, causing the error.

I've never been too happy about the expando approach, I'll see if there's an easy way around it.

from cufon.

rvwoens avatar rvwoens commented on June 13, 2024

Sorccu, thanks for your quick response.
I've done some tests myself and found out that if I cufon.replace the text instead of cufon.refresh it, it works, but only for the first time the box is shown. If I start the popup for the second time cufon "magically" knows it did the replacement already and tries to do the refresh to no effect.

So there seems to be some kind of cache or info-copy inside of cufon that keeps track of replaced elements. The best workaround would be if you could clear this cache somehow, or make cufon more robust so it can handle situations where the expando property is not there when the cache says it should be there and the other way around.

from cufon.

rvwoens avatar rvwoens commented on June 13, 2024

Another thing I noticed is that this can really crash firefox! After this error, I've seen firefox OSX crash several times. The windows version seems a bit more stable but strange things are happening under the hood.

Instead of adding expando properties you might consider adding a special "CufonReplaced" class to the object, the same way as Sifr does.

from cufon.

sorccu avatar sorccu commented on June 13, 2024

The issue isn't how to detect already replaced elements, but rather that the structure is broken. Expando properties are used by many, many scripts (including jQuery, MooTools and presumably most other frameworks as well), which is why it would be better to use DOM methods than .innerHTML. I don't really understand why they chose to go with .innerHTML.

from cufon.

rvwoens avatar rvwoens commented on June 13, 2024

I understand and i don't like the innerHTML method neither, but it is something that cufon should be able to handle somehow. You can't forbid other libs to use innerhtml. But a workaround with good documentation should be enough. If i have some spare time i'll take a look at the cufon code myself.

from cufon.

jasonseney avatar jasonseney commented on June 13, 2024

Was able to get this working with simple modal by putting all the Cufon.replace calls after it is shown. Looks like the alt attribute in the DOM isn't being carried through between show/hide of the dialog box?

Example:

$("#results").modal({
    opacity: 70,
    containerId: "dialogContainer",
    overlayId: "dialogOverlay",
    onShow: applyDialogFontRender
});

function applyDialogFontRender() {
    if (typeof (Cufon) != "undefined" && Cufon != null) {
        Cufon.replace('#results h3', { fontFamily: fontFamily });
        Cufon.replace('#results p', { fontFamily: fontFamily });
        Cufon.replace('#results strong', { fontFamily: fontFamily });
    }
}

Hope this helps someone!

from cufon.

rvwoens avatar rvwoens commented on June 13, 2024

@jasonseney Yep this works as I stated earlier. But when the user hides the popup and shows it AGAIN, the font is not visible any more. And the replace call in that case does not work any more. So this is not a solution.

from cufon.

jasonseney avatar jasonseney commented on June 13, 2024

@rvwoens , sorry my solution was for simpleModal, which is probably a little different from fancybox? This works for me (will render on subsequent dialog popups). Maybe you'll need to write an un-render function that undoes cufon and then call the cufon.replace after that? Wish I could help more, might try to look at fancy box source when I have a chance.

from cufon.

rvwoens avatar rvwoens commented on June 13, 2024

@jasonseney well, an un-render or cufon-clear or cufon-reset function might come in handy here. As I said, a simple workaround would be sufficient. There is a large amount of js code out there and sometimes you just need to tweak things a bit. A few extra cufon calls might do the trick.

Make no mistake: I like cufon a lot, and it is already a much more reliable method than Sifr.

from cufon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.