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

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

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

    _hintId: null,
    _draggable: null,

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

    start: function () {

        var container = this.get_grid().get_kendo().content,
            constrainDragToGrid = this.getOption("dragAndDrop.constrainToGrid");

        this._super();

        this._hintId = uuid.v4();

        this._draggable = this.get_grid().get_node().kendoDraggable({
            autoScroll: true,
            container: constrainDragToGrid ? container : undefined,
            hint: $.proxy(this._dragHint, this),
            filter: "TR[data-uid][role=row]",
            cursorOffset: {
                top: -10,
                left: 20
            }
        }).data("kendoDraggable");

    },

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

    //===================================
    // PRIVATE METHODS
    //===================================

    _dragHint: function (e) {

        var count = this.get_grid().getSelections().count(),
            message = this.getOption("dragAndDrop.dragHint", "{0} items selected");

        message = message.replace(/\{0\}/g, count);

        return $("<div id='" + this._hintId + "' class='-pd-viewgrid-draghint'>" + message + "<div class='subtext'></div></div>");

    }

});