123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762 |
- MWF.xApplication.HotArticle.options.multitask = false;
- MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
- MWF.xDesktop.requireApp("Template", "MForm", null, false);
- MWF.xApplication.HotArticle.Main = new Class({
- Extends: MWF.xApplication.Common.Main,
- Implements: [Options, Events],
- options: {
- "style1": "default",
- "style": "default",
- "name": "HotArticle",
- "mvcStyle": "style.css",
- "icon": "icon.png",
- "title": MWF.xApplication.HotArticle.LP.title,
- "key" : ""
- },
- onQueryLoad: function(){
- this.lp = MWF.xApplication.HotArticle.LP;
- this.action = o2.Actions.load("x_hotpic_assemble_control");
- },
- loadApplication: function(callback){
- var url = this.path+this.options.style+"/view/view.html";
- this.content.loadHtml(url, {"bind": {"lp": this.lp,"data":{}}, "module": this}, function(){
- this.setLayout();
- this.loadList("all");
- if (callback) callback();
- }.bind(this));
- },
- loadList: function(type){
- if (this.currentMenu) this.setMenuItemStyleDefault(this.currentMenu);
- this.setMenuItemStyleCurrent(this[type+"MenuNode"]);
- this.currentMenu = this[type+"MenuNode"];
- this._loadListContent(type);
- },
- _loadListContent: function(type){
- this.mainNode.empty();
- list = new MWF.xApplication.HotArticle[type.capitalize() +"List"](this.mainNode,this, {
- "onLoadData": function (){
- this.hideSkeleton();
- },
- "type" : type,
- "key" : this.options.key
- });
- this.currentList = list;
- },
- setMenuItemStyleDefault: function(node){
- node.removeClass("mainColor_bg_opacity");
- node.getFirst().removeClass("mainColor_color");
- node.getLast().removeClass("mainColor_color");
- },
- setMenuItemStyleCurrent: function(node){
- node.addClass("mainColor_bg_opacity");
- node.getFirst().addClass("mainColor_color");
- node.getLast().addClass("mainColor_color");
- },
- setLayout: function(){
- },
- recordStatus: function(){
- // return {"navi": this.currentList.options.type};
- }
- });
- MWF.xApplication.HotArticle.List = new Class({
- Implements: [Options, Events],
- options: {
- "type": "all",
- "defaultViewType" : "list",
- "key" : ""
- },
- initialize: function (node,app, options) {
- this.setOptions(options);
- this.app = app;
- this.container = node;
- this.lp = this.app.lp;
- this.action = app.action;
- this.type = this.options.type;
- var url = this.app.path + this.app.options.style + "/view/content.html";
- this.container.loadHtml(url, {"bind": {"lp": this.lp,"data":{"type":this.type}}, "module": this}, function(){
- this.content = this.listContentNode;
- this.bottomNode = this.listBottomNode;
- this.pageNode = this.pageNumberAreaNode;
- this.init();
- this.load();
- }.bind(this));
- },
- showSkeleton: function(){
- if (this.skeletonNode) this.skeletonNode.inject(this.listContentNode);
- },
- hideSkeleton: function(){
- if (this.skeletonNode) this.skeletonNode.dispose();
- },
- inputFilter: function(e){
- if (e.keyCode==13) this.doFilter();
- },
- doFilter: function(){
- var key = this.searchKeyNode.get("value");
- this.searchKeyNode.set("value","");
- this.app.options.key = key;
- this.app.loadList("all");
- },
- loadListTitle : function (){
- this.listTitleNode.empty();
- this.listTitleNode.loadHtml(this.titleTempleteUrl, {"bind": {"lp": this.lp}, "module": this}, function(){
- this.currentSortNode = this.sortUpdateTimeNode;
- this.currentSortKey = "name";
- }.bind(this));
- },
- selectAllFile : function (e){
- if (e.currentTarget.get("disabled").toString()!="true"){
- var itemNode = e.currentTarget.getParent(".listItem");
- var iconNode = e.currentTarget.getElement(".selectFlagIcon");
- if (itemNode){
- if (itemNode.hasClass("mainColor_bg_opacity")){
- itemNode.removeClass("mainColor_bg_opacity");
- iconNode.removeClass("iconfont-workCompleted");
- iconNode.removeClass("selectFlagIcon_select");
- iconNode.removeClass("mainColor_color");
- this.listContentNode.getElements(this.toolbar.options.viewType === "list"?"tr":".listItem").each(function (tr){
- tr.removeClass("mainColor_bg_opacity");
- var ss = tr.getElement(".selectFlagIcon");
- tr.getElement(".selectFlag").hide();
- ss.removeClass("iconfont-workCompleted");
- ss.removeClass("selectFlagIcon_select");
- ss.removeClass("mainColor_color");
- })
- this.selectedList = [];
- }else{
- itemNode.addClass("mainColor_bg_opacity");
- iconNode.addClass("iconfont-workCompleted");
- iconNode.addClass("selectFlagIcon_select");
- iconNode.addClass("mainColor_color");
- this.listContentNode.getElements(this.toolbar.options.viewType === "list"?"tr":".listItem").each(function (tr){
- tr.getElement(".selectFlag").show();
- tr.addClass("mainColor_bg_opacity");
- var ss = tr.getElement(".selectFlagIcon");
- ss.addClass("iconfont-workCompleted");
- ss.addClass("selectFlagIcon_select");
- ss.addClass("mainColor_color");
- })
- this.selectedList = this.dataList;
- }
- }
- }
- this._setToolBar();
- },
- loadItems: function(data){
- this.dataList = data;
- this.content.loadHtml(this.listTempleteUrl, {"bind": {"lp": this.lp, "type": this.options.type, "data": data}, "module": this}, function(){
- this.node = this.content.getFirst();
- }.bind(this));
- },
- init: function(){
- this.size = 20;
- this.page = 1;
- if(this.options.key!==""){
- var keyContainer = new Element("div.ft_filterItem").inject(this.pathNode);
- new Element("div",{"class":"ft_filterItemTitle mainColor_color","text": this.lp.key + ":"}).inject(keyContainer);
- new Element("div",{"class":"ft_filterItemName","text":this.options.key}).inject(keyContainer);
- var iconNode = new Element("icon",{"class":"iconfont-off ft_filterItemDel"}).inject(keyContainer);
- iconNode.addEvent("click",function (ev){
- ev.target.getParent().hide();
- this.app.options.key = "";
- this.app.loadList(this.options.type);
- }.bind(this))
- }
- },
- _initTempate: function (){
- this.titleTempleteUrl = this.app.path+this.app.options.style+"/view/all/"+this.options.defaultViewType+"_title.html";
- this.listTempleteUrl = this.app.path+this.app.options.style+"/view/all/" +this.options.defaultViewType + ".html";
- },
- load: function(){
- var _self = this;
- this._initToolBar();
- this._initTempate();
- this.loadListTitle();
- this.loadToolBar(this.toolbarItems.unSelect);
- this.selectedList = [];
- this.loadData().then(function(data){
- _self.hide();
- _self.loadItems(data);
- });
- },
- _initToolBar : function (){
- this.toolbarItems = {
- "unSelect":[
- ["rename", "delete"]
- ],
- "selected":[
- ["rename", "delete"]
- ],
- "mulSelect":[
- ["delete"]
- ]
- }
- },
- loadToolBar : function (availableTool){
- this.toolBarNode.empty();
- this.toolbar = new MWF.xApplication.HotArticle.Toolbar(this.toolBarNode, this, {
- viewType : this.options.defaultViewType,
- type : this.type,
- availableTool : availableTool
- });
- this.toolbar.load();
- },
- refresh: function(){
- this.hide();
- this.load();
- },
- hide: function(){
- if (this.node) this.node.destroy();
- },
- loadData: function(){
- var _self = this;
- var data = {}
- if(this.options.key!==""){
- data.title = this.options.key;
- }
- return this.action.HotPictureInfoAction.listForPage(this.page,this.size,data).then(function(json){
- _self.fireEvent("loadData");
- _self.total = json.count;
- _self.loadPage();
- return _self._fixData(json.data);
- });
- },
- _fixData : function (dataList){
- dataList.each(function (data){
- if(data.application === "BBS"){
- data.applicationName = this.lp.bbsHotArticele;
- }
- if(data.application === "CMS"){
- data.applicationName = this.lp.infoHotArticele;
- }
- }.bind(this));
- return dataList;
- },
- overTaskItem: function(e){
- e.currentTarget.addClass("listItem_over");
- var iconNode = e.currentTarget.getElement(".selectFlagIcon");
- if (iconNode.hasClass("selectFlagIcon_select")){
- }else{
- e.currentTarget.getElement(".selectFlag").show();
- }
- },
- outTaskItem: function(e){
- e.currentTarget.removeClass("listItem_over");
- var iconNode = e.currentTarget.getElement(".selectFlagIcon");
- if (iconNode.hasClass("selectFlagIcon_select")){
- }else{
- e.currentTarget.getElement(".selectFlag").hide();
- }
- },
- open: function(id,e){
- var data ;
- for(var i = 0 ; i < this.dataList.length;i++){
- if(this.dataList[i].id === id){
- data = this.dataList[i];
- break ;
- }
- }
- if( data.application == "BBS" ){
- var appId = "ForumDocument"+data.infoId;
- if (this.app.desktop.apps[appId]){
- this.app.desktop.apps[appId].setCurrent();
- }else {
- this.app.desktop.openApplication(null, "ForumDocument", {
- "id" : data.infoId,
- "appId": appId,
- "isEdited" : false,
- "isNew" : false
- });
- }
- }else{
- var appId = "cms.Document"+data.infoId;
- if (this.app.desktop.apps[appId]){
- this.app.desktop.apps[appId].setCurrent();
- }else {
- this.app.desktop.openApplication(null, "cms.Document", {
- "documentId" : data.infoId,
- "appId": appId,
- "readonly" : true
- });
- }
- }
- },
- selectFile: function(id,e, dataList){
- e.stopPropagation()
- var data ;
- for(var i = 0 ; i < this.dataList.length;i++){
- if(this.dataList[i].id === id){
- data = this.dataList[i];
- break ;
- }
- }
- if (e.currentTarget.get("disabled").toString()!="true"){
- var itemNode = e.currentTarget.getParent(".listItem");
- var iconNode = e.currentTarget.getElement(".selectFlagIcon");
- if (itemNode){
- if (itemNode.hasClass("mainColor_bg_opacity")){
- itemNode.removeClass("mainColor_bg_opacity");
- iconNode.removeClass("iconfont-workCompleted");
- iconNode.removeClass("selectFlagIcon_select");
- iconNode.removeClass("mainColor_color");
- this.unselectedFile(data);
- }else{
- itemNode.addClass("mainColor_bg_opacity");
- iconNode.addClass("iconfont-workCompleted");
- iconNode.addClass("selectFlagIcon_select");
- iconNode.addClass("mainColor_color");
- this.selectedFile(data);
- }
- }
- }
- this._setToolBar();
- },
- _setToolBar : function (){
- if(this.selectedList.length === 0 ){
- this.loadToolBar(this.toolbarItems.unSelect);
- } else if (this.selectedList.length === 1){
- this.loadToolBar(this.toolbarItems.selected);
- }else{
- this.loadToolBar(this.toolbarItems.mulSelect);
- }
- },
- selectedFile: function(data){
- if (!this.selectedList) this.selectedList = [];
- var idx = this.selectedList.findIndex(function(t){
- return t.id == data.id;
- });
- if (idx===-1) this.selectedList.push(data);
- },
- unselectedFile: function(data){
- // delete data._;
- if (!this.selectedList) this.selectedList = [];
- var idx = this.selectedList.findIndex(function(t){
- return t.id == data.id;
- });
- if (idx!==-1) this.selectedList.splice(idx, 1);
- },
- loadPage: function(){
- var totalCount = this.total;
- var pages = totalCount/this.size;
- var pageCount = pages.toInt();
- if (pages !== pageCount) pageCount = pageCount+1;
- this.pageCount = pageCount;
- var size = this.bottomNode.getSize();
- var maxPageSize = 500;//size.x*0.8;
- maxPageSize = maxPageSize - 80*2-24*2-10*3;
- var maxPageCount = (maxPageSize/34).toInt();
- this.loadPageNode(pageCount, maxPageCount);
- },
- loadPageNode: function(pageCount, maxPageCount){
- var pageStart = 1;
- var pageEnd = pageCount;
- if (pageCount>maxPageCount){
- var halfCount = (maxPageCount/2).toInt();
- pageStart = Math.max(this.page-halfCount, 1);
- pageEnd = pageStart+maxPageCount-1;
- pageEnd = Math.min(pageEnd, pageCount);
- pageStart = pageEnd - maxPageCount+1;
- }
- this.pageNode.empty();
- var _self = this;
- for (var i=pageStart; i<=pageEnd; i++){
- var node = new Element("div.pageItem", {
- "text": i,
- "events": { "click": function(){_self.gotoPage(this.get("text"));} }
- }).inject(this.pageNode);
- if (i==this.page) node.addClass("mainColor_bg");
- }
- },
- nextPage: function(){
- this.page++;
- if (this.page>this.pageCount) this.page = this.pageCount;
- this.gotoPage(this.page);
- },
- prevPage: function(){
- this.page--;
- if (this.page<1) this.page = 1;
- this.gotoPage(this.page);
- },
- firstPage: function(){
- this.gotoPage(1);
- },
- lastPage: function(){
- this.gotoPage(this.pageCount);
- },
- gotoPage: function(page){
- this.page = page;
- this.hide();
- this.showSkeleton();
- this.load();
- },
- });
- MWF.xApplication.HotArticle.AllList = new Class({
- Extends: MWF.xApplication.HotArticle.List
- });
- MWF.xApplication.HotArticle.CMSList = new Class({
- Extends: MWF.xApplication.HotArticle.AllList,
- loadData: function(){
- var _self = this;
- var data = {}
- if(this.options.key!==""){
- data.title = this.options.key;
- }
- data.application = "CMS";
- return this.action.HotPictureInfoAction.listForPage(this.page,this.size,data).then(function(json){
- _self.fireEvent("loadData");
- _self.total = json.count;
- _self.loadPage();
- return _self._fixData(json.data);
- });
- }
- });
- MWF.xApplication.HotArticle.BBSList = new Class({
- Extends: MWF.xApplication.HotArticle.AllList,
- loadData: function(){
- var _self = this;
- var data = {}
- if(this.options.key!==""){
- data.title = this.options.key;
- }
- data.application = "BBS";
- return this.action.HotPictureInfoAction.listForPage(this.page,this.size,data).then(function(json){
- _self.fireEvent("loadData");
- _self.total = json.count;
- _self.loadPage();
- return _self._fixData(json.data);
- });
- }
- });
- MWF.xApplication.HotArticle.Toolbar = new Class({
- Extends: MWF.widget.Common,
- Implements: [Options, Events],
- options: {
- "style": "default",
- "viewType" : "list",
- "type" : "all"
- },
- initialize : function( container, explorer, options ) {
- this.container = container;
- this.explorer = explorer;
- this.app = explorer.app;
- this.lp = explorer.app.lp;
- this.action = explorer.action;
- this.setOptions(options);
- this._initTools();
- this.type = this.options.type;
- this.availableTool = this.options.availableTool;
- },
- _initTools : function (){
- this.tools = {
- rename : {
- action : "rename",
- text : this.lp.button.rename,
- icon : "iconfont-edit"
- },
- delete : {
- action : "delete",
- text : this.lp.button.delete,
- icon : "iconfont-delete"
- },
- }
- },
- load : function(){
- this.node = new Element("div").inject( this.container );
- this.availableTool.each( function( group ){
- var toolgroupNode = new Element("div.toolgroupNode").inject( this.node );
- var length = group.length;
- group.each( function( t, i ){
- var className;
- if( length == 1 ){
- className = "toolItemNode_single";
- }else{
- if( i == 0 ){
- className = "toolItemNode_left";
- }else if( i + 1 == length ){
- className = "toolItemNode_right";
- }else{
- className = "toolItemNode_center";
- }
- }
- var tool = this.tools[ t ];
- var toolNode = new Element( "div", {
- class : className,
- style : "cursor:pointer;height:30px;line-height:30px;padding-left:12px;padding-right:12px;background: #4A90E2;font-size: 13px;color: #FFFFFF;font-weight: 400;",
- events : {
- click : function( ev ){ this[tool.action]( ev ) }.bind(this)
- }
- }).inject( toolgroupNode );
- var iconNode = new Element("icon",{"class":"o2Drive " + tool.icon,"style":"margin-right:6px"}).inject(toolNode);
- var textNode = new Element("span").inject(toolNode);
- textNode.set("text",tool.text);
- }.bind(this))
- }.bind(this));
- this.loadRightNode()
- },
- rename : function(){
- var _self = this;
- if (this.explorer.selectedList && this.explorer.selectedList.length){
- var data = this.explorer.selectedList[0];
- var form = new MWF.xApplication.HotArticle.ReNameForm(this.explorer, data, {
- }, {
- app: this.app
- });
- form.edit()
- }else {
- this.app.notice(this.lp.tip.selectFile,"error");
- return;
- }
- },
- delete : function (e){
- if (this.explorer.selectedList && this.explorer.selectedList.length){
- var _self = this;
- var dataList = this.explorer.selectedList;
- this.app.confirm("warn", e, this.lp.tip.removeConfirmTitle, this.lp.tip.removeConfirm.replace("{length}",dataList.length), 350, 120, function () {
- var count = 0;
- dataList.each( function(data){
- _self.action.HotPictureInfoAction.delete(data.application, data.infoId , function(){
- count++;
- if( dataList.length == count ){
- _self.app.notice(_self.lp.tip.removeSuccess.replace("{count}",count));
- _self.explorer.refresh();
- }
- });
- }.bind(this));
- this.close();
- }, function () {
- this.close();
- });
- }else {
- this.app.notice(this.lp.tip.selectFile,"error");
- return;
- }
- },
- loadRightNode : function(){
- this.toolabrRightNode = new Element("div.toolabrRightNode",{
- "style": "float:right"
- }).inject(this.node);
- this.loadListType();
- },
- getListType : function(){
- return this.viewType || this.options.viewType
- },
- loadListType : function(){
- this.listViewTypeNode = new Element("div", {
- "style" : "font-size:18px;float:left;margin-right:6px",
- "class" : this.options.viewType == "list" ? "mainColor_color" : "",
- events : {
- click : function(){
- this.viewType = "list";
- this.explorer.options.defaultViewType = this.viewType;
- this.explorer.refresh();
- }.bind(this)
- }
- }).inject(this.toolabrRightNode);
- new Element("icon",{"class":"iconfont-list"}).inject(this.listViewTypeNode);
- this.tileViewTypeNode = new Element("div", {
- "style" : "font-size:18px;float:left",
- "class" : this.options.viewType !== "list" ? "mainColor_color" : "",
- events : {
- click : function(){
- this.viewType = "tile";
- this.explorer.options.defaultViewType = this.viewType;
- this.explorer.refresh();
- }.bind(this)
- }
- }).inject(this.toolabrRightNode);
- new Element("icon",{"class":"iconfont-grid"}).inject(this.tileViewTypeNode);
- }
- });
- MWF.xApplication.HotArticle.ReNameForm = new Class({
- Extends: MPopupForm,
- Implements: [Options, Events],
- options: {
- "style": "attendanceV2",
- "width": 700,
- //"height": 300,
- "height": "200",
- "hasTop": true,
- "hasIcon": false,
- "draggable": true,
- "title" : MWF.xApplication.HotArticle.LP.tip.modifyTitle,
- "id" : ""
- },
- _createTableContent: function () {
- var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin-top: 20px; '>" +
- "<tr>" +
- " <td styles='formTableValue14' item='title' ></td></tr>" +
- "</table>";
- this.formTableArea.set("html", html);
- this.form = new MForm(this.formTableArea, this.data || {}, {
- isEdited: true,
- style : "minder",
- hasColon : true,
- itemTemplate: {
- title: { text : MWF.xApplication.HotArticle.LP.list.title, notEmpty : true }
- }
- }, this.app);
- this.form.load();
- },
- _createBottomContent: function () {
- if (this.isNew || this.isEdited) {
- this.okActionNode = new Element("button.inputOkButton", {
- "styles": this.css.inputOkButton,
- "text": MWF.xApplication.HotArticle.LP.button.ok
- }).inject(this.formBottomNode);
- this.okActionNode.addEvent("click", function (e) {
- this.save(e);
- }.bind(this));
- }
- this.cancelActionNode = new Element("button.inputCancelButton", {
- "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
- "text": MWF.xApplication.HotArticle.LP.button.close
- }).inject(this.formBottomNode);
- this.cancelActionNode.addEvent("click", function (e) {
- this.close(e);
- }.bind(this));
- },
- save: function(){
- var data = this.form.getResult(true,null,true,false,true);
- if( data ){
- this.app.action.HotPictureInfoAction.changeTitle({
- "id" : data.id,
- "application" : data.application,
- "infoId" : data.infoId,
- "title" : data.title,
- "summary" : data.summary,
- "picId" : data.picId,
- "creator" : data.creator,
- "createTime" : data.createTime,
- "updateTime" : data.updateTime
- }).then(function (){
- this.app.notice(MWF.xApplication.HotArticle.LP.tip.success);
- this.explorer.refresh();
- this.close();
- }.bind(this));
- }
- }
- });
|