Guest User

Untitled

a guest
Dec 18th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. /*
  2.  
  3. File: Buttons.js
  4.  
  5. Abstract: Abstract button creation for Birthdays
  6. example widget.
  7.  
  8. Version: 1.2
  9.  
  10.  
  11. Disclaimer: IMPORTANT: This Apple software is supplied to you by
  12. Apple Inc. ("Apple") in consideration of your agreement to the
  13. following terms, and your use, installation, modification or
  14. redistribution of this Apple software constitutes acceptance of these
  15. terms. If you do not agree with these terms, please do not use,
  16. install, modify or redistribute this Apple software.
  17.  
  18. In consideration of your agreement to abide by the following terms, and
  19. subject to these terms, Apple grants you a personal, non-exclusive
  20. license, under Apple's copyrights in this original Apple software (the
  21. "Apple Software"), to use, reproduce, modify and redistribute the Apple
  22. Software, with or without modifications, in source and/or binary forms;
  23. provided that if you redistribute the Apple Software in its entirety and
  24. without modifications, you must retain this notice and the following
  25. text and disclaimers in all such redistributions of the Apple Software.
  26. Neither the name, trademarks, service marks or logos of Apple Inc.
  27. may be used to endorse or promote products derived from the Apple
  28. Software without specific prior written permission from Apple. Except
  29. as expressly stated in this notice, no other rights or licenses, express
  30. or implied, are granted by Apple herein, including but not limited to
  31. any patent rights that may be infringed by your derivative works or by
  32. other works in which the Apple Software may be incorporated.
  33.  
  34. The Apple Software is provided by Apple on an "AS IS" basis. APPLE
  35. MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
  36. THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
  37. FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
  38. OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
  39.  
  40. IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
  41. OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  42. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  43. INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
  44. MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
  45. AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
  46. STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
  47. POSSIBILITY OF SUCH DAMAGE.
  48.  
  49. Copyright (C) 2010-2006 Apple Inc. All Rights Reserved.
  50.  
  51. */
  52.  
  53. var BUTTON_IMAGE_DIR = "Images/button/";
  54. var LEFT = "left.png";
  55. var LEFT_PRS = "left_press.png";
  56. var MID = BUTTON_IMAGE_DIR + "mid.png";
  57. var MID_PRS = BUTTON_IMAGE_DIR + "mid_press.png";
  58. var RIGHT = "right.png";
  59. var RIGHT_PRS = "right_press.png";
  60.  
  61. var ROUND_END_WIDTH = 5;
  62. var FLAT_END_WIDTH = 2;
  63. var HEIGHT = 20;
  64.  
  65. // Build our control buttons using the AppleButton class and bundled image files
  66. function CreateButton(buttonID, text, buttonStyle, onclick) {
  67. var buttonElement = document.getElementById(buttonID);
  68.  
  69. if (!buttonElement.loaded) {
  70. buttonElement.loaded = true;
  71.  
  72. var lImgWidth = FLAT_END_WIDTH;
  73. var rImgWidth = FLAT_END_WIDTH;
  74. if (buttonStyle == "leftEnd") {
  75. lImgWidth = ROUND_END_WIDTH;
  76. } else if (buttonStyle == "rightEnd") {
  77. rImgWidth = ROUND_END_WIDTH;
  78. }
  79.  
  80. var imgPrefix = BUTTON_IMAGE_DIR + buttonStyle + "_";
  81. buttonElement.object = new AppleButton(buttonElement, text, HEIGHT, imgPrefix + LEFT, imgPrefix + LEFT_PRS, lImgWidth, MID, MID_PRS, imgPrefix + RIGHT, imgPrefix + RIGHT_PRS, rImgWidth, onclick);
  82. // extra padding so the button does not hug the text
  83. buttonElement.object.textElement.style.width = (parseInt(document.defaultView.getComputedStyle(buttonElement, null).getPropertyValue("width"), 10) - (lImgWidth + rImgWidth)) + "px";
  84. }
  85.  
  86. return buttonElement.object;
Add Comment
Please, Sign In to add comment