author | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2011-10-02 23:56:18 (UTC) |
---|---|---|
committer | Giulio Cesare Solaroli <giulio.cesare@clipperz.com> | 2011-10-02 23:56:18 (UTC) |
commit | ef68436ac04da078ffdcacd7e1f785473a303d45 (patch) (side-by-side diff) | |
tree | c403752d66a2c4775f00affd4fa8431b29c5b68c /frontend/gamma/js/Clipperz/PM/UI/Common/Controllers | |
parent | 597ecfbc0249d83e1b856cbd558340c01237a360 (diff) | |
download | clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.zip clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.tar.gz clipperz-ef68436ac04da078ffdcacd7e1f785473a303d45.tar.bz2 |
First version of the newly restructured repository
Diffstat (limited to 'frontend/gamma/js/Clipperz/PM/UI/Common/Controllers') (more/less context) (show whitespace changes)
4 files changed, 629 insertions, 0 deletions
diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/DirectLoginRunner.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/DirectLoginRunner.js new file mode 100644 index 0000000..e534435 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/DirectLoginRunner.js @@ -0,0 +1,267 @@ +/* + +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 + <http://www.gnu.org/licenses/>. + +*/ + +Clipperz.Base.module('Clipperz.PM.UI.Common.Controllers'); + +Clipperz.PM.UI.Common.Controllers.DirectLoginRunner = function(args) { + this._directLogin = args['directLogin'] || Clipperz.Base.exception.raise('MandatoryParameter'); + this._target = Clipperz.PM.Crypto.randomKey(); + + return this; +} + +MochiKit.Base.update(Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.prototype, { + + 'toString': function() { + return "Clipperz.PM.UI.Common.Controllers.DirectLoginRunner"; + }, + + //----------------------------------------------------------------------------- + + 'directLogin': function () { + return this._directLogin; + }, + + //----------------------------------------------------------------------------- + + 'target': function () { + return this._target; + }, + + //============================================================================= + + 'setWindowTitle': function (aWindow, aTitle) { + aWindow.document.title = aTitle; + }, + + 'setWindowBody': function (aWindow, anHTML) { + aWindow.document.body.innerHTML = anHTML; + }, + + //============================================================================= + + 'initialWindowSetup': function (aWindow) { + this.setWindowTitle(aWindow, "Loading Clipperz Direct Login"); + this.setWindowBody (aWindow, MochiKit.DOM.toHTML(MochiKit.DOM.H3("Loading Clipperz Direct Login ..."))); + }, + + //----------------------------------------------------------------------------- + + 'updateWindowWithDirectLoginLabel': function (aWindow, aLabel) { + var titleText; + var bodyText; + + titleText = "Loading '__label__' Direct Login".replace(/__label__/, aLabel) + bodyText = "Loading '__label__' Direct Login... ".replace(/__label__/, aLabel) + + this.setWindowTitle(aWindow, titleText); + this.setWindowBody (aWindow, MochiKit.DOM.toHTML(MochiKit.DOM.H3(bodyText))); + }, + + //----------------------------------------------------------------------------- + + 'updateWindowWithHTMLContent': function (aWindow, anHtml) { + this.setWindowBody(aWindow, anHtml); + }, + + //============================================================================= + + 'submitLoginForm': function(aWindow, aSubmitFunction) { + MochiKit.DOM.withWindow(aWindow, MochiKit.Base.bind(function () { + var formElement; + var submitButtons; + + formElement = MochiKit.DOM.getElement('directLoginForm'); + + submitButtons = MochiKit.Base.filter(function(anInputElement) { + return ((anInputElement.tagName.toLowerCase() == 'input') && (anInputElement.getAttribute('type').toLowerCase() == 'submit')); + }, formElement.elements); + + if (submitButtons.length == 0) { + if (typeof(formElement.submit) == 'function') { + formElement.submit(); + } else { + aSubmitFunction.apply(formElement); + } +/* + var formSubmitFunction; + + formSubmitFunction = MochiKit.Base.method(formElement, 'submit'); + if (Clipperz_IEisBroken == true) { + formElement.submit(); + } else { + formSubmitFunction(); + } +*/ + } else { + submitButtons[0].click(); + } + }, this)); + }, + + //------------------------------------------------------------------------- + + 'runSubmitFormDirectLogin': function (aWindow, someAttributes) { + var html; + var formElement; + var submitFunction; + + formElement = MochiKit.DOM.FORM({ + 'id':'directLoginForm', + 'method':someAttributes['formAttributes']['method'], + 'action':someAttributes['formAttributes']['action'] + }); + + submitFunction = formElement.submit; + + MochiKit.DOM.appendChildNodes(formElement, MochiKit.Base.map(function (anInputAttributes) { + return MochiKit.DOM.INPUT({'type':'hidden', 'name':anInputAttributes[0], 'value':anInputAttributes[1]}); + }, MochiKit.Base.items(someAttributes['inputValues']))); + + html = ''; + html += '<h3>Loading ' + someAttributes['label'] + ' ...</h3>'; + html += MochiKit.DOM.appendChildNodes(MochiKit.DOM.DIV(), MochiKit.DOM.appendChildNodes(MochiKit.DOM.DIV({style:'display:none; visibility:hidden;'}), formElement)).innerHTML; + + this.updateWindowWithHTMLContent(aWindow, html); + this.submitLoginForm(aWindow, submitFunction); + }, + + //------------------------------------------------------------------------- + + 'runHttpAuthDirectLogin': function(aWindow, someAttributes) { + var completeUrl; + var url; + +//console.log("runHttpAuthDirectLogin", someAttributes); + url = someAttributes['inputValues']['url']; + + if (/^https?\:\/\//.test(url) == false) { + url = 'http://' + url; + } + + if (Clipperz_IEisBroken === true) { + completeUrl = url; + } else { + var username; + var password; + + username = someAttributes['inputValues']['username']; + password = someAttributes['inputValues']['password']; + /(^https?\:\/\/)?(.*)/.test(url); + + completeUrl = RegExp.$1 + username + ':' + password + '@' + RegExp.$2; + } + + window.open(completeUrl, this.target()); + }, + + //============================================================================= + + 'runDirectLogin': function (aWindow) { + var deferredResult; + +//console.log(">>> runDirectLogin"); + deferredResult = new Clipperz.Async.Deferred("DirectLoginRunner.openDirectLogin", {trace:false}); + deferredResult.addMethod(this, 'initialWindowSetup', aWindow); + deferredResult.addMethod(this.directLogin(), 'label'); + deferredResult.addMethod(this, 'updateWindowWithDirectLoginLabel', aWindow); + deferredResult.collectResults({ + 'type': MochiKit.Base.method(this.directLogin(), 'type'), + 'label': MochiKit.Base.method(this.directLogin(), 'label'), + 'formAttributes': MochiKit.Base.method(this.directLogin(), 'formAttributes'), + 'inputValues': MochiKit.Base.method(this.directLogin(), 'inputValues') + }); +//deferredResult.addCallback(function (aValue) { console.log("SOME ATTRIBUTES", aValue); return aValue; }); + deferredResult.addCallback(MochiKit.Base.bind(function (someAttributes) { +//console.log("SOME ATTRIBUTES", someAttributes); + switch (someAttributes['type']) { + case 'http_auth': + this.runHttpAuthDirectLogin(aWindow, someAttributes); + break; + case 'simple_url': + this.runSimpleUrlDirectLogin(aWindow, someAttributes); + break; + default: + this.runSubmitFormDirectLogin(aWindow, someAttributes); + break; + } + }, this)); + deferredResult.callback(); +//console.log("<<< runDirectLogin"); + + return deferredResult; + }, + + //============================================================================= + + 'run': function () { + var newWindow; + + newWindow = window.open(Clipperz.PM.Strings.getValue('directLoginJumpPageUrl'), this.target()); + + return this.runDirectLogin(newWindow); + }, + + //============================================================================= + + 'test': function () { + var iFrame; + var newWindow; + + iFrame = MochiKit.DOM.createDOM('iframe'); + MochiKit.DOM.appendChildNodes(MochiKit.DOM.currentDocument().body, iFrame); + + newWindow = iFrame.contentWindow; + + return this.runDirectLogin(newWindow); + }, + + //============================================================================= + __syntaxFix__: "syntax fix" +}); + +//----------------------------------------------------------------------------- + +Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.openDirectLogin = function (aDirectLogin) { + var runner; + + runner = new Clipperz.PM.UI.Common.Controllers.DirectLoginRunner({directLogin:aDirectLogin}); + return runner.run(); +}; + +//----------------------------------------------------------------------------- + +Clipperz.PM.UI.Common.Controllers.DirectLoginRunner.testDirectLogin = function (aDirectLogin) { + var runner; + +//console.log(">>>>>> TESTING DIRECT LOGIN"); + runner = new Clipperz.PM.UI.Common.Controllers.DirectLoginRunner({directLogin:aDirectLogin}); + return runner.test(); +}; + +//----------------------------------------------------------------------------- diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js new file mode 100644 index 0000000..a4fa400 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/ProgressBarController.js @@ -0,0 +1,143 @@ +/* + +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 + <http://www.gnu.org/licenses/>. + +*/ + +Clipperz.Base.module('Clipperz.PM.UI.Common.Controllers'); + +Clipperz.PM.UI.Common.Controllers.ProgressBarController = function(args) { + args = args || {}; + + this._numberOfSteps = 0; + this._currentStep = 0; + + MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'initProgress', this, 'initProgressHandle'); + MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'updateProgress', this, 'updateProgressHandle'); + MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'advanceProgress', this, 'advanceProgressHandle'); + MochiKit.Signal.connect(Clipperz.Signal.NotificationCenter, 'progressDone', this, 'progressDoneHandle'); + + return this; +} + +MochiKit.Base.update(Clipperz.PM.UI.Common.Controllers.ProgressBarController.prototype, { + + 'toString': function() { + return "Clipperz.PM.UI.Common.Controllers.ProgressBarController"; + }, + + //----------------------------------------------------------------------------- + + 'numberOfSteps': function() { + return this._numberOfSteps; + }, + + 'setNumberOfSteps': function (aValue) { + this._numberOfSteps = aValue; + }, + + 'updateNumberOfSteps': function (aValue) { + this._numberOfSteps += aValue; + }, + + //----------------------------------------------------------------------------- + + 'currentStep': function() { + return this._currentStep; + }, + + 'advanceCurrentStep': function () { + this._currentStep ++; + }, + + //----------------------------------------------------------------------------- + + 'completedPercentage': function () { + var result; +//Clipperz.log(">>> completedPercentage" + this.currentStep() + "/" + this.numberOfSteps(), this.currentStep() / this.numberOfSteps()); + if (this.numberOfSteps() == 0) { + result = 0; + } else { + result = (Math.min(100, 100 * (this.currentStep() / this.numberOfSteps()))); + } +//Clipperz.log("<<< completedPercentage", result); + return result; + }, + + //----------------------------------------------------------------------------- + + 'resetStatus': function () { + this._numberOfSteps = 0; + this._currentStep = 0; + }, + + //----------------------------------------------------------------------------- + + 'updateProgress': function () { +//Clipperz.log(">>> updateProgress: " + this.completedPercentage() + "%"); + MochiKit.Signal.signal(this, 'updateProgress', this.completedPercentage()); + }, + + //============================================================================= + + 'initProgressHandle': function (anEvent) { +//Clipperz.log(">>> initProgressHandle - steps: " + (anEvent != null ? anEvent['steps'] : 0)); + this.resetStatus(); + if (anEvent != null) { + this.setNumberOfSteps(anEvent['steps']); + } + MochiKit.Signal.signal(this, 'initProgress'); + this.updateProgress(); + }, + + //............................................................................. + + 'updateProgressHandle': function (anEvent) { + this.updateNumberOfSteps(anEvent['extraSteps']); +//Clipperz.log("=== updateProgressHandle - steps: " + this.numberOfSteps() + " (extra " + anEvent['extraSteps'] + ")"); + this.updateProgress(); + }, + + //............................................................................. + + 'advanceProgressHandle': function (anEvent) { + this.advanceCurrentStep(); +//Clipperz.log("--- advanceProgressHandle: " + this.currentStep() + "/" + this.numberOfSteps()); + this.updateProgress(); + }, + + //............................................................................. + + 'progressDoneHandle': function (anEvent) { +//Clipperz.log("<<< progressDoneHandle: " + this.currentStep() + "/" + this.numberOfSteps()); + this.resetStatus(); + MochiKit.Signal.signal(this, 'progressDone'); + }, + + //============================================================================= + __syntaxFix__: "syntax fix" +}); + +Clipperz.PM.UI.Common.Controllers.ProgressBarController.defaultController = new Clipperz.PM.UI.Common.Controllers.ProgressBarController(); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/TabPanelController.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/TabPanelController.js new file mode 100644 index 0000000..fbc5929 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/TabPanelController.js @@ -0,0 +1,188 @@ +/* + +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 + <http://www.gnu.org/licenses/>. + +*/ + +Clipperz.Base.module('Clipperz.PM.UI.Common.Controllers'); + +Clipperz.PM.UI.Common.Controllers.TabPanelController = function(args) { + args = args || {}; + + this._component = args.component; + this._configuration = args.configuration; + this._isEnabled = args.enabled || true; + + this._selectedTab = null; + return this; +} + +MochiKit.Base.update(Clipperz.PM.UI.Common.Controllers.TabPanelController.prototype, { + + 'toString': function() { + return "Clipperz.PM.UI.Common.Controllers.TabPanelController"; + }, + + //----------------------------------------------------------------------------- + + 'component': function() { + return this._component; + }, + + 'configuration': function() { + return this._configuration; + }, + + //----------------------------------------------------------------------------- + + 'getElement': function(anElementID) { + return this.component().getElement(anElementID); + }, + + 'tabForTabElement': function(anElement) { + var result; + + for (result in this.configuration()) { + if (this.getElement(this.configuration()[result]['tab']) == anElement) { + break; + } + } + + return result; + }, + + //----------------------------------------------------------------------------- + + 'setupTab': function(aConfiguration) { + var tabElement; + + tabElement = this.getElement(aConfiguration['tab']); + + MochiKit.DOM.removeElementClass(tabElement, 'selected'); + MochiKit.Signal.connect(tabElement, 'onclick', this, 'handleTabClick') + }, + + 'setupPanel': function(aConfiguration) { + this.hidePanel(aConfiguration['panel']); + }, + + 'setup': function(args) { + args = args || {}; + + MochiKit.Base.map(MochiKit.Base.method(this, 'setupTab'), MochiKit.Base.values(this.configuration())); + MochiKit.Base.map(MochiKit.Base.method(this, 'setupPanel'), MochiKit.Base.values(this.configuration())); + this.selectTab(args.selected); + }, + + //----------------------------------------------------------------------------- + + 'hidePanel': function(aPanel) { + MochiKit.DOM.removeElementClass(this.getElement(aPanel), 'selected'); + }, + + 'selectTab': function(aTab) { + if ((aTab != this.selectedTab()) && (this.isEnabled())) { + if (this.selectedTab() != null) { + MochiKit.DOM.removeElementClass(this.getElement(this.configuration()[this.selectedTab()]['tab']), 'selected'); + MochiKit.DOM.removeElementClass(this.getElement(this.configuration()[this.selectedTab()]['panel']), 'selected'); + } + + if (aTab != null) { + MochiKit.DOM.addElementClass(this.getElement(this.configuration()[aTab]['tab']), 'selected'); + MochiKit.DOM.addElementClass(this.getElement(this.configuration()[aTab]['panel']), 'selected'); + } + + this.setSelectedTab(aTab); + MochiKit.Signal.signal(this, 'tabSelected', aTab); + } + }, + + //----------------------------------------------------------------------------- + + 'selectedTab': function() { + return this._selectedTab; + }, + + 'setSelectedTab': function(aTab) { + this._selectedTab = aTab; + }, + + //----------------------------------------------------------------------------- + + 'selectedTabElement': function() { + var result; + + if (this.selectedTab() != null) { + result = this.getElement(this.configuration()[this.selectedTab()]['tab']); + } else { + result = null; + } + + return null; + }, + + 'selectedTabPanelElement': function() { + var result; + + if (this.selectedTab() != null) { + result = this.getElement(this.configuration()[this.selectedTab()]['panel']); + } else { + result = null; + } + + return result; + }, + + //----------------------------------------------------------------------------- + + 'handleTabClick': function(anEvent) { + this.selectTab(this.tabForTabElement(anEvent.src())); + anEvent.preventDefault(); + }, + + //============================================================================= + + 'isEnabled': function () { + return this._isEnabled; + }, + + 'enable': function () { + this._isEnabled = true; + MochiKit.Base.map(MochiKit.Base.bind(function (aTabComponentID) { + MochiKit.DOM.removeElementClass(this.getElement(this.configuration()[aTabComponentID]['tab']), 'disabled'); + }, this), MochiKit.Base.keys(this.configuration())); + }, + + 'disable': function () { + this._isEnabled = false; + MochiKit.Base.map(MochiKit.Base.bind(function (aTabComponentID) { + MochiKit.DOM.addElementClass(this.getElement(this.configuration()[aTabComponentID]['tab']), 'disabled'); + }, this), MochiKit.Base.keys(this.configuration())); + }, + + //============================================================================= + + __syntaxFix__: "syntax fix" +}); diff --git a/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/WizardController.js b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/WizardController.js new file mode 100644 index 0000000..868cea6 --- a/dev/null +++ b/frontend/gamma/js/Clipperz/PM/UI/Common/Controllers/WizardController.js @@ -0,0 +1,31 @@ +/* + +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 + <http://www.gnu.org/licenses/>. + +*/ + +// Still empty, but here it should be reasonable to factor in code duplicated between +// - DirectLoginWizardController +// - NewUserWizardController
\ No newline at end of file |