Commit 355e8c31 authored by Romain Courteaud's avatar Romain Courteaud

Add simple notification system based on acknowledgement tool.

parent fdf0454f
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>result_list = context.AcknowledgementTool_getUserUnreadAcknowledgementList()\n
if len(result_list):\n
result_list = [result_list[0]]\n
result_list = [\'{"text_content": "%s", "acknowledge_url": "%s"}\' % (x[\'text_content\'], x[\'acknowledge_url\']) for x in result_list]\n
\n
context.REQUEST.RESPONSE.setHeader(\'Content-Type\', \'application/json\')\n
return \'{"result": [%s]}\' % \', \'.join(result_list)\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>AcknowledgementTool_getUserUnreadAcknowledgementJSON</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -53,6 +53,7 @@
<value> <string># This script returns an iterable of the paths to standard JavaScript objects.\n
\n
return (\'jquery/core/jquery.js\',\n
\'vifib_hosting_js/erp5_acknowledgement.js\',\n
\'vifib_hosting_js/vifib_hosting.js\',)\n
</string> </value>
</item>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="DTMLMethod" module="OFS.DTMLMethod"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>erp5_acknowledgement.js</string> </value>
</item>
<item>
<key> <string>_vars</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>globals</string> </key>
<value>
<dictionary/>
</value>
</item>
<item>
<key> <string>raw</string> </key>
<value> <string encoding="cdata"><![CDATA[
/*\n
Copyright (c) 2012 Nexedi SA and Contributors. All Rights Reserved.\n
\n
This program is Free Software; you can redistribute it and/or\n
modify it under the terms of the GNU General Public License\n
as published by the Free Software Foundation; either version 2\n
of the License, or (at your option) any later version.\n
\n
This program is distributed in the hope that it will be useful,\n
but WITHOUT ANY WARRANTY; without even the implied warranty of\n
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n
GNU General Public License for more details.\n
\n
You should have received a copy of the GNU General Public License\n
along with this program; if not, write to the Free Software\n
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.\n
*/\n
"use strict";\n
(function (window, $) {\n
\n
var notificationload,\n
notificationdisplay,\n
notificationsettimeout,\n
notificationhide,\n
notificationdismiss,\n
methods;\n
\n
notificationload = function (context) {\n
$.ajax({\n
url: \'AcknowledgementTool_getUserUnreadAcknowledgementJSON\',\n
dataType: \'json\',\n
context: context,\n
success: function (data) {\n
notificationhide($(this));\n
var result = data.result;\n
if (result.length === 0) {\n
notificationsettimeout($(this));\n
} else {\n
notificationdisplay($(this), data.result[0]);\n
}\n
},\n
error: function () {\n
notificationsettimeout($(this));\n
},\n
});\n
};\n
\n
notificationdisplay = function (context, acknowledgement_json) {\n
context\n
.css({\n
"width": "300px",\n
"min-height": "5em",\n
"z-index": "9999",\n
"position": "fixed",\n
"top": "1em",\n
"left": "1em",\n
"text-align": "center",\n
"color": "#eee",\n
"font-weight": "bold",\n
"font-size": "14px",\n
"text-shadow": "1px 1px 0 #000",\n
"background-color": "#59bae2",\n
"padding": "2px 11px 8px 11px",\n
"border-radius": "15px",\n
})\n
.show()\n
.html(acknowledgement_json.text_content)\n
.append("<br/><br/><button id=\'acknowledgement_button\'>Mark as read</button>")\n
.find("#acknowledgement_button")\n
.attr("data-acknowledgement-url", encodeURIComponent(acknowledgement_json.acknowledge_url))\n
.click(function () {\n
var url = decodeURIComponent($(this).attr("data-acknowledgement-url"));\n
notificationdismiss($(this).parent(), url);\n
return false;\n
\n
})\n
;\n
};\n
\n
notificationhide = function (context) {\n
context.hide();\n
};\n
\n
notificationdismiss = function (context, url) {\n
notificationhide(context);\n
$.ajax({\n
type: \'POST\',\n
url: url,\n
context: context,\n
async: true,\n
complete: function () {\n
notificationload($(this));\n
},\n
});\n
};\n
\n
notificationsettimeout = function (context) {\n
setTimeout(function () {\n
notificationload(context);\n
}, 600000);\n
};\n
\n
methods = {\n
init: function () {\n
notificationload($(this));\n
return $(this);\n
},\n
};\n
\n
$.fn.slaposnotification = function (method) {\n
var result;\n
if (methods.hasOwnProperty(method)) {\n
result = methods[method].apply(\n
this,\n
Array.prototype.slice.call(arguments, 1)\n
);\n
} else {\n
$.error(\'Method \' + method +\n
\' does not exist on jQuery.slaposnotification\');\n
}\n
return result;\n
};\n
}(window, jQuery));\n
\n
$(document).ready(function () {\n
$("#acknowledgement_zone").slaposnotification("init");\n
});\n
\n
]]></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -51,6 +51,7 @@
logout_form_id python:current_web_site.getLayoutProperty(\'layout_logout_form_id\',\'WebSite_logout\');\n
login_form_id python:current_web_site.getLayoutProperty(\'layout_login_form_id\',\'login_form\')">\n
\n
<div id="acknowledgement_zone"></div>\n
<a tal:attributes="href current_web_site_url"><div id="vifib_logo"></div></a>\n
\n
<div id="login_menu">\n
......@@ -86,8 +87,7 @@
</ul>\n
</div>\n
\n
</tal:block>\n
</tal:block>
]]></unicode> </value>
</item>
......
423
\ No newline at end of file
424
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment