Subversion Repositories SmartDukaan

Rev

Rev 12112 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<html>
<head>
<title>Private Deal Items</title>
<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js"></script>
<script>
$(document).ready(function() {
    $('#btnRight').on('click', function(e) {
        var selectedOpts = $('#lstBox1 option:selected');
        if (selectedOpts.length == 0) {
            alert("Please select an Item.");
            e.preventDefault();
        }

        $('#lstBox2').append($(selectedOpts).clone());
        $(selectedOpts).remove();
        e.preventDefault();
    });
        
        $('#viewSourceCode').on('click', function(e) {
                $('#generated-news-letter').hide();
                $("#source-code").show();
    });
        
        $('#viewHtml').on('click', function(e) {
                $('#generated-news-letter').show();
                $("#source-code").hide();
    });

    $('#btnLeft').on('click', function(e) {
        var selectedOpts = $('#lstBox2 option:selected');
        if (selectedOpts.length == 0) {
            alert("Nothing to move.");
            e.preventDefault();
        }

        $('#lstBox1').append($(selectedOpts).clone());
        $(selectedOpts).remove();
        e.preventDefault();
    });
});
</script>
<script>
    jQuery.fn.filterByText = function(textbox, selectSingleMatch) {
        return this.each(function() {
            var select = this;
            var options = [];
            $(select).find('option').each(function() {
                options.push({value: $(this).val(), text: $(this).text()});
            });
            $(select).data('options', options);
            $(textbox).bind('change keyup', function() {
                var options = $(select).empty().data('options');
                var search = $(this).val();
                var regex = new RegExp(search,"gi");
              
                jQuery.each(options, function(i) {
                    var option = options[i];
                    if(option.text.match(regex) !== null) {
                        $(select).append(
                           $('<option>').text(option.text).val(option.value)
                        );
                    }
                });
                if (selectSingleMatch === true && $(select).children().length === 1) {
                    $(select).children().get(0).selected = true;
                }
            });            
        });
    };

    $(function() {
        $('#lstBox1').filterByText($('#textbox'), true);
    });  
</script>
<script>
function StoreSubTypes()
{
        var _Catalogids = new Array();
    $("#lstBox2 option").each(
    function(index, option)
    {
      _Catalogids[index] = option.value;
    }
   );
          console.log(_Catalogids.toString());
   jQuery.ajax({
                url: window.location.href+"!createPrivateDealsNewsLetter?itemIds="+_Catalogids,
        type: 'POST',
        async: false,
                success : function(response) {
                        $('#generated-news-letter').empty();
                        $("#source-code").text('');
                        $('<iframe id="newsletter-iframe" style="width:100%;height:100%;margin-top:20px;"/>').appendTo('#generated-news-letter')
                          .contents().find('body').append(response);
                        $("#source-code").text(response);
                        $('#generated-news-letter').show();
                        $('#buttons').show();
        },
        cache: false,
        contentType: "application/x-www-form-urlencoded",
        processData: false
    });
    return false;
}
</script>
<style>
        td {
    padding: 20px;
        }
</style>
</head>
<body>
<div style="border: 2px solid blue; height: 10%; padding: 10px; width: 30%;" class="searchBox">
<label style="font-weight: bold; margin-right: 10px;">Search Item</label>
<input type="text" id="textbox" style="width: 50%;">    
</div>
<table style="width: 100%; border: 2px solid blue; margin-top: 20px;">
<tr>
    <td style='min-width:300px;'align = 'left'>
           <b>Active Private Deal Items :</b><br/>
           <select multiple="multiple" id='lstBox1' style="width:100%">
                        #set($items = $action.getPrivateDealItems())
                        #foreach ( $item in $items )
                                  <option value="$item.getId()">$item.getId() $item.getBrand() $item.getModelName() $item.getModelNumber() $item.getColor()</option>
                        #end
           </select>
    </td>
    <td style='width:100%;text-align:center;vertical-align:middle;' >
                <input type="button" style="margin-bottom: 15px;" id="btnRight" value="&gt;">
        <br/>
                 <input type="button" value="&lt;" id="btnLeft" style="margin-bottom: 15px;">
                <br/>
                <button onclick="StoreSubTypes()" type="button">Generate NewsLetter</button>
    </td>
    <td align="" width="100%" style="min-width: 300px;">
        <b>Selected Active Deal Items :</b><br/>
        <select id="lstBox2" multiple="multiple" style="width: 100%;">
        </select>
    </td>
</tr>
</table>
<div id="buttons" style="float: right; border: 2px solid blue; display: block;height:50px;margin-top:15px;display:none;">
<button id="viewSourceCode" type="button" style="float: right; margin-top: 15px; margin-right: 10px;">View Source</button>
<button id="viewHtml" type="button" style="float: right; margin: 15px;">View New Letter</button>
</div>
<div id="generated-news-letter" style="margin-top:30px;display:none;">
</div>
<textarea id="source-code" style="width: 100%;height: 100%;font-size: 12px;color:black;font-weight: 14px;font-family: sans-serif;margin-top:20px;display:none;border:2px solid grey;"></textarea>
</body>
</html>