From 35d0a287388ae02a04f2432e746c757d9ce12d04 Mon Sep 17 00:00:00 2001 From: wangjeaf Date: Fri, 9 May 2014 15:54:58 +0800 Subject: [PATCH 1/4] fix jquery file location bug --- WebContent/stat/js/util/mock.plugin.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/WebContent/stat/js/util/mock.plugin.js b/WebContent/stat/js/util/mock.plugin.js index bca6a82..fb1f0ec 100644 --- a/WebContent/stat/js/util/mock.plugin.js +++ b/WebContent/stat/js/util/mock.plugin.js @@ -223,9 +223,16 @@ } if (window.define && window.define.cmd) { - var data = seajs.data; + var data = seajs.config().data; data.alias = data.alias || {}; - var path = window.location.protocol + '//' + window.location.host + '/stat/js/util/jquery-rapped.js'; + var path; + var protocol = window.location.protocol; + if (protocol.indexOf('http') == 0) { + path = protocol + '//' + window.location.host + '/stat/js/util/jquery-rapped.js'; + } else { + path = 'http://' + ROOT + '/stat/js/util/jquery-rapped.js'; + } + data.alias.jquery = data.alias.jQuery = data.alias.jq = data.alias.jQ = data.alias.$ = path; } From b11912751abb7e08c4c2765b1c023fec7c85889b Mon Sep 17 00:00:00 2001 From: wangjeaf Date: Fri, 9 May 2014 16:23:28 +0800 Subject: [PATCH 2/4] just load it --- WebContent/stat/js/util/mock.plugin.js | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/WebContent/stat/js/util/mock.plugin.js b/WebContent/stat/js/util/mock.plugin.js index fb1f0ec..bd5c28d 100644 --- a/WebContent/stat/js/util/mock.plugin.js +++ b/WebContent/stat/js/util/mock.plugin.js @@ -225,14 +225,7 @@ if (window.define && window.define.cmd) { var data = seajs.config().data; data.alias = data.alias || {}; - var path; - var protocol = window.location.protocol; - if (protocol.indexOf('http') == 0) { - path = protocol + '//' + window.location.host + '/stat/js/util/jquery-rapped.js'; - } else { - path = 'http://' + ROOT + '/stat/js/util/jquery-rapped.js'; - } - + var path = 'http://' + ROOT + '/stat/js/util/jquery-rapped.js'; data.alias.jquery = data.alias.jQuery = data.alias.jq = data.alias.jQ = data.alias.$ = path; } From 6accb00041295af133988bbad8a7bfbb9273d3fb Mon Sep 17 00:00:00 2001 From: wangjeaf Date: Fri, 9 May 2014 17:37:53 +0800 Subject: [PATCH 3/4] better notification operation --- WebContent/stat/css/rap.template.css | 15 ++++-- WebContent/stat/js/base.js | 77 ++++++++++++++++++++++++---- 2 files changed, 79 insertions(+), 13 deletions(-) diff --git a/WebContent/stat/css/rap.template.css b/WebContent/stat/css/rap.template.css index fc9dc69..92aa5ae 100644 --- a/WebContent/stat/css/rap.template.css +++ b/WebContent/stat/css/rap.template.css @@ -377,12 +377,15 @@ div#tipDiv { } .messages-container .msgs { + max-height: 360px; + overflow-y: auto; } .messages-container .close { - margin-right: 2px; + position: absolute; + right: 5px; + top: 6px; outline: none; - margin-top: -2px; } .messages-dropdown { @@ -395,9 +398,11 @@ div#tipDiv { } .messages-container ul li { - padding: 10px; + padding: 10px 20px 10px; cursor: pointer; border-bottom: 1px solid #EEE; + font-size: 12px; + position: relative; } .messages-container ul li:last-child { @@ -428,4 +433,8 @@ border-radius: 0 0 4px 4px; } .messages-container .btns .close-btn, .messages-container .btns .clear-btn { margin-left: 10px; +} + +.label { + padding: .2em .3em .2em; } \ No newline at end of file diff --git a/WebContent/stat/js/base.js b/WebContent/stat/js/base.js index cdf4a05..24bfae5 100644 --- a/WebContent/stat/js/base.js +++ b/WebContent/stat/js/base.js @@ -925,16 +925,58 @@ $(function() { \ '; var tmpl = '
    \ - {{#items}}
  • {{{desc}}}
  • {{/items}}\ -
' - con.find('.msgs').html($.render(tmpl, { - items: [ - {desc: 'fdafdasfdafda', id: 1}, - {desc: 'fdafdasfdafda', id: 2}, - {desc: 'fdafdasfdafda', id: 3}, - {desc: 'fdafdasfdafda', id: 4} + {{#changelogs}}
  • {{{desc}}}
  • {{/changelogs}}\ + '; + var label = $('.messages-trigger .label'); + var data = { + changelogs: [ + {id: 1, type: 'project', operate: 'modify', id: '123', field: '名称', from: '项目A', to: '项目B', operatorId: 21, operator: '思竹', date: '2014-3-21', detail: 11}, + {id: 1, type: 'project', operate: 'delete', id: '123', field: '', from: '测试项目', to: '', operatorId: 21, operator: '思竹', date: '2014-3-21', detail: 11}, + {id: 2, type: 'action', operate: 'modify', id: '1223', field: '名称', from: '请求A', to: '请求A+', operatorId: 21, operator: '思竹', date: '2014-3-21', detail: 22}, + {id: 3, type: 'action', operate: 'delete', id: '1223', field: '', from: '请求A', to: '', operatorId: 21, operator: '思竹', date: '2014-3-21', detail: 33}, + {id: 4, type: 'project', operate: 'create', id: '1234', field: '', from: '', to: '项目BBB', operatorId: 21, operator: '思竹', date: '2014-3-21', detail: 44}, + {id: 4, type: 'action', operate: 'create', id: '1234', field: '', from: '', to: '请求CCC', operatorId: 21, operator: '思竹', date: '2014-3-21', detail: 44}, ] - })) + } + + function href(text, link) { + return '' + text + ''; + } + function create() { + return ' '; + } + function del() { + return ' '; + } + function update() { + return ' '; + } + + function wrap(name) { + return '"' + name + '"'; + } + + data.changelogs.forEach(function(log) { + var type = log.type, operate = log.operate; + if (type == 'project') { + if (operate == 'create') { + log.desc = create() + href(log.operator, log.operatorId) + ' 竟然不经过我的同意就擅自在RAP系统里创建了一个自己都不知道名字的项目 ' + wrap(log.to) + ''; + } else if (operate == 'delete') { + log.desc = del() + href(log.operator, log.operatorId) + ' 删除了项目 ' + wrap(log.from) + ''; + } else if (operate == 'modify') { + log.desc = update() + href(log.operator, log.operatorId) + ' 将项目 ' + wrap(log.from) + ' 的名称修改为 ' + wrap(log.to) + ''; + } + } else if (type == 'action') { + if (operate == 'create') { + log.desc = create() + href(log.operator, log.operatorId) + ' 创建了接口 ' + wrap(log.to) + ''; + } else if (operate == 'delete') { + log.desc = del() + href(log.operator, log.operatorId) + ' 删除了接口 ' + wrap(log.from) + ''; + } else if (operate == 'modify') { + log.desc = update() + href(log.operator, log.operatorId) + ' 将接口 ' + wrap(log.from) + ' 的名称修改为 ' + wrap(log.to) + ''; + } + } + }); + con.find('.msgs').html($.render(tmpl, data)) con.find('.btns').html(btns); con.find('.close-btn').click(function() { $(this).parents('li').toggleClass('open'); @@ -942,6 +984,20 @@ $(function() { con.find('.set-btn').click(function() { window.location.href = '/account/mySetting.action'; }) + + function reset() { + con.find('.msgs').html('
    没有消息提醒
    '); + con.parents('li').toggleClass('open'); + label.hide(); + } + con.delegate('button.close', 'click', function(e) { + $(this).parent().remove(); + label.text(label.text() - 1); + if (label.text() == '0') { + reset(); + } + }); + con.find('.clear-btn').click(function() { $.confirm({ content: '确定要清空所有的提醒消息么?', @@ -952,6 +1008,7 @@ $(function() { confirmClicked: function() { var modal = $(this); modal.modal('hide'); + reset(); } }) }) @@ -960,5 +1017,5 @@ $(function() { $(this).parents('li').toggleClass('open'); }) - $('.messages-trigger .label').show(); + label.text(data.changelogs.length).show(); }) \ No newline at end of file From f229a12a1f1121cbbef15facd2ee4400b97684a2 Mon Sep 17 00:00:00 2001 From: wangjeaf Date: Fri, 9 May 2014 17:46:57 +0800 Subject: [PATCH 4/4] less code --- WebContent/stat/js/base.js | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/WebContent/stat/js/base.js b/WebContent/stat/js/base.js index 24bfae5..fb5cdc2 100644 --- a/WebContent/stat/js/base.js +++ b/WebContent/stat/js/base.js @@ -956,24 +956,19 @@ $(function() { return '"' + name + '"'; } + var chMapper = { + project: '项目', + action: '接口' + } data.changelogs.forEach(function(log) { var type = log.type, operate = log.operate; - if (type == 'project') { - if (operate == 'create') { - log.desc = create() + href(log.operator, log.operatorId) + ' 竟然不经过我的同意就擅自在RAP系统里创建了一个自己都不知道名字的项目 ' + wrap(log.to) + ''; - } else if (operate == 'delete') { - log.desc = del() + href(log.operator, log.operatorId) + ' 删除了项目 ' + wrap(log.from) + ''; - } else if (operate == 'modify') { - log.desc = update() + href(log.operator, log.operatorId) + ' 将项目 ' + wrap(log.from) + ' 的名称修改为 ' + wrap(log.to) + ''; - } - } else if (type == 'action') { - if (operate == 'create') { - log.desc = create() + href(log.operator, log.operatorId) + ' 创建了接口 ' + wrap(log.to) + ''; - } else if (operate == 'delete') { - log.desc = del() + href(log.operator, log.operatorId) + ' 删除了接口 ' + wrap(log.from) + ''; - } else if (operate == 'modify') { - log.desc = update() + href(log.operator, log.operatorId) + ' 将接口 ' + wrap(log.from) + ' 的名称修改为 ' + wrap(log.to) + ''; - } + var cnName = chMapper[type] || '实体'; + if (operate == 'create') { + log.desc = create() + href(log.operator, log.operatorId) + ' 创建了' + cnName + ' ' + wrap(log.to) + ''; + } else if (operate == 'delete') { + log.desc = del() + href(log.operator, log.operatorId) + ' 删除了' + cnName + ' ' + wrap(log.from) + ''; + } else if (operate == 'modify') { + log.desc = update() + href(log.operator, log.operatorId) + ' 将' + cnName + ' ' + wrap(log.from) + ' 的名称修改为 ' + wrap(log.to) + ''; } }); con.find('.msgs').html($.render(tmpl, data))