[closed] New plugin: Pagemanager_XH

Third Party Plugins to CMSimple - how to install, use and create plugins

Moderator: Tata

Gert
Posts: 3078
Joined: Fri May 30, 2008 4:53 pm
Location: Berlin
Contact:

Re: New plugin: Pagemanager_XH

Post by Gert » Sat Jun 25, 2011 3:26 pm

Martin wrote:but as there are only a few jQuery-based plugins and Holger's integration is fresh and new, we could take the opportunity to establish this closure thing as "best practice"?
Already done:

http://www.cmsimple-xh.com/wiki/doku.ph ... d_cmsimple
Gert Ebersbach | CMSimple | Templates - Plugins - Services

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: New plugin: Pagemanager_XH

Post by cmb » Sat Jun 25, 2011 3:43 pm

Hello Martin, hello Gert,
Martin wrote: but as there are only a few jQuery-based plugins and Holger's integration is fresh and new, we could take the opportunity to establish this closure thing as "best practice"?
Gert wrote: Already done:
I think what Martin means with "this closure thing" is the code he'd given! I didn't read about in the documentation, that I've downloaded about an hour ago. Maybe there was an update?

Similar code could be used by all jQuery4CMSimple using plugin authors, to use noConflict(), to make available $ for other js libraries. If it really works for jsTree (i've not tested it for myself, I do not even understand exactly what it's doing right now, but I trust Martin), it's fine with me.

Thanks for the suggestion, testing it soon,
Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Martin
Posts: 346
Joined: Thu Oct 23, 2008 11:57 am
Contact:

Re: New plugin: Pagemanager_XH

Post by Martin » Sat Jun 25, 2011 3:45 pm

That's nice - but not what I habve bee thinking of!

There are several ways to use jQuery in conjunction with other frameworks.
  • just dont use $('#content') but jQuery('#content')
  • you´can create another shortcut like this

    Code: Select all

    var jq = jQuery.noConflict();
    // and after that use jq instead of $
    jq('#content') //etc
  • or you encapsulate your code:

    Code: Select all

    jQuery.noConflict();
    // after the noConflict()-call this won't work
    $(document).ready(function(){alert("Hello");});
    // this will still
    (function($){
        $(document).ready(function(){alert("Hello again");});
    })(jQuery);
    
Perhaps the last solution is the best - at least it keeps you independent from other authors code and your code should have no sideeffects on their ...

Martin

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: New plugin: Pagemanager_XH

Post by cmb » Sat Jun 25, 2011 4:06 pm

Hello Martin,

thanks for your information. The second version you've given here (= the version you've given 2 posts above) is completly new to me. Maybe a good idea.

But shouldn't this information be moved to http://www.cmsimpleforum.com/viewtopic.php?f=12&t=3200 or http://www.cmsimpleforum.com/viewtopic.php?f=29&t=2843, or a new Thread in "Open Development".

I think a solution which is agreed upon by all jQuery plugin developers would be very helpful for everybody.

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Gert
Posts: 3078
Joined: Fri May 30, 2008 4:53 pm
Location: Berlin
Contact:

Re: New plugin: Pagemanager_XH

Post by Gert » Sat Jun 25, 2011 4:12 pm

Hallo Martin,

we should release a new CMSimple_XH 1.4.1 with jQuery4CMSimple included. Not more downloads without jQuery4CMSimple. Are you fit enough in sourceforge to do that right now?

All the other 80% ready stuff we can release as CMSimple_XH 1.5 some weeks later.
Gert Ebersbach | CMSimple | Templates - Plugins - Services

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: New plugin: Pagemanager_XH

Post by cmb » Sat Jun 25, 2011 4:29 pm

Hello Martin,

@Martin:
Yes, I've understand your code. This is no specialty of jQuery, it's general JS!? Ah, lambdas ... ;)

But even if I can use this "trick" for jsTree, I have to know the name under which jQuery is available. After another plugin executes

Code: Select all

var jq = jQuery.noConflict();
$ and jQuery are gone :( Or am I wrong?

So there should be some convention for the plugin writers. I don't want to call my plugin AAAPagemanager_XH ;)

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Holger
Site Admin
Posts: 3470
Joined: Mon May 19, 2008 7:10 pm
Location: Hessen, Germany

Re: New plugin: Pagemanager_XH

Post by Holger » Sat Jun 25, 2011 4:46 pm

@cmb

I can't follow your problem... :?

IMO every incompatibility is gone when only one up to date jQuery-version is included in a page.
And now we have the chance to make things clear with jQuery4CMSimple...

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: New plugin: Pagemanager_XH

Post by cmb » Sat Jun 25, 2011 4:53 pm

Hello Holger,
Holger wrote: And now we have the chance to make things clear with jQuery4CMSimple...
Yes, I think it is a wonderful chance.

But IMO there still is a problem, if a plugin writer calls noConflict() in any way. Then another plugin can't call jQuery in any way, because it doesn't know the name which it was given by the usage of noConflict(). So the plugin which comes first in the alphabet has the chance to let the later plugins fail.

Or am I totally wrong??

Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Martin
Posts: 346
Joined: Thu Oct 23, 2008 11:57 am
Contact:

Re: New plugin: Pagemanager_XH

Post by Martin » Sat Jun 25, 2011 5:12 pm

Hi Christoph,

your pagemanager_xh thread is not what it was intended to be anymore ...

I don't think you have to worry about the variable names of another author. I just inserted this into a template

Code: Select all

        <script>
            $(document).ready(function(){alert("That's the way we know it")});
            jQuery.noConflict();

            a = jQuery.noConflict();
            b = jQuery.noConflict();
            c = jQuery.noConflict();

            c(document).ready(function(){alert("c")});
            a(document).ready(function(){alert("a")});
            b(document).ready(function(){alert("b")});
            jQuery(document).ready(function(){alert("jQuery")});
            (function($){
                $(document).ready(function(){alert("jQuery closure");});
            })(jQuery);
            $(document).ready(function(){alert("That's the way it used to work, but it does not anymore")});
        </script>
All alert dialogs - but the last one - pop up. But I have to admit, I have no idea what is the content of a, b and c and how much memory they consume ... But in fact this a, b, c stuff does not spare that much time in comparison to typing "jQuery" or using a closure anyway. If soemone uses it anyway it wil not hurt your code ...
Martin

Martin

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: New plugin: Pagemanager_XH

Post by cmb » Sat Jun 25, 2011 5:26 pm

Hello Martin,
Martin wrote: your pagemanager_xh thread is not what it was intended to be anymore ...
That's no problem for me, but I'd like to see the discussion about jQuery(4CMSimple)/noConflict in a central place. I'm currently active in discussions about this topic in at least two different threads :(
Martin wrote: All alert dialogs - but the last one - pop up. But I have to admit, I have no idea what is the content of a, b and c and how much memory they consume ... But in fact this a, b, c stuff does not spare that much time in comparison to typing "jQuery" or using a closure anyway. If soemone uses it anyway it wil not hurt your code ...
So I was wrong! Thanks for showing me. But I still would like a simple convention for using jQuery4CMSimple; whatever that would be. And I would like it to be added to jQuery4CMSimple's fine documentation before further distribution. IMO this could be a good idea.

Thanks,
Christoph
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply