/// class PD.Web.UI.Controls.GridDropModule
/// using PD.Web.UI.Controls.GridModule

PD.Web.UI.Controls.GridDropModule =
PD.Web.UI.Controls.GridModule.extend({

    //===================================
    // FIELDS
    //===================================

    _dropTargetArea: null,

    //===================================
    // PUBLIC METHODS
    //===================================

    start: function () {
        this._super();

        this._dropTargetArea = this.get_kendo().content.kendoDropTargetArea({
            filter: "TR[data-uid][role=row]",
            drop: $.proxy(this._onDrop, this)
        }).data("kendoDropTargetArea");

    },

    unload: function () {
        if (this._dropTargetArea != null) {
            this._dropTargetArea.destroy();
        }
    },

    //===================================
    // PRIVATE METHODS
    //===================================
    
    _onDrop: function (e) {

        var $node = $(e.dropTarget),
            grid = this.get_grid(),
            kendo = this.get_kendo(),
            dropFn = this.getOption("dragAndDrop.drop", false);

        if ($node.length > 0 && dropFn != null) {
            dropFn({
                node: $node,
                item: kendo.dataItem($node),
                selections: grid.getSelections()
            });
        }

    }

});