We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Calling all developers! Registering javascripts... lets reuse the ones already there

Development and Programming

Ryan M.'s avatar
Ryan M.
1,511 posts
17 years ago
Ryan M.'s avatar Ryan M.
jQuery 1.6 UI is out with a bunch of bug fixes so you may want to consider using that.

Right…I was just copy/pasting real quick from the google AJAX API page - looks like the latest they have is 1.5.2. I’m not even using UI - I have it disabled in the extension settings.

Can’t wait to see what Derek suggests Travis incorporate into this so I can install a more-or-less “official” version of this extension.

Good stuff!

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

Though I can’t imagine anyone activating this extension and then unchecking jQuery, Victor points out correctly that it’s of course possible. I don’t like the idea of checking for specific versions, it seems like overkill, but since this feature was added primarily for the people in this thread, here’s your chance to lay out a case for how this should be modified to let you easily check to ensure it’s installed, and that jQuery and/or jQuery UI is active.

My personal feeling is to remove the options of disabling either, which was something I did internally first, but decided against it to be friendly for people upgrading from version 1.0. It seems the simplest and most sane option in my book, though.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
17 years ago
Ryan M.'s avatar Ryan M.

I know if I go to the trouble of enabling an extension whose sole purpose is to add jQuery to the CP, I want it on - so, no need for a checkbox to disable. I can see where I might not want UI on, but why not just accept that fact that if I’m loading this extension, they’re both on, and available for use.

In my extensions, then, should I just somehow state, if CP jQuery isn’t enabled, “This extension requires that CP jQuery be enabled.” I’m not a huge fan of having a dependency like that, but simple is good.

I’ll let more experienced developers (Leevi, Victor…) chime in with specifics about how the extensions should check for the presence of jQuery. I think I agree that version checking is a little bit overkill.

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

If we just remove those checkboxes, then you’d check via:

if ( ! isset($EXT->version_numbers['Cp_jquery']))

or comparing the version number of the extension if you need to.

Either way, you could display an error telling the user that it is needed, or you could install it for them by loading the file and calling activate_extension(). Of course, if the file does not exist, then you’d have to settle for an error. That decision would really be up to you.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
17 years ago
Ryan M.'s avatar Ryan M.

What a great thread this is. If nothing else, I’m learning things about extensions that I’m not sure are explicitly stated anywhere else.

I think I like a “check if the Ext is set, if not try to load it for them, if that fails - show an error” route.

       
Derek Jones's avatar
Derek Jones
7,561 posts
17 years ago
Derek Jones's avatar Derek Jones

Yoinked.

       
Leevi Graham's avatar
Leevi Graham
1,143 posts
17 years ago
Leevi Graham's avatar Leevi Graham
So for people following this: This is the new code then 😊
if (isset($EXT->version_numbers['Cp_jquery']) === FALSE && empty($SESS->cache['scripts']['jquery']) === TRUE)
{
/* include jquery */
$SESS->cache['scripts']['jquery']['1.2.6'] = TRUE;
}

Hey Victor,

Are you suggesting that developers put this in their own extension code?

Cheers

       
Ryan M.'s avatar
Ryan M.
1,511 posts
17 years ago
Ryan M.'s avatar Ryan M.

That’s what I’ve been updating in my most recent extensions for the last few days (MD Markitup, MD Character Count, MD Live Search, etc).

       
First 3 4 5

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.