Sfoglia il codice sorgente

NEW v.2 full ipad support + new zoom feature + hw scroll

Changelog nicescroll release 2.0.0

New features
- full support for mobile devices as iPad, iPhone, Android
- new zoom feature (desktop & mobile)
- hardware accelerated scroll
- touchbehavior flag
- support for "scrollable wrapper" (div in div)

Changed features
- cursor size changed to 5 pixels
- z-index for scrollbar lowered to 9000
- mobile device use native scrollbar for window (main page)

Fixes
- some fixes for IE6
- some fixes for Chrome/Safari
- fixing cursor scrolling/hiding functions
Inuyaksa 13 anni fa
parent
commit
824cead7f7
10 ha cambiato i file con 753 aggiunte e 692 eliminazioni
  1. 35 9
      README
  2. 19 0
      changelog_2.0.0.txt
  3. 129 0
      demo/index.html
  4. 0 406
      demo/js/jquery.nicescroll.js
  5. 37 0
      demo/js/jquery.nicescroll.min.js
  6. BIN
      demo/js/zoomico.png
  7. 0 110
      demo/test1.html
  8. 496 167
      jquery.nicescroll.js
  9. 37 0
      jquery.nicescroll.min.js
  10. BIN
      zoomico.png

+ 35 - 9
README

@@ -1,37 +1,48 @@
 jquery.nicescroll
-v. 1.5.1 10-30-2011
+v. 2.0.0 11-03-2011
 copyright 2011 InuYaksa*2011
 licensed under the MIT
+http://areaaperta.com/nicescroll
 https://github.com/inuyaksa/jquery.nicescroll
 
 
 Nicescroll (as nice scroll for browsers) is a jquery (since 1.5) plugin, for nice scrollbars with a very similar ios/mobile style.
 It supports DIVs, IFrames and document page (body) scrollbars.
 Compatible with Firefox 4+, Chrome 5+, Safari 4+ (win/mac), Opera 10+, IE 6+. (all A-grade browsers)
+Compatible with iOS devices as iPad. So you have scrollable divs for iPad.
+
+Sexy zoom feature, you can "zoom-in" the content of any nicescroll'ed div. Nice to use and nice to see, all the content of the div in fullscreen mode. It works on desktop (double click on div) either in mobile/touch devices using pitch gesture.
+
+On modern browsers hardware accelerated scrolling has implemented.
 
 Only vertical scrollbars supported in this version.
 
-Warning for IE6 users (who uses IE6 yet? Please updgrade to a more stable and modern browser), some feature can't work for limitation of the browser.
-Document (body) scrollbars can't appears, old (native browser) one is used.
-Some issues with IFrame scrolling.
+Warning for IE6 users (who uses IE6 yet? Please updgrade to a more stable and modern browser), some feature can't work for limitation of the browser. Document (body) scrollbars can't appears, old (native browser) one is used. Some issues with IFrame scrolling.
 
 
 * FEATURES
 
 - simple installation and activation, it works with NO modification of your code. (some exceptions can happen, so you can write to me)
 - very stylish scrollbars, with no occupation on your window (original browser scrollbars need some of page space and reduces window/div usable width)
-- you can stile main document scrollbar (body) too!! (not all script implements this feature)
+- you can style main document scrollbar (body) too!! (not all script implements this feature)
 - on all browsers you can scroll: dragging the cursor, mouse wheel (speed customizable), keyboard navigation (cursor keys, pagup/down keys, home/end keys)
 - scroll is smooth (as modern tablet browsing), speed is customizable
-- tested for all major browsers but with extended support, including IE6, Safari on Mac and IE10 preview!
+- zoom feature
+- hardware accelerated scroll (when available)
+- tested for all major browsers desktop and mobile versiones
+- support for touch devices
+- compatible with many other browsers, including IE6, Safari on Mac and IE10 preview!
+- very customizable aspect of bar
+- native scroll events are working yet
 
 
 * DEPENDENCIES
-It uses jquery framework, since 1.5.x version. (you can try with 1.4.x)
+It's a plugin for the jquery framework, you need to include jquery in your scripts.
+From 1.5.x version and on. (you can try with 1.4.x also)
 
 
 * INSTALLATION
-Put loading script tag after jquery script tag:
+Put loading script tag after jquery script tag and loading the zoom image in the same folder of the script:
 
 <script src="jquery.nicescroll.js"></script>
 
@@ -65,6 +76,13 @@ $(document).ready(
   }
 );
 
+4. DIV with "wrapper", formed by two divs, the first is the vieport, the latter is the content:
+$(document).ready(
+  function() {
+    $("#viewportdiv").niceScroll("#wrapperdiv",{cursorcolor:"#00F"});
+  }
+);
+
 
 * CONFIGURATION PARAMETERS
 
@@ -73,13 +91,21 @@ When you call "niceScroll" you can pass some parameters to custom visual aspects
 . cursorcolor - change cursor color in hex, default is "#000000"
 . cursoropacitymin - change opacity very cursor is inactive (scrollabar "hidden" state), range from 1 to 0, default is 0 (hidden)
 . cursoropacitymax - change opacity very cursor is active (scrollabar "visible" state), range from 1 to 0, default is 1 (full opacity)
+. cursorwidth - cursor width in pixel, default is 5 (you can write "5px" too)
+. cursorborder - css definition for cursor border, default is "1px solid #fff"
+. cursorborderradius - border radius in pixel for cursor, default is "4px"
 . zindex - change z-index for scrollbar div, default value is 9999
 . scrollspeed - scrolling speed, default value is 60
 . mousescrollstep - scrolling speed with mouse wheel, default value is 48 (pixel)
+. touchbehavior - enable cursor-drag scrolling like touch devices in desktop computer, default is false
+. hwacceleration - use hardware accelerated scroll when supported, default is true
+. boxzoom - enable zoom for box content, default is false
+. dblclickzoom - (only when boxzoom=true) zoom activated when double click on box, default is true
+. gesturezoom - (only when boxzoom=true and with touch devices) zoom activated when pitch out/in on box, default is true
 
 
 * LICENSE
 
 Copyright 2011*InuYaksa
 Licensed under the MIT License, http://www.opensource.org/licenses/mit-license.php
-
+Images used for zoom icons have derived from OLPC interface, http://laptop.org/8.2.0/manual/Browse_ChangingView.html

+ 19 - 0
changelog_2.0.0.txt

@@ -0,0 +1,19 @@
+Changelog nicescroll release 2.0.0
+https://github.com/inuyaksa/jquery.nicescroll
+
+New features
+- full support for mobile devices as iPad, iPhone, Android
+- new zoom feature (desktop & mobile)
+- hardware accelerated scroll
+- touchbehavior flag
+- support for "scrollable wrapper" (div in div)
+
+Changed features
+- cursor size changed to 5 pixels
+- z-index for scrollbar lowered to 9000
+- mobile device use native scrollbar for window (main page)
+
+Fixes
+- some fixes for IE6
+- some fixes for Chrome/Safari
+- fixing cursor scrolling/hiding functions

+ 129 - 0
demo/index.html

@@ -0,0 +1,129 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+<title>jQuery NiceScroll Test 2.0.0</title>
+<style type="text/css">
+#boxscroll {
+	padding: 40px;
+	height: 220px;
+	width: 300px;
+	border: 2px solid #00F;
+	overflow: auto;
+  margin-bottom:20px;
+}
+#boxscroll2 {
+	padding: 40px;
+	height: 120px;
+	width: 500px;
+	border: 2px solid #F00;
+	overflow: auto;
+  position: relative;
+}
+#boxscroll3 {
+	overflow: hidden;
+}
+#boxframe {
+  position:absolute;
+  top:8px;
+  left:420px;
+  width:400px;
+  height:300px;
+  overflow:auto;
+	border: 2px solid #0F0;
+}
+</style>
+
+<script src="js/jquery.min.js"></script>
+<script src="js/jquery.nicescroll.min.js"></script>
+<script>
+//  document.addEventListener('touchmove',function(e){e.preventDefault();},false); // for touch devices
+</script>
+
+<script>
+  $(document).ready(function() {
+  $("body").niceScroll();  // The document page (body)
+    
+  $("#boxscroll").niceScroll({cursorborder:"",cursorcolor:"#00F",boxzoom:true}); // First scrollable DIV
+    
+//    $("#boxscroll").niceScroll({touchbehavior:false,cursorcolor:"#00F",cursoropacitymax:0.7,cursorwidth:11,cursorborder:"1px solid #2848BE",cursorborderradius:"8px"}).cursor.css({"background-image":"url(img/mac6scroll.png)"}); // MAC like scrollbar
+
+    $("#boxscroll2").niceScroll("#contentscroll2",{cursorcolor:"#F00",cursoropacitymax:0.7,boxzoom:true});  // Second scrollable DIV
+    $("#boxframe").niceScroll("#boxscroll3",{cursorcolor:"#0F0",cursoropacitymax:0.7,boxzoom:true});  // This is an IFrame (iPad compatible)
+  });
+</script>
+
+<meta name="viewport" content="user-scalable=no" />
+
+</head>
+
+<body>
+<div id="boxscroll">
+  <h2> Package Description </h2>
+  <p>Release Date: August 10, 2010</p>
+  <p>The <a title="http://www.openprinting.org/show_driver.cgi?driver=hpijs" rel="nofollow" href="http://www.openprinting.org/show_driver.cgi?driver=hpijs">HPIJS</a> driver is the free, <a title="http://hplipopensource.com/hplip-web/index.html" rel="nofollow" href="http://hplipopensource.com/hplip-web/index.html">open-source driver</a> issued by HP for their DeskJet and LaserJet printers. For most <a title="" href="http://www.linuxfoundation.org/collaborate/workgroups/openprinting/macosx/hpijs#Printers">supported printers</a>,   this driver produces output quality equivalent to the proprietary HP   drivers. In photo mode, with photo paper, the output quality is very   high, especially for the HP DeskJet 990C and later models, which   auto-detect the paper type in hardware. Photo printing is fully   supported in the newer 6- and 7-ink models.</p>
+  <p>A major advantage of using this driver over those supplied by HP is   the direct interface between HPIJS and the native CUPS spooler, which   allows printing from any printer over any available connection such as   USB, AppleTalk, TCP/IP (via LPD and IPP), HP JetDirect, and shared   windows printers via SAMBA. Additionally, this driver utilizes the   existing Mac OS X USB &quot;backend&quot; and thus does not install any software   that might interfere with standard USB operation.</p>
+  <p>Please note:</p>
+  <ul>
+    <li>HP does not provide any support for HPLIP or HPIJS on the Mac OS X platform.</li>
+    <li><a href="http://www.linuxfoundation.org/en/OpenPrinting/MacOSX/hpijs-USB">Several HP USB devices</a> may not print successfully over the standard Mac OS X USB &quot;backend&quot;. Please <a href="http://www.linuxfoundation.org/en/OpenPrinting/MacOSX/hpijs-USB">see this note</a> for more information.</li>
+  </ul>
+  <h2>Release Notes</h2>
+  <ul>
+    <li>This release fixes a problem with the PPDs that caused many job   options such as page orientation, color/grayscale mode, duplex printing,   etc. to fail.</li>
+    <li>HPIJS is HP's universal printer driver for most of their   non-PostScript printers. It comes as a part of HPLIP, HP Linux Imaging   and Printing.</li>
+    <li>The PPDs for HP printers are now sourced from the HPLIP package rather than the OpenPrinting.org database.</li>
+    <li>PPDs for printers from other manufacturers are provided by OpenPrinting.org.</li>
+    <li>Some printers are only partially supported.  Printers such as<br />
+      HP LaserJet 1022<br />
+      HP LaserJet p1505n<br />
+      HP LaserJet p12014<br />
+      HP LaserJet p2035<br />
+      require a proprietary plug-in for full support.  This package does not contain or support such plug-ins.</li>
+  </ul>
+  <p><a name="Printer_Set_Up_Instructions" id="Printer_Set_Up_Instructions"></a></p>
+  <h2> Printer Set Up Instructions </h2>
+  <p>To add a printer queue, Leopard (Mac OS X 10.5.x) users should use   the Print &amp; Fax from System Preferences. Click on the + (plus) icon   at the lower left. A new window will open. In that window, click the   Default Browser icon at the top left. Highlight your printer in the   section below. Use the &quot;Print Using&quot; pop-up menu near the bottom of the   window to select the correct PPD for your printer and click Add.</p>
+  <p>Tiger users should open the Printer Setup Utility and click on the   Add icon at the top of the Printer List window. A new window will open.   In that window, click the Default Browser icon at the top left.   Highlight your printer in the section below. Use the &quot;Print Using&quot;   pop-up menu near the bottom of the window to select the correct PPD for   your printer and click Add.</p>
+  <p>Jaguar (OS X 10.2.x) and Panther (OS X 10.3.x) users should open   Print Center (Jaguar) or Printer Setup Utility (Panther), hold down the   Option key, and click the Add Printer button in the Print Center   toolbar. Within the setup sheet, choose Advanced from the top popup   menu; then in the &quot;Device:&quot; popup menu select your printer by name (it   should be the last item in the menu list). Finally, select the correct   PPD from the model browser and click Add.</p>
+</div>
+
+<div id="boxscroll2">
+  <div id="contentscroll2">
+    <h2> Package Description </h2>
+    <p>Release Date: August 10, 2010</p>
+    <p>The <a title="http://www.openprinting.org/show_driver.cgi?driver=hpijs" rel="nofollow" href="http://www.openprinting.org/show_driver.cgi?driver=hpijs">HPIJS</a> driver is the free, <a title="http://hplipopensource.com/hplip-web/index.html" rel="nofollow" href="http://hplipopensource.com/hplip-web/index.html">open-source driver</a> issued by HP for their DeskJet and LaserJet printers. For most <a title="" href="http://www.linuxfoundation.org/collaborate/workgroups/openprinting/macosx/hpijs#Printers">supported printers</a>,   this driver produces output quality equivalent to the proprietary HP   drivers. In photo mode, with photo paper, the output quality is very   high, especially for the HP DeskJet 990C and later models, which   auto-detect the paper type in hardware. Photo printing is fully   supported in the newer 6- and 7-ink models.</p>
+    <p>A major advantage of using this driver over those supplied by HP is   the direct interface between HPIJS and the native CUPS spooler, which   allows printing from any printer over any available connection such as   USB, AppleTalk, TCP/IP (via LPD and IPP), HP JetDirect, and shared   windows printers via SAMBA. Additionally, this driver utilizes the   existing Mac OS X USB &quot;backend&quot; and thus does not install any software   that might interfere with standard USB operation.</p>
+    <p>Please note:</p>
+    <ul>
+      <li>HP does not provide any support for HPLIP or HPIJS on the Mac OS X platform.</li>
+      <li><a href="http://www.linuxfoundation.org/en/OpenPrinting/MacOSX/hpijs-USB">Several HP USB devices</a> may not print successfully over the standard Mac OS X USB &quot;backend&quot;. Please <a href="http://www.linuxfoundation.org/en/OpenPrinting/MacOSX/hpijs-USB">see this note</a> for more information.</li>
+    </ul>
+    <h2>Release Notes</h2>
+    <ul>
+      <li>This release fixes a problem with the PPDs that caused many job   options such as page orientation, color/grayscale mode, duplex printing,   etc. to fail.</li>
+      <li>HPIJS is HP's universal printer driver for most of their   non-PostScript printers. It comes as a part of HPLIP, HP Linux Imaging   and Printing.</li>
+      <li>The PPDs for HP printers are now sourced from the HPLIP package rather than the OpenPrinting.org database.</li>
+      <li>PPDs for printers from other manufacturers are provided by OpenPrinting.org.</li>
+      <li>Some printers are only partially supported.  Printers such as<br />
+        HP LaserJet 1022<br />
+        HP LaserJet p1505n<br />
+        HP LaserJet p12014<br />
+        HP LaserJet p2035<br />
+        require a proprietary plug-in for full support.  This package does not contain or support such plug-ins.</li>
+    </ul>
+    <p><a name="Printer_Set_Up_Instructions" id="Printer_Set_Up_Instructions"></a></p>
+    <h2> Printer Set Up Instructions </h2>
+    <p>To add a printer queue, Leopard (Mac OS X 10.5.x) users should use   the Print &amp; Fax from System Preferences. Click on the + (plus) icon   at the lower left. A new window will open. In that window, click the   Default Browser icon at the top left. Highlight your printer in the   section below. Use the &quot;Print Using&quot; pop-up menu near the bottom of the   window to select the correct PPD for your printer and click Add.</p>
+    <p>Tiger users should open the Printer Setup Utility and click on the   Add icon at the top of the Printer List window. A new window will open.   In that window, click the Default Browser icon at the top left.   Highlight your printer in the section below. Use the &quot;Print Using&quot;   pop-up menu near the bottom of the window to select the correct PPD for   your printer and click Add.</p>
+    <p>Jaguar (OS X 10.2.x) and Panther (OS X 10.3.x) users should open   Print Center (Jaguar) or Printer Setup Utility (Panther), hold down the   Option key, and click the Add Printer button in the Print Center   toolbar. Within the setup sheet, choose Advanced from the top popup   menu; then in the &quot;Device:&quot; popup menu select your printer by name (it   should be the last item in the menu list). Finally, select the correct   PPD from the model browser and click Add.</p>
+  </div>
+</div>
+
+<div id="boxframe">
+<iframe id="boxscroll3" src="iframe/lgpl-3.0-standalone.html" height="100%" width="100%" frameborder="0" onload="$(this).height($(this).contents().height());"></iframe>
+</div>
+
+
+</body>
+</html>

+ 0 - 406
demo/js/jquery.nicescroll.js

@@ -1,406 +0,0 @@
-/* jquery.nicescroll
--- versione 1.5.0
--- copyright 2011 InuYaksa*2011
--- licensed under the MIT
---
--- https://github.com/inuyaksa/jquery.nicescroll
---
-*/
-
-(function($){
-
-  var domfocus = false;
-  var mousefocus = false;
-
-  var NiceScrollClass = function(myopt) {
-
-    var self = this;
-    
-    this.opt = {
-      doc:$("body"),
-      win:false,
-      zindex:9999,
-      cursoropacitymin:0,
-      cursoropacitymax:1,
-      cursorcolor:"#424242",
-      scrollspeed:60,
-      mousescrollstep:8*6
-    };
-    
-    if (myopt||false) {
-      for(var a in self.opt) {
-        if (myopt[a]!==undefined) self.opt[a] = myopt[a];
-      }
-    }
-    
-    this.id = self.opt.doc[0].id||'';
-    this.doc = self.opt.doc;
-    this.ispage = (self.doc[0].nodeName=='BODY'||self.doc[0].nodeName=='HTML');    
-    this.docscroll = self.ispage?$(window):this.doc;
-    this.win = self.opt.win||this.docscroll;
-    
-    this.isiframe = (this.doc[0].nodeName == 'IFRAME');
-    
-    if (self.isiframe) {
-      this.docscroll = (this.doc[0].document)?$(this.doc[0].document.body):this.doc;
-      this.doc.load(function() {
-        var doc = 'contentDocument' in this? this.contentDocument : this.contentWindow.document;
-        self.docscroll = $(doc.body);
-        self.onResize();
-        $(doc.body).css({'overflow-y':'hidden'});
-        $(doc).scroll(self.onscroll);
-        self.bind(doc,"mousewheel",self.onmousewheel);
-        $(doc).keydown(self.onkeypress);
-      });
-    }
-    
-    this.view = false;
-    this.page = false;
-    
-    this.scroll = {x:0,y:0};
-    this.scrollratio = {x:0,y:0};    
-    this.cursorheight = 20;
-    this.scrollvaluemax = 0;
-    
-    do {
-      this.id = "ascrail"+Math.round(Math.random() * 99999);
-    } while (document.getElementById(this.id));
-    
-    this.rail = false;
-    this.cursor = false;
-    this.cursorfreezed = false;  
-    
-    this.hasfocus = false;
-    this.hasmousefocus = false;
-    
-    this.isie = (document.all && !document.opera);
-    
-    this.scrollTop = function(val) {
-      return (val === undefined) ? self.getScrollTop() : self.setScrollTop(val);
-    };
-    
-    this.getScrollTop = function() {
-      return self.docscroll.scrollTop();
-    };
-    this.setScrollTop = function(val) {
-      return self.docscroll.scrollTop(val);
-    };
-    
-    this.hasParent = function(e,id) {
-      var el = e.target||e||false;
-      while (el && el.id != id) {
-        el = el.parentNode||false;
-      }
-      return (el!==false);
-    };
-    
-    this.updateScrollBar = function() {
-      var pos = self.win.offset();
-      pos.top+=2;
-      pos.left+=self.win.outerWidth()-16;
-      self.rail.css({position:"absolute",top:pos.top,left:pos.left,height:self.win.outerHeight()});
-    };
-    
-    this.init = function() {
-      self.doc.css({'overflow-y':'hidden'});
-      var rail = $(document.createElement('div'));
-      rail.attr('id',self.id);
-      rail.css({"padding-left":"4px",width:"12px",'z-index':self.opt.zindex,opacity:self.cursoropacitymin});
-      self.rail = rail;
-      
-      if (self.ispage) {
-        rail.css({position:"fixed",top:"0px",right:"0px",height:"100%"});
-        self.doc.append(rail);
-      } else {
-        self.updateScrollBar();
-        $("body").append(rail);
-      }
-      
-      var cursor = $(document.createElement('div'));
-      cursor.css({
-        position:"relative",top:0,left:0,width:"8px",height:"0px",
-        'background-color':self.opt.cursorcolor,
-        border:"1px solid #fff",
-        '-webkit-border-radius':'4px',
-        '-moz-border-radius':'4px',
-        'border-radius':'4px'
-      });
-      self.cursor = cursor;
-      self.rail.append(cursor);
-      
-      self.win.resize(function(){self.onResize()});    
-      self.doc.resize(function(){self.onResize()});    
-      self.onResize();
-
-      self.rail.mousedown(function(e) {
-        self.rail.drag = {x:e.screenX,y:e.screenY,sx:self.scroll.x,sy:self.scroll.y};
-        return self.cancelEvent(e);
-      });
-      self.rail.mouseup(function() {
-        self.rail.drag = false;
-        return false;
-      });
-      
-      $(document).mouseup(function(e) {
-        self.rail.drag = false;      
-        self.hideCursor();
-      });
-      
-      $(document).mousemove(function(e) {
-        if (self.rail.drag) {
-          self.scroll.y = self.rail.drag.sy + (e.screenY-self.rail.drag.y);
-          if (self.scroll.y<0) self.scroll.y=0;
-          var my = self.scrollvaluemax;
-          if (self.scroll.y>my) self.scroll.y=my;
-          self.showCursor();
-          self.cursorfreezed = true;
-          self.doScroll(Math.round(self.scroll.y*self.scrollratio.y));          
-          return self.cancelEvent(e);
-        }
-      });
-      
-      self.rail.mouseenter(function() {
-        $(self.rail).animate({opacity:self.opt.cursoropacitymax});
-        self.rail.active = true;
-      });
-      self.rail.mouseleave(function() {
-        self.rail.active = false;
-        if (!self.rail.drag) self.hideCursor();
-      });
-      
-      if (!self.isiframe) self.bind((self.isie&&self.ispage) ? document : self.docscroll,"mousewheel",self.onmousewheel);
-      self.bind(self.rail,"mousewheel",self.onmousewheel);
-
-      if (!self.ispage) {
-        if (!self.win.attr("tabindex")) self.win.attr({"tabindex":(new Date()).getTime()});
-        self.win.focus(function(e) {          
-          domfocus = e.target.id||true;
-          self.hasfocus = true;
-          self.showCursor();
-          self.hideCursor();
-        });
-        self.win.blur(function(e) {
-          domfocus = false;
-          self.hasfocus = false;
-        });
-        self.win.mouseenter(function(e) {
-          mousefocus = e.target.id||true;
-          self.hasmousefocus = true;
-        });
-        self.win.mouseleave(function() {
-          mousefocus = false;
-          self.hasmousefocus = false;
-        });
-      };
-      
-      //Thanks to http://www.quirksmode.org !!
-      self.onkeypress = function(e) {
-        e = (e) ? e : window.e;
-        if (e.target&&/(INPUT|TEXTAREA|SELECT)/.test(e.target.nodeName)) return;
-        if (self.hasfocus||(self.hasmousefocus&&!domfocus)||(self.ispage&&!domfocus&&!mousefocus)) {
-          var key = e.keyCode;     
-          var ret = true;
-          switch (key) {
-            case 38:
-            case 63233: //safari
-              self.doScrollBy(12);
-              ret = false;
-              break;
-            case 40:
-            case 63235: //safari
-              self.doScrollBy(-12);
-              ret = false;
-              break;
-            case 33:
-            case 63276: // safari
-              self.doScrollBy(self.view.h,true);
-              ret = false;
-              break;
-            case 34:
-            case 63277: // safari
-              self.doScrollBy(-self.view.h,true);
-              ret = false;
-              break;
-            case 36:
-            case 63273: // safari
-              self.doScrollTo(0,true);
-              ret = false;
-              break;
-            case 35:
-            case 63275: // safari
-              self.doScrollTo(self.page.h,true);
-              ret = false;
-              break;
-          }
-          if (!ret) return self.cancelEvent(e);
-        }
-      };
-      self.bind(document,"keydown",self.onkeypress);
-      
-    };
-    
-    this.showCursor = function() {
-      if (self.cursortimeout) {
-        clearTimeout(self.cursortimeout);
-        self.cursortimeout = 0;
-      }
-      self.rail.clearQueue().css({opacity:self.opt.cursoropacitymax});
-      self.cursor.css({height:self.cursorheight,top:self.scroll.y});
-    };
-    
-    this.hideCursor = function(tm) {
-      if (self.cursortimeout) return;
-      self.cursortimeout = setTimeout(function() {
-         if (self.rail.active) return;
-         $(self.rail).animate({opacity:self.opt.cursoropacitymin});
-         self.cursortimeout = 0;
-      },tm||800);
-    };
-    
-    this.getContentSize = function() {
-      var pg = (self.ispage) ?
-        {
-          w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),
-          h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)
-        } : 
-        {
-          w:self.docscroll[0].scrollWidth,
-          h:self.docscroll[0].scrollHeight
-        };
-
-      pg.w-=1;
-      pg.h-=1;
-
-      return pg;
-    };
-    
-    this.onResize = function() {
-      if (!self.ispage) self.updateScrollBar();
-    
-      self.view = {
-        w:(self.ispage) ? self.win.width() : self.win.innerWidth(),
-        h:(self.ispage) ? self.win.height() : self.win.innerHeight()
-      };
-      self.page = self.getContentSize();
-      
-      self.cursorheight = Math.min(self.view.h,Math.round(self.view.h * (self.view.h / self.page.h)));
-      
-      self.scrollvaluemax = self.view.h-self.cursorheight-2;
-      
-      self.scrollratio = {
-        x:0,
-        y:((self.page.h - self.view.h)/self.scrollvaluemax)
-      };
-      
-      self.scroll.y = Math.round(self.getScrollTop() * (1/self.scrollratio.y));
-      
-      self.showCursor();
-      self.hideCursor();
-    };
-   
-    this.bind = function(dom,name,fn,bubble) {  // fixing jquery bind
-      var el = (dom.length) ? dom[0] : dom;
-      if (el.addEventListener) {
-        el.addEventListener(name,fn,bubble||false);
-        if (name=='mousewheel') el.addEventListener("DOMMouseScroll",fn,bubble||false);
-      } 
-      else if (el.attachEvent) {
-        el.attachEvent("on"+name,fn);
-      } 
-      else {
-        el["on"+name] = fn;
-      }
-    };
-    
-    // Thanks to http://www.switchonthecode.com !!
-    this.cancelEvent = function(e) {
-      e = e ? e : window.event;
-      if(e.stopPropagation) e.stopPropagation();
-      if(e.preventDefault) e.preventDefault();
-      e.cancelBubble = true;
-      e.cancel = true;
-      e.returnValue = false;
-      return false;
-    };
-   
-    this.onmousewheel = function(e) {
-      var delta = 0;
-      e = e ? e : window.event;
-      var delta = e.detail ? e.detail * -1 : e.wheelDelta / 40;
-      if (delta) {
-        self.doScrollBy(delta*self.opt.mousescrollstep,true);
-      }
-      return self.cancelEvent(e);
-    };
-    
-    this.doScroll = function(y) {
-      self.newscrolly = y;
-      if (self.timer) return;
-      self.timer = setInterval(function() {
-        var gp = self.newscrolly - self.getScrollTop();
-        var df = (gp>0) ? Math.ceil(gp/4) : Math.floor(gp/4);
-        var sc = self.getScrollTop()+df;
-        self.setScrollTop(sc);     
-        if (sc == self.newscrolly) {
-          clearInterval(self.timer);
-          self.timer = 0;        
-          self.cursorfreezed = false;
-        }
-      },self.opt.scrollspeed);
-      self.showCursor();
-      self.hideCursor();
-    };
-    
-    this.doScrollBy = function(stp,absolute) {
-      if (absolute) stp = Math.round(stp * 1/self.scrollratio.y);
-      var ny = self.scroll.y-stp;
-      if (ny<0) ny=0;
-      var my = self.scrollvaluemax;
-      if (ny>my) ny=my;
-      self.cursorfreezed = false;
-      self.doScroll(Math.floor(ny*self.scrollratio.y));
-    };
-
-    this.doScrollTo = function(pos,absolute) {
-      if (absolute) pos = Math.round(pos * 1/self.scrollratio.y);
-      ny=pos;
-      if (ny<0) ny=0;
-      var my = self.scrollvaluemax;
-      if (ny>my) ny=my;
-      self.cursorfreezed = false;
-      self.doScroll(Math.floor(ny*self.scrollratio.y));
-    };
-    
-    self.onscroll = function(e) {    
-      var tm = (new Date()).getTime();
-      if (!self.lastcontentcheck || self.lastcontentcheck<tm) {
-        self.lastcontentcheck=tm+500;
-        var pg = self.getContentSize();
-        if (pg.h!=self.page.h) self.onResize();        
-      }    
-      if (self.rail.drag) return;
-      if (!self.cursorfreezed) self.scroll.y = Math.round(self.getScrollTop() * (1/self.scrollratio.y));
-      self.showCursor();
-      self.hideCursor();
-    };
-    self.docscroll.scroll(function(e) {
-      self.onscroll(e);
-    });
-   
-    this.init();
-
-  };
-  
-  $.fn.niceScroll = function(opt) {
-    var ret = [];
-    if (typeof opt=="undefined") opt = {};
-    var docundef = !("doc" in opt);
-    this.each(function() {      
-      opt.doc = (docundef) ? $(this) : opt.doc;
-      ret.push(new NiceScrollClass(opt));
-    });
-    return (ret.length==1) ? ret[0] : ret;
-  };
-  
-})( jQuery );
-  

+ 37 - 0
demo/js/jquery.nicescroll.min.js

@@ -0,0 +1,37 @@
+/* jquery.nicescroll
+-- versione 2.0.0
+-- copyright 2011 InuYaksa*2011
+-- licensed under the MIT
+--
+-- http://areaaperta.com/nicescroll
+-- https://github.com/inuyaksa/jquery.nicescroll
+--
+*/
+(function(e){var i=false,j=false,k=function(){var d=document.getElementsByTagName("script"),d=d[d.length-1].src.split("?")[0];return d.split("/").length>0?d.split("/").slice(0,-1).join("/")+"/":""}(),l=function(d){var a=this;this.opt={doc:e("body"),win:false,zindex:9E3,cursoropacitymin:0,cursoropacitymax:1,cursorcolor:"#424242",cursorwidth:"5px",cursorborder:"1px solid #fff",cursorborderradius:"4px",scrollspeed:60,mousescrollstep:48,touchbehavior:false,hwacceleration:true,boxzoom:false,dblclickzoom:true,
+gesturezoom:true};if(d)for(var g in a.opt)d[g]!==void 0&&(a.opt[g]=d[g]);this.id=a.opt.doc[0].id||"";this.doc=a.opt.doc;this.ispage=a.doc[0].nodeName=="BODY"||a.doc[0].nodeName=="HTML";this.haswrapper=a.opt.win!==false;this.win=a.opt.win||(this.ispage?e(window):this.doc);this.docscroll=this.ispage?e(window):this.win;this.isiframe=this.doc[0].nodeName=="IFRAME"&&this.win[0].nodeName=="IFRAME";this.doc[0].nodeName=="IFRAME"&&this.doc.load(function(){var b="contentDocument"in this?this.contentDocument:
+this.contentWindow.document;if(a.isiframe)a.docscroll=e(b.body);a.onResize();e(b.body).css({"overflow-y":"hidden"});e(b).scroll(a.onscroll);e(b).mouseup(function(){a.rail.drag=false});a.bind(b,"mousewheel",a.onmousewheel);e(b).keydown(a.onkeypress);if(a.cantouch||a.opt.touchbehavior)a.bind(b,"mousedown",function(b){a.rail.drag={x:b.pageX,y:b.pageY,sx:a.scroll.x,sy:a.scroll.y,st:a.getScrollTop()};return a.cancelEvent(b)}),a.bind(b,"mouseup",function(b){a.rail.drag=false;return a.cancelEvent(b)}),a.bind(b,
+"mousemove",function(b){if(a.rail.drag)return a.doScrollTo(a.rail.drag.st-(b.pageY-a.rail.drag.y),true),a.cancelEvent(b)});a.zoom&&(a.bind(b,"dblclick",a.doZoom),a.cantouch&&a.opt.gesturezoom&&a.bind(b,"gesturechange",function(b){b.scale>1.5&&a.doZoomIn(b);b.scale<0.8&&a.doZoomOut(b);return a.cancelEvent(b)}))});this.page=this.view=false;this.scroll={x:0,y:0};this.scrollratio={x:0,y:0};this.cursorheight=20;this.scrollvaluemax=0;do this.id="ascrail"+Math.round(Math.random()*99999);while(document.getElementById(this.id));
+this.hasmousefocus=this.hasfocus=this.zoomactive=this.zoom=this.cursorfreezed=this.cursor=this.rail=false;d=document.createElement("DIV");this.isieold=(this.isie=document.all&&!document.opera)&&!("msInterpolationMode"in d.style);this.cantouch="ontouchstart"in document.documentElement;if(a.opt.hwacceleration){if((this.trstyle=window.opera?"OTransform":document.all?"msTransform":d.style.webkitTransform!==void 0?"webkitTransform":d.style.MozTransform!==void 0?"MozTransform":false)&&d.style[this.trstyle]===
+void 0)this.trstyle=false;if(this.hastransform=this.trstyle!=false)d.style[this.trstyle]="translate3d(1px,2px,3px)",this.hastranslate3d=/translate3d/.test(d.style[this.trstyle])}else this.hastransform=this.trstyle=false;this.ishwscroll=a.hastransform&&a.opt.hwacceleration&&a.haswrapper;this.scrollTop=function(b){return b===void 0?a.getScrollTop():a.setScrollTop(b)};this.ishwscroll?(a.doc.translate={x:0,y:0},this.getScrollTop=function(){return a.doc.translate.y},this.setScrollTop=this.hastranslate3d?
+function(b){a.doc.css(a.trstyle,"translate3d(0px,"+b*-1+"px,0px)");a.doc.translate.y=b;document.createEvent?(b=document.createEvent("UIEvents"),b.initUIEvent("scroll",false,true,window,1),a.docscroll[0].dispatchEvent(b)):(b=document.createEventObject(),a.docscroll[0].fireEvent("onscroll"),b.cancelBubble=true)}:function(b){a.doc.css(a.trstyle,"translate(0px,"+b*-1+"px)");a.doc.translate.y=b;document.createEvent?(b=document.createEvent("UIEvents"),b.initUIEvent("scroll",false,true,window,1),a.docscroll[0].dispatchEvent(b)):
+(b=document.createEventObject(),a.docscroll[0].fireEvent("onscroll"),b.cancelBubble=true)}):(this.getScrollTop=function(){return a.docscroll.scrollTop()},this.setScrollTop=function(b){return a.docscroll.scrollTop(b)});this.getTarget=function(a){return!a?false:a.target?a.target:a.srcElement?a.srcElement:false};this.hasParent=function(a,c){if(!a)return false;for(var h=a.target||a.srcElement||a||false;h&&h.id!=c;)h=h.parentNode||false;return h!==false};this.updateScrollBar=function(){if(a.ishwscroll)a.rail.css({height:a.win.innerHeight()});
+else{var b=a.win.offset();b.top+=2;b.left+=a.win.outerWidth()-a.rail.width-5;a.rail.css({position:"absolute",top:b.top,left:b.left,height:a.win.outerHeight()});a.zoom&&a.zoom.css({position:"absolute",top:b.top+1,left:b.left-18})}};this.init=function(){if(!a.ispage||!a.cantouch&&!this.isieold){a.ispage?a.doc.css({"overflow-y":"hidden"}):a.docscroll.css({"overflow-y":"hidden"});var b=e(document.createElement("div"));b.attr("id",a.id);b.width=4+parseFloat(a.opt.cursorwidth);b.css({"padding-left":"4px",
+"padding-right":"1px",width:a.rail.width+"px","z-index":a.opt.zindex,opacity:a.cursoropacitymin});a.rail=b;var c=false;if(a.opt.boxzoom&&!a.ispage&&!a.isieold)c=document.createElement("div"),a.bind(c,"click",a.doZoom),a.zoom=e(c),a.zoom.css({cursor:"pointer","z-index":a.opt.zindex,backgroundImage:"url("+k+"zoomico.png)",height:18,width:18,backgroundPosition:"0px 0px"}),a.opt.dblclickzoom&&a.bind(a.win,"dblclick",a.doZoom),a.cantouch&&a.opt.gesturezoom&&a.bind(a.win,"gesturechange",function(b){b.scale>
+1.5&&a.doZoomIn(b);b.scale<0.8&&a.doZoomOut(b);return a.cancelEvent(b)});a.ispage?(b.css({position:"fixed",top:"0px",right:"0px",height:"100%"}),a.doc.append(b)):a.ishwscroll?(a.win.css("position")=="static"&&a.win.css("position","relative"),a.zoom&&(a.zoom.css({position:"absolute",top:1,right:0,"margin-right":b.width+2}),a.win.append(a.zoom)),b.css({position:"absolute",top:0,right:0}),a.win.append(b)):(a.updateScrollBar(),e("body").append(b),a.zoom&&e("body").append(a.zoom));b=e(document.createElement("div"));
+b.css({position:"relative",top:0,left:0,width:a.opt.cursorwidth,height:"0px","background-color":a.opt.cursorcolor,border:a.opt.cursorborder,"-webkit-border-radius":a.opt.cursorborderradius,"-moz-border-radius":a.opt.cursorborderradius,"border-radius":a.opt.cursorborderradius});a.cursor=b;a.rail.append(b);a.win.resize(a.onResize);a.doc.resize(a.onResize);!a.ispage&&a.opt.boxzoom&&e(window).resize(a.resizeZoom);a.onResize();a.cantouch||a.opt.touchbehavior?(a.bind(a.win,"mousedown",function(b){a.rail.drag=
+{x:b.pageX,y:b.pageY,sx:a.scroll.x,sy:a.scroll.y,st:a.getScrollTop()};return a.cancelEvent(b)}),a.bind(a.win,"mouseup",function(b){a.rail.drag=false;return a.cancelEvent(b)}),a.bind(a.rail,"mousedown",function(b){a.rail.drag={x:b.pageX,y:b.pageY,sx:a.scroll.x,sy:a.scroll.y,st:a.getScrollTop()};return a.cancelEvent(b)}),a.bind(a.rail,"mouseup",function(b){a.rail.drag=false;return a.cancelEvent(b)}),a.bind(document,"mousemove",function(b){if(a.rail.drag)return a.doScrollTo(a.rail.drag.st-(b.pageY-a.rail.drag.y),
+true),a.cancelEvent(b)})):(a.bind(a.rail,"mousedown",function(b){a.rail.drag={x:b.screenX,y:b.screenY,sx:a.scroll.x,sy:a.scroll.y};return a.cancelEvent(b)}),a.bind(a.rail,"mouseup",function(b){a.rail.drag=false;a.hideCursor();return a.cancelEvent(b)}),a.bind(document,"mousemove",function(b){if(a.rail.drag){a.scroll.y=a.rail.drag.sy+(b.screenY-a.rail.drag.y);if(a.scroll.y<0)a.scroll.y=0;var c=a.scrollvaluemax;if(a.scroll.y>c)a.scroll.y=c;a.showCursor();a.cursorfreezed=true;a.doScroll(Math.round(a.scroll.y*
+a.scrollratio.y));return a.cancelEvent(b)}}));a.bind(document,"mouseup",function(){a.rail.drag=false;a.hideCursor()});a.cantouch||(a.rail.mouseenter(function(){a.showCursor();a.rail.active=true}),a.rail.mouseleave(function(){a.rail.active=false;a.rail.drag||a.hideCursor()}),a.isiframe||a.bind(a.isie&&a.ispage?document:a.docscroll,"mousewheel",a.onmousewheel),a.bind(a.rail,"mousewheel",a.onmousewheel));!a.ispage&&!a.cantouch&&(a.win.attr("tabindex")||a.win.attr({tabindex:(new Date).getTime()}),a.win.focus(function(b){i=
+a.getTarget(b).id||true;a.hasfocus=true;a.noticeCursor()}),a.win.blur(function(){i=false;a.hasfocus=false}),a.win.mouseenter(function(b){j=a.getTarget(b).id||true;a.hasmousefocus=true;a.noticeCursor()}),a.win.mouseleave(function(){j=false;a.hasmousefocus=false}));a.onkeypress=function(b){var b=b?b:window.e,c=a.getTarget(b);if(!c||!/(INPUT|TEXTAREA|SELECT)/.test(c.nodeName))if(a.hasfocus||a.hasmousefocus&&!i||a.ispage&&!i&&!j){c=true;switch(b.keyCode){case 38:case 63233:a.doScrollBy(12);c=false;break;
+case 40:case 63235:a.doScrollBy(-12);c=false;break;case 33:case 63276:a.doScrollBy(a.view.h,true);c=false;break;case 34:case 63277:a.doScrollBy(-a.view.h,true);c=false;break;case 36:case 63273:a.doScrollTo(0,true);c=false;break;case 35:case 63275:a.doScrollTo(a.page.h,true);c=false;break;case 27:a.zoomactive&&(a.doZoom(),c=false)}if(!c)return a.cancelEvent(b)}};a.bind(document,"keydown",a.onkeypress)}};this.showCursor=function(){if(a.cursortimeout)clearTimeout(a.cursortimeout),a.cursortimeout=0;a.rail&&
+(a.rail.stop().css({opacity:a.opt.cursoropacitymax}),a.cursor.css({height:a.cursorheight,top:a.scroll.y}),a.zoom&&a.zoom.stop().css({opacity:a.opt.cursoropacitymax}))};this.hideCursor=function(b){if(!a.cursortimeout&&a.rail)a.cursortimeout=setTimeout(function(){a.rail.active||(e(a.rail).stop().animate({opacity:a.opt.cursoropacitymin}),a.zoom&&a.zoom.stop().animate({opacity:a.opt.cursoropacitymin}));a.cursortimeout=0},b||800)};this.noticeCursor=function(b){a.showCursor();a.hideCursor(b)};this.getContentSize=
+function(){var b=a.ispage?{w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)}:a.haswrapper?{w:a.doc.outerWidth()+parseInt(a.win.css("paddingLeft"))+parseInt(a.win.css("paddingRight")),h:a.doc.outerHeight()+parseInt(a.win.css("paddingTop"))+parseInt(a.win.css("paddingBottom"))}:{w:a.docscroll[0].scrollWidth,h:a.docscroll[0].scrollHeight};b.w-=1;b.h-=1;return b};this.onResize=function(){a.ispage||a.updateScrollBar();
+a.view={w:a.ispage?a.win.width():a.win.innerWidth(),h:a.ispage?a.win.height():a.win.innerHeight()};a.page=a.getContentSize();a.cursorheight=Math.min(a.view.h,Math.round(a.view.h*(a.view.h/a.page.h)));a.scrollvaluemax=a.view.h-a.cursorheight-2;a.scrollratio={x:0,y:(a.page.h-a.view.h)/a.scrollvaluemax};a.scroll.y=Math.round(a.getScrollTop()*(1/a.scrollratio.y));a.noticeCursor()};this.bind=function(b,c,d,e){var f=b.length?b[0]:b;f.addEventListener?(a.cantouch&&/mouseup|mousedown|mousemove/.test(c)&&
+f.addEventListener(c=="mousedown"?"touchstart":c=="mouseup"?"touchend":"touchmove",function(a){if(a.touches.length<2){var b=a.touches.length>0?a.touches[0]:a;b.original=a;d.call(this,b)}},e||false),f.addEventListener(c,d,e||false),c=="mousewheel"&&f.addEventListener("DOMMouseScroll",d,e||false)):f.attachEvent?f.attachEvent("on"+c,function(b){if(!d.call(f,b)||!e)return a.cancelEvent(b)}):f["on"+c]=function(b){if(!d.call(f,b)||!e)return a.cancelEvent(b)}};this.cancelEvent=function(b){b=a.cantouch?b?
+b.original:false:b?b:window.event||false;if(!b)return false;b.stopPropagation&&b.stopPropagation();b.preventDefault&&b.preventDefault();b.cancelBubble=true;b.cancel=true;return b.returnValue=false};this.onmousewheel=function(b){b=b?b:window.event;if(a.rail.drag)return a.cancelEvent(b);var c=0;(c=b.detail?b.detail*-1:b.wheelDelta/40)&&a.doScrollBy(c*a.opt.mousescrollstep,true);return a.cancelEvent(b)};this.stop=function(){a.timer&&clearInterval(a.timer);a.timer=0;a.cursorfreezed=false;a.scroll.y=Math.round(a.getScrollTop()*
+(1/a.scrollratio.y));a.noticeCursor()};this.doScroll=function(b){a.newscrolly=b;if(!a.timer)a.timer=setInterval(function(){var b=a.newscrolly-a.getScrollTop(),b=b>0?Math.ceil(b/4):Math.floor(b/4),b=a.getScrollTop()+b;a.setScrollTop(b);if(b==a.newscrolly)clearInterval(a.timer),a.timer=0,a.cursorfreezed=false},a.opt.scrollspeed),a.noticeCursor()};this.doScrollBy=function(b,c){c&&(b=Math.round(b*1/a.scrollratio.y));var d=a.scroll.y-b;d<0&&(d=0);var e=a.scrollvaluemax;d>e&&(d=e);a.cursorfreezed=false;
+a.doScroll(Math.floor(d*a.scrollratio.y))};this.doScrollTo=function(b,c){c&&(b=Math.round(b*1/a.scrollratio.y));ny=b;ny<0&&(ny=0);var d=a.scrollvaluemax;ny>d&&(ny=d);a.cursorfreezed=false;a.doScroll(Math.floor(ny*a.scrollratio.y))};a.onscroll=function(){var b=(new Date).getTime();if(!a.lastcontentcheck||a.lastcontentcheck<b)if(a.lastcontentcheck=b+500,a.getContentSize().h!=a.page.h)a.onResize();if(!a.rail.drag){if(!a.cursorfreezed)a.scroll.y=Math.round(a.getScrollTop()*(1/a.scrollratio.y));a.noticeCursor()}};
+a.docscroll.scroll(function(b){a.onscroll(b)});this.doZoomIn=function(b){if(!a.zoomactive){a.zoomrestore={style:{}};for(var c in a.win[0].style)a.zoomrestore.style[c]=a.win[0].style[c];a.zoomrestore.padding={w:a.win.outerWidth()-a.win.width(),h:a.win.outerHeight()-a.win.height()};a.win.css({position:"fixed",top:0,left:0,"z-index":a.opt.zindex+100});c=a.win.css("backgroundColor");(c==""||/transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(c))&&a.win.css("backgroundColor","#fff");a.rail.css({"z-index":a.opt.zindex+
+110});a.zoom.css({"z-index":a.opt.zindex+112});a.zoomactive=true;a.zoom.css("backgroundPosition","0px -18px");a.resizeZoom();return a.cancelEvent(b)}};this.doZoomOut=function(b){if(a.zoomactive){var c=a.zoomrestore.style;a.win.css({position:c.position||"",top:c.top||"",left:c.left||"",width:c.width||"",height:c.height||"","z-index":c.zIndex||"",backgroundColor:c.backgroundColor||""});a.rail.css({"z-index":a.opt.zindex});a.zoom.css({"z-index":a.opt.zindex});a.zoomactive=false;a.zoomrestore=false;a.zoom.css("backgroundPosition",
+"0px 0px");a.win.resize();return a.cancelEvent(b)}};this.doZoom=function(b){return a.zoomactive?a.doZoomOut(b):a.doZoomIn(b)};this.resizeZoom=function(){if(a.zoomactive){var b=a.getScrollTop();a.win.css({width:e(window).width()-a.zoomrestore.padding.w+"px",height:e(window).height()-a.zoomrestore.padding.h+"px"});a.setScrollTop(b);a.win.resize()}};this.init()};e.fn.niceScroll=function(d,a){typeof d=="object"&&typeof a=="undefined"&&(a=d,d=false);var g=[];typeof a=="undefined"&&(a={});if(d)a.doc=e(d),
+a.win=e(this);var b=!("doc"in a);this.each(function(){a.doc=b?e(this):a.doc;g.push(new l(a))});return g.length==1?g[0]:g}})(jQuery);

BIN
demo/js/zoomico.png


+ 0 - 110
demo/test1.html

@@ -1,110 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-<title>jQuery NiceScroll Test</title>
-<style type="text/css">
-#boxscroll {
-	padding: 40px;
-	height: 300px;
-	width: 300px;
-	border: 2px solid #00F;
-	overflow: auto;
-}
-#boxscroll2 {
-	padding: 40px;
-	height: 120px;
-	width: 500px;
-	border: 2px solid #F00;
-	overflow: auto;
-}
-#boxframe {
-  position:absolute;
-  top:8px;
-  left:420px;
-	border: 2px solid #0F0;
-}
-</style>
-
-<script src="js/jquery.min.js"></script>
-<script src="js/jquery.nicescroll.js"></script>
-
-<script>
-  $(document).ready(function() {
-    $("body").niceScroll();  // The document page (body)
-    $("#boxscroll").niceScroll({cursorcolor:"#00F",cursoropacitymax:0.7});  // First scrollable DIV
-    $("#boxscroll2").niceScroll({cursorcolor:"#F00",cursoropacitymax:0.7});  // Second scrollable DIV
-    $("#boxscroll3").niceScroll({cursorcolor:"#0F0",cursoropacitymax:0.7});  // Thi is an IFrame
-  });
-</script>
-
-</head>
-
-<body>
-<div id="boxscroll">
-  <h2> Package Description </h2>
-  <p>Release Date: August 10, 2010</p>
-  <p>The <a title="http://www.openprinting.org/show_driver.cgi?driver=hpijs" rel="nofollow" href="http://www.openprinting.org/show_driver.cgi?driver=hpijs">HPIJS</a> driver is the free, <a title="http://hplipopensource.com/hplip-web/index.html" rel="nofollow" href="http://hplipopensource.com/hplip-web/index.html">open-source driver</a> issued by HP for their DeskJet and LaserJet printers. For most <a title="" href="http://www.linuxfoundation.org/collaborate/workgroups/openprinting/macosx/hpijs#Printers">supported printers</a>,   this driver produces output quality equivalent to the proprietary HP   drivers. In photo mode, with photo paper, the output quality is very   high, especially for the HP DeskJet 990C and later models, which   auto-detect the paper type in hardware. Photo printing is fully   supported in the newer 6- and 7-ink models.</p>
-  <p>A major advantage of using this driver over those supplied by HP is   the direct interface between HPIJS and the native CUPS spooler, which   allows printing from any printer over any available connection such as   USB, AppleTalk, TCP/IP (via LPD and IPP), HP JetDirect, and shared   windows printers via SAMBA. Additionally, this driver utilizes the   existing Mac OS X USB &quot;backend&quot; and thus does not install any software   that might interfere with standard USB operation.</p>
-  <p>Please note:</p>
-  <ul>
-    <li>HP does not provide any support for HPLIP or HPIJS on the Mac OS X platform.</li>
-    <li><a href="http://www.linuxfoundation.org/en/OpenPrinting/MacOSX/hpijs-USB">Several HP USB devices</a> may not print successfully over the standard Mac OS X USB &quot;backend&quot;. Please <a href="http://www.linuxfoundation.org/en/OpenPrinting/MacOSX/hpijs-USB">see this note</a> for more information.</li>
-  </ul>
-  <h2>Release Notes</h2>
-  <ul>
-    <li>This release fixes a problem with the PPDs that caused many job   options such as page orientation, color/grayscale mode, duplex printing,   etc. to fail.</li>
-    <li>HPIJS is HP's universal printer driver for most of their   non-PostScript printers. It comes as a part of HPLIP, HP Linux Imaging   and Printing.</li>
-    <li>The PPDs for HP printers are now sourced from the HPLIP package rather than the OpenPrinting.org database.</li>
-    <li>PPDs for printers from other manufacturers are provided by OpenPrinting.org.</li>
-    <li>Some printers are only partially supported.  Printers such as<br />
-      HP LaserJet 1022<br />
-      HP LaserJet p1505n<br />
-      HP LaserJet p12014<br />
-      HP LaserJet p2035<br />
-      require a proprietary plug-in for full support.  This package does not contain or support such plug-ins.</li>
-  </ul>
-  <p><a name="Printer_Set_Up_Instructions" id="Printer_Set_Up_Instructions"></a></p>
-  <h2> Printer Set Up Instructions </h2>
-  <p>To add a printer queue, Leopard (Mac OS X 10.5.x) users should use   the Print &amp; Fax from System Preferences. Click on the + (plus) icon   at the lower left. A new window will open. In that window, click the   Default Browser icon at the top left. Highlight your printer in the   section below. Use the &quot;Print Using&quot; pop-up menu near the bottom of the   window to select the correct PPD for your printer and click Add.</p>
-  <p>Tiger users should open the Printer Setup Utility and click on the   Add icon at the top of the Printer List window. A new window will open.   In that window, click the Default Browser icon at the top left.   Highlight your printer in the section below. Use the &quot;Print Using&quot;   pop-up menu near the bottom of the window to select the correct PPD for   your printer and click Add.</p>
-  <p>Jaguar (OS X 10.2.x) and Panther (OS X 10.3.x) users should open   Print Center (Jaguar) or Printer Setup Utility (Panther), hold down the   Option key, and click the Add Printer button in the Print Center   toolbar. Within the setup sheet, choose Advanced from the top popup   menu; then in the &quot;Device:&quot; popup menu select your printer by name (it   should be the last item in the menu list). Finally, select the correct   PPD from the model browser and click Add.</p>
-</div>
-
-<div id="boxscroll2">
-  <h2> Package Description </h2>
-  <p>Release Date: August 10, 2010</p>
-  <p>The <a title="http://www.openprinting.org/show_driver.cgi?driver=hpijs" rel="nofollow" href="http://www.openprinting.org/show_driver.cgi?driver=hpijs">HPIJS</a> driver is the free, <a title="http://hplipopensource.com/hplip-web/index.html" rel="nofollow" href="http://hplipopensource.com/hplip-web/index.html">open-source driver</a> issued by HP for their DeskJet and LaserJet printers. For most <a title="" href="http://www.linuxfoundation.org/collaborate/workgroups/openprinting/macosx/hpijs#Printers">supported printers</a>,   this driver produces output quality equivalent to the proprietary HP   drivers. In photo mode, with photo paper, the output quality is very   high, especially for the HP DeskJet 990C and later models, which   auto-detect the paper type in hardware. Photo printing is fully   supported in the newer 6- and 7-ink models.</p>
-  <p>A major advantage of using this driver over those supplied by HP is   the direct interface between HPIJS and the native CUPS spooler, which   allows printing from any printer over any available connection such as   USB, AppleTalk, TCP/IP (via LPD and IPP), HP JetDirect, and shared   windows printers via SAMBA. Additionally, this driver utilizes the   existing Mac OS X USB &quot;backend&quot; and thus does not install any software   that might interfere with standard USB operation.</p>
-  <p>Please note:</p>
-  <ul>
-    <li>HP does not provide any support for HPLIP or HPIJS on the Mac OS X platform.</li>
-    <li><a href="http://www.linuxfoundation.org/en/OpenPrinting/MacOSX/hpijs-USB">Several HP USB devices</a> may not print successfully over the standard Mac OS X USB &quot;backend&quot;. Please <a href="http://www.linuxfoundation.org/en/OpenPrinting/MacOSX/hpijs-USB">see this note</a> for more information.</li>
-  </ul>
-  <h2>Release Notes</h2>
-  <ul>
-    <li>This release fixes a problem with the PPDs that caused many job   options such as page orientation, color/grayscale mode, duplex printing,   etc. to fail.</li>
-    <li>HPIJS is HP's universal printer driver for most of their   non-PostScript printers. It comes as a part of HPLIP, HP Linux Imaging   and Printing.</li>
-    <li>The PPDs for HP printers are now sourced from the HPLIP package rather than the OpenPrinting.org database.</li>
-    <li>PPDs for printers from other manufacturers are provided by OpenPrinting.org.</li>
-    <li>Some printers are only partially supported.  Printers such as<br />
-      HP LaserJet 1022<br />
-      HP LaserJet p1505n<br />
-      HP LaserJet p12014<br />
-      HP LaserJet p2035<br />
-      require a proprietary plug-in for full support.  This package does not contain or support such plug-ins.</li>
-  </ul>
-  <p><a name="Printer_Set_Up_Instructions" id="Printer_Set_Up_Instructions"></a></p>
-  <h2> Printer Set Up Instructions </h2>
-  <p>To add a printer queue, Leopard (Mac OS X 10.5.x) users should use   the Print &amp; Fax from System Preferences. Click on the + (plus) icon   at the lower left. A new window will open. In that window, click the   Default Browser icon at the top left. Highlight your printer in the   section below. Use the &quot;Print Using&quot; pop-up menu near the bottom of the   window to select the correct PPD for your printer and click Add.</p>
-  <p>Tiger users should open the Printer Setup Utility and click on the   Add icon at the top of the Printer List window. A new window will open.   In that window, click the Default Browser icon at the top left.   Highlight your printer in the section below. Use the &quot;Print Using&quot;   pop-up menu near the bottom of the window to select the correct PPD for   your printer and click Add.</p>
-  <p>Jaguar (OS X 10.2.x) and Panther (OS X 10.3.x) users should open   Print Center (Jaguar) or Printer Setup Utility (Panther), hold down the   Option key, and click the Add Printer button in the Print Center   toolbar. Within the setup sheet, choose Advanced from the top popup   menu; then in the &quot;Device:&quot; popup menu select your printer by name (it   should be the last item in the menu list). Finally, select the correct   PPD from the model browser and click Add.</p>
-</div>
-
-<div id="boxframe">
-<iframe id="boxscroll3" src="iframe/lgpl-3.0-standalone.html" height="380px" width="400px" frameborder="0"></iframe>
-</div>
-
-
-</body>
-</html>

+ 496 - 167
jquery.nicescroll.js

@@ -1,8 +1,9 @@
 /* jquery.nicescroll
--- versione 1.5.0
+-- versione 2.0.0
 -- copyright 2011 InuYaksa*2011
 -- licensed under the MIT
 --
+-- http://areaaperta.com/nicescroll
 -- https://github.com/inuyaksa/jquery.nicescroll
 --
 */
@@ -11,6 +12,15 @@
 
   var domfocus = false;
   var mousefocus = false;
+  var zoomactive = false;
+ 
+  // http://stackoverflow.com/questions/2161159/get-script-path
+  function getScriptPath() {
+    var scripts= document.getElementsByTagName('script');
+    var path= scripts[scripts.length-1].src.split('?')[0];
+    return (path.split('/').length>0) ? path.split('/').slice(0, -1).join('/')+'/' : '';
+  }
+  var scriptpath = getScriptPath();
 
   var NiceScrollClass = function(myopt) {
 
@@ -19,12 +29,20 @@
     this.opt = {
       doc:$("body"),
       win:false,
-      zindex:9999,
+      zindex:9000,
       cursoropacitymin:0,
       cursoropacitymax:1,
       cursorcolor:"#424242",
+      cursorwidth:"5px",
+      cursorborder:"1px solid #fff",
+      cursorborderradius:"4px",
       scrollspeed:60,
-      mousescrollstep:8*6
+      mousescrollstep:8*6,
+      touchbehavior:false,
+      hwacceleration:true,
+      boxzoom:false,
+      dblclickzoom:true,
+      gesturezoom:true
     };
     
     if (myopt||false) {
@@ -35,13 +53,15 @@
     
     this.id = self.opt.doc[0].id||'';
     this.doc = self.opt.doc;
-    this.ispage = (self.doc[0].nodeName=='BODY'||self.doc[0].nodeName=='HTML');    
-    this.docscroll = self.ispage?$(window):this.doc;
-    this.win = self.opt.win||this.docscroll;
-    
-    this.isiframe = (this.doc[0].nodeName == 'IFRAME');
+    this.ispage = (self.doc[0].nodeName=='BODY'||self.doc[0].nodeName=='HTML');  
+    this.haswrapper = (self.opt.win!==false);
+    this.win = self.opt.win||(this.ispage?$(window):this.doc);
+    this.docscroll = this.ispage?$(window):this.win;
+
+    this.isiframe = ((this.doc[0].nodeName == 'IFRAME') && (this.win[0].nodeName == 'IFRAME'));
     
-    if (self.isiframe) {
+/*    
+    if (this.isiframe) {
       this.docscroll = (this.doc[0].document)?$(this.doc[0].document.body):this.doc;
       this.doc.load(function() {
         var doc = 'contentDocument' in this? this.contentDocument : this.contentWindow.document;
@@ -49,10 +69,62 @@
         self.onResize();
         $(doc.body).css({'overflow-y':'hidden'});
         $(doc).scroll(self.onscroll);
+        $(doc).mouseup(function() {self.rail.drag = false;});
         self.bind(doc,"mousewheel",self.onmousewheel);
         $(doc).keydown(self.onkeypress);
       });
     }
+    else if (this.doc[0].nodeName == 'IFRAME') {
+      this.doc.load(function() {
+        self.onResize();
+        var doc = 'contentDocument' in this? this.contentDocument : this.contentWindow.document;
+        $(doc).find('body,html').css({'overflow-y':'hidden'});
+        $(doc).scroll(self.onscroll);
+        $(doc).mouseup(function() {self.rail.drag = false;});
+        self.bind(doc,"mousewheel",self.onmousewheel);
+        $(doc).keydown(self.onkeypress);
+      });
+    }
+*/
+
+    if (this.doc[0].nodeName == 'IFRAME') {
+      this.doc.load(function() {        
+        var doc = 'contentDocument' in this? this.contentDocument : this.contentWindow.document;
+        if (self.isiframe) self.docscroll = $(doc.body);
+        self.onResize();
+        $(doc.body).css({'overflow-y':'hidden'});
+        $(doc).scroll(self.onscroll);
+        $(doc).mouseup(function(){self.rail.drag = false;});
+        self.bind(doc,"mousewheel",self.onmousewheel);
+        $(doc).keydown(self.onkeypress);        
+        if (self.cantouch||self.opt.touchbehavior) {
+          self.bind(doc,"mousedown",function(e) {            
+            self.rail.drag = {x:e.pageX,y:e.pageY,sx:self.scroll.x,sy:self.scroll.y,st:self.getScrollTop()};
+            return self.cancelEvent(e);
+          });
+          self.bind(doc,"mouseup",function(e) {
+            self.rail.drag = false;
+            return self.cancelEvent(e);
+          });
+          self.bind(doc,"mousemove",function(e) {
+            if (self.rail.drag) {
+              self.doScrollTo(self.rail.drag.st - (e.pageY-self.rail.drag.y),true);
+              return self.cancelEvent(e);
+            }
+          });
+        }      
+        if (self.zoom) {
+          self.bind(doc,'dblclick',self.doZoom);
+          if (self.cantouch&&self.opt.gesturezoom) {
+            self.bind(doc,"gesturechange",function(e) {
+              if (e.scale>1.5) self.doZoomIn(e);
+              if (e.scale<0.8) self.doZoomOut(e);
+              return self.cancelEvent(e);
+            });             
+          }          
+        }
+      });
+    }
     
     this.view = false;
     this.page = false;
@@ -70,24 +142,93 @@
     this.cursor = false;
     this.cursorfreezed = false;  
     
+    this.zoom = false;
+    this.zoomactive = false;
+    
     this.hasfocus = false;
     this.hasmousefocus = false;
     
+    var domtest = document.createElement('DIV');
+    
     this.isie = (document.all && !document.opera);
+    this.isieold = (this.isie && !('msInterpolationMode' in domtest.style));
+    
+    this.cantouch = ('ontouchstart' in document.documentElement);
+    
+    if (self.opt.hwacceleration) {  // if you dont need dont bother to look for
+      this.trstyle = (window.opera) ? 'OTransform' : (document.all) ? 'msTransform' : (domtest.style.webkitTransform!==undefined) ? 'webkitTransform' : (domtest.style.MozTransform!==undefined) ? 'MozTransform' : false;
+      if (this.trstyle && domtest.style[this.trstyle] === undefined) this.trstyle = false;
+      this.hastransform = (this.trstyle != false);
+      if (this.hastransform) {
+        domtest.style[this.trstyle] = "translate3d(1px,2px,3px)";
+        this.hastranslate3d = /translate3d/.test(domtest.style[this.trstyle]);
+      }
+    } else {
+      this.trstyle = false;
+      this.hastransform = false;
+    }
+
+    this.ishwscroll = (self.hastransform)&&(self.opt.hwacceleration)&&(self.haswrapper);
     
     this.scrollTop = function(val) {
       return (val === undefined) ? self.getScrollTop() : self.setScrollTop(val);
     };
     
-    this.getScrollTop = function() {
-      return self.docscroll.scrollTop();
-    };
-    this.setScrollTop = function(val) {
-      return self.docscroll.scrollTop(val);
+    if (this.ishwscroll) {
+      // hw accelerated scroll
+      self.doc.translate = {x:0,y:0};
+      this.getScrollTop = function() {
+        return self.doc.translate.y;
+      };
+      if (this.hastranslate3d) {
+        this.setScrollTop = function(val) {
+          self.doc.css(self.trstyle,"translate3d(0px,"+(val*-1)+"px,0px)");
+          self.doc.translate.y = val;
+          if (document.createEvent) {
+            var e = document.createEvent("UIEvents");
+            e.initUIEvent("scroll", false, true, window, 1);
+            self.docscroll[0].dispatchEvent(e);
+          } else {
+            var e = document.createEventObject();
+            self.docscroll[0].fireEvent("onscroll");
+            e.cancelBubble = true; 
+          }
+        };
+      } else {
+        this.setScrollTop = function(val) {
+          self.doc.css(self.trstyle,"translate(0px,"+(val*-1)+"px)");
+          self.doc.translate.y = val;
+          if (document.createEvent) {
+            var e = document.createEvent("UIEvents");
+            e.initUIEvent("scroll", false, true, window, 1);
+            self.docscroll[0].dispatchEvent(e);
+          } else {
+            var e = document.createEventObject();
+            self.docscroll[0].fireEvent("onscroll");
+            e.cancelBubble = true; 
+          }
+        };
+      }
+    } else {
+      // native scroll
+      this.getScrollTop = function() {
+        return self.docscroll.scrollTop();
+      };
+      this.setScrollTop = function(val) {
+        return self.docscroll.scrollTop(val);
+      };
+    }
+    
+    this.getTarget = function(e) {
+      if (!e) return false;
+      if (e.target) return e.target;
+      if (e.srcElement) return e.srcElement;
+      return false;
     };
     
     this.hasParent = function(e,id) {
-      var el = e.target||e||false;
+      if (!e) return false;
+      var el = e.target||e.srcElement||e||false;
       while (el && el.id != id) {
         el = el.parentNode||false;
       }
@@ -95,147 +236,220 @@
     };
     
     this.updateScrollBar = function() {
-      var pos = self.win.offset();
-      pos.top+=2;
-      pos.left+=self.win.outerWidth()-16;
-      self.rail.css({position:"absolute",top:pos.top,left:pos.left,height:self.win.outerHeight()});
+      if (self.ishwscroll) {
+        self.rail.css({height:self.win.innerHeight()});
+      } else {
+        var pos = self.win.offset();
+        pos.top+=2;
+        pos.left+=self.win.outerWidth()-self.rail.width-5;
+        self.rail.css({position:"absolute",top:pos.top,left:pos.left,height:self.win.outerHeight()});
+        if (self.zoom) self.zoom.css({position:"absolute",top:pos.top+1,left:pos.left-18});
+      }
     };
     
     this.init = function() {
-      self.doc.css({'overflow-y':'hidden'});
-      var rail = $(document.createElement('div'));
-      rail.attr('id',self.id);
-      rail.css({"padding-left":"4px",width:"12px",'z-index':self.opt.zindex,opacity:self.cursoropacitymin});
-      self.rail = rail;
-      
-      if (self.ispage) {
-        rail.css({position:"fixed",top:"0px",right:"0px",height:"100%"});
-        self.doc.append(rail);
-      } else {
-        self.updateScrollBar();
-        $("body").append(rail);
-      }
-      
-      var cursor = $(document.createElement('div'));
-      cursor.css({
-        position:"relative",top:0,left:0,width:"8px",height:"0px",
-        'background-color':self.opt.cursorcolor,
-        border:"1px solid #fff",
-        '-webkit-border-radius':'4px',
-        '-moz-border-radius':'4px',
-        'border-radius':'4px'
-      });
-      self.cursor = cursor;
-      self.rail.append(cursor);
-      
-      self.win.resize(function(){self.onResize()});    
-      self.doc.resize(function(){self.onResize()});    
-      self.onResize();
+    
+      if (!self.ispage || (!self.cantouch && !this.isieold)) {
 
-      self.rail.mousedown(function(e) {
-        self.rail.drag = {x:e.screenX,y:e.screenY,sx:self.scroll.x,sy:self.scroll.y};
-        return self.cancelEvent(e);
-      });
-      self.rail.mouseup(function() {
-        self.rail.drag = false;
-        return false;
-      });
-      
-      $(document).mouseup(function(e) {
-        self.rail.drag = false;      
-        self.hideCursor();
-      });
-      
-      $(document).mousemove(function(e) {
-        if (self.rail.drag) {
-          self.scroll.y = self.rail.drag.sy + (e.screenY-self.rail.drag.y);
-          if (self.scroll.y<0) self.scroll.y=0;
-          var my = self.scrollvaluemax;
-          if (self.scroll.y>my) self.scroll.y=my;
-          self.showCursor();
-          self.cursorfreezed = true;
-          self.doScroll(Math.round(self.scroll.y*self.scrollratio.y));          
-          return self.cancelEvent(e);
+        (self.ispage)?self.doc.css({'overflow-y':'hidden'}):self.docscroll.css({'overflow-y':'hidden'});
+        var rail = $(document.createElement('div'));
+        rail.attr('id',self.id);
+        rail.width = 4+parseFloat(self.opt.cursorwidth);
+        rail.css({"padding-left":"4px","padding-right":"1px",width:self.rail.width+"px",'z-index':self.opt.zindex,opacity:self.cursoropacitymin});
+        self.rail = rail;
+        
+        var zoom = false;
+        if (self.opt.boxzoom&&!self.ispage&&!self.isieold) {
+          zoom = document.createElement('div');          
+          self.bind(zoom,"click",self.doZoom);
+          self.zoom = $(zoom);
+          self.zoom.css({"cursor":"pointer",'z-index':self.opt.zindex,'backgroundImage':'url('+scriptpath+'zoomico.png)','height':18,'width':18,'backgroundPosition':'0px 0px'});
+          if (self.opt.dblclickzoom) self.bind(self.win,"dblclick",self.doZoom);
+          if (self.cantouch&&self.opt.gesturezoom) {
+            self.bind(self.win,"gesturechange",function(e) {
+              if (e.scale>1.5) self.doZoomIn(e);
+              if (e.scale<0.8) self.doZoomOut(e);
+              return self.cancelEvent(e);
+            });             
+          }
+        }
+        
+        if (self.ispage) {
+          rail.css({position:"fixed",top:"0px",right:"0px",height:"100%"});
+          self.doc.append(rail);
+        } else {
+          if (self.ishwscroll) {
+            if (self.win.css('position')=='static') self.win.css('position','relative');
+            if (self.zoom) {
+              self.zoom.css({position:"absolute",top:1,right:0,"margin-right":rail.width+2});
+              self.win.append(self.zoom);
+            }
+            rail.css({position:"absolute",top:0,right:0});
+            self.win.append(rail);
+          } else {
+            self.updateScrollBar();
+            $("body").append(rail);
+            if (self.zoom) $("body").append(self.zoom);
+          }
+        }
+        
+        var cursor = $(document.createElement('div'));
+        cursor.css({
+          position:"relative",top:0,left:0,width:self.opt.cursorwidth,height:"0px",
+          'background-color':self.opt.cursorcolor,
+          border:self.opt.cursorborder,
+          '-webkit-border-radius':self.opt.cursorborderradius,
+          '-moz-border-radius':self.opt.cursorborderradius,
+          'border-radius':self.opt.cursorborderradius
+        });
+        self.cursor = cursor;
+        self.rail.append(cursor);
+        
+        self.win.resize(self.onResize);
+        self.doc.resize(self.onResize);
+        if (!self.ispage&&self.opt.boxzoom) $(window).resize(self.resizeZoom);
+        self.onResize();
+
+        if (self.cantouch||self.opt.touchbehavior) {
+          self.bind(self.win,"mousedown",function(e) {
+            self.rail.drag = {x:e.pageX,y:e.pageY,sx:self.scroll.x,sy:self.scroll.y,st:self.getScrollTop()};
+            return self.cancelEvent(e);
+          });
+          self.bind(self.win,"mouseup",function(e) {
+            self.rail.drag = false;
+            return self.cancelEvent(e);
+          });
+          self.bind(self.rail,"mousedown",function(e) {
+            self.rail.drag = {x:e.pageX,y:e.pageY,sx:self.scroll.x,sy:self.scroll.y,st:self.getScrollTop()};
+            return self.cancelEvent(e);
+          });
+          self.bind(self.rail,"mouseup",function(e) {
+            self.rail.drag = false;
+            return self.cancelEvent(e);
+          });
+          self.bind(document,"mousemove",function(e) {
+            if (self.rail.drag) {
+              self.doScrollTo(self.rail.drag.st - (e.pageY-self.rail.drag.y),true);
+              return self.cancelEvent(e);
+            }
+          });
+        } else {
+          self.bind(self.rail,"mousedown",function(e) {
+            self.rail.drag = {x:e.screenX,y:e.screenY,sx:self.scroll.x,sy:self.scroll.y};
+            return self.cancelEvent(e);
+          });
+          self.bind(self.rail,"mouseup",function(e) {
+            self.rail.drag = false;
+            self.hideCursor();
+            return self.cancelEvent(e);
+          });
+          self.bind(document,"mousemove",function(e) {
+            if (self.rail.drag) {
+              self.scroll.y = self.rail.drag.sy + (e.screenY-self.rail.drag.y);
+              if (self.scroll.y<0) self.scroll.y=0;
+              var my = self.scrollvaluemax;
+              if (self.scroll.y>my) self.scroll.y=my;
+              self.showCursor();
+              self.cursorfreezed = true;
+              self.doScroll(Math.round(self.scroll.y*self.scrollratio.y));          
+              return self.cancelEvent(e);
+            }
+          });
         }
-      });
-      
-      self.rail.mouseenter(function() {
-        $(self.rail).animate({opacity:self.opt.cursoropacitymax});
-        self.rail.active = true;
-      });
-      self.rail.mouseleave(function() {
-        self.rail.active = false;
-        if (!self.rail.drag) self.hideCursor();
-      });
-      
-      if (!self.isiframe) self.bind((self.isie&&self.ispage) ? document : self.docscroll,"mousewheel",self.onmousewheel);
-      self.bind(self.rail,"mousewheel",self.onmousewheel);
 
-      if (!self.ispage) {
-        if (!self.win.attr("tabindex")) self.win.attr({"tabindex":(new Date()).getTime()});
-        self.win.focus(function(e) {          
-          domfocus = e.target.id||true;
-          self.hasfocus = true;
-          self.showCursor();
+        self.bind(document,"mouseup",function(e) {
+          self.rail.drag = false;      
           self.hideCursor();
         });
-        self.win.blur(function(e) {
-          domfocus = false;
-          self.hasfocus = false;
-        });
-        self.win.mouseenter(function(e) {
-          mousefocus = e.target.id||true;
-          self.hasmousefocus = true;
-        });
-        self.win.mouseleave(function() {
-          mousefocus = false;
-          self.hasmousefocus = false;
-        });
-      };
-      
-      //Thanks to http://www.quirksmode.org !!
-      self.onkeypress = function(e) {
-        e = (e) ? e : window.e;
-        if (e.target&&/(INPUT|TEXTAREA|SELECT)/.test(e.target.nodeName)) return;
-        if (self.hasfocus||(self.hasmousefocus&&!domfocus)||(self.ispage&&!domfocus&&!mousefocus)) {
-          var key = e.keyCode;     
-          var ret = true;
-          switch (key) {
-            case 38:
-            case 63233: //safari
-              self.doScrollBy(12);
-              ret = false;
-              break;
-            case 40:
-            case 63235: //safari
-              self.doScrollBy(-12);
-              ret = false;
-              break;
-            case 33:
-            case 63276: // safari
-              self.doScrollBy(self.view.h,true);
-              ret = false;
-              break;
-            case 34:
-            case 63277: // safari
-              self.doScrollBy(-self.view.h,true);
-              ret = false;
-              break;
-            case 36:
-            case 63273: // safari
-              self.doScrollTo(0,true);
-              ret = false;
-              break;
-            case 35:
-            case 63275: // safari
-              self.doScrollTo(self.page.h,true);
-              ret = false;
-              break;
-          }
-          if (!ret) return self.cancelEvent(e);
+        
+        if (!self.cantouch) {
+          self.rail.mouseenter(function() {
+            self.showCursor();
+            self.rail.active = true;
+          });
+          self.rail.mouseleave(function() { 
+            self.rail.active = false;
+            if (!self.rail.drag) self.hideCursor();
+          });
+        
+          if (!self.isiframe) self.bind((self.isie&&self.ispage) ? document : self.docscroll,"mousewheel",self.onmousewheel);
+          self.bind(self.rail,"mousewheel",self.onmousewheel);
         }
-      };
-      self.bind(document,"keydown",self.onkeypress);
+
+        if (!self.ispage&&!self.cantouch) {
+          if (!self.win.attr("tabindex")) self.win.attr({"tabindex":(new Date()).getTime()});
+          self.win.focus(function(e) {
+            domfocus = (self.getTarget(e)).id||true;
+            self.hasfocus = true;
+            self.noticeCursor();
+          });
+          self.win.blur(function(e) {
+            domfocus = false;
+            self.hasfocus = false;
+          });
+          self.win.mouseenter(function(e) {
+            mousefocus = (self.getTarget(e)).id||true;
+            self.hasmousefocus = true;
+            self.noticeCursor();
+          });
+          self.win.mouseleave(function() {
+            mousefocus = false;
+            self.hasmousefocus = false;
+          });
+        };
+        
+        //Thanks to http://www.quirksmode.org !!
+        self.onkeypress = function(e) {
+          e = (e) ? e : window.e;
+          var tg = self.getTarget(e);
+          if (tg&&/(INPUT|TEXTAREA|SELECT)/.test(tg.nodeName)) return;
+          if (self.hasfocus||(self.hasmousefocus&&!domfocus)||(self.ispage&&!domfocus&&!mousefocus)) {
+            var key = e.keyCode;     
+            var ret = true;
+            switch (key) {
+              case 38:
+              case 63233: //safari
+                self.doScrollBy(12);
+                ret = false;
+                break;
+              case 40:
+              case 63235: //safari
+                self.doScrollBy(-12);
+                ret = false;
+                break;
+              case 33:
+              case 63276: // safari
+                self.doScrollBy(self.view.h,true);
+                ret = false;
+                break;
+              case 34:
+              case 63277: // safari
+                self.doScrollBy(-self.view.h,true);
+                ret = false;
+                break;
+              case 36:
+              case 63273: // safari
+                self.doScrollTo(0,true);
+                ret = false;
+                break;
+              case 35:
+              case 63275: // safari
+                self.doScrollTo(self.page.h,true);
+                ret = false;
+                break;
+              case 27: // ESC
+                if (self.zoomactive) {
+                  self.doZoom();
+                  ret = false;
+                }
+                break;
+            }
+            if (!ret) return self.cancelEvent(e);
+          }
+        };
+        self.bind(document,"keydown",self.onkeypress);
+        
+      }
       
     };
     
@@ -244,30 +458,47 @@
         clearTimeout(self.cursortimeout);
         self.cursortimeout = 0;
       }
-      self.rail.clearQueue().css({opacity:self.opt.cursoropacitymax});
+      if (!self.rail) return;
+      self.rail.stop().css({opacity:self.opt.cursoropacitymax});
       self.cursor.css({height:self.cursorheight,top:self.scroll.y});
+      if (self.zoom) self.zoom.stop().css({opacity:self.opt.cursoropacitymax});
     };
     
     this.hideCursor = function(tm) {
       if (self.cursortimeout) return;
+      if (!self.rail) return;
       self.cursortimeout = setTimeout(function() {
-         if (self.rail.active) return;
-         $(self.rail).animate({opacity:self.opt.cursoropacitymin});
+         if (!self.rail.active) {
+           $(self.rail).stop().animate({opacity:self.opt.cursoropacitymin});
+           if (self.zoom) self.zoom.stop().animate({opacity:self.opt.cursoropacitymin});
+         }
          self.cursortimeout = 0;
       },tm||800);
     };
     
+    this.noticeCursor = function(tm) {
+      self.showCursor();
+      self.hideCursor(tm);
+    };
+    
     this.getContentSize = function() {
-      var pg = (self.ispage) ?
+      var pg = 
+        (self.ispage) ?
         {
           w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),
           h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)
-        } : 
+        } 
+        : (self.haswrapper) ?
+        {
+          w:self.doc.outerWidth()+parseInt(self.win.css('paddingLeft'))+parseInt(self.win.css('paddingRight')),
+          h:self.doc.outerHeight()+parseInt(self.win.css('paddingTop'))+parseInt(self.win.css('paddingBottom'))
+        } 
+        :
         {
           w:self.docscroll[0].scrollWidth,
           h:self.docscroll[0].scrollHeight
         };
-
+        
       pg.w-=1;
       pg.h-=1;
 
@@ -276,7 +507,7 @@
     
     this.onResize = function() {
       if (!self.ispage) self.updateScrollBar();
-    
+
       self.view = {
         w:(self.ispage) ? self.win.width() : self.win.innerWidth(),
         h:(self.ispage) ? self.win.height() : self.win.innerHeight()
@@ -294,27 +525,42 @@
       
       self.scroll.y = Math.round(self.getScrollTop() * (1/self.scrollratio.y));
       
-      self.showCursor();
-      self.hideCursor();
+      self.noticeCursor();
     };
    
-    this.bind = function(dom,name,fn,bubble) {  // fixing jquery bind
+    this.bind = function(dom,name,fn,bubble) {  // fixing jquery bind & touch-oriented
       var el = (dom.length) ? dom[0] : dom;
       if (el.addEventListener) {
+        if (self.cantouch && /mouseup|mousedown|mousemove/.test(name)) {  // touch device support
+          var tt = (name=='mousedown')?'touchstart':(name=='mouseup')?'touchend':'touchmove';
+          el.addEventListener(tt,function(e){
+            if(e.touches.length<2){var ev=(e.touches.length>0)?e.touches[0]:e;ev.original=e;fn.call(this,ev);}
+          },bubble||false);
+        }
         el.addEventListener(name,fn,bubble||false);
         if (name=='mousewheel') el.addEventListener("DOMMouseScroll",fn,bubble||false);
       } 
       else if (el.attachEvent) {
-        el.attachEvent("on"+name,fn);
+        el.attachEvent("on"+name,function(e) {
+          if (!fn.call(el,e)||!bubble) return self.cancelEvent(e);
+        });
       } 
       else {
-        el["on"+name] = fn;
+        el["on"+name] = function(e) {
+          var rt=fn.call(el,e);          
+          if (!rt||!bubble) return self.cancelEvent(e);          
+        };
       }
     };
     
     // Thanks to http://www.switchonthecode.com !!
     this.cancelEvent = function(e) {
-      e = e ? e : window.event;
+      if (self.cantouch) {
+        e = e ? e.original : false;
+      } else {
+        e = e ? e : window.event||false;
+      }
+      if (!e) return false;      
       if(e.stopPropagation) e.stopPropagation();
       if(e.preventDefault) e.preventDefault();
       e.cancelBubble = true;
@@ -324,8 +570,9 @@
     };
    
     this.onmousewheel = function(e) {
-      var delta = 0;
       e = e ? e : window.event;
+      if (self.rail.drag) return self.cancelEvent(e);
+      var delta = 0;      
       var delta = e.detail ? e.detail * -1 : e.wheelDelta / 40;
       if (delta) {
         self.doScrollBy(delta*self.opt.mousescrollstep,true);
@@ -333,6 +580,14 @@
       return self.cancelEvent(e);
     };
     
+    this.stop = function() {
+      if (self.timer) clearInterval(self.timer);
+      self.timer = 0;
+      self.cursorfreezed = false;
+      self.scroll.y = Math.round(self.getScrollTop() * (1/self.scrollratio.y));      
+      self.noticeCursor();      
+    };
+    
     this.doScroll = function(y) {
       self.newscrolly = y;
       if (self.timer) return;
@@ -347,8 +602,7 @@
           self.cursorfreezed = false;
         }
       },self.opt.scrollspeed);
-      self.showCursor();
-      self.hideCursor();
+      self.noticeCursor();
     };
     
     this.doScrollBy = function(stp,absolute) {
@@ -380,21 +634,96 @@
       }    
       if (self.rail.drag) return;
       if (!self.cursorfreezed) self.scroll.y = Math.round(self.getScrollTop() * (1/self.scrollratio.y));
-      self.showCursor();
-      self.hideCursor();
+      self.noticeCursor();
     };
     self.docscroll.scroll(function(e) {
       self.onscroll(e);
     });
+    
+    this.doZoomIn = function(e) {
+      if (self.zoomactive) return;
+      
+      self.zoomrestore = {
+        style:{}
+      };
+      for(var a in self.win[0].style) {
+        self.zoomrestore.style[a] = self.win[0].style[a];
+      }
+      self.zoomrestore.padding = {
+        w:self.win.outerWidth()-self.win.width(),
+        h:self.win.outerHeight()-self.win.height()
+      };      
+      self.win.css({
+        "position":"fixed",
+        "top":0,
+        "left":0,
+        "z-index":self.opt.zindex+100
+      });
+      var bkg = self.win.css("backgroundColor");      
+      if (bkg==""||/transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(bkg)) self.win.css("backgroundColor","#fff");
+      self.rail.css({"z-index":self.opt.zindex+110});
+      self.zoom.css({"z-index":self.opt.zindex+112});
+      self.zoomactive = true;
+      self.zoom.css('backgroundPosition','0px -18px');
+      self.resizeZoom();                
+      return self.cancelEvent(e);
+    };
+
+    this.doZoomOut = function(e) {
+      if (!self.zoomactive) return;
+      
+      var res = self.zoomrestore.style;
+      self.win.css({
+        "position":res.position||'',
+        "top":res.top||'',
+        "left":res.left||'',
+        "width":res.width||'',
+        "height":res.height||'',
+        "z-index":res.zIndex||'',
+        "backgroundColor":res.backgroundColor||''
+      });
+      self.rail.css({"z-index":self.opt.zindex});
+      self.zoom.css({"z-index":self.opt.zindex});
+      self.zoomactive = false;
+      self.zoomrestore = false;
+      self.zoom.css('backgroundPosition','0px 0px');
+      self.win.resize();
+      return self.cancelEvent(e);
+    };
+    
+    this.doZoom = function(e) {
+      return (self.zoomactive) ? self.doZoomOut(e) : self.doZoomIn(e);
+    };
+    
+    this.resizeZoom = function() {
+      if (!self.zoomactive) return;
+
+      var py = self.getScrollTop(); //preserve scrolling position
+      self.win.css({
+        width:$(window).width()-self.zoomrestore.padding.w+"px",
+        height:$(window).height()-self.zoomrestore.padding.h+"px"
+      });
+      self.setScrollTop(py);
+      
+      self.win.resize();
+    };
    
     this.init();
 
   };
   
-  $.fn.niceScroll = function(opt) {
+  $.fn.niceScroll = function(wrapper,opt) {    
+    if ((typeof wrapper=="object") && (typeof opt=="undefined")) {
+      opt = wrapper;
+      wrapper = false;
+    }
     var ret = [];
     if (typeof opt=="undefined") opt = {};
-    var docundef = !("doc" in opt);
+    if (wrapper||false) {
+      opt.doc = $(wrapper);
+      opt.win = $(this);
+    }    
+    var docundef = !("doc" in opt);    
     this.each(function() {      
       opt.doc = (docundef) ? $(this) : opt.doc;
       ret.push(new NiceScrollClass(opt));

+ 37 - 0
jquery.nicescroll.min.js

@@ -0,0 +1,37 @@
+/* jquery.nicescroll
+-- versione 2.0.0
+-- copyright 2011 InuYaksa*2011
+-- licensed under the MIT
+--
+-- http://areaaperta.com/nicescroll
+-- https://github.com/inuyaksa/jquery.nicescroll
+--
+*/
+(function(e){var i=false,j=false,k=function(){var d=document.getElementsByTagName("script"),d=d[d.length-1].src.split("?")[0];return d.split("/").length>0?d.split("/").slice(0,-1).join("/")+"/":""}(),l=function(d){var a=this;this.opt={doc:e("body"),win:false,zindex:9E3,cursoropacitymin:0,cursoropacitymax:1,cursorcolor:"#424242",cursorwidth:"5px",cursorborder:"1px solid #fff",cursorborderradius:"4px",scrollspeed:60,mousescrollstep:48,touchbehavior:false,hwacceleration:true,boxzoom:false,dblclickzoom:true,
+gesturezoom:true};if(d)for(var g in a.opt)d[g]!==void 0&&(a.opt[g]=d[g]);this.id=a.opt.doc[0].id||"";this.doc=a.opt.doc;this.ispage=a.doc[0].nodeName=="BODY"||a.doc[0].nodeName=="HTML";this.haswrapper=a.opt.win!==false;this.win=a.opt.win||(this.ispage?e(window):this.doc);this.docscroll=this.ispage?e(window):this.win;this.isiframe=this.doc[0].nodeName=="IFRAME"&&this.win[0].nodeName=="IFRAME";this.doc[0].nodeName=="IFRAME"&&this.doc.load(function(){var b="contentDocument"in this?this.contentDocument:
+this.contentWindow.document;if(a.isiframe)a.docscroll=e(b.body);a.onResize();e(b.body).css({"overflow-y":"hidden"});e(b).scroll(a.onscroll);e(b).mouseup(function(){a.rail.drag=false});a.bind(b,"mousewheel",a.onmousewheel);e(b).keydown(a.onkeypress);if(a.cantouch||a.opt.touchbehavior)a.bind(b,"mousedown",function(b){a.rail.drag={x:b.pageX,y:b.pageY,sx:a.scroll.x,sy:a.scroll.y,st:a.getScrollTop()};return a.cancelEvent(b)}),a.bind(b,"mouseup",function(b){a.rail.drag=false;return a.cancelEvent(b)}),a.bind(b,
+"mousemove",function(b){if(a.rail.drag)return a.doScrollTo(a.rail.drag.st-(b.pageY-a.rail.drag.y),true),a.cancelEvent(b)});a.zoom&&(a.bind(b,"dblclick",a.doZoom),a.cantouch&&a.opt.gesturezoom&&a.bind(b,"gesturechange",function(b){b.scale>1.5&&a.doZoomIn(b);b.scale<0.8&&a.doZoomOut(b);return a.cancelEvent(b)}))});this.page=this.view=false;this.scroll={x:0,y:0};this.scrollratio={x:0,y:0};this.cursorheight=20;this.scrollvaluemax=0;do this.id="ascrail"+Math.round(Math.random()*99999);while(document.getElementById(this.id));
+this.hasmousefocus=this.hasfocus=this.zoomactive=this.zoom=this.cursorfreezed=this.cursor=this.rail=false;d=document.createElement("DIV");this.isieold=(this.isie=document.all&&!document.opera)&&!("msInterpolationMode"in d.style);this.cantouch="ontouchstart"in document.documentElement;if(a.opt.hwacceleration){if((this.trstyle=window.opera?"OTransform":document.all?"msTransform":d.style.webkitTransform!==void 0?"webkitTransform":d.style.MozTransform!==void 0?"MozTransform":false)&&d.style[this.trstyle]===
+void 0)this.trstyle=false;if(this.hastransform=this.trstyle!=false)d.style[this.trstyle]="translate3d(1px,2px,3px)",this.hastranslate3d=/translate3d/.test(d.style[this.trstyle])}else this.hastransform=this.trstyle=false;this.ishwscroll=a.hastransform&&a.opt.hwacceleration&&a.haswrapper;this.scrollTop=function(b){return b===void 0?a.getScrollTop():a.setScrollTop(b)};this.ishwscroll?(a.doc.translate={x:0,y:0},this.getScrollTop=function(){return a.doc.translate.y},this.setScrollTop=this.hastranslate3d?
+function(b){a.doc.css(a.trstyle,"translate3d(0px,"+b*-1+"px,0px)");a.doc.translate.y=b;document.createEvent?(b=document.createEvent("UIEvents"),b.initUIEvent("scroll",false,true,window,1),a.docscroll[0].dispatchEvent(b)):(b=document.createEventObject(),a.docscroll[0].fireEvent("onscroll"),b.cancelBubble=true)}:function(b){a.doc.css(a.trstyle,"translate(0px,"+b*-1+"px)");a.doc.translate.y=b;document.createEvent?(b=document.createEvent("UIEvents"),b.initUIEvent("scroll",false,true,window,1),a.docscroll[0].dispatchEvent(b)):
+(b=document.createEventObject(),a.docscroll[0].fireEvent("onscroll"),b.cancelBubble=true)}):(this.getScrollTop=function(){return a.docscroll.scrollTop()},this.setScrollTop=function(b){return a.docscroll.scrollTop(b)});this.getTarget=function(a){return!a?false:a.target?a.target:a.srcElement?a.srcElement:false};this.hasParent=function(a,c){if(!a)return false;for(var h=a.target||a.srcElement||a||false;h&&h.id!=c;)h=h.parentNode||false;return h!==false};this.updateScrollBar=function(){if(a.ishwscroll)a.rail.css({height:a.win.innerHeight()});
+else{var b=a.win.offset();b.top+=2;b.left+=a.win.outerWidth()-a.rail.width-5;a.rail.css({position:"absolute",top:b.top,left:b.left,height:a.win.outerHeight()});a.zoom&&a.zoom.css({position:"absolute",top:b.top+1,left:b.left-18})}};this.init=function(){if(!a.ispage||!a.cantouch&&!this.isieold){a.ispage?a.doc.css({"overflow-y":"hidden"}):a.docscroll.css({"overflow-y":"hidden"});var b=e(document.createElement("div"));b.attr("id",a.id);b.width=4+parseFloat(a.opt.cursorwidth);b.css({"padding-left":"4px",
+"padding-right":"1px",width:a.rail.width+"px","z-index":a.opt.zindex,opacity:a.cursoropacitymin});a.rail=b;var c=false;if(a.opt.boxzoom&&!a.ispage&&!a.isieold)c=document.createElement("div"),a.bind(c,"click",a.doZoom),a.zoom=e(c),a.zoom.css({cursor:"pointer","z-index":a.opt.zindex,backgroundImage:"url("+k+"zoomico.png)",height:18,width:18,backgroundPosition:"0px 0px"}),a.opt.dblclickzoom&&a.bind(a.win,"dblclick",a.doZoom),a.cantouch&&a.opt.gesturezoom&&a.bind(a.win,"gesturechange",function(b){b.scale>
+1.5&&a.doZoomIn(b);b.scale<0.8&&a.doZoomOut(b);return a.cancelEvent(b)});a.ispage?(b.css({position:"fixed",top:"0px",right:"0px",height:"100%"}),a.doc.append(b)):a.ishwscroll?(a.win.css("position")=="static"&&a.win.css("position","relative"),a.zoom&&(a.zoom.css({position:"absolute",top:1,right:0,"margin-right":b.width+2}),a.win.append(a.zoom)),b.css({position:"absolute",top:0,right:0}),a.win.append(b)):(a.updateScrollBar(),e("body").append(b),a.zoom&&e("body").append(a.zoom));b=e(document.createElement("div"));
+b.css({position:"relative",top:0,left:0,width:a.opt.cursorwidth,height:"0px","background-color":a.opt.cursorcolor,border:a.opt.cursorborder,"-webkit-border-radius":a.opt.cursorborderradius,"-moz-border-radius":a.opt.cursorborderradius,"border-radius":a.opt.cursorborderradius});a.cursor=b;a.rail.append(b);a.win.resize(a.onResize);a.doc.resize(a.onResize);!a.ispage&&a.opt.boxzoom&&e(window).resize(a.resizeZoom);a.onResize();a.cantouch||a.opt.touchbehavior?(a.bind(a.win,"mousedown",function(b){a.rail.drag=
+{x:b.pageX,y:b.pageY,sx:a.scroll.x,sy:a.scroll.y,st:a.getScrollTop()};return a.cancelEvent(b)}),a.bind(a.win,"mouseup",function(b){a.rail.drag=false;return a.cancelEvent(b)}),a.bind(a.rail,"mousedown",function(b){a.rail.drag={x:b.pageX,y:b.pageY,sx:a.scroll.x,sy:a.scroll.y,st:a.getScrollTop()};return a.cancelEvent(b)}),a.bind(a.rail,"mouseup",function(b){a.rail.drag=false;return a.cancelEvent(b)}),a.bind(document,"mousemove",function(b){if(a.rail.drag)return a.doScrollTo(a.rail.drag.st-(b.pageY-a.rail.drag.y),
+true),a.cancelEvent(b)})):(a.bind(a.rail,"mousedown",function(b){a.rail.drag={x:b.screenX,y:b.screenY,sx:a.scroll.x,sy:a.scroll.y};return a.cancelEvent(b)}),a.bind(a.rail,"mouseup",function(b){a.rail.drag=false;a.hideCursor();return a.cancelEvent(b)}),a.bind(document,"mousemove",function(b){if(a.rail.drag){a.scroll.y=a.rail.drag.sy+(b.screenY-a.rail.drag.y);if(a.scroll.y<0)a.scroll.y=0;var c=a.scrollvaluemax;if(a.scroll.y>c)a.scroll.y=c;a.showCursor();a.cursorfreezed=true;a.doScroll(Math.round(a.scroll.y*
+a.scrollratio.y));return a.cancelEvent(b)}}));a.bind(document,"mouseup",function(){a.rail.drag=false;a.hideCursor()});a.cantouch||(a.rail.mouseenter(function(){a.showCursor();a.rail.active=true}),a.rail.mouseleave(function(){a.rail.active=false;a.rail.drag||a.hideCursor()}),a.isiframe||a.bind(a.isie&&a.ispage?document:a.docscroll,"mousewheel",a.onmousewheel),a.bind(a.rail,"mousewheel",a.onmousewheel));!a.ispage&&!a.cantouch&&(a.win.attr("tabindex")||a.win.attr({tabindex:(new Date).getTime()}),a.win.focus(function(b){i=
+a.getTarget(b).id||true;a.hasfocus=true;a.noticeCursor()}),a.win.blur(function(){i=false;a.hasfocus=false}),a.win.mouseenter(function(b){j=a.getTarget(b).id||true;a.hasmousefocus=true;a.noticeCursor()}),a.win.mouseleave(function(){j=false;a.hasmousefocus=false}));a.onkeypress=function(b){var b=b?b:window.e,c=a.getTarget(b);if(!c||!/(INPUT|TEXTAREA|SELECT)/.test(c.nodeName))if(a.hasfocus||a.hasmousefocus&&!i||a.ispage&&!i&&!j){c=true;switch(b.keyCode){case 38:case 63233:a.doScrollBy(12);c=false;break;
+case 40:case 63235:a.doScrollBy(-12);c=false;break;case 33:case 63276:a.doScrollBy(a.view.h,true);c=false;break;case 34:case 63277:a.doScrollBy(-a.view.h,true);c=false;break;case 36:case 63273:a.doScrollTo(0,true);c=false;break;case 35:case 63275:a.doScrollTo(a.page.h,true);c=false;break;case 27:a.zoomactive&&(a.doZoom(),c=false)}if(!c)return a.cancelEvent(b)}};a.bind(document,"keydown",a.onkeypress)}};this.showCursor=function(){if(a.cursortimeout)clearTimeout(a.cursortimeout),a.cursortimeout=0;a.rail&&
+(a.rail.stop().css({opacity:a.opt.cursoropacitymax}),a.cursor.css({height:a.cursorheight,top:a.scroll.y}),a.zoom&&a.zoom.stop().css({opacity:a.opt.cursoropacitymax}))};this.hideCursor=function(b){if(!a.cursortimeout&&a.rail)a.cursortimeout=setTimeout(function(){a.rail.active||(e(a.rail).stop().animate({opacity:a.opt.cursoropacitymin}),a.zoom&&a.zoom.stop().animate({opacity:a.opt.cursoropacitymin}));a.cursortimeout=0},b||800)};this.noticeCursor=function(b){a.showCursor();a.hideCursor(b)};this.getContentSize=
+function(){var b=a.ispage?{w:Math.max(document.body.scrollWidth,document.documentElement.scrollWidth),h:Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)}:a.haswrapper?{w:a.doc.outerWidth()+parseInt(a.win.css("paddingLeft"))+parseInt(a.win.css("paddingRight")),h:a.doc.outerHeight()+parseInt(a.win.css("paddingTop"))+parseInt(a.win.css("paddingBottom"))}:{w:a.docscroll[0].scrollWidth,h:a.docscroll[0].scrollHeight};b.w-=1;b.h-=1;return b};this.onResize=function(){a.ispage||a.updateScrollBar();
+a.view={w:a.ispage?a.win.width():a.win.innerWidth(),h:a.ispage?a.win.height():a.win.innerHeight()};a.page=a.getContentSize();a.cursorheight=Math.min(a.view.h,Math.round(a.view.h*(a.view.h/a.page.h)));a.scrollvaluemax=a.view.h-a.cursorheight-2;a.scrollratio={x:0,y:(a.page.h-a.view.h)/a.scrollvaluemax};a.scroll.y=Math.round(a.getScrollTop()*(1/a.scrollratio.y));a.noticeCursor()};this.bind=function(b,c,d,e){var f=b.length?b[0]:b;f.addEventListener?(a.cantouch&&/mouseup|mousedown|mousemove/.test(c)&&
+f.addEventListener(c=="mousedown"?"touchstart":c=="mouseup"?"touchend":"touchmove",function(a){if(a.touches.length<2){var b=a.touches.length>0?a.touches[0]:a;b.original=a;d.call(this,b)}},e||false),f.addEventListener(c,d,e||false),c=="mousewheel"&&f.addEventListener("DOMMouseScroll",d,e||false)):f.attachEvent?f.attachEvent("on"+c,function(b){if(!d.call(f,b)||!e)return a.cancelEvent(b)}):f["on"+c]=function(b){if(!d.call(f,b)||!e)return a.cancelEvent(b)}};this.cancelEvent=function(b){b=a.cantouch?b?
+b.original:false:b?b:window.event||false;if(!b)return false;b.stopPropagation&&b.stopPropagation();b.preventDefault&&b.preventDefault();b.cancelBubble=true;b.cancel=true;return b.returnValue=false};this.onmousewheel=function(b){b=b?b:window.event;if(a.rail.drag)return a.cancelEvent(b);var c=0;(c=b.detail?b.detail*-1:b.wheelDelta/40)&&a.doScrollBy(c*a.opt.mousescrollstep,true);return a.cancelEvent(b)};this.stop=function(){a.timer&&clearInterval(a.timer);a.timer=0;a.cursorfreezed=false;a.scroll.y=Math.round(a.getScrollTop()*
+(1/a.scrollratio.y));a.noticeCursor()};this.doScroll=function(b){a.newscrolly=b;if(!a.timer)a.timer=setInterval(function(){var b=a.newscrolly-a.getScrollTop(),b=b>0?Math.ceil(b/4):Math.floor(b/4),b=a.getScrollTop()+b;a.setScrollTop(b);if(b==a.newscrolly)clearInterval(a.timer),a.timer=0,a.cursorfreezed=false},a.opt.scrollspeed),a.noticeCursor()};this.doScrollBy=function(b,c){c&&(b=Math.round(b*1/a.scrollratio.y));var d=a.scroll.y-b;d<0&&(d=0);var e=a.scrollvaluemax;d>e&&(d=e);a.cursorfreezed=false;
+a.doScroll(Math.floor(d*a.scrollratio.y))};this.doScrollTo=function(b,c){c&&(b=Math.round(b*1/a.scrollratio.y));ny=b;ny<0&&(ny=0);var d=a.scrollvaluemax;ny>d&&(ny=d);a.cursorfreezed=false;a.doScroll(Math.floor(ny*a.scrollratio.y))};a.onscroll=function(){var b=(new Date).getTime();if(!a.lastcontentcheck||a.lastcontentcheck<b)if(a.lastcontentcheck=b+500,a.getContentSize().h!=a.page.h)a.onResize();if(!a.rail.drag){if(!a.cursorfreezed)a.scroll.y=Math.round(a.getScrollTop()*(1/a.scrollratio.y));a.noticeCursor()}};
+a.docscroll.scroll(function(b){a.onscroll(b)});this.doZoomIn=function(b){if(!a.zoomactive){a.zoomrestore={style:{}};for(var c in a.win[0].style)a.zoomrestore.style[c]=a.win[0].style[c];a.zoomrestore.padding={w:a.win.outerWidth()-a.win.width(),h:a.win.outerHeight()-a.win.height()};a.win.css({position:"fixed",top:0,left:0,"z-index":a.opt.zindex+100});c=a.win.css("backgroundColor");(c==""||/transparent|rgba\(0, 0, 0, 0\)|rgba\(0,0,0,0\)/.test(c))&&a.win.css("backgroundColor","#fff");a.rail.css({"z-index":a.opt.zindex+
+110});a.zoom.css({"z-index":a.opt.zindex+112});a.zoomactive=true;a.zoom.css("backgroundPosition","0px -18px");a.resizeZoom();return a.cancelEvent(b)}};this.doZoomOut=function(b){if(a.zoomactive){var c=a.zoomrestore.style;a.win.css({position:c.position||"",top:c.top||"",left:c.left||"",width:c.width||"",height:c.height||"","z-index":c.zIndex||"",backgroundColor:c.backgroundColor||""});a.rail.css({"z-index":a.opt.zindex});a.zoom.css({"z-index":a.opt.zindex});a.zoomactive=false;a.zoomrestore=false;a.zoom.css("backgroundPosition",
+"0px 0px");a.win.resize();return a.cancelEvent(b)}};this.doZoom=function(b){return a.zoomactive?a.doZoomOut(b):a.doZoomIn(b)};this.resizeZoom=function(){if(a.zoomactive){var b=a.getScrollTop();a.win.css({width:e(window).width()-a.zoomrestore.padding.w+"px",height:e(window).height()-a.zoomrestore.padding.h+"px"});a.setScrollTop(b);a.win.resize()}};this.init()};e.fn.niceScroll=function(d,a){typeof d=="object"&&typeof a=="undefined"&&(a=d,d=false);var g=[];typeof a=="undefined"&&(a={});if(d)a.doc=e(d),
+a.win=e(this);var b=!("doc"in a);this.each(function(){a.doc=b?e(this):a.doc;g.push(new l(a))});return g.length==1?g[0]:g}})(jQuery);

BIN
zoomico.png