コード例 #1
0
	function loadTodoFile( callback ) {
		var fileEntry = FileSystem.getFileForPath( Paths.todoFile() ),
			fileContent,
			fileSettings = {};
		
		// Check if .todo exists in current project.
		fileEntry.exists( function( err, exists ) {
			// Only load settings from .todo if it exists.
			if ( exists ) {
				fileContent = FileUtils.readAsText( fileEntry );
				
				// File is loaded asynchronous.
				fileContent.done( function( content ) {
					// Catch error if JSON is invalid
					try {
						// Parse .todo file.
						fileSettings = JSON.parse( content );
					} catch ( e ) {
						// .todo exists but isn't valid JSON.
					}
				} ).always( function() {
					callback( fileSettings );
				} );
			} else {
				callback( fileSettings );
			}
		} );
	}
コード例 #2
0
ファイル: main.js プロジェクト: ceroberoz/brackets-todo
			.on( 'pathDeleted.todo', function( event, deletedPath ) {
				var todoPath = Paths.todoFile();
				
				// Reload settings if .todo of current project was deleted.
				if ( deletedPath === todoPath ) {
					SettingsManager.loadSettings();
				}
				
				// Parse path that was deleted to remove from list.
				setTodos( ParseUtils.removeFile( deletedPath, todos ) );
			} );
コード例 #3
0
ファイル: main.js プロジェクト: ceroberoz/brackets-todo
		FileSystem.on( 'rename', function( event, oldName, newName ) {
			var todoPath = Paths.todoFile();
			
			// Reload settings if .todo of current project was updated.
			if ( newName === todoPath || oldName === todoPath ) {
				SettingsManager.loadSettings();
			} else {
				// If not .todo, parse all files.
				run();
			}
		} );
コード例 #4
0
ファイル: main.js プロジェクト: Denisov21/brackets-todo
		FileSystem.on( 'rename', function( event, oldName, newName ) {
			var todoPath = Paths.todoFile();
			
			// Reload settings if .todo of current project was updated.
			if ( newName === todoPath || oldName === todoPath ) {
				SettingsManager.loadSettings();
			} else {
				// Move visibility state to new file.
				SettingsManager.toggleFileVisible( newName, SettingsManager.fileVisible( oldName ) );
				SettingsManager.toggleFileVisible( oldName, false );
				
				// If not .todo, parse all files.
				run();
			}
		} );
コード例 #5
0
ファイル: main.js プロジェクト: Denisov21/brackets-todo
		FileSystem.on( 'change', function( event, file ) {
			// Bail if not a file or file is outside current project root.
			if ( !file.isFile || file.fullPath.indexOf( Paths.projectRoot() ) === -1 ) {
				return false;
			}
			
			// Reload settings if .todo of current project was updated.
			if ( file.fullPath === Paths.todoFile() ) {
				SettingsManager.loadSettings();
			} else {
				// Get document from path and parse.
				DocumentManager.getDocumentForPath( file.fullPath ).done( function( document ) {
					setTodos( ParseUtils.parseFile( document, todos ) );
				} );
			}
		} );
コード例 #6
0
ファイル: main.js プロジェクト: Denisov21/brackets-todo
			.on( 'click', '.indicator', function() {
				var todoFilePath = Paths.todoFile();
				
				// Check if there is a file with the name .todo.
				FileSystem.resolve( todoFilePath, function( error, entry ) {
					// Check if the todo file is present.
					if ( entry !== undefined ) {
						// Open .todo filein editor.
						CommandManager.execute( Commands.FILE_OPEN, { fullPath: todoFilePath } ).done( function() {
							// Set focus on editor.
							EditorManager.focusEditor();
						} );
					} else {
						// Show settings dialog.
						SettingsManager.showSettingsDialog();
					}
				} );
			} )
コード例 #7
0
	function handleButton( buttonId, callback ) {
		var todoPath = Paths.todoFile(),
			fileEntry = FileSystem.getFileForPath( todoPath ),
			validation = validateValues(),
			newSettings = getValues();
		
		// Close button if cancel was clicked.
		if ( buttonId === 'cancel' ) {
			dialog.close();
		}
		
		// Save preferences if OK button was clicked.
		if ( buttonId === 'ok' ) {
			// Check that values are valid.
			if ( validation.valid === true ) {
				// Send values to callback if one is supplied.
				if ( callback ) {
					callback( newSettings );
				}
				
				// Close dialog.
				dialog.close();
			} else {
				markInvalidFields( validation.invalidFields );
			}
		} else if ( buttonId === 'save-file' ) {
			// Check that values are valid.
			if ( validation.valid === true ) {
				// Write settings to .todo as JSON.
				FileUtils.writeText( fileEntry, JSON.stringify( newSettings, null, '\t' ), true ).done( function() {
					// Open newly created file.
					CommandManager.execute( Commands.FILE_OPEN, { fullPath: todoPath } ).done( function() {
						// Set focus on editor.
						EditorManager.focusEditor();
					} );
				} );
				
				// Close dialog.
				dialog.close();
			} else {
				markInvalidFields( validation.invalidFields );
			}
		}
	}
コード例 #8
0
          onClick: function () {
            var todoFilePath = Paths.todoFile();

            // Check if there is a file with the name .todo.
            FileSystem.resolve(todoFilePath, function (error, entry) {
              if (error) {
                console.log(error);
              }

              // Check if the .todo file is present.
              if (entry !== undefined) {
                // Open .todo file in editor.
                CommandManager.execute(Commands.FILE_OPEN, {fullPath: todoFilePath}).done(function () {
                  // Set focus on editor.
                  MainViewManager.focusActivePane();
                });
              } else {
                // Show settings dialog.
                SettingsManager.showSettingsDialog();
              }
            });
          }