123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845 |
- MWF.xApplication.cms = MWF.xApplication.cms || {};
- MWF.CMSE = MWF.xApplication.cms.Module = MWF.xApplication.cms.Module ||{};
- MWF.require("MWF.widget.O2Identity", null,false);
- //MWF.xDesktop.requireApp("cms.Module", "Actions.RestActions", null, false);
- MWF.xApplication.cms.Module.options = {
- multitask: false,
- executable: true
- };
- MWF.xApplication.cms.Module.Main = new Class({
- Extends: MWF.xApplication.Common.Main,
- Implements: [Options, Events],
- options: {
- "style": "default",
- "name": "cms.Module",
- "icon": "icon.png",
- "width": "1200",
- "height": "700",
- "isResize": true,
- "isMax": true,
- "isCategory" : false,
- "searchKey" : "",
- "title": MWF.xApplication.cms.Module.LP.title
- },
- onQueryLoad: function(){
- this.lp = MWF.xApplication.cms.Module.LP;
- },
- onQueryClose : function(){
- if (window.clipboardData){
- if (this.keyCopyItemsFun)this.removeEvent("copy", this.keyCopyItemsFun);
- if (this.keyPasteItemsFun)this.removeEvent("paste", this.keyPasteItemsFun);
- }else{
- if (this.keyCopyItemsFun) document.removeEventListener('copy', this.keyCopyItemsFun);
- if (this.keyPasteItemsFun) document.removeEventListener('paste', this.keyPasteItemsFun);
- }
- },
- loadApplication: function(callback){
- //this.controllers = [];
- this.content.loadCss("../x_component_cms_Module/$Main/default/style.css");
- this.isAdmin = false;
- this.restActions = MWF.Actions.get("x_cms_assemble_control"); //new MWF.xApplication.cms.Module.Actions.RestActions();
- this.createNode();
- this.loadApplicationContent();
- },
- createNode: function(){
- this.content.setStyle("overflow", "hidden");
- this.node = new Element("div", {
- "styles": this.css.node
- }).inject(this.content);
- this.naviContainerNode = new Element("div.naviContainerNode", {
- "styles": this.css.naviContainerNode
- }).inject(this.node);
- this.leftTitleNode = new Element("div.leftTitleNode", {
- "styles": this.css.leftTitleNode
- }).inject(this.naviContainerNode);
- this.leftTitleNode.addClass("mainColor_border");
- this.rightContentNode = new Element("div", {
- "styles":this.css.rightContentNode
- }).inject(this.node);
- this.titleBar = new Element("div", {
- "styles": this.css.titleBar
- }).inject(this.rightContentNode );
- this.titleActionBar = new Element("div", {
- "styles": this.css.titleActionBar
- }).inject(this.titleBar );
- },
- loadApplicationContent: function(){
- var columnId = (this.options.columnData && this.options.columnData.id ) ||
- (this.status && this.status.columnId) || this.options.columnId;
- var columnAlias = this.options.columnAlias || (this.options.columnData && this.options.columnData.columnAlias ) ||
- (this.status && this.status.columnAlias );
- // if( this.options.columnData ){
- // this.setColumnDataConfig();
- // this.setTitle(this.options.columnData.appName);
- // this.loadController(function(){
- // this.loadTitle(function(){
- // this.loadMenu();
- // }.bind(this));
- // }.bind(this))
- // }else
- if( columnId ){
- this.loadColumnData( columnId, function(){
- this.loadController(function(){
- this.loadTitle(function(){
- this.loadMenu();
- }.bind(this));
- }.bind(this))
- }.bind(this))
- }else if( columnAlias ){
- this.restActions.getColumnByAlias( columnAlias, function( json ){
- this.columnData = json.data;
- this.setColumnDataConfig();
- this.setTitle(this.columnData.appName);
- this.loadController(function(){
- this.loadTitle(function(){
- this.loadMenu();
- }.bind(this));
- }.bind(this))
- }.bind(this))
- }
- },
- setColumnDataConfig : function(){
- if( !this.columnData.config ){
- this.columnData.config = {};
- }else if( typeOf(this.columnData.config) === "string" ){
- this.columnData.config = JSON.parse( this.columnData.config || {} );
- }
- },
- loadColumnData : function(columnId, callback){
- this.restActions.getColumn( columnId, function( json ){
- this.columnData = json.data;
- this.setTitle(this.columnData.appName);
- this.setColumnDataConfig();
- //MWF.require("MWF.xScript.Actions.CMSScriptActions", null, false);
- //MWF.require("o2.xScript.Macro", null, false);
- //var scriptAction = new MWF.xScript.Actions.CMSScriptActions();
- //scriptAction.getScriptByName( this.columnData.id, "_config", [], function(json){
- // if (json.data){
- // try{
- // this.columnData = Object.merge(this.columnData,JSON.parse(json.data.text));
- // }catch(e){
- // }
- // }
- //}.bind(this), null, false);
- if(callback)callback()
- }.bind(this))
- },
- loadController: function(callback){
- //this.restActions.listColumnController(this.columnData.id, function( json ){
- // json.data = json.data || [];
- // json.data.each(function(item){
- // this.controllers.push(item.adminUid)
- // }.bind(this));
- // this.isAdmin = MWF.AC.isCMSManager() || this.controllers.contains(layout.desktop.session.user.distinguishedName);
- // if(callback)callback(json);
- //}.bind(this));
- this.restActions.isAppInfoManager( this.columnData.id, function( json ){
- this.isAdmin = MWF.AC.isCMSManager() || json.data.value;
- if(callback)callback(json);
- }.bind(this))
- },
- loadTitle : function(callback){
- if( this.isAdmin ){
- //this.loadImportActionNode();
- //this.loadExportActionNode();
- }
- this.loadCreateDocumentActionNode(
- function(){
- this.loadTitleIconNode();
- this.loadTitleContentNode();
- this.loadBatchAction();
- this.loadPastEvent();
- this.loadSearchNode();
- if(callback)callback();
- }.bind(this)
- );
- },
- loadBatchAction: function(){
- if( !this.isAdmin )return;
- this.batchAction = new Element("div", {
- "styles": this.css.batchAction
- }).inject(this.titleActionBar);
- this.batchIcon = new Element("i.o2icon-folder-select", {
- "styles": this.css.actionIcon
- }).inject(this.batchAction, "top");
- this.batchText = new Element("div", {
- "styles": this.css.batchText,
- "text" : this.lp.select
- }).inject(this.batchAction);
- this.batchAction.addEvents({
- "click": function(e){
- if( this.view ){
- if( this.view.selectEnable ){
- this.selectEnable = false;
- this.batchAction.setStyles( this.css.batchAction );
- this.batchAction.removeClass("mainColor_color");
- this.batchText.set("text",this.lp.select);
- this.batchIcon.setStyles( this.css.actionIcon );
- this.batchIcon.removeClass("mainColor_color");
- this.view.disableSelectMode();
- this.cancelBatchRemoveAction();
- this.cancelChangeCategoryAction();
- this.cancelCopyActionNode();
- }else{
- this.selectEnable = true;
- this.batchAction.setStyles( this.css.batchAction_over );
- this.batchAction.addClass("mainColor_color");
- this.batchText.set("text", this.lp.cancelSelect);
- this.batchIcon.setStyles( this.css.actionIcon_over );
- this.batchIcon.addClass("mainColor_color");
- this.view.selectMode();
- this.loadCopyActionNode();
- this.loadChangeCategoryAction();
- this.loadBatchRemoveAction();
- }
- }
- }.bind(this),
- "mouseover" : function(e){
- if( this.view.selectEnable )return;
- this.batchAction.setStyles( this.css.batchAction_over );
- this.batchAction.addClass("mainColor_color");
- this.batchIcon.setStyles( this.css.actionIcon_over );
- this.batchIcon.addClass("mainColor_color");
- }.bind(this),
- "mouseout" : function(e){
- if( this.view.selectEnable )return;
- this.batchAction.setStyles( this.css.batchAction );
- this.batchAction.removeClass("mainColor_color");
- this.batchIcon.setStyles( this.css.actionIcon );
- this.batchIcon.removeClass("mainColor_color");
- }.bind(this)
- });
- },
- getSearchBarSize : function(){
- var x_action = this.titleActionBar.getSize().x;
- var x_titlebar = this.titleBar.getSize().x;
- return x_titlebar - x_action;
- },
- loadPastEvent : function(){
- if( !this.isAdmin )return;
- this.keyPasteItemsFun = this.keyPasteItems.bind(this);
- if (window.clipboardData){
- this.addEvent("paste", this.keyPasteItemsFun);
- }else{
- document.addEventListener('paste', this.keyPasteItemsFun);
- //this.addEvent("queryClose", function(){
- // if (this.keyPasteItemsFun) document.removeEventListener('paste', this.keyPasteItemsFun);
- //}.bind(this));
- }
- },
- loadCreateDocumentActionNode: function( callback ){
- this.restActions.listCategoryByPublisher( this.columnData.id, function( json ){
- if( json.data && json.data.length ){
- this.createDocumentAction = new Element("div", {
- "styles": this.css.createDocumentAction,
- "text" : this.lp.start
- }).inject(this.titleActionBar);
- this.createDocumentIcon = new Element("i.o2icon-newfiles", {
- "styles": this.css.actionIcon
- }).inject(this.createDocumentAction, "top");
- this.createDocumentAction.addEvents({
- "click": function(e){
- MWF.xDesktop.requireApp("cms.Index", "Newer", null, false);
- //if(this.columnData.latest===undefined) this.columnData.latest = true;
- //if(this.columnData.ignoreTitle===undefined) this.columnData.ignoreTitle = false;
- this.creater = new MWF.xApplication.cms.Index.Newer( this.columnData, null, this, this.view, {
- restrictToColumn : true
- // onAfterPublish : function () {
- // try{
- // if(this.view && this.view.reload){
- // this.view.reload();
- // }
- // }catch (e) {
- // }
- // }.bind(this)
- //ignoreTitle : this.columnData.ignoreTitle,
- //latest : this.columnData.latest
- });
- this.creater.load();
- }.bind(this),
- "mouseover" : function(e){
- this.createDocumentAction.setStyles( this.css.createDocumentAction_over );
- this.createDocumentAction.addClass("mainColor_color");
- this.createDocumentIcon.setStyles( this.css.actionIcon_over );
- this.createDocumentIcon.addClass("mainColor_color");
- }.bind(this),
- "mouseout" : function(e){
- this.createDocumentAction.setStyles( this.css.createDocumentAction );
- this.createDocumentAction.removeClass("mainColor_color");
- this.createDocumentIcon.setStyles( this.css.actionIcon );
- this.createDocumentIcon.removeClass("mainColor_color");
- }.bind(this)
- });
- }
- if(callback)callback();
- }.bind(this));
- },
- cancelChangeCategoryAction : function(){
- if(this.moveAction)this.moveAction.destroy();
- this.moveAction = null;
- },
- loadChangeCategoryAction : function(){
- if( !this.isAdmin )return;
- this.moveAction = new Element("div", {
- "styles": this.css.moveDocumentAction,
- "text" : this.lp.move //"移动"
- }).inject(this.titleActionBar);
- this.moveIcon = new Element("i.o2icon-folder-move", {
- "styles": this.css.actionIcon
- }).inject(this.moveAction, "top");
- this.moveAction.addEvents({
- "click": function(e){
- var _self = this;
- if( this.view ){
- var itemIds = this.view.getSelectedIds();
- if (!itemIds.length) {
- this.notice( _self.lp.selectDocNotice, "error"); //"请先选择文档"
- return;
- }
- this.loadSelectColumnDialog( function( data ){
- if( data && data.id ){
- var text = _self.lp.moveDocConfirmContent.replace("{count}", itemIds.length ).replace("{category}", data.categoryName);
- //"移动后将在本分类删除,确定要移动选中的"+itemIds.length+"个文档到"+data.categoryName+"?";
- this.confirm("warn", e, _self.lp.moveDocConfirmTitle, text, 350, 120, function(){
- _self.restActions.moveDocumentToCategory({
- ids : itemIds,
- categoryId : data.id
- }, function(){
- _self.notice( _self.lp.moveDocSuccessNotice, "success"); //"移动成功"
- _self.view.reload();
- this.close();
- }.bind(this))
- }, function(){
- this.close();
- });
- }
- }.bind(this))
- }
- }.bind(this),
- "mouseover" : function(e){
- this.moveAction.setStyles( this.css.moveDocumentAction_over );
- this.moveAction.addClass("mainColor_color");
- this.moveIcon.setStyles( this.css.actionIcon_over );
- this.moveIcon.addClass("mainColor_color");
- }.bind(this),
- "mouseout" : function(e){
- this.moveAction.setStyles( this.css.moveDocumentAction );
- this.moveAction.removeClass("mainColor_color");
- this.moveIcon.setStyles( this.css.actionIcon );
- this.moveIcon.removeClass("mainColor_color");
- }.bind(this)
- });
- },
- cancelBatchRemoveAction : function(){
- if(this.batchRemoveAction)this.batchRemoveAction.destroy();
- this.batchRemoveAction = null;
- },
- loadBatchRemoveAction : function(){
- if( !this.isAdmin )return;
- var _self = this;
- this.batchRemoveAction = new Element("div", {
- "styles": this.css.batchRemoveDocumentAction,
- "text" : this.lp.batchRemove
- }).inject(this.titleActionBar);
- this.batchRemoveIcon = new Element("i.o2icon-delete", {
- "styles": this.css.actionIcon
- }).inject(this.batchRemoveAction, "top");
- this.batchRemoveAction.addEvents({
- "click": function(e){
- var _self = this;
- if( this.view ){
- var itemIds = this.view.getSelectedIds();
- if (itemIds.length) {
- _self.readyRemove = true;
- var text = _self.lp.clearDocConfirmContent.replace("{count}", itemIds.length);
- // var text = "删除后无法恢复,确定要删除选中的"+itemIds.length+"个文档?";
- this.confirm("warn", e, _self.lp.clearDocConfirmTitle, text, 350, 120, function(){
- _self.removeDocumentList(itemIds);
- this.close();
- }, function(){
- _self.readyRemove = false;
- this.close();
- });
- }else{
- this.notice( _self.lp.selectDocNotice,"error")
- }
- }
- }.bind(this),
- "mouseover" : function(e){
- this.batchRemoveAction.setStyles( this.css.batchRemoveDocumentAction_over )
- this.batchRemoveAction.addClass("mainColor_color");
- this.batchRemoveIcon.setStyles( this.css.actionIcon_over );
- this.batchRemoveIcon.addClass("mainColor_color");
- }.bind(this),
- "mouseout" : function(e){
- this.batchRemoveAction.setStyles( this.css.batchRemoveDocumentAction );
- this.batchRemoveAction.removeClass("mainColor_color");
- this.batchRemoveIcon.setStyles( this.css.actionIcon );
- this.batchRemoveIcon.removeClass("mainColor_color");
- }.bind(this)
- });
- },
- //loadBatchRemoveAction : function(){
- // if( !this.isAdmin )return;
- //
- // this.batchRemoveAction = new Element("div", {
- // "styles": this.css.batchRemoveDocumentAction,
- // "text" : this.lp.batchRemove
- // }).inject(this.titleBar);
- // this.batchRemoveAction.addEvents({
- // "click": function(e){
- // if( this.view ){
- // if( this.view.selectEnable ){
- // this.view.disableSelectMode();
- // this.batchRemoveConfirmAction.setStyle("display","none");
- // //this.batchRemoveAction.set("text",this.lp.batchRemove);
- // }else{
- // this.view.selectMode();
- // this.batchRemoveConfirmAction.setStyle("display","");
- // //this.batchRemoveAction.set("text",this.lp.cancel);
- // }
- // }
- // }.bind(this),
- // "mouseover" : function(e){
- // this.batchRemoveAction.setStyles( this.css.batchRemoveDocumentAction_over )
- // }.bind(this),
- // "mouseout" : function(e){
- // this.batchRemoveAction.setStyles( this.css.batchRemoveDocumentAction )
- // }.bind(this)
- // });
- //
- //
- // this.batchRemoveConfirmAction = new Element("div", {
- // "styles": this.css.batchRemoveConfirmDocumentAction,
- // "text" : this.lp.batchRemoveConfirm
- // }).inject(this.titleBar);
- // var _self = this;
- // this.batchRemoveConfirmAction.addEvents({
- // "click": function (e) {
- // var itemIds = this.view.getSelectedIds();
- // if (itemIds.length) {
- // _self.readyRemove = true;
- // var text = "删除后无法恢复,确定要删除选中的"+itemIds.length+"个文档?";
- // this.confirm("warn", e, "清除确认", text, 350, 120, function(){
- //
- // _self.removeDocumentList(itemIds);
- //
- // this.close();
- //
- // }, function(){
- // _self.readyRemove = false;
- // this.close();
- // });
- // }else{
- // this.notice("请先选择文档","error")
- // }
- // }.bind(this)
- // });
- // this.batchRemoveConfirmAction.setStyle("display","none");
- //},
- removeDocumentList : function( itemIds ){
- var count = 0;
- itemIds.each( function(id){
- this.restActions.removeDocument(id, function(json){
- count++;
- if( count === itemIds.length ){
- this.notice( this.lp.clearDocSuccessNotice, "success");
- //this.view.disableSelectMode();
- this.view.reload();
- }
- }.bind(this));
- }.bind(this))
- },
- cancelCopyActionNode : function(){
- if (window.clipboardData){
- if (this.keyCopyItemsFun)this.removeEvent("copy", this.keyCopyItemsFun);
- }else{
- if (this.keyCopyItemsFun) document.removeEventListener('copy', this.keyCopyItemsFun);
- }
- this.keyCopyItemsFun = null;
- if(this.copyAction)this.copyAction.destroy();
- this.copyAction = null;
- },
- loadCopyActionNode : function(){
- if( !this.isAdmin )return;
- this.copyAction = new Element("div", {
- "styles": this.css.copyDocumentAction,
- "text" : this.lp.enableCopy
- }).inject(this.titleActionBar);
- this.copyIcon = new Element("i.o2icon-document-copy", {
- "styles": this.css.actionIcon
- }).inject(this.copyAction, "top");
- this.copyAction.addEvents({
- "click": function(e){
- if( this.view ){
- if( this.keyCopyItemsFun )return;
- this.keyCopyItemsFun = this.keyCopyItems.bind(this);
- if (window.clipboardData){
- this.addEvent("copy", this.keyCopyItemsFun);
- }else{
- document.addEventListener('copy', this.keyCopyItemsFun);
- //this.addEvent("queryClose", function(){
- // if (this.keyCopyItemsFun) document.removeEventListener('copy', this.keyCopyItemsFun);
- //}.bind(this));
- }
- this.notice( this.lp.copyInfor );
- }
- }.bind(this),
- "mouseover" : function(e){
- this.copyAction.setStyles( this.css.copyDocumentAction_over );
- this.copyAction.addClass("mainColor_color");
- this.copyIcon.setStyles( this.css.actionIcon_over );
- this.copyIcon.addClass("mainColor_color");
- }.bind(this),
- "mouseout" : function(e){
- this.copyAction.setStyles( this.css.copyDocumentAction );
- this.copyAction.removeClass("mainColor_color");
- this.copyIcon.setStyles( this.css.actionIcon );
- this.copyIcon.removeClass("mainColor_color");
- }.bind(this)
- });
- },
- //loadCopyActionNode : function(){
- // if( !this.isAdmin )return;
- // this.copyAction = new Element("div", {
- // "styles": this.css.copyDocumentAction,
- // "text" : this.lp.copy
- // }).inject(this.titleBar);
- // this.copyAction.addEvents({
- // "click": function(e){
- // if( this.view ){
- // if( this.view.selectEnable ){
- // this.view.disableSelectMode();
- // if (window.clipboardData){
- // if (this.keyCopyItemsFun)this.removeEvent("copy", this.keyCopyItemsFun);
- // }else{
- // if (this.keyCopyItemsFun) document.removeEventListener('copy', this.keyCopyItemsFun);
- // }
- // this.keyCopyItemsFun = null;
- // }else{
- // this.view.selectMode();
- // this.keyCopyItemsFun = this.keyCopyItems.bind(this);
- // if (window.clipboardData){
- // this.addEvent("copy", this.keyCopyItemsFun);
- // }else{
- // document.addEventListener('copy', this.keyCopyItemsFun);
- // //this.addEvent("queryClose", function(){
- // // if (this.keyCopyItemsFun) document.removeEventListener('copy', this.keyCopyItemsFun);
- // //}.bind(this));
- // }
- // this.notice( this.lp.copyInfor );
- // }
- // }
- // }.bind(this),
- // "mouseover" : function(e){
- // this.copyAction.setStyles( this.css.copyDocumentAction_over )
- // }.bind(this),
- // "mouseout" : function(e){
- // this.copyAction.setStyles( this.css.copyDocumentAction )
- // }.bind(this)
- // });
- //},
- keyCopyItems: function(e){
- if (layout.desktop.currentApp && layout.desktop.currentApp.appId===this.appId) {
- var itemIds = this.view.getSelectedIds();
- if (itemIds.length) {
- var items = [];
- var i = 0;
- var checkItems = function (e) {
- if (i >= itemIds.length) {
- if (items.length) {
- var str = JSON.encode(items);
- if (e && e.clipboardData) {
- e.clipboardData.setData('text/plain', str);
- e.preventDefault();
- } else {
- window.clipboardData.setData("Text", str);
- }
- this.notice(this.lp.copyed, "success");
- }
- }
- }.bind(this);
- itemIds.each(function (id) {
- this.restActions.getDocument(id, function (json) {
- json.data.elementType = "cmsDocument";
- items.push(json.data);
- i++;
- checkItems(e);
- }.bind(this), null, false)
- }.bind(this));
- }
- }
- },
- keyPasteItems: function(e){
- if (layout.desktop.currentApp && layout.desktop.currentApp.appId===this.appId) {
- var dataStr = "";
- if (e && e.clipboardData) {
- dataStr = e.clipboardData.getData('text/plain');
- } else {
- dataStr = window.clipboardData.getData("Text");
- }
- if( !dataStr.contains("elementType") )return;
- if( !dataStr.contains("cmsDocument") )return;
- if( dataStr.contains("eval(\"") || dataStr.contains("eval('") )return;
- var data = JSON.decode(dataStr);
- this.listPublishableCategoryInfo(function(){
- this.pasteItem(data, 0);
- }.bind(this))
- }
- },
- listPublishableCategoryInfo : function( callback ){
- this.publishableCategoryInfoObject_id = {};
- this.publishableCategoryInfoObject_alias = {};
- this.publishableCategoryInfoObject_name = {};
- this.categoryTransformMap = {};
- this.categoryRadioHtml = "";
- o2.Actions.load("x_cms_assemble_control").CategoryInfoAction.listPublishableCategoryInfo( this.columnData.id, function(json){
- ( json.data || [] ).each( function(c){
- this.publishableCategoryInfoObject_id[c.id] = c;
- this.publishableCategoryInfoObject_alias[c.categoryAlias] = c;
- this.publishableCategoryInfoObject_name[c.categoryName] = c;
- this.categoryRadioHtml += "<div><input type='radio' name='categoryRadio' value='"+ c.id+"'/>" + c.categoryName + "(" + c.categoryAlias +")</div>"
- }.bind(this));
- this.categoryRadioHtml = "<div style='overflow: hidden; margin: 10px 0px; padding: 5px 10px; background-color: #ffffff; border-radius: 6px;'>" +
- this.categoryRadioHtml + "</div>";
- if(callback)callback();
- }.bind(this));
- },
- pasteItem: function(data, i){
- if (i<data.length){
- var item = data[i];
- if (item.elementType==="cmsDocument"){
- this.saveItemAs(item, function(){
- i++;
- this.pasteItem(data, i);
- }.bind(this), function(){
- i++;
- this.pasteItem(data, i);
- }.bind(this), function(){
- this.view.reload();
- }.bind(this));
- }else{
- i++;
- this.pasteItem(data, i);
- }
- }else{
- this.view.reload();
- }
- },
- saveItemAs: function(data, success, failure, cancel){
- var lp = this.lp;
- var _self = this;
- if( this.publishableCategoryInfoObject_id[ data.document.categoryId ] ){
- this._saveItemAs(data, success, failure, cancel );
- }else if( this.categoryTransformMap[ data.document.categoryId ] ){
- this._saveItemAs(data, success, failure, cancel, this.categoryTransformMap[ data.document.categoryId ] );
- }else{
- var text;
- if( this.publishableCategoryInfoObject_alias[ data.document.categoryAlias ] ){
- text = lp.copyConfirmCategoryInfor_hasSameAlias + "。<br/>" + lp.copyConfirmCateogyrInfor_withChoice
- }else if( this.publishableCategoryInfoObject_name[ data.document.categoryName ] ){
- text = lp.copyConfirmCategoryInfor_hasSameName + "。<br/>" + lp.copyConfirmCateogyrInfor_withChoice
- }else{
- text = lp.copyConfirmCategoryInfor_noCategory + ":"
- }
- text = text.replace("{alias}", "(<span style='color:red;'>" + data.document.categoryAlias + "</span>)" );
- text = text.replace("{name}", "(<span style='color:red;'>" + data.document.categoryName + "</span>)" );
- var html = "<div style='overflow-y:auto;height:300px'>";
- html += "<div style='overflow: hidden; margin: 10px 0px; padding: 5px 10px; background-color: #ffffff; border-radius: 6px;'>";
- html += " <div style='clear: both;font-weight: bold; font-size:14px;'>"+lp.copyTarget+" "+data.document.title+"</div>";
- html += " <div style='font-size:12px; color: #666666; float: left;'>"+data.document.publishTime+"</div>";
- html += " <div style='font-size:12px; color: #666666; float: left; margin-left: 20px;'>"+MWF.name.cn(data.document.creatorPersonShort)+"</div>";
- html += "</div>";
- html += "<div>" + text + "</div>" + this.categoryRadioHtml;
- html += "<div><input type='checkbox' value='true' name='useSameChoice'>"+lp.copyConfirm_SameCategory+"</div>";
- html += "</div>";
- // html += "<>"
- this.dlg("inofr", null, lp.copyConfirmCategoryTitle, {"html": html}, 500, 450, [
- {
- "text": lp.copy,
- "action": function(){
- var categoryRadio = this.node.getElements("[name='categoryRadio']");
- var checkbox = this.node.getElement("[name='useSameChoice']");
- var newCategory;
- for( var i=0; i<categoryRadio.length; i++ ){
- if( categoryRadio[i].checked ){
- newCategory = _self.publishableCategoryInfoObject_id[ categoryRadio[i].get("value") ];
- }
- }
- if( !newCategory ){
- if( _self.publishableCategoryInfoObject_alias[ data.document.categoryAlias ] ){
- newCategory = _self.publishableCategoryInfoObject_alias[ data.document.categoryAlias ];
- }else if( _self.publishableCategoryInfoObject_name[ data.document.categoryName ] ){
- newCategory = _self.publishableCategoryInfoObject_name[ data.document.categoryName ];
- }
- }
- if( newCategory ){
- if( checkbox.checked )_self.categoryTransformMap[ data.document.categoryId ] = newCategory;
- this.close();
- _self._saveItemAs(data, success, failure, cancel, newCategory );
- }else{
- _self.notice( lp.notSelectCategory, "error" )
- }
- //_self.saveItemAsUpdate(someItem, data, success, failure);
- }
- },
- {
- "text": lp.copyConfirm_skip,
- "action": function(){/*nothing*/ this.close(); if (success) success();}
- },
- {
- "text": lp.copyConfirm_cancel,
- "action": function(){this.close(); if (cancel) cancel();}
- }
- ]);
- }
- },
- _saveItemAs: function(data, success, failure, cancel, newCategory ){
- this.restActions.getDocument(data.document.id, function(dJson){
- var someItem = dJson.data;
- var flag = false;
- if (someItem){
- if( newCategory ){
- if( newCategory.id !== someItem.document.categoryId ){ //如果已有文档的分类和新分类不一样,直接新建
- this.saveItemAsNew(data, success, failure, true, newCategory)
- }else{ //如果已有文档的分类和新分类一样,需要询问
- flag = true;
- }
- }else{ //如果使用原有分类,需要询问
- flag = true;
- }
- if( flag ){
- var lp = this.lp;
- var _self = this;
- var d1 = new Date().parse(data.document.publishTime);
- var d2 = new Date().parse(someItem.document.publishTime);
- var html = "<div>"+lp.copyConfirmInfor+"</div>";
- html += "<div style='overflow: hidden; margin: 10px 0px; padding: 5px 10px; background-color: #ffffff; border-radius: 6px;'><div style='font-weight: bold; font-size:14px;'>"+lp.copySource+" "+someItem.document.title+"</div>";
- html += "<div style='font-size:12px; color: #666666; float: left'>"+someItem.document.publishTime+"</div>" +
- "<div style='font-size:12px; color: #666666; float: left; margin-left: 20px;'>"+MWF.name.cn(someItem.document.creatorPersonShort)+"</div>" +
- "<div style='color: red; float: right;'>"+((d1>=d2) ? "": lp.copynew)+"</div></div>";
- html += "<div style='overflow: hidden; margin: 10px 0px; padding: 5px 10px; background-color: #ffffff; border-radius: 6px;'><div style='clear: both;font-weight: bold; font-size:14px;'>"+lp.copyTarget+" "+data.document.title+"</div>";
- html += "<div style='font-size:12px; color: #666666; float: left;'>"+data.document.publishTime+"</div>" +
- "<div style='font-size:12px; color: #666666; float: left; margin-left: 20px;'>"+MWF.name.cn(data.document.creatorPersonShort)+"</div>" +
- "<div style='color: red; float: right;'>"+((d1<=d2) ? "": lp.copynew)+"</div></div>";
- // html += "<>"
- this.dlg("inofr", null, lp.copyConfirmTitle, {"html": html}, 500, 290, [
- {
- "text": lp.copyConfirm_overwrite,
- "action": function(){_self.saveItemAsUpdate(someItem, data, success, failure);this.close();}
- },
- {
- "text": lp.copyConfirm_new,
- "action": function(){_self.saveItemAsNew( data, success, failure, true, newCategory );this.close();}
- },
- {
- "text": lp.copyConfirm_skip,
- "action": function(){/*nothing*/ this.close(); if (success) success();}
- },
- {
- "text": lp.copyConfirm_cancel,
- "action": function(){this.close(); if (cancel) cancel();}
- }
- ]);
- }
- }
- }.bind(this), function(){
- //if (failure) failure();
- this.saveItemAsNew(data, success, failure, false, newCategory);
- return true;
- }.bind(this));
- },
- saveItemAsUpdate: function(someItem, data, success, failure){
- var doc = data.document;
- doc.id = someItem.document.id;
- doc.isNewDocument = false;
- doc.appId = someItem.document.appId;
- doc.appName = someItem.document.appName;
- doc.categoryId = someItem.document.categoryId;
- doc.categoryName = someItem.document.categoryName;
- doc.categoryAlias = someItem.document.categoryAlias;
- doc.form = someItem.document.form;
- doc.formName = someItem.document.formName;
- doc.readFormId = someItem.document.readFormId;
- doc.readFormName = someItem.document.readFormName;
- doc.docData = data.data;
- this.restActions.saveDocument(doc, function(){
- if (success) success();
- }.bind(this), function(){
- if (failure) failure();
- }.bind(this));
- },
- saveItemAsNew: function(data, success, failure, clearId, newCategory){
- var columnData = this.columnData;
- var doc = data.document;
- if( clearId ){
- delete doc.id;
- }
- delete doc.documentType;
- delete doc.appId;
- delete doc.appName;
- delete doc.appAlias;
- // delete doc.categoryId;
- delete doc.categoryName;
- delete doc.categoryAlias;
- delete doc.form;
- delete doc.formName;
- delete doc.readFormId;
- delete doc.readFormName;
- doc.appId = columnData.id;
- doc.docData = data.data;
- delete doc.docData.$document;
- var callback = function(data){
- this.restActions.publishDocumentComplex(data, function(){
- if (success) success();
- }.bind(this), function(){
- if (failure) failure();
- }.bind(this));
- }.bind(this);
- debugger;
- if( newCategory ){
- doc.categoryId = newCategory.id;
- callback( doc );
- }else{
- this.restActions.getCategory( data.document.categoryId, function( json ){
- if( json.data.appId === columnData.id ){
- doc.categoryId = data.document.categoryId;
- callback( doc );
- }else{
- this.loadSelectCategoryDialog( this.lp.selectCategoryText.replace("{title}", data.document.title ), function(id){
- doc.categoryId = id;
- callback( doc );
- }.bind(this))
- }
- }.bind(this), function(){
- this.loadSelectCategoryDialog( this.lp.selectCategoryText.replace("{title}", data.document.title), function(id){
- doc.categoryId = id;
- callback( doc );
- }.bind(this))
- }.bind(this))
- }
- },
- loadSelectColumnDialog : function( callback){
- MWF.xDesktop.requireApp("Selector", "package", null, false);
- var options = {
- "type": "CMSCategory",
- "count": 1,
- "onComplete": function(items){
- items.each(function(item){
- if( callback )callback( item.data );
- }.bind(this));
- }.bind(this)
- };
- var selector = new MWF.O2Selector(this.content, options);
- },
- loadSelectCategoryDialog : function(title, callback){
- if( !this.categoryList ){
- this.categoryList = [];
- this.restActions.listCategory( this.columnData.id, function( json ){
- json.data.each( function(d){
- this.categoryList.push( {
- name : d.categoryName,
- id : d.id
- })
- }.bind(this))
- }.bind(this), null, false)
- }
- MWF.xDesktop.requireApp("Template", "Selector.Custom", null, false);
- var opt = {
- "count": 1,
- "title": this.lp.selectCategory,
- "selectableItems" : this.categoryList,
- "values": [],
- "onComplete": function( array ){
- if( !array || array.length == 0 )return;
- var id = array[0].data.id;
- callback( id )
- }.bind(this)
- };
- var selector = new MWF.xApplication.Template.Selector.Custom(this.content, opt );
- selector.load();
- },
- loadImportActionNode : function(){
- this.importAction = new Element("div", {
- "styles": this.css.importAction,
- "text" : this.lp.import
- }).inject(this.titleActionBar);
- this.importAction.setStyle("display","none");
- this.importAction.addEvents({
- "click": function(e){
- MWF.xDesktop.requireApp("cms.Module", "ExcelForm", null, false);
- var categoryData = this.navi.currentObject.isCategory ? this.navi.currentObject.data : this.navi.currentObject.category.data ;
- this.import = new MWF.xApplication.cms.Module.ImportForm( { app : this }, categoryData, {} );
- this.import.edit();
- }.bind(this),
- "mouseover" : function(e){
- this.importAction.setStyles( this.css.importAction_over )
- }.bind(this),
- "mouseout" : function(e){
- this.importAction.setStyles( this.css.importAction )
- }.bind(this)
- });
- },
- loadExportActionNode : function(){
- this.exportAction = new Element("div", {
- "styles": this.css.exportAction,
- "text" : this.lp.export
- }).inject(this.titleActionBar);
- this.exportAction.setStyle("display","none");
- this.exportAction.addEvents({
- "click": function(e){
- MWF.xDesktop.requireApp("cms.Module", "ExcelForm", null, false);
- var categoryData = this.navi.currentObject.isCategory ? this.navi.currentObject.data : this.navi.currentObject.category.data ;
- this.export = new MWF.xApplication.cms.Module.ExportForm ( { app : this }, categoryData, {} );
- this.export.edit();
- }.bind(this),
- "mouseover" : function(e){
- this.exportAction.setStyles( this.css.exportAction_over )
- }.bind(this),
- "mouseout" : function(e){
- this.exportAction.setStyles( this.css.exportAction )
- }.bind(this)
- });
- },
- loadTitleIconNode : function(){
- this.defaultColumnIcon = "../x_component_cms_Index/$Main/"+this.options.style+"/icon/column.png";
- var iconAreaNode = this.iconAreaNode = new Element("div",{
- "styles" : this.css.titleIconAreaNode
- }).inject(this.leftTitleNode);
- var iconNode = this.iconNode = new Element("img",{
- "styles" : this.css.titleIconNode
- }).inject(iconAreaNode);
- if (this.columnData.appIcon){
- this.iconNode.set("src", "data:image/png;base64,"+this.columnData.appIcon+"");
- }else{
- this.iconNode.set("src", this.defaultColumnIcon)
- }
- iconNode.makeLnk({
- "par": this._getLnkPar()
- });
- },
- _getLnkPar: function(){
- var lnkIcon = this.defaultColumnIcon;
- if (this.columnData.appIcon) lnkIcon = "data:image/png;base64,"+this.columnData.appIcon;
- var appId = "cms.Module"+this.columnData.id;
- return {
- "icon": lnkIcon,
- "title": this.columnData.appName,
- "par": "cms.Module#{\"columnId\": \""+this.columnData.id+"\", \"appId\": \""+appId+"\"}"
- };
- },
- loadTitleContentNode: function(){
- this.titleContentNode = new Element("div.titleContentNode", {
- "styles": this.css.titleContentNode
- }).inject(this.leftTitleNode);
- this.titleTextNode = new Element("div.titleTextNode", {
- "styles": this.css.titleTextNode,
- "text": this.columnData.appName,
- "title": this.columnData.appName
- }).inject(this.titleContentNode);
- this.titleDescriptionNode = new Element("div.titleDescriptionNode", {
- "styles": this.css.titleDescriptionNode,
- "text": this.columnData.description ? this.columnData.description : this.lp.noDescription,
- "title": this.columnData.description ? this.columnData.description : this.lp.noDescription
- }).inject(this.titleContentNode);
- },
- loadSearchNode : function(){
- this.searchNode = new Element("div").inject( this.titleBar );
- },
- loadMenu: function(callback){
- this.naviNode = new Element("div.naviNode", {
- "styles": this.css.naviNode
- }).inject(this.naviContainerNode);
- //this.setScrollBar(this.naviNode,{"where": "before"});
- MWF.require("MWF.widget.ScrollBar", function(){
- new MWF.widget.ScrollBar(this.naviContainerNode, {
- "style":"xApp_ProcessManager_StartMenu", "distance": 100, "friction": 4, "axis": {"x": false, "y": true}
- });
- }.bind(this));
- this.addEvent("resize", function(){this.setNaviSize();}.bind(this));
- //MWF.require("MWF.widget.ScrollBar", function(){
- // new MWF.widget.ScrollBar(this.menuNode, {
- // "style":"xApp_CMSModule_StartMenu", "distance": 100, "friction": 4, "axis": {"x": false, "y": true}
- // });
- //}.bind(this));
- if( this.options.categoryId == "all" ){
- this.options.categoryId = "whole";
- }
- if( this.status && this.status.categoryId ){
- this._loadMenu( this.status );
- }else if( this.options.categoryId && this.options.categoryId != "" ){
- if( this.options.viewId && this.options.viewId!="" ){
- this._loadMenu( { "categoryId" :this.options.categoryId , "viewId" : this.options.viewId } )
- }else{
- //this.getCategoryDefaultList(this.options.categoryId , function(viewId){
- // if( viewId ){
- // this._loadMenu( { "categoryId" :this.options.categoryId , "viewId" : viewId, "isCategory" : this.options.isCategory } );
- // }else{
- // this._loadMenu( { "categoryId" :this.options.categoryId , "isCategory" : this.options.isCategory, "naviIndex" : (this.options.naviIndex || 0) } );
- // }
- //}.bind(this))
- this._loadMenu( { "categoryId" :this.options.categoryId , "isCategory" : true, "naviIndex" : (this.options.naviIndex || 0) } ); //this.options.isCategory
- }
- }else if( this.options.categoryAlias && this.options.categoryAlias != "" ){
- this.restActions.getCategoryByAlias( this.options.categoryAlias, function( json ){
- this.options.categoryId = json.data.id;
- if( this.options.viewId && this.options.viewId!="" ){
- this._loadMenu( { "categoryId" :this.options.categoryId , "viewId" : this.options.viewId } )
- }else{
- this._loadMenu( { "categoryId" :this.options.categoryId , "isCategory" : true, "naviIndex" : (this.options.naviIndex || 0) } ); //this.options.isCategory
- }
- }.bind(this))
- }else{
- this._loadMenu( { "categoryId" :"whole" } )
- }
- },
- _loadMenu : function( options ){
- this.navi = new MWF.xApplication.cms.Module.Navi(this, this.naviNode, this.columnData, options );
- this.setNaviSize();
- },
- clearContent: function(){
- //debugger;
- if (this.moduleContent){
- if (this.view) delete this.view;
- this.moduleContent.destroy();
- this.searchNode.empty();
- this.moduleContent = null;
- }
- },
- openView : function(el, categoryData, revealData, searchKey, navi){
- if( revealData && revealData.type == "queryview" ){
- this.loadQueryView(el, categoryData, revealData, searchKey, navi);
- }else{
- this.loadList(el, categoryData, revealData, searchKey, navi);
- }
- },
- loadQueryView : function(el, categoryData, revealData, searchKey, navi){
- MWF.xDesktop.requireApp("cms.Module", "ViewExplorer", function(){
- this.clearContent();
- this.moduleContent = new Element("div", {
- "styles": this.css.moduleContent
- }).inject(this.rightContentNode);
- this.view = new MWF.xApplication.cms.Module.ViewExplorer(
- this.moduleContent,
- this,
- this.columnData,
- categoryData,
- revealData,
- {"isAdmin": this.isAdmin, "searchKey" : searchKey },
- this.searchNode
- );
- this.view.selectEnable = this.selectEnable;
- this.view.load();
- }.bind(this))
- },
- loadList : function(el, categoryData, revealData, searchKey, navi){
- MWF.xDesktop.requireApp("cms.Module", "ListExplorer", function(){
- this.clearContent();
- this.moduleContent = new Element("div", {
- "styles": this.css.moduleContent
- }).inject(this.rightContentNode);
- if (!this.restActions) this.restActions = MWF.Actions.get("x_cms_assemble_control"); //new MWF.xApplication.cms.Module.Actions.RestActions();
- this.view = new MWF.xApplication.cms.Module.ListExplorer(
- this.moduleContent,
- this.restActions,
- this.columnData,
- categoryData,
- revealData,
- {"isAdmin": this.isAdmin, "searchKey" : searchKey },
- this.searchNode
- );
- this.view.app = this;
- this.view.selectEnable = this.selectEnable;
- this.view.load();
- }.bind(this));
- },
- recordStatus: function(){
- var currentObject = this.navi.currentObject;
- if( currentObject ){
- var categoryId = currentObject.getCategoryId();
- if (categoryId){
- return {
- "columnId" : this.columnData.id,
- "categoryId" :categoryId,
- "isCategory" : currentObject.isCategory,
- "viewId" : currentObject.data.id
- };
- }else{
- return { "columnId" : this.columnData.id , "categoryId" : "whole"}
- }
- }else{
- return { "columnId" : this.columnData.id , "categoryId" : "whole" }
- }
- },
- setNaviSize: function(){
- //var titlebarSize = this.titleBar ? this.titleBar.getSize() : {"x":0,"y":0};
- var nodeSize = this.node.getSize();
- //var pt = this.naviContainerNode.getStyle("padding-top").toFloat();
- //var pb = this.naviContainerNode.getStyle("padding-bottom").toFloat();
- //var height = nodeSize.y-pt-pb-titlebarSize.y;
- this.naviContainerNode.setStyle("height", ""+nodeSize.y+"px");
- }
- });
- MWF.xApplication.cms.Module.Navi = new Class({
- Implements: [Options, Events],
- options : {
- "categoryId" :"" ,
- "viewId" : "",
- "isCategory" : false,
- "navi" : -1
- },
- initialize: function(app, node, columnData, options){
- this.setOptions(options);
- this.app = app;
- this.node = $(node);
- this.columnData = columnData;
- this.categoryList = [];
- this.css = this.app.css;
- this.load();
- },
- load: function(){
- var self = this;
- var showAll = (typeOf(this.columnData.showAllDocuments) === "boolean" ? this.columnData.showAllDocuments : true).toString();
- if( showAll !== "false" ){
- this.allView = new MWF.xApplication.cms.Module.NaviAllView( this, this.node, {} );
- }
- if( this.columnData.config.latest === false ){
- this.draftView = new MWF.xApplication.cms.Module.NaviDraftView( this, this.node, {} );
- }
- var allowWaitPublish = (typeOf(this.columnData.allowWaitPublish) === "boolean" ? this.columnData.allowWaitPublish : false).toString();
- if( allowWaitPublish === "true" ){
- this.delayView = new MWF.xApplication.cms.Module.NaviDelayView( this, this.node, {} );
- }
- new Element("div",{
- "styles" : this.css.viewNaviBottom
- }).inject(this.node);
- this.app.restActions.listCategory( this.columnData.id, function( json ) {
- json.data.each(function (d, idx) {
- var isCurrent = false;
- var category = new MWF.xApplication.cms.Module.NaviCategory(this, this.node,d, {} );
- this.categoryList.push( category );
- if( showAll == "false" && idx === 0 ){
- category.setCurrent();
- }
- this.fireEvent("postLoad");
- }.bind(this))
- }.bind(this))
- }
- });
- MWF.xApplication.cms.Module.NaviCategory = new Class({
- Implements: [Options, Events],
- options: {
- "style": "default"
- },
- initialize: function ( navi, container, data, options) {
- this.setOptions(options);
- this.navi = navi;
- this.app = navi.app;
- this.container = $(container);
- this.data = data;
- this.css = this.app.css;
- this.load();
- },
- load: function () {
- var _self = this;
- this.isCategory = true;
- this.isCurrent = false;
- this.isExpended = false;
- this.hasSub = false;
- this.naviViewList = [];
- if( this.navi.options.categoryId == this.data.id && this.navi.options.isCategory ){
- this.isCurrent = true;
- }
- this.reveal = this.getRevealData();
- this.node = new Element("div.categoryNaviNode", {
- "styles": this.css.categoryNaviNode
- }).inject(this.container);
- this.iconNode = new Element("i.o2icon-files", {
- "styles": this.css.categoryNaviIcon
- }).inject(this.node);
- this.expendNode = new Element("div").inject(this.node);
- this.setExpendNodeStyle();
- if( this.hasSub ){
- this.expendNode.addEvent( "click" , function(ev){
- this.triggerExpend();
- ev.stopPropagation();
- }.bind(this));
- }
- this.textNode = new Element("div.categoryNaviTextNode",{
- "styles": this.css.categoryNaviTextNode,
- "text": this.data.name //this.defaultRevealData.id == "defaultList" ? this.data.name : this.defaultRevealData.showName
- }).inject(this.node);
- this.node.addEvents({
- "mouseover": function(){ if ( !_self.isCurrent ){
- this.setStyles(_self.app.css.categoryNaviNode_over);
- this.addClass("mainColor_bg_opacity");
- } },
- "mouseout": function(){ if ( !_self.isCurrent ){
- this.setStyles( _self.app.css.categoryNaviNode );
- this.removeClass("mainColor_bg_opacity");
- } },
- click : function(){ _self.setCurrent(this);}
- });
- this.listNode = new Element("div.viewNaviListNode",{
- "styles" : this.css.viewNaviListNode
- }).inject(this.container);
- this.loadListContent();
- if( this.isCurrent ){
- this.setCurrent();
- }
- },
- getRevealData: function(){
- debugger;
- var j = this.data.extContent;
- if( j ){
- this.extContent = JSON.parse( j );
- }
- if( !this.extContent || !this.extContent.reveal || this.extContent.reveal.length == 0 ){ //兼容以前的设置
- this.extContent = { reveal : [] };
- this.app.restActions.listViewByCategory( this.data.id, function(json){
- ( json.data || [] ).each( function(d){
- var itemData = {
- "type" : "list",
- "name" : d.name,
- "showName" : d.name,
- "id" : d.id,
- "alias" : d.alias,
- "appId" : d.appId,
- "formId" : d.formId,
- "formName" : d.formName
- };
- this.extContent.reveal.push( itemData );
- }.bind(this));
- }.bind(this), null, false );
- }
- this.extContent.reveal.each( function( r, i ){
- if(this.data.defaultViewName && r.id == this.data.defaultViewName ){
- this.defaultRevealData = r;
- }else if( i>0 ){
- this.isExpended = true;
- this.hasSub = true;
- }
- }.bind(this));
- if( !this.extContent || !this.extContent.reveal || this.extContent.reveal.length == 0 ){
- this.extContent = { reveal : [{
- id : "defaultList",
- showName : this.app.lp.systemList,
- name : this.app.lp.systemList
- }] };
- }
- this.revealData = this.extContent.reveal;
- if( !this.defaultRevealData ){
- this.defaultRevealData = {
- id : "defaultList",
- showName : this.app.lp.systemList,
- name : this.app.lp.systemList
- }
- }
- },
- setExpendNodeStyle : function(){
- var style;
- if( this.hasSub ){
- if( this.isExpended ){
- if( this.isCurrent ){
- style = this.css.categoryExpendNode_selected;
- this.expendNode.addClass("mainColor_color");
- }else{
- style = this.css.categoryExpendNode;
- this.expendNode.removeClass("mainColor_color");
- }
- this.expendNode.removeClass("o2icon-triangle_right").addClass("o2icon-triangle_down");
- }else{
- if( this.isCurrent ){
- style = this.css.categoryCollapseNode_selected;
- this.expendNode.addClass("mainColor_color");
- }else{
- style = this.css.categoryCollapseNode;
- this.expendNode.removeClass("mainColor_color");
- }
- this.expendNode.removeClass("o2icon-triangle_down").addClass("o2icon-triangle_right");
- }
- }else{
- style = this.css.emptyExpendNode;
- }
- this.expendNode.setStyles( style );
- },
- triggerExpend : function(){
- if( this.hasSub ){
- if( this.isExpended ){
- this.isExpended = false;
- this.listNode.setStyle("display","none")
- }else{
- this.isExpended = true;
- this.listNode.setStyle("display","")
- }
- this.setExpendNodeStyle();
- }
- },
- setCurrent : function(){
- if( this.navi.currentObject ){
- this.navi.currentObject.cancelCurrent();
- }
- this.node.setStyles( this.css.categoryNaviNode_selected );
- this.node.addClass( "mainColor_color" );
- this.node.addClass( "mainColor_bg_opacity" );
- this.iconNode.setStyles( this.css.categoryNaviIcon_selected );
- this.iconNode.addClass( "mainColor_color" );
- if( this.hasSub ){
- if( this.isExpended ){
- this.expendNode.setStyles( this.css.categoryExpendNode_selected );
- }else{
- this.expendNode.setStyles( this.css.categoryCollapseNode_selected );
- }
- this.expendNode.addClass("mainColor_color");
- }
- this.isCurrent = true;
- this.navi.currentObject = this;
- var action = this.app.importAction;
- if( action ){
- action.setStyle("display", (this.data.importViewId && this.app.isAdmin) ? "" : "none");
- }
- action = this.app.exportAction;
- if( action ){
- action.setStyle("display", (this.data.importViewId && this.app.isAdmin) ? "" : "none");
- }
- this.loadView();
- },
- cancelCurrent : function(){
- this.isCurrent = false;
- this.node.setStyles( this.css.categoryNaviNode );
- this.node.removeClass( "mainColor_color" );
- this.node.removeClass( "mainColor_bg_opacity" );
- this.iconNode.setStyles( this.css.categoryNaviIcon );
- this.iconNode.removeClass( "mainColor_color" );
- if( this.hasSub ){
- if( this.isExpended ){
- this.expendNode.setStyles( this.css.categoryExpendNode );
- }else{
- this.expendNode.setStyles( this.css.categoryCollapseNode );
- }
- this.expendNode.removeClass("mainColor_color");
- }
- },
- loadView: function( searchkey ){
- this.app.openView( this, this.data, this.viewData || this.defaultRevealData, searchkey || "", this );
- },
- loadListContent : function(){
- this.revealData.each( function( d , i){
- if( d.id != this.defaultRevealData.id ){
- var naviView = new MWF.xApplication.cms.Module.NaviView(this.navi, this, this.listNode, d, {
- "style": this.options.style,
- "index" : i
- });
- this.naviViewList.push( naviView );
- }
- }.bind(this));
- new Element("div", {
- "styles": this.css.viewNaviSepartorNode
- }).inject( this.listNode );
- },
- getCategoryId : function(){
- return this.data.id;
- }
- });
- MWF.xApplication.cms.Module.NaviView = new Class({
- Implements: [Options, Events],
- options: {
- "style": "default",
- "index" : 0
- },
- initialize: function ( navi, category, container, data, options) {
- this.setOptions(options);
- this.navi = navi;
- this.category = category;
- this.app = navi.app;
- this.data = data;
- this.container = $(container);
- this.css = this.app.css;
- this.load();
- },
- load: function(){
- this.isDefault = this.data.id == "defaultList";
- this.isCurrent = false;
- this.isCategory = false;
- if( this.navi.options.categoryId == this.category.data.id && !this.navi.options.isCategory ){
- if( this.navi.options.viewId == "defaultList" && this.isDefault ){
- this.isCurrent = true;
- }else if( this.navi.options.viewId == this.data.id ){
- this.isCurrent = true;
- }else if( this.navi.options.naviIndex == this.options.index ){
- this.isCurrent = true;
- }
- }
- var _self = this;
- this.node = new Element("div.viewNaviNode", {
- "styles": this.css.viewNaviNode,
- "text" : (this.isDefault && !this.data.showName) ? this.app.lp.defaultView : this.data.showName
- }).inject(this.container);
- this.node.addEvents({
- "mouseover": function(){ if (!_self.isCurrent){
- this.setStyles(_self.css.viewNaviNode_over);
- this.addClass("mainColor_bg_opacity");
- } },
- "mouseout": function(){ if (!_self.isCurrent){
- this.setStyles( _self.css.viewNaviNode )
- this.removeClass("mainColor_bg_opacity");
- } },
- "click": function (el) {
- _self.setCurrent();
- }
- });
- if( this.isCurrent ){
- this.setCurrent()
- }
- },
- setCurrent : function(){
- if( this.navi.currentObject ){
- this.navi.currentObject.cancelCurrent();
- }
- this.node.setStyles( this.css.viewNaviNode_selected );
- this.node.addClass( "mainColor_color" );
- this.node.addClass( "mainColor_bg_opacity" );
- this.isCurrent = true;
- this.navi.currentObject = this;
- var action = this.app.importAction;
- if( action ){
- action.setStyle("display", (this.category.data.importViewId && this.app.isAdmin) ? "" : "none");
- }
- action = this.app.exportAction;
- if( action ){
- action.setStyle("display", (this.category.data.importViewId && this.app.isAdmin) ? "" : "none");
- }
- this.loadView();
- },
- cancelCurrent : function(){
- this.isCurrent = false;
- this.node.setStyles( this.css.viewNaviNode );
- this.node.removeClass( "mainColor_color" );
- this.node.removeClass( "mainColor_bg_opacity" );
- },
- getCategoryId : function(){
- return this.category.data.id;
- },
- loadView : function( searchKey ){
- this.app.openView( this, this.category.data, this.data, searchKey || "", this );
- }
- });
- MWF.xApplication.cms.Module.NaviAllView = new Class({
- Implements: [Options, Events],
- options: {
- "style": "default"
- },
- initialize: function ( navi, container, options) {
- this.setOptions(options);
- this.navi = navi;
- this.app = navi.app;
- this.container = $(container);
- this.css = this.app.css;
- this.data = {
- "isAll" : true,
- "id" : "defaultList"
- };
- this.load();
- },
- load: function(){
- var _self = this;
- this.isDefault = true;
- this.isAll = true;
- this.isCurrent = false;
- this.isCategory = false;
- if( this.navi.options.categoryId == "whole" ){
- this.isCurrent = true;
- }
- this.listNode = new Element("div.viewNaviListNode_all",{
- "styles" : this.css.viewNaviListNode_all
- }).inject(this.container);
- this.node = new Element("div.viewNaviNode_all", {
- "styles": this.css.viewNaviNode_all,
- "text" : this.app.lp.allDocument
- }).inject(this.listNode);
- this.iconNode = new Element("i.o2icon-list4", {
- "styles": this.css.viewNaviIcon_all
- }).inject(this.node, "top");
- this.node.addEvents({
- "mouseover": function(){ if ( !_self.isCurrent ){
- this.setStyles(_self.css.viewNaviNode_all_over);
- this.addClass( "mainColor_bg_opacity" );
- }},
- "mouseout": function(){ if ( !_self.isCurrent ){
- this.setStyles( _self.css.viewNaviNode_all );
- this.removeClass( "mainColor_bg_opacity" );
- }},
- "click": function (el) {
- _self.setCurrent();
- }
- });
- new Element("div", {
- "styles": this.css.viewNaviSepartorNode
- }).inject(this.listNode);
- if( this.isCurrent ){
- this.setCurrent()
- }
- },
- setCurrent : function(){
- if( this.navi.currentObject ){
- this.navi.currentObject.cancelCurrent();
- }
- this.node.setStyles( this.css.viewNaviNode_all_selected );
- this.node.addClass( "mainColor_color" );
- this.node.addClass( "mainColor_bg_opacity" );
- this.iconNode.setStyles( this.css.viewNaviIcon_all_selected );
- this.iconNode.addClass( "mainColor_color" );
- this.isCurrent = true;
- this.navi.currentObject = this;
- var action = this.app.importAction;
- if( action ){
- action.setStyle("display","none");
- }
- var action = this.app.exportAction;
- if( action ){
- action.setStyle("display","none");
- }
- this.loadView();
- },
- cancelCurrent : function(){
- this.isCurrent = false;
- this.node.setStyles( this.css.viewNaviNode_all );
- this.node.removeClass( "mainColor_color" );
- this.node.removeClass( "mainColor_bg_opacity" );
- this.iconNode.setStyles( this.css.viewNaviIcon_all );
- this.iconNode.removeClass( "mainColor_color" );
- },
- getCategoryId : function(){
- return null;
- },
- loadView : function( searchKey ){
- this.app.openView( this, null, this.data, searchKey || "", this );
- }
- });
- MWF.xApplication.cms.Module.NaviDraftView = new Class({
- Implements: [Options, Events],
- options: {
- "style": "default"
- },
- initialize: function ( navi, container, options) {
- this.setOptions(options);
- this.navi = navi;
- this.app = navi.app;
- this.container = $(container);
- this.css = this.app.css;
- this.data = {
- "isDraft" : true,
- "id" : "defaultList"
- };
- this.load();
- },
- load: function(){
- var _self = this;
- this.isDefault = true;
- this.isAll = true;
- this.isCurrent = false;
- this.isCategory = false;
- this.listNode = new Element("div.viewNaviListNode_all",{
- "styles" : this.css.viewNaviListNode_all
- }).inject(this.container);
- this.node = new Element("div.viewNaviNode_all", {
- "styles": this.css.viewNaviNode_all,
- "text" : this.app.lp.draftStatus
- }).inject(this.listNode);
- this.iconNode = new Element("i.o2icon-list3", {
- "styles": this.css.viewNaviIcon_all
- }).inject(this.node, "top");
- this.node.addEvents({
- "mouseover": function(){ if ( !_self.isCurrent ){
- this.setStyles(_self.css.viewNaviNode_all_over);
- this.addClass( "mainColor_bg_opacity" );
- } },
- "mouseout": function(){ if ( !_self.isCurrent ){
- this.setStyles( _self.css.viewNaviNode_all );
- this.removeClass( "mainColor_bg_opacity" );
- } },
- "click": function (el) {
- _self.setCurrent();
- }
- });
- new Element("div", {
- "styles": this.css.viewNaviSepartorNode
- }).inject(this.listNode);
- if( this.isCurrent ){
- this.setCurrent()
- }
- },
- setCurrent : function(){
- if( this.navi.currentObject ){
- this.navi.currentObject.cancelCurrent();
- }
- this.node.setStyles( this.css.viewNaviNode_all_selected );
- this.node.addClass( "mainColor_color" );
- this.node.addClass( "mainColor_bg_opacity" );
- this.iconNode.setStyles( this.css.viewNaviIcon_all_selected );
- this.iconNode.addClass( "mainColor_color" );
- this.isCurrent = true;
- this.navi.currentObject = this;
- var action = this.app.importAction;
- if( action ){
- action.setStyle("display","none");
- }
- var action = this.app.exportAction;
- if( action ){
- action.setStyle("display","none");
- }
- this.loadView();
- },
- cancelCurrent : function(){
- this.isCurrent = false;
- this.node.setStyles( this.css.viewNaviNode_all );
- this.node.removeClass( "mainColor_color" );
- this.node.removeClass( "mainColor_bg_opacity" );
- this.iconNode.setStyles( this.css.viewNaviIcon_all );
- this.iconNode.removeClass( "mainColor_color" );
- },
- getCategoryId : function(){
- return null;
- },
- loadView : function( searchKey ){
- this.app.openView( this, null, this.data, searchKey || "", this );
- }
- });
- MWF.xApplication.cms.Module.NaviDelayView = new Class({
- Implements: [Options, Events],
- options: {
- "style": "default"
- },
- initialize: function ( navi, container, options) {
- this.setOptions(options);
- this.navi = navi;
- this.app = navi.app;
- this.container = $(container);
- this.css = this.app.css;
- this.data = {
- "isDelay" : true,
- "id" : "defaultList"
- };
- this.load();
- },
- load: function(){
- var _self = this;
- this.isDefault = true;
- this.isAll = true;
- this.isCurrent = false;
- this.isCategory = false;
- this.listNode = new Element("div.viewNaviListNode_all",{
- "styles" : this.css.viewNaviListNode_all
- }).inject(this.container);
- this.node = new Element("div.viewNaviNode_all", {
- "styles": this.css.viewNaviNode_all,
- "text" : this.app.lp.delayStatus
- }).inject(this.listNode);
- this.iconNode = new Element("i.o2icon-clock2", {
- "styles": this.css.viewNaviIcon_all
- }).inject(this.node, "top");
- this.node.addEvents({
- "mouseover": function(){ if ( !_self.isCurrent ){
- this.setStyles(_self.css.viewNaviNode_all_over);
- this.addClass( "mainColor_bg_opacity" );
- } },
- "mouseout": function(){ if ( !_self.isCurrent ){
- this.setStyles( _self.css.viewNaviNode_all );
- this.removeClass( "mainColor_bg_opacity" );
- } },
- "click": function (el) {
- _self.setCurrent();
- }
- });
- new Element("div", {
- "styles": this.css.viewNaviSepartorNode
- }).inject(this.listNode);
- if( this.isCurrent ){
- this.setCurrent()
- }
- },
- setCurrent : function(){
- if( this.navi.currentObject ){
- this.navi.currentObject.cancelCurrent();
- }
- this.node.setStyles( this.css.viewNaviNode_all_selected );
- this.node.addClass( "mainColor_color" );
- this.node.addClass( "mainColor_bg_opacity" );
- this.iconNode.setStyles( this.css.viewNaviIcon_all_selected );
- this.iconNode.addClass( "mainColor_color" );
- this.isCurrent = true;
- this.navi.currentObject = this;
- var action = this.app.importAction;
- if( action ){
- action.setStyle("display","none");
- }
- var action = this.app.exportAction;
- if( action ){
- action.setStyle("display","none");
- }
- this.loadView();
- },
- cancelCurrent : function(){
- this.isCurrent = false;
- this.node.setStyles( this.css.viewNaviNode_all );
- this.node.removeClass( "mainColor_color" );
- this.node.removeClass( "mainColor_bg_opacity" );
- this.iconNode.setStyles( this.css.viewNaviIcon_all );
- this.iconNode.removeClass( "mainColor_color" );
- },
- getCategoryId : function(){
- return null;
- },
- loadView : function( searchKey ){
- this.app.openView( this, null, this.data, searchKey || "", this );
- }
- });
|