{% block addTag %}
    <style>
        #tagList > tbody > tr > td {
            text-align: center;
            padding: 12px;
            border: 0;
        }
        #tagList > tbody > tr > td > span {
            border-radius: 50px;
            border: 1px solid #e5e5e5;
            padding: 5px 10px;
        }
        #tagList > tbody > tr > td > span:active {
            border-color: #1b9af7;
        }
    </style>
    <!-- 房源特色出层 -->
    <div class="modal fade" id="houseFeature" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
        <div class="modal-dialog" role="document" style="position: absolute;top: 0;bottom: 0;left: 0;right: 0;	margin: auto;height: 232px;overflow-y: auto;overflow-x: hidden;">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title"></h4>
                </div>
                <div id="featureTable">
                    <table class="table" id="tagList" style="table-layout:fixed;">
                    </table>
                </div>
            </div>
        </div>
    </div>
    <script>
        var search_type;
        var search_callback;
        var tagList;
        $(document).ready(function () {
            tagList = $('#tagList');
            $("#houseFeature").on("show.bs.modal", function () {
                tagList.html('');
                $.ajax({
                    type: "POST",
                    url: "/tospur/wp-admin/admin-ajax.php",
                    data: "action=searchTagOrFeature&type=" + search_type,
                    success: function (data) {
                        var tr,lastIndex;
                        $.each(data, function (index, item) {
                            if (index % 4 == 0) {
                                tr = $('<tr>');
                            }
                            tr.append('<td><span id="' + item.id + '">' + item.value + '</span></td>');
                            tagList.append(tr);
                            lastIndex = index;
                        });
                        for(var i = 0;i<=4-tr.find("td").length;i++){
                            tr.append('<td></td>');
                        }
                    }
                });
            });
            tagList.on("click", "tr > td > span", function () {
                if($(this).attr('id') != null){
                    search_callback($(this).attr('id'), $(this).text());
                }
            });
            existsCancel();
        });
        function init_modal_addTag(type, callback) {
            search_type = type;
            search_callback = callback;
            var houseTag = $('#houseFeature');
            var title = (search_type == 0) ? '标签' : '特色';
            houseTag.find('h4').text(title);
            houseTag.modal('show');
        }
    </script>
{% endblock %}