spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / javascript / column95


Print Templates, Part VI: Interactive Margin Settings

Vice President of Risk Technology - READY TO HIRE! (NYC)
Next Step Systems
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs


The onmouseup Event Handler

The MouseUpHandler() handles the mouseup event. The mouseup event completes the marker move transaction. The transaction is initiated upon a mousedown event, continues while the mouse moves (while being pressed), and completes on a mouseup event.

The function first checks that indeed one of the page elements triggered the event. It returns if the event source is null:

if (!sSrcID) return;

Then, it computes again the pixels-per-inch ratio:

iPixelToInchRatio = ratiomarker.offsetLeft;

The function handles the different markers with a switch statement, switch(sSrcID). Let's take the left margin marker first. We do two basic operations. First, we set the templateprinter object's marginLeft property:

printer.marginLeft = 100 * (mmarkerLeft.offsetLeft -
  5)/iPixelToInchRatio;

The second operation hides the tool tip:

oPopup.hide();

Here is the complete listing of the switch() statement:

switch (sSrcID) {
  case "mmarkerLeft":
    printer.marginLeft = 100 * (mmarkerLeft.offsetLeft -
      5)/iPixelToInchRatio;
    oPopup.hide();
    break;

  case "mmarkerRight":
    printer.marginRight = printer.pageWidth - (100 *
      (mmarkerRight.offsetLeft - 5)/iPixelToInchRatio);
    oPopup.hide();
    break;

  case "mmarkerTop":
    printer.marginTop = 100 * (mmarkerTop.offsetTop -
      5)/iPixelToInchRatio;
    oPopup.hide();
    break;

  case "mmarkerBottom":
    printer.marginBottom = printer.pageHeight - (100 *
      (mmarkerBottom.offsetTop - 5)/iPixelToInchRatio);
    oPopup.hide();
    break;
}

Once the margin is updated, we need to re-initialize the markers, reset iDeltaX and iDelatY, reset the move flags, and reset the source element ID to null:

InitClasses();
InitMMarkers();
iDeltaX = 0;
iDeltaY = 0;
bMoveMMarkerLeft = false;
bMoveMMarkerRight = false;
bMoveMMarkerTop = false;
bMoveMMarkerBottom = false;

sSrcID = null;

Next: How to show and hide the margin dashed lines


http://www.internet.com

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint


Produced by Yehuda Shiran and Tomer Shiran
All Rights Reserved. Legal Notices.
Created: November 22, 2001
Revised: November 22, 2001

URL: http://www.webreference.com/js/column95/6.html