OrderHandler = Class.create(); OrderHandler.prototype = Object.extend(new CommonHandler(), { //---------------------------------- initialize: function(gridIds) { this.gridIds = gridIds ? eval(gridIds) : []; }, initializeGrids: function() { var self = OrderHandlerObj; for (var i = 0; i < self.gridIds.length; i++) { var currentGridId = self.gridIds[i]; var tempGrid = window[currentGridId + 'JsObject']; if (!(tempGrid instanceof varienGrid)) { continue; } if (typeof self[currentGridId] != 'undefined') { // already initialized continue; } self[currentGridId] = tempGrid.rowClickCallback; tempGrid.rowClickCallback = self.gridRowClickCallback; } }, disableGridCallback: function(gridId) { var self = OrderHandlerObj; var tempGrid = window[gridId + 'JsObject']; if (!(tempGrid instanceof varienGrid)) { return; } self[gridId] = tempGrid.rowClickCallback; tempGrid.rowClickCallback = ''; }, restoreGridCallback: function(gridId) { var self = OrderHandlerObj; var tempGrid = window[gridId + 'JsObject']; if (!(tempGrid instanceof varienGrid)) { return; } tempGrid.rowClickCallback = self[gridId]; }, gridRowClickCallback: function(grid, event) { if(['a', 'select', 'option'].indexOf(Event.element(event).tagName.toLowerCase())!=-1) { return; } var self = OrderHandlerObj; var trElement = Event.findElement(event, 'tr'); var tdElement = Event.findElement(event, 'td'); if ($(tdElement).down('input')) { self[grid.containerId](grid, event); } else { setLocation(trElement.title); } }, //---------------------------------- viewOrderHelp: function(rowId, data) { var row = $('grid_help_icon_open_' + rowId).up('tr'); var grid = row.up('table'); var gridId = grid.id.replace('_table', ''); OrderHandlerObj.disableGridCallback(gridId); $('grid_help_icon_open_'+rowId).hide(); $('grid_help_icon_close_'+rowId).show(); if ($('grid_help_content_'+rowId) !== null) { $('grid_help_content_'+rowId).show(); // Restore grid callback // ------------------------------ setTimeout(function() { OrderHandlerObj.restoreGridCallback(gridId); },150); // ------------------------------ return; } var html = OrderHandlerObj.createHelpTitleHtml(rowId); data = eval(base64_decode(data)); for (var i=0;i'+html+'' }); setTimeout(function() { OrderHandlerObj.restoreGridCallback(gridId); },150); }, hideOrderHelp: function(rowId) { var row = $('grid_help_icon_open_' + rowId).up('tr'); var grid = row.up('table'); var gridId = grid.id.replace('_table', ''); OrderHandlerObj.disableGridCallback(gridId); if ($('grid_help_content_'+rowId) != null) { $('grid_help_content_'+rowId).hide(); } $('grid_help_icon_open_'+rowId).show(); $('grid_help_icon_close_'+rowId).hide(); setTimeout(function() { OrderHandlerObj.restoreGridCallback(gridId); },150); }, createHelpTitleHtml: function(rowId) { var nativeOrderNumber = $('grid_help_icon_open_' + rowId).up('td').next().innerHTML; var orderTitle = nativeOrderNumber.replace(/<[^>]+>/g, ''); var closeHtml = '×'; return '
'+orderTitle+''+closeHtml+'
'; }, createHelpActionHtml: function(action) { var classContainer = 'hl_container'; if (action.type == M2ePro.php.constant('Ess_M2ePro_Model_Order_Log::TYPE_SUCCESS')) { classContainer += ' hl_container_success'; } else if (action.type == M2ePro.php.constant('Ess_M2ePro_Model_Order_Log::TYPE_WARNING')) { classContainer += ' hl_container_warning'; } else if (action.type == M2ePro.php.constant('Ess_M2ePro_Model_Order_Log::TYPE_NOTICE')) { classContainer += ' hl_container_notice'; } else if (action.type == M2ePro.php.constant('Ess_M2ePro_Model_Order_Log::TYPE_ERROR')) { classContainer += ' hl_container_error'; } var type = ''+ M2ePro.translator.translate('Success')+''; if (action.type == M2ePro.php.constant('Ess_M2ePro_Model_Order_Log::TYPE_NOTICE')) { type = ''+ M2ePro.translator.translate('Notice')+''; } else if (action.type == M2ePro.php.constant('Ess_M2ePro_Model_Order_Log::TYPE_WARNING')) { type = ''+ M2ePro.translator.translate('Warning')+''; } else if (action.type == M2ePro.php.constant('Ess_M2ePro_Model_Order_Log::TYPE_ERROR')) { type = ''+ M2ePro.translator.translate('Error')+''; } var html = '
'; html += '
'+action.date+'
'; if (action.initiator != '') { html += '
' + ''+action.initiator+'  ' + '
'; } html += '
'; html += '
'; html += '
'+type+'
'+action.text+'
'; html += '
'; html += '
'; return html; }, createHelpViewAllLogHtml: function(rowId, gridId) { var url = ''; if (gridId.match(/ebay/i)) { url = M2ePro.url.get('adminhtml_ebay_order/view'); } else if (gridId.match(/amazon/i)) { url = M2ePro.url.get('adminhtml_common_amazon_order/view'); } else if (gridId.match(/buy/i)) { url = M2ePro.url.get('adminhtml_common_buy_order/view'); } else if (gridId.match(/play/i)) { url = M2ePro.url.get('adminhtml_common_play_order/view'); } else { return ''; } url = url + 'id/' + rowId + '/'; return ''; } //---------------------------------- });