librelist archives

« back to archive

Fwd: Converse Plugings: Override ControlBoxToggle show method

Fwd: Converse Plugings: Override ControlBoxToggle show method

From:
Rodrigo Alvarez
Date:
2015-07-29 @ 07:10
Hello I'm trying to override ControlBoxToggle.show method. For this I'm
trying to create a plugin to extend (or override) it. But the examples and
documentation that I found couldn't help me (
https://conversejs.org/docs/html/development.html#an-example-plugin and
https://gist.github.com/gbonvehi/376078bd6b702255a7e7 ).

Can you show me a little example to do this?

I guess it will be something like : converse.plugins.extend(...);

Re: [conversejs] Fwd: Converse Plugings: Override ControlBoxToggle show method

From:
Jc Brand
Date:
2015-07-30 @ 12:40
On Wed, Jul 29, 2015 at 12:10:53AM -0700, Rodrigo Alvarez wrote:
>    Hello I'm trying to override ControlBoxToggle.show method. For this I'm
>    trying to create a plugin to extend (or override) it. But the examples and
>    documentation that I found couldn't help me (
>    [1]https://conversejs.org/docs/html/development.html#an-example-plugin and
>    [2]https://gist.github.com/gbonvehi/376078bd6b702255a7e7 ). 
> 
>    Can you show me a little example to do this?
> 
>    I guess it will be something like : converse.plugins.extend(...);

You need something along the lines of:

    converse_api.plugins.add('myplugin', {
        overrides: {
            ControlBoxToggle: {
                show: function (callback) {
                    // Custom code comes here
                }
            },
        }
    }

Pretty much like it's shown in the example you linked to.

JC

Re: [conversejs] Fwd: Converse Plugings: Override ControlBoxToggle show method

From:
Rodrigo Alvarez
Date:
2015-07-30 @ 15:36
Hmm probably Im doing something wrong. With this code:

 require(['converse'], function (converse) {
    converse.plugins.add('myplugin', {
        overrides: {
            ControlBoxToggle: {
                show: function (callback) {
                    console.log('HELLO');
                }
            },
        }
    });
    converse.initialize({
            bosh_service_url: 'https://conversejs.org/http-bind/',
            i18n: locales['en'],
            keepalive: true,
            message_carbons: true,
            play_sounds: true,
            roster_groups: true,
            show_controlbox_by_default: true,
            xhr_user_search: false,
            debug: true
        });
    });


Im getting the following errors in the browser console:
- Converse.js-0.9.3 returns: Uncaught TypeError: $.proxy(...) is not a
function           converse.js:5488
- Converse.js-0.9.4 returns: Uncaught TypeError: plugin.bind is not a
function           converse.js:5909


On Thu, Jul 30, 2015 at 5:40 AM, JC Brand <lists@opkode.com> wrote:

> On Wed, Jul 29, 2015 at 12:10:53AM -0700, Rodrigo Alvarez wrote:
> >    Hello I'm trying to override ControlBoxToggle.show method. For this
> I'm
> >    trying to create a plugin to extend (or override) it. But the
> examples and
> >    documentation that I found couldn't help me (
> >    [1]
> https://conversejs.org/docs/html/development.html#an-example-plugin and
> >    [2]https://gist.github.com/gbonvehi/376078bd6b702255a7e7 ).
> >
> >    Can you show me a little example to do this?
> >
> >    I guess it will be something like : converse.plugins.extend(...);
>
> You need something along the lines of:
>
>     converse_api.plugins.add('myplugin', {
>         overrides: {
>             ControlBoxToggle: {
>                 show: function (callback) {
>                     // Custom code comes here
>                 }
>             },
>         }
>     }
>
> Pretty much like it's shown in the example you linked to.
>
> JC
>

Re: [conversejs] Fwd: Converse Plugings: Override ControlBoxToggle show method

From:
Jc Brand
Date:
2015-07-30 @ 15:44
I'm not sure what the problem is to be honest.

The plugins feature is still a bit raw and not very well documented, because it
currently relies 100% on me donating my time on it.

If you have some JS skills, you can try to figure out what the issue is.

The example in the docs should work, because I distilled it from a plugin 
I wrote for a client.

http://conversejs.containers/docs/html/development.html#writing-a-converse-js-plugin

But it'll only work for version 0.9.4 and up.


On Thu, Jul 30, 2015 at 08:36:21AM -0700, Rodrigo Alvarez wrote:
>    Hmm probably Im doing something wrong. With this code:
> 
>     require(['converse'], function (converse) { 
>        converse.plugins.add('myplugin', {
>            overrides: {
>                ControlBoxToggle: {
>                    show: function (callback) {
>                        console.log('HELLO');
>                    }
>                },
>            }
>        });
>        converse.initialize({
>                bosh_service_url: '[1]https://conversejs.org/http-bind/', 
>                i18n: locales['en'],
>                keepalive: true,
>                message_carbons: true,
>                play_sounds: true,
>                roster_groups: true,
>                show_controlbox_by_ default: true,
>                xhr_user_search: false,
>                debug: true
>            });
>        });
>    Im getting the following errors in the browser console:
>    - Converse.js-0.9.3 returns: Uncaught TypeError: $.proxy(...) is not a
>    function           converse.js:5488
>    - Converse.js-0.9.4 returns: Uncaught TypeError: plugin.bind is not a
>    function           converse.js:5909
> 
>    On Thu, Jul 30, 2015 at 5:40 AM, JC Brand <[2]lists@opkode.com> wrote:
> 
>      On Wed, Jul 29, 2015 at 12:10:53AM -0700, Rodrigo Alvarez wrote:
>      >    Hello I'm trying to override ControlBoxToggle.show method. For this
>      I'm
>      >    trying to create a plugin to extend (or override) it. But the
>      examples and
>      >    documentation that I found couldn't help me (
>      >   
>      [1][3]https://conversejs.org/docs/html/development.html#an-example-plugin
>      and
>      >    [2][4]https://gist.github.com/gbonvehi/376078bd6b702255a7e7 ). 
>      >
>      >    Can you show me a little example to do this?
>      >
>      >    I guess it will be something like : converse.plugins.extend(...);
> 
>      You need something along the lines of:
> 
>          converse_api.plugins.add('myplugin', {
>              overrides: {
>                  ControlBoxToggle: {
>                      show: function (callback) {
>                          // Custom code comes here
>                      }
>                  },
>              }
>          }
> 
>      Pretty much like it's shown in the example you linked to.
>      JC
> 
> References
> 
>    Visible links
>    1. https://conversejs.org/http-bind/
>    2. mailto:lists@opkode.com
>    3. https://conversejs.org/docs/html/development.html#an-example-plugin
>    4. https://gist.github.com/gbonvehi/376078bd6b702255a7e7

Re: [conversejs] Fwd: Converse Plugings: Override ControlBoxToggle show method

From:
Rodrigo Alvarez
Date:
2015-07-30 @ 16:21
Ok, thank you for your time. I will try to find what is the issue and
report it.

And one more question, if converse.plugins.add('mypluging',
{override:{...}}) is for override an function/object. What is the use or
functionality of converse.plugins.extend and converse.plugins.override ?

On Thu, Jul 30, 2015 at 8:44 AM, JC Brand <lists@opkode.com> wrote:

> I'm not sure what the problem is to be honest.
>
> The plugins feature is still a bit raw and not very well documented,
> because it
> currently relies 100% on me donating my time on it.
>
> If you have some JS skills, you can try to figure out what the issue is.
>
> The example in the docs should work, because I distilled it from a plugin
> I wrote for a client.
>
> 
http://conversejs.containers/docs/html/development.html#writing-a-converse-js-plugin
>
> But it'll only work for version 0.9.4 and up.
>
>
> On Thu, Jul 30, 2015 at 08:36:21AM -0700, Rodrigo Alvarez wrote:
> >    Hmm probably Im doing something wrong. With this code:
> >
> >     require(['converse'], function (converse) {
> >        converse.plugins.add('myplugin', {
> >            overrides: {
> >                ControlBoxToggle: {
> >                    show: function (callback) {
> >                        console.log('HELLO');
> >                    }
> >                },
> >            }
> >        });
> >        converse.initialize({
> >                bosh_service_url: '[1]https://conversejs.org/http-bind/
> ',
> >                i18n: locales['en'],
> >                keepalive: true,
> >                message_carbons: true,
> >                play_sounds: true,
> >                roster_groups: true,
> >                show_controlbox_by_ default: true,
> >                xhr_user_search: false,
> >                debug: true
> >            });
> >        });
> >    Im getting the following errors in the browser console:
> >    - Converse.js-0.9.3 returns: Uncaught TypeError: $.proxy(...) is not a
> >    function           converse.js:5488
> >    - Converse.js-0.9.4 returns: Uncaught TypeError: plugin.bind is not a
> >    function           converse.js:5909
> >
> >    On Thu, Jul 30, 2015 at 5:40 AM, JC Brand <[2]lists@opkode.com>
> wrote:
> >
> >      On Wed, Jul 29, 2015 at 12:10:53AM -0700, Rodrigo Alvarez wrote:
> >      >    Hello I'm trying to override ControlBoxToggle.show method. For
> this
> >      I'm
> >      >    trying to create a plugin to extend (or override) it. But the
> >      examples and
> >      >    documentation that I found couldn't help me (
> >      >
> >      [1][3]
> https://conversejs.org/docs/html/development.html#an-example-plugin
> >      and
> >      >    [2][4]https://gist.github.com/gbonvehi/376078bd6b702255a7e7
> ).
> >      >
> >      >    Can you show me a little example to do this?
> >      >
> >      >    I guess it will be something like :
> converse.plugins.extend(...);
> >
> >      You need something along the lines of:
> >
> >          converse_api.plugins.add('myplugin', {
> >              overrides: {
> >                  ControlBoxToggle: {
> >                      show: function (callback) {
> >                          // Custom code comes here
> >                      }
> >                  },
> >              }
> >          }
> >
> >      Pretty much like it's shown in the example you linked to.
> >      JC
> >
> > References
> >
> >    Visible links
> >    1. https://conversejs.org/http-bind/
> >    2. mailto:lists@opkode.com
> >    3.
> https://conversejs.org/docs/html/development.html#an-example-plugin
> >    4. https://gist.github.com/gbonvehi/376078bd6b702255a7e7
>

Re: [conversejs] Fwd: Converse Plugings: Override ControlBoxToggle show method

From:
Jc Brand
Date:
2015-07-31 @ 14:49
On Thu, Jul 30, 2015 at 09:21:21AM -0700, Rodrigo Alvarez wrote:
>    Ok, thank you for your time. I will try to find what is the issue and
>    report it.
> 
>    And one more question, if converse.plugins.add('mypluging',
>    {override:{...}}) is for override an function/object. What is the use or
>    functionality of converse.plugins.extend and converse.plugins.override ?
>    On Thu, Jul 30, 2015 at 8:44 AM, JC Brand <[1]lists@opkode.com> wrote:

Read the comments in the source code under those API methods, it explains 
their usage:
https://github.com/jcbrand/converse.js/blob/master/converse.js#L6448

Best thing you can do is read the relevant source code. Then you'll understand
how it works.