/*jslint nomen: true, devel: true*/

define([
    'underscore',
    'backbone',
    'ccweb.files.extract/utils/TemplateUtil',
    'ccweb.files.extract/utils/CSSUtil'
], function (_, Backbone, TemplateUtil, CSSUtil) {
    'use strict';
    var colorProperties = {
        'background-color': 1,
        'border-color': 1,
        'color': 1
    },
        CSSListItemView = Backbone.View.extend({

            defaults: {
                cssObj : null,
                clip : null
            },

            initialize: function (options) {
                this.cssObj = options.cssObj;
                this.preProcessor = options.preProcessor;
                this.render();
            },

            render: function () {
                var listItem = CSSUtil.cssPreprocessors[this.preProcessor].listItem(this.cssObj);
                this.setElement('<li>' + listItem + '</li>');

                if (this.cssObj && this.cssObj.comment) {
                    this.$el.append(' <span class="comment">/* ' + this.cssObj.comment + ' */</span>');
                }

                return this;
            },

            isColorProperty: function () {
                return this.cssObj && (colorProperties.hasOwnProperty(this.cssObj.property));
            },

            isSpacer: function () {
                return this.cssObj && this.cssObj.spacer;
            }
        });

    return CSSListItemView;
});
