rounded_corners.inc.js.tmp

来自「PHP 知识管理系统(基于树结构的知识管理系统), 英文原版的PHP源码。」· TMP 代码 · 共 1,115 行 · 第 1/4 页

TMP
1,115
字号
 /****************************************************************  *                                                              *  *  curvyCorners                                                *  *  ------------                                                *  *                                                              *  *  This script generates rounded corners for your divs.        *  *                                                              *  *  Version 1.2.9                                               *  *  Copyright (c) 2006 Cameron Cooke                            *  *  By: Cameron Cooke and Tim Hutchison.                        *  *                                                              *  *                                                              *  *  Website: http://www.curvycorners.net                        *  *  Email:   info@totalinfinity.com                             *  *  Forum:   http://www.curvycorners.net/forum/                 *  *                                                              *  *                                                              *  *  This library is free software; you can redistribute         *  *  it and/or modify it under the terms of the GNU              *  *  Lesser General Public License as published by the           *  *  Free Software Foundation; either version 2.1 of the         *  *  License, or (at your option) any later version.             *  *                                                              *  *  This library is distributed in the hope that it will        *  *  be useful, but WITHOUT ANY WARRANTY; without even the       *  *  implied warranty of MERCHANTABILITY or FITNESS FOR A        *  *  PARTICULAR PURPOSE. See the GNU Lesser General Public       *  *  License for more details.                                   *  *                                                              *  *  You should have received a copy of the GNU Lesser           *  *  General Public License along with this library;             *  *  Inc., 59 Temple Place, Suite 330, Boston,                   *  *  MA 02111-1307 USA                                           *  *                                                              *  ****************************************************************/  // Browser detection  var isIE     = navigator.userAgent.toLowerCase().indexOf("msie") > -1;  var isMoz    = document.implementation && document.implementation.createDocument;  var isSafari = ((navigator.userAgent.toLowerCase().indexOf('safari')!=-1)&&(navigator.userAgent.toLowerCase().indexOf('mac')!=-1))?true:false;  var masterCorners    = new Array();  /*  Usage:  newCornersObj = new curvyCorners(settingsObj, "classNameStr");  newCornersObj = new curvyCorners(settingsObj, divObj1[, divObj2[, divObj3[, . . . [, divObjN]]]]);  */  function curvyCorners()  {      // Check parameters      if(typeof(arguments[0]) != "object") throw newCurvyError("First parameter of curvyCorners() must be an object.");      if(typeof(arguments[1]) != "object" && typeof(arguments[1]) != "string") throw newCurvyError("Second parameter of curvyCorners() must be an object or a class name.");      // Get object(s)      if(typeof(arguments[1]) == "string")      {          // Get elements by class name          var startIndex = 0;          var boxCol = getElementsByClass(arguments[1]);      }      else      {          // Get objects          var startIndex = 1;          var boxCol = arguments;      }      // Create return collection/object      var curvyCornersCol = new Array();      // Create array of html elements that can have rounded corners      if(arguments[0].validTags)        var validElements = arguments[0].validTags;      else        var validElements = ["div"]; // Default      // Loop through each argument      for(var i = startIndex, j = boxCol.length; i < j; i++)      {          // Current element tag name          var currentTag = boxCol[i].tagName.toLowerCase();          if(inArray(validElements, currentTag) !== false)          {              curvyCornersCol[curvyCornersCol.length] = new curvyObject(arguments[0], boxCol[i]);          }      }      this.objects = curvyCornersCol;      // Applies the curvyCorners to all objects      this.applyCornersToAll = function()      {          for(var x = 0, k = this.objects.length; x < k; x++)          {              this.objects[x].applyCorners();          }      }  }  // curvyCorners object (can be called directly)  function curvyObject()  {      // Setup Globals      this.box              = arguments[1];      this.settings         = arguments[0];      this.topContainer     = null;      this.bottomContainer  = null;            this.contentDIV       = null;      // Get box formatting details      var boxHeight       = get_style(this.box, "height", "height");      var boxWidth        = get_style(this.box, "width", "width");      var borderWidth     = get_style(this.box, "borderTopWidth", "border-top-width");      var borderColour    = get_style(this.box, "borderTopColor", "border-top-color");      var boxColour       = get_style(this.box, "backgroundColor", "background-color");      var backgroundImage = get_style(this.box, "backgroundImage", "background-image");      var boxPosition     = get_style(this.box, "position", "position");      var boxPadding      = get_style(this.box, "paddingTop", "padding-top");      // Set formatting propertes      this.boxHeight       = parseInt(((boxHeight != "" && boxHeight != "auto" && boxHeight.indexOf("%") == -1)? boxHeight.substring(0, boxHeight.indexOf("px")) : this.box.scrollHeight));      this.boxWidth        = parseInt(((boxWidth != "" && boxWidth != "auto" && boxWidth.indexOf("%") == -1)? boxWidth.substring(0, boxWidth.indexOf("px")) : this.box.scrollWidth));      this.borderWidth     = parseInt(((borderWidth != "" && borderWidth.indexOf("px") !== -1)? borderWidth.slice(0, borderWidth.indexOf("px")) : 0));      this.boxColour       = format_colour(boxColour);      this.boxPadding      = parseInt(((boxPadding != "" && boxPadding.indexOf("px") !== -1)? boxPadding.slice(0, boxPadding.indexOf("px")) : 0));      this.borderColour    = format_colour(borderColour);      this.borderString    = this.borderWidth + "px" + " solid " + this.borderColour;      this.backgroundImage = ((backgroundImage != "none")? backgroundImage : "");      this.boxContent      = this.box.innerHTML;      // Make box relative if not already absolute and remove any padding      if(boxPosition != "absolute") this.box.style.position = "relative";      this.box.style.padding = "0px";      // If IE and height and width are not set, we need to set width so that we get positioning      if(isIE && boxWidth == "auto" && boxHeight == "auto") this.box.style.width = "100%";      // Resize box so that it stays to the orignal height      // Remove content if box is using autoPad      if(this.settings.autoPad == true && this.boxPadding > 0)        this.box.innerHTML = "";      /*      This method creates the corners and      applies them to the div element.      */      this.applyCorners = function()      {          /*          Create top and bottom containers.          These will be used as a parent for the corners and bars.          */          for(var t = 0; t < 2; t++)          {              switch(t)              {                  // Top                  case 0:                      // Only build top bar if a top corner is to be draw                      if(this.settings.tl || this.settings.tr)                      {                          var newMainContainer = document.createElement("DIV");                          newMainContainer.style.width    = "100%";                          newMainContainer.style.fontSize = "1px";                          newMainContainer.style.overflow = "hidden";                          newMainContainer.style.position = "absolute";                          newMainContainer.style.paddingLeft  = this.borderWidth + "px";                          newMainContainer.style.paddingRight = this.borderWidth + "px";                          var topMaxRadius = Math.max(this.settings.tl ? this.settings.tl.radius : 0, this.settings.tr ? this.settings.tr.radius : 0);                          newMainContainer.style.height = topMaxRadius + "px";                          newMainContainer.style.top    = 0 - topMaxRadius + "px";                          newMainContainer.style.left   = 0 - this.borderWidth + "px";                          this.topContainer = this.box.appendChild(newMainContainer);                      }                      break;                  // Bottom                  case 1:                      // Only build bottom bar if a top corner is to be draw                      if(this.settings.bl || this.settings.br)                      {                          var newMainContainer = document.createElement("DIV");                          newMainContainer.style.width    = "100%";                          newMainContainer.style.fontSize = "1px";                          newMainContainer.style.overflow = "hidden";                          newMainContainer.style.position = "absolute";                          newMainContainer.style.paddingLeft  = this.borderWidth + "px";                          newMainContainer.style.paddingRight = this.borderWidth + "px";                          var botMaxRadius = Math.max(this.settings.bl ? this.settings.bl.radius : 0, this.settings.br ? this.settings.br.radius : 0);                          newMainContainer.style.height  = botMaxRadius + "px";                          newMainContainer.style.bottom  =  0 - botMaxRadius + "px";                          newMainContainer.style.left    =  0 - this.borderWidth + "px";                          this.bottomContainer = this.box.appendChild(newMainContainer);                      }                      break;              }          }          // Turn off current borders          if(this.topContainer) this.box.style.borderTopWidth = "0px";          if(this.bottomContainer) this.box.style.borderBottomWidth = "0px";          // Create array of available corners          var corners = ["tr", "tl", "br", "bl"];          /*          Loop for each corner          */          for(var i in corners)          {                            // FIX for prototype lib              if(i > -1 < 4)              {                                // Get current corner type from array                  var cc = corners[i];                  myobj = cc;                 // alert(myobj + ' ' + cc + ' ' + i);                  // Has the user requested the currentCorner be round?                  if(!this.settings[cc])                  {                      // No                      if(((cc == "tr" || cc == "tl") && this.topContainer != null) || ((cc == "br" || cc == "bl") && this.bottomContainer != null))                      {                          // We need to create a filler div to fill the space upto the next horzontal corner.                          var newCorner = document.createElement("DIV");                          // Setup corners properties                          newCorner.style.position = "relative";                          newCorner.style.fontSize = "1px";                          newCorner.style.overflow = "hidden";                          // Add background image?                          if(this.backgroundImage == "")                            newCorner.style.backgroundColor = this.boxColour;                          else                            newCorner.style.backgroundImage = this.backgroundImage;                          switch(cc)                          {                              case "tl":                                  newCorner.style.height      = topMaxRadius - this.borderWidth + "px";                                  newCorner.style.marginRight = this.settings.tr.radius - (this.borderWidth*2) + "px";                                  newCorner.style.borderLeft  = this.borderString;                                  newCorner.style.borderTop   = this.borderString;                                  newCorner.style.left        = -this.borderWidth + "px";                                  break;                              case "tr":                                  newCorner.style.height      = topMaxRadius - this.borderWidth + "px";                                  newCorner.style.marginLeft  = this.settings.tl.radius - (this.borderWidth*2) + "px";                                  newCorner.style.borderRight = this.borderString;                                  newCorner.style.borderTop   = this.borderString;                                  newCorner.style.backgroundPosition  = "-" + (topMaxRadius + this.borderWidth) + "px 0px";                                  newCorner.style.left        = this.borderWidth + "px";                                  break;                              case "bl":                                  newCorner.style.height       = botMaxRadius - this.borderWidth + "px";                                  newCorner.style.marginRight  = this.settings.br.radius - (this.borderWidth*2) + "px";                                  newCorner.style.borderLeft   = this.borderString;                                  newCorner.style.borderBottom = this.borderString;                                  newCorner.style.left         = -this.borderWidth + "px";                                  newCorner.style.backgroundPosition = "-" + (this.borderWidth) + "px -" + (this.boxHeight + (botMaxRadius + this.borderWidth)) + "px";                                  break;                              case "br":                                  newCorner.style.height       = botMaxRadius - this.borderWidth + "px";                                  newCorner.style.marginLeft   = this.settings.bl.radius - (this.borderWidth*2) + "px";

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?