<commit_before>//= require ./image_view
//= require ./panel
//= require ./label_view
//= require ./button_view

var alias = Ember.computed.alias,
    nearest = Flame.computed.nearest;

Flame.AlertPanel = Flame.Panel.extend();

Flame.AlertPanel.INFO_ICON = Flame.image('info_icon.svg');
Flame.AlertPanel.WARN_ICON = Flame.image('warn_icon.svg');
Flame.AlertPanel.ERROR_ICON = Flame.image('error_icon.svg');

Flame.AlertPanelButtonView = Flame.View.extend({
    layout: { width: '100%', right: 0, height: 30 },
    childViews: ['cancelButtonView', 'confirmButtonView'],
    cancelButtonTitle: 'Cancel',
    confirmButtonTitle: 'OK',
    isCancelVisible: true,
    isConfirmVisible: true,
    isCancelDisabled: false,
    isConfirmDisabled: false,
    alertPanelView: null,

    cancelButtonView: Flame.ButtonView.extend({
        layout: { width: 90, bottom: 2, right: 110 },
        title: alias('parentView.cancelButtonTitle'),
        isVisible: alias('parentView.isCancelVisible'),
        isDisabled: alias('parentView.isCancelDisabled'),
        action: function() {
            this.get('parentView.alertPanelView').onCancel();
        }
    }),

    confirmButtonView: Flame.ButtonView.extend({
        layout: { width: 90, bottom: 2, right: 2 },
        title: alias('parentView.confirmButtonTitle'),
        isVisible: alias('parentView.isConfirmVisible'),
        isDisabled: alias('parentView.isConfirmDisabled'),
        isDefault: true,
        action: function() {
            this.get('parentView.alertPanelView').onConfirm();
        }
    })
});

Flame.AlertPanelMessageView = Flame.View.extend({
    layout: { left: 10, right: 2, height: 'measuredHeight' },
    childViews: ['iconView', 'messageView'],
    messageViewWidth: 0,
    measuredHeight: function() {
        var width  = "width: %@px;".fmt(this.get('messageViewWidth'));
        var parentClasses = this.nearestOfType(Flame.AlertPanel).get('classNames').join(' ');
        var elementClasses = this.get('messageView.classNames').join(' ');
        var computedMessageViewHeight = Flame.measureString(this.get('message'), parentClasses, elementClasses, width).height;
        return Math.max(Math.min(computedMessageViewHeight, 600), 50);
    }.property('message', 'messageViewWidth'),
    message: null,

    iconView: Flame.ImageView.extend({
        layout: { left: 10 },
        value: nearest('icon')
    }),

    messageView: Flame.LabelView.extend({
        layout: { left: 75, right: 2, height: null },
        didInsertElement: function() {
            this.set('parentView.messageViewWidth', this.$().width());
        },
        allowWrapping: true,
        value: alias('parentView.message')
    })
});

Flame.AlertPanel.reopen({<commit_msg>all alertpanels made selectable<commit_after>//= require ./image_view
//= require ./panel
//= require ./label_view
//= require ./button_view

var alias = Ember.computed.alias,
    nearest = Flame.computed.nearest;

Flame.AlertPanel = Flame.Panel.extend();

Flame.AlertPanel.INFO_ICON = Flame.image('info_icon.svg');
Flame.AlertPanel.WARN_ICON = Flame.image('warn_icon.svg');
Flame.AlertPanel.ERROR_ICON = Flame.image('error_icon.svg');

Flame.AlertPanelButtonView = Flame.View.extend({
    layout: { width: '100%', right: 0, height: 30 },
    childViews: ['cancelButtonView', 'confirmButtonView'],
    cancelButtonTitle: 'Cancel',
    confirmButtonTitle: 'OK',
    isCancelVisible: true,
    isConfirmVisible: true,
    isCancelDisabled: false,
    isConfirmDisabled: false,
    alertPanelView: null,

    cancelButtonView: Flame.ButtonView.extend({
        layout: { width: 90, bottom: 2, right: 110 },
        title: alias('parentView.cancelButtonTitle'),
        isVisible: alias('parentView.isCancelVisible'),
        isDisabled: alias('parentView.isCancelDisabled'),
        action: function() {
            this.get('parentView.alertPanelView').onCancel();
        }
    }),

    confirmButtonView: Flame.ButtonView.extend({
        layout: { width: 90, bottom: 2, right: 2 },
        title: alias('parentView.confirmButtonTitle'),
        isVisible: alias('parentView.isConfirmVisible'),
        isDisabled: alias('parentView.isConfirmDisabled'),
        isDefault: true,
        action: function() {
            this.get('parentView.alertPanelView').onConfirm();
        }
    })
});

Flame.AlertPanelMessageView = Flame.View.extend({
    layout: { left: 10, right: 2, height: 'measuredHeight' },
    childViews: ['iconView', 'messageView'],
    messageViewWidth: 0,
    measuredHeight: function() {
        var width  = "width: %@px;".fmt(this.get('messageViewWidth'));
        var parentClasses = this.nearestOfType(Flame.AlertPanel).get('classNames').join(' ');
        var elementClasses = this.get('messageView.classNames').join(' ');
        var computedMessageViewHeight = Flame.measureString(this.get('message'), parentClasses, elementClasses, width).height;
        return Math.max(Math.min(computedMessageViewHeight, 600), 50);
    }.property('message', 'messageViewWidth'),
    message: null,

    iconView: Flame.ImageView.extend({
        layout: { left: 10 },
        value: nearest('icon')
    }),

    messageView: Flame.LabelView.extend({
        layout: { left: 75, right: 2, height: null },
        didInsertElement: function() {
            this.set('parentView.messageViewWidth', this.$().width());
        },
        allowWrapping: true,
        value: alias('parentView.message'),
        isSelectable: true
    })
});

Flame.AlertPanel.reopen({
{'fraction_non_alphanumeric': 0.14747548129313476, 'fraction_numerical': 0.010897203051216855, 'mean_word_length': 3.4056, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4361868', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1621, 'n_words': 306}