123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674 |
- MWF.xApplication = MWF.xApplication || {};
- MWF.xApplication.cms = MWF.xApplication.cms || {};
- MWF.xApplication.cms.ViewDesigner = MWF.xApplication.cms.ViewDesigner || {};
- MWF.CMSVD = MWF.xApplication.cms.ViewDesigner;
- MWF.require("MWF.widget.Common", null, false);
- MWF.xDesktop.requireApp("cms.ViewDesigner", "lp."+MWF.language, null, false);
- MWF.xApplication.cms.ViewDesigner.View = new Class({
- Extends: MWF.widget.Common,
- Implements: [Options, Events],
- options: {
- "style": "default",
- "showTab": true
- },
- initialize: function(designer, data, options){
- this.setOptions(options);
- this.path = "../x_component_cms_ViewDesigner/$View/";
- this.cssPath = "../x_component_cms_ViewDesigner/$View/"+this.options.style+"/css.wcss";
- this._loadCss();
- this.designer = designer;
- this.documentFields =designer.documentFields;
- this.formFields=designer.formFields;
- this.relativeForm = data.content.relativeForm;
- this.actions = designer.actions;
- this.application = designer.application;
- this.lp = this.designer.lp;
- this.node = this.designer.designNode;
- this.tab = this.designer.tab;
- this.areaNode = new Element("div.areaNode", {"styles": {"overflow": "hidden"}});
- //this.propertyListNode = this.designer.propertyDomArea;
- //this.propertyNode = this.designer.propertyContentArea;
- this.data = data.content;
- this.isNewView = this.data.isNew;
- this.columns = [];
- this.columnsRemoved = [];
- this.autoSave();
- this.designer.addEvent("queryClose", function(){
- if (this.autoSaveTimerID) window.clearInterval(this.autoSaveTimerID);
- }.bind(this));
- },
- autoSave: function(){
- this.autoSaveTimerID = window.setInterval(function(){
- if (!this.autoSaveCheckNode) this.autoSaveCheckNode = this.designer.contentToolbarNode.getElement("#MWFViewAutoSaveCheck");
- if (this.autoSaveCheckNode){
- if (this.autoSaveCheckNode.get("checked")){
- this.save();
- }
- }
- }.bind(this), 60000);
- },
- load : function(){
- this.setAreaNodeSize();
- this.designer.addEvent("resize", function(){
- this.setAreaNodeSize();
- this.setPropertyContentResize();
- this.setViewNodeWidth();
- }.bind(this));
- this.page = this.tab.addTab(this.areaNode, this.data.name || this.designer.lp.newView, (!this.data.isNew && this.data.id!=this.designer.options.id));
- this.page.view = this;
- this.page.addEvent("show", function(){
- this.designer.viewListAreaNode.getChildren().each(function(node){
- var view = node.retrieve("view");
- if (view.id==this.data.id || (view.content.isNew && this.isNewView) ){
- if (this.designer.currentListViewItem){
- this.designer.currentListViewItem.setStyles(this.designer.css.listViewItem);
- }
- node.setStyles(this.designer.css.listViewItem_current);
- this.designer.currentListViewItem = node;
- this.lisNode = node;
- }
- }.bind(this));
- if(!this.propertyNode)this.loadProperty();
- }.bind(this));
- this.page.addEvent("queryClose", function(){
- if (this.autoSaveTimerID) window.clearInterval(this.autoSaveTimerID);
- this.saveSilence();
- if (this.lisNode) this.lisNode.setStyles(this.designer.css.listScriptItem);
- }.bind(this));
- this.page.tabNode.addEvent("dblclick", this.designer.maxOrReturnEditor.bind(this.designer));
- this.createViewNode();
- if (this.options.showTab) this.page.showTabIm();
- this.setPropertyContentResize();
- },
- saveSilence: function(callback){
- this._save(callback);
- },
- save: function(callback){
- //if (this.designer.tab.showPage==this.page){
- //
- //}
- this._save( callback, true );
- },
- _save : function(callback, isNotice ){
- var _self = this;
- if (!this.data.name || this.data.name==""){
- this.designer.notice(this.lp.notice.inputName, "error");
- return false;
- }
- //var flag = true;
- //if( flag ){
- // this.columns.each(function(column){
- // flag = column.save();
- // })
- //}
- //if(!flag)return false;
- //this.columnsRemoved.each(function(column){
- // column.delete(function(){
- // _self.columnsRemoved.erase(this);
- // }.bind(column));
- //})
- var data = {};
- data.isNew = this.isNewView; //this.data.isNew;
- data.id = this.data.id;
- data.name = this.data.name;
- data.alias = this.data.alias;
- data.description = this.data.description;
- data.appId = this.data.application;
- data.formId = this.data.relativeForm.id;
- data.orderType = this.data.sortType;
- data.orderField = this.data.sortField;
- data.orderFieldType = this.data.sortFieldType;
- this.data.isNew = false;
- this.data.columns = this.getColumnsData();
- data.fields = this.getColumnsItemData();
- data.content = JSON.stringify(this.data);
- this.designer.actions.saveView(data, function(json){
- this.data.id = json.data.id;
- if( isNotice ){
- this.designer.notice(this.designer.lp.notice.save_success, "success", this.node, {"x": "left", "y": "bottom"});
- }
- if (this.lisNode) {
- this.lisNode.getLast().set("text", this.data.name+"("+this.data.alias+")");
- if( this.isNewView ){
- this.lisNode.eliminate("view");
- this.lisNode.store("view",json.data);
- }
- }
- this.data.isNew = false;
- this.isNewView = false;
- this.page.textNode.set("text", this.data.name);
- if (callback) callback();
- }.bind(this));
- },
- saveAs: function(){
- var form = new MWF.xApplication.cms.ViewDesigner.View.NewName(this, {
- name : this.data.name + "_" + this.designer.lp.copy
- }, {
- onSave : function( data, callback ){
- this._saveAs( data.name , callback);
- }.bind(this)
- }, {
- app: this.designer
- });
- form.edit()
- },
- clone : function( obj ){
- if (null == obj || "object" != typeof obj) return obj;
- if ( typeof obj.length==='number'){ //数组
- //print( "array" );
- var copy = [];
- for (var i = 0, len = obj.length; i < len; ++i) {
- copy[i] = this.clone(obj[i]);
- }
- return copy;
- }else{
- var copy = {};
- for (var attr in obj) {
- copy[attr] = this.clone(obj[attr]);
- }
- return copy;
- }
- },
- _saveAs : function( name , callback){
- var _self = this;
- var d = this.clone( this.data );
- d.name = name;
- d.alias = "";
- var data = {};
- data.isNew = true; //this.data.isNew;
- data.id = this.designer.actions.getUUID();
- data.name = name;
- data.alias = "";
- data.description = d.description;
- data.appId = d.application;
- data.formId = d.relativeForm.id;
- data.orderType = d.sortType;
- data.orderField = d.sortField;
- data.orderFieldType = d.sortFieldType;
- d.isNew = false;
- var columnsData = this.clone( this.getColumnsData() );
- var fieldData = this.clone( this.getColumnsItemData() );
- columnsData.each( function( column, i ){
- var field = fieldData[i];
- var id = this.designer.actions.getUUID();
- column.id = id;
- column.isNew = false;
- column.viewId = data.id;
- field.id = id;
- field.isNew = true;
- field.viewId = data.id;
- }.bind(this));
- d.columns = columnsData;
- data.fields = fieldData;
- data.content = JSON.stringify(d);
- this.designer.actions.saveView(data, function(json){
- this.designer.notice(this.designer.lp.notice.saveAs_success, "success", this.node, {"x": "left", "y": "bottom"});
- if (callback) callback();
- }.bind(this));
- },
- explode: function(){},
- implode: function(){},
- setAreaNodeSize: function(){
- var size = this.node.getSize();
- var tabSize = this.tab.tabNodeContainer.getSize();
- var y = parseInt(size.y - tabSize.y);
- this.areaNode.setStyle("height", ""+y+"px");
- },
- setViewNodeWidth: function(){
- this.columnWidth = this.getColumnsWidth();
- var cWidth = this.columnWidth + ( this.columns.length * 2 ) + 300;
- if( this.node.getSize().x - 10 > cWidth ){
- this.viewNode.setStyle( "width", this.node.getSize().x - 10 + "px");
- }else{
- this.viewNode.setStyle( "width" , cWidth + "px" );
- }
- },
- createViewNode: function() {
- this.viewAreaNode = new Element("div.viewAreaNode", { styles : { "overflow-x" : "scroll", "overflow-y" : "hidden" } }).inject( this.areaNode );
- this.viewAreaNode.addEvent("scroll", function() {
- if (this.currentColumn)this.currentColumn._hideActions();
- }.bind(this));
- //MWF.require("MWF.widget.ScrollBar", function(){
- // new MWF.widget.ScrollBar(this.viewAreaNode, {"distance": 100});
- //}.bind(this));
- this.setViewAreaNodeSize();
- this.viewAreaNode.addEvent( "click", function(){
- if(this.currentColumn) {
- this.currentColumn.cancelCurrent();
- this.currentColumn.hideProperty();
- }
- this.showPropertyContent();
- }.bind(this));
- this.viewNode = new Element("div.viewNode", { "styles": this.css.viewNode }).inject( this.viewAreaNode );
- this.headBar = new MWF.xApplication.cms.ViewDesigner.View.HeadBar(this);
- if( this.data.columns && this.data.columns.length > 0 ){
- for(var i=0;i<this.data.columns.length;i++){
- var c = this.data.columns[i];
- this.addColumn( i, c );
- }
- }else {
- this.addColumn(0);
- }
- this.setViewNodeWidth();
- },
- setViewAreaNodeSize: function(){
- var size = this.node.getSize();
- var tabSize = this.tab.tabNodeContainer.getSize();
- var y = parseInt((size.y - tabSize.y)/3);
- this.viewAreaNode.setStyle("height", ""+y+"px");
- },
- getTemplateData: function( callback){
- if (this.dataTemplate){
- if (callback) callback(this.dataTemplate);
- }else{
- var templateUrl = this.path +this.options.style+"/columnTemplate.json";
- MWF.getJSON(templateUrl, function(responseJSON, responseText){
- this.dataTemplate = responseJSON;
- if (callback) callback(responseJSON);
- }.bind(this), false );
- }
- },
- addColumn : function( index , data ){
- if( !data ){
- this.getTemplateData();
- data = Object.clone( this.dataTemplate );
- data.isNew = true;
- data.id = this.actions.getUUID();
- }
- index = index || 0;
- if( this.columns.length <= index ){
- index = this.columns.length;
- }
- var column = new MWF.xApplication.cms.ViewDesigner.View.Column(this, data , index );
- if( this.columns.length == index ){
- this.columns.push( column );
- }else{
- var tmpColumns = this.columns.splice( index, this.columns.length - index , column );
- tmpColumns.each(function(c){
- c.data.index = c.data.index + 1;
- c.node.set("index", c.data.index);
- });
- this.columns = this.columns.concat( tmpColumns );
- }
- this.setEachColumnWidth();
- this.setViewNodeWidth();
- },
- moveColumn : function(fromIndex, toIndex){
- if( fromIndex == toIndex )return;
- var tmpColumns = [];
- for(var i=0; i<this.columns.length; i++){
- if( i != fromIndex ){
- if( i == toIndex && toIndex != this.columns.length ) {
- tmpColumns.push( this.columns[fromIndex] );
- }
- tmpColumns.push( this.columns[i] );
- if( i == this.columns.length-1 && toIndex == this.columns.length ) {
- tmpColumns.push( this.columns[fromIndex] );
- }
- }
- }
- this.columns = tmpColumns;
- for(var i=0; i<this.columns.length; i++){
- c = this.columns[i];
- c.data.index = i;
- c.node.set("index",i);
- }
- this.setViewNodeWidth();
- },
- removeColumn : function( index ){
- if( this.columns.length <= 1 ){
- this.designer.notice(this.designer.lp.notice.noRemoveOnlyColumn, "error");
- return;
- }
- for( var i=index+1; i<this.columns.length;i++ ){
- c = this.columns[i];
- c.data.index = c.data.index - 1;
- //c.contentNode.set("text",c.index);
- c.node.set("index", c.data.index);
- }
- this.showPropertyContent();
- var column = this.columns.splice(index, 1);
- if( !column[0].data.isNew ){
- this.columnsRemoved.push(column[0]);
- }
- column[0].removeNode();
- this.setEachColumnWidth();
- this.setViewNodeWidth();
- },
- getColumnNodes : function(){
- var columnNodes = [];
- this.columns.each(function(column){
- columnNodes.push(column.node);
- });
- return columnNodes;
- },
- getColumnsWidth : function(){
- var width = 0;
- this.columns.each(function(column){
- width = width + column.data.width;
- });
- return width;
- },
- setEachColumnWidth : function(){
- var totalWidth = this.getColumnsWidth();
- this.columns.each(function(column){
- if( column.property ){
- var per = Math.round( (column.data.width/totalWidth) * 100 );
- column.property.columnPercentageWidthNode.set("text", per );
- column.data.widthPer = per;
- }
- })
- },
- getColumnsData : function(){
- var data = [];
- this.columns.each(function(column){
- data.push(column.data);
- });
- return data;
- },
- getColumnsItemData: function( ignoreNew ){
- var data = [];
- this.columns.each(function(column){
- data.push(column.getData());
- if(!ignoreNew)column.data.isNew = false;
- });
- return data;
- },
- //loadProperty------------------------
- loadProperty: function(){
- this.propertyNode = new Element("div", {
- "styles": this.css.propertyNode
- }).inject(this.areaNode);
- this.propertyContentNode = new Element("div.propertyContentNode", {
- "styles": this.css.propertyContentNode
- }).inject(this.propertyNode);
- this.viewAreaPercent = 0.3;
- this.propertyContentResizeNode = new Element("div", {
- "styles": this.css.propertyContentResizeNode
- }).inject(this.propertyContentNode);
- this.propertyTitleNode = new Element("div.propertyTitleNode", {
- "styles": this.css.propertyTitleNode,
- "text": this.lp.viewProperty
- }).inject(this.propertyContentNode);
- this.propertyContentArea = new Element("div.propertyContentArea", {
- "styles": this.css.propertyContentArea
- }).inject(this.propertyContentNode);
- this.loadPropertyContentResize();
- this.setPropertyContent();
- this.propertyNode.addEvent("keydown", function(e){e.stopPropagation();});
- },
- setPropertyContent: function(){
- this.propertyContentContainArea = new Element("div.propertyContentContainArea").inject(this.propertyContentArea);
- this.viewPropertyNode = new Element("div.viewPropertyNode", {"styles": this.css.viewPropertyNode});
- //this.eventsNode = new Element("div.eventsNode", {"styles": this.css.eventsNode});
- MWF.require("MWF.widget.Tab", function(){
- this.propertyTab = new MWF.widget.Tab(this.propertyContentContainArea, {"style": "moduleList"});
- this.propertyTab.load();
- var page = this.propertyTab.addTab(this.viewPropertyNode, this.lp.base, false);
- page.contentNodeArea.set("class","viewContentNodeArea");
- this.setScrollBar(page.contentNodeArea, "small", null, null);
- //page = this.propertyTab.addTab(this.eventsNode, this.lp.events, false);
- //page.contentNodeArea.set("class","eventsContentNodeArea");
- //this.setScrollBar(page.contentNodeArea, "small", null, null);
- this.propertyTab.pages[0].showTab();
- }.bind(this));
- var table = new Element("table", { "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "styles" : this.css.editTable, "class" : "editTable"}).inject( this.viewPropertyNode );
- var tr = new Element("tr").inject(table);
- var td = new Element("td", { "class" : "editTableTitle", "styles" : this.css.editTableTitle, "text" : this.lp.id }).inject(tr);
- var td = this.propertyIdNode = new Element("td", { "class" : "editTableValue", "styles" : this.css.editTableValue , "text": this.data.id ? this.data.id : "" }).inject(tr);
- var tr = new Element("tr").inject(table);
- var td = new Element("td", { "class" : "editTableTitle", "styles" : this.css.editTableTitle, "text" : this.lp.relativeForm }).inject(tr);
- var td = new Element("td", { "class" : "editTableValue", "styles" : this.css.editTableValue , "text": this.relativeForm.name }).inject(tr);
- var tr = new Element("tr").inject(table);
- var td = new Element("td", { "class" : "editTableTitle", "styles" : this.css.editTableTitle, "text" : this.lp.name }).inject(tr);
- var td = new Element("td", { "class" : "editTableValue", "styles" : this.css.editTableValue }).inject(tr);
- this.propertyNameNode = new Element("input", {"styles": this.css.editTableInput}).inject(td);
- this.propertyNameNode.addEvent("change",function(){
- this.data.name = this.propertyNameNode.get("value");
- }.bind(this));
- var tr = new Element("tr").inject(table);
- var td = new Element("td", { "class" : "editTableTitle", "styles" : this.css.editTableTitle, "text" : this.lp.alias }).inject(tr);
- var td = new Element("td", { "class" : "editTableValue", "styles" : this.css.editTableValue }).inject(tr);
- this.propertyAliasNode = new Element("input", {"styles": this.css.editTableInput}).inject(td);
- this.propertyAliasNode.addEvent("change",function(){
- this.data.alias = this.propertyAliasNode.get("value");
- }.bind(this));
- var tr = new Element("tr").inject(table);
- var td = new Element("td", { "class" : "editTableTitle", "styles" : this.css.editTableTitle, "text" : this.lp.sortColumn }).inject(tr);
- var td = new Element("td", { "class" : "editTableValue", "styles" : this.css.editTableValue }).inject(tr);
- this.propertySortFieldNode = this.getFieldsSelectElement();
- this.propertySortFieldNode.inject(td);
- this.propertySortFieldNode.addEvent("change",function(){
- this.data.sortField = this.getSelectText(this.propertySortFieldNode);
- this.data.sortFieldType = this.getSelectValue(this.propertySortFieldNode);
- }.bind(this));
- this.propertySortTypeNode = this.getSortSelectElement();
- this.propertySortTypeNode.inject(td);
- this.propertySortTypeNode.addEvent("change",function(){
- this.data.sortType = this.getSelectValue(this.propertySortTypeNode);
- }.bind(this));
- var tr = new Element("tr").inject(table);
- var td = new Element("td", { "class" : "editTableTitle", "styles" : this.css.editTableTitle, "text" : this.lp.description }).inject(tr);
- var td = new Element("td", { "class" : "editTableValue", "styles" : this.css.editTableValue }).inject(tr);
- this.propertyDescriptionNode = new Element("textarea", {"styles": this.css.editTableTextarea}).inject(td);
- this.propertyDescriptionNode.addEvent("change",function(){
- this.data.description = this.propertyDescriptionNode.get("text");
- }.bind(this));
- //var tr = new Element("tr").inject(table);
- //var td = new Element("td", { "class" : "editTableTitle", "styles" : this.css.editTableTitle, "text" : "JS Header" }).inject(tr);
- //this.jsHeaderContainer = new Element("td", { "class" : "editTableValue", "styles" : this.css.editTableValue }).inject(tr);
- this.setPropertyValue();
- },
- hidePropertyContent : function(){
- this.propertyContentContainArea.setStyle("display", "none");
- },
- showPropertyContent : function(){
- if(this.currentColumn) {
- this.currentColumn.hideProperty();
- }
- this.propertyTitleNode.set("text",this.lp.viewProperty);
- this.propertyContentContainArea.setStyle("display", "block");
- },
- getFormSelectElement : function(formName, formId ){
- var obj = new Element("select", { "styles" : this.css.propertyFormNode });
- this.actions.listForm(this.application.id, function(json){
- json.data.each(function( form ){
- var opt = new Element("option", {
- "value":form.id,
- "text":form.name
- }).inject(obj);
- if( formId == form.id ){
- opt.selected = true;
- }
- })
- }.bind(this), null, false);
- return obj;
- },
- getFieldsSelectElement : function(){
- var obj = new Element("select");
- new Element("option", {
- "value":"",
- "text":""
- }).inject(obj);
- this.documentFields.concat(this.formFields).each(function( field ){
- var opt = new Element("option", {
- "value":field.type,
- "text":field.name
- }).inject(obj);
- if( this.data.sortField == field.name ){
- opt.selected = true;
- }else if( field.name === "createTime" ){
- opt.selected = true;
- }
- }.bind(this));
- return obj;
- },
- getSortSelectElement : function(){
- var obj = new Element("select", {"styles":{"margin-left":"5px"}});
- var opt = new Element("option", {
- "value":"ASC",
- "text":this.lp.asc
- }).inject(obj);
- if( this.data.sortType == "ASC" ){
- opt.selected = true;
- }
- var opt = new Element("option", {
- "value":"DESC",
- "text":this.lp.desc
- }).inject(obj);
- if( this.data.sortType == "DESC" ){
- opt.selected = true;
- }
- return obj;
- },
- getSelectValue : function( el ){
- var value;
- el.getElements("option").each(function(opt){
- if(opt.selected){
- value = opt.value;
- }
- });
- return value;
- },
- getSelectText : function( el ){
- var text;
- el.getElements("option").each(function(opt){
- if(opt.selected){
- text = opt.text;
- }
- });
- return text;
- },
- loadPropertyContentResize: function(){
- this.propertyContentResize = new Drag(this.propertyContentResizeNode, {
- "snap": 1,
- "onStart": function(el, e){
- var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
- var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
- el.store("position", {"x": x, "y": y});
- var size = this.viewAreaNode.getSize();
- el.store("initialHeight", size.y);
- }.bind(this),
- "onDrag": function(el, e){
- var size = this.areaNode.getSize();
- // var x = e.event.x;
- var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
- var position = el.retrieve("position");
- var dy = y.toFloat()-position.y.toFloat();
- var initialHeight = el.retrieve("initialHeight").toFloat();
- var height = initialHeight+dy;
- if (height<60) height = 60;
- if (height> size.y-60) height = size.y-60;
- this.viewAreaPercent = height/size.y;
- this.setPropertyContentResize();
- }.bind(this)
- });
- },
- setPropertyContentResize: function(){
- var size = this.areaNode.getSize();
- var resizeNodeSize = this.propertyContentResizeNode.getSize();
- var height = size.y-resizeNodeSize.y-27;
- var domHeight = this.viewAreaPercent*height;
- var contentHeight = height-domHeight;
- this.viewAreaNode.setStyle("height", ""+domHeight+"px");
- this.propertyContentNode.setStyle("height", ""+contentHeight+"px");
- var tabSize = this.propertyTab.tabNodeContainer.getSize();
- var titleSize = this.propertyTitleNode.getSize();
- var areaHeight = this.propertyPageHeight = contentHeight-tabSize.y-titleSize.y-20;
- this.propertyTab.pages.each(function( page ){
- page.contentNodeArea.setStyle("height",""+ areaHeight +"px" );
- });
- if( this.currentColumn && this.currentColumn.property ){
- this.currentColumn.property.propertyTab.pages.each(function( page ){
- page.contentNodeArea.setStyle("height",""+ areaHeight +"px" );
- })
- }
- },
- setPropertyValue: function(){
- this.propertyIdNode.set("text", this.data.id);
- this.propertyNameNode.set("value", this.data.name);
- this.propertyAliasNode.set("value", this.data.alias);
- this.propertyDescriptionNode.set("value", this.data.description);
- //this.loadScriptEditor( this.jsHeaderContainer, "jsheader", "JS Header" );
- //if( !this.data.events ){
- // this.getViewEventsData();
- //}
- //this.loadEventsEditor( this.eventsNode, this.data.events );
- },
- loadEventsEditor: function( eventsNode, eventsData ){
- MWF.xDesktop.requireApp("cms.FormDesigner", "widget.EventsEditor", function(){
- var eventsEditor = new MWF.xApplication.cms.FormDesigner.widget.EventsEditor( eventsNode, this.designer, {
- "helpStyle" : "cmsView",
- "maxObj": this.node
- });
- eventsEditor.load( eventsData );
- }.bind(this));
- },
- loadScriptEditor: function(node, name, title, style){
- var scriptContent = this.data[name];
- MWF.require("MWF.widget.ScriptArea", function(){
- var scriptArea = this.scriptArea = new MWF.widget.ScriptArea(node, {
- "title": title,
- "maxObj": this.node,
- "onChange": function(){
- this.data[name] = scriptArea.toJson();
- }.bind(this),
- "onSave": function(){
- this.save();
- }.bind(this),
- "style": style || "default",
- "helpStyle" : "cmsView"
- });
- scriptArea.load(scriptContent);
- }.bind(this));
- },
- getViewEventsData: function( callback){
- var templateUrl = this.path +this.options.style+"/viewEventsTemplate.json";
- MWF.getJSON(templateUrl, function(responseJSON, responseText){
- this.data.events = responseJSON;
- if (callback) callback(responseJSON);
- }.bind(this), false );
- },
- getOperationConfig: function( callback){
- if (this.operationConfig){
- if (callback) callback(this.operationConfig);
- }else{
- var templateUrl = this.path +this.options.style+"/operation.json";
- MWF.getJSON(templateUrl, function(responseJSON, responseText){
- this.operationConfig = responseJSON;
- if (callback) callback(responseJSON);
- }.bind(this), false );
- }
- return this.operationConfig;
- }
- });
- MWF.xApplication.cms.ViewDesigner.View.Column = new Class({
- Implements: [Options, Events],
- options: {
- "style": "default",
- //"propertyPath": "../x_component_process_FormDesigner/Module/Table$Td/table$td.html",
- "actions": [
- {
- "name": "insertColLeft",
- "icon": "insertColLeft.png",
- "event": "click",
- "action": "insertColLeft",
- "title": MWF.xApplication.cms.ViewDesigner.LP.insertColLeft
- },
- {
- "name": "insertColRight",
- "icon": "insertColRight.png",
- "event": "click",
- "action": "insertColRight",
- "title": MWF.xApplication.cms.ViewDesigner.LP.insertColRight
- },
- {
- "name": "deleteCol",
- "icon": "deleteCol1.png",
- "event": "click",
- "action": "deleteCol",
- "title": MWF.xApplication.cms.ViewDesigner.LP.deleteCol
- },
- {
- "name": "moveCol",
- "icon": "move1.png",
- "event": "click",
- "action": "moveCol",
- "title": MWF.xApplication.cms.ViewDesigner.LP.moveCol
- }
- ],
- "actionNodeStyles": {
- "width": "16px",
- "height": "16px",
- "margin-left": "2px",
- "margin-right": "2px",
- "float": "left",
- "border": "1px solid #F1F1F1",
- "cursor": "pointer"
- }
- },
- initialize: function(view, data, index ){
- this.view = view;
- this.css = view.css;
- this.designer = view.designer;
- this.data = data;
- this.container = view.viewNode;
- this.data.index = index;
- this.isCurrent = false;
- this.load();
- },
- load: function(){
- this.createNodes();
- this.createIconAction();
- this.setEvent();
- },
- createNodes : function(){
- this.node = new Element("div.column", {"styles": this.view.css.columnNode , "index" : this.data.index } );
- this.node.store("column", this);
- var tmpNode = this.container.getFirst("div.column[index="+this.data.index+"]");
- if( !tmpNode ){
- this.node.inject(this.container)
- }else{
- this.node.inject(tmpNode,"before");
- }
- this.contentNode = new Element("div", {"styles": this.view.css.columnContentNode } ).inject(this.node);
- this.contentTitleNode = new Element("div.columnContentTitleNode", {"styles": this.view.css.columnContentTitleNode } ).inject(this.contentNode);
- if( this.data.title ){
- this.contentTitleNode.set("text",this.data.title);
- }else{
- this.contentTitleNode.set("text", this.view.lp.noTitle );
- }
- if( this.data.width ){
- this.contentNode.setStyle("width",this.data.width);
- }else{
- this.contentNode.setStyle("width","150px");
- this.data.width = 150;
- }
- if( this.data.align ){
- //this.contentNode.setStyle("text-align", this.data.align );
- this.setAlignIcon();
- }
- this.resizeNode = new Element("div",{"styles":this.view.css.columnResizeNode}).inject(this.node);
- this.loadResize();
- if( this.data.operation ){
- for(var o in this.data.operation){
- op = this.data.operation[o];
- this.setOperation(op.name,op.text,op.icon,op.iconOver, op.action);
- }
- }
- if( this.data.sortByClickTitle == "yes" ){
- this.setSortIcon();
- }
- },
- setEvent:function(){
- this.node.addEvents({
- "click":function(e){
- if( !this.view.isOnDragging ){
- this.setCurrent();
- }
- e.stopPropagation();
- }.bind(this),
- "mouseover" : function(e){
- if(!this.isCurrent)this.contentNode.setStyles( this.view.css.columnContentNode_over );
- }.bind(this),
- "mouseout" : function(e){
- if(!this.isCurrent)this.contentNode.setStyles( this.view.css.columnContentNode );
- }.bind(this)
- })
- },
- _showActions: function(){
- if (this.actionArea){
- if (this.options.actions.length){
- this._setActionAreaPosition();
- this.actionArea.setStyle("display", "block");
- }
- }
- },
- _hideActions: function(){
- if (this.actionArea) this.actionArea.setStyle("display", "none");
- },
- createIconAction: function(){
- this.actionNodes = this.actionNodes || {};
- if (!this.actionArea){
- this.actionArea = new Element("div", {
- styles: {
- "display": "none",
- // "width": 18*this.options.actions.length,
- "position": "absolute",
- "background-color": "#F1F1F1",
- "padding": "1px",
- "padding-right": "0px",
- "border": "1px solid #AAA",
- "box-shadow": "0px 2px 5px #999",
- "opacity": 1,
- "z-index": 100
- }
- }).inject(this.container, "after");
- this.options.actions.each(function(action){
- var actionNode = this.actionNodes[action.name] = new Element("div", {
- "styles": this.options.actionNodeStyles,
- "title": action.title
- }).inject(this.actionArea);
- actionNode.setStyle("background", "url("+this.view.path+this.options.style+"/icon/"+action.icon+") no-repeat left center");
- actionNode.addEvent(action.event, function(e){
- this[action.action](e);
- e.stopPropagation();
- }.bind(this));
- actionNode.addEvents({
- "mouseover": function(e){
- e.target.setStyle("border", "1px solid #999");
- }.bind(this),
- "mouseout": function(e){
- e.target.setStyle("border", "1px solid #F1F1F1");
- }.bind(this)
- });
- }.bind(this));
- }
- },
- _setActionAreaPosition: function(){
- var p = this.node.getPosition(this.designer.designNode.getOffsetParent());
- var y = p.y-25;
- var x = p.x;
- this.actionArea.setPosition({"x": x, "y": y});
- },
- insertColLeft : function(){
- var index = this.data.index;
- this.view.addColumn( index );
- this.view.columns[index].setCurrent();
- },
- insertColRight : function(){
- var index = this.data.index + 1;
- this.view.addColumn( index );
- this.view.columns[index].setCurrent();
- },
- deleteCol : function(){
- var _self = this;
- this.designer.confirm("warn", this.actionNodes.deleteCol, MWF.xApplication.cms.ViewDesigner.LP.deleteColConfirmTitle, MWF.xApplication.cms.ViewDesigner.LP.deleteColConfirm, 300, 120, function(){
- _self.view.removeColumn(_self.data.index);
- this.close();
- }, function(){
- this.close();
- });
- },
- removeNode : function(){
- if(this.actionArea)this.actionArea.destroy();
- this.node.destroy();
- },
- cancelCurrent : function(){
- this.isCurrent = false;
- this.contentNode.setStyles(this.view.css.columnContentNode);
- this._hideActions()
- },
- setCurrent : function(){
- if(this.view.currentColumn) {
- if( this.view.currentColumn.currentTimeout ){
- clearTimeout( this.view.currentColumn.currentTimeout );
- }
- this.view.currentColumn.cancelCurrent();
- this.view.currentColumn.hideProperty();
- }
- this.contentNode.setStyles( this.view.css.columnContentNode_current );
- this.isCurrent = true;
- this.setNodeScroll();
- this.currentTimeout = setTimeout( function(){
- this._showActions();
- this.showProperty();
- if( this.view.propertyPageHeight ){
- this.property.propertyTab.pages.each(function( page ){
- page.contentNodeArea.setStyle("height",""+ this.view.propertyPageHeight +"px" );
- }.bind(this))
- }
- this.view.currentColumn = this;
- this.currentTimeout = null;
- }.bind(this), 100 );
- },
- setNodeScroll : function(){
- var viewAreaNode = this.view.viewAreaNode;
- var viewNode = this.view.viewNode;
- var viewAreaCrd = viewAreaNode.getCoordinates();
- var leftPoint = viewAreaCrd.left;
- var rightPoint = leftPoint + viewAreaCrd.width;
- var nodeCrd = this.node.getCoordinates();
- if( rightPoint - nodeCrd.left < 100 ){
- var d = nodeCrd.left + 100 - rightPoint;
- if( viewAreaNode.getScroll().x + d < viewNode.getSize().x ){
- viewAreaNode.scrollTo(viewAreaNode.getScroll().x + d, 0);
- }else{
- viewAreaNode.scrollTo( viewNode.getSize().x, 0);
- }
- }else if( leftPoint > nodeCrd.left ){
- var d = viewAreaNode.getScroll().x - (leftPoint - nodeCrd.left) - 10;
- if( d > 0 ){
- viewAreaNode.scrollTo( d, 0);
- }else{
- viewAreaNode.scrollTo(0, 0);
- }
- }
- },
- loadResize: function(){
- // var size = this.propertyNode.getSize();
- // var position = this.propertyResizeBar.getPosition();
- this.resize = new Drag(this.resizeNode,{
- "snap": 1,
- "onStart": function(el, e){
- var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
- var y = (Browser.name=="firefox") ? e.event.clientY : e.event.y;
- el.store("position", {"x": x, "y": y});
- var size = this.contentNode.getSize();
- el.store("initialWidth", size.x);
- }.bind(this),
- "onDrag": function(el, e){
- var x = (Browser.name=="firefox") ? e.event.clientX : e.event.x;
- // var y = e.event.y;
- var bodySize = this.view.viewNode.getSize();
- var position = el.retrieve("position");
- var initialWidth = el.retrieve("initialWidth").toFloat();
- var dx = position.x.toFloat()-x.toFloat();
- var width = initialWidth-dx;
- if (width> bodySize.x/2) width = bodySize.x/2;
- if (width<40) width = 40;
- //this.contentNode.setStyle("margin-right", width+1);
- this.contentNode.setStyle("width", width);
- this.data.width = width+10;
- if( this.property ){
- this.property.columnWidthNode.set("value",Math.round(width)+10);
- }
- this.view.setEachColumnWidth();
- this.view.setViewNodeWidth();
- }.bind(this)
- });
- },
- moveCol: function(e){
- this._createMoveNode();
- this._setNodeMove(e);
- this._hideActions();
- },
- _createMoveNode: function(){
- this.moveNode = new Element("div", {
- "MWFType": "label",
- "styles": this.view.css.moduleNodeMove,
- "text": this.node.get("text"),
- "events": {
- "selectstart": function(){
- return false;
- }
- }
- }).inject(this.container);
- },
- _setNodeMove: function(e){
- this._setMoveNodePosition(e);
- var droppables = this.view.getColumnNodes(); //[this.container].concat(this.view.node, this.view.areaNode,this.view.columns);
- droppables.push( this.view.headBar.node );
- //debugger;
- var nodeDrag = new Drag.Move(this.moveNode, {
- "droppables": droppables,
- "onEnter": function(dragging, inObj){
- var column = inObj.retrieve("column");
- if (column) column._dragIn(this);
- }.bind(this),
- "onLeave": function(dragging, inObj){
- var column = inObj.retrieve("column");
- if (column) column._dragOut(this);
- }.bind(this),
- "onDrag": function(e){
- this.view.isOnDragging = true;
- this._setScroll();
- //this._nodeDrag(e, nodeDrag);
- }.bind(this),
- "onDrop": function(dragging, inObj, e){
- if (inObj){
- var column = inObj.retrieve("column");
- if (column){
- if( column.isHeadBar ){
- if( this.data.index==0 ){
- this._dragCancel(dragging);
- }else{
- this._dragComplete( column.node );
- this.view.moveColumn( this.data.index, 0 );
- }
- }else{
- if( column.data.index+1 == this.data.index || column.data.index==this.data.index ){
- this._dragCancel(dragging);
- }else{
- this._dragComplete( column.node );
- this.view.moveColumn( this.data.index, column.data.index+1 );
- }
- }
- column._dragDrop(this);
- }else{
- this._dragCancel(dragging);
- }
- }else{
- this._dragCancel(dragging);
- }
- if( this.dragColInterval ){
- clearInterval( this.dragColInterval );
- this.dragColInterval = null;
- }
- setTimeout( function(){
- this.view.isOnDragging = false;
- }.bind(this), 100 );
- e.stopPropagation();
- }.bind(this),
- "onCancel": function(dragging){
- if( this.dragColInterval ){
- clearInterval( this.dragColInterval );
- this.dragColInterval = null;
- }
- setTimeout( function(){
- this.view.isOnDragging = false;
- }.bind(this), 100 )
- }.bind(this)
- });
- nodeDrag.start(e);
- // this.form.moveModule = this;
- //this.form.recordCurrentSelectedModule = this.form.currentSelectedModule;
- //this.form.selected();
- },
- _setScroll : function(){
- var viewAreaNode = this.view.viewAreaNode;
- var viewAreaCrd = viewAreaNode.getCoordinates();
- var leftPoint = viewAreaCrd.left;
- var rightPoint = leftPoint + viewAreaCrd.width;
- var viewNode = this.view.viewNode;
- var coordinates = this.moveNode.getCoordinates();
- if( coordinates.left + coordinates.width > rightPoint ) {
- if (!this.dragColInterval) {
- this.dragColInterval = setInterval(function () {
- if( viewAreaNode.getScroll().x + 15 < viewNode.getSize().x ){
- viewAreaNode.scrollTo(viewAreaNode.getScroll().x + 15, 0);
- }else{
- viewAreaNode.scrollTo( viewNode.getSize().x, 0);
- }
- }.bind(this), 100)
- }
- }else if( coordinates.left < leftPoint ){
- if (!this.dragColInterval) {
- this.dragColInterval = setInterval(function () {
- if( viewAreaNode.getScroll().x - 15 > 0 ){
- viewAreaNode.scrollTo(viewAreaNode.getScroll().x - 15, 0);
- }else{
- viewAreaNode.scrollTo(0, 0);
- }
- }.bind(this), 100)
- }
- }else{
- if( this.dragColInterval ){
- clearInterval( this.dragColInterval );
- this.dragColInterval = null;
- }
- }
- },
- _dragIn : function(){ //移动时鼠标进入
- this.resizeNode.setStyles( this.view.css.columnResizeNode_dragIn );
- },
- _dragOut : function(){ //移动时鼠标移出
- this.resizeNode.setStyles( this.view.css.columnResizeNode );
- },
- _dragDrop : function(){ //移动到该对象时鼠标松开
- this.resizeNode.setStyles( this.view.css.columnResizeNode );
- },
- _dragComplete: function( toNode ){ //拖拽完成
- this.node.inject(toNode,"after");
- this.setCurrent();
- if (this.moveNode) this.moveNode.destroy();
- this.moveNode = null;
- },
- _dragCancel: function(){ //拖拽取消
- if (this.moveNode) this.moveNode.destroy();
- this.moveNode = null;
- },
- _setMoveNodePosition: function(e){
- var x = e.page.x+2;
- var y = e.page.y+2;
- this.moveNode.positionTo(x, y);
- },
- showProperty: function(){
- this.view.hidePropertyContent();
- this.view.propertyTitleNode.set("text", this.view.lp.columnProperty);
- if (!this.property){
- this.property = new MWF.xApplication.cms.ViewDesigner.View.ColumnProperty(this, this.view.propertyContentArea, this.designer, {
- "onPostLoad": function(){
- this.property.show();
- }.bind(this)
- });
- this.property.load();
- }else{
- this.property.show();
- }
- },
- hideProperty: function(){
- if (this.property) this.property.hide();
- },
- setPropertiesOrStyles: function(name){
- if (name=="styles"){
- this.setCustomStyles();
- }
- if (name=="properties"){
- this.node.setProperties(this.data.properties);
- }
- },
- setCustomStyles: function(){
- var border = this.node.getStyle("border");
- this.node.clearStyles();
- this.node.setStyles(this.css.moduleNode);
- if (this.initialStyles) this.node.setStyles(this.initialStyles);
- this.node.setStyle("border", border);
- Object.each(this.data.styles, function(value, key){
- var reg = /^border\w*/ig;
- if (!key.test(reg)){
- this.node.setStyle(key, value);
- }
- }.bind(this));
- },
- setSortIcon : function(){
- if( this.sortIconNode ){
- this.sortIconNode.setStyle("display","inline");
- }else{
- this.sortIconNode = new Element("div",{"styles":this.css.sortIconNode}).inject( this.contentTitleNode, "before" );
- }
- },
- cancelSortIcon : function(){
- this.sortIconNode.setStyle("display","none");
- },
- setAlignIcon: function(){
- if( this.alignIconNode )this.alignIconNode.destroy();
- if( this.data.align == "left" ){
- this.alignIconNode = new Element("div",{"styles":this.css.alignleftNode}).inject( this.contentTitleNode, "after" );
- }else if( this.data.align == "right" ){
- this.alignIconNode = new Element("div",{"styles":this.css.alignrightNode}).inject( this.contentTitleNode, "after" );
- }
- },
- setOperation : function(name, title, image, imageOver, action){
- this.optionNodes = this.optionNodes || {};
- var _self = this;
- var path = this.view.path +this.view.options.style+"/operationIcon/";
- if( !this.optionNodes[name] ){
- if( this.contentTitleNode.get("text") == this.view.lp.noTitle ){
- this.contentTitleNode.set("text","");
- }
- var node = this.optionNodes[name] = new Element("div", {"styles": this.view.css.operationNode, "title": title }).inject(this.contentNode, "bottom" );
- node.setStyle("background-image","url("+path+image+")");
- }
- },
- deleteOperation : function( name ) {
- if (this.optionNodes && this.optionNodes[name]) {
- this.optionNodes[name].destroy();
- this.optionNodes[name] = null;
- delete this.optionNodes[name];
- }
- flag = false;
- for (var op in this.optionNodes) {
- flag = true;
- }
- if (!flag) {
- if (this.contentTitleNode.get("text") == "") {
- this.contentTitleNode.set("text", this.view.lp.noTitle );
- }
- }
- },
- delete : function(callback){
- if( !this.data.isNew && this.data.id ){
- this.view.actions.deleteViewColumn( this.data.id, function(json){
- if(callback)callback();
- }.bind(this));
- }
- },
- getData: function(){
- var data = {};
- data.id = this.data.id;
- data.isNew = this.data.isNew;
- data.viewId = this.view.data.id;
- data.fieldTitle = this.data.title;
- data.fieldName = this.data.value;
- data.xshowSequence = this.view.data.relativeForm.id;
- return data;
- },
- save : function(callback){
- var flag = true;
- if( this.data.value && this.data.value!="" ){
- var data = {};
- data.id = this.data.id;
- data.isNew = this.data.isNew;
- data.viewId = this.view.data.id;
- data.fieldTitle = this.data.title;
- data.fieldName = this.data.value;
- data.xshowSequence = this.view.data.relativeForm.id;
- this.view.actions.saveViewColumn( data, function(json){
- //this.data.id = json.data.id;
- this.data.isNew = false;
- if(callback)callback();
- }.bind(this), function(){
- flag = false;
- }.bind(this), false );
- }else{ //如果字段为空,且已经保存过,则删除
- if( !this.data.isNew ){
- this["delete"]( callback );
- this.data.isNew = true;
- }
- }
- return flag;
- }
- });
- MWF.xApplication.cms.ViewDesigner.View.HeadBar = new Class({
- initialize: function(view){
- this.view = view;
- this.designer = view.designer;
- this.container = view.viewNode;
- this.isHeadBar = true;
- this.load();
- },
- load: function(){
- this.createNodes();
- },
- createNodes : function(){
- this.node = new Element("div.column", {"styles": this.view.css.headBarNode } );
- this.node.store("column", this);
- this.node.inject(this.container);
- this.headBarContentNode = new Element("div", {"styles": this.view.css.headBarContentNode } ).inject(this.node);
- this.resizeNode = new Element("div",{"styles":this.view.css.headBarResizeNode}).inject(this.node);
- },
- _dragIn : function(){ //移动时鼠标进入
- this.resizeNode.setStyles( this.view.css.headBarResizeNode_dragIn );
- },
- _dragOut : function(){ //移动时鼠标移出
- this.resizeNode.setStyles( this.view.css.headBarResizeNode );
- },
- _dragDrop : function(){ //移动到该对象时鼠标松开
- this.resizeNode.setStyles( this.view.css.headBarResizeNode );
- }
- });
- MWF.xApplication.cms.ViewDesigner.View.ColumnProperty = new Class({
- Extends: MWF.widget.Common,
- Implements: [Options, Events],
- options: {
- "style": "default"
- },
- initialize: function(column, propertyNode, designer, options){
- this.setOptions(options);
- this.column = column;
- this.data = column.data;
- this.css = column.css;
- this.lp = column.view.lp;
- this.designer = designer;
- this.propertyNode = propertyNode;
- },
- load: function(){
- this.fireEvent( "queryLoad" );
- this.fireEvent( "postLoad" );
- },
- editProperty: function(td){
- },
- show: function(){
- if (!this.propertyContent){
- this.createNode();
- //this.loadEventsEditor( this.eventsNode, this.data.events );
- }else{
- this.propertyContent.setStyle("display", "block");
- }
- },
- hide: function(){
- //this.JsonTemplate = null;
- //this.propertyNode.set("html", "");
- if (this.propertyContent) this.propertyContent.setStyle("display", "none");
- },
- createNode : function(){
- var _self = this;
- this.propertyContent = new Element("div", {"styles": this.css.columnPropertyContent }).inject(this.propertyNode);
- this.basePropertyNode = new Element("div" );
- //this.eventsNode = new Element("div");
- MWF.require("MWF.widget.Tab", function(){
- this.propertyTab = new MWF.widget.Tab(this.propertyContent, {"style": "moduleList"});
- this.propertyTab.load();
- var page = this.propertyTab.addTab(this.basePropertyNode, this.lp.base, false);
- this.setScrollBar(page.contentNodeArea, "small", null, null);
- //page = this.propertyTab.addTab(this.eventsNode, this.lp.events, false);
- //this.setScrollBar(page.contentNodeArea, "small", null, null);
- this.propertyTab.pages[0].showTab();
- }.bind(this));
- var table = new Element("table", { "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "styles" : this.css.editTable, "class" : "editTable"}).inject( this.basePropertyNode );
- var tr = new Element("tr").inject(table);
- var td = new Element("td", { "class" : "editTableTitle", "styles" : this.css.editTableTitle, "text" : this.lp.columnTitle }).inject(tr);
- var td = new Element("td", { "class" : "editTableValue", "styles" : this.css.editTableValue }).inject(tr);
- this.columnTitleNode = new Element("input", {
- "type" : "text",
- "class" : "editTableInput",
- "styles" : this.css.editTableInput,
- "value" : this.data.title
- }).inject(td);
- this.columnTitleNode.addEvents({
- "change" : function(){
- var val = this.columnTitleNode.get("value");
- this.data.title = val;
- this.column.contentTitleNode.set("text",val);
- }.bind(this)
- });
- var tr = new Element("tr").inject(table);
- var td = new Element("td", { "class" : "editTableTitle", "styles" : this.css.editTableTitle }).inject(tr);
- var td = new Element("td", { "class" : "editTableValue", "styles" : this.css.editTableValue }).inject(tr);
- this.loadSort(td);
- var tr = new Element("tr").inject(table);
- var td = new Element("td", { "class" : "editTableTitle", "styles" : this.css.editTableTitle, "text" : this.lp.columnValue }).inject(tr);
- var td = new Element("td", { "class" : "editTableValue", "styles" : this.css.editTableValue }).inject(tr);
- this.columnValueNode = this.getFieldSelectElement();
- this.columnValueNode.inject(td);
- this.columnValueNode.addEvent("change",function(){
- this.data.value = this.column.view.getSelectValue(this.columnValueNode);
- }.bind(this));
- var tr = new Element("tr").inject(table);
- var td = new Element("td", { "class" : "editTableTitle", "styles" : this.css.editTableTitle, "text" : this.lp.columnWidth }).inject(tr);
- var td = new Element("td", { "class" : "editTableValue", "styles" : this.css.editTableValue }).inject(tr);
- if( this.data.widthPer ){
- this.columnPercentageWidthNode = new Element("span",{"text": this.data.widthPer }).inject(td);
- }else{
- this.columnPercentageWidthNode = new Element("span",{"text": Math.round( this.data.width/this.column.view.getColumnsWidth() * 100) }).inject(td);
- }
- if( this.data.widthType == "px" ){
- this.columnPercentageWidthNode.setStyle("display","none");
- }
- this.columnWidthNode = new Element("input", {
- "type" : "text",
- "class" : "editTableInput",
- "styles" : this.css.editTableInputNoWidth,
- "value" : this.data.width
- }).inject(td);
- this.columnWidthNode.setStyles({"width":"50px"});
- if( this.data.widthType != "px" ){
- this.columnWidthNode.setStyle("display","none");
- }
- this.columnWidthNode.addEvents({
- "change" : function(){
- var width = Math.round(this.value);
- if( !isNaN( width ) ){
- if( width > 10 ){
- _self.column.node.setStyle("width",width);
- _self.column.contentNode.setStyle("width",width-10);
- _self.data.width = width;
- _self.column.view.setViewNodeWidth();
- }
- }
- }
- });
- this.columnWidthTypeNode = new Element("select").inject( td );
- new Element("option" , {"value": "percentage", "text":this.lp.percentage }).inject(this.columnWidthTypeNode);
- var option = new Element("option" , {"value": "px", "text":this.lp.px }).inject(this.columnWidthTypeNode);
- if( this.data.widthType == "px" )option.selected = true;
- this.columnWidthTypeNode.addEvents({
- "change" : function(){
- for(var i=0; i<this.options.length;i++){
- option = this.options[i];
- if(option.selected){
- _self.data.widthType = option.value;
- if( option.value == "percentage" ){
- _self.widthType = "percentage";
- _self.columnWidthNode.setStyle("display","none");
- _self.columnPercentageWidthNode.setStyle("display","inline");
- var per = Math.round(_self.column.node.getSize().x / _self.column.view.getColumnsWidth() * 100);
- _self.columnPercentageWidthNode.set("text", per );
- _self.data.widthPer = per;
- _self.column.view.setViewNodeWidth();
- }else{
- _self.widthType = "px";
- _self.columnWidthNode.setStyle("display","inline");
- var width = _self.column.node.getSize().x;
- _self.columnWidthNode.set("value",width);
- _self.data.width = width;
- _self.columnPercentageWidthNode.setStyle("display","none");
- _self.column.view.setViewNodeWidth();
- }
- }
- }
- }
- });
- var tr = new Element("tr").inject(table);
- var td = new Element("td", { "class" : "editTableTitle", "styles" : this.css.editTableTitle, "text" : this.lp.columnAlign }).inject(tr);
- var td = new Element("td", { "class" : "editTableValue", "styles" : this.css.editTableValue }).inject(tr);
- this.columnAlignNode = this.loadAlign(td);
- this.columnAlignNode.addEvent("change",function(){
- this.data.align = this.column.view.getSelectValue(this.columnAlignNode);
- this.column.setAlignIcon();
- }.bind(this));
- var tr = new Element("tr").inject(table);
- var td = new Element("td", { "class" : "editTableTitle", "styles" : this.css.editTableTitle, "text" : this.lp.action }).inject(tr);
- var td = new Element("td", { "class" : "editTableValue", "styles" : this.css.editTableValue }).inject(tr);
- this.loadOperation(td);
- },
- loadSort : function( container ){
- var _self = this;
- var node = new Element("span", {"styles":this.css.propertyCheckBox } ).inject( container );
- var input = new Element("input",{
- "type" : "checkbox",
- "value" : "yes"
- }).inject( node );
- if( this.data.sortByClickTitle == "yes" )input.checked = true;
- new Element("span" , { "text" : this.lp.sortByClickTitle } ).inject( node );
- input.addEvents({
- "click" : function(el){
- if( this.checked ){
- _self.data.sortByClickTitle = "yes";
- _self.column.setSortIcon()
- }else{
- _self.data.sortByClickTitle = "no";
- _self.column.cancelSortIcon()
- }
- }
- })
- },
- getFieldSelectElement : function(){
- var obj = new Element("select");
- new Element("option", {
- "value":"",
- "text":""
- }).inject(obj);
- this.column.view.documentFields.concat(this.column.view.formFields).each(function( field ){
- var opt = new Element("option", {
- "value":field.name,
- "text":field.name
- }).inject(obj);
- if( this.data.value == field.name ){
- opt.selected = true;
- }
- }.bind(this));
- return obj;
- },
- loadEventsEditor: function( eventsNode, eventsObj ){
- MWF.xDesktop.requireApp("cms.FormDesigner", "widget.EventsEditor", function(){
- var eventsEditor = new MWF.xApplication.cms.FormDesigner.widget.EventsEditor( eventsNode, this.designer, {
- "helpStyle" : "cmsViewColumn",
- "maxObj": this.column.view.node
- });
- eventsEditor.load( eventsObj );
- }.bind(this));
- },
- loadAlign : function( container ){
- var obj = new Element("select").inject(container);
- var columnAlignValues = this.lp.columnAlignValue.split(",");
- var columnAlignTexts = this.lp.columnAlignText.split(",");
- columnAlignValues.each(function( v, i ){
- var opt = new Element("option", {
- "value":v,
- "text":columnAlignTexts[i]
- }).inject(obj);
- if( this.data.align == v ){
- opt.selected = true;
- }
- }.bind(this));
- return obj;
- },
- loadOperation : function( container ){
- var _self = this;
- this.data.operation = this.data.operation || {};
- var config = this.column.view.getOperationConfig();
- if( config.default ){
- for( var name in config.default ){
- var op = config.default[name];
- op.name = name;
- op.text = _self.lp[op.title] ? _self.lp[op.title] : op.title;
- var node = new Element("span", {"styles":this.css.propertyCheckBox } ).inject( container );
- var input = new Element("input",{
- "type" : "checkbox",
- "value" : op.name
- }).inject( node );
- if( this.data.operation[name] )input.checked = true;
- new Element("span" , { "text" : op.text} ).inject( node );
- input.store("op", op );
- input.addEvents({
- "click" : function(el){
- var op = this.retrieve("op");
- if( this.checked ){
- _self.data.operation[op.name] = op;
- _self.column.setOperation( op.name,op.text,op.icon,op.iconOver, op.action )
- }else{
- if( _self.data.operation[op.name] ){
- delete _self.data.operation[op.name];
- }
- _self.column.deleteOperation(op.name)
- }
- }
- })
- }
- }
- }
- });
- MWF.xApplication.cms.ViewDesigner.View.NewName = new Class({
- Extends: MPopupForm,
- Implements: [Options, Events],
- options: {
- "style": "blue",
- "width": 700,
- //"height": 300,
- "height": "220",
- "hasTop": true,
- "hasIcon": false,
- "draggable": true,
- "title" : MWF.xApplication.cms.ViewDesigner.LP.newListName
- },
- _createTableContent: function () {
- var html = "<table width='80%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin: 20px auto 0px auto; '>" +
- "<tr><td styles='formTableTitle' lable='name' width='25%'></td>" +
- " <td styles='formTableValue' item='name' colspan='3'></td></tr>" +
- "</table>";
- this.formTableArea.set("html", html);
- MWF.xDesktop.requireApp("Template", "MForm", function () {
- this.form = new MForm(this.formTableArea, this.data || {}, {
- isEdited: true,
- style : "cms",
- hasColon : true,
- itemTemplate: {
- name: { text : MWF.xApplication.cms.ViewDesigner.LP.name, notEmpty : true }
- }
- }, this.app);
- this.form.load();
- }.bind(this), null, true)
- },
- ok: function(){
- var data = this.form.getResult(true,null,true,false,true);
- if( data ){
- this.fireEvent("save", [data, function(){
- this.close();
- }.bind(this)])
- }
- }
- });
|