operations.category.Index.js 8.19 KB
webpackJsonp([100],{

/***/ 0:
/***/ function(module, exports, __webpack_require__) {

	/**
	 * Created by ty on 2016/5/26.
	 */

	var $ = __webpack_require__(1),
	    common = __webpack_require__(2);
	__webpack_require__(65);

	new common.dropDown({el: "#status"});
	new common.dropDown({el: "#platform"});

	var Bll = {
	    initGrid: function () {
	        common.util.__ajax({
	            async: false,
	            url: "/category/getCategoryList",
	            data: {
	                platform: common.util.__input("platform"),
	                status: common.util.__input("status")
	            }
	        },function(res) {
	            $("#basicTable").html(common.util.__template2($("#grid-template").html(), res));
	            $('#author_id, #article_gender, #status,#tag,#is_hot,#platform').select2();
	            $('#nestable').nestable();
	            $('.dd').nestable('collapseAll');
	            $('div[data-toggle="category"]').on('click', function(){
	                var sort_id = $(this).parent().data('id');
	                $('#addModalBox').on('click', function(){
	                    $.get('/cmsproduct/sortattribute/attribute', {sort_id : sort_id}, function(html){
	                        $('.modal-dialog').html(html);
	                        $('#addModal').modal();
	                        $('#attribute_id').select2();
	                        $('#addAttribute').on('click', function(){
	                            var attribute_id = $('#attribute_id').val();
	                            var _text = $('#attribute_id option:selected').text();
	                            var _count = $('#attributeBox tr').length;
	                            var _html = '<tr><td>'+_text+'<input type="hidden" name="data['+_count+'][attribute_id]" value="'+attribute_id+'" /></td><td><input type="text" name="data['+_count+'][order_by]" style="height:28px;width:60px;" value="" /></td></tr>';
	                            $('#attributeBox').append(_html);
	                        });
	                    });
	                });
	            });
	        }, true);
	    }
	}

	Bll.initGrid();

	$(document).on("click", "#filter-btn", function () {
	    Bll.initGrid();
	});

	$(document).on("click", ".updateStatus", function() {
	    var id  = $(this).data("id");
	    var status = $(this).data("status");
	    common.util.__ajax({
	        url: "/category/updateCategoryStatus",
	        data: {
	            id:id,
	            status: status
	        }
	    },function() {
	        Bll.initGrid();
	    });
	});

/***/ },

/***/ 65:
/***/ function(module, exports, __webpack_require__) {

	/*!
	 * Nestable jQuery Plugin - Copyright (c) 2012 David Bushell - http://dbushell.com/
	 * Dual-licensed under the BSD or MIT licenses
	 */
	var jQuery = __webpack_require__(1);

	;(function($, window, document, undefined)
	{
	    var hasTouch = 'ontouchstart' in window;

	    /**
	     * Detect CSS pointer-events property
	     * events are normally disabled on the dragging element to avoid conflicts
	     * https://github.com/ausi/Feature-detection-technique-for-pointer-events/blob/master/modernizr-pointerevents.js
	     */

	    var defaults = {
	        listNodeName    : 'ol',
	        itemNodeName    : 'li',
	        rootClass       : 'dd',
	        listClass       : 'dd-list',
	        itemClass       : 'dd-item',
	        dragClass       : 'dd-dragel',
	        handleClass     : 'dd-handle',
	        collapsedClass  : 'dd-collapsed',
	        placeClass      : 'dd-placeholder',
	        noDragClass     : 'dd-nodrag',
	        emptyClass      : 'dd-empty',
	        expandBtnHTML   : '<button data-action="expand" type="button">Expand</button>',
	        collapseBtnHTML : '<button data-action="collapse" type="button">Collapse</button>',
	        group           : 0,
	        maxDepth        : 5,
	        threshold       : 20
	    };

	    function Plugin(element, options)
	    {
	        this.w  = $(window);
	        this.el = $(element);
	        this.options = $.extend({}, defaults, options);
	        this.init();
	    }

	    Plugin.prototype = {

	        init: function()
	        {
	            var list = this;

	            list.el.data('nestable-group', this.options.group);

	            list.placeEl = $('<div class="' + list.options.placeClass + '"/>');

	            $.each(this.el.find(list.options.itemNodeName), function(k, el) {
	                list.setParent($(el));
	            });

	            list.el.on('click', 'button', function(e) {
	                if (list.dragEl || (!hasTouch && e.button !== 0)) {
	                    return;
	                }
	                var target = $(e.currentTarget),
	                    action = target.data('action'),
	                    item   = target.parent(list.options.itemNodeName);
	                if (action === 'collapse') {
	                    list.collapseItem(item);
	                }
	                if (action === 'expand') {
	                    list.expandItem(item);
	                }
	            });

	        },

	        serialize: function()
	        {
	            var data,
	                depth = 0,
	                list  = this;
	            step  = function(level, depth)
	            {
	                var array = [ ],
	                    items = level.children(list.options.itemNodeName);
	                items.each(function()
	                {
	                    var li   = $(this),
	                        item = $.extend({}, li.data()),
	                        sub  = li.children(list.options.listNodeName);
	                    if (sub.length) {
	                        item.children = step(sub, depth + 1);
	                    }
	                    array.push(item);
	                });
	                return array;
	            };
	            data = step(list.el.find(list.options.listNodeName).first(), depth);
	            return data;
	        },

	        serialise: function()
	        {
	            return this.serialize();
	        },

	        expandItem: function(li)
	        {
	            li.removeClass(this.options.collapsedClass);
	            li.children('[data-action="expand"]').hide();
	            li.children('[data-action="collapse"]').show();
	            li.children(this.options.listNodeName).show();
	        },

	        collapseItem: function(li)
	        {
	            var lists = li.children(this.options.listNodeName);
	            if (lists.length) {
	                li.addClass(this.options.collapsedClass);
	                li.children('[data-action="collapse"]').hide();
	                li.children('[data-action="expand"]').show();
	                li.children(this.options.listNodeName).hide();
	            }
	        },

	        expandAll: function()
	        {
	            var list = this;
	            list.el.find(list.options.itemNodeName).each(function() {
	                list.expandItem($(this));
	            });
	        },

	        collapseAll: function()
	        {
	            var list = this;
	            list.el.find(list.options.itemNodeName).each(function() {
	                list.collapseItem($(this));
	            });
	        },

	        setParent: function(li)
	        {
	            if (li.children(this.options.listNodeName).length) {
	                li.prepend($(this.options.expandBtnHTML));
	                li.prepend($(this.options.collapseBtnHTML));
	            }
	            li.children('[data-action="expand"]').hide();
	        },

	        unsetParent: function(li)
	        {
	            li.removeClass(this.options.collapsedClass);
	            li.children('[data-action]').remove();
	            li.children(this.options.listNodeName).remove();
	        },

	    };

	    $.fn.nestable = function(params)
	    {
	        var lists  = this,
	            retval = this;

	        lists.each(function()
	        {
	            var plugin = $(this).data("nestable");

	            if (!plugin) {
	                $(this).data("nestable", new Plugin(this, params));
	                $(this).data("nestable-id", new Date().getTime());
	            } else {
	                if (typeof params === 'string' && typeof plugin[params] === 'function') {
	                    retval = plugin[params]();
	                }
	            }
	        });

	        return retval || lists;
	    };

	})(jQuery, window, document);


/***/ }

});