~dongpo-deng/sahana-eden/test

« back to all changes in this revision

Viewing changes to static/scripts/gis/mapfish/core/Protocol.js

  • Committer: Deng Dongpo
  • Date: 2010-08-01 09:29:44 UTC
  • Revision ID: dongpo@dhcp-21193.iis.sinica.edu.tw-20100801092944-8t9obt4xtl7otesb
initial

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2007  Camptocamp
 
3
 *
 
4
 * This file is part of MapFish Client
 
5
 *
 
6
 * MapFish Client is free software: you can redistribute it and/or modify
 
7
 * it under the terms of the GNU General Public License as published by
 
8
 * the Free Software Foundation, either version 3 of the License, or
 
9
 * (at your option) any later version.
 
10
 *
 
11
 * MapFish Client is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with MapFish Client.  If not, see <http://www.gnu.org/licenses/>.
 
18
 */
 
19
 
 
20
/**
 
21
 * Namespace: mapfish.Protocol
 
22
 * Contains convenience methods for protocol manipulation.
 
23
 */
 
24
mapfish.Protocol = {
 
25
 
 
26
    /**
 
27
     * APIFunction: decorateProtocol
 
28
     * Decorate a protocol.
 
29
     *
 
30
     * Example of use:
 
31
     * (start code)
 
32
     * var protocol = mapfish.Protocol.decorateProtocol({
 
33
     *     protocol: protocol,
 
34
     *     TriggerEventDecorator: {
 
35
     *         eventListeners: {
 
36
     *             crudfinished: function() {
 
37
     *                 alert("CRUD operation completed");
 
38
     *             }
 
39
     *         }
 
40
     *     },
 
41
     *     MergeFilterDecorator: null
 
42
     * });
 
43
     * (end)
 
44
     *
 
45
     * Parameters:
 
46
     * config - {Object} Config object specifying how protocol must be
 
47
     *     decorated, see the above the example.
 
48
     *
 
49
     * Returns:
 
50
     * {<OpenLayers.Protocol>} The resulting protocol.
 
51
     * */
 
52
    decorateProtocol: function(config) {
 
53
        var protocol = config.protocol;
 
54
        for (var key in config) {
 
55
            if (key != "protocol") {
 
56
                if (!mapfish.Protocol[key]) {
 
57
                    OpenLayers.Console.error(
 
58
                        "mapfish.Protocol." + key + " does not exist");
 
59
                } else {
 
60
                    protocol = new mapfish.Protocol[key](
 
61
                        OpenLayers.Util.extend(
 
62
                            {protocol: protocol}, config[key])
 
63
                    );
 
64
                }
 
65
            }
 
66
       }
 
67
       return protocol;
 
68
    }
 
69
    
 
70
};