From 6b2fd62cb1d45a920f9b69c638a302e8720258c5 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 21 Oct 2013 13:42:39 +0000 Subject: [PATCH] feature(dom) add Dialog --- lib/client/dom.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 450e8314..8a8193b6 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1,4 +1,4 @@ -var CloudCmd, Util, DOM, CloudFunc; +var CloudCmd, Util, DOM, CloudFunc, Dialog; (function(Util) { 'use strict'; @@ -6,6 +6,11 @@ var CloudCmd, Util, DOM, CloudFunc; var DOMFunc = function() {}, DOMProto, + DialogProto = function() { + this.alert = alert.bind(window); + this.prompt = prompt.bind(window); + }, + ImagesProto = function() { var LImagesProto = function() { function getImage(pName) { @@ -114,7 +119,7 @@ var CloudCmd, Util, DOM, CloudFunc; if (lText) { Util.log(lText); - setTimeout(Util.retFunc(alert, lText), 100); + setTimeout(Util.retFunc(Dialog.alert, lText), 100); } return lErrorImage; @@ -1098,7 +1103,7 @@ var CloudCmd, Util, DOM, CloudFunc; if (lName === '..') lName = ''; - lName = prompt(lMsg, lName); + lName = Dialog.prompt(lMsg, lName); if (lName) RESTfull.save(lDir + lName + lType, null, CloudCmd.refresh); @@ -1175,7 +1180,7 @@ var CloudCmd, Util, DOM, CloudFunc; if (lName !== '..') lRet = confirm(lMsg); else - alert('No files selected!'); + Dialog.alert('No files selected!'); if (lRet) { var lUrl; @@ -1813,7 +1818,7 @@ var CloudCmd, Util, DOM, CloudFunc; var lCurrent = pCurrentFile || Cmd.getCurrentFile(), lFrom = Cmd.getCurrentName(lCurrent), - lTo = prompt('Rename', lFrom) || lFrom, + lTo = Dialog.prompt('Rename', lFrom) || lFrom, lDirPath = Cmd.getCurrentDirPath(); if ( !Util.strCmp(lFrom, lTo) ) { @@ -1842,7 +1847,7 @@ var CloudCmd, Util, DOM, CloudFunc; lFromPath = Cmd.getCurrentPath(), lToPath = Cmd.getNotCurrentDirPath() + lName; - lToPath = prompt( 'Rename/Move file "' + lName + '"', lToPath ); + lToPath = Dialog.prompt('Rename/Move file "' + lName + '"', lToPath); if ( lToPath && !Util.strCmp(lFromPath, lToPath) ) { var lFiles = { @@ -1875,7 +1880,7 @@ var CloudCmd, Util, DOM, CloudFunc; lName = Cmd.getCurrentName(lCurrent), lFromPath = Cmd.getCurrentPath(), lToPath = Cmd.getNotCurrentDirPath() + lName; - lToPath = prompt( 'Copy file "' + lName + '" to', lToPath ); + lToPath = Dialog.prompt( 'Copy file "' + lName + '" to', lToPath ); if ( lToPath && !Util.strCmp(lFromPath, lToPath) ) { var lFiles = { @@ -1945,6 +1950,8 @@ var CloudCmd, Util, DOM, CloudFunc; DOMProto = DOMFunc.prototype = new CmdProto(); + Dialog = new DialogProto(); + Util.extend(DOMProto, [ DOMTree, Loader, {