Skip to content

Commit

Permalink
- removed htmlContentLoad.js module. Functionality moved to brackets.js
Browse files Browse the repository at this point in the history
- modified SidebarView.js and ProjectManager.js to init DOM dependant variables after htmlContentLoadComplete event
  • Loading branch information
tvoliter committed Aug 14, 2012
1 parent a5440c2 commit 71c97d6
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 86 deletions.
15 changes: 8 additions & 7 deletions src/brackets.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/*global require, define, brackets: true, $, PathUtils, window, navigator */
/*global require, define, brackets: true, $, PathUtils, window, navigator, Mustache */

require.config({
paths: {
Expand Down Expand Up @@ -57,12 +57,6 @@ define(function (require, exports, module) {
require("thirdparty/path-utils/path-utils.min");
require("thirdparty/smart-auto-complete/jquery.smart_autocomplete");

// Load HTML Content
// The htmlContentLoad module renders all of html in Bracktes.
// If a module depends on the DOM being fulling formed before it is loaded
// then the module should listen for the event "htmlContentLoadComplete"
require("htmlContent/htmlContentLoad");

// Load LiveDeveopment
require("LiveDevelopment/main");

Expand All @@ -87,6 +81,7 @@ define(function (require, exports, module) {
QuickOpen = require("search/QuickOpen"),
Menus = require("command/Menus"),
FileUtils = require("file/FileUtils"),
MainViewHTML = require("text!htmlContent/main-view.html"),
Strings = require("strings"),
Dialogs = require("widgets/Dialogs"),
ExtensionLoader = require("utils/ExtensionLoader"),
Expand Down Expand Up @@ -346,7 +341,13 @@ define(function (require, exports, module) {

// Main Brackets initialization
_initGlobalBrackets();

// Localize MainViewHTML and inject into <BODY> tag
$('body').html(Mustache.render(MainViewHTML, Strings));
// modules that depend on the HTML DOM should listen to
// the htmlContentLoadComplete event.
$(brackets).trigger("htmlContentLoadComplete");

$(window.document).ready(_onReady);

});
37 changes: 0 additions & 37 deletions src/htmlContent/htmlContentLoad.js

This file was deleted.

4 changes: 2 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
</head>
<body>

<!-- HTML content is dynamically loaded and rendered by the htmlContentLoad
module. Any modules that depend on or modify HTML during load should
<!-- HTML content is dynamically loaded and rendered by bracket.js.
Any modules that depend on or modify HTML during load should
listen for the "htmlContentLoadComplete" event that is triggered from
the brackets global object before touching the dom. -->

Expand Down
47 changes: 26 additions & 21 deletions src/project/ProjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,11 @@ define(function (require, exports, module) {

/**
* @private
* Reference to the tree control container div
* Reference to the tree control container div. Initialized by
* htmlContentLoadComplete handler
* @type {jQueryObject}
*/
var $projectTreeContainer = $("#project-files-container");
var $projectTreeContainer;

/**
* @private
Expand Down Expand Up @@ -927,6 +928,29 @@ define(function (require, exports, module) {
$(".jstree-rename-input").blur();
}


// Initialize variables and listeners that depend on the HTML DOM
$(brackets).on("htmlContentLoadComplete", function () {
$projectTreeContainer = $("#project-files-container");

$("#open-files-container").on("contentChanged", function () {
_redraw(false); // redraw jstree when working set size changes
});
});

// Init PreferenceStorage
var defaults = {
projectPath: _getDefaultProjectPath() /* initialize to brackets source */
};
_prefs = PreferencesManager.getPreferenceStorage(PREFERENCES_CLIENT_ID, defaults);

// Event Handlers
$(FileViewController).on("documentSelectionFocusChange", _documentSelectionFocusChange);
$(FileViewController).on("fileViewFocusChange", _fileViewFocusChange);

// Commands
CommandManager.register(Strings.CMD_OPEN_FOLDER, Commands.FILE_OPEN_FOLDER, openProject);

// Define public API
exports.getProjectRoot = getProjectRoot;
exports.isWithinProject = isWithinProject;
Expand All @@ -937,23 +961,4 @@ define(function (require, exports, module) {
exports.getInitialProjectPath = getInitialProjectPath;
exports.createNewItem = createNewItem;
exports.forceFinishRename = forceFinishRename;

// Initialize now
(function () {
var defaults = {
projectPath: _getDefaultProjectPath() /* initialize to brackets source */
};

// Init PreferenceStorage
_prefs = PreferencesManager.getPreferenceStorage(PREFERENCES_CLIENT_ID, defaults);

// Event Handlers
$(FileViewController).on("documentSelectionFocusChange", _documentSelectionFocusChange);
$(FileViewController).on("fileViewFocusChange", _fileViewFocusChange);
$("#open-files-container").on("contentChanged", function () {
_redraw(false); // redraw jstree when working set size changes
});

CommandManager.register(Strings.CMD_OPEN_FOLDER, Commands.FILE_OPEN_FOLDER, openProject);
}());
});
34 changes: 15 additions & 19 deletions src/project/SidebarView.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
/*global define, $, document, window */
/*global define, $, document, window, brackets */

define(function (require, exports, module) {
"use strict";
Expand All @@ -48,24 +48,7 @@ define(function (require, exports, module) {
$sidebarResizer,
$openFilesContainer,
$projectTitle,
$projectFilesContainer,
isSidebarClosed;

// Init sidebar resizer and setup working set view after the DOM
// is initialized
$(brackets).on("htmlContentLoadComplete", function () {
$sidebar = $("#sidebar");
$sidebarMenuText = $("#menu-view-hide-sidebar span");
$sidebarResizer = $("#sidebar-resizer");
$openFilesContainer = $("#open-files-container");
$projectTitle = $("#project-title");
$projectFilesContainer = $("#project-files-container");

// init
WorkingSetView.create($openFilesContainer);
_initSidebarResizer();
});

$projectFilesContainer;

/**
* @private
Expand Down Expand Up @@ -248,10 +231,23 @@ define(function (require, exports, module) {
});
}

// Initialize items dependent on HTML DOM
$(brackets).on("htmlContentLoadComplete", function () {
$sidebar = $("#sidebar");
$sidebarMenuText = $("#menu-view-hide-sidebar span");
$sidebarResizer = $("#sidebar-resizer");
$openFilesContainer = $("#open-files-container");
$projectTitle = $("#project-title");
$projectFilesContainer = $("#project-files-container");

// init
WorkingSetView.create($openFilesContainer);
_initSidebarResizer();
});

$(ProjectManager).on("projectOpen", _updateProjectTitle);
CommandManager.register(Strings.CMD_HIDE_SIDEBAR, Commands.VIEW_HIDE_SIDEBAR, toggleSidebar);

// Define public API
exports.toggleSidebar = toggleSidebar;
});

0 comments on commit 71c97d6

Please sign in to comment.