Ejemplo n.º 1
0
    Async.doInParallel(singleFile || files, readFile).always(function () {
      // Remove all files that do not have todos.
      files = files.filter(function (file) {
        return file.todos && file.todos.length > 0;
      });

      // Sort file by path.
      files = files.sort(function (a, b) {
        var nameA = a.name.toLowerCase();
        var nameB = b.name.toLowerCase();

        if (nameA < nameB) {
          return -1;
        }

        if (nameA > nameB) {
          return 1;
        }

        return 0;
      });

      // Count used tags.
      count();

      // Parsing is done. Publish event.
      Events.publish('todos:updated');
    });
			nodeConnection.loadDomains( [ path ], true ).done( function() {
				// Set initialization status.
				initialized = true;
				
				// Publish event.
				Events.publish( 'node:connected' );
			} );
Ejemplo n.º 3
0
  /**
   * Set all files to expanded state.
   */
  function expand () {
    // Expand all files.
    files.forEach(function (file) {
      file.expanded = true;
    });

    // Update list of comments.
    Events.publish('todos:updated');
  }
Ejemplo n.º 4
0
	function saveHidden( hidden ) {
		// Save in session.
		hiddenTags = hidden;
		
		// Save in persitent storage.
		localStorage.setItem( 'hiddenTags', JSON.stringify( hidden ) );
		
		// Trigger event for changed visibility.
		Events.publish( 'tags:visible', [ hidden ] );
	}
Ejemplo n.º 5
0
  /**
   * Remove file of path from array.
   *
   * @param path
   */
  function deletePath (path) {
    var index = getFileIndex(path);

    // Remove from array if file contained todos.
    if (index > -1) {
      files.splice(index, 1);

      // Update list of comments.
      Events.publish('todos:updated');
    }
  }
Ejemplo n.º 6
0
  /**
   * Update file of path from array.
   *
   * @param path
   */
  function updatePath (path) {
    var index = getFileIndex(path);

    // Update file.
    if (index > -1) {
      read([files[index]]);

      // Update list of comments.
      Events.publish('todos:updated');
    }
  }
Ejemplo n.º 7
0
			.on( 'click', '.tags a', function() {
				// Show or hide clicked tag.
				var $this = $( this )
					.toggleClass( 'visible' );
				
				// Toggle tag visibility.
				SettingsManager.toggleTagVisible( $this.data( 'name' ), $this.hasClass( 'visible' ) );
				
				// Update list of comments.
				Events.publish( 'todos:updated' );
			} );
Ejemplo n.º 8
0
  /**
   * Toggle visibility of tag.
   *
   * @param key
   */
  function toggle (key) {
    // Get tag from array.
    var tag = _.find(tags, function (tag) {
      return tag.key === key;
    });

    tag.visible = !tag.visible;

    // Update list of comments.
    Events.publish('todos:updated');
  }
Ejemplo n.º 9
0
			.on( 'click', '.tags a', function() {
				// Show or hide clicked tag.
				var $this = $( this )
					.toggleClass( 'visible' );
				
				// Save names of hidden tags.
				Tags.saveHidden( $.makeArray( $this.parent().children().not( '.visible' ).map( function() {
					return $( this ).data( 'name' );
				} ) ) );
				
				// Update list of comments.
				Events.publish( 'todos:updated' );
			} );
Ejemplo n.º 10
0
  /**
   * Toggle expanded state of file.
   *
   * @param key
   */
  function toggle (key) {
    var file = _.find(files, function (file) {
      return file.key === key;
    });

    // Toggle expanded state if file was found in array.
    if (file) {
      file.expanded = file.autoopened ? false : !file.expanded;
      file.autoopened = false;
    }

    // Update list of comments.
    Events.publish('todos:updated');
  }
Ejemplo n.º 11
0
		loadTodoFile( function( fileSettings ) {
			// Merge base settings with settings from file.
			settings = mergeSettings( baseSettings, fileSettings );
			
			// Build array of tags.
			Tags.init( settings.tags, preferences );
			
			// Initialize files.
			Files.init( settings.search.scope );
			
			// Build regular expression.
			setupRegExp();
			
			// Publish event.
			Events.publish( 'settings:changed', [ settings ] );
			
			// Trigger callback.
			if ( callback ) {
				callback();
			}
			
			// Publish event.
			Events.publish( 'settings:loaded', [ settings ] );
		} );
Ejemplo n.º 12
0
		} ).always( function() {
			// Merge default settings with JSON.
			SettingsManager.mergeSettings( userSettings );
			
			// Show or hide .todo indicator.
			if ( todoFile ) {
				$todoPanel.addClass( 'todo-file' );
			} else {
				$todoPanel.removeClass( 'todo-file' );
			}
			
			// Build array of tags and save to preferences.
			visibleTags = initTags();
			preferences.setValue( 'visibleTags', visibleTags );
			
			// Trigger callback.
			if ( callback ) { callback(); }
			
			// Publish event.
			Events.publish( 'settings:loaded' );
		} );
Ejemplo n.º 13
0
  MainViewManager.on('currentFileChange.todo', function (event, file) {
    var settings = Settings.get();

    // Bail if no file is open or if settings are not loaded.
    if (file === null || settings.search === undefined) {
      return false;
    }

    // Only one file when current scope, refresh it.
    if (settings.search.scope === 'current') {
      refresh();
    } else {
      var path = file.fullPath;

      // Expand the opened file if in array.
      files.forEach(function (file) {
        file.autoopened = file.path === path;
      });

      // Update list of comments.
      Events.publish('todos:updated');
    }
  });
Ejemplo n.º 14
0
 function updateTrelloComments(comments) {
     newestComments = comments;
     Events.publish('comments:updated');
 }
Ejemplo n.º 15
0
	/**
	 * Store array of todos.
	 */
	function setTodos( todoArray ) {
		todos = todoArray;
		
		// Publish event.
		Events.publish( 'todos:updated' );
	}