text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <title>Example: Search Results</title>
    <link rel="stylesheet" href="http://fonts.googleapis.com/css?family=PT+Sans:400,700,400italic,700italic">
    <link rel="stylesheet" href="../../build/cssgrids/cssgrids-min.css">
    <link rel="stylesheet" href="../assets/css/main.css">
    <link rel="stylesheet" href="../assets/vendor/prettify/prettify-min.css">
    <link rel="shortcut icon" type="image/png" href="../assets/favicon.png">

        Jump to Table of Contents

Example: Search Results

An application using the Flickr API to display images with a paginator control to step through the results.

This is a hefty example that may include some modules you are not familiar
    with, such as
    Y.Model,
    Y.View, and
    Y.JSONP.
    These modules are covered in detail on their respective pages.

    <form>
        <input type="text" name="q" value="kitten">
        <input type="submit" value="Search" class="yui3-button">
    </form>

Setting Up the Interface

First we need to construct the HTML for the table and controls.

<div id="demo" class="yui3-skin-sam hide-pg">
    <form>
        <input type="text" name="q" value="kitten">
        <input type="submit" value="Search" class="yui3-button">
    </form>
    <div class="results"></div>
    <div class="paginator"></div>
    <div class="loading"></div>
</div>

JavaScript

Our Flickr Search application will have four main parts:

A form to submit and request new images

Our paginator with navigation controls and direct page number options

Our pages that display the images

A Y.View that will maintain our application state

Our form is included in the markup, so we will just bind to the submit
    event in our application (more on this later).

Setting Up the YUI Instance

Now we need to create our YUI instance and tell it to load the modules we need.

YUI().use('paginator-core', 'model', 'view', 'transition', 'jsonp', 'querystring-stringify-simple', 'cssbutton', function (Y) {

    // Define our FlickrSearch object to contain our different components
    var FlickrSearch = {};

    // Code goes here...

});

There are a number of modules we use:

paginator-core: Gives us the core part of paginator to mix into a model.

model: Gives us a model structure to use with our paginator views

view: Let's us abstract our view logic into a more focused component

transition: Gives us the ability to fade pages in and out when swapping pages

jsonp: Let's us make a JSONP request to the Flickr API

querystring-stringify-simple: Gives us the ability to convert a simple object to a URL to pass to the Flickr API

cssbutton: Dresses up our search form's submit button

Paginator

The paginator we will create will consist of four control buttons (First, Previous, Next, Last) and a collection of buttons representing each page.

Our paginator will consist of one Y.Model and two Y.Views.

Paginator Model

First we'll set up the model.

FlickrSearch.PaginatorModel = Y.Base.create('pager-model', Y.Model, [Y.Paginator.Core]);

Since paginator-core contains our logic, and is built to be mixed into a
    Base-based component, we do not need to add any new logic. Just mix in
    and our model is complete!

Paginator Pages View

The first view we will create is the view for the page numbers between the
    left and right controls.

FlickrSearch.PaginatorPages = Y.Base.create('pager-pages', Y.View, [], {

    // We modify the the containerTemplate so our page items are contained in
    // their proper parent
    containerTemplate: '<ul/>',

    // Our page numbers are in a list element (<li>) and contain data about
    // the page (`data-page`) and control type (`data-type`)
    pageTemplate: '<li class="control page page-{page}{selected}"' +
                  ' data-type="page" data-page="{page}">{page}</li>',

    // We delegate our .page element clicks
    events: {
        '.page': {
            'click': '_pageClick'
        }
    },

    // We listen to our model's `change` event to know what page controls to
    // display and which page item to activate
    initializer: function () {
        this.get('model').after('change', this._afterChange, this);
    },

    // When we render, we simply call _buildPageList to render the page items
    render: function () {
        this.get('container').setHTML(this._buildPageList());

        return this;
    },

    // Generates a string of page items based on the current page number and
    // the number of items we can display at one time. The current page of the
    // model will be given the "selected" class name.
    //
    // For example, if our current page is 20, we have a total of 50 pages
    // and we can only display 10, our paginator should display pages
    // 15 thru 24
    //
    // Given the same scenario, if we have a total of 20 pages, our paginator
    // should display 11 thru 20
    _buildPageList: function () {
        var data = this.get('model').toJSON(),
            pages = data.totalPages,
            pagesNode = '',
            display = this.get('display'),
            min = Math.max(1, data.page - Math.floor(display / 2)),
            max = min + display - 1;

        if (max > pages) {
            min -= max - pages;
        }

        min = Math.max(1, min);
        max = Math.min(pages, max);

        for (; min <= max; min++) {
            pagesNode += Y.Lang.sub(this.pageTemplate, {
                page: min,
                selected: (data.page === min) ? ' selected' : ''
            });
        }

        return pagesNode;
    },

    // When a page is clicked, we need to push that data to the model
    _pageClick: function (e) {
        var page = e.currentTarget.getData('page');

        this.get('model').set('page', parseInt(page, 10));
    },

    // When the model's `page` or `totalItems` changes, we need to re-render
    // all the page nodes to ensure we are displaying the correct number
    _afterChange: function (e) {
        this.render();
    }

}, {
    ATTRS: {

        // Maximum number of items to display at one time
        display: {
            value: 10
        }
    }
});

Paginator View

Our Paginator View consists of four local controls: first, previous, next
    and last. In the middle of these four controls, we display a truncated
    list of pages (our Pages View previously discussed) from which the user
    can select.

FlickrSearch.Paginator = Y.Base.create('pager', Y.View, [], {

    // Our paginator will consist of controls as list elements so we need to
    // ensure our container is the proper parent element type
    containerTemplate: '<ul/>',

    // Our controls are list items we bind click events to. Based on the given
    // control type - stored in `data-type` - we will be able to determine the
    // course of action we need to take
    controlTemplate: '<li class="control {type}" data-type="{type}">' +
                        '{label}' +
                     '</li>',

    // We delegate click events for our controls
    events: {
        '.control': {
            'click': '_controlClick'
        }
    },

    // Our paginator will consist of a few controls as well as a list of pages
    // To get the list of pages, we need to instantiate a `PaginatorPages`
    // view. We also pass our model to the pages view to keep our controls and
    // page items in sync with each other
    initializer: function () {
        var model = this.get('model'),
            pages = this.pages = new FlickrSearch.PaginatorPages({
                model: model
            });

        model.after('change', this._afterModelChange, this);
    },

    // We can generate our controls as strings, but our pages controls are
    // generated through another module, so we need to append the pages
    // container node between our two sets of controls.
    render: function () {
        var container = this.get('container'),
            firstControls,
            lastControls;

        // build first and prev controls
        firstControls = this._makeControl('first');
        firstControls += this._makeControl('prev', 'Previous');

        // build next and last controls
        lastControls = this._makeControl('next');
        lastControls += this._makeControl('last');

        // add the controls and page items to the container
        container.append(firstControls);
        container.append(this.pages.render().get('container'));
        container.append(lastControls);

        return this;
    },

    // We use this method to simplify the building of our controls. This will
    // give us a Title Cased label from the `type` if we do not provide one
    _makeControl: function (type, label, control) {
        return Y.Lang.sub(this.controlTemplate, {
            type: type,
            label: label || (type.charAt(0).toUpperCase() + type.substr(1))
        });
    },

    // After our model is changed, we only need to update our controls
    _afterModelChange: function (e) {
        this._updateControls();
    },

    // We can know whether our controls should be disabled or not by checking
    // if there is a previous page (for first and previous controls) and a
    // next page (for the next and last controls)
    _updateControls: function () {
        var model = this.get('model'),
            hasPrev = model.hasPrevPage(),
            hasNext = model.hasNextPage(),
            disabled = 'disabled',
            container = this.get('container');

        container.one('.first').toggleClass(disabled, !hasPrev);
        container.one('.prev').toggleClass(disabled, !hasPrev);
        container.one('.next').toggleClass(disabled, !hasNext);
        container.one('.last').toggleClass(disabled, !hasNext);
    },

    // When one of our controls is clicked, we want to update the model as
    // expected, unless the control has been disabled.
    _controlClick: function (e) {
        e.preventDefault();

        var control = e.currentTarget.getData('type'),
            model = this.get('model');

        if (e.currentTarget.hasClass('disabled')) {
            return;
        }

        switch (control) {
            case 'first':
                model.set('page', 1);
                break;
            case 'prev':
                model.prevPage();
                break;
            case 'next':
                model.nextPage();
                break;
            case 'last':
                model.set('page', model.get('totalPages'));
                break;
            default:
                return;
        }
    },

    // ATTRS passthrough to our internal model for external gets and sets
    _setPageFn: function (val) {
        this.get('model').set('page', parseInt(val, 10));
        return val;
    },

    _getPageFn: function () {
        return this.get('model').get('page');
    },

    _setTotalItemsFn: function (val) {
        this.get('model').set('totalItems', parseInt(val, 10));
        return val;
    },

    _getTotalItemsFn: function () {
        return this.get('model').get('totalItems');
    }

}, {
    ATTRS: {
        // Relays changes to our model's page and retrives our model's page
        // when requested
        page: {
            setter: '_setPageFn',
            getter: '_getPageFn'
        },

        // Relays changes to our model's totalItems and retrieves our model's
        // totalItems when requested
        totalItems: {
            setter: '_setTotalItemsFn',
            getter: '_getTotalItemsFn'
        }
    }
});

That's all it takes for our Paginator. As such it's fairly flexible and
    extremely customizable if we need it to be.

Next we need to look at our actual pages that hold the images.

Page View

Our page view need only display the images we pass to it. We do this by
    sustituying placeholders with the data from the Flickr API.

FlickrSearch.PageView = Y.Base.create('page-view', Y.View, [], {

    // We will be displaying the images in list elements, so we need to
    // ensure the parent element is semantically correct
    containerTemplate: '<ul></ul>',

    // Our image template is dictated from the Flickr API. Here we set up
    // placeholders that will be substitued by the photo's API data in
    // order to display the correct photo
    imageTemplate: '<img src="http://farm{farm}.staticflickr.com/{server}/{id}_{secret}_q.jpg">',

    // In order to add photos to the container, they are expected to be in
    // the format from the API, this would mean an Array of photos.
    //
    // We loop through each of these photo data objects and generate an
    // image element. Then we append all the image elements to our
    // container
    addPhotos: function (photos) {
        var container = this.get('container'),
            photoItems = '',
            i,
            len;

        for (i = 0, len = photos.length; i < len; i++) {
            photoItems += Y.Lang.sub('<li>' + this.imageTemplate + '</li>', photos[i]);
        }

        this.get('container').append(photoItems)
    }

});

Search App View

Our application view is a bit more envolved. It needs to request images
    when the form is submitted and start a new series of pages. As well as
    fetch new images when a new page is requested.

FlickrSearch.App = Y.Base.create('search', Y.View, [], {

    // This is the Flickr API URL
    url: 'http://api.flickr.com/services/rest/?',

    // This is a flag that will determin if we are performing a new query
    // or simply going to a new page of the previous query
    _isNewQuery: false,

    // An array of pages that are being displayed. This will adjust as
    // the paginator is being interacted with, but should result in only
    // one item being persistent
    _pages: [],

    paginator: null,

    // When our form is submitted, we run a new query on it
    events: {
        'form .yui3-button': {
            'click': '_afterFormSubmit'
        }
    },

    // When we first initialize our application, we set up our paginator
    // We also listen to it's page change event to get that page's images
    initializer: function () {
        this._api = this.get('apiConfig');

        this.paginator = new FlickrSearch.Paginator({
            model:  new FlickrSearch.PaginatorModel({
                itemsPerPage: this._api.per_page
            })
        });

        this.paginator.get('model').after('pageChange', this._afterPageChange, this);
    },

    // We append our paginator to the paginator placeholder in our
    // container
    render: function () {
        this.get('container').one('.paginator').append(
            this.paginator.render().get('container')
        );
    },

    // We update the app based on our loading process
    //
    // If status is true, we add the "loading" class
    // If status is false, we remove the "loading" class
    setLoading: function (status) {
        this.get('container').toggleClass('loading', status);
    },

    // Our app needs a way to display a message to the user where there's
    // an error or remove an error message if there is no longer a
    // message that needs to be displayed
    setMessage: function (msg) {
        var container = this.get('container'),
            msgNode = container.one('.results .msg');

        if (msg) {
            container.one('.results').setHTML('<div class="msg">' + msg + '</div>');
            container.removeClass('hide-pg');
            this.setLoading(false);
        } else {
            if (msgNode) {
                msgNode.remove();
            }
        }
    },

    // When we request a new photo, there are a few things that happen.
    //
    // * First we alert our app that something is loading
    // * Then we construct our url based on the API configuration and the
    //   page requested
    // * Finally we request the API response through JSON-P
    //
    // If that request fails, we let the user know with a message
    // If the requst succeeds, we process the response data
    requestPhotos: function (page) {
        this.setLoading(true);

        var self = this,
            api = this._api,
            url = this.url;

        api.page = page || 1;

        url += Y.QueryString.stringify(api);

        Y.jsonp(url, {
            format: function (url, proxy) {
                return url + '&jsoncallback=' + proxy;
            },
            on: {
                failure: Y.bind(function () {
                    this.setLoading(false);
                    this.setMessage('Oops!! something broke :(');
                }, self),

                success: Y.bind(function (resp) {
                    this._processResults(resp.photos);
                    this._isNewQuery = false;
                }, self)
            }
        });
    },

    // When our form is submitted, we assume it's a new request. As a new
    // request we remove our old pages, ensure our paginator is set to
    // page 1 and request our new set of photos
    _afterFormSubmit: function (e) {
        e.preventDefault();

        while (this._pages.length) {
            this._pages.shift().destroy({ remove: true });
        }

        this._api.text = this.get('container').one('form input').get('value');

        this._isNewQuery = true;

        if (this.paginator.get('page') !== 1) {
            this.paginator.set('page', 1);
        } else {
            this.requestPhotos();
        }
    },

    // After we receive a response from the Flickr API, we check if we
    // have any pages to process and send the
    _processResults: function (resp) {
        this.setMessage( !resp.pages ?
            'There are no images for "' + this._api.text + '"' :
            ''
        );

        if (this._isNewQuery) {
            this.paginator.set('totalItems', parseInt(resp.total, 10));
        }

        this._createNewPage(resp.photo);
    },

    // Once our data have been received by the Flicker API and the
    // results have been processed, we create a new page containing the
    // new photos
    _createNewPage: function (photos) {
        var page = new FlickrSearch.PageView(),
            resultsNode = this.get('container').one('.results'),
            pageContainer;

        // Add our photos to the new page
        page.addPhotos(photos);

        pageContainer = page.get('container');

        // append our new page to the results node
        resultsNode.append(pageContainer);
        resultsNode.setStyle('height', pageContainer.get('offsetHeight'));

        // We do not want to display the new page before all the images
        // requested have had a chance to process.
        var images = pageContainer.all('img'),
            imagesLeft = images.size();

        images.after(['load', 'error', 'abort'], function (e) {

            if (!(--imagesLeft)) {

                // If there is more than one page, we have a previous page
                var prevPage = (this._pages.length > 1) ? this._pages.shift() : null;

                // Turn off the loading indicator
                this.setLoading(false);

                // Transition the new page in
                // If there is not a previous page, just display the new page
                pageContainer.transition({
                    opacity: 1,
                    duration: 1,
                    delay: (prevPage) ? 0.5 : 0
                });

                // Transition the previous page out
                // Once the transition is complete, remove the previous page
                if (prevPage) {
                    prevPage.get('container').transition({
                        opacity: 0,
                        duration: 1
                    }, function (e) {
                        prevPage.destroy({
                            remove: true
                        });
                    });
                }
            }
        }, this);

        // We now have a page to display, so let's show the paginator
        this.get('container').removeClass('hide-pg');
        this._pages.push(page);
    },

    // After our page changes, we request that page's photos
    _afterPageChange: function (e) {
        this.requestPhotos(e.newVal);
    }

}, {
    ATTRS: {
        // This will contain our settings for the Flickr API
        apiConfig: {
            value: {
                api_key: FLICKR_API_KEY,
                method: 'flickr.photos.search',
                safe_search: 1,
                sort: 'relevance',
                format: 'json',
                license: 4,
                per_page: 20
            }
        }
    }
});

Run with it!

Now we need to create an instance and render it

var flickrSearch = new FlickrSearch.App({
    container: '#demo'
});

flickrSearch.render();

Finishing touches

Whew, that was a lot to digest! One last element is our CSS.

<style>
/** DEMO BOX **/
#demo {
    position: relative;
    border: 1px solid #cbcbcb;
    border-radius: 6px;
    padding: 8px;
    background: #fafafa;
}

/** SEARCH FORM **/
#demo form {
    border: 1px solid #cbcbcb;
    border-radius: 3px;
    padding: 8px;
    background: #fefefe;
}
#demo form input {
    font-size: 180%;
    padding: 3px 7px;
}

/** SEARCH RESULTS **/
#demo .results {
    position: relative;
    margin: 8px 0;
}
#demo.hide-pg .results {
    margin: 0;
}
#demo .results ul {
    margin: 0;
    padding: 0;
    text-align: center;
    position: absolute;
    opacity: 0;
}
#demo .results li {
    list-style: none;
    float: left;
    padding: 3px;
    position: relative;
    width: 150px;
    height: 150px;
}
#demo .results li img {
    background: #efefef;
    width: 150px;
    height: 150px;
}
#demo .results li:hover {
    z-index: 10;
}
#demo .results li:hover img {
    position: absolute;
    left: -5px;
    top: -5px;
    width: 160px;
    height: 160px;
    z-index: 10;
    border: 3px solid #fff;
    -webkit-box-shadow: 3px 3px 5px hsla(250, 40%, 30%, 0.5);
    -moz-box-shadow: 3px 3px 5px hsla(250, 40%, 30%, 0.5);
    box-shadow: 3px 3px 5px hsla(250, 40%, 30%, 0.5);
}

/** LOADING INDICATOR **/
#demo.loading .loading {
    display: block;
}
#demo .loading {
    background: url('../assets/paginator/images/loading.gif') left center repeat-x;
    height: 15px;
    width: 150px;
    border: 1px solid #3b4f93;
    border-radius: 4px;
    box-shadow: 3px 3px 3px hsla(40, 40%, 30%, 0.5);
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -75px;
    display: none;
    z-index: 100;
    -webkit-box-shadow: 0 0 0 6px hsla(226, 10%, 40%, 0.4);
    -moz-box-shadow: 0 0 0 6px hsla(226, 10%, 40%, 0.4);
    box-shadow: 0 0 0 6px hsla(226, 10%, 40%, 0.4);
}

/** PAGINATOR CSS **/
#demo.hide-pg .paginator {
    display: none;
}

#demo .paginator {
    margin-top: 8px;
    text-align: center;
    border-top: 1px solid #eee;
    padding-top: 10px;
    margin: 0 10px;
}

#demo .paginator .control {
    display: block;
    padding: 0 .5em;
    text-align: center;
    text-decoration: none;
}
#demo .paginator ul {
    margin: 0;
    padding: 0;
    display: inline-block;
    zoom: 1; *display: inline;
}
#demo .paginator ul li {
    display: inline-block;
    zoom: 1; *display: inline;
    list-style: none;
}
#demo .paginator .control {
    border: solid 1px #CBCBCB;
    display: inline-block;
    zoom: 1; *display: inline;
    margin: 0 3px;
    padding: 0 .5em;
    text-align: center;
    text-decoration: none;
    line-height: 1.7em;
    color: #4A4A4A;
    font-family: arial,san-serif;
    background-color: #E6E6E6;
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    -ie-border-radius: 3px;
    -o-border-radius: 3px;
    border-radius: 3px;
    cursor: pointer;
}
#demo .paginator .control:hover {
    background-color: #d6d6d6;
    color: #3a3a3a;
}
#demo .paginator .control.selected,
#demo .paginator .control.selected:hover {
    cursor: default;
    font-weight: bold;
    font-weight: bold;
    background-color: #2647a0;
    color: #fff;
}
#demo .paginator .control.disabled,
#demo .paginator .control.disabled:hover {
    background-color: #E6E6E6;
    cursor: default;
    opacity: 0.55;
    filter: alpha(opacity=55);
}
#demo .paginator .page:hover {
    background-color: #bfdaff;
    color: #000;
}
</style>

The Whole Example

Now let's see it all together!

<style>
/** DEMO BOX **/
#demo {
    position: relative;
    border: 1px solid #cbcbcb;
    border-radius: 6px;
    padding: 8px;
    background: #fafafa;
}

/** SEARCH FORM **/
#demo form {
    border: 1px solid #cbcbcb;
    border-radius: 3px;
    padding: 8px;
    background: #fefefe;
}
#demo form input {
    font-size: 180%;
    padding: 3px 7px;
}

/** SEARCH RESULTS **/
#demo .results {
    position: relative;
    margin: 8px 0;
}
#demo.hide-pg .results {
    margin: 0;
}
#demo .results ul {
    margin: 0;
    padding: 0;
    text-align: center;
    position: absolute;
    opacity: 0;
}
#demo .results li {
    list-style: none;
    float: left;
    padding: 3px;
    position: relative;
    width: 150px;
    height: 150px;
}
#demo .results li img {
    background: #efefef;
    width: 150px;
    height: 150px;
}
#demo .results li:hover {
    z-index: 10;
}
#demo .results li:hover img {
    position: absolute;
    left: -5px;
    top: -5px;
    width: 160px;
    height: 160px;
    z-index: 10;
    border: 3px solid #fff;
    -webkit-box-shadow: 3px 3px 5px hsla(250, 40%, 30%, 0.5);
    -moz-box-shadow: 3px 3px 5px hsla(250, 40%, 30%, 0.5);
    box-shadow: 3px 3px 5px hsla(250, 40%, 30%, 0.5);
}

/** LOADING INDICATOR **/
#demo.loading .loading {
    display: block;
}
#demo .loading {
    background: url('../assets/paginator/images/loading.gif') left center repeat-x;
    height: 15px;
    width: 150px;
    border: 1px solid #3b4f93;
    border-radius: 4px;
    box-shadow: 3px 3px 3px hsla(40, 40%, 30%, 0.5);
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -75px;
    display: none;
    z-index: 100;
    -webkit-box-shadow: 0 0 0 6px hsla(226, 10%, 40%, 0.4);
    -moz-box-shadow: 0 0 0 6px hsla(226, 10%, 40%, 0.4);
    box-shadow: 0 0 0 6px hsla(226, 10%, 40%, 0.4);
}

/** PAGINATOR CSS **/
#demo.hide-pg .paginator {
    display: none;
}

#demo .paginator {
    margin-top: 8px;
    text-align: center;
    border-top: 1px solid #eee;
    padding-top: 10px;
    margin: 0 10px;
}

#demo .paginator .control {
    display: block;
    padding: 0 .5em;
    text-align: center;
    text-decoration: none;
}
#demo .paginator ul {
    margin: 0;
    padding: 0;
    display: inline-block;
    zoom: 1; *display: inline;
}
#demo .paginator ul li {
    display: inline-block;
    zoom: 1; *display: inline;
    list-style: none;
}
#demo .paginator .control {
    border: solid 1px #CBCBCB;
    display: inline-block;
    zoom: 1; *display: inline;
    margin: 0 3px;
    padding: 0 .5em;
    text-align: center;
    text-decoration: none;
    line-height: 1.7em;
    color: #4A4A4A;
    font-family: arial,san-serif;
    background-color: #E6E6E6;
    -webkit-border-radius: 3px;
    -moz-border-radius: 3px;
    -ie-border-radius: 3px;
    -o-border-radius: 3px;
    border-radius: 3px;
    cursor: pointer;
}
#demo .paginator .control:hover {
    background-color: #d6d6d6;
    color: #3a3a3a;
}
#demo .paginator .control.selected,
#demo .paginator .control.selected:hover {
    cursor: default;
    font-weight: bold;
    font-weight: bold;
    background-color: #2647a0;
    color: #fff;
}
#demo .paginator .control.disabled,
#demo .paginator .control.disabled:hover {
    background-color: #E6E6E6;
    cursor: default;
    opacity: 0.55;
    filter: alpha(opacity=55);
}
#demo .paginator .page:hover {
    background-color: #bfdaff;
    color: #000;
}
</style>

<div id="demo" class="yui3-skin-sam hide-pg">
    <form>
        <input type="text" name="q" value="kitten">
        <input type="submit" value="Search" class="yui3-button">
    </form>
    <div class="results"></div>
    <div class="paginator"></div>
    <div class="loading"></div>
</div>

<script>
YUI().use('paginator-core', 'model', 'view', 'transition', 'jsonp', 'querystring-stringify-simple', 'cssbutton', function (Y) {

    var FlickrSearch = {};

    FlickrSearch.PaginatorModel = Y.Base.create('pager-model', Y.Model, [Y.Paginator.Core]);

    FlickrSearch.PaginatorPages = Y.Base.create('pager-pages', Y.View, [], {

        // We modify the the containerTemplate so our page items are contained in
        // their proper parent
        containerTemplate: '<ul/>',

        // Our page numbers are in a list element (<li>) and contain data about
        // the page (`data-page`) and control type (`data-type`)
        pageTemplate: '<li class="control page page-{page}{selected}"' +
                      ' data-type="page" data-page="{page}">{page}</li>',

        // We delegate our .page element clicks
        events: {
            '.page': {
                'click': '_pageClick'
            }
        },

        // We listen to our model's `change` event to know what page controls to
        // display and which page item to activate
        initializer: function () {
            this.get('model').after('change', this._afterChange, this);
        },

        // When we render, we simply call _buildPageList to render the page items
        render: function () {
            this.get('container').setHTML(this._buildPageList());

            return this;
        },

        // Generates a string of page items based on the current page number and
        // the number of items we can display at one time. The current page of the
        // model will be given the "selected" class name.
        //
        // For example, if our current page is 20, we have a total of 50 pages
        // and we can only display 10, our paginator should display pages
        // 15 thru 24
        //
        // Given the same scenario, if we have a total of 20 pages, our paginator
        // should display 11 thru 20
        _buildPageList: function () {
            var data = this.get('model').toJSON(),
                pages = data.totalPages,
                pagesNode = '',
                display = this.get('display'),
                min = Math.max(1, data.page - Math.floor(display / 2)),
                max = min + display - 1;

            if (max > pages) {
                min -= max - pages;
            }

            min = Math.max(1, min);
            max = Math.min(pages, max);

            for (; min <= max; min++) {
                pagesNode += Y.Lang.sub(this.pageTemplate, {
                    page: min,
                    selected: (data.page === min) ? ' selected' : ''
                });
            }

            return pagesNode;
        },

        // When a page is clicked, we need to push that data to the model
        _pageClick: function (e) {
            var page = e.currentTarget.getData('page');

            this.get('model').set('page', parseInt(page, 10));
        },

        // When the model's `page` or `totalItems` changes, we need to re-render
        // all the page nodes to ensure we are displaying the correct number
        _afterChange: function (e) {
            this.render();
        }

    }, {
        ATTRS: {

            // Maximum number of items to display at one time
            display: {
                value: 10
            }
        }
    });

    FlickrSearch.Paginator = Y.Base.create('pager', Y.View, [], {

        // Our paginator will consist of controls as list elements so we need to
        // ensure our container is the proper parent element type
        containerTemplate: '<ul/>',

        // Our controls are list items we bind click events to. Based on the given
        // control type - stored in `data-type` - we will be able to determine the
        // course of action we need to take
        controlTemplate: '<li class="control {type}" data-type="{type}">' +
                            '{label}' +
                         '</li>',

        // We delegate click events for our controls
        events: {
            '.control': {
                'click': '_controlClick'
            }
        },

        // Our paginator will consist of a few controls as well as a list of pages
        // To get the list of pages, we need to instantiate a `PaginatorPages`
        // view. We also pass our model to the pages view to keep our controls and
        // page items in sync with each other
        initializer: function () {
            var model = this.get('model'),
                pages = this.pages = new FlickrSearch.PaginatorPages({
                    model: model
                });

            model.after('change', this._afterModelChange, this);
        },

        // We can generate our controls as strings, but our pages controls are
        // generated through another module, so we need to append the pages
        // container node between our two sets of controls.
        render: function () {
            var container = this.get('container'),
                firstControls,
                lastControls;

            // build first and prev controls
            firstControls = this._makeControl('first');
            firstControls += this._makeControl('prev', 'Previous');

            // build next and last controls
            lastControls = this._makeControl('next');
            lastControls += this._makeControl('last');

            // add the controls and page items to the container
            container.append(firstControls);
            container.append(this.pages.render().get('container'));
            container.append(lastControls);

            return this;
        },

        // We use this method to simplify the building of our controls. This will
        // give us a Title Cased label from the `type` if we do not provide one
        _makeControl: function (type, label, control) {
            return Y.Lang.sub(this.controlTemplate, {
                type: type,
                label: label || (type.charAt(0).toUpperCase() + type.substr(1))
            });
        },

        // After our model is changed, we only need to update our controls
        _afterModelChange: function (e) {
            this._updateControls();
        },

        // We can know whether our controls should be disabled or not by checking
        // if there is a previous page (for first and previous controls) and a
        // next page (for the next and last controls)
        _updateControls: function () {
            var model = this.get('model'),
                hasPrev = model.hasPrevPage(),
                hasNext = model.hasNextPage(),
                disabled = 'disabled',
                container = this.get('container');

            container.one('.first').toggleClass(disabled, !hasPrev);
            container.one('.prev').toggleClass(disabled, !hasPrev);
            container.one('.next').toggleClass(disabled, !hasNext);
            container.one('.last').toggleClass(disabled, !hasNext);
        },

        // When one of our controls is clicked, we want to update the model as
        // expected, unless the control has been disabled.
        _controlClick: function (e) {
            e.preventDefault();

            var control = e.currentTarget.getData('type'),
                model = this.get('model');

            if (e.currentTarget.hasClass('disabled')) {
                return;
            }

            switch (control) {
                case 'first':
                    model.set('page', 1);
                    break;
                case 'prev':
                    model.prevPage();
                    break;
                case 'next':
                    model.nextPage();
                    break;
                case 'last':
                    model.set('page', model.get('totalPages'));
                    break;
                default:
                    return;
            }
        },

        // ATTRS passthrough to our internal model for external gets and sets
        _setPageFn: function (val) {
            this.get('model').set('page', parseInt(val, 10));
            return val;
        },

        _getPageFn: function () {
            return this.get('model').get('page');
        },

        _setTotalItemsFn: function (val) {
            this.get('model').set('totalItems', parseInt(val, 10));
            return val;
        },

        _getTotalItemsFn: function () {
            return this.get('model').get('totalItems');
        }

    }, {
        ATTRS: {
            // Relays changes to our model's page and retrives our model's page
            // when requested
            page: {
                setter: '_setPageFn',
                getter: '_getPageFn'
            },

            // Relays changes to our model's totalItems and retrieves our model's
            // totalItems when requested
            totalItems: {
                setter: '_setTotalItemsFn',
                getter: '_getTotalItemsFn'
            }
        }
    });

    FlickrSearch.PageView = Y.Base.create('page-view', Y.View, [], {

        // We will be displaying the images in list elements, so we need to
        // ensure the parent element is semantically correct
        containerTemplate: '<ul></ul>',

        // Our image template is dictated from the Flickr API. Here we set up
        // placeholders that will be substitued by the photo's API data in
        // order to display the correct photo
        imageTemplate: '<img src="http://farm{farm}.staticflickr.com/{server}/{id}_{secret}_q.jpg">',

        // In order to add photos to the container, they are expected to be in
        // the format from the API, this would mean an Array of photos.
        //
        // We loop through each of these photo data objects and generate an
        // image element. Then we append all the image elements to our
        // container
        addPhotos: function (photos) {
            var container = this.get('container'),
                photoItems = '',
                i,
                len;

            for (i = 0, len = photos.length; i < len; i++) {
                photoItems += Y.Lang.sub('<li>' + this.imageTemplate + '</li>', photos[i]);
            }

            this.get('container').append(photoItems)
        }

    });

    FlickrSearch.App = Y.Base.create('search', Y.View, [], {

        // This is the Flickr API URL
        url: 'http://api.flickr.com/services/rest/?',

        // This is a flag that will determin if we are performing a new query
        // or simply going to a new page of the previous query
        _isNewQuery: false,

        // An array of pages that are being displayed. This will adjust as
        // the paginator is being interacted with, but should result in only
        // one item being persistent
        _pages: [],

        paginator: null,

        // When our form is submitted, we run a new query on it
        events: {
            'form .yui3-button': {
                'click': '_afterFormSubmit'
            }
        },

        // When we first initialize our application, we set up our paginator
        // We also listen to it's page change event to get that page's images
        initializer: function () {
            this._api = this.get('apiConfig');

            this.paginator = new FlickrSearch.Paginator({
                model:  new FlickrSearch.PaginatorModel({
                    itemsPerPage: this._api.per_page
                })
            });

            this.paginator.get('model').after('pageChange', this._afterPageChange, this);
        },

        // We append our paginator to the paginator placeholder in our
        // container
        render: function () {
            this.get('container').one('.paginator').append(
                this.paginator.render().get('container')
            );
        },

        // We update the app based on our loading process
        //
        // If status is true, we add the "loading" class
        // If status is false, we remove the "loading" class
        setLoading: function (status) {
            this.get('container').toggleClass('loading', status);
        },

        // Our app needs a way to display a message to the user where there's
        // an error or remove an error message if there is no longer a
        // message that needs to be displayed
        setMessage: function (msg) {
            var container = this.get('container'),
                msgNode = container.one('.results .msg');

            if (msg) {
                container.one('.results').setHTML('<div class="msg">' + msg + '</div>');
                container.removeClass('hide-pg');
                this.setLoading(false);
            } else {
                if (msgNode) {
                    msgNode.remove();
                }
            }
        },

        // When we request a new photo, there are a few things that happen.
        //
        // * First we alert our app that something is loading
        // * Then we construct our url based on the API configuration and the
        //   page requested
        // * Finally we request the API response through JSON-P
        //
        // If that request fails, we let the user know with a message
        // If the requst succeeds, we process the response data
        requestPhotos: function (page) {
            this.setLoading(true);

            var self = this,
                api = this._api,
                url = this.url;

            api.page = page || 1;

            url += Y.QueryString.stringify(api);

            Y.jsonp(url, {
                format: function (url, proxy) {
                    return url + '&jsoncallback=' + proxy;
                },
                on: {
                    failure: Y.bind(function () {
                        this.setLoading(false);
                        this.setMessage('Oops!! something broke :(');
                    }, self),

                    success: Y.bind(function (resp) {
                        this._processResults(resp.photos);
                        this._isNewQuery = false;
                    }, self)
                }
            });
        },

        // When our form is submitted, we assume it's a new request. As a new
        // request we remove our old pages, ensure our paginator is set to
        // page 1 and request our new set of photos
        _afterFormSubmit: function (e) {
            e.preventDefault();

            while (this._pages.length) {
                this._pages.shift().destroy({ remove: true });
            }

            this._api.text = this.get('container').one('form input').get('value');

            this._isNewQuery = true;

            if (this.paginator.get('page') !== 1) {
                this.paginator.set('page', 1);
            } else {
                this.requestPhotos();
            }
        },

        // After we receive a response from the Flickr API, we check if we
        // have any pages to process and send the
        _processResults: function (resp) {
            this.setMessage( !resp.pages ?
                'There are no images for "' + this._api.text + '"' :
                ''
            );

            if (this._isNewQuery) {
                this.paginator.set('totalItems', parseInt(resp.total, 10));
            }

            this._createNewPage(resp.photo);
        },

        // Once our data have been received by the Flicker API and the
        // results have been processed, we create a new page containing the
        // new photos
        _createNewPage: function (photos) {
            var page = new FlickrSearch.PageView(),
                resultsNode = this.get('container').one('.results'),
                pageContainer;

            // Add our photos to the new page
            page.addPhotos(photos);

            pageContainer = page.get('container');

            // append our new page to the results node
            resultsNode.append(pageContainer);
            resultsNode.setStyle('height', pageContainer.get('offsetHeight'));

            // We do not want to display the new page before all the images
            // requested have had a chance to process.
            var images = pageContainer.all('img'),
                imagesLeft = images.size();

            images.after(['load', 'error', 'abort'], function (e) {

                if (!(--imagesLeft)) {

                    // If there is more than one page, we have a previous page
                    var prevPage = (this._pages.length > 1) ? this._pages.shift() : null;

                    // Turn off the loading indicator
                    this.setLoading(false);

                    // Transition the new page in
                    // If there is not a previous page, just display the new page
                    pageContainer.transition({
                        opacity: 1,
                        duration: 1,
                        delay: (prevPage) ? 0.5 : 0
                    });

                    // Transition the previous page out
                    // Once the transition is complete, remove the previous page
                    if (prevPage) {
                        prevPage.get('container').transition({
                            opacity: 0,
                            duration: 1
                        }, function (e) {
                            prevPage.destroy({
                                remove: true
                            });
                        });
                    }
                }
            }, this);

            // We now have a page to display, so let's show the paginator
            this.get('container').removeClass('hide-pg');
            this._pages.push(page);
        },

        // After our page changes, we request that page's photos
        _afterPageChange: function (e) {
            this.requestPhotos(e.newVal);
        }

    }, {
        ATTRS: {
            // This will contain our settings for the Flickr API
            apiConfig: {
                value: {
                    api_key: FLICKR_API_KEY,
                    method: 'flickr.photos.search',
                    safe_search: 1,
                    sort: 'relevance',
                    format: 'json',
                    license: 4,
                    per_page: 20
                }
            }
        }
    });

    var flickrSearch = new FlickrSearch.App({
        container: '#demo'
    });

    flickrSearch.render();

});
</script>

Table of Contents

Setting Up the Interface

JavaScript

Setting Up the YUI Instance

Paginator

Paginator Model

Paginator Pages View

Paginator View

Page View

Search App View

Run with it!

Finishing touches

The Whole Example

Examples

                                            Slideshow

                                            Tables

                                            Search Results

Examples That Use This Component

                                            DataTable with Paginator


text:
local keyboardMovement = require("src.logic.ai.movement.keyboard_movement")
local spritesheet = require("src.graphics.spritesheet")
local entity = require("src.logic.entity")
local punch = require("src.items.punch")
local timer = require("src.logic.timer")

local player = {}

local adventurerSprite = spritesheet.create("assets/sprites/adventurer.png", 16)

local action1 = function (self, game)
  local currentRoom = game.map:currentRoom()
  currentRoom:addEntity(punch.create(self.x + 8, self.y, self.z))
  self.interuptMovement = true
  local t = timer.create(timer.ticks(5), function (_, owner, game)
    owner.interuptMovement = false
  end)
  self:addTimer(t)
end

player.create = function ()
  local player = entity.create(
    adventurerSprite,
    50,
    0,
    100,
    56,
    keyboardMovement)

  player.action1 = action1

  return player
end

return player

redpajama_set_name: RedPajamaGithub


text:
module Voice
  class WavToMp3Error < RuntimeError
  end

  class WavToMp3
    def initialize(config = {})
      @config = SS.config.voice['lame'].merge(config)
    end

    def convert(input_file, output_file)
      bin_path = resolve_path(@config['bin'])
      opts = @config['opts']
      input_file = resolve_path(input_file)
      output_file = resolve_path(output_file)

      raise WavToMp3Error, I18n.t("voice.synthesis_fail.no_lame") unless ::File.exist?(bin_path)
      cmd = %("#{bin_path}" #{opts} "#{input_file}" "#{output_file}")

      # execute command
      status = Voice::Command.run_with_logging(cmd, "lame")
      raise WavToMp3Error, I18n.t("voice.synthesis_fail.lame") unless status.exitstatus == 0
    end

    private

    def resolve_path(path)
      path = path.path if path.class.method_defined?(:path)
      path = File.join(Rails.root, path) if Pathname.new(path).relative?
      return path
    end
  end
end


text:
require 'date'
require 'google/apis/core/base_service'
require 'google/apis/core/json_representation'
require 'google/apis/core/hashable'
require 'google/apis/errors'

module Google
  module Apis
    module DeploymentmanagerAlpha

      class AuditConfig
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class AuditLogConfig
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class AuthorizationLoggingOptions
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class BasicAuth
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class Binding
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class CollectionOverride
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class CompositeType
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class CompositeTypeLabelEntry
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class CompositeTypesListResponse
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class Condition
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class ConfigFile
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class ConfigurableService
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class Credential
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class Deployment
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class DeploymentLabelEntry
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class DeploymentUpdate
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class DeploymentUpdateLabelEntry
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class DeploymentsCancelPreviewRequest
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class DeploymentsListResponse
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class DeploymentsStopRequest
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class Expr
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class ImportFile
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class InputMapping
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class LogConfig
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class LogConfigCloudAuditOptions
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class LogConfigCounterOptions
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class LogConfigDataAccessOptions
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class Manifest
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class ManifestsListResponse
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class Operation
        class Representation < Google::Apis::Core::JsonRepresentation; end

        class Error
          class Representation < Google::Apis::Core::JsonRepresentation; end

          class Error
            class Representation < Google::Apis::Core::JsonRepresentation; end

            include Google::Apis::Core::JsonObjectSupport
          end

          include Google::Apis::Core::JsonObjectSupport
        end

        class Warning
          class Representation < Google::Apis::Core::JsonRepresentation; end

          class Datum
            class Representation < Google::Apis::Core::JsonRepresentation; end

            include Google::Apis::Core::JsonObjectSupport
          end

          include Google::Apis::Core::JsonObjectSupport
        end

        include Google::Apis::Core::JsonObjectSupport
      end

      class OperationsListResponse
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class Options
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class Policy
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class Resource
        class Representation < Google::Apis::Core::JsonRepresentation; end

        class Warning
          class Representation < Google::Apis::Core::JsonRepresentation; end

          class Datum
            class Representation < Google::Apis::Core::JsonRepresentation; end

            include Google::Apis::Core::JsonObjectSupport
          end

          include Google::Apis::Core::JsonObjectSupport
        end

        include Google::Apis::Core::JsonObjectSupport
      end

      class ResourceAccessControl
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class ResourceUpdate
        class Representation < Google::Apis::Core::JsonRepresentation; end

        class Error
          class Representation < Google::Apis::Core::JsonRepresentation; end

          class Error
            class Representation < Google::Apis::Core::JsonRepresentation; end

            include Google::Apis::Core::JsonObjectSupport
          end

          include Google::Apis::Core::JsonObjectSupport
        end

        class Warning
          class Representation < Google::Apis::Core::JsonRepresentation; end

          class Datum
            class Representation < Google::Apis::Core::JsonRepresentation; end

            include Google::Apis::Core::JsonObjectSupport
          end

          include Google::Apis::Core::JsonObjectSupport
        end

        include Google::Apis::Core::JsonObjectSupport
      end

      class ResourcesListResponse
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class Rule
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class TargetConfiguration
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class TemplateContents
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class TestPermissionsRequest
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class TestPermissionsResponse
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class Type
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class TypeInfo
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class TypeInfoSchemaInfo
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class TypeLabelEntry
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class TypeProvider
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class TypeProviderLabelEntry
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class TypeProvidersListResponse
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class TypeProvidersListTypesResponse
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class TypesListResponse
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class ValidationOptions
        class Representation < Google::Apis::Core::JsonRepresentation; end

        include Google::Apis::Core::JsonObjectSupport
      end

      class AuditConfig
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          collection :audit_log_configs, as: 'auditLogConfigs', class: Google::Apis::DeploymentmanagerAlpha::AuditLogConfig, decorator: Google::Apis::DeploymentmanagerAlpha::AuditLogConfig::Representation

          collection :exempted_members, as: 'exemptedMembers'
          property :service, as: 'service'
        end
      end

      class AuditLogConfig
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          collection :exempted_members, as: 'exemptedMembers'
          property :log_type, as: 'logType'
        end
      end

      class AuthorizationLoggingOptions
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :permission_type, as: 'permissionType'
        end
      end

      class BasicAuth
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :password, as: 'password'
          property :user, as: 'user'
        end
      end

      class Binding
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :condition, as: 'condition', class: Google::Apis::DeploymentmanagerAlpha::Expr, decorator: Google::Apis::DeploymentmanagerAlpha::Expr::Representation

          collection :members, as: 'members'
          property :role, as: 'role'
        end
      end

      class CollectionOverride
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :collection, as: 'collection'
          property :options, as: 'options', class: Google::Apis::DeploymentmanagerAlpha::Options, decorator: Google::Apis::DeploymentmanagerAlpha::Options::Representation

        end
      end

      class CompositeType
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :description, as: 'description'
          property :id, :numeric_string => true, as: 'id'
          property :insert_time, as: 'insertTime'
          collection :labels, as: 'labels', class: Google::Apis::DeploymentmanagerAlpha::CompositeTypeLabelEntry, decorator: Google::Apis::DeploymentmanagerAlpha::CompositeTypeLabelEntry::Representation

          property :name, as: 'name'
          property :operation, as: 'operation', class: Google::Apis::DeploymentmanagerAlpha::Operation, decorator: Google::Apis::DeploymentmanagerAlpha::Operation::Representation

          property :self_link, as: 'selfLink'
          property :status, as: 'status'
          property :template_contents, as: 'templateContents', class: Google::Apis::DeploymentmanagerAlpha::TemplateContents, decorator: Google::Apis::DeploymentmanagerAlpha::TemplateContents::Representation

        end
      end

      class CompositeTypeLabelEntry
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :key, as: 'key'
          property :value, as: 'value'
        end
      end

      class CompositeTypesListResponse
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          collection :composite_types, as: 'compositeTypes', class: Google::Apis::DeploymentmanagerAlpha::CompositeType, decorator: Google::Apis::DeploymentmanagerAlpha::CompositeType::Representation

          property :next_page_token, as: 'nextPageToken'
        end
      end

      class Condition
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :iam, as: 'iam'
          property :op, as: 'op'
          property :svc, as: 'svc'
          property :sys, as: 'sys'
          property :value, as: 'value'
          collection :values, as: 'values'
        end
      end

      class ConfigFile
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :content, as: 'content'
        end
      end

      class ConfigurableService
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          collection :collection_overrides, as: 'collectionOverrides', class: Google::Apis::DeploymentmanagerAlpha::CollectionOverride, decorator: Google::Apis::DeploymentmanagerAlpha::CollectionOverride::Representation

          property :credential, as: 'credential', class: Google::Apis::DeploymentmanagerAlpha::Credential, decorator: Google::Apis::DeploymentmanagerAlpha::Credential::Representation

          property :descriptor_url, as: 'descriptorUrl'
          property :options, as: 'options', class: Google::Apis::DeploymentmanagerAlpha::Options, decorator: Google::Apis::DeploymentmanagerAlpha::Options::Representation

        end
      end

      class Credential
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :basic_auth, as: 'basicAuth', class: Google::Apis::DeploymentmanagerAlpha::BasicAuth, decorator: Google::Apis::DeploymentmanagerAlpha::BasicAuth::Representation

        end
      end

      class Deployment
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :description, as: 'description'
          property :fingerprint, :base64 => true, as: 'fingerprint'
          property :id, :numeric_string => true, as: 'id'
          property :insert_time, as: 'insertTime'
          collection :labels, as: 'labels', class: Google::Apis::DeploymentmanagerAlpha::DeploymentLabelEntry, decorator: Google::Apis::DeploymentmanagerAlpha::DeploymentLabelEntry::Representation

          property :manifest, as: 'manifest'
          property :name, as: 'name'
          property :operation, as: 'operation', class: Google::Apis::DeploymentmanagerAlpha::Operation, decorator: Google::Apis::DeploymentmanagerAlpha::Operation::Representation

          property :self_link, as: 'selfLink'
          property :target, as: 'target', class: Google::Apis::DeploymentmanagerAlpha::TargetConfiguration, decorator: Google::Apis::DeploymentmanagerAlpha::TargetConfiguration::Representation

          property :update, as: 'update', class: Google::Apis::DeploymentmanagerAlpha::DeploymentUpdate, decorator: Google::Apis::DeploymentmanagerAlpha::DeploymentUpdate::Representation

        end
      end

      class DeploymentLabelEntry
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :key, as: 'key'
          property :value, as: 'value'
        end
      end

      class DeploymentUpdate
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :description, as: 'description'
          collection :labels, as: 'labels', class: Google::Apis::DeploymentmanagerAlpha::DeploymentUpdateLabelEntry, decorator: Google::Apis::DeploymentmanagerAlpha::DeploymentUpdateLabelEntry::Representation

          property :manifest, as: 'manifest'
        end
      end

      class DeploymentUpdateLabelEntry
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :key, as: 'key'
          property :value, as: 'value'
        end
      end

      class DeploymentsCancelPreviewRequest
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :fingerprint, :base64 => true, as: 'fingerprint'
        end
      end

      class DeploymentsListResponse
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          collection :deployments, as: 'deployments', class: Google::Apis::DeploymentmanagerAlpha::Deployment, decorator: Google::Apis::DeploymentmanagerAlpha::Deployment::Representation

          property :next_page_token, as: 'nextPageToken'
        end
      end

      class DeploymentsStopRequest
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :fingerprint, :base64 => true, as: 'fingerprint'
        end
      end

      class Expr
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :description, as: 'description'
          property :expression, as: 'expression'
          property :location, as: 'location'
          property :title, as: 'title'
        end
      end

      class ImportFile
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :content, as: 'content'
          property :name, as: 'name'
        end
      end

      class InputMapping
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :field_name, as: 'fieldName'
          property :location, as: 'location'
          property :method_match, as: 'methodMatch'
          property :value, as: 'value'
        end
      end

      class LogConfig
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :cloud_audit, as: 'cloudAudit', class: Google::Apis::DeploymentmanagerAlpha::LogConfigCloudAuditOptions, decorator: Google::Apis::DeploymentmanagerAlpha::LogConfigCloudAuditOptions::Representation

          property :counter, as: 'counter', class: Google::Apis::DeploymentmanagerAlpha::LogConfigCounterOptions, decorator: Google::Apis::DeploymentmanagerAlpha::LogConfigCounterOptions::Representation

          property :data_access, as: 'dataAccess', class: Google::Apis::DeploymentmanagerAlpha::LogConfigDataAccessOptions, decorator: Google::Apis::DeploymentmanagerAlpha::LogConfigDataAccessOptions::Representation

        end
      end

      class LogConfigCloudAuditOptions
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :authorization_logging_options, as: 'authorizationLoggingOptions', class: Google::Apis::DeploymentmanagerAlpha::AuthorizationLoggingOptions, decorator: Google::Apis::DeploymentmanagerAlpha::AuthorizationLoggingOptions::Representation

          property :log_name, as: 'logName'
        end
      end

      class LogConfigCounterOptions
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :field, as: 'field'
          property :metric, as: 'metric'
        end
      end

      class LogConfigDataAccessOptions
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :log_mode, as: 'logMode'
        end
      end

      class Manifest
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :config, as: 'config', class: Google::Apis::DeploymentmanagerAlpha::ConfigFile, decorator: Google::Apis::DeploymentmanagerAlpha::ConfigFile::Representation

          property :expanded_config, as: 'expandedConfig'
          property :id, :numeric_string => true, as: 'id'
          collection :imports, as: 'imports', class: Google::Apis::DeploymentmanagerAlpha::ImportFile, decorator: Google::Apis::DeploymentmanagerAlpha::ImportFile::Representation

          property :insert_time, as: 'insertTime'
          property :layout, as: 'layout'
          property :name, as: 'name'
          property :self_link, as: 'selfLink'
        end
      end

      class ManifestsListResponse
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          collection :manifests, as: 'manifests', class: Google::Apis::DeploymentmanagerAlpha::Manifest, decorator: Google::Apis::DeploymentmanagerAlpha::Manifest::Representation

          property :next_page_token, as: 'nextPageToken'
        end
      end

      class Operation
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :client_operation_id, as: 'clientOperationId'
          property :creation_timestamp, as: 'creationTimestamp'
          property :description, as: 'description'
          property :end_time, as: 'endTime'
          property :error, as: 'error', class: Google::Apis::DeploymentmanagerAlpha::Operation::Error, decorator: Google::Apis::DeploymentmanagerAlpha::Operation::Error::Representation

          property :http_error_message, as: 'httpErrorMessage'
          property :http_error_status_code, as: 'httpErrorStatusCode'
          property :id, :numeric_string => true, as: 'id'
          property :insert_time, as: 'insertTime'
          property :kind, as: 'kind'
          property :name, as: 'name'
          property :operation_type, as: 'operationType'
          property :progress, as: 'progress'
          property :region, as: 'region'
          property :self_link, as: 'selfLink'
          property :start_time, as: 'startTime'
          property :status, as: 'status'
          property :status_message, as: 'statusMessage'
          property :target_id, :numeric_string => true, as: 'targetId'
          property :target_link, as: 'targetLink'
          property :user, as: 'user'
          collection :warnings, as: 'warnings', class: Google::Apis::DeploymentmanagerAlpha::Operation::Warning, decorator: Google::Apis::DeploymentmanagerAlpha::Operation::Warning::Representation

          property :zone, as: 'zone'
        end

        class Error
          # @private
          class Representation < Google::Apis::Core::JsonRepresentation
            collection :errors, as: 'errors', class: Google::Apis::DeploymentmanagerAlpha::Operation::Error::Error, decorator: Google::Apis::DeploymentmanagerAlpha::Operation::Error::Error::Representation

          end

          class Error
            # @private
            class Representation < Google::Apis::Core::JsonRepresentation
              property :code, as: 'code'
              property :location, as: 'location'
              property :message, as: 'message'
            end
          end
        end

        class Warning
          # @private
          class Representation < Google::Apis::Core::JsonRepresentation
            property :code, as: 'code'
            collection :data, as: 'data', class: Google::Apis::DeploymentmanagerAlpha::Operation::Warning::Datum, decorator: Google::Apis::DeploymentmanagerAlpha::Operation::Warning::Datum::Representation

            property :message, as: 'message'
          end

          class Datum
            # @private
            class Representation < Google::Apis::Core::JsonRepresentation
              property :key, as: 'key'
              property :value, as: 'value'
            end
          end
        end
      end

      class OperationsListResponse
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :next_page_token, as: 'nextPageToken'
          collection :operations, as: 'operations', class: Google::Apis::DeploymentmanagerAlpha::Operation, decorator: Google::Apis::DeploymentmanagerAlpha::Operation::Representation

        end
      end

      class Options
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          collection :input_mappings, as: 'inputMappings', class: Google::Apis::DeploymentmanagerAlpha::InputMapping, decorator: Google::Apis::DeploymentmanagerAlpha::InputMapping::Representation

          property :name_property, as: 'nameProperty'
          property :validation_options, as: 'validationOptions', class: Google::Apis::DeploymentmanagerAlpha::ValidationOptions, decorator: Google::Apis::DeploymentmanagerAlpha::ValidationOptions::Representation

        end
      end

      class Policy
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          collection :audit_configs, as: 'auditConfigs', class: Google::Apis::DeploymentmanagerAlpha::AuditConfig, decorator: Google::Apis::DeploymentmanagerAlpha::AuditConfig::Representation

          collection :bindings, as: 'bindings', class: Google::Apis::DeploymentmanagerAlpha::Binding, decorator: Google::Apis::DeploymentmanagerAlpha::Binding::Representation

          property :etag, :base64 => true, as: 'etag'
          property :iam_owned, as: 'iamOwned'
          collection :rules, as: 'rules', class: Google::Apis::DeploymentmanagerAlpha::Rule, decorator: Google::Apis::DeploymentmanagerAlpha::Rule::Representation

          property :version, as: 'version'
        end
      end

      class Resource
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :access_control, as: 'accessControl', class: Google::Apis::DeploymentmanagerAlpha::ResourceAccessControl, decorator: Google::Apis::DeploymentmanagerAlpha::ResourceAccessControl::Representation

          property :final_properties, as: 'finalProperties'
          property :id, :numeric_string => true, as: 'id'
          property :insert_time, as: 'insertTime'
          property :manifest, as: 'manifest'
          property :name, as: 'name'
          property :properties, as: 'properties'
          property :type, as: 'type'
          property :update, as: 'update', class: Google::Apis::DeploymentmanagerAlpha::ResourceUpdate, decorator: Google::Apis::DeploymentmanagerAlpha::ResourceUpdate::Representation

          property :update_time, as: 'updateTime'
          property :url, as: 'url'
          collection :warnings, as: 'warnings', class: Google::Apis::DeploymentmanagerAlpha::Resource::Warning, decorator: Google::Apis::DeploymentmanagerAlpha::Resource::Warning::Representation

        end

        class Warning
          # @private
          class Representation < Google::Apis::Core::JsonRepresentation
            property :code, as: 'code'
            collection :data, as: 'data', class: Google::Apis::DeploymentmanagerAlpha::Resource::Warning::Datum, decorator: Google::Apis::DeploymentmanagerAlpha::Resource::Warning::Datum::Representation

            property :message, as: 'message'
          end

          class Datum
            # @private
            class Representation < Google::Apis::Core::JsonRepresentation
              property :key, as: 'key'
              property :value, as: 'value'
            end
          end
        end
      end

      class ResourceAccessControl
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :gcp_iam_policy, as: 'gcpIamPolicy'
        end
      end

      class ResourceUpdate
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :access_control, as: 'accessControl', class: Google::Apis::DeploymentmanagerAlpha::ResourceAccessControl, decorator: Google::Apis::DeploymentmanagerAlpha::ResourceAccessControl::Representation

          property :error, as: 'error', class: Google::Apis::DeploymentmanagerAlpha::ResourceUpdate::Error, decorator: Google::Apis::DeploymentmanagerAlpha::ResourceUpdate::Error::Representation

          property :final_properties, as: 'finalProperties'
          property :intent, as: 'intent'
          property :manifest, as: 'manifest'
          property :properties, as: 'properties'
          property :state, as: 'state'
          collection :warnings, as: 'warnings', class: Google::Apis::DeploymentmanagerAlpha::ResourceUpdate::Warning, decorator: Google::Apis::DeploymentmanagerAlpha::ResourceUpdate::Warning::Representation

        end

        class Error
          # @private
          class Representation < Google::Apis::Core::JsonRepresentation
            collection :errors, as: 'errors', class: Google::Apis::DeploymentmanagerAlpha::ResourceUpdate::Error::Error, decorator: Google::Apis::DeploymentmanagerAlpha::ResourceUpdate::Error::Error::Representation

          end

          class Error
            # @private
            class Representation < Google::Apis::Core::JsonRepresentation
              property :code, as: 'code'
              property :location, as: 'location'
              property :message, as: 'message'
            end
          end
        end

        class Warning
          # @private
          class Representation < Google::Apis::Core::JsonRepresentation
            property :code, as: 'code'
            collection :data, as: 'data', class: Google::Apis::DeploymentmanagerAlpha::ResourceUpdate::Warning::Datum, decorator: Google::Apis::DeploymentmanagerAlpha::ResourceUpdate::Warning::Datum::Representation

            property :message, as: 'message'
          end

          class Datum
            # @private
            class Representation < Google::Apis::Core::JsonRepresentation
              property :key, as: 'key'
              property :value, as: 'value'
            end
          end
        end
      end

      class ResourcesListResponse
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :next_page_token, as: 'nextPageToken'
          collection :resources, as: 'resources', class: Google::Apis::DeploymentmanagerAlpha::Resource, decorator: Google::Apis::DeploymentmanagerAlpha::Resource::Representation

        end
      end

      class Rule
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :action, as: 'action'
          collection :conditions, as: 'conditions', class: Google::Apis::DeploymentmanagerAlpha::Condition, decorator: Google::Apis::DeploymentmanagerAlpha::Condition::Representation

          property :description, as: 'description'
          collection :ins, as: 'ins'
          collection :log_configs, as: 'logConfigs', class: Google::Apis::DeploymentmanagerAlpha::LogConfig, decorator: Google::Apis::DeploymentmanagerAlpha::LogConfig::Representation

          collection :not_ins, as: 'notIns'
          collection :permissions, as: 'permissions'
        end
      end

      class TargetConfiguration
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :config, as: 'config', class: Google::Apis::DeploymentmanagerAlpha::ConfigFile, decorator: Google::Apis::DeploymentmanagerAlpha::ConfigFile::Representation

          collection :imports, as: 'imports', class: Google::Apis::DeploymentmanagerAlpha::ImportFile, decorator: Google::Apis::DeploymentmanagerAlpha::ImportFile::Representation

        end
      end

      class TemplateContents
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          collection :imports, as: 'imports', class: Google::Apis::DeploymentmanagerAlpha::ImportFile, decorator: Google::Apis::DeploymentmanagerAlpha::ImportFile::Representation

          property :interpreter, as: 'interpreter'
          property :schema, as: 'schema'
          property :template, as: 'template'
        end
      end

      class TestPermissionsRequest
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          collection :permissions, as: 'permissions'
        end
      end

      class TestPermissionsResponse
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          collection :permissions, as: 'permissions'
        end
      end

      class Type
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :configurable_service, as: 'configurableService', class: Google::Apis::DeploymentmanagerAlpha::ConfigurableService, decorator: Google::Apis::DeploymentmanagerAlpha::ConfigurableService::Representation

          property :description, as: 'description'
          property :id, :numeric_string => true, as: 'id'
          property :insert_time, as: 'insertTime'
          collection :labels, as: 'labels', class: Google::Apis::DeploymentmanagerAlpha::TypeLabelEntry, decorator: Google::Apis::DeploymentmanagerAlpha::TypeLabelEntry::Representation

          property :name, as: 'name'
          property :operation, as: 'operation', class: Google::Apis::DeploymentmanagerAlpha::Operation, decorator: Google::Apis::DeploymentmanagerAlpha::Operation::Representation

          property :self_link, as: 'selfLink'
        end
      end

      class TypeInfo
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :description, as: 'description'
          property :documentation_link, as: 'documentationLink'
          property :kind, as: 'kind'
          property :name, as: 'name'
          property :schema, as: 'schema', class: Google::Apis::DeploymentmanagerAlpha::TypeInfoSchemaInfo, decorator: Google::Apis::DeploymentmanagerAlpha::TypeInfoSchemaInfo::Representation

          property :self_link, as: 'selfLink'
          property :title, as: 'title'
        end
      end

      class TypeInfoSchemaInfo
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :input, as: 'input'
          property :output, as: 'output'
        end
      end

      class TypeLabelEntry
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :key, as: 'key'
          property :value, as: 'value'
        end
      end

      class TypeProvider
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          collection :collection_overrides, as: 'collectionOverrides', class: Google::Apis::DeploymentmanagerAlpha::CollectionOverride, decorator: Google::Apis::DeploymentmanagerAlpha::CollectionOverride::Representation

          property :credential, as: 'credential', class: Google::Apis::DeploymentmanagerAlpha::Credential, decorator: Google::Apis::DeploymentmanagerAlpha::Credential::Representation

          property :description, as: 'description'
          property :descriptor_url, as: 'descriptorUrl'
          property :id, :numeric_string => true, as: 'id'
          property :insert_time, as: 'insertTime'
          collection :labels, as: 'labels', class: Google::Apis::DeploymentmanagerAlpha::TypeProviderLabelEntry, decorator: Google::Apis::DeploymentmanagerAlpha::TypeProviderLabelEntry::Representation

          property :name, as: 'name'
          property :operation, as: 'operation', class: Google::Apis::DeploymentmanagerAlpha::Operation, decorator: Google::Apis::DeploymentmanagerAlpha::Operation::Representation

          property :options, as: 'options', class: Google::Apis::DeploymentmanagerAlpha::Options, decorator: Google::Apis::DeploymentmanagerAlpha::Options::Representation

          property :self_link, as: 'selfLink'
        end
      end

      class TypeProviderLabelEntry
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :key, as: 'key'
          property :value, as: 'value'
        end
      end

      class TypeProvidersListResponse
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :next_page_token, as: 'nextPageToken'
          collection :type_providers, as: 'typeProviders', class: Google::Apis::DeploymentmanagerAlpha::TypeProvider, decorator: Google::Apis::DeploymentmanagerAlpha::TypeProvider::Representation

        end
      end

      class TypeProvidersListTypesResponse
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :next_page_token, as: 'nextPageToken'
          collection :types, as: 'types', class: Google::Apis::DeploymentmanagerAlpha::TypeInfo, decorator: Google::Apis::DeploymentmanagerAlpha::TypeInfo::Representation

        end
      end

      class TypesListResponse
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :next_page_token, as: 'nextPageToken'
          collection :types, as: 'types', class: Google::Apis::DeploymentmanagerAlpha::Type, decorator: Google::Apis::DeploymentmanagerAlpha::Type::Representation

        end
      end

      class ValidationOptions
        # @private
        class Representation < Google::Apis::Core::JsonRepresentation
          property :schema_validation, as: 'schemaValidation'
          property :undeclared_properties, as: 'undeclaredProperties'
        end
      end
    end
  end
end


text:
if [ exit ]; then
    echo exit works;
fi


text:
function fileList = FindFiles(folder, filter, isFolders, isExact)
%% Compatibility wrapper for code written using version 2.
%
% This function is a wrapper that can be called by "old" RenderToolbox4
% examples and user code, written before the Version 3.  Its job is to
% "look like" the old code, but internally it calls new code.
%
% To encourage users to update to Versoin 3 code, this wrapper will display
% an irritating warning.
%
%%% RenderToolbox4 Copyright (c) 2012-2016 The RenderToolbox Team.
%%% About Us://github.com/RenderToolbox/RenderToolbox4/wiki/About-Us
%%% RenderToolbox4 is released under the MIT License.  See LICENSE file.

rtbWarnDeprecated();

if nargin < 4 || isempty(isExact)
    isExact = false;
end

if nargin < 3 || isempty(isFolders)
    isFolders = false;
end

if nargin < 2
    filter = '';
end

if nargin < 1 || isempty(folder)
    folder = pwd();

else
    % convert relative folder to absolute path
    initalFolder = pwd();
    cd(folder)
    folder = pwd();

    % oddly enough, pwd() may not have existed!
    if exist(initalFolder, 'dir')
        cd(initalFolder);
    end
end

fileList = rtbFindFiles( ...
    'root', folder, ...
    'filter', filter, ...
    'exactMatch', isExact, ...
    'allowFolders', isFolders);


text:
package com.example.liwei.chattool.util;

import android.widget.Toast;

import com.example.liwei.chattool.app.MyApp;

/**
 * Created by liwei on 2017/8/1.
 * 土司工具
 */

public class ToastUtils {
    private static Toast toast=null;
    public static void showToast(String message){
        if(toast==null){
            synchronized (ToastUtils.class){
                if(toast==null){
                    toast=Toast.makeText(MyApp.getmContext(),message,Toast.LENGTH_SHORT);
                }else{
                    toast.setText(message);
                }
            }
        }else{
            toast.setText(message);
        }
        toast.show();
    }
    public static void showToast(int messageId){
        if(toast==null){
            synchronized (ToastUtils.class){
                if(toast==null){
                    toast=Toast.makeText(MyApp.getmContext(),MyApp.getmContext().getString(messageId),Toast.LENGTH_SHORT);
                }else{
                    toast.setText(MyApp.getmContext().getString(messageId));
                }
            }
        }else{
            toast.setText(MyApp.getmContext().getString(messageId));
        }
        toast.show();
    }

}


text:
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable enable

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.CodeAnalysis.FindSymbols;
using Microsoft.CodeAnalysis.LanguageServices;
using Microsoft.CodeAnalysis.Shared.Utilities;
using Roslyn.Utilities;

namespace Microsoft.CodeAnalysis.Shared.Extensions
{
    internal static partial class IFindReferencesResultExtensions
    {
        public static IEnumerable<Location> GetDefinitionLocationsToShow(
            this ISymbol definition)
        {
            return definition.IsKind(SymbolKind.Namespace)
                ? SpecializedCollections.SingletonEnumerable(definition.Locations.First())
                : definition.Locations;
        }

        public static IEnumerable<ReferencedSymbol> FilterToItemsToShow(
            this IEnumerable<ReferencedSymbol> result, FindReferencesSearchOptions options)
        {
            return result.Where(r => ShouldShow(r, options));
        }

        public static bool ShouldShow(
            this ReferencedSymbol referencedSymbol, FindReferencesSearchOptions options)
        {
            // If the reference has any locations then we will present it.
            if (referencedSymbol.Locations.Any())
            {
                return true;
            }

            return referencedSymbol.Definition.ShouldShowWithNoReferenceLocations(
                options, showMetadataSymbolsWithoutReferences: true);
        }

        public static bool ShouldShowWithNoReferenceLocations(
            this ISymbol definition, FindReferencesSearchOptions options, bool showMetadataSymbolsWithoutReferences)
        {
            // If the definition is implicit and we have no references, then we don't want to
            // clutter the UI with it.
            if (definition.IsImplicitlyDeclared)
            {
                return false;
            }

            // If we're associating property references with an accessor, then we don't want to show
            // a property if it is has no references.  Similarly, if we're associated associating
            // everything with the property, then we don't want to include accessors if there are no
            // references to them.
            if (options.AssociatePropertyReferencesWithSpecificAccessor)
            {
                if (definition.Kind == SymbolKind.Property)
                {
                    return false;
                }
            }
            else
            {
                if (definition.IsPropertyAccessor())
                {
                    return false;
                }
            }

            // Otherwise we still show the item even if there are no references to it.
            // And it's at least a source definition.
            if (definition.Locations.Any(loc => loc.IsInSource))
            {
                return true;
            }

            if (showMetadataSymbolsWithoutReferences &&
                definition.Locations.Any(loc => loc.IsInMetadata))
            {
                return true;
            }

            return false;
        }

        public static IEnumerable<ReferencedSymbol> FilterToAliasMatches(
            this IEnumerable<ReferencedSymbol> result,
            IAliasSymbol? aliasSymbol)
        {
            if (aliasSymbol == null)
            {
                return result;
            }

            return from r in result
                   let aliasLocations = r.Locations.Where(loc => SymbolEquivalenceComparer.Instance.Equals(loc.Alias, aliasSymbol))
                   where aliasLocations.Any()
                   select new ReferencedSymbol(r.Definition, aliasLocations);
        }

        public static IEnumerable<ReferencedSymbol> FilterNonMatchingMethodNames(
            this IEnumerable<ReferencedSymbol> result,
            Solution solution,
            ISymbol symbol)
        {
            return symbol.IsOrdinaryMethod()
                ? FilterNonMatchingMethodNamesWorker(result, solution, symbol)
                : result;
        }

        private static IEnumerable<ReferencedSymbol> FilterNonMatchingMethodNamesWorker(
            IEnumerable<ReferencedSymbol> result,
            Solution solution,
            ISymbol symbol)
        {
            foreach (var reference in result)
            {
                var isCaseSensitive = solution.Workspace.Services.GetLanguageServices(reference.Definition.Language).GetRequiredService<ISyntaxFactsService>().IsCaseSensitive;
                var comparer = isCaseSensitive ? StringComparer.Ordinal : StringComparer.OrdinalIgnoreCase;
                if (reference.Definition.IsOrdinaryMethod() &&
                    !comparer.Equals(reference.Definition.Name, symbol.Name))
                {
                    continue;
                }

                yield return reference;
            }
        }
    }
}


text:
.listdemoListControls md-divider {
  margin-top: 10px;
  margin-bottom: 10px; }
.listdemoListControls md-list-item > p, .listdemoListControls md-list-item > .md-list-item-inner > p, .listdemoListControls md-list-item .md-list-item-inner > p, .listdemoListControls md-list-item .md-list-item-inner > .md-list-item-inner > p {
  -webkit-user-select: none;
  /* Chrome all / Safari all */
  -moz-user-select: none;
  /* Firefox all */
  -ms-user-select: none;
  /* IE 10+ */
  user-select: none;
  /* Likely future */ }


text:
package com.twitter.sdk.android.core;

import com.google.gson.annotations.SerializedName;

/**
 * Base class for session associated with {@link com.twitter.sdk.android.core.AuthToken}.
 */
public class Session<T extends AuthToken> {

    @SerializedName("auth_token")
    private final T authToken;

    @SerializedName("id")
    private final long id;

    public Session(T authToken, long id) {
        this.authToken = authToken;
        this.id = id;
    }

    public T getAuthToken() {
        return authToken;
    }

    public long getId() {
        return id;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        final Session session = (Session) o;

        if (id != session.id) return false;
        if (authToken != null ? !authToken.equals(session.authToken) : session.authToken != null) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        int result = authToken != null ? authToken.hashCode() : 0;
        result = 31 * result + (int) (id ^ (id >>> 32));
        return result;
    }
}


text:
angular.module("campus-app").controller("AmbassadorBillingController", AmbassadorBillingController);

AmbassadorBillingController.$inject = ['$scope', '$state', '$q', '$uibModal', '$document', 'urls', 'HttpRequest', 'CookieService', 'SweetAlert'];

function AmbassadorBillingController($scope, $state, $q, $uibModal, $document, urls, HttpRequest, CookieService, SweetAlert) {
  var url = urls.BASE_API + '/users/' + CookieService.read("nickname");
  var promise = HttpRequest.send("GET", url);

  var urlPayments = urls.BASE_API + '/movements/' + CookieService.read("nickname") + '/ambassador_payments';
  var promisePayments = HttpRequest.send("GET", urlPayments);

  var allPromises = $q.all([promise, promisePayments]);

  allPromises.then(function (response) {
    $scope.user = response[0];
    $scope.payments = response[1];

    $scope.fullname = angular.copy($scope.user.fullname);

    var $contenido = $('#contenido');
    $contenido.addClass("loaded");
  }, function(error){
    toastr.error("Hubo un error");
  });
}