/*exported UIPSaveFontPreset*/
/*global designer, ErrorUtility, ControlPresetStorage, Utils, UIProvider */
/**
 * @param {ProviderData} data
 * @constructor
 */
var UIPSaveFontPreset = function (data) {
    'use strict';
    UIPSaveFontPreset.superclass.constructor.call(this, data);

    this.visible(!!window.debug);
};

Utils.extend(UIPSaveFontPreset, UIProvider);

UIPSaveFontPreset.prototype.click = function () {
    'use strict';
    var newStyle = {
        caption: '',
        thmbn: '',
        properties: []
    };
    var fontScheme = window.bootstrap.variables.fontScheme;
    newStyle.properties.push({property: 'headingsFontFamily', value: fontScheme.headingsFontFamily.family.toString()});
    newStyle.properties.push({property: 'sansFontFamily', value: fontScheme.sansFontFamily.family.toString()});
    var json = JSON.stringify(newStyle, null, '\t');
    ControlPresetStorage.savePreset(fontScheme, { json: json, name: 'FontSchema' }, function (error) {
        if (ErrorUtility.logError(error)) {
            designer.ui.dialog.messageBox.show("Error", "#Designer_PresetNotSaved");
            return;
        }
        designer.ui.dialog.messageBox.show('#Designer_PresetSaved_Title', '#Designer_PresetSaved_Body');
    });
};