<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>template.con_art_overview.html</title>
{_META_HEAD_CONTENIDO_}
{_CSS_HEAD_CONTENIDO_}
{_JS_HEAD_CONTENIDO_}
    <link rel="stylesheet" type="text/css" href="styles/jquery/plugins/tipsy.css">
    <script type="text/javascript" src="scripts/rowMark.js"></script>
    <script type="text/javascript" src="scripts/articleObject.js.php?contenido={_SID_}"></script>
    <script type="text/javascript" src="scripts/jquery/plugins/tipsy.js"></script>
    <script type="text/javascript" src="scripts/registerTipsy.js"></script>
</head>
<body style="margin:10px">
    <form action ="main.php" name="bulk_editing" class="bulk_editing_form" method="post">
        <input type="hidden" name="area" value="con">
        <input type="hidden" name="action" value="">
        <input type="hidden" name="frame" value="4">
        <input type="hidden" name="idcat" value="{IDCAT}">
        <input type="hidden" name="contenido" value="{_SID_}">
        <input type="hidden" name="idarts" value="">
        <input type="hidden" name="invert" value="">
        <input type="hidden" name="next" value="{NEXT}">
        <input type="hidden" name="sourcelanguage" value="{SOURCELANGUAGE}">
        <input type="hidden" name="syncoptions" value="{SYNCOPTIONS}">
    </form>
    <div class="text_large">
        {CATEGORY}
    </div>
    {CATTEMPLATE}

    <!-- header -->
    <table width="100%" cellspacing="0" cellpadding="2" border="0">
        <tr>
            <td colspan="12">
                <img src="images/spacer.gif" width="1" height="10" alt="">
            </td>
        </tr>
        <tr valign="middle">
            <td colspan="4" class="text_medium" style="padding-right: 5px;border: 1px solid #B3B3B3;border-right-style: none;background-color: #E2E2E2">
                <table cellspacing="0" cellpadding="0" border="0">
                    <tr>
                        <td>
                            {NEWARTICLE_IMG}
                        </td>
                        <td>
                            &nbsp;
                        </td>
                        <td>
                            {NEWARTICLE_TEXT}
                        </td>
                    </tr>
                </table>
            </td>
            <td align="right" class="text_medium" colspan="10" style="border: 1px solid #B3B3B3;border-left-width: 0;background-color: #E2E2E2">
                {ELEMPERPAGECAPTION} {ELEMPERPAGE}
            </td>
        </tr>
        <tr>
            <td colspan="12">
                <img src="images/spacer.gif" width="1" height="10" alt="">
            </td>
        </tr>{NOTIFICATION}
    </table>
    <!-- /header -->

    <!-- flip section -->
    <table width="100%" cellspacing="0" cellpadding="2" border="0" style="{NOARTICLE_CSS}">
        <tr valign="middle">
            <td style="height:20px; line-height:20px; text-align:right; border: 1px solid #B3B3B3;background-color: #E2E2E2;" colspan="7">
                <a class="flip_mark" href="javascript:void(0)"><img alt="i18n('Flip selection')" title="i18n('Flip Selection')" src="images/but_invert_selection.gif"> i18n("Flip selection")</a>
                <div class="bulk_editing_functions">
                    i18n("Apply to all selected articles"):
                    {BULK_EDITING_FUNCTIONS}
                </div>
                {BROWSE}
            </td>
        </tr>
        <tr height="10">
            <td colspan="7">
            </td>
        </tr>
    </table>
    <!-- /flip section -->

    <!-- article list -->
    <table class="generic generic_art_overwiew" width="100%" border="0" cellspacing="0" cellpadding="2">
        <tr>
            {HEADERS}
        </tr>
        <!-- BEGIN:BLOCK -->
        <tr id="{ROWID}" {CSS_CLASS} onmouseover="artRow.over(this)" onmouseout="artRow.out(this)" onclick="artRow.click(this)">
            {CELLS}
        </tr>
        <!-- END:BLOCK -->
    </table>
    <!-- /article list -->

    <!-- flip section -->
    <table width="100%" cellspacing="0" cellpadding="2" border="0" style="{NOARTICLE_CSS}">
        <tr height="10">
            <td colspan="7">
            </td>
        </tr>
        <tr valign="middle">
            <td style="height:20px; line-height:20px; text-align:right; border: 1px solid #B3B3B3;background-color: #E2E2E2;" colspan="7">
                <a class="flip_mark" href="javascript:void(0)"><img alt="i18n('Flip selection')" title="i18n('Flip Selection')" src="images/but_invert_selection.gif"> i18n("Flip selection")</a>
                <div class="bulk_editing_functions">
                    i18n("Apply to all selected articles"):
                    {BULK_EDITING_FUNCTIONS}
                </div>
            </td>
        </tr>
        <tr height="10">
            <td colspan="7">
            </td>
        </tr>
    </table>
    <!-- /flip section -->

    <!-- footer -->
    <table width="100%" cellspacing="0" cellpadding="2" border="0">
        <tr>
            <td>
                <img src="images/spacer.gif" width="1" height="10" alt="">
            </td>
        </tr>
        <tr class="text_medium" style="background-color: #ffffff;">
            <td style="border: 1px solid #B3B3B3;border-right-width: 0;background-color: #E2E2E2; color:#666666">
               {CLICK_ROW_NOTIFICATION}
            </td>
            <td style="border: 1px solid #B3B3B3;border-left-width: 0;background-color: #E2E2E2; text-align:right;">
                 {BROWSE}
            </td>
        </tr>
    </table>
    <!-- /footer -->

<script type="text/javascript">

Con.markSubmenuItem('c_0');

var rcount = 0;
var artObj;

initValues();

function initValues() {

    // create a reference to the Article Object in frame 'right_top'
    artObj = Con.getFrame('left_top').artObj;

    // Reset article object properties. e.g. Some article was edited and we are
    // now back in the overview mask. There is now no marked article, the
    // articleObject data should be reset.
    if (artObj) {
        artObj.reset();
        artObj.enable();
        artObj.setHrefOverview(document.location.href);
        // save current page selection
        artObj.next = {NEXT};
    }

    // timeout to call the function afer 250ms
    window.setTimeout(function() {
        createReference();
    }, 250);

}

/**
 * Javascript-Error work-around... try to create the reference after
 * 250ms again... and hope it works..
 */
function createReference() {

    if (!artObj) {
        artObj = Con.getFrame('left_top').artObj;
        if (artObj) {
            artObj.reset();
            artObj.enable();
            artObj.setHrefOverview(document.location.href);
            // save current page selection
            artObj.next = {NEXT};
        }
    }

    if (!artObj) {
        return false;
    }

}

/**
 * Extract data from the article grid and send them to the articleObject instance.
 * The data is stored in the attribute 'id' of the row object.
 */
function conArtOverviewExtractData(obj) {

    if (!artObj) {
        var rval = createReference();
        if (rval == false) {
            return false;
        }
    }

    var datastring  = obj.id;
    var data        = datastring.split("-");

    if (data.length == 6) {
        // Send data to articleObject instance:
        //    0: idart
        //    1: idartlang
        //    2: idcat
        //    3: idcatlang
        //    5: idcatart
        artObj.setProperties(data[0], data[1], data[2], data[3], data[4], data[5]);
    }

    return true;

}

function changeElemPerPage(selObj) {
    var url = '{SELF_URL}';
    var i = selObj.selectedIndex;
    var elemperpage = selObj.options[i].value;
    window.location.href = url + '&elemperpage=' + elemperpage;
}

/**
 * Function for deleting articles
 */
function deleteArticle(idart, idcat, next) {
    Con.multiLink(
        'right_bottom', "main.php?area=con&action=con_deleteart&frame=4&idcat=" + idcat + "&idart=" + idart + "&next=" + next + "&contenido=" + Con.sid,
        'right_top', 'main.php?area=con&action=deleteArt&frame=3&idcat=' + idcat + '&idtpl={IDTPL}&display_menu={DISPLAY_MENU}&syncoptions={SYNCOPTIONS}&contenido=' + Con.sid
    );
}

/**
 * execute the delete action
 */
function deleteArticles() {
    doAction($('div.bulk_editing_functions a.con_deleteart'));
}

function doAction(thisObject) {

    var action = '';
    if (thisObject.hasClass('invert')) {
        $('form.bulk_editing_form input[name="invert"]').val('1');
        if (thisObject.hasClass('con_makeonline')) {
            action = 'con_makeonline';
        }
        if (thisObject.hasClass('con_lock')) {
            action = 'con_lock';
        }
    } else {
        action = thisObject.attr('class');
    }

    // set action
    $('form.bulk_editing_form input[name="action"]').val(action);

    // collect all selected idarts
    var selectedIdArts = '[';
    $('input.mark_articles:checked').each(function(index, value) {
        selectedIdArts += $(this).val() + ',';
    });
    selectedIdArts = selectedIdArts.substring(0, selectedIdArts.length - 1);
    selectedIdArts += ']';

    // set all selected idarts
    $('form.bulk_editing_form input[name="idarts"]').val(selectedIdArts);

    // send form
    $('form.bulk_editing_form').submit();

}

function saveInlineEditArt() {

    var inlinedata = [];

    $('input.mark_articles:checked').each(function(index, value) {

        var tr = $(this).closest('tr');

        var tempData = [];
        tempData['idart'] = $(this).val();
        tempData['title'] = $.trim(tr.find('input[name="title"]').val());
        tempData['index'] = $.trim(tr.find('input[name="index"]').val());

        inlinedata.push(tempData);
    });

    var params = "";
    for (var i = 0; i<inlinedata.length; i++) {
        params += "&fields["+i+"][idart]=" + inlinedata[i]['idart'];
        params += "&fields["+i+"][title]=" + inlinedata[i]['title'];
        params += "&fields["+i+"][index]=" + inlinedata[i]['index'];
    }
    params += '&ajax=inlineeditart'

    $.post("ajaxmain.php", params, function(data) {
        document.location = document.location;
    });

}

$('input.mark_articles').on('change', function() {
    if ($(this).is(':checked')) {
        if ($('.bulk_editing_functions .con_inlineeditart').hasClass('con_inlinesaveart')) {
            doInlineEditArt();
        }
    }
});

function doInlineEditArt() {

    $('input.mark_articles:checked').each(function() {

        if (!$('.bulk_editing_functions .con_inlineeditart').hasClass('con_inlinesaveart')) {

            $('.bulk_editing_functions .con_inlineeditart')
                .addClass('con_inlinesaveart')
                .find('img')
                    .addClass('img-edit')
                    .hide();

            var saveImg = $('<img />').attr({
                'class': 'img-save',
                'src': 'images/save.gif',
                'alt': '{SAVE_ARTICLES}',
                'title': '{SAVE_ARTICLES}'
            });

            $('.bulk_editing_functions .con_inlineeditart').append(saveImg);

        }

        // dom path to td
        var tds = $(this).closest('tr').find('td');

        // edit title
        var title = tds.eq(2).find('a');
        if (!title.next().length) {
            title.hide();
            title.parent().append($('<input type="text" name="title" value="' + title.html() + '" />'));
        }

        // edit index
        var index = tds.eq(5);
        if (!index.find('input').length) {
            index.html('<input type="text" name="index" data-value="'+index.html()+'" value="' + index.html() + '" />');
        }

        $(this).off('click.markarticles').on('click.markarticles', function() {

            if ($(this).prop('checked') === false) {

                $(this).closest('tr').find('input').each(function() {
                    if ($(this).attr('name') === 'title') {
                        $(this).prev().show();
                        $(this).remove();
                    } else if ($(this).attr('name') === 'index') {
                        $(this).parent().html($(this).attr('data-value'));
                    }
                });

                var cbChecked = false;
                $(this).closest('table').find('input.mark_articles').each(function() {
                    if ($(this).is(':checked')) {
                        cbChecked = true;
                        return false;
                    }
                });

                if (cbChecked === false) {
                    var inlineEditArt = $('.bulk_editing_functions .con_inlineeditart');
                    inlineEditArt.removeClass('con_inlinesaveart');
                    inlineEditArt.find('img.img-save').remove();
                    inlineEditArt.find('img.img-edit').show();
                }

            }

        });

     });

    $('.generic.generic_art_overwiew').off('keypress').on('keypress', function (event) {
        if (event.which === 13) {
            saveInlineEditArt();
        }
    });

}

(function(Con, $) {

    // mark first row in article list
    var firstRow = $("table.generic_art_overwiew tr[id]")[0];
    if (firstRow) {
        artRow.reset();
        artRow.over(firstRow);
        artRow.click(firstRow);
    }

    $(function() {

        // On properties action click
        $('#properties').click(function() {
            Con.markSubmenuItem('c_1');
        });

        // show mark function or hide
        $('input.mark_articles').click(function() {
            $('div.bulk_editing_functions').hide();
            if ($(this).prop('checked')) {
                $('div.bulk_editing_functions').show();
            } else if ($('input.mark_articles:checked').length > 0) {
                $('div.bulk_editing_functions').show();
            }
        });

        // On flip mark click
        $('a.flip_mark').click(function() {
            $('div.bulk_editing_functions').hide();
            $('input.mark_articles').each(function() {
                if ($(this).prop('checked')) {
                    $(this).prop('checked', false);
                } else {
                    $('div.bulk_editing_functions').show();
                    $(this).prop('checked', true);
                }
            });
        });

        // On bulk editing functions click
        $('div.bulk_editing_functions a').click(function() {
            if ($(this).hasClass('con_inlinesaveart')) {
                // inline editing (save)
                saveInlineEditArt();
            } else if ($(this).hasClass('con_inlineeditart')) {
                // inline editing
            	doInlineEditArt();
            } else if (!$(this).hasClass('con_deleteart')) {
                // action delete article has a security prompt, so do nothing here
                doAction($(this));
            }
            return false;
        });

        // On category path link click
        $("div#categorypath > a").click(function() {
            if ($(this).attr("disabled") !== undefined) {
                return false;
            }
            var url = $(this).attr('href'),
                params = Con.UtilUrl.getParams(url);
            Con.multiLink(
                'right_top', 'main.php?area=con&frame=3&idcat=' + params.idcat + '&idtpl=' + params.idtpl + '&display_menu={DISPLAY_MENU}&syncoptions={SYNCOPTIONS}&contenido=' + Con.sid,
                'right_bottom', url,
                'left_bottom', 'main.php?area=con&frame=2&idcat=' + params.idcat + '&idtpl=' + params.idtpl + '&contenido=' + Con.sid
            );
            return false;
        });

        // if no article exists
        var bNoArticle = {NOARTICLE_JS};
        if (bNoArticle) {

            $("a#newArtTxt").click(function() {
                var url = $(this).attr('href');
                Con.multiLink(
                    'right_bottom', url+ '&idtpl=' + {IDTPL} + '&display_menu={DISPLAY_MENU}&syncoptions={SYNCOPTIONS}&contenido=' + Con.sid + '&bNoArticle='+bNoArticle,
                    'right_top', 'main.php?area=con&frame=3&idcat=' + {IDCAT} + '&idtpl=' + {IDTPL} + '&display_menu={DISPLAY_MENU}&syncoptions={SYNCOPTIONS}&contenido=' + Con.sid + ''+'&bNoArticle='+bNoArticle
                );
                Con.markSubmenuItem('c_1');
                return false;
            });

            $("a#newArtImg").click(function() {
                $("a#newArtTxt").click();
            });

        }

    });

})(Con, Con.$);

</script>
</body>
</html>

<!--
template.con_art_overview

i18n("Flip selection")
i18n("Apply to all selected articles")
i18n("Set articles online")
i18n("Set articles offline")
i18n("Freeze articles")
i18n("Unfreeze articles")
i18n("Copy article to the current language")
i18n("Delete articles")
-->
