Results 1 to 5 of 5

Thread: [JQuery] Syntactic Sugar JavaScript library

Hybrid View

  1. #1

    Thread Starter
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Smile [JQuery] Syntactic Sugar JavaScript library

    Recent Changes
    1. Update to v0.8 Critical bug fixes.
    2. Update to v0.7 Bug fixes and more extensions.


    This is my first shot at a JavaScript library, it includes support for:
    • CSS1 Selectors (By tag name, class name, ID, and parent node trees, although that's a bit different)
    • CSS3 Pseudo-classes
    • Multi-element CSS changes
    • Animation (multiple elements, too!)
    • Additional extensions


    The CSS1 selectors are a bit different when dealing with ancestor-of selectors. Normally, in CSS, "div p" would be any <p> element under a <div> element. In Syntactic Sugar, it must be a direct child (equivalent to "div > p" in CSS). This is because I found it too complicated and unnecessary to include the relationship selectors (*: general sibling, >: direct child, <: direct parent, ~: general sibling, +: adjacent sibling). If you find it necessary, let me know - I'll move it up on the priority list. I'm working on it.

    Here's a syntax example. It takes all <div> elements that are the last <div> element in their parent element that also have the class "blue" but not the class "dontstyle" and colors them blue and italicizes them:

    Code:
    $("div.blue:last-of-type:not(.dontstyle)").color("blue").italic();
    One known bug is that the nth-child, nth-last-child, nth-of-type, and nth-last-of-type selectors do not work with expressions, such as ":nth-last-child(2n+3)". Once again, working on it.

    Please enjoy this library and let me know about any bugs, or any features you want added. Attached are the main library, the animation extensions, and an example HTML file. The example HTML is example.txt (VBForums doesn't let you upload HTML files directly) and contains both scripts so people who just want to see what it's like don't have to download a whole ZIP file.
    Attached Files Attached Files
    Last edited by minitech; Feb 21st, 2011 at 04:34 PM.

  2. #2
    Frenzied Member
    Join Date
    Apr 2009
    Location
    CA, USA
    Posts
    1,516

    Re: [JavaScript] Syntactic Sugar JavaScript library

    Just a note - I don't see a sample HTML file in your zip, just 2 JS files.

  3. #3

    Thread Starter
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: [JavaScript] Syntactic Sugar JavaScript library

    Sorry, I guess I deleted it accidentally. I'll try to make a new one soon.

    In the meantime, 0.8 fixes a huge bug where attribute selectors and ID selectors just do not work.

  4. #4
    PowerPoster motil's Avatar
    Join Date
    Apr 2009
    Location
    Tel Aviv, Israel
    Posts
    2,143

    Re: [JavaScript] Syntactic Sugar JavaScript library

    I just took quick look inside the code and didn't yet tested it, it will be nice to if you'll post here more examples of how to use it and what your library can do.

    one thing though, why you are re-building the css selecter system? you can add sizzle selector system and focus in developing new features that users can't find in other libraries. even John Resig the creator of jQuery did it.

    Anyway I'm really impressed, keep up the good work.
    * Rate It If you Like it

    __________________________________________________________________________________________

    "Programming is like sex: one mistake and you’re providing support for a lifetime."

    Get last SQL insert ID

  5. #5

    Thread Starter
    Stack Overflow mod​erator
    Join Date
    May 2008
    Location
    British Columbia, Canada
    Posts
    2,824

    Re: [JavaScript] Syntactic Sugar JavaScript library

    Thanks I have a little policy, though - I never, ever use libraries of code that aren't mine unless it's really something I can't make. That way I always learn something from making it, and I can customize it very easily.

    Thanks for the suggestions, I'll add some more examples.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width