123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- function CReportSelectionController()
- {
- this.m_aSelectedObjects = new Array();
- this.m_oObserver = new CObserver(this);
- };
- CReportSelectionController.prototype.select = function(oSelectionObject, evt)
- {
- var iCount = -1;
- for (var i = 0; i < this.getSelections().length; i++)
- {
- if (this.getSelections()[i].m_sType == oSelectionObject.m_sType)
- {
- iCount = i;
- break;
- }
- }
-
- if (evt !== null && evt.ctrlKey === false && evt.shiftKey === false)
- {
- this.clearSelections();
- }
- if (iCount !== -1 && evt !== null)
- {
- this.deselect(this.getSelections()[iCount]);
- }
- else
- {
- var o = oSelectionObject.m_oElement;
- if (o.getAttribute("oldClassName") === null)
- {
- o.setAttribute("oldClassName", o.className);
- }
- o.className += " primarySelection";
-
- this.m_aSelectedObjects[this.getSelections().length] = oSelectionObject;
- this.onSelectionChange();
- }
- };
- CReportSelectionController.prototype.getSelections = function()
- {
- return this.m_aSelectedObjects;
- };
- CReportSelectionController.prototype.clearSelections = function()
- {
- if (this.getSelections().length > 0)
- {
-
- for (var i = 0; i < this.getSelections().length; i++)
- {
- var o = this.getSelections()[i].m_oElement;
- var oldClass = o.getAttribute("oldClassName");
- if (oldClass !== null)
- {
- o.className = oldClass;
- }
- }
-
-
- this.m_aSelectedObjects = new Array();
- this.onSelectionChange();
- }
- };
- CReportSelectionController.prototype.reselect = function()
- {
- for (var i = 0; i < this.getSelections().length; i++)
- {
- var o = this.getSelections()[i].m_oElement;
- if (o !== null)
- {
- o.className += " primarySelection";
- }
- }
- };
- CReportSelectionController.prototype.deselect = function(oSelectionObject)
- {
- if (this.getSelections().length > 0)
- {
- var o = oSelectionObject.m_oElement;
- o.className = o.getAttribute("oldClassName");
- if (this.getSelections().length === 1)
- {
- this.clearSelections();
- }
- else
- {
- var newArray = new Array();
- for (var i = 0; i < this.getSelections().length; i++)
- {
- if (this.getSelections()[i].m_oElement.id != o.id)
- {
- newArray[newArray.length] = this.getSelections()[i];
- }
- }
- this.m_aSelectedObjects = newArray;
- this.onSelectionChange();
- }
- }
- };
- CReportSelectionController.prototype.getObservers = function()
- {
- return this.m_oObserver;
- };
- CReportSelectionController.prototype.attachObserver = function(observer)
- {
- this.m_oObserver.attach(observer);
- };
- CReportSelectionController.prototype.onSelectionChange = function()
- {
- this.getObservers().notify();
- };
- var g_reportSelectionController = new CReportSelectionController();
|