UNPKG

@extjs/sencha-cmd-linux-32

Version:

Productivity and performance optimization tool for building applications with Sencha Ext JS and Sencha Touch.

115 lines (101 loc) 4.36 kB
"use strict"; var LinearGradient = require('../export/type/LinearGradient.js'); var RadialGradient = require('../export/type/RadialGradient.js'); var List = require('../export/type/List.js'); var ColorStop = require('../export/type/ColorStop.js'); module.exports = { init(runtime) { runtime.register({ linear_gradient: function (position, stops) { stops = this.tailArgs(1, arguments); if (stops && stops.length === 1) { stops = stops[0]; } if ( (position.type === 'list' && (position.get(1).type === 'rgba' || position.get(1).type === 'hsla')) || position.type === 'hsla' || position.type === 'rgba' ) { stops = this.color_stops.apply(this, arguments); position = null; } else if (position.type == 'list' && position.get(1).type == 'colorstop') { stops = position; position = null; } else if (stops.type === 'hsla' || stops.type === 'rgba') { stops = this.color_stops.call(this, new List([stops])); } else { stops = this.color_stops.call(this, stops); } return new LinearGradient(position, stops); }, radial_gradient: function (position, shape, stops) { stops = this.tailArgs(2, arguments); if (stops && stops.length === 1) { stops = stops[0]; } if ( (position.type === 'list' && (position.get(1).type === 'rgba' || position.get(1).type === 'hsla')) || position.type === 'hsla' || position.type === 'rgba' ) { stops = this.color_stops.apply(this, arguments); position = null; } else if (position.type == 'list' && position.get(1).type == 'colorstop') { stops = position; position = null; } else if ( (shape.type === 'list' && (shape.get(1).type === 'rgba' || shape.get(1).type === 'hsla')) || shape.type === 'hsla' || shape.type === 'rgba' ) { stops = this.color_stops.apply(this, arguments); shape = null; } else if (shape.type == 'list' && shape.get(1).type == 'colorstop') { stops = shape; shape = null; } else if (stops.type === 'hsla' || stops.type === 'rgba') { stops = this.color_stops.call(this, new List([stops])); } else { stops = this.color_stops.call(this, stops); } return new RadialGradient(position, shape, stops); }, color_stops: function () { var args = this.tailArgs(0, arguments), mapped = this.handleArgs(args && args.items || args, [['stops']]), stops = mapped.stops.items, ln = stops.length, list = new List(null, ', '), i, arg; for (i = 0; i < ln; i++) { arg = stops[i]; if (arg.type === 'list') { if (arg.items.length === 2) { list.add(new ColorStop(arg.get(1), arg.get(2))); } else { list.items.push.apply(list.items, arg.items); } } else if (arg.type === 'rgba' || arg.type === 'hsla') { list.add(new ColorStop(arg)); } else if (Array.isArray(arg)) { list.items.push.apply(list.items, arg); } else { list.add(arg); } } return list; } }); } }