| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523 |
- 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: '微软雅黑',
- val: '微软雅黑,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 = [];
- 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();
- }
- });
|