#1 2010-08-09 09:51:39

ukyo
Community Manager
From: Marmaris - Turkey
Registered: 2010-05-19
Posts: 734
Website

Preparing ionizeItemManager : switchOnline for work with modules

In ionize 0.9.4 default swichOnline

if you want to use this swichOnline in your module your online png files not in action. i will explain with examples.

Default ItemManager Code Snippets :

statusManager = new IonizeItemManager(
    {
        baseUrl:     '<?= base_url() ?>',
        element:     'page',
    });

This is working well for ionize structure but when i use it like this. Switching working well but .png files not changing :

     element: 'page'

"element" look like your table class and url here. if i want use it in my module look like :

     element: 'module/module_name/controller_name'

if u use it like page url its not working for module. And My Modified Code Snippets :

statusManager = new IonizeItemManager(
    {
        baseUrl:     '<?= base_url() ?>',
        element:     'module/module_name/controller_name',
                elementname: 'my_modul_name'
    });

I added an element for send just class name "elementname" :

/** ItemManager
 *    Manage a simple items list of element
 *
 *    Options :
 *
 *        baseUrl:            URL to the website
 *        element:            The element name. Each elemetn ID must be named like : element_ID
 *        itemContainer:        The items container DOM element 
 *
 */

var IonizeItemManager = new Class(
{
    Implements: Options,

    options: {
        baseUrl:        '',
        element:        '',
        idParent:        '',
        parent:            '',
                elementname:    '', //HERE
        container:        false
    },

    initialize: function(options)
    {
        this.setOptions(options);
        
        this.baseUrl =        this.options.baseUrl;

        this.idParent =        this.options.idParent;
        this.parent =        this.options.parent;
        this.element =        this.options.element;
                this.elementname =    this.options.elementname; // HERE

AND here is switchOnline changes :

if (responseJSON.status == 1) {
                        $$('.' + this.elementname + '_' + responseJSON.id).removeClass('offline').addClass('online');//HERE
                    }
                    else
                    {
                        $$('.' + this.elementname + '_' + responseJSON.id).removeClass('online').addClass('offline');//HERE
                    }
                
                    // Set the new online status icon on all articles images
                    var icons = $$('.online_' + this.elementname + '_status' + responseJSON.id);//HERE
                    
                    if (icons)
                    {
                        // Offline icon
                        var src = 'icon_16_offline.png';
                        
                        // Get the online icon
                        if (responseJSON.status == 1) {    src = 'icon_16_online.png';    }
                        
                        src = this.baseUrl + 'themes/admin/images/' + src;

                        // Set the new src to each online icon
                        icons.each(function(item, idx)
                        {
                            item.setProperty('src', src);
                        });
                    }
                
                    // Set the new status on checkedboxes
                    var cb = $('online');
                    var el = $('id_' + this.elementname);//HERE

now working well for me. My Suggestion Is : Can we use elementname or something like this for sending class information.

Sorry for my engilish smile

Last edited by ukyo (2010-08-30 16:30:00)


<ion:ukyo from="Turkey" />
Ionize CMS Türkçe Dil Çeviri Dosyaları | My Github Repositories
Please send your first message to a forum section, not forum users or administration.

Offline

What's Ionize ?

Ionize is an Open Source Content Management System created by webdesigners for webdesigners.

Created and maintained by Partikule and Toopixel, Ionize wants to be the easiest and most powerful CMS.

Can I help ?

Because talent is nothing without involvement, we are looking for motivated coders and webdesigners to join the project team.

Resources

Website : ionizecms.com
Documentation : doc.ionizecms.com

Development : Ionize on GitHub
Translations : Ionize Translations