<commit_before>API.Page = new Class({
    
    Implements: Options,
    
    options: {
        filename: '',
        path: ''
    },
    
    initialize: function(options) {
        this.setOptions(options);
        
        if (!this.options.path) this.options.path = this.options.filename;
    },
    
    getID: function() {
        return 'Page-' + this.options.filename.replace(/\//g, '-');
    }
    
});


FlightDeck = Class.refactor(FlightDeck, {

    options: {
        file_selected_class: 'UI_File_Selected',
        file_listing_class: 'tree',
        file_normal_class: 'UI_File_Normal'
    },
    
    initialize: function(options) {
        this.previous(options);
        
        var actions = { add: false, edit: false, remove: false };
        
        API.Tree = new FileTree('PackTree', {
            checkDrag: Function.from(false),
            editable: false,
            actions: actions
        });
        
        

		API.Tree.collapse = new FileTree.Collapse('PackTree', {});
		var top_branch = API.Tree.addBranch({
			'rel': 'directory',
			'title': 'Docs',
			'id': 'lib_branch',
			'class': 'top_branch nodrag'
		}, null, { actions: actions, collapsed: false });
		API.Tree.collapse.prepare();
        
        
        doc_list.forEach(function(page) {
            var p = API.pages[page.filename] = new API.Page(page);
            var el = API.Tree.addPath(p, Object.merge({
               target: top_branch
            }, actions));
            API.Tree.collapse.prepare();
            el.store('page', p);
            if (p.options.selected) {
                
			    this.setSelectedFile(el);
            }
            
        }, this);
        
        $('PackTree').addEvent('click:relay(li:not(top_branch) > .holder > .label)', function(e, label) {
            var page = label.getParent('li').retrieve('page');
            if(page) {
                window.location.href = page.options.get_url;
            }
        });
    },
    
    setSelectedFile: function(el) {
        var options = this.options;
        
        $$('.'+options.file_listing_class+' li')
			.removeClass(options.file_selected_class)
			.addClass(options.file_normal_class);
		
		el.removeClass(options.file_normal_class)
			.addClass(options.file_selected_class);
		
		//also be sure to expand all parent folders
		var tree = API.Tree;
			node = el;
			
		tree.collapse.expand(node);
		
		while (node = node.getParent('li')) {
			tree.collapse.expand(node);
		}
    }
    
});<commit_msg>fixes Bug 640365 - Any doc sidebar API link that is clicked is always shown as an open folder<commit_after>API.Page = new Class({
    
    Implements: Options,
    
    options: {
        filename: '',
        path: ''
    },
    
    initialize: function(options) {
        this.setOptions(options);
        
        if (!this.options.path) this.options.path = this.options.filename;
    },
    
    getID: function() {
        return 'Page-' + this.options.filename.replace(/\//g, '-');
    }
    
});


FlightDeck = Class.refactor(FlightDeck, {

    options: {
        file_selected_class: 'UI_File_Selected',
        file_listing_class: 'tree',
        file_normal_class: 'UI_File_Normal'
    },
    
    initialize: function(options) {
        this.previous(options);
        
        var actions = { add: false, edit: false, remove: false },
			that = this;
        
        API.Tree = new FileTree('PackTree', {
            checkDrag: Function.from(false),
            editable: false,
            actions: actions
        });
        
        

		API.Tree.collapse = new FileTree.Collapse('PackTree', {});
		var top_branch = API.Tree.addBranch({
			'rel': 'directory',
			'title': 'Docs',
			'id': 'lib_branch',
			'class': 'top_branch nodrag'
		}, null, { actions: actions, collapsed: false });
		API.Tree.collapse.prepare();
        
        
        doc_list.forEach(function(page) {
            var p = API.pages[page.filename] = new API.Page(page);
            var el = API.Tree.addPath(p, Object.merge({
               target: top_branch
            }, actions));
            API.Tree.collapse.prepare();
            el.store('page', p);
            if (p.options.selected) {
                
			    this.setSelectedFile(el);
            }
            
        }, this);
        
        $('PackTree').addEvent('click:relay(li:not(top_branch) > .holder > .label)', function(e, label) {
            var page = label.getParent('li').retrieve('page');
            if(page) {
                that.setSelectedFile(label.getParent('li'));
				window.location.href = page.options.get_url;
            }
        });
    },
    
    setSelectedFile: function(el) {
        var options = this.options;
        
        $$('.'+options.file_listing_class+' li')
			.removeClass(options.file_selected_class)
			.addClass(options.file_normal_class);
		
		el.removeClass(options.file_normal_class)
			.addClass(options.file_selected_class);
		
		//also be sure to expand all parent folders
		var tree = API.Tree;
			node = el;
		
		if (node.getElement('li')) {
			tree.collapse.expand(node);
		}
		
		while (node = node.getParent('li')) {
			tree.collapse.expand(node);
		}
    }
    
});
{'fraction_non_alphanumeric': 0.1399691952252599, 'fraction_numerical': 0.0011551790527531767, 'mean_word_length': 1.9450113378684808, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '779536', 'n_tokens_mistral': 1673, 'n_tokens_neox': 1564, 'n_words': 282}