How to use the alloy/underscore._.isObject function in alloy

To help you get started, we’ve selected a few alloy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BOXOUT-THINKERS / TiOpenChat / app / lib / alloy / sync / sqlrest.js View on Github external
continue;
        }
        if (!_.contains(_.keys(attrObj), c)) {
          Ti.API.error("[SQL REST API] ITEM NOT VALID - REASON: " + c + " is not present");
          return;
        }
      }
    }

    // Create arrays for insert query
    var names = [],
      values = [],
      q = [];
    for (var k in columns) {
      names.push(k);
      if (_.isObject(attrObj[k])) {
        values.push(JSON.stringify(attrObj[k]));
      } else {
        values.push(attrObj[k]);
      }
      q.push('?');
    }

    // Last Modified logic
    if (params.lastModifiedColumn && _.isUndefined(params.disableLastModified)) {
      values[_.indexOf(names, params.lastModifiedColumn)] = params.lastModifiedDateFormat ? moment().format(params.lastModifiedDateFormat) : moment().lang('en').zone('GMT').format('ddd, D MMM YYYY HH:mm:ss ZZ');
    }

    // Assemble create query
    var sqlInsert = "INSERT INTO " + table + " (" + names.join(",") + ") VALUES (" + q.join(",") + ");";

    if (queryList) {
github BOXOUT-THINKERS / TiOpenChat / app / lib / alloy / sync / sqlrest.js View on Github external
} else {
      if (!isCollection) {
        attrObj = model.toJSON();
      } else {
        Ti.API.error("Its a collection - error!");
      }
    }

    // Create arrays for insert query
    var names = [],
      values = [],
      q = [];
    for (var k in columns) {
      if (!_.isUndefined(attrObj[k])) {//only update those who are in the data
        names.push(k + '=?');
        if (_.isObject(attrObj[k])) {
          values.push(JSON.stringify(attrObj[k]));
        } else {
          values.push(attrObj[k]);
        }
        q.push('?');
      }
    }

    if (params.lastModifiedColumn && _.isUndefined(params.disableLastModified)) {
      values[_.indexOf(names, params.lastModifiedColumn + "=?")] = params.lastModifiedDateFormat ? moment().format(params.lastModifiedDateFormat) : moment().lang('en').zone('GMT').format('YYYY-MM-DD HH:mm:ss ZZ');
    }

    // compose the update query
    var sql = 'UPDATE ' + table + ' SET ' + names.join(',') + ' WHERE ' + model.idAttribute + '=?';
    values.push(attrObj[model.idAttribute]);
github BOXOUT-THINKERS / TiOpenChat / app / lib / alloy / sync / sqlrest.js View on Github external
if (params.lastModifiedColumn && _.isUndefined(params.disableLastModified)) {
    //send last modified model datestamp to the remote server
    params.lastModifiedValue = null;
    try {
      params.lastModifiedValue = sqlLastModifiedItem();
    } catch (e) {
      logger(DEBUG, "LASTMOD SQL FAILED: ");

    }
    if (params.lastModifiedValue) {
      params.headers['If-Modified-Since'] = params.lastModifiedValue;
    }
  }

  // Extend the provided url params with those from the model config
  if (_.isObject(params.urlparams) || model.config.URLPARAMS) {
    if (_.isUndefined(params.urlparams)) {
      params.urlparams = {};
    }
    _.extend(params.urlparams, _.isFunction(model.config.URLPARAMS) ? model.config.URLPARAMS() : model.config.URLPARAMS);
  }

  // parse url {requestparams}
  _.each(params.requestparams, function(value, key) {
    params.url = params.url.replace('{' + key + '}', value ? escape(value) : '', "gi");
  });

  // For older servers, emulate JSON by encoding the request into an HTML-form.
  if (Alloy.Backbone.emulateJSON) {
    params.contentType = 'application/x-www-form-urlencoded';
    params.processData = true;
    params.data = params.data ? {
github viezel / napp.alloy.adapter.restsql / sqlrest.js View on Github external
continue;
				}
				if (!_.contains(_.keys(attrObj), c)) {
					Ti.API.error("[SQL REST API] ITEM NOT VALID - REASON: " + c + " is not present");
					return;
				}
			}
		}

		// Create arrays for insert query
		var names = [],
		    values = [],
		    q = [];
		for (var k in columns) {
			names.push(k);
			if (_.isObject(attrObj[k])) {
				values.push(JSON.stringify(attrObj[k]));
			} else {
				values.push(attrObj[k]);
			}
			q.push('?');
		}

		// Last Modified logic
		if (params.lastModifiedColumn && _.isUndefined(params.disableLastModified)) {
			values[_.indexOf(names, params.lastModifiedColumn)] = params.lastModifiedDateFormat ? moment().format(params.lastModifiedDateFormat) : moment().lang('en').zone('GMT').format('ddd, D MMM YYYY HH:mm:ss ZZ');
		}

		// Assemble create query
		var sqlInsert = "INSERT INTO " + table + " (" + names.join(",") + ") VALUES (" + q.join(",") + ");";

		if (!_.isUndefined(queryList) && _.isFunction(queryList.push)) {
github bob-sims / ytPlayer / Resources / alloy.js View on Github external
exports.createStyle = function(controller, opts, defaults) {
    var classes, apiName;
    if (!opts) return {};
    classes = _.isArray(opts.classes) ? opts.classes.slice(0) : _.isString(opts.classes) ? opts.classes.split(/\s+/) : [];
    apiName = opts.apiName;
    apiName && -1 === apiName.indexOf(".") && (apiName = addNamespace(apiName));
    var styleArray;
    styleArray = controller && _.isObject(controller) ? require("alloy/widgets/" + controller.widgetId + "/styles/" + controller.name) : require("alloy/styles/" + controller);
    var styleFinal = {};
    var i, len;
    for (i = 0, len = styleArray.length; len > i; i++) {
        var style = styleArray[i];
        var styleApi = style.key;
        style.isApi && -1 === styleApi.indexOf(".") && (styleApi = (CONST.IMPLICIT_NAMESPACES[styleApi] || CONST.NAMESPACE_DEFAULT) + "." + styleApi);
        if (style.isId && opts.id && style.key === opts.id || style.isClass && _.contains(classes, style.key)) ; else {
            if (!style.isApi) continue;
            -1 === style.key.indexOf(".") && (style.key = addNamespace(style.key));
            if (style.key !== apiName) continue;
        }
        if (style.queries && style.queries.formFactor && !Alloy[style.queries.formFactor]) continue;
        _.extend(styleFinal, style.style);
    }
    var extraStyle = _.omit(opts, [ CONST.CLASS_PROPERTY, CONST.APINAME_PROPERTY ]);
    _.extend(styleFinal, extraStyle);
github pablorr18 / TiFlexiGrid / Image Gallery Sample / Resources / mobileweb / alloy.js View on Github external
exports.createStyle = function(controller, opts, defaults) {
    var classes, apiName;
    if (!opts) return {};
    classes = _.isArray(opts.classes) ? opts.classes.slice(0) : _.isString(opts.classes) ? opts.classes.split(/\s+/) : [];
    apiName = opts.apiName;
    apiName && -1 === apiName.indexOf(".") && (apiName = addNamespace(apiName));
    var styleArray;
    styleArray = controller && _.isObject(controller) ? require("alloy/widgets/" + controller.widgetId + "/styles/" + controller.name) : require("alloy/styles/" + controller);
    var styleFinal = {};
    var i, len;
    for (i = 0, len = styleArray.length; len > i; i++) {
        var style = styleArray[i];
        var styleApi = style.key;
        style.isApi && -1 === styleApi.indexOf(".") && (styleApi = (CONST.IMPLICIT_NAMESPACES[styleApi] || CONST.NAMESPACE_DEFAULT) + "." + styleApi);
        if (style.isId && opts.id && style.key === opts.id || style.isClass && _.contains(classes, style.key)) ; else {
            if (!style.isApi) continue;
            -1 === style.key.indexOf(".") && (style.key = addNamespace(style.key));
            if (style.key !== apiName) continue;
        }
        if (style.queries && style.queries.formFactor && !Alloy[style.queries.formFactor]) continue;
        _.extend(styleFinal, style.style);
    }
    var extraStyle = _.omit(opts, [ CONST.CLASS_PROPERTY, CONST.APINAME_PROPERTY ]);
    _.extend(styleFinal, extraStyle);
github BOXOUT-THINKERS / TiOpenChat / Resources / iphone / alloy.js View on Github external
exports.createStyle = function(controller, opts, defaults) {
    var classes, apiName;
    if (!opts) return {};
    classes = _.isArray(opts.classes) ? opts.classes.slice(0) : _.isString(opts.classes) ? opts.classes.split(/\s+/) : [];
    apiName = opts.apiName;
    apiName && -1 === apiName.indexOf(".") && (apiName = addNamespace(apiName));
    var styleArray;
    styleArray = require(controller && _.isObject(controller) ? "alloy/widgets/" + controller.widgetId + "/styles/" + controller.name : "alloy/styles/" + controller);
    var styleFinal = {};
    var i, len;
    for (i = 0, len = styleArray.length; len > i; i++) {
        var style = styleArray[i];
        var styleApi = style.key;
        style.isApi && -1 === styleApi.indexOf(".") && (styleApi = (CONST.IMPLICIT_NAMESPACES[styleApi] || CONST.NAMESPACE_DEFAULT) + "." + styleApi);
        if (style.isId && opts.id && style.key === opts.id || style.isClass && _.contains(classes, style.key)) ; else {
            if (!style.isApi) continue;
            -1 === style.key.indexOf(".") && (style.key = addNamespace(style.key));
            if (style.key !== apiName) continue;
        }
        if (style.queries && style.queries.formFactor && !Alloy[style.queries.formFactor]) continue;
        if (style.queries && style.queries.if && ("false" === style.queries.if.trim().toLowerCase() || -1 !== style.queries.if.indexOf("Alloy.Globals") && false === Alloy.Globals[style.queries.if.split(".")[2]])) continue;
        exports.deepExtend(true, styleFinal, style.style);
    }
    var extraStyle = _.omit(opts, [ CONST.CLASS_PROPERTY, CONST.APINAME_PROPERTY ]);
github viezel / napp.alloy.adapter.restsql / sqlrest.js View on Github external
_.each(data, function(v, f) {
		if (_.isArray(v)) {//select multiple items
			var innerWhere = [];
			_.each(v, function(value) {
				innerWhere.push(f + whereOperator + _valueType(value));
			});
			where.push(innerWhere.join(' OR '));
		} else if (_.isObject(v)) {
			where = whereBuilder(where, v, whereOperator);
		} else {
			where.push(f + whereOperator + _valueType(v));
		}
	});
	return where;
github hoyo / ActionBarSample / Resources / alloy.js View on Github external
exports.createWidget = function(id, name, args) {
    if ("undefined" != typeof name && null !== name && _.isObject(name) && !_.isString(name)) {
        args = name;
        name = DEFAULT_WIDGET;
    }
    return new (require("alloy/widgets/" + id + "/controllers/" + (name || DEFAULT_WIDGET)))(args);
};
github fnando521 / AlloyMenuWidget / Menu / Resources / alloy.js View on Github external
exports.createWidget = function(id, name, args) {
    if ("undefined" != typeof name && null !== name && _.isObject(name) && !_.isString(name)) {
        args = name;
        name = DEFAULT_WIDGET;
    }
    return new (require("alloy/widgets/" + id + "/controllers/" + (name || DEFAULT_WIDGET)))(args);
};