1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525 |
- MWF.xDesktop.requireApp("Template", "MForm", null, false);
- MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
- MWF.xDesktop.requireApp("Template", "widget.ColorPicker", null, false);
- MWF.xDesktop.requireApp("Template", "MSelector", null, false);
- MWF.xApplication.MinderEditor.FontFamily = new Class({
- Extends: MSelector,
- options : {
- "style": "minderFont",
- "width": "240px",
- "height": "28px",
- "defaultOptionLp" : "字体",
- "textField" : "name",
- "valueField" : "val",
- "event" : "mouseenter",
- "isSetSelectedValue" : true,
- "isChangeOptionStyle" : true,
- "emptyOptionEnable" : false
- },
- _selectItem : function( itemNode, itemData ){
- },
- _loadData : function( callback ){
- var fontFamilyList = [{
- name: '宋体',
- val: '宋体,SimSun'
- }, {
- name: 'Microsoft YaHei',
- val: 'Microsoft YaHei,Microsoft YaHei'
- }, {
- name: '楷体',
- val: '楷体,楷体_GB2312,SimKai'
- }, {
- name: '黑体',
- val: '黑体, SimHei'
- }, {
- name: '隶书',
- val: '隶书, SimLi'
- }, {
- name: 'Andale Mono',
- val: 'andale mono'
- }, {
- name: 'Arial',
- val: 'arial,helvetica,sans-serif'
- }, {
- name: 'arialBlack',
- val: 'arial black,avant garde'
- }, {
- name: 'Comic Sans Ms',
- val: 'comic sans ms'
- }, {
- name: 'Impact',
- val: 'impact,chicago'
- }, {
- name: 'Times New Roman',
- val: 'times new roman'
- }, {
- name: 'Sans-Serif',
- val: 'sans-serif'
- }];
- if(callback)callback( fontFamilyList );
- },
- _postCreateItem: function( itemNode, data ){
- itemNode.setStyles( {
- "font-family": data.val,
- "font-size" : "14px",
- "min-height" : "30px",
- "line-height" : "30px"
- } );
- }
- });
- MWF.xApplication.MinderEditor.FontSize = new Class({
- Extends: MSelector,
- options : {
- "style": "minderFont",
- "width": "80px",
- "height": "28px",
- "defaultOptionLp" : "字号",
- "isSetSelectedValue" : true,
- "isChangeOptionStyle" : true,
- "emptyOptionEnable" : false,
- "event" : "mouseenter"
- },
- _selectItem : function( itemNode, itemData ){
- },
- _loadData : function( callback ){
- var fontSizeList = ["10", "12", "16", "18", "24", "32", "48"];
- if(callback)callback( fontSizeList );
- },
- _postCreateItem: function( itemNode, data ){
- itemNode.setStyles( {
- "font-size" : data.value +"px",
- "min-height" : ( parseInt(data.value) + 6) +"px",
- "line-height" : ( parseInt(data.value) + 6) +"px"
- } );
- }
- });
- MWF.xApplication.MinderEditor.PriorityImage = new Class({
- Extends: MSelector,
- options : {
- "style": "minderProgress",
- "width": "130px",
- "defaultOptionLp" : "",
- "valueField" : "command",
- "isSetSelectedValue" : false,
- "isChangeOptionStyle" : true,
- "emptyOptionEnable" : false,
- "event" : "mouseenter"
- },
- _selectItem : function( itemNode, itemData ){
- },
- _loadData : function( callback ){
- var list = [
- {
- command : "0",
- position : "0 -180px",
- title : "移除优先级"
- },
- {
- command : "1",
- position : "0 0px",
- title : "优先级1"
- },
- {
- command : "2",
- position : "0 -20px",
- title : "优先级2"
- },
- {
- command : "3",
- position : "0 -40px",
- title : "优先级3"
- },
- {
- command : "4",
- position : "0 -60px",
- title : "优先级4"
- },
- {
- command : "5",
- position : "0 -80px",
- title : "优先级5"
- },
- {
- command : "6",
- position : "0 -100px",
- title : "优先级6"
- },
- {
- command : "7",
- position : "0 -120px",
- title : "优先级7"
- },
- {
- command : "8",
- position : "0 -140px",
- title : "优先级8"
- },
- {
- command : "9",
- position : "0 -160px",
- title : "优先级9"
- }
- ];
- if(callback)callback( list );
- },
- _postCreateItem: function( itemNode, data ){
- },
- loadContent : function( data ){
- if( !this.contentTooltip ){
- var width = parseInt(this.options.width)+"px";
- this.css.tooltipNode.width = width;
- this.css.tooltipNode["max-width"] = width;
- var options = Object.merge({
- nodeStyles : this.css.tooltipNode,
- onPostInitialize : function(){
- if(this.options.trigger == "immediately" ){
- this.contentTooltip.load();
- }
- }.bind(this),
- onHide : function(){
- this.status = "hidden";
- }.bind(this)
- }, this.options.tooltipsOptions );
- this.contentTooltip = new MWF.xApplication.MinderEditor.PriorityImage.Tootips( this.dropdownContainer || this.app.content, this.node, this.app, data, options );
- this.contentTooltip.selector = this;
- }
- }
- });
- MWF.xApplication.MinderEditor.PriorityImage.Tootips = new Class({
- Extends: MSelector.Tootips,
- options : {
- axis: "y", //箭头在x轴还是y轴上展现
- position : { //node 固定的位置
- x : "center", //x轴上left center right, auto 系统自动计算
- y : "bottom" //y 轴上top middle bottom, auto 系统自动计算
- },
- event : "mouseenter", //事件类型,有target 时有效, mouseenter对应mouseleave,click 对应 container 的 click
- hiddenDelay : 200, //ms , 有target 且 事件类型为 mouseenter 时有效
- displayDelay : 0, //ms , 有target 且事件类型为 mouseenter 时有效
- hasArrow : true
- },
- _customNode : function( node, contentNode ){
- //var width = ( parseInt( this.selector.options.width ) )+ "px";
- //node.setStyles({
- // "width": width,
- // "max-width": width
- //});
- this.createItemList( this.data, contentNode )
- },
- createItemList:function(data, node){
- data = data || [];
- var _selector = this.selector;
- this.css = _selector.css;
- _selector.listContentNode = new Element("div.listContentNode",{
- "styles":this.css.listContentNode
- }).inject( node );
- //_selector.listContentNode.setStyles({
- // "width": node.getSize().x+"px"
- //});
- _selector.listNode = new Element("div.listNode",{
- "styles":this.css.listNode
- }).inject(_selector.listContentNode);
- _selector.setScrollBar(_selector.listNode);
- data.each(function(d){
- this.createItem( d );
- }.bind(this));
- },
- createItem: function( data ){
- var _selector = this.selector;
- var listItemNode = new Element("div.listItemNode",{
- "styles":this.css.listItemNode,
- "title" : data.title
- }).inject(_selector.listNode);
- listItemNode.setStyles({
- "background": "url("+ _selector.path + _selector.options.style + "/icon/priority.png) no-repeat "+ data.position
- });
- if(data)listItemNode.store("data",data);
- listItemNode.addEvents({
- "click":function(ev){
- var _self = this.obj;
- var data = this.itemNode.retrieve( "data" );
- _self.selector.setCurrentItem( this.itemNode );
- _self.selector._selectItem( this.itemNode, data );
- _self.selector.fireEvent("selectItem", [ this.itemNode, data ] );
- _self.hide();
- ev.stopPropagation();
- }.bind({ obj : this, itemNode : listItemNode }),
- "mouseover":function(){
- if( this.obj.selector.currentItemNode != this.itemNode || !this.obj.selector.options.isChangeOptionStyle ){
- this.itemNode.setStyles( this.obj.selector.css.listItemNode_over );
- }
- }.bind( {obj : this, itemNode : listItemNode }),
- "mouseout":function(){
- if( this.obj.selector.currentItemNode != this.itemNode || !this.obj.selector.options.isChangeOptionStyle ){
- this.itemNode.setStyles( this.obj.selector.css.listItemNode );
- }
- }.bind( {obj : this, itemNode : listItemNode })
- });
- _selector.itemNodeList.push( listItemNode );
- _selector.itemNodeObject[ data[ _selector.valueField ] ] = listItemNode;
- var isCurrent = false;
- if( _selector.currentItemData ){
- isCurrent = data[ _selector.valueField ] == _selector.currentItemData[ _selector.valueField ];
- }else if( _selector.value ){
- isCurrent = data[ _selector.valueField ] == _selector.value;
- }else if( _selector.text ){
- isCurrent = data[ _selector.textField ] == _selector.text;
- }
- if( isCurrent )_selector.setCurrentItem( listItemNode );
- _selector._postCreateItem(listItemNode, data)
- }
- });
- MWF.xApplication.MinderEditor.ProgressImage = new Class({
- Extends: MSelector,
- options : {
- "style": "minderProgress",
- "width": "130px",
- "defaultOptionLp" : "",
- "valueField" : "command",
- "isSetSelectedValue" : false,
- "isChangeOptionStyle" : true,
- "emptyOptionEnable" : false,
- "event" : "mouseenter"
- },
- _selectItem : function( itemNode, itemData ){
- },
- _loadData : function( callback ){
- var list = [
- {
- command : "0",
- position : "0 -180px",
- title : "移除进度"
- },
- {
- command : "1",
- position : "0 0px",
- title : "未开始"
- },
- {
- command : "2",
- position : "0 -20px",
- title : "完成1/8"
- },
- {
- command : "3",
- position : "0 -40px",
- title : "完成2/8"
- },
- {
- command : "4",
- position : "0 -60px",
- title : "完成3/8"
- },
- {
- command : "5",
- position : "0 -80px",
- title : "完成4/8"
- },
- {
- command : "6",
- position : "0 -100px",
- title : "完成5/8"
- },
- {
- command : "7",
- position : "0 -120px",
- title : "完成6/8"
- },
- {
- command : "8",
- position : "0 -140px",
- title : "完成7/8"
- },
- {
- command : "9",
- position : "0 -160px",
- title : "全部完成"
- }
- ];
- if(callback)callback( list );
- },
- _postCreateItem: function( itemNode, data ){
- },
- loadContent : function( data ){
- if( !this.contentTooltip ){
- var width = parseInt(this.options.width)+"px";
- this.css.tooltipNode.width = width;
- this.css.tooltipNode["max-width"] = width;
- var options = Object.merge({
- nodeStyles : this.css.tooltipNode,
- onPostInitialize : function(){
- if(this.options.trigger == "immediately" ){
- this.contentTooltip.load();
- }
- }.bind(this),
- onHide : function(){
- this.status = "hidden";
- }.bind(this)
- }, this.options.tooltipsOptions );
- this.contentTooltip = new MWF.xApplication.MinderEditor.ProgressImage.Tootips( this.dropdownContainer || this.app.content, this.node, this.app, data, options );
- this.contentTooltip.selector = this;
- }
- }
- });
- MWF.xApplication.MinderEditor.ProgressImage.Tootips = new Class({
- Extends: MSelector.Tootips,
- options : {
- axis: "y", //箭头在x轴还是y轴上展现
- position : { //node 固定的位置
- x : "center", //x轴上left center right, auto 系统自动计算
- y : "bottom" //y 轴上top middle bottom, auto 系统自动计算
- },
- event : "mouseenter", //事件类型,有target 时有效, mouseenter对应mouseleave,click 对应 container 的 click
- hiddenDelay : 200, //ms , 有target 且 事件类型为 mouseenter 时有效
- displayDelay : 0, //ms , 有target 且事件类型为 mouseenter 时有效
- hasArrow : true
- },
- _customNode : function( node, contentNode ){
- //var width = ( parseInt( this.selector.options.width ) )+ "px";
- //node.setStyles({
- // "width": width,
- // "max-width": width
- //});
- this.createItemList( this.data, contentNode )
- },
- createItemList:function(data, node){
- data = data || [];
- var _selector = this.selector;
- this.css = _selector.css;
- _selector.listContentNode = new Element("div.listContentNode",{
- "styles":this.css.listContentNode
- }).inject( node );
- //_selector.listContentNode.setStyles({
- // "width": node.getSize().x+"px"
- //});
- _selector.listNode = new Element("div.listNode",{
- "styles":this.css.listNode
- }).inject(_selector.listContentNode);
- _selector.setScrollBar(_selector.listNode);
- data.each(function(d){
- this.createItem( d );
- }.bind(this));
- },
- createItem: function( data ){
- var _selector = this.selector;
- var listItemNode = new Element("div.listItemNode",{
- "styles":this.css.listItemNode,
- "title" : data.title
- }).inject(_selector.listNode);
- listItemNode.setStyles({
- "background": "url("+ _selector.path + _selector.options.style + "/icon/progress.png) no-repeat "+ data.position
- });
- if(data)listItemNode.store("data",data);
- listItemNode.addEvents({
- "click":function(ev){
- var _self = this.obj;
- var data = this.itemNode.retrieve( "data" );
- _self.selector.setCurrentItem( this.itemNode );
- _self.selector._selectItem( this.itemNode, data );
- _self.selector.fireEvent("selectItem", [ this.itemNode, data ] );
- _self.hide();
- ev.stopPropagation();
- }.bind({ obj : this, itemNode : listItemNode }),
- "mouseover":function(){
- if( this.obj.selector.currentItemNode != this.itemNode || !this.obj.selector.options.isChangeOptionStyle ){
- this.itemNode.setStyles( this.obj.selector.css.listItemNode_over );
- }
- }.bind( {obj : this, itemNode : listItemNode }),
- "mouseout":function(){
- if( this.obj.selector.currentItemNode != this.itemNode || !this.obj.selector.options.isChangeOptionStyle ){
- this.itemNode.setStyles( this.obj.selector.css.listItemNode );
- }
- }.bind( {obj : this, itemNode : listItemNode })
- });
- _selector.itemNodeList.push( listItemNode );
- _selector.itemNodeObject[ data[ _selector.valueField ] ] = listItemNode;
- var isCurrent = false;
- if( _selector.currentItemData ){
- isCurrent = data[ _selector.valueField ] == _selector.currentItemData[ _selector.valueField ];
- }else if( _selector.value ){
- isCurrent = data[ _selector.valueField ] == _selector.value;
- }else if( _selector.text ){
- isCurrent = data[ _selector.textField ] == _selector.text;
- }
- if( isCurrent )_selector.setCurrentItem( listItemNode );
- _selector._postCreateItem(listItemNode, data)
- }
- });
- MWF.xApplication.MinderEditor.SaveTooltips = new Class({
- Implements: [Options, Events],
- Extends: MTooltips,
- options: {
- style : "default",
- axis: "y", //箭头在x轴还是y轴上展现
- position : { //node 固定的位置
- x : "auto", //x 轴上left center right, auto 系统自动计算
- y : "auto" //y轴上top middle bottom, auto 系统自动计算
- },
- event : "mouseenter", //事件类型,有target 时有效, mouseenter对应mouseleave,click 对应 container 的 click
- nodeStyles : {
- "min-width" : "50px",
- "padding" : "0px",
- "border-radius" : "3px"
- }
- },
- _customNode : function( node, contentNode ){
- var div = new Element("div", {
- "text" : (this.app.autoSaveInter / 60000) + "分钟自动保存一次",
- "styles" : { "margin" : "10px" }
- }).inject( contentNode );
- new Element("input",{
- type : "checkbox",
- value : "true",
- checked : this.app.autoSave,
- events : {
- change : function( el ){
- if( el.target.get("checked") ){
- this.app.startAutoSave();
- }else{
- this.app.stopAutoSave();
- }
- }.bind(this)
- }
- }).inject( div, "top" );
- //var list = new Element("div", { styles : this.app.css.selectorListNode }).inject( contentNode );
- //var saveAsDiv = new Element("div", { "text": "另存为",
- // styles : this.app.css.selectorListItemNode,
- // events : {
- // mouseover : function(el){
- // el.target.setStyles( this.app.css.selectorListItemNode_over )
- // }.bind(this),
- // mouseleave : function(el){
- // el.target.setStyles( this.app.css.selectorListItemNode )
- // }.bind(this),
- // click : function(){
- // this.app.openSaveAsDialog();
- // }.bind(this)
- // }
- //}).inject( list );
- //
- //var renameDiv = new Element("div", { "text": "重命名",
- // styles : this.app.css.selectorListItemNode,
- // events : {
- // mouseover : function(el){
- // el.target.setStyles( this.app.css.selectorListItemNode_over )
- // }.bind(this),
- // mouseleave : function(el){
- // el.target.setStyles( this.app.css.selectorListItemNode )
- // }.bind(this),
- // click : function(){
- // this.app.openRenameDialog();
- // }.bind(this)
- // }
- //}).inject( list );
- }
- });
- MWF.require("MWF.widget.ImageClipper", null, false);
- MWF.xApplication.MinderEditor.HyperLinkForm = new Class({
- Extends: MPopupForm,
- Implements: [Options, Events],
- options: {
- "style": "minder",
- "width": 700,
- //"height": 300,
- "height": "300",
- "hasTop": true,
- "hasIcon": false,
- "draggable": true,
- "title" : "链接"
- },
- _createTableContent: function () {
- var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin-top: 20px; '>" +
- "<tr><td styles='formTableTitle' lable='url' width='20%'></td>" +
- " <td styles='formTableValue14' item='url' colspan='3'></td></tr>" +
- "<tr><td styles='formTableTitle' lable='title'></td>" +
- " <td styles='formTableValue14' item='title' colspan='3'></td></tr>" +
- "</table>";
- this.formTableArea.set("html", html);
- var data = this.app.minder.queryCommandValue('HyperLink');
- this.form = new MForm(this.formTableArea, data, {
- isEdited: true,
- style : "minder",
- hasColon : true,
- itemTemplate: {
- url: { text : "链接地址", notEmpty : true,
- validRule : { isInvalid : function( value, it ){
- var urlRegex = '^(?!mailto:)(?:(?:http|https|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$';
- var R_URL = new RegExp(urlRegex, 'i');
- return R_URL.test( value )
- }.bind(this)},
- validMessage : { isInvalid : "请输入正确的链接" },
- attr : { placeholder : "必填:以 http(s):// 或 ftp:// 开头" }
- },
- title: { text : "提示文本", attr : { placeholder : "选填:鼠标在链接上悬停时提示的文本" } }
- }
- }, this.app);
- this.form.load();
- },
- _createBottomContent: function () {
- if (this.isNew || this.isEdited) {
- this.okActionNode = new Element("button.inputOkButton", {
- "styles": this.css.inputOkButton,
- "text": "确定"
- }).inject(this.formBottomNode);
- this.okActionNode.addEvent("click", function (e) {
- this.save(e);
- }.bind(this));
- }
- this.removeAction = new Element("button.inputCancelButton", {
- "styles": this.css.inputCancelButton,
- "text": "删除链接"
- }).inject(this.formBottomNode);
- this.removeAction.addEvent("click", function (e) {
- this.remove(e);
- }.bind(this));
- this.cancelActionNode = new Element("button.inputCancelButton", {
- "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
- "text": "关闭"
- }).inject(this.formBottomNode);
- this.cancelActionNode.addEvent("click", function (e) {
- this.close(e);
- }.bind(this));
- },
- save: function(){
- var data = this.form.getResult(true,null,true,false,true);
- if( data ){
- this.app.minder.execCommand('HyperLink', data.url, data.title || '');
- this.close();
- }
- },
- remove: function( ev ){
- this.app.minder.execCommand('HyperLink', null );
- this.close();
- }
- });
- MWF.xApplication.MinderEditor.ImageForm = new Class({
- Extends: MPopupForm,
- Implements: [Options, Events],
- options: {
- "style": "minder",
- "width": 800,
- "height": 640,
- "hasTop": true,
- "hasIcon": false,
- "draggable": true,
- "title" : "图片"
- },
- createContent: function () {
- this.createTab();
- this.formContentNode = new Element("div.formContentNode", {
- "styles": this.css.formContentNode
- }).inject(this.formNode);
- this.formTableContainer = new Element("div.formTableContainer", {
- "styles": this.css.formTableContainer
- }).inject(this.formContentNode);
- this.formTableArea = new Element("div.formTableArea", {
- "styles": this.css.formTableArea
- }).inject(this.formTableContainer);
- this._createTableContent();
- },
- _createTableContent: function () {
- this.linkContainer = new Element("div.linkContainer").inject(this.formTableArea);
- var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin-top: 20px; '>" +
- "<tr><td styles='formTableTitle' lable='url' width='20%'></td>" +
- " <td styles='formTableValue14' item='url' colspan='3'></td></tr>" +
- "<tr><td styles='formTableTitle' lable='title'></td>" +
- " <td styles='formTableValue14' item='title' colspan='3'></td></tr>" +
- "<tr><td styles='formTableTitle'>预览:</td>" +
- " <td styles='formTableValue14' item='preview' colspan='3'></td></tr>" +
- "</table>";
- this.linkContainer.set("html", html);
- var data = this.app.minder.queryCommandValue('image');
- this.linkform = new MForm(this.linkContainer, data, {
- isEdited: true,
- style : "minder",
- hasColon : true,
- itemTemplate: {
- url: { text : "图片地址", notEmpty : true,
- validRule : { isInvalid : function( value, it ){
- var R_URL = /^https?\:\/\/\w+/;
- return R_URL.test( value )
- }.bind(this)},
- validMessage : { isInvalid : "请输入正确的链接" },
- attr : { placeholder : "必填:以 http(s):// 开始" },
- event : { blur : function( it ){
- if( it.getValue() )it.form.getItem("preview").setValue( it.getValue() )
- }.bind(this)}
- },
- title: { text : "提示文本", attr : { placeholder : "选填:鼠标在图片上悬停时提示的文本" } },
- preview : { type : "img", defaultValue : data.url || "", style : { "max-width" : "400px", "max-height" : "260px" } }
- }
- }, this.app);
- this.linkform.load();
- this.uploadContainer = new Element("div.uploadContainer", { styles : {"display":"none"} }).inject( this.formTableArea );
- var html = "<table width='100%' bordr='0' cellpadding='0' cellspacing='0' styles='formTable' style='margin-top: 20px; '>" +
- "<tr><td item='image' colspan='4' style='padding-bottom: 10px;'></td></tr>" +
- "<tr><td styles='formTableTitle' lable='title2' width='20%'></td>" +
- " <td styles='formTableValue14' item='title2' colspan='3'></td></tr>" +
- "</table>";
- this.uploadContainer.set("html", html);
- var data = this.app.minder.queryCommandValue('image');
- this.uploadform = new MForm(this.uploadContainer, data, {
- isEdited: true,
- style : "minder",
- hasColon : true,
- itemTemplate: {
- title2: { text : "提示文本", attr : { placeholder : "选填:鼠标在图片上悬停时提示的文本" } }
- }
- }, this.app);
- this.uploadform.load();
- this.image = new MWF.widget.ImageClipper(this.uploadContainer.getElement("[item='image']"), {
- "aspectRatio": 0,
- "description" : "",
- "imageUrl" : "",
- "ratioAdjustedEnable" : true,
- "reference" : this.app.data.id || "1111",
- "referenceType": "mindInfo",
- "fromFileEnable" : false,
- "resetEnable" : true
- });
- this.image.load();
- },
- createTab: function(){
- var _self = this;
- this.tabContainer = new Element("div.formTabContainer",{
- styles : this.css.formTabContainer
- }).inject(this.formNode);
- var tabNode = new Element("div.formTabNode", {
- "styles": this.css.formTabNode,
- "text" : "外链图片"
- }).inject(this.tabContainer);
- tabNode.addEvents({
- "mouseover" : function(){ if( _self.currentTabNode != this.node)this.node.setStyles(_self.css.formTabNode_over) }.bind({node : tabNode }),
- "mouseout" : function(){ if( _self.currentTabNode != this.node)this.node.setStyles(_self.css.formTabNode) }.bind({node : tabNode }),
- "click":function(){
- if( _self.currentTabNode )_self.currentTabNode.setStyles(_self.css.formTabNode);
- _self.currentTabNode = this.node;
- this.node.setStyles(_self.css.formTabNode_current);
- _self.linkContainer.setStyle("display","");
- _self.uploadContainer.setStyle("display","none");
- }.bind({ node : tabNode })
- });
- tabNode.setStyles( this.css.formTabNode_current );
- _self.currentTabNode = tabNode;
- var tabNode = new Element("div.tabNode", {
- "styles": this.css.formTabNode,
- "text" : "上传图片"
- }).inject(this.tabContainer);
- tabNode.addEvents({
- "mouseover" : function(){ if( _self.currentTabNode != this.node)this.node.setStyles(_self.css.formTabNode_over) }.bind({node : tabNode }),
- "mouseout" : function(){ if( _self.currentTabNode != this.node)this.node.setStyles(_self.css.formTabNode) }.bind({node : tabNode }),
- "click":function(){
- if( _self.currentTabNode )_self.currentTabNode.setStyles(_self.css.formTabNode);
- _self.currentTabNode = this.node;
- this.node.setStyles(_self.css.formTabNode_current);
- _self.linkContainer.setStyle("display","none");
- _self.uploadContainer.setStyle("display","");
- }.bind({ node : tabNode })
- })
- },
- _createBottomContent: function () {
- if (this.isNew || this.isEdited) {
- this.okActionNode = new Element("button.inputOkButton", {
- "styles": this.css.inputOkButton,
- "text": "确定"
- }).inject(this.formBottomNode);
- this.okActionNode.addEvent("click", function (e) {
- this.save(e);
- }.bind(this));
- }
- this.removeAction = new Element("button.inputCancelButton", {
- "styles": this.css.inputCancelButton,
- "text": "删除图片"
- }).inject(this.formBottomNode);
- this.removeAction.addEvent("click", function (e) {
- this.remove(e);
- }.bind(this));
- this.cancelActionNode = new Element("button.inputCancelButton", {
- "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
- "text": "关闭"
- }).inject(this.formBottomNode);
- this.cancelActionNode.addEvent("click", function (e) {
- this.close(e);
- }.bind(this));
- },
- save: function(){
- if( this.image.getResizedImage() ){
- this.image.uploadImage( function( json ){
- var data = {
- url : MWF.xDesktop.getImageSrc( json.id ),
- title : this.uploadform.getResult(true,null,true,false,true)["title2"]
- };
- this.app.minder.execCommand('image', data.url, data.title || '', json.id );
- this.close();
- }.bind(this));
- }else{
- var data = this.linkform.getResult(true,null,true,false,true);
- if( data ){
- this.app.minder.execCommand('image', data.url, data.title || '', '');
- this.close();
- }
- }
- },
- remove: function( ev ){
- this.app.minder.execCommand('image', '' );
- this.close();
- },
- setFormNodeSize: function (width, height, top, left) {
- if (!width)width = this.options.width ? this.options.width : "50%";
- if (!height)height = this.options.height ? this.options.height : "50%";
- if (!top) top = this.options.top ? this.options.top : 0;
- if (!left) left = this.options.left ? this.options.left : 0;
- var containerSize = this.container.getSize();
- if( containerSize.x < width )width = containerSize.x;
- if( containerSize.y < height )height = containerSize.y;
- var allSize = this.app.content.getSize();
- var limitWidth = allSize.x; //window.screen.width
- var limitHeight = allSize.y; //window.screen.height
- "string" == typeof width && (1 < width.length && "%" == width.substr(width.length - 1, 1)) && (width = parseInt(limitWidth * parseInt(width, 10) / 100, 10));
- "string" == typeof height && (1 < height.length && "%" == height.substr(height.length - 1, 1)) && (height = parseInt(limitHeight * parseInt(height, 10) / 100, 10));
- 300 > width && (width = 300);
- 220 > height && (height = 220);
- top = top || parseInt((limitHeight - height) / 2, 10); //+appTitleSize.y);
- left = left || parseInt((limitWidth - width) / 2, 10);
- this.formAreaNode.setStyles({
- "width": "" + width + "px",
- "height": "" + height + "px",
- "top": "" + top + "px",
- "left": "" + left + "px"
- });
- this.formNode.setStyles({
- "width": "" + width + "px",
- "height": "" + height + "px"
- });
- var iconSize = this.formIconNode ? this.formIconNode.getSize() : {x: 0, y: 0};
- var topSize = this.formTopNode ? this.formTopNode.getSize() : {x: 0, y: 0};
- var bottomSize = this.formBottomNode ? this.formBottomNode.getSize() : {x: 0, y: 0};
- var tabSize = this.tabContainer ? this.tabContainer.getSize() : {x: 0, y: 0};
- var contentHeight = height - iconSize.y - topSize.y - bottomSize.y - tabSize.y;
- //var formMargin = formHeight -iconSize.y;
- this.formContentNode.setStyles({
- "height": "" + contentHeight + "px"
- });
- this.formTableContainer.setStyles({
- "height": "" + contentHeight + "px"
- });
- }
- });
- MWF.xApplication.MinderEditor.SaveAsForm = new Class({
- Extends: MPopupForm,
- Implements: [Options, Events],
- options: {
- "style": "minder",
- "width": 800,
- //"height": 300,
- "height": "300",
- "hasTop": true,
- "hasIcon": false,
- "draggable": true,
- "title" : "另存为"
- },
- _createTableContent: function () {
- var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin-top: 20px; '>" +
- "<tr><td styles='formTableTitle' lable='folder' width='25%'></td>" +
- " <td styles='formTableValue14' item='folder' colspan='3'></td></tr>" +
- "<tr><td styles='formTableTitle' lable='newname'></td>" +
- " <td styles='formTableValue14' item='newname' colspan='3'></td></tr>" +
- "</table>";
- this.formTableArea.set("html", html);
- this.form = new MForm(this.formTableArea, this.data || {}, {
- isEdited: true,
- style : "minder",
- hasColon : true,
- itemTemplate: {
- folder: { text : "选择文件夹", notEmpty : true, attr : { readonly : true }, defaultValue : "根目录" },
- newname: { text : "新文件名称" }
- }
- }, this.app);
- this.form.load();
- this.loadFolderSelect();
- },
- _createBottomContent: function () {
- if (this.isNew || this.isEdited) {
- this.okActionNode = new Element("button.inputOkButton", {
- "styles": this.css.inputOkButton,
- "text": "确定"
- }).inject(this.formBottomNode);
- this.okActionNode.addEvent("click", function (e) {
- this.save(e);
- }.bind(this));
- }
- this.cancelActionNode = new Element("button.inputCancelButton", {
- "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
- "text": "关闭"
- }).inject(this.formBottomNode);
- this.cancelActionNode.addEvent("click", function (e) {
- this.close(e);
- }.bind(this));
- },
- save: function(){
- var data = this.form.getResult(true,null,true,false,true);
- if( data ){
- this.app.saveAs( this.folderId || "root", data.newname );
- this.close();
- }
- },
- loadFolderSelect: function() {
- MWF.xDesktop.requireApp("Minder", "Common", null, false);
- this.folderSelect = new MWF.xApplication.Minder.FolderSelector( this.app.content, this.form.getItem("folder").getElements()[0], this.app, {}, {
- onSelect : function( folderData ){
- this.form.getItem("folder").setValue( folderData.name );
- this.folderId = folderData.id;
- }.bind(this)
- } );
- }
- });
- MWF.xApplication.MinderEditor.NewNameForm = new Class({
- Extends: MPopupForm,
- Implements: [Options, Events],
- options: {
- "style": "minder",
- "width": 700,
- //"height": 300,
- "height": "200",
- "hasTop": true,
- "hasIcon": false,
- "draggable": true,
- "title" : "重命名"
- },
- _createTableContent: function () {
- var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin-top: 20px; '>" +
- "<tr><td styles='formTableTitle' lable='newname' width='25%'></td>" +
- " <td styles='formTableValue14' item='newname' colspan='3'></td></tr>" +
- "</table>";
- this.formTableArea.set("html", html);
- this.form = new MForm(this.formTableArea, this.data || {}, {
- isEdited: true,
- style : "minder",
- hasColon : true,
- itemTemplate: {
- newname: { text : "新文件名称", notEmpty : true }
- }
- }, this.app);
- this.form.load();
- },
- _createBottomContent: function () {
- if (this.isNew || this.isEdited) {
- this.okActionNode = new Element("button.inputOkButton", {
- "styles": this.css.inputOkButton,
- "text": "确定"
- }).inject(this.formBottomNode);
- this.okActionNode.addEvent("click", function (e) {
- this.save(e);
- }.bind(this));
- }
- this.cancelActionNode = new Element("button.inputCancelButton", {
- "styles": (this.isEdited || this.isNew || this.getEditPermission() ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
- "text": "关闭"
- }).inject(this.formBottomNode);
- this.cancelActionNode.addEvent("click", function (e) {
- this.close(e);
- }.bind(this));
- },
- save: function(){
- var data = this.form.getResult(true,null,true,false,true);
- if( data ){
- this.app.setNewName( data.newname );
- this.close();
- }
- }
- });
- MWF.xApplication.MinderEditor.ExportTooltips = new Class({
- Implements: [Options, Events],
- Extends: MTooltips,
- options: {
- style : "default",
- axis: "y", //箭头在x轴还是y轴上展现
- position : { //node 固定的位置
- x : "auto", //x 轴上left center right, auto 系统自动计算
- y : "auto" //y轴上top middle bottom, auto 系统自动计算
- },
- event : "mouseenter", //事件类型,有target 时有效, mouseenter对应mouseleave,click 对应 container 的 click
- nodeStyles : {
- "padding-top" : "5px",
- "min-width" : "210px",
- "padding" : "0px",
- "border-radius" : "5px"
- }
- },
- _loadCustom : function( callback ){
- this.css = this.app.css;
- if( document.id( "km-csrf" ) ){
- document.id( "km-csrf").set( "value", this.app.data.id );
- }else{
- new Element("input", {
- id : "km-csrf",
- "styles" : { display : "none" }
- }).inject( this.contentNode )
- }
- this.app.loadExtentResource( function(){
- var contentNode = this.contentNode;
- var list = new Element("div", { styles : this.css.selectorListNode }).inject( contentNode );
- var protocols = [];
- var pool = kityminder.data.getRegisterProtocol();
- for(var name in pool) {
- if (pool.hasOwnProperty(name) && pool[name].encode) {
- protocols.push(pool[name]);
- }
- }
- protocols.each(function( p ) {
- new Element("div", { "text": (p.fileDescription + "("+ p.fileExtension +")"),
- styles : this.css.selectorListItemNode,
- events : {
- mouseover : function(el){
- el.target.setStyles( this.css.selectorListItemNode_over )
- }.bind(this),
- mouseleave : function(el){
- el.target.setStyles( this.css.selectorListItemNode )
- }.bind(this),
- click : function(){
- this.exportFile(p);
- }.bind(this)
- }
- }).inject( list );
- }.bind(this));
- if(callback)callback();
- }.bind(this))
- },
- exportFile : function( protocol ){
- this.createProgressBar();
- this.minder = this.app.minder;
- var fileName = this.app.data.name || this.minder.getRoot().getText();
- filename = fileName + protocol.fileExtension;
- var mineType = protocol.mineType || 'text/plain';
- var options = {
- download: true,
- filename: filename
- };
- if( protocol.name == "png" ){
- var converter = new MWF.xApplication.MinderEditor.Converter(this.app, this.minder);
- converter.toPng(null, null, function( img ){
- var link = new Element("a", {"text": filename}).inject(this.progressBarTextNode);
- link.download = fileName;
- link.href = URL.createObjectURL(img);
- //link.href = "data:text/plain," + content;
- var evt = document.createEvent("HTMLEvents");
- evt.initEvent("click", false, false);
- link.dispatchEvent(evt);
- link.click();
- this.progressBarNode.destroy();
- this.progressBarNode = null;
- this.progressBarTextNode = null;
- this.progressBar = null;
- this.progressBarPercent = null;
- }.bind(this));
- }else{
- this.minder.exportData(protocol.name, options).then(function(data) {
- if (protocol.name == 'freemind') {
- return;
- }
- switch (protocol.dataType) {
- case 'text':
- return this.doDownload(this.buildDataUrl(mineType, data), filename, 'text');
- case 'base64':
- return this.doDownload(data, filename, 'base64');
- case 'blob':
- return null;
- }
- return null;
- }.bind(this));
- }
- },
- doDownload : function (url, filename, type) {
- var Promise = kityminder.Promise;
- var stamp = +new Date() * 1e5 + Math.floor(Math.random() * (1e5 - 1));
- stamp = stamp.toString(36);
- var ret = new Promise(function(resolve, reject) {
- var ticker = 0;
- var MAX_TICK = 30;
- var interval = 1000;
- //function check() {
- // if (document.cookie.indexOf(stamp + '=1') != -1) return resolve([stamp, ticker]);
- // if (++ticker > MAX_TICK) {
- // resolve([stamp, ticker]);
- // }
- // setTimeout(check, interval);
- //}
- //
- //setTimeout(check, interval);
- var content = url.split(',')[1];
- this.saveToLocal( content, filename );
- return resolve([stamp, ticker]);
- }.bind(this));
- //var form = new Element("form",{
- // 'action': 'home/download',
- // 'method': 'POST',
- // 'accept-charset': 'utf-8'
- //});
- //var $content = new Element("input",{
- // name: 'content',
- // type: 'hidden',
- // value: decodeURIComponent(content)
- //}).inject( from );
- //
- //var $type = new Element("input",{
- // name: 'type',
- // type: 'hidden',
- // value: type
- //}).inject( from );
- //
- //var $filename = new Element("input",{
- // name: 'filename',
- // type: 'hidden',
- // value: filename
- //}).inject( from );
- //
- //var $csrfToken = new Element("input",{
- // name: 'csrf_token',
- // type: 'hidden',
- // value: $('#km-csrf').val()
- //}).inject( from );
- //
- //
- //if (kity.Browser.ie) {
- // new Element("input",{
- // name : "iehack",
- // value : "1"
- // }).inject( form );
- //}
- //
- //new Element("input",{
- // name : "stamp",
- // value : stamp
- //}).inject( form );
- //
- //form.inject('body');
- //form.submit();
- //form.destroy();
- return ret;
- },
- buildDataUrl: function (mineType, data) {
- return 'data:' + mineType + '; utf-8,' + encodeURIComponent(data);
- },
- saveToLocal: function( data, filename ){
- if (window.hasOwnProperty("ActiveXObject")){
- var win = window.open("", "_blank");
- win.document.write(decodeURIComponent(data));
- }else{
- this.downloadFile(filename, decodeURIComponent(data));
- }
- this.progressBarNode.destroy();
- this.progressBarNode = null;
- this.progressBarTextNode = null;
- this.progressBar = null;
- this.progressBarPercent = null;
- this.close();
- },
- downloadFile: function(fileName, content){
- var link = new Element("a", {"text": this.data.name}).inject(this.progressBarTextNode);
- var blob = new Blob([content]);
- link.download = fileName;
- link.href = URL.createObjectURL(blob);
- //link.href = "data:text/plain," + content;
- var evt = document.createEvent("HTMLEvents");
- evt.initEvent("click", false, false);
- link.dispatchEvent(evt);
- link.click();
- },
- createProgressBar: function(){
- this.node.hide();
- this.progressBarNode = new Element("div", {"styles": this.css.progressBarNode});
- this.progressBarNode.inject(this.container);
- this.progressBarNode.position({
- relativeTo: this.container,
- position: 'center',
- edge: 'center'
- });
- this.progressBarTextNode = new Element("div", {"styles": this.css.progressBarTextNode}).inject(this.progressBarNode);
- this.progressBar = new Element("div", {"styles": this.css.progressBar}).inject(this.progressBarNode);
- this.progressBarPercent = new Element("div", {"styles": this.css.progressBarPercent}).inject(this.progressBar);
- }
- });
- MWF.xApplication.MinderEditor.ExportForm = new Class({
- Extends: MPopupForm,
- Implements: [Options, Events],
- options: {
- "style": "minder",
- "width": 400,
- //"height": 300,
- "height": "300",
- "hasTop": true,
- "hasIcon": false,
- "draggable": true,
- "hasBottom" : false,
- "title" : "选择导出的文件类型"
- },
- _createTableContent : function( callback ){
- this.css = this.app.css;
- if( document.id( "km-csrf" ) ){
- document.id( "km-csrf").set( "value", this.app.data.id );
- }else{
- new Element("input", {
- id : "km-csrf",
- "styles" : { display : "none" }
- }).inject( this.formTableArea )
- }
- this.app.loadExtentResource( function(){
- var contentNode = this.formTableArea;
- var list = new Element("div", { styles : this.css.selectorListNode }).inject( contentNode );
- var protocols = [];
- debugger;
- var pool = kityminder.data.getRegisterProtocol();
- for(var name in pool) {
- if (pool.hasOwnProperty(name) && pool[name].encode) {
- protocols.push(pool[name]);
- }
- }
- protocols.each(function( p ) {
- new Element("div", { "text": (p.fileDescription + "("+ p.fileExtension +")"),
- styles : this.css.selectorListItemNode,
- events : {
- mouseover : function(el){
- el.target.setStyles( this.css.selectorListItemNode_over )
- }.bind(this),
- mouseleave : function(el){
- el.target.setStyles( this.css.selectorListItemNode )
- }.bind(this),
- click : function(){
- this.exportFile(p);
- }.bind(this)
- }
- }).inject( list );
- }.bind(this));
- if(callback)callback();
- }.bind(this))
- },
- exportFile : function( protocol ){
- this.createProgressBar();
- this.minder = this.app.minder;
- var fileName = this.app.data.name || this.minder.getRoot().getText();
- filename = fileName + protocol.fileExtension;
- var mineType = protocol.mineType || 'text/plain';
- var options = {
- download: true,
- filename: filename
- };
- if( protocol.name == "png" ){
- var converter = new MWF.xApplication.MinderEditor.Converter(this.app, this.minder);
- converter.toPng(null, null, function( img ){
- var link = new Element("a", {"text": filename}).inject(this.progressBarTextNode);
- link.download = fileName;
- link.href = URL.createObjectURL(img);
- //link.href = "data:text/plain," + content;
- var evt = document.createEvent("HTMLEvents");
- evt.initEvent("click", false, false);
- link.dispatchEvent(evt);
- link.click();
- this.progressBarNode.destroy();
- this.progressBarNode = null;
- this.progressBarTextNode = null;
- this.progressBar = null;
- this.progressBarPercent = null;
- }.bind(this));
- }else{
- this.minder.exportData(protocol.name, options).then(function(data) {
- if (protocol.name == 'freemind') {
- return;
- }
- switch (protocol.dataType) {
- case 'text':
- return this.doDownload(this.buildDataUrl(mineType, data), filename, 'text');
- case 'base64':
- return this.doDownload(data, filename, 'base64');
- case 'blob':
- return null;
- }
- return null;
- }.bind(this));
- }
- },
- doDownload : function (url, filename, type) {
- var Promise = kityminder.Promise;
- var stamp = +new Date() * 1e5 + Math.floor(Math.random() * (1e5 - 1));
- stamp = stamp.toString(36);
- var ret = new Promise(function(resolve, reject) {
- var ticker = 0;
- var MAX_TICK = 30;
- var interval = 1000;
- //function check() {
- // if (document.cookie.indexOf(stamp + '=1') != -1) return resolve([stamp, ticker]);
- // if (++ticker > MAX_TICK) {
- // resolve([stamp, ticker]);
- // }
- // setTimeout(check, interval);
- //}
- //
- //setTimeout(check, interval);
- var content = url.split(',')[1];
- this.saveToLocal( content, filename );
- return resolve([stamp, ticker]);
- }.bind(this));
- //var form = new Element("form",{
- // 'action': 'home/download',
- // 'method': 'POST',
- // 'accept-charset': 'utf-8'
- //});
- //var $content = new Element("input",{
- // name: 'content',
- // type: 'hidden',
- // value: decodeURIComponent(content)
- //}).inject( from );
- //
- //var $type = new Element("input",{
- // name: 'type',
- // type: 'hidden',
- // value: type
- //}).inject( from );
- //
- //var $filename = new Element("input",{
- // name: 'filename',
- // type: 'hidden',
- // value: filename
- //}).inject( from );
- //
- //var $csrfToken = new Element("input",{
- // name: 'csrf_token',
- // type: 'hidden',
- // value: $('#km-csrf').val()
- //}).inject( from );
- //
- //
- //if (kity.Browser.ie) {
- // new Element("input",{
- // name : "iehack",
- // value : "1"
- // }).inject( form );
- //}
- //
- //new Element("input",{
- // name : "stamp",
- // value : stamp
- //}).inject( form );
- //
- //form.inject('body');
- //form.submit();
- //form.destroy();
- return ret;
- },
- buildDataUrl: function (mineType, data) {
- return 'data:' + mineType + '; utf-8,' + encodeURIComponent(data);
- },
- saveToLocal: function( data, filename ){
- if (window.hasOwnProperty("ActiveXObject")){
- var win = window.open("", "_blank");
- win.document.write(decodeURIComponent(data));
- }else{
- this.downloadFile(filename, decodeURIComponent(data));
- }
- this.progressBarNode.destroy();
- this.progressBarNode = null;
- this.progressBarTextNode = null;
- this.progressBar = null;
- this.progressBarPercent = null;
- this.close();
- },
- downloadFile: function(fileName, content){
- var link = new Element("a", {"text": this.data.name}).inject(this.progressBarTextNode);
- var blob = new Blob([content]);
- link.download = fileName;
- link.href = URL.createObjectURL(blob);
- //link.href = "data:text/plain," + content;
- var evt = document.createEvent("HTMLEvents");
- evt.initEvent("click", false, false);
- link.dispatchEvent(evt);
- link.click();
- },
- createProgressBar: function(){
- this.progressBarNode = new Element("div", {"styles": this.css.progressBarNode});
- this.progressBarNode.inject(this.container);
- this.progressBarNode.position({
- relativeTo: this.container,
- position: 'center',
- edge: 'center'
- });
- this.progressBarTextNode = new Element("div", {"styles": this.css.progressBarTextNode}).inject(this.progressBarNode);
- this.progressBar = new Element("div", {"styles": this.css.progressBar}).inject(this.progressBarNode);
- this.progressBarPercent = new Element("div", {"styles": this.css.progressBarPercent}).inject(this.progressBar);
- this.close();
- }
- });
|