define([ 'jquery', '/common/toolbar3.js', '/bower_components/nthen/index.js', '/common/sframe-common.js', '/common/common-interface.js', '/common/common-ui-elements.js', '/common/common-util.js', '/common/common-hash.js', '/customize/messages.js', '/common/hyperscript.js', '/customize/credential.js', '/customize/application_config.js', '/api/config', '/common/outer/login-block.js', // XXX HACK '/bower_components/file-saver/FileSaver.min.js', 'css!/bower_components/bootstrap/dist/css/bootstrap.min.css', 'css!/bower_components/components-font-awesome/css/font-awesome.min.css', 'less!/customize/src/less2/main.less', ], function ( $, Toolbar, nThen, SFCommon, UI, UIElements, Util, Hash, Messages, h, Cred, AppConfig, ApiConfig, Block // XXX HACK ) { var saveAs = window.saveAs; var APP = window.APP = {}; var common; var metadataMgr; var privateData; var sframeChan; var categories = { 'account': [ 'cp-settings-info-block', 'cp-settings-displayname', 'cp-settings-language-selector', 'cp-settings-logout-everywhere', 'cp-settings-resettips', 'cp-settings-thumbnails', 'cp-settings-userfeedback', 'cp-settings-change-password', 'cp-settings-migrate', 'cp-settings-delete' ], 'creation': [ 'cp-settings-creation-owned', 'cp-settings-creation-expire', 'cp-settings-creation-skip', 'cp-settings-creation-template' ], 'drive': [ 'cp-settings-drive-backup', 'cp-settings-drive-import-local', 'cp-settings-drive-reset' ], 'pad': [ 'cp-settings-pad-width', ], 'code': [ 'cp-settings-code-indent-unit', 'cp-settings-code-indent-type' ], 'subscription': { onClick: function () { var urls = common.getMetadataMgr().getPrivateData().accounts; window.open(urls.upgradeURL); } } }; if (!AppConfig.displayCreationScreen) { delete categories.creation; } if (AppConfig.disableFeedback) { var feedbackIdx = categories.account.indexOf('cp-settings-userfeedback'); categories.account.splice(feedbackIdx, 1); } if (AppConfig.disableProfile) { var displaynameIdx = categories.account.indexOf('cp-settings-displayname'); categories.account.splice(displaynameIdx, 1); } if (!ApiConfig.allowSubscriptions) { delete categories.subscription; } var create = {}; // Account settings create['info-block'] = function () { var $div = $('
', {'class': 'cp-settings-info-block'}); var $account = $('
', {'class': 'cp-sidebarlayout-element'}).appendTo($div); var accountName = privateData.accountName; var $label = $('', {'class': 'label'}).text(Messages.user_accountName); var $name = $('').text(accountName || ''); if (!accountName) { $label.text(''); $name.text(Messages.settings_anonymous); } $account.append($label).append($name); var publicKey = privateData.edPublic; if (publicKey) { var $key = $('
', {'class': 'cp-sidebarlayout-element'}).appendTo($div); var userHref = Hash.getUserHrefFromKeys(privateData.origin, accountName, publicKey); var $pubLabel = $('', {'class': 'label'}) .text(Messages.settings_publicSigningKey); $key.append($pubLabel).append(UI.dialog.selectable(userHref)); } return $div; }; // Create the block containing the display name field create['displayname'] = function () { var $div = $('
', {'class': 'cp-settings-displayname cp-sidebarlayout-element'}); $('