/*

-----------------------------------------------------

Project Fireworks

(c) 1999 Kleanthis Economou

ekleanthis@hotmail.com

website: http://projectfireworks.cjb.net

-----------------------------------------------------

         Make Guides From Selection v.1.0

-----------------------------------------------------

*/

if ( fw.selection != null && fw.selection.length > 0) {

 

 

         // Get the selection Size

         var selectBounds = fw.getDocumentDOM().getSelectionBounds();

         var selectLeft = selectBounds.left;

         var selectTop = selectBounds.top;

         var selectRight = selectBounds.right;

         var selectBottom = selectBounds.bottom;

 

         //Get the guide(s) that the user wants

         var myGuides = prompt("Make guides from selection:\nFormat: (L)eft, (R)ight, (T)op, (B)ottom, (A)ll\nTo combine, seperate with comma e.g: L,R,T","A");

         // I assume that All would be the most common, so made it default

 

         var arGuides = myGuides.split(",",3); // Max num should be 3 for obvious reasons

         for ( i = 0; i < arGuides.length; i++ ) {

                  var makeGuide = arGuides[i].toUpperCase(); // So we don't worry how they typed it

                  makeGuide = makeGuide.replace (" ", ""); // In case they add space after comma

                  switch (makeGuide) {

                       case "L":

                                fw.getDocumentDOM().addGuide(selectLeft, "vertical");

                                break;

 

 

                       case "R":

                                fw.getDocumentDOM().addGuide(selectRight, "vertical");

                                break;

 

                       case "T":

                                fw.getDocumentDOM().addGuide(selectTop, "horizontal");

                                break;

 

 

                       case "B":

                                fw.getDocumentDOM().addGuide(selectBottom, "horizontal");

                                break;

 

                       case "A":

                                fw.getDocumentDOM().addGuide(selectLeft, "vertical");

                                fw.getDocumentDOM().addGuide(selectRight, "vertical");

                                fw.getDocumentDOM().addGuide(selectTop, "horizontal");

                                fw.getDocumentDOM().addGuide(selectBottom, "horizontal");

                                break;

                       default:

                                // Typo ?!?

                  }

         }

}

else {

         alert("No selection was made. Try agaian...");

}

 

กก