PageRenderTime 20ms CodeModel.GetById 16ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/mod_logging/actions/action_logging_addlog.erl

https://code.google.com/p/zotonic/
Erlang | 41 lines | 20 code | 6 blank | 15 comment | 0 complexity | eeadb23edb5168e675d756b15a2391f1 MD5 | raw file
 1%% @author Arjan Scherpenisse <arjan@scherpenisse.net>
 2%% @copyright 2010 Arjan Scherpenisse <arjan@scherpenisse.net>
 3
 4%% Copyright 2010 Arjan Scherpenisse <arjan@scherpenisse.net>
 5%%
 6%% Licensed under the Apache License, Version 2.0 (the "License");
 7%% you may not use this file except in compliance with the License.
 8%% You may obtain a copy of the License at
 9%% 
10%%     http://www.apache.org/licenses/LICENSE-2.0
11%% 
12%% Unless required by applicable law or agreed to in writing, software
13%% distributed under the License is distributed on an "AS IS" BASIS,
14%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15%% See the License for the specific language governing permissions and
16%% limitations under the License.
17
18-module(action_logging_addlog).
19-include("zotonic.hrl").
20-export([
21    render_action/4
22]).
23
24render_action(_TriggerId, TargetId, Args, Context) ->
25    SignalProps = proplists:get_value(signal_props, Args),
26    Type = proplists:get_value(type, SignalProps),
27
28    {Tpl, Context1} = z_template:render_to_iolist(proplists:get_value(template, Args, "_admin_log_row.tpl"), Args, Context),
29    Tpl2 = lists:flatten(z_string:line(erlang:iolist_to_binary(Tpl))),
30    {[], z_script:add_script([
31                              "$('", z_utils:js_escape(Tpl2), 
32                              "').hide().insertBefore('#", TargetId, " li:first').fadeIn().css({backgroundColor:'",
33                              log_color(Type), "'}).animate({backgroundColor:'",
34                              log_color(bg), "'}, 8000, 'linear');"], Context1)}.
35
36
37log_color(debug) -> "#ffffff";
38log_color(info) -> "#ffff99";
39log_color(warning) -> "#ffcc99";
40log_color(bg) -> "#f1f1f1";
41log_color(_) -> "#f1f1f1".