﻿//// GridDialogCustomSort Class -------------------------------------------

//Properties
GridDialogCustomSort.prototype.divDialog;
GridDialogCustomSort.prototype.btnSort;
GridDialogCustomSort.prototype.btnClose;
GridDialogCustomSort.prototype.imgClose;

GridDialogCustomSort.prototype.addSortMethod;
GridDialogCustomSort.prototype.originalMarginTop;

//Event Handlers

GridDialogCustomSort.prototype.sortClick = function (event)
{
//    this.addSortMethod(cleanedLines);
    this.hide();
}

GridDialogCustomSort.prototype.closeClick = function (event)
{
    this.hide();
}

//other methods
GridDialogCustomSort.prototype.show = function()
{
    this.divDialog.style.marginTop = getNewMarginTop(this.originalMarginTop); //account for scrolling that may have happened
    this.divDialog.style.visibility = 'visible';
}

GridDialogCustomSort.prototype.hide = function()
{
    this.divDialog.style.visibility = 'hidden';
}

// GridDialogCustomSort object constructor
function GridDialogCustomSort(addSortMethod, divDialogId
                                , btnSortId, btnCloseId, imgCloseId)
{
    this.divDialog = elm(divDialogId);
    this.btnSort = elm(btnSortId);
    this.btnClose = elm(btnCloseId);
    this.imgClose = elm(imgCloseId);
    
    this.addSortMethod = addSortMethod;
    this.originalMarginTop = pixelsToNum(getStyle(this.divDialog).marginTop);
    
    function assignEventHandlers(currObj) // Creates a new closure so that inside each event handler "this" means the GridDialogGoogleExport object, not the event target
    {
        if(document.addEventListener)
        {
            currObj.btnSort.addEventListener('click', function(event) {currObj.sortClick(event); }, false);
            currObj.btnClose.addEventListener('click', function(event) {currObj.closeClick(event); }, false);
            currObj.imgClose.addEventListener('click', function(event) {currObj.closeClick(event); }, false);
        }
        else if(document.attachEvent) // IE
        {
            currObj.btnSort.attachEvent('onclick', function(event) {currObj.sortClick(event); }, false);
            currObj.btnClose.attachEvent('onclick', function(event) {currObj.closeClick(event); }, false);
            currObj.imgClose.attachEvent('onclick', function(event) {currObj.closeClick(event); }, false);
        }
    };
    assignEventHandlers(this);
}

//// End of GridDialogCustomSort Class -------------------------------------------
