define [ "utils/Modal" "settings/DropboxSettingsManager" ], (Modal, DropboxSettingsManager) -> class SettingsManager templates: settingsPanel: $("#settingsPanelTemplate").html() constructor: (@ide, options) -> options || = {} setup = _.once => @bindToProjectName() @bindToPublicAccessLevel() @bindToCompiler() @bindToRootDocument() @bindToSpellingPreference() new DropboxSettingsManager @ide @setFontSize() if @ide? @ide.on "afterJoinProject", (project) => @project = project setup() settingsPanel = $(@templates.settingsPanel) @ide.tabManager.addTab id: "settings" name: "Settings" content: settingsPanel lock: true $('#DownloadZip').click (event)=> event.preventDefault() @ide.mainAreaManager.setIframeSrc "/project/#{@ide.project_id}/download/zip" $("#deleteProject").click (event)=> event.preventDefault() self = @ deleteProject = => $.ajax url: "/Project/#{@ide.project_id}", type: 'DELETE' data: _csrf: window.csrfToken success: -> window.location = '/' modalOptions = templateId:'deleteEntityModal' isStatic: false title:'Delete Project' message: "Are you sure you want to delete this project?" buttons: [{ text : "Cancel", class : "btn", }, { text : "Delete Forever", class : "btn-danger confirm", callback : deleteProject }] Modal.createModal modalOptions $('.cloneProject').click (event)=> event.stopPropagation() event.preventDefault() goToRegPage = -> window.location = "/register" modalOptions = isStatic: false title:'Registration Required' message: "You need to register to clone a project" buttons: [{ text : "Cancel", class : "btn", }, { text : "Register Now", class : "btn-success confirm", callback : goToRegPage }] user = @project.get("ide").user if user.id == "openUser" return Modal.createModal modalOptions $modal = $('#cloneProjectModal') $confirm = $('#confirmCloneProject') $modal.modal({backdrop:true, show:true, keyboard:true}) $modal.find('input').val('').focus() self = @ $confirm.click (e)-> $confirm.attr("disabled", true) $confirm.text("Cloning...") projectName = $modal.find('input').val() $.ajax url: "/project/#{self.ide.project_id}/clone" type:'POST' data: projectName: projectName _csrf: window.csrfToken success: (data)-> if data.redir? window.location = data.redir else if data.project_id? window.location = '/project/'+data.project_id $modal.on 'hide', -> $confirm.off 'click' $modal.find('.cancel').click (e)-> $modal.modal('hide') setFontSize: () -> @fontSizeCss = $("