BlockNotice = Class.create(); BlockNotice.prototype = { // -------------------------------- initialize: function(type) { this.type = type; this.isHideToolTip = false; }, // -------------------------------- getHashedCookie: function(id) { var hashedCookieKey = 'm2e_bn_' + md5(id).substr(0, 10); var notHashedCookie = getCookie(id); var resultCookie = null; if (notHashedCookie !== "") { deleteCookie(id, '/', ''); this.setHashedCookie(id); resultCookie = notHashedCookie; } else { resultCookie = getCookie(hashedCookieKey); } return resultCookie; }, setHashedCookie: function(id) { var hashedCookieKey = 'm2e_bn_' + md5(id).substr(0, 10); setCookie(hashedCookieKey, 1, 3*365, '/'); }, deleteHashedCookie: function(id) { var hashedCookieKey = 'm2e_bn_' + md5(id).substr(0, 10); deleteCookie(hashedCookieKey, '/', ''); deleteCookie(id, '/', ''); }, // -------------------------------- show: function(id) { id = id || ''; if (id == '') { return false; } $(id).show(); return true; }, hide: function(id) { id = id || ''; if (id == '') { return false; } $(id).hide(); return true; }, // -------------------------------- showContent: function(id) { var self = this; id = id || ''; if (id == '') { return false; } $$('#'+id+' div.block_notices_content').each(function(object) { Effect.SlideDown(object,{duration:0.7}); }); $$('#'+id+' div.block_notices_header div.block_notices_header_left span.arrow').each(function(object) { object.innerHTML = '↑'; }); $$('#'+id+' div.block_notices_header div.block_notices_header_left a').each(function(object) { object.writeAttribute("onclick",self.type+'NoticeObj.hideContent(\'' + id + '\')'); }); if (!IS_VIEW_EBAY || IS_VIEW_CONFIGURATION) { this.deleteHashedCookie(id+'_closed_content'); } return true; }, hideContent: function(id) { var self = this; id = id || ''; if (id == '') { return false; } $$('#'+id+' div.block_notices_content').each(function(object) { Effect.SlideUp(object,{duration:0.7}); }); $$('#'+id+' div.block_notices_header div.block_notices_header_left span.arrow').each(function(object) { object.innerHTML = '↓'; }); $$('#'+id+' div.block_notices_header div.block_notices_header_left a').each(function(object) { object.writeAttribute("onclick",self.type+'NoticeObj.showContent(\'' + id + '\')'); }); this.setHashedCookie( id+'_closed_content'); return true; }, // -------------------------------- showBlock: function(id) { id = id || ''; if (id == '') { return false; } $(id).show(); this.deleteHashedCookie(id+'_hide_block'); return true; }, hideBlock: function(id) { if (!confirm(M2ePro.translator.translate('Are you sure?'))) { return false; } id = id || ''; if (id == '') { return false; } $(id).remove(); this.setHashedCookie(id+'_hide_block'); return true; }, // -------------------------------- remove: function(id) { id = id || ''; if (id == '') { return false; } $(id).remove(); return true; }, clear: function(id) { id = id || ''; if (id == '') { return false; } $(id).innerHTML = ''; return true; }, // -------------------------------- getPreparedId: function(object) { var id = object.readAttribute('id'); if (typeof id != 'string') { id = 'block_notice_md5_' + md5(object.innerHTML.replace(/[^A-Za-z]/g,'')); object.writeAttribute('id',id); } return id; }, getPreparedTitle: function(object) { var title = object.readAttribute('title'); if (typeof title != 'string') { title = ''; } object.writeAttribute('title',''); return title; }, getPreparedSubTitle: function(object) { var subtitle = object.readAttribute('subtitle'); if (typeof subtitle != 'string') { subtitle = '['+M2ePro.translator.translate('Help')+']'; } object.writeAttribute('subtitle',''); return subtitle; }, getPreparedContent: function(object) { var content = object.readAttribute('content'); if (typeof content != 'string') { content = ''; } object.writeAttribute('content',''); return content; }, getPreparedCollapseable: function(object) { var collapseable = object.readAttribute('collapseable'); object.writeAttribute('collapseable',''); if (typeof collapseable != 'string') { return true; } return collapseable != 'no'; }, getPreparedHideBlock: function(object) { var hideblock = object.readAttribute('hideblock'); object.writeAttribute('hideblock',''); if (typeof hideblock != 'string') { return true; } return hideblock != 'no'; }, getPreparedAlwaysShow: function(object) { var alwaysShow = object.readAttribute('always_show'); object.writeAttribute('always_show',''); if (typeof alwaysShow != 'string') { return false; } return alwaysShow != 'no'; }, // -------------------------------- getHeaderHtml: function(id,title,subtitle,collapseable,hideblock) { var isClosedContent = this.getHashedCookie(id+'_closed_content'); if (BLOCK_NOTICES_DISABLE_COLLAPSE) { isClosedContent = 0; } var titleHtml = ''; if (title != '') { titleHtml = ''+title+''; } var subtitleHtml = ''; if (subtitle != '') { subtitleHtml = ''+subtitle+''; } var arrowHtml = ''; if (collapseable) { if (isClosedContent == '1') { arrowHtml = ''; } else { arrowHtml = ''; } } var hideBlockHtml = ''; if (hideblock) { var tempOnClick = this.type+'NoticeObj.hideBlock(\'' + id + '\')'; hideBlockHtml = '×'; } if (titleHtml == '' && subtitleHtml == '' && arrowHtml == '' && hideBlockHtml == '') { return ''; } var leftHtml = titleHtml + '  ' + subtitleHtml + '  ' + arrowHtml; if (collapseable) { var tempOnClick = this.type+'NoticeObj.hideContent(\'' + id + '\')'; if (isClosedContent == '1') { tempOnClick = this.type+'NoticeObj.showContent(\'' + id + '\')'; } leftHtml = '' + leftHtml + ''; } var rightHtml = hideBlockHtml; return '
' + '
' + leftHtml + '
' + '
' + rightHtml + '
' + '
' + '
'; }, getContentHtml: function(id,content,collapseable) { var isClosedContent = this.getHashedCookie(id+'_closed_content'); if (BLOCK_NOTICES_DISABLE_COLLAPSE) { isClosedContent = 0; } var contentHtml = ''; if (collapseable && isClosedContent == '1') { contentHtml = '