<commit_before>/*
 * Copyright 2005-2012 The Kuali Foundation
 *
 * Licensed under the Educational Community License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.opensource.org/licenses/ecl2.php
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
function getSelectedPropositionInput() {
    return jq('input[id="proposition_selected_attribute"]');
}

function getCutPropositionInput() {
    return jq('input[id="proposition_cut_attribute"]');
}

function getPropositionIdFromParentLi(parentLiNode) {
    return jq(parentLiNode).find('input.hiddenId').first().attr('value');
}


function ajaxCallPropositionTree(controllerMethod, collectionGroupId) {

    var collectionGroupDivLocator = '#' + collectionGroupId + '_div';

    var elementToBlock = jq(collectionGroupDivLocator);
    var selectedItemInput = getSelectedPropositionInput();
    var selectedItemId = selectedItemInput.val();
    var selectedItemInputName = selectedItemInput.attr('name');

    var updateCollectionCallback = function(htmlContent){
        var component = jq(collectionGroupDivLocator, htmlContent);

        elementToBlock.unblock({onUnblock: function(){
            //replace component
            if(jq(collectionGroupDivLocator).length){
                jq(collectionGroupDivLocator).replaceWith(component);
            }
            runHiddenScripts(collectionGroupId + '_div');
        }
        });

    };

    ajaxSubmitForm(controllerMethod, updateCollectionCallback,
            {reqComponentId: collectionGroupId, skipViewInit: 'true', selectedItemInputName: selectedItemId},
            elementToBlock);
}

function ajaxCutPropositionTree(controllerMethod, collectionGroupId) {
    jq('a.ruleTreeNode').each( function() {
        var propositionId = getPropositionIdFromParentLi(this.parentNode);
        var selectedItemTracker = getSelectedPropositionInput();
        var selectedItemId = selectedItemTracker.val();
        var cutItemTracker = getCutPropositionInput();

        if (selectedItemId == propositionId) {
            // simulate click, which will mark it
            //jq(this).click();
//            jq(this.parentNode).addClass('ruleCutSelected');
//            jq(this.parentNode).removeClass('ruleBlockSelected');
            cutItemTracker.val(propositionId);
        }
    });
    ajaxCallPropositionTree(controllerMethod, collectionGroupId);
}

function ajaxPastePropositionTree(controllerMethod, collectionGroupId) {
    jq('a.ruleTreeNode').each( function() {
        jq(this.parentNode).removeClass('ruleCutSelected');
    });
    var cutItemTracker = getCutPropositionInput();
    cutItemTracker.val(null);
    ajaxCallPropositionTree(controllerMethod, collectionGroupId);
}

function markNodeAsSelected(parentLiNode) {
    if (!jq(parentLiNode).hasClass('ruleCutSelected')) {
        jq(parentLiNode).addClass('ruleBlockSelected');
    }
    ;
    enableTreeButtons(); // disableButtons.js
    // show hidden edit image link
    jq(parentLiNode).find(".actionReveal").first().show();
}
function handlePropositionNodeClick(parentLiNode) {
    var propositionId = getPropositionIdFromParentLi(parentLiNode);
    var selectedItemTracker = getSelectedPropositionInput();

    // make li show containment of children
    jq('li').each(function() {
        jq(this).removeClass('ruleBlockSelected');
        // hide edit image links
        jq(this.parentNode).find(".actionReveal").hide();
    });

    if (selectedItemTracker.val() == propositionId) {
        // if this item is already selected, deselect it
        selectedItemTracker.val('');
    } else {
        selectedItemTracker.val(propositionId);
        markNodeAsSelected(parentLiNode);
    }
}
function initRuleTree(componentId){

    // binding to tree loaded event
    jq('#' + componentId).bind('loaded.jstree', function (event, data) {
        /* make the tree load with all nodes expanded */
        jq('#' + componentId).jstree('open_all');

        jq('select.categorySelect').change( function() {
            ajaxCallPropositionTree('ajaxRefresh', 'RuleEditorView-Tree')
        });

        jq(this).find(".actionReveal").hide();

        // selecting the description on an edit node should set it to be selected
        jq('input.editDescription').click( function() {

            var parentLiNode = jq(this).closest('li');
            handlePropositionNodeClick(parentLiNode);
        });

        // rule node clicks should set the selected item
        jq('a.ruleTreeNode').click( function() {
            var parentLiNode = this.parentNode;
            handlePropositionNodeClick(parentLiNode);
        });<commit_msg>Proposition selection/unselection button enabling/disabling.<commit_after>/*
 * Copyright 2005-2012 The Kuali Foundation
 *
 * Licensed under the Educational Community License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.opensource.org/licenses/ecl2.php
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
function getSelectedPropositionInput() {
    return jq('input[id="proposition_selected_attribute"]');
}

function getCutPropositionInput() {
    return jq('input[id="proposition_cut_attribute"]');
}

function getPropositionIdFromParentLi(parentLiNode) {
    return jq(parentLiNode).find('input.hiddenId').first().attr('value');
}


function ajaxCallPropositionTree(controllerMethod, collectionGroupId) {

    var collectionGroupDivLocator = '#' + collectionGroupId + '_div';

    var elementToBlock = jq(collectionGroupDivLocator);
    var selectedItemInput = getSelectedPropositionInput();
    var selectedItemId = selectedItemInput.val();
    var selectedItemInputName = selectedItemInput.attr('name');

    var updateCollectionCallback = function(htmlContent){
        var component = jq(collectionGroupDivLocator, htmlContent);

        elementToBlock.unblock({onUnblock: function(){
            //replace component
            if(jq(collectionGroupDivLocator).length){
                jq(collectionGroupDivLocator).replaceWith(component);
            }
            runHiddenScripts(collectionGroupId + '_div');
        }
        });

    };

    ajaxSubmitForm(controllerMethod, updateCollectionCallback,
            {reqComponentId: collectionGroupId, skipViewInit: 'true', selectedItemInputName: selectedItemId},
            elementToBlock);
}

function ajaxCutPropositionTree(controllerMethod, collectionGroupId) {
    jq('a.ruleTreeNode').each( function() {
        var propositionId = getPropositionIdFromParentLi(this.parentNode);
        var selectedItemTracker = getSelectedPropositionInput();
        var selectedItemId = selectedItemTracker.val();
        var cutItemTracker = getCutPropositionInput();

        if (selectedItemId == propositionId) {
            // simulate click, which will mark it
            //jq(this).click();
//            jq(this.parentNode).addClass('ruleCutSelected');
//            jq(this.parentNode).removeClass('ruleBlockSelected');
            cutItemTracker.val(propositionId);
        }
    });
    ajaxCallPropositionTree(controllerMethod, collectionGroupId);
}

function ajaxPastePropositionTree(controllerMethod, collectionGroupId) {
    jq('a.ruleTreeNode').each( function() {
        jq(this.parentNode).removeClass('ruleCutSelected');
    });
    var cutItemTracker = getCutPropositionInput();
    cutItemTracker.val(null);
    ajaxCallPropositionTree(controllerMethod, collectionGroupId);
}

function markNodeAsSelected(parentLiNode) {
    if (!jq(parentLiNode).hasClass('ruleCutSelected')) {
        jq(parentLiNode).addClass('ruleBlockSelected');
    }
    ;
    enableTreeButtons(); // disableButtons.js
    // show hidden edit image link
    jq(parentLiNode).find(".actionReveal").first().show();
}
function handlePropositionNodeClick(parentLiNode) {
    var propositionId = getPropositionIdFromParentLi(parentLiNode);
    var selectedItemTracker = getSelectedPropositionInput();

    // make li show containment of children
    jq('li').each(function() {
        jq(this).removeClass('ruleBlockSelected');
        // hide edit image links
        jq(this.parentNode).find(".actionReveal").hide();
    });

    if (selectedItemTracker.val() == propositionId) {
        // if this item is already selected, deselect it
        selectedItemTracker.val('');
        disableTreeButtons(); // disableButtons.js
        enableAddButton(); // disableButtons.js
        enableRefreshButton(); // disableButtons.js
    } else {
        selectedItemTracker.val(propositionId);
        markNodeAsSelected(parentLiNode);
        enableTreeButtons(); // disableButtons.js
    }
}
function initRuleTree(componentId){

    // binding to tree loaded event
    jq('#' + componentId).bind('loaded.jstree', function (event, data) {
        /* make the tree load with all nodes expanded */
        jq('#' + componentId).jstree('open_all');

        jq('select.categorySelect').change( function() {
            ajaxCallPropositionTree('ajaxRefresh', 'RuleEditorView-Tree')
        });

        jq(this).find(".actionReveal").hide();

        // selecting the description on an edit node should set it to be selected
        jq('input.editDescription').click( function() {

            var parentLiNode = jq(this).closest('li');
            handlePropositionNodeClick(parentLiNode);
        });

        // rule node clicks should set the selected item
        jq('a.ruleTreeNode').click( function() {
            var parentLiNode = this.parentNode;
            handlePropositionNodeClick(parentLiNode);
        });
{'fraction_non_alphanumeric': 0.10977751756440281, 'fraction_numerical': 0.002146760343481655, 'mean_word_length': 3.5129898723029505, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6261936', 'n_tokens_mistral': 2705, 'n_tokens_neox': 2587, 'n_words': 597}