PageRenderTime 25ms CodeModel.GetById 10ms app.highlight 9ms RepoModel.GetById 2ms app.codeStats 0ms

/modules/mod_admin/actions/action_admin_zmedia_choose.erl

http://github.com/zotonic/zotonic
Erlang | 48 lines | 17 code | 11 blank | 20 comment | 0 complexity | 3480ba188a6f65139c09218ffee48acd MD5 | raw file
 1%% @author Arjan Scherpenisse <arjan@scherpenisse.net>
 2%% @copyright 2009 Arjan Scherpenisse
 3%% @doc A media item has been chosen for insertion in the body text.
 4
 5%% Copyright 2009 Arjan Scherpenisse
 6%%
 7%% Licensed under the Apache License, Version 2.0 (the "License");
 8%% you may not use this file except in compliance with the License.
 9%% You may obtain a copy of the License at
10%% 
11%%     http://www.apache.org/licenses/LICENSE-2.0
12%% 
13%% Unless required by applicable law or agreed to in writing, software
14%% distributed under the License is distributed on an "AS IS" BASIS,
15%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16%% See the License for the specific language governing permissions and
17%% limitations under the License.
18
19-module(action_admin_zmedia_choose).
20-author("Arjan Scherpenisse <arjan@scherpenisse.net>").
21-include("zotonic.hrl").
22
23%% interface functions
24-export([
25    render_action/4,
26    event/2
27]).
28
29render_action(TriggerId, TargetId, Args, Context) ->
30    Postback = {zmedia_choose, Args},
31	{PostbackMsgJS, _PickledPostback} = z_render:make_postback(Postback, click, TriggerId, TargetId, ?MODULE, Context),
32	{PostbackMsgJS, Context}.
33
34
35%% @spec event(Event, Context1) -> Context2
36event(#postback{message={zmedia_choose, []}}, Context) ->
37    ?DEBUG(z_context:get("media_id", Context)),
38    Args = [{id, z_context:get("media_id", Context)}],
39    z_render:wire({zmedia_has_chosen, Args}, Context);
40
41%% @spec event(Event, Context1) -> Context2
42event(#postback{message={zmedia_choose, Args}}, Context) ->
43    z_render:wire({zmedia_has_chosen, Args}, Context).
44
45
46%z_render:wire([{growl, [{text, "Yay."}]}], Context).
47
48