Esempio n. 1
0
 _.each(this, function(value, property) {
     if (value && snippet.isFunction(value._destroy)) {
         value._destroy();
     }
     if (value && snippet.isFunction(value.stopListening)) {
         value.stopListening();
     }
     this[property] = null;
 }, this);
Esempio n. 2
0
    _getDefaultRequestOptions: function(type, params) {
        var options = this.command[type];

        if (snippet.isFunction(options.url)) { // for restful API url
            options.url = options.url(params);
        }

        if (snippet.isFunction(options.data)) { // for custom request data
            options.data = options.data(params);
        }

        options.type = (options.type) ? options.type.toLowerCase() : 'get';
        options.dataType = options.dataType || 'json';

        return options;
    },
Esempio n. 3
0
    changeTemplateToElement: function(template, props) {
        var html;

        if (snippet.isFunction(template)) {
            html = template(props);
        } else {
            html = util.replaceTemplate(template, props);
        }

        return util.getElementFromTemplate(html);
    },
Esempio n. 4
0
Collection.prototype.single = function(filter) {
    var result,
        useFilter = util.isFunction(filter);

    this.each(function(item) {
        if (!useFilter) {
            result = item;

            return false; // returning false can stop this loop
        }
        if (filter(item)) {
            result = item;

            return false; // returning false can stop this loop
        }

        return true;
    }, this);

    return result;
};