forked from adobe/brackets
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Darpan Pradhan
authored and
Darpan Pradhan
committed
Jan 3, 2013
1 parent
2e06e51
commit 9a30fb2
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/*jslint vars: true, plusplus: true, devel: true, nomen: true, regexp: true, indent: 4, maxerr: 50 */ | ||
/*global define, $, brackets, window */ | ||
|
||
define(function (require, exports, module) { | ||
"use strict"; | ||
|
||
var CommandManager = brackets.getModule("command/CommandManager"), | ||
Menus = brackets.getModule("command/Menus"), | ||
EditorManager = brackets.getModule("editor/EditorManager"), | ||
DocumentManager = brackets.getModule("document/DocumentManager"), | ||
DocumentCommandHandlers = brackets.getModule("document/DocumentCommandHandlers"); | ||
|
||
var WORD_WRAP_COMMAND_ID = "view.wordwrap"; | ||
|
||
function checkUncheckWordWrapMenu() { | ||
var wordWrapRef = CommandManager.get(WORD_WRAP_COMMAND_ID); | ||
if (!wordWrapRef) { | ||
return; | ||
} | ||
var toggleCheck = !wordWrapRef.getChecked(); | ||
wordWrapRef.setChecked(toggleCheck); | ||
|
||
return toggleCheck; | ||
} | ||
|
||
function handleWordWrap() { | ||
var isChecked = checkUncheckWordWrapMenu(); | ||
|
||
var listOfOpenDocuments = DocumentManager.getAllOpenDocuments(); | ||
DocumentManager.closeAll(); | ||
EditorManager.setWordWrapForEditor(isChecked); | ||
|
||
var doc; | ||
for (doc in listOfOpenDocuments) { | ||
if (listOfOpenDocuments.hasOwnProperty(doc)) { | ||
DocumentCommandHandlers.doOpen(listOfOpenDocuments[doc].file.fullPath); | ||
DocumentManager.addToWorkingSet(listOfOpenDocuments[doc].file); | ||
} | ||
} | ||
} | ||
|
||
CommandManager.register("Word Wrap", WORD_WRAP_COMMAND_ID, handleWordWrap); | ||
|
||
var menu = Menus.getMenu(Menus.AppMenuBar.VIEW_MENU); | ||
menu.addMenuDivider(); | ||
menu.addMenuItem(WORD_WRAP_COMMAND_ID); | ||
}); |