Simplification in explorer
This commit is contained in:
		@@ -234,142 +234,146 @@ jQuery(document).ready(function($)
 | 
			
		||||
            URLGeneration(originalAvailableOptions);
 | 
			
		||||
            updateMenu(availableOptions);
 | 
			
		||||
 | 
			
		||||
            function makeFilterChanges()
 | 
			
		||||
            function handleVisualFilterChanges()
 | 
			
		||||
            {
 | 
			
		||||
                selectedOptions = gatherURLdata();
 | 
			
		||||
                data = originalData;
 | 
			
		||||
                filterData(selectedOptions);
 | 
			
		||||
                availableOptions = [];
 | 
			
		||||
                availableOptions = gatherData();
 | 
			
		||||
                updateMenu(availableOptions);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // handle tags
 | 
			
		||||
            function handleTags()
 | 
			
		||||
            {
 | 
			
		||||
                $('input[name="tags"]').change(function()
 | 
			
		||||
                function makeFilterChanges()
 | 
			
		||||
                {
 | 
			
		||||
                    params["tag"] = []; // remove filter
 | 
			
		||||
                    if (this.checked)
 | 
			
		||||
                    {
 | 
			
		||||
                        $('select[name="tag"] option[value=""]').prop('selected', true);
 | 
			
		||||
                        $('select[name="tag"]').attr('disabled', 'disabled');
 | 
			
		||||
                        $(".box.tags span:not(.first) select").parent().remove();
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                        $('select[name="tag"]').removeAttr('disabled');
 | 
			
		||||
                    selectedOptions = gatherURLdata();
 | 
			
		||||
                    data = originalData;
 | 
			
		||||
                    filterData(selectedOptions);
 | 
			
		||||
                    availableOptions = [];
 | 
			
		||||
                    availableOptions = gatherData();
 | 
			
		||||
                    updateMenu(availableOptions);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                    makeFilterChanges();
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
                $('.box.tags .item-cont').delegate('select[name="tag"]', 'change', function()
 | 
			
		||||
                // handle tags
 | 
			
		||||
                function handleTags()
 | 
			
		||||
                {
 | 
			
		||||
                    params.tag = []; // collect all tags from all dropdowns
 | 
			
		||||
                    $('.box.tags .item-cont select[name="tag"]').each(function()
 | 
			
		||||
                    $('input[name="tags"]').change(function()
 | 
			
		||||
                    {
 | 
			
		||||
                        if (params.tag.indexOf(this.value) === -1 && this.value != "")
 | 
			
		||||
                            params.tag.push(this.value);
 | 
			
		||||
                        params["tag"] = []; // remove filter
 | 
			
		||||
                        if (this.checked)
 | 
			
		||||
                        {
 | 
			
		||||
                            $('select[name="tag"] option[value=""]').prop('selected', true);
 | 
			
		||||
                            $('select[name="tag"]').attr('disabled', 'disabled');
 | 
			
		||||
                            $(".box.tags span:not(.first) select").parent().remove();
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                            $('select[name="tag"]').removeAttr('disabled');
 | 
			
		||||
 | 
			
		||||
                        makeFilterChanges();
 | 
			
		||||
                    });
 | 
			
		||||
                    
 | 
			
		||||
                    if (this.value != "")
 | 
			
		||||
 | 
			
		||||
                    $('.box.tags .item-cont').delegate('select[name="tag"]', 'change', function()
 | 
			
		||||
                    {
 | 
			
		||||
                        createNewElem = true; // if we modify an existing element to a value, we don't delete it
 | 
			
		||||
                        $('.box.tags select').each(function()
 | 
			
		||||
                        params.tag = []; // collect all tags from all dropdowns
 | 
			
		||||
                        $('.box.tags .item-cont select[name="tag"]').each(function()
 | 
			
		||||
                        {
 | 
			
		||||
                            if ($(this).val() == "")
 | 
			
		||||
                                createNewElem = false;
 | 
			
		||||
                            if (params.tag.indexOf(this.value) === -1 && this.value != "")
 | 
			
		||||
                                params.tag.push(this.value);
 | 
			
		||||
                        });
 | 
			
		||||
                        if (createNewElem)
 | 
			
		||||
                        
 | 
			
		||||
                        if (this.value != "")
 | 
			
		||||
                        {
 | 
			
		||||
                            html = '<span><span class="inline">※ </span><select name="tag">';
 | 
			
		||||
                            html += '<option value="">Aucun filtre</option>';
 | 
			
		||||
                            for (a of originalAvailableOptions.tags)
 | 
			
		||||
                                html += '<option value="' + a + '">' + a + '</option>';
 | 
			
		||||
                            html += '</select></span>';
 | 
			
		||||
                            $(".box.tags .item-cont").append(html);
 | 
			
		||||
                            createNewElem = true; // if we modify an existing element to a value, we don't delete it
 | 
			
		||||
                            $('.box.tags select').each(function()
 | 
			
		||||
                            {
 | 
			
		||||
                                if ($(this).val() == "")
 | 
			
		||||
                                    createNewElem = false;
 | 
			
		||||
                            });
 | 
			
		||||
                            if (createNewElem)
 | 
			
		||||
                            {
 | 
			
		||||
                                html = '<span><span class="inline">※ </span><select name="tag">';
 | 
			
		||||
                                html += '<option value="">Aucun filtre</option>';
 | 
			
		||||
                                for (a of originalAvailableOptions.tags)
 | 
			
		||||
                                    html += '<option value="' + a + '">' + a + '</option>';
 | 
			
		||||
                                html += '</select></span>';
 | 
			
		||||
                                $(".box.tags .item-cont").append(html);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                    {
 | 
			
		||||
                        // if the element has no value, we delete it
 | 
			
		||||
                        $(this).parent().remove();
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    makeFilterChanges();
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
            handleTags();
 | 
			
		||||
 | 
			
		||||
            function visualFilterCheckboxItem(name)
 | 
			
		||||
            {
 | 
			
		||||
                $('input[name="' + name + 's"]').change(function()
 | 
			
		||||
                {
 | 
			
		||||
                    params[name] = []; // remove filter
 | 
			
		||||
                    makeFilterChanges();
 | 
			
		||||
                });
 | 
			
		||||
 | 
			
		||||
                $('input[name="' + name + '"]').change(function()
 | 
			
		||||
                {
 | 
			
		||||
                    if (this.checked)
 | 
			
		||||
                    {
 | 
			
		||||
                        if (this.id == "exist") // photos special case
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            params[name].push("bad");
 | 
			
		||||
                            params[name].push("ok");
 | 
			
		||||
                            params[name].push("good");
 | 
			
		||||
                            // if the element has no value, we delete it
 | 
			
		||||
                            $(this).parent().remove();
 | 
			
		||||
                        }
 | 
			
		||||
                        params[name].push(this.id);
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
 | 
			
		||||
                        makeFilterChanges();
 | 
			
		||||
                    });
 | 
			
		||||
                }
 | 
			
		||||
                handleTags();
 | 
			
		||||
 | 
			
		||||
                function visualFilterCheckboxItem(name)
 | 
			
		||||
                {
 | 
			
		||||
                    $('input[name="' + name + 's"]').change(function()
 | 
			
		||||
                    {
 | 
			
		||||
                        if (this.id == "exist") // photos special case
 | 
			
		||||
                        params[name] = []; // remove filter
 | 
			
		||||
                        makeFilterChanges();
 | 
			
		||||
                    });
 | 
			
		||||
 | 
			
		||||
                    $('input[name="' + name + '"]').change(function()
 | 
			
		||||
                    {
 | 
			
		||||
                        if (this.checked)
 | 
			
		||||
                        {
 | 
			
		||||
                            removeFromArray(params[name], "bad");
 | 
			
		||||
                            removeFromArray(params[name], "ok");
 | 
			
		||||
                            removeFromArray(params[name], "good");
 | 
			
		||||
                            if (this.id == "exist") // photos special case
 | 
			
		||||
                            {
 | 
			
		||||
                                params[name].push("bad");
 | 
			
		||||
                                params[name].push("ok");
 | 
			
		||||
                                params[name].push("good");
 | 
			
		||||
                            }
 | 
			
		||||
                            params[name].push(this.id);
 | 
			
		||||
                        }
 | 
			
		||||
                        removeFromArray(params[name], this.id);
 | 
			
		||||
                    }
 | 
			
		||||
                    
 | 
			
		||||
                    makeFilterChanges();
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
                        else
 | 
			
		||||
                        {
 | 
			
		||||
                            if (this.id == "exist") // photos special case
 | 
			
		||||
                            {
 | 
			
		||||
                                removeFromArray(params[name], "bad");
 | 
			
		||||
                                removeFromArray(params[name], "ok");
 | 
			
		||||
                                removeFromArray(params[name], "good");
 | 
			
		||||
                            }
 | 
			
		||||
                            removeFromArray(params[name], this.id);
 | 
			
		||||
                        }
 | 
			
		||||
                        
 | 
			
		||||
                        makeFilterChanges();
 | 
			
		||||
                    });
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
            function visualFilterListItem(name)
 | 
			
		||||
            {
 | 
			
		||||
                $('input[name="' + name + 's"]').change(function()
 | 
			
		||||
                function visualFilterListItem(name)
 | 
			
		||||
                {
 | 
			
		||||
                    params[name] = []; // remove filter
 | 
			
		||||
                    if (this.checked)
 | 
			
		||||
                    $('input[name="' + name + 's"]').change(function()
 | 
			
		||||
                    {
 | 
			
		||||
                        $('select[name="' + name + '"] option[value=""]').prop('selected', true);
 | 
			
		||||
                        $('select[name="' + name + '"]').attr('disabled', 'disabled');
 | 
			
		||||
                    }
 | 
			
		||||
                    else
 | 
			
		||||
                        $('select[name="' + name + '"]').removeAttr('disabled');
 | 
			
		||||
                        params[name] = []; // remove filter
 | 
			
		||||
                        if (this.checked)
 | 
			
		||||
                        {
 | 
			
		||||
                            $('select[name="' + name + '"] option[value=""]').prop('selected', true);
 | 
			
		||||
                            $('select[name="' + name + '"]').attr('disabled', 'disabled');
 | 
			
		||||
                        }
 | 
			
		||||
                        else
 | 
			
		||||
                            $('select[name="' + name + '"]').removeAttr('disabled');
 | 
			
		||||
 | 
			
		||||
                    makeFilterChanges();
 | 
			
		||||
                });
 | 
			
		||||
                        makeFilterChanges();
 | 
			
		||||
                    });
 | 
			
		||||
 | 
			
		||||
                $('select[name="' + name + '"]').change(function()
 | 
			
		||||
                {
 | 
			
		||||
                    if (this.value == "" && name == "place")
 | 
			
		||||
                        params[name].pop();
 | 
			
		||||
                    else
 | 
			
		||||
                        params[name].push(this.value);
 | 
			
		||||
                    $('select[name="' + name + '"]').change(function()
 | 
			
		||||
                    {
 | 
			
		||||
                        if (this.value == "" && name == "place")
 | 
			
		||||
                            params[name].pop();
 | 
			
		||||
                        else
 | 
			
		||||
                            params[name].push(this.value);
 | 
			
		||||
 | 
			
		||||
                    makeFilterChanges();
 | 
			
		||||
                });
 | 
			
		||||
                        makeFilterChanges();
 | 
			
		||||
                    });
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                visualFilterCheckboxItem("photo");
 | 
			
		||||
                visualFilterCheckboxItem("year");
 | 
			
		||||
                visualFilterCheckboxItem("month");
 | 
			
		||||
                visualFilterCheckboxItem("genre");
 | 
			
		||||
                visualFilterCheckboxItem("theme");
 | 
			
		||||
                visualFilterCheckboxItem("dimension");
 | 
			
		||||
                visualFilterCheckboxItem("help");
 | 
			
		||||
                visualFilterListItem("place");
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            visualFilterCheckboxItem("photo");
 | 
			
		||||
            visualFilterCheckboxItem("year");
 | 
			
		||||
            visualFilterCheckboxItem("month");
 | 
			
		||||
            visualFilterCheckboxItem("genre");
 | 
			
		||||
            visualFilterCheckboxItem("theme");
 | 
			
		||||
            visualFilterCheckboxItem("dimension");
 | 
			
		||||
            visualFilterCheckboxItem("help");
 | 
			
		||||
            visualFilterListItem("place");
 | 
			
		||||
            handleVisualFilterChanges();
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
/*********************/
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user