From d52a8be40e22e09d773f5f06994e1f175134ba29 Mon Sep 17 00:00:00 2001 From: Dan Byler Date: Sat, 9 May 2015 12:08:14 +0700 Subject: [PATCH] Adding: Focus in New Window --- Focus in New Window.applescript | 71 ++++++++++++++++++++++++++++++++ FocusIcon.png | Bin 0 -> 1043 bytes README.markdown | 42 ++++++++++++++++++- 3 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 Focus in New Window.applescript create mode 100644 FocusIcon.png diff --git a/Focus in New Window.applescript b/Focus in New Window.applescript new file mode 100644 index 0000000..cad85ad --- /dev/null +++ b/Focus in New Window.applescript @@ -0,0 +1,71 @@ +(* + # DESCRIPTION # + + Inspired by OmniFocus 1 behavior, this script opens the selected task's (or tasks') + project(s) in a new window so you can jump from a context view into the project view + without losing place. + + # LICENSE # + + Copyright © 2015 Dan Byler (contact: dbyler@gmail.com) + Licensed under MIT License (http://www.opensource.org/licenses/mit-license.php) + (TL;DR: no warranty, do whatever you want with it.) + + # CHANGE HISTORY # + + 1.0 (2015-04-28) + - Initial release + + # INSTALLATION # + + 1. Copy script to OmniFocus script folder (OmniFocus -> Help -> Open Scripts Folder) + 2. (Optional) Update to use the icon in this repo + 3. Add script to the OmniFocus toolbar using View -> Customize Toolbar... + +*) + + +on main() + tell application "OmniFocus" + set myFocus to {} + -- get selection + tell content of front document window of front document + set validSelectedItemsList to value of (selected trees where class of its value is not item and class of its value is not folder) + set totalItems to count of validSelectedItemsList + if totalItems is 0 then + my notifyWithoutGrowl("No valid task(s) selected") + return + end if + repeat with validSelectedItem in validSelectedItemsList + validSelectedItem + if (containing project of validSelectedItem) is not missing value then + set end of myFocus to (containing project of validSelectedItem) + else if (assigned container of validSelectedItem) is not missing value then + set end of myFocus to (assigned container of validSelectedItem) + end if + end repeat + end tell + + -- no valid projects to focus on + if length of myFocus is 0 then + my notifyWithoutGrowl("No projects to focus") + return + end if + + -- make new window + tell default document + make new document window with properties {perspective name:"Projects"} + end tell + + -- set focus + tell front document window of front document + set focus to myFocus + end tell + end tell +end main + +on notifyWithoutGrowl(alertText) + tell application "OmniFocus" to display dialog alertText with icon 1 buttons {"OK"} default button "OK" +end notifyWithoutGrowl + +main() diff --git a/FocusIcon.png b/FocusIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..d5c5e0e17a8ef2f0d5b003af4cf7603aada7d974 GIT binary patch literal 1043 zcmV+u1nm2XP)z~E>1~F z$!v1}r`M+vhF4r=ca2|EH!DH~zP6m7h-@y+( zX!w+_Y!;P*rO5fgGdmeTO?2a5KcNQ(ltz_$Y0qGLz+G?;e6ouHl_n)lkV!SH`7gA0 z;BzMk*}?$)v$ec@Vq)S#xo87S>V*x!AutFNx_F@G z4to;34%)$6Y!ie5IYI_#Xvhej0lazN`~s_d#%VvR>w+Y6e8Yd79}cVu(tc-_{nFhR={qnwp`*_e$- zSk!Cox; z^IQ5UXQf^?X5$f7BoZkBWgLp9SudMn83v?rnkuH;H0q@{Z!{hyiI2lG`d+{SsWKji z%_c