UNPKG

nyx_server

Version:

Node内容发布

100 lines (87 loc) 2.71 kB
(function ($, lib, conf) { 'use strict'; var doc = document; var win = window; var BannerSortTool = function () { this.init(); }; BannerSortTool.prototype = { init: function () { this.initParams(); this.initLayout(); this.initEvent(); }, initParams: function () { }, initLayout: function () { this.layout = $('<div class="topic_moveSaveBox t_anim_long" data-topicSystem="true">' + '<span class="topic_moveSaveBox_save" data-action="save" ' + 'data-topicSystem="true"><em>保存</em></span>' + '<span class="topic_moveSaveBox_cancel" data-action="cancel" ' + 'data-topicSystem="true"><em>取消</em></span>' + '</div>'); $(doc.body).append(this.layout); }, initEvent: function () { var _this = this; this.layout.on('click', 'span', function () { var action = $(this).attr('data-action'); _this[action](this); }); }, show: function () { this.layout.addClass('show'); }, hide: function () { this.layout.removeClass('show'); }, save: function (elm) { var bodyList = lib.creatBodyList(); var params = topic_global_params.page; $.ajax({ url: conf.bannerReOrderUrl, type: 'post', dataType: 'json', context: this, data: { bodyList: bodyList, pageId: params.id, // pageVersion: params.version, pageDigest: params.digest }, success: function (msg) { if (msg.code === 1) { // @todo 改成hint提示。 // alert('保存成功'); new topic.module.Hint({ target: elm, scope: this, content: '保存成功' }); this.hide(); topic.state.set('bodyList', bodyList); topic.state.set('isSortBanner', false); // 因为后端对position有顺序要求,需要在做一些改变顺序的操作的时候, // 进行刷新操作。 window.location.reload(); return; } else { alert(msg.msg); } } }); }, cancel: function (elm) { new topic.module.Hint({ content: '确认要取消对通栏排序么?', target: elm, scope: this, type: 'confirm', callback: function () { win.location.reload(); } }); } }; lib.ns('topic.module').BannerSortTool = BannerSortTool; }(topicJquery, topic.utils, topic.conf));