﻿//// GridDialogCustomFilter Class -------------------------------------------

//Properties
GridDialogCustomFilter.prototype.divDialog;
GridDialogCustomFilter.prototype.btnAddLevel;
GridDialogCustomFilter.prototype.btnDeleteLevel;
GridDialogCustomFilter.prototype.radgrpBoolType;
GridDialogCustomFilter.prototype.divFilterTable;
GridDialogCustomFilter.prototype.btnClose;
GridDialogCustomFilter.prototype.imgClose;

GridDialogCustomFilter.prototype.addFilterMethod;
GridDialogCustomFilter.prototype.originalMarginTop;

//Event Handlers

GridDialogCustomFilter.prototype.addLevelClick = function (event)
{
    alert('ADD');
}

GridDialogCustomFilter.prototype.deleteLevelClick = function (event)
{
    alert('DELETE');
}

GridDialogCustomFilter.prototype.filterClick = function (event)
{
//    this.addFilterMethod(cleanedLines);
    this.hide();
}

GridDialogCustomFilter.prototype.closeClick = function (event)
{
    this.hide();
}

//other methods
GridDialogCustomFilter.prototype.GetDropDownColumns = function()
{

}

GridDialogCustomFilter.prototype.GetDropDownComparisons = function()
{

}

GridDialogCustomFilter.prototype.GetDropDownComparisons = function()
{

}

GridDialogCustomFilter.prototype.show = function()
{
    this.divDialog.style.marginTop = getNewMarginTop(this.originalMarginTop); //account for scrolling that may have happened
    this.divDialog.style.visibility = 'visible';
}

GridDialogCustomFilter.prototype.hide = function()
{
    this.divDialog.style.visibility = 'hidden';
}

// GridDialogCustomFilter object constructor
function GridDialogCustomFilter(addFilterMethod, divDialogId, btnAddLevelId, btnDeleteLevelId
                                  , radgrpBoolTypeId, divFilterTableId, btnFilterId, btnCloseId, imgCloseId)
{
    this.divDialog = elm(divDialogId);
    this.btnAddLevel = elm(btnAddLevelId);
    this.btnDeleteLevel = elm(btnDeleteLevelId);
    this.radgrpBoolType = elm(radgrpBoolTypeId);
    this.divFilterTable = elm(divFilterTableId);
    this.btnFilter = elm(btnFilterId);
    this.btnClose = elm(btnCloseId);
    this.imgClose = elm(imgCloseId);
    
    this.addFilterMethod = addFilterMethod;
    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.btnAddLevel.addEventListener('click', function(event) {currObj.addLevelClickClick(event); }, false);
            currObj.btnDeleteLevel.addEventListener('click', function(event) {currObj.deleteLevelClick(event); }, false);
            currObj.btnFilter.addEventListener('click', function(event) {currObj.filterClick(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.btnAddLevel.attachEvent('onclick', function(event) {currObj.addLevelClickClick(event); }, false);
            currObj.btnDeleteLevel.attachEvent('onclick', function(event) {currObj.deleteLevelClick(event); }, false);
            currObj.btnFilter.attachEvent('onclick', function(event) {currObj.filterClick(event); }, false);
            currObj.btnClose.attachEvent('onclick', function(event) {currObj.closeClick(event); }, false);
            currObj.imgClose.attachEvent('onclick', function(event) {currObj.closeClick(event); }, false);
        }
    };
    assignEventHandlers(this);
    //this.show(); //for debugging/designing the dialog
}

//// End of GridDialogCustomFilter Class -------------------------------------------
