Sha256: da14d3b14f9dcf8e5f3929ab3791c582f6c8db2ce0ce80c3a2701530cbce801f
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 KB
Contents
CodeSync.DocumentManager = Backbone.Model.extend initialize: (@attributes={})-> @editor = @attributes.editor delete @attributes.editor @openDocuments = new CodeSync.Documents() for trigger in ["add","remove","change:display","change:sticky"] @openDocuments.on(trigger, @notify, @) Backbone.Model::initialize.apply(@,arguments) # In multiple setups with multiple editors # the DocumentManager can act as a singleton # and route documents to multiple editors getEditor: ()-> @editor || _(CodeSync.AssetEditor.instances).values()[0] detect: (iterator)-> @openDocuments.each(iterator) each: (iterator)-> @openDocuments.each(iterator) notify: ()-> @trigger "document:change" openDocument: (doc, editor)-> editor ||= @getEditor() @openDocuments.add(doc) @setCurrentDocument(doc, editor) setCurrentDocument: (@currentDocument, editor)-> editor ||= @editor editor.loadDocument(@currentDocument) saveDocument: ()-> if CodeSync.get("disableAssetSave") @getEditor().showError("Saving is disabled.") else @currentDocument.saveToDisk() createDocument: (editor)-> editor ||= @getEditor() mode = editor.mode?.id || CodeSync.get("defaultFileType") extension = CodeSync.Modes.guessExtensionFor(mode) doc = new CodeSync.Document name: "untitled" display: "Untitled" mode: mode extension: extension @openDocument(doc,editor)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
code_sync-0.6.7 | lib/assets/javascripts/code_sync/editor/plugins/document_manager.coffee |