kampfer.require('Dialog'); kampfer.require('mindMap.command'); kampfer.provide('mindMap.RenameMapDialog'); kampfer.mindMap.RenameMapDialog = kampfer.Dialog.extend({ initializer : function(storage, view) { this._storage = storage; this._view = view; }, events : { click : { 'ok' : 'ok hide', 'close' : 'hide', 'cancel' : 'hide', map : function(event) { var element = event.target, name = element.querySelectorAll('td')[1].innerHTML; kampfer.dom.addClass(element, 'info'); this.selectMap(name); } } }, _content : '

There are 0 maps in your localstorage.<\/p>' + '

' + '' + '' + '' + '<\/tbody>' + '<\/table>' + '<\/div>' + '
' + '
' + 'File name :<\/span>' + '' + '<\/div>' + '<\/div>', _buttons : (function() { var buttons = [ document.createElement('button'), document.createElement('button') ]; buttons[0].setAttribute('data-action', 'ok'); buttons[0].innerHTML = 'Save'; buttons[1].setAttribute('data-action', 'cancel'); buttons[1].innerHTML = 'Cancel'; return buttons; })(), render : function() { kampfer.mindMap.RenameMapDialog.superClass.render.call(this); this.setContent(this._content); this.setTitle('另存为:'); }, updateMapCount : function() { var mapCount = this._storage.getMapCount(); if(!this._mapCountElement) { this._mapCountElement = this._element.querySelector('.text-info>span'); } this._mapCountElement.innerHTML = mapCount; }, updateMapList : function() { var mapList = this._storage.getMapList(); if(!mapList) { return; } for(var i = 0, map; (map = mapList[i]); i++) { this.addMap2List(map, i + 1); } }, addMap2List : function(map, index) { var tr = document.createElement('tr'), name = map.name, lastModified = new Date(map.lastModified).toLocaleDateString(); tr.innerHTML = ['
#<\/th>' + 'map name<\/th>' + 'lastModified<\/th>' + '<\/tr>' + '<\/thead>' + '
', index, '', name, '', lastModified, '