/* Copyright 2008-2011 Clipperz Srl This file is part of Clipperz's Javascript Crypto Library. Javascript Crypto Library provides web developers with an extensive and efficient set of cryptographic functions. The library aims to obtain maximum execution speed while preserving modularity and reusability. For further information about its features and functionalities please refer to http://www.clipperz.com * Javascript Crypto Library is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. * Javascript Crypto Library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. * You should have received a copy of the GNU Affero General Public License along with Javascript Crypto Library. If not, see . */ if (typeof(Clipperz) == 'undefined') { Clipperz = {}; } if (typeof(Clipperz.PM) == 'undefined') { Clipperz.PM = {}; } if (typeof(Clipperz.PM.Components) == 'undefined') { Clipperz.PM.Components = {}; } if (typeof(Clipperz.PM.Components.Panels) == 'undefined') { Clipperz.PM.Components.Panels = {}; } //############################################################################# Clipperz.PM.Components.Panels.DataPanel = function(anElement, args) { args = args || {}; Clipperz.PM.Components.Panels.DataPanel.superclass.constructor.call(this, anElement, args); this._progressWidth = 400; this.render(); return this; } //============================================================================= YAHOO.extendX(Clipperz.PM.Components.Panels.DataPanel, Clipperz.PM.Components.Panels.BasePanel, { 'toString': function() { return "Clipperz.PM.Components.DataPanel component"; }, //------------------------------------------------------------------------- 'render': function() { MochiKit.Signal.disconnectAllTo(this); Clipperz.NotificationCenter.unregister(this); this.element().update(""); Clipperz.YUI.DomHelper.append(this.element().dom, {tag:'table', border:'0', cellspacing:'0', cellpadding:'0', children:[ {tag:'tbody', children:[ {tag:'tr', children:[ {tag:'td', valign:'top', width:'200', children:[ {tag:'ul', id:"dataSubMenu", cls:'subMenu', children:[ {tag:'li', id:'offlineCopyTab', htmlString:Clipperz.PM.Strings['offlineCopyTabLabel']}, {tag:'li', id:'sharingTab', htmlString:Clipperz.PM.Strings['sharingTabLabel']}, {tag:'li', id:'importTab', htmlString:Clipperz.PM.Strings['importTabLabel']}, {tag:'li', id:'printingTab', htmlString:Clipperz.PM.Strings['printingTabLabel']} ]} ]}, {tag:'td', valign:'top', children:[ {tag:'ul', cls:'clipperzTabPanels', children:[ {tag:'li', id:this.getId('offlineCopyPanel'), children:[ {tag:'div', cls:'clipperzSubPanel', children:[ {tag:'h5', htmlString:Clipperz.PM.Strings['offlineCopyTabTitle']}, {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['offlineCopyTabDescription']}, {tag:'div', id:this.getId('offlineCopyLinkBox'), children:[ {tag:'a', id:'offlineCopyLink', href:'#', htmlString:Clipperz.PM.Strings['offlineCopyDownloadLinkLabel']} ]}, {tag:'div', id:this.getId('offlineCopyLinkBox_read-only'), children:[ {tag:'span', cls:'read-only', htmlString:Clipperz.PM.Strings['offlineCopyDownloadLinkLabel']} ]} ]} ]}, {tag:'li', id:this.getId('sharingPanel'), children:[ {tag:'div', cls:'clipperzSubPanel', children:[ {tag:'h5', htmlString:Clipperz.PM.Strings['sharingTabTitle']}, {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['sharingTabDescription']} ]} ]}, {tag:'li', id:this.getId('importPanel'), children:[ {tag:'div', cls:'clipperzSubPanel', children:[ {tag:'div', id:this.getId('importPanelMainComponent')} ]} ]}, {tag:'li', id:this.getId('printingPanel'), children:[ {tag:'div', cls:'clipperzSubPanel', children:[ {tag:'h5', htmlString:Clipperz.PM.Strings['printingTabTitle']}, {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['printingTabDescription']}, {tag:'div', id:this.getId('printingLinkBox'), children:[ {tag:'a', id:'printingLink', href:'#', htmlString:Clipperz.PM.Strings['printingLinkLabel']} ]}, {tag:'hr'}, {tag:'div', cls:'panelDescription', htmlString:Clipperz.PM.Strings['exportTabDescription']}, {tag:'div', id:this.getId('exportLinkBox'), children:[ {tag:'a', id:'exportLink', href:'#', htmlString:Clipperz.PM.Strings['exportLinkLabel']} ]} ]} ]} ]} ]} ]} ]} ]}); this.tabPanelController().setUp(); if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { this.getElement('offlineCopyLinkBox').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); } else { this.getElement('offlineCopyLinkBox_read-only').setVisibilityMode(YAHOO.ext.Element.DISPLAY).hide(); MochiKit.Signal.connect('offlineCopyLink', 'onclick', this, 'downloadOfflineCopy'); } new Clipperz.PM.Components.Import.MainComponent(this.getElement('importPanelMainComponent'), {user:this.user()}); MochiKit.Signal.connect('printingLink', 'onclick', this, 'printAllData'); MochiKit.Signal.connect('exportLink', 'onclick', this, 'exportAllData'); Clipperz.NotificationCenter.register(null, 'switchLanguage', this, 'switchLanguageHandler'); }, //------------------------------------------------------------------------- 'tabPanelController': function() { if (this._tabPanelController == null) { var tabPanelControllerConfig; tabPanelControllerConfig = {} tabPanelControllerConfig['offlineCopyTab'] = this.getId('offlineCopyPanel'); tabPanelControllerConfig['sharingTab'] = this.getId('sharingPanel'); tabPanelControllerConfig['importTab'] = this.getId('importPanel'); tabPanelControllerConfig['printingTab'] = this.getId('printingPanel'); this._tabPanelController = new Clipperz.PM.Components.TabPanel.TabPanelController({ name: 'dataTabPanel', config:tabPanelControllerConfig, selectedTab:'offlineCopyTab' }); } return this._tabPanelController; }, //------------------------------------------------------------------------- 'downloadOfflineCopy': function(anEvent) { var downloadHref; downloadHref = window.location.href.replace(/\/[^\/]*$/,'') + Clipperz_dumpUrl; if (Clipperz_IEisBroken == true) { window.open(downloadHref, ""); } else { var deferredResult; var newWindow; newWindow = window.open("", ""); anEvent.preventDefault(); deferredResult = new MochiKit.Async.Deferred(); deferredResult.addCallback(MochiKit.Base.method(this.user().connection(), 'message'), 'echo', {'echo':"echo"}); deferredResult.addCallback(function(aWindow) { aWindow.location.href = downloadHref; }, newWindow); deferredResult.callback(); } }, //------------------------------------------------------------------------- 'compareRecords': function(a, b) { return MochiKit.Base.compare(a.label().toLowerCase(), b.label().toLowerCase()); }, 'logo': function() { var result; if (Clipperz_IEisBroken == true) { if (Clipperz.PM.Proxy.defaultProxy.isReadOnly()) { result = "clipperz"; } else { result = ""; } } else { result = ""; } return result; }, 'progressWidth': function() { return this._progressWidth; }, 'updateProgress': function(aProgressComponent, aPercentage) { }, //------------------------------------------------------------------------- 'printAllData': function(anEvent) { var newWindow; var allRecords; //MochiKit.Logging.logDebug(">>> printAllData"); newWindow = window.open("", ""); newWindow.document.write( "" + "
" + " Clipperz export data" + "" + "" + "" + "" + "
" + "" + "
" + this.logo() + "
 
" + "
" + "" + "" ); anEvent.preventDefault(); allRecords = MochiKit.Base.values(this.user().records()); allRecords.sort(this.compareRecords); /* deferredResult = new MochiKit.Async.Deferred(); MochiKit.Iter.forEach(allRecords, MochiKit.Base.partial(function(aDeferredResult, aWindow, aRecord) { var printerRecord; printerRecord = new Clipperz.PM.Components.Printing.Record({record:aRecord}); aDeferredResult.addCallback(MochiKit.Base.method(printerRecord, 'deferredDrawToWindow', aWindow)); }, deferredResult, newWindow)); deferredResult.callback(); return deferredResult; */ MochiKit.DOM.withWindow(newWindow, MochiKit.Base.bind(function(someRecords) { var currentWindow; var deferredResult; var progressBar; var progressWrapper; var i, c; currentWindow = MochiKit.DOM.currentWindow(); progressBar = MochiKit.DOM.getElement('progress'); progressWrapper = MochiKit.DOM.getElement('progressWrapper'); deferredResult = new MochiKit.Async.Deferred(); c = someRecords.length; for (i=0; i>> printAllData"); newWindow = window.open("", ""); newWindow.document.write( "" + "
" + " Clipperz export data" + "" + "" + "" + "" + "
" + "" + "
" + this.logo() + "
" + "
" + "
" + Clipperz.PM.Strings['exportDataInProgressDescription'] + "
" + "
 
" + "
" + "
" + "
" + Clipperz.PM.Strings['exportDataDescription'] + "
" + " " + "
" + "" + "" ); anEvent.preventDefault(); allRecords = MochiKit.Base.values(this.user().records()); allRecords.sort(this.compareRecords); MochiKit.DOM.withWindow(newWindow, MochiKit.Base.bind(function(someRecords) { var currentWindow; var deferredResult; var textareaWrapper; var textarea; var progressBar; var progressWrapper; var i, c; currentWindow = MochiKit.DOM.currentWindow(); textarea = MochiKit.DOM.getElement('exportedData'); textareaWrapper = MochiKit.DOM.getElement('textareaWrapper'); MochiKit.Style.hideElement(textareaWrapper); progressBar = MochiKit.DOM.getElement('progress'); progressWrapper = MochiKit.DOM.getElement('progressWrapper'); deferredResult = new MochiKit.Async.Deferred(); //deferredResult.addBoth(function(res) {MochiKit.Logging.logDebug("exportAllData - 1: " + res); return res;}); c = someRecords.length; for (i=0; i