Subversion Repositories SmartDukaan

Rev

Rev 12112 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<html>
<head>
<title>Private Deal Items</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
    $('#btnRight').live('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();
    });

    $('#btnLeft').live('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;
    }
   );
   $.post(/Support/news-letter!createPrivateDealsNewsLetter,{ '_Catalogids[]': Catalogids }, function(data){
          console.log(data);
    },'html');
}
</script>
</head>
<body>
<input id="textbox" type="text" /><br />        
<table style="width: 100%">
<tr>
    <td style='width:300px;'align = 'left'>
           <b>Active Private Deal Items :</b><br/>
           <select multiple="multiple" id='lstBox1' width='100%'>
                        #set($items = $action.getPrivateDealItems())
                        #foreach ( $item in $items )
                                  <option value="$item.getCatalogItemId()">$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' id='btnRight' value ='  >  '/>
        <br/><input type='button' id='btnLeft' value ='  <  '/>
    </td>
    <td style='width:300px;' align = 'right' width='100%'>
        <b>Selected Active Deal Items :</b><br/>
        <select multiple="multiple" id='lstBox2'>
        </select>
    </td>
</tr>
<button type="button" onclick="StoreSubTypes()">Generate NewsLetter</button>
</table>
</body>
</html>