<commit_before>/**
 * Clarify.
 * 
 * Copyright (C) 2012 <NAME> <<EMAIL>>
 *
 * Licensed under the MIT license:
 * http://www.opensource.org/licenses/MIT
 */
(function($) { 
    Tc.Module.LayerComment = Tc.Module.extend({
        
        active: false,
        deletemode: false,
        
        onBinding: function() { 
            var that = this;
            var $ctx = this.$ctx;
            $('.btn-comments').bind('click', function(e) {
                if (that.active) {
                    that.deactivate();
                } else {
                    that.sandbox.getModuleById($('.modLayerModule').data('id')).deactivate();
                    that.sandbox.getModuleById($('.modLayerColor').data('id')).deactivate();
                    that.sandbox.getModuleById($('.modLayerMeasure').data('id')).deactivate();
                    that.activate();
                }
            });
            
            $('.btn-delete').on('click', function(e) {
                that.deletemode = !that.deletemode;
                if (that.deletemode) {
                    $('.def', $ctx).addClass('def-delete');
                    $('.btn-delete').addClass('delete');
                    $('.edit', $ctx).hide();
                } else {
                    $('.def', $ctx).removeClass('def-delete');
                    $('.btn-delete').removeClass('delete');
                }
            });
            
            $('.btn-embed').on('click', function(e) {
                var screen = $(this).data('screen');
                $('.modal-confirm h3').text('Copy & Paste the following snippet into your site');
                $('.modal-confirm p').empty();
                var code = $('<code></code>').text('<script type="text/javascript" src="' + $(this).data('url') + '"></script>');
                $('.modal-confirm p').append($('<span>You can customize the width (e.g. 800px) to your needs.</span>'));
                $('.modal-confirm p').append(code);
                $('.modal-confirm .btn-confirm').text('Allow Embedding');
                $('.modal-confirm .btn-confirm').on('click', function() {
                    $.ajax({
                        url: "/api/screen/setting/" + screen + "/embeddable/true",
                        dataType: 'json',
                        success: function(data){
                            $('.modal-confirm').modal('hide');
                        }
                    });
                    e.stopPropagation();
                    return false;
                });
                $('.modal-confirm').modal();
            });
            
            $('.dot').live('click', function(e) {
                var container = $(this).parent();
                if (that.deletemode) {
                    $.ajax({
                        url: "/api/comment/remove/" + container.data('id'),
                        dataType: 'json',
                        success: function(data){
                            $('.edit', container).fadeOut('fast');
                            $('.dot', container).effect('puff');
                        }
                    });
                    return;
                }
                var edit = $('.edit', container);
                if (edit.is(':visible')) {
                    /*
                    // save changes
                    var content = $('textarea', edit).val();
                    $.ajax({
                        url: "/api/comment/update/" + container.data('id'),
                        dataType: 'json',
                        type: 'POST',
                        data: "content=" + content,
                        success: function(data){
                            // NOOP
                        }<commit_msg>changed effect to fade (bye bye puff).<commit_after>/**
 * Clarify.
 * 
 * Copyright (C) 2012 <NAME> <<EMAIL>>
 *
 * Licensed under the MIT license:
 * http://www.opensource.org/licenses/MIT
 */
(function($) { 
    Tc.Module.LayerComment = Tc.Module.extend({
        
        active: false,
        deletemode: false,
        
        onBinding: function() { 
            var that = this;
            var $ctx = this.$ctx;
            $('.btn-comments').bind('click', function(e) {
                if (that.active) {
                    that.deactivate();
                } else {
                    that.sandbox.getModuleById($('.modLayerModule').data('id')).deactivate();
                    that.sandbox.getModuleById($('.modLayerColor').data('id')).deactivate();
                    that.sandbox.getModuleById($('.modLayerMeasure').data('id')).deactivate();
                    that.activate();
                }
            });
            
            $('.btn-delete').on('click', function(e) {
                that.deletemode = !that.deletemode;
                if (that.deletemode) {
                    $('.def', $ctx).addClass('def-delete');
                    $('.btn-delete').addClass('delete');
                    $('.edit', $ctx).hide();
                } else {
                    $('.def', $ctx).removeClass('def-delete');
                    $('.btn-delete').removeClass('delete');
                }
            });
            
            $('.btn-embed').on('click', function(e) {
                var screen = $(this).data('screen');
                $('.modal-confirm h3').text('Copy & Paste the following snippet into your site');
                $('.modal-confirm p').empty();
                var code = $('<code></code>').text('<script type="text/javascript" src="' + $(this).data('url') + '"></script>');
                $('.modal-confirm p').append($('<span>You can customize the width (e.g. 800px) to your needs.</span>'));
                $('.modal-confirm p').append(code);
                $('.modal-confirm .btn-confirm').text('Allow Embedding');
                $('.modal-confirm .btn-confirm').on('click', function() {
                    $.ajax({
                        url: "/api/screen/setting/" + screen + "/embeddable/true",
                        dataType: 'json',
                        success: function(data){
                            $('.modal-confirm').modal('hide');
                        }
                    });
                    e.stopPropagation();
                    return false;
                });
                $('.modal-confirm').modal();
            });
            
            $('.dot').live('click', function(e) {
                var container = $(this).parent();
                if (that.deletemode) {
                    $.ajax({
                        url: "/api/comment/remove/" + container.data('id'),
                        dataType: 'json',
                        success: function(data){
                            $('.edit', container).fadeOut('fast');
                            $('.dot', container).fadeOut();
                        }
                    });
                    return;
                }
                var edit = $('.edit', container);
                if (edit.is(':visible')) {
                    /*
                    // save changes
                    var content = $('textarea', edit).val();
                    $.ajax({
                        url: "/api/comment/update/" + container.data('id'),
                        dataType: 'json',
                        type: 'POST',
                        data: "content=" + content,
                        success: function(data){
                            // NOOP
                        }
{'fraction_non_alphanumeric': 0.1675120128136679, 'fraction_numerical': 0.002135611318739989, 'mean_word_length': 1.1202603282399548, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '6984062', 'n_tokens_mistral': 1900, 'n_tokens_neox': 1753, 'n_words': 316}