May 10, 2020
Estimated Post Reading Time ~

Disable drop source of smart image object

CQ Widget object can be disabled using disable() method. This is also true for SmartImage, but the disabled smart image is still accepting content via drag-and-drop event.

A solution for this is to override SmartImage's disable()methods, then disable dropTarget objects. The enable() method should also be adjusted for restoring the original state.

MySmartImage = CQ.Ext.extend(CQ.html5.form.SmartImage, {

    /**
     * Override disable to disable drop-targets.
     */
    disable : function() {
        if(this.dropTargets) {
            for(var k = 0; k < this.dropTargets.length; k++) {
                this.dropTargets[k].lock();
            }
        }
        MySmartImage.superclass.disable.call(this);
    },

    /**
     * Override enable to enable drop-targets.
     */
    enable : function () {
        if(this.dropTargets) {
            for(var k = 0; k < this.dropTargets.length; k++) {
                this.dropTargets[k].unlock();
            }
        }
        MySmartImage.superclass.enable.call(this);
    }
});

//register xtype
CQ.Ext.reg('mySmartImage', MySmartImage);

The new 'mySmartImage' should be used instead of the default 'html5smartimage' xtype value in the respective configuration file.


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.