~ubuntu-branches/ubuntu/raring/maas/raring-updates

« back to all changes in this revision

Viewing changes to src/maasserver/static/jslibs/yui/3.4.1/build/recordset-filter/recordset-filter.js

  • Committer: Package Import Robot
  • Author(s): Andres Rodriguez
  • Date: 2012-07-03 17:42:37 UTC
  • mfrom: (1.1.13)
  • Revision ID: package-import@ubuntu.com-20120703174237-p8l0keuuznfg721k
Tags: 0.1+bzr709+dfsg-0ubuntu1
* New Upstream release
* debian/control:
  - Depends on python-celery, python-tempita, libjs-yui3-{full,min},
    libjs-raphael
* debian/maas.install:
  - Install apiclient, celeryconfig.py, maas-import-pxe-files, preseeds_v2.
  - Update to install various files from chroot, rather tha manually copy
    them from the source.
* debian/maas.links: symlink celeryconfig.py
* debian/maas.maas-celery.upstart: Add job.
* debian/rules:
  - Install celery upstart job.
  - Do not install jslibs as packages are now used.
  - Drop copying of maas_local_settings_sample.py as source now ships
    a maas_local_settings.py
* debian/patches:
  - 04-maas-http-fix.patch: Drop. Merged upstream.
  - 01-fix-database-settings.patch: Refreshed.
  - 99_enums_js.patch: Added until creation of enum.js / build process
    is fixed.
* debian/maas.postinst: Update bzr version to correctly handle upgrades.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
YUI 3.4.1 (build 4118)
3
 
Copyright 2011 Yahoo! Inc. All rights reserved.
4
 
Licensed under the BSD License.
5
 
http://yuilibrary.com/license/
6
 
*/
7
 
YUI.add('recordset-filter', function(Y) {
8
 
 
9
 
/**
10
 
 * Plugin that provides the ability to filter through a recordset.
11
 
 * Uses the filter methods available on Y.Array (see arrayextras submodule) to filter the recordset.
12
 
 * @module recordset
13
 
 * @submodule recordset-filter
14
 
 */
15
 
 
16
 
 
17
 
var YArray = Y.Array,
18
 
Lang = Y.Lang;
19
 
 
20
 
 
21
 
/**
22
 
 * Plugin that provides the ability to filter through a recordset.
23
 
 * Uses the filter methods available on Y.Array (see arrayextras submodule) to filter the recordset. 
24
 
 * @class RecordsetFilter
25
 
 */
26
 
function RecordsetFilter(config) {
27
 
    RecordsetFilter.superclass.constructor.apply(this, arguments);
28
 
}
29
 
 
30
 
Y.mix(RecordsetFilter, {
31
 
    NS: "filter",
32
 
 
33
 
    NAME: "recordsetFilter",
34
 
 
35
 
    ATTRS: {
36
 
    }
37
 
 
38
 
});
39
 
 
40
 
 
41
 
Y.extend(RecordsetFilter, Y.Plugin.Base, {
42
 
 
43
 
 
44
 
    /**
45
 
    Filter through the recordset with a custom filter function, or a key-value
46
 
    pair.
47
 
    
48
 
    @method filter
49
 
    @param {Function|String} filter A custom filter function or a string
50
 
        representing the key to filter by.
51
 
    @param {Any} [value] If filtering by key (_filter_ is a string), further
52
 
        filter by a specific value.
53
 
    @return {Recordset} A new filtered Recordset instance
54
 
    **/
55
 
    filter: function (filter, value) {
56
 
        var recs = this.get('host').get('records'),
57
 
            key;
58
 
 
59
 
        //If a key-value pair is passed in, generate a custom function
60
 
        if (value && Lang.isString(filter)) {
61
 
            key = filter;
62
 
            filter = function(item) {
63
 
                return (item.getValue(key) === value);
64
 
            };
65
 
        }
66
 
 
67
 
        //TODO: PARENT CHILD RELATIONSHIP
68
 
        return new Y.Recordset({
69
 
            records: YArray.filter(recs, filter)
70
 
        });
71
 
    },
72
 
 
73
 
    /**
74
 
    The inverse of filter. Executes the supplied function on each item. Returns
75
 
    a new Recordset containing the items that the supplied function returned
76
 
    `false` for.
77
 
 
78
 
    @method reject
79
 
    @param {Function} filter A boolean function, executed on each item.
80
 
    @return {Recordset} A new Recordset instance containing the items on which
81
 
        the supplied function returned false.
82
 
    **/
83
 
    reject: function (filter) {
84
 
        return new Y.Recordset({
85
 
            records: YArray.reject(this.get('host').get('records'), filter)
86
 
        });
87
 
    },
88
 
 
89
 
    /**
90
 
    Iterates over the Recordset, returning a new Recordset of all the elements
91
 
    that match the supplied regular expression
92
 
 
93
 
    @method grep
94
 
    @param {RegExp} pattern The regular expression to test against each record.
95
 
    @return {Recordset} A Recordset instance containing all the items in the
96
 
        collection that produce a match against the supplied regular
97
 
        expression. If no items match, an empty Recordset instance is returned.
98
 
    **/
99
 
    grep: function (pattern) {
100
 
        return new Y.Recordset({
101
 
            records: YArray.grep(this.get('host').get('records'), pattern)
102
 
        });
103
 
    }
104
 
 
105
 
    //TODO: Add more pass-through methods to arrayextras
106
 
});
107
 
 
108
 
Y.namespace("Plugin").RecordsetFilter = RecordsetFilter;
109
 
 
110
 
 
111
 
}, '3.4.1' ,{requires:['recordset-base','array-extras','plugin']});