nyx_server
Version:
Node内容发布
149 lines (127 loc) • 4.24 kB
JavaScript
(function ($, lib, conf, topic) {
'use strict';
var win = window;
var resizeTimer = null;
var page = {
init: function () {
// this.initModel();
// this.initClipboard();
this.initEvent();
this.checkWs();
},
// initModel: function () {
// var hash = win.location.hash;
// if (hash === '') {
// return;
// }
// if (hash.indexOf('#bannerEdit') > -1) {
// topic.state.set('pageModel', 'bannerEdit');
// topic.state.set('isDesign', false);
// return;
// }
// if (hash.indexOf('#fragmentEdit') > -1) {
// topic.state.set('pageModel', 'fragmentEdit');
// topic.state.set('isDesign', false);
// return;
// }
// },
// initClipboard: function () {
// localStorage['clipboard'] = '';
// $.ajax({
// url: conf.clipboardQueryUrl,
// dataType: 'json',
// type: 'get',
// context: this,
// success: function (msg) {
// if (msg.code === 1) {
// localStorage['clipboard'] = JSON.stringify(msg.data);
// }
// }
// });
// },
initEvent: function () {
var _this = this;
// @todo 应该将这个事件分散到各自的对象中进行管理。
$(win).on('resize', function () {
clearTimeout(resizeTimer);
resizeTimer = setTimeout(function () {
_this.trigger('resize', topic.state.get('pageModel'));
}, 50);
});
},
checkWs: function () {
var _this = this;
setTimeout(function () {
// 判断webSocket是否连接
if (topic.ws.getConnState() === 'connected') {
_this.checkBannerLock();
} else {
_this.checkWs();
}
}, 500);
},
checkBannerLock: function () {
var pageModel = topic.state.get('pageModel');
if (pageModel === 'bannerEdit') {
topic.ws.lock('page', topic_global_params.page.id, function (data) {
// 这里判断的是系统层面是否有问题
if (data.success) {
/*// 这里判断的是业务方面,该碎片是否被锁定
if (data.data.success || data.data.user.domainName == win.__user_id) {
} else {
alert(data.data.user.userName + '正在通栏编辑模式。');
window.location.hash = 'fragmentEdit';
window.location.reload();
}*/
} else {
alert(data.msg);
}
});
}
},
// // 根据不同状态,对通栏蒙板层和碎片蒙板层进行切换。
// changeModel: function (modelName) {
// this.currentModel = modelName;
// win.location.hash = modelName;
// switch (modelName) {
// case 'fragmentDesign':
// topic.state.set('isDesign', true);
// // topic.fragmentDesign.enable();
// topic.bannerGroup.layoutHideAll();
// topic.fragmentGroup.layoutResetAll();
// break;
// case 'fragmentEdit':
// topic.state.set('isDesign', false);
// // topic.fragmentDesign.disable();
// topic.bannerGroup.layoutHideAll();
// topic.fragmentGroup.layoutResetAll();
// break;
// case 'bannerEdit':
// topic.state.set('isDesign', false);
// // topic.fragmentDesign.disable();
// topic.bannerGroup.layoutResetAll();
// topic.fragmentGroup.layoutHideAll();
// break;
// }
// },
// pageInfoUpdate: function () {
// $.ajax({
// url: conf.pageInfoUrl,
// dataType: 'jsonp',
// type: 'post',
// data: {
// id: topic_global_params.page.id
// },
// success: function (msg) {
// if (msg.code === 1) {
// topic_global_params.page = msg.data;
// } else {
// alert(msg.msg);
// }
// }
// });
// }
};
topic.Events.mixTo(page);
lib.ns('topic').page = page;
}(topicJquery, topic.utils, topic.conf, topic));