Вход Регистрация
Файл: Luxe-Shop v6.0/templates/Mac_3.2/js/ZeroClipboard.js
Строк: 916
<?php
/*!
* ZeroClipboard
* The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface.
* Copyright (c) 2013 Jon Rohan, James M. Greene
* Licensed MIT
* http://zeroclipboard.org/
* v1.2.3
*/
(function() {
  
"use strict";
  var 
currentElement;
  var 
gluedElements = [];
  var 
flashState = {
    global: {
      
noflashnull,
      
wrongflashnull,
      
version"0.0.0"
    
},
    
clients: {}
  };
  var 
_camelizeCssPropName = function() {
    var 
matcherRegex = /-([a-z])/greplacerFn = function(matchgroup) {
      return 
group.toUpperCase();
    };
    return function(
prop) {
      return 
prop.replace(matcherRegexreplacerFn);
    };
  }();
  var 
_getStyle = function(elprop) {
    var 
valuecamelProptagNamepossiblePointersilen;
    if (
window.getComputedStyle) {
      
value window.getComputedStyle(elnull).getPropertyValue(prop);
    } else {
      
camelProp _camelizeCssPropName(prop);
      if (
el.currentStyle) {
        
value el.currentStyle[camelProp];
      } else {
        
value el.style[camelProp];
      }
    }
    if (
prop === "cursor") {
      if (!
value || value === "auto") {
        
tagName el.tagName.toLowerCase();
        
possiblePointers = [ "a" ];
        for (
0len possiblePointers.lengthleni++) {
          if (
tagName === possiblePointers[i]) {
            return 
"pointer";
          }
        }
      }
    }
    return 
value;
  };
  var 
_elementMouseOver = function(event) {
    if (!
ZeroClipboard.prototype._singleton) return;
    if (!
event) {
      
event window.event;
    }
    var 
target;
    if (
this !== window) {
      
target this;
    } else if (
event.target) {
      
target event.target;
    } else if (
event.srcElement) {
      
target event.srcElement;
    }
    
ZeroClipboard.prototype._singleton.setCurrent(target);
  };
  var 
_addEventHandler = function(elementmethodfunc) {
    if (
element.addEventListener) {
      
element.addEventListener(methodfuncfalse);
    } else if (
element.attachEvent) {
      
element.attachEvent("on" methodfunc);
    }
  };
  var 
_removeEventHandler = function(elementmethodfunc) {
    if (
element.removeEventListener) {
      
element.removeEventListener(methodfuncfalse);
    } else if (
element.detachEvent) {
      
element.detachEvent("on" methodfunc);
    }
  };
  var 
_addClass = function(elementvalue) {
    if (
element.addClass) {
      
element.addClass(value);
      return 
element;
    }
    if (
value && typeof value === "string") {
      var 
classNames = (value || "").split(/s+/);
      if (
element.nodeType === 1) {
        if (!
element.className) {
          
element.className value;
        } else {
          var 
className " " element.className " "setClass element.className;
          for (var 
0cl classNames.lengthclc++) {
            if (
className.indexOf(" " classNames[c] + " ") < 0) {
              
setClass += " " classNames[c];
            }
          }
          
element.className setClass.replace(/^s+|s+$/g"");
        }
      }
    }
    return 
element;
  };
  var 
_removeClass = function(elementvalue) {
    if (
element.removeClass) {
      
element.removeClass(value);
      return 
element;
    }
    if (
value && typeof value === "string" || value === undefined) {
      var 
classNames = (value || "").split(/s+/);
      if (
element.nodeType === && element.className) {
        if (
value) {
          var 
className = (" " element.className " ").replace(/[nt]/g" ");
          for (var 
0cl classNames.lengthclc++) {
            
className className.replace(" " classNames[c] + " "" ");
          }
          
element.className className.replace(/^s+|s+$/g"");
        } else {
          
element.className "";
        }
      }
    }
    return 
element;
  };
  var 
_getZoomFactor = function() {
    var 
rectphysicalWidthlogicalWidthzoomFactor 1;
    if (
typeof document.body.getBoundingClientRect === "function") {
      
rect document.body.getBoundingClientRect();
      
physicalWidth rect.right rect.left;
      
logicalWidth document.body.offsetWidth;
      
zoomFactor Math.round(physicalWidth logicalWidth 100) / 100;
    }
    return 
zoomFactor;
  };
  var 
_getDOMObjectPosition = function(objdefaultZIndex) {
    var 
info = {
      
left0,
      
top0,
      
width0,
      
height0,
      
zIndex_getSafeZIndex(defaultZIndex) - 1
    
};
    if (
obj.getBoundingClientRect) {
      var 
rect obj.getBoundingClientRect();
      var 
pageXOffsetpageYOffsetzoomFactor;
      if (
"pageXOffset" in window && "pageYOffset" in window) {
        
pageXOffset window.pageXOffset;
        
pageYOffset window.pageYOffset;
      } else {
        
zoomFactor _getZoomFactor();
        
pageXOffset Math.round(document.documentElement.scrollLeft zoomFactor);
        
pageYOffset Math.round(document.documentElement.scrollTop zoomFactor);
      }
      var 
leftBorderWidth document.documentElement.clientLeft || 0;
      var 
topBorderWidth document.documentElement.clientTop || 0;
      
info.left rect.left pageXOffset leftBorderWidth;
      
info.top rect.top pageYOffset topBorderWidth;
      
info.width "width" in rect rect.width rect.right rect.left;
      
info.height "height" in rect rect.height rect.bottom rect.top;
    }
    return 
info;
  };
  var 
_noCache = function(pathoptions) {
    var 
useNoCache = !(options && options.useNoCache === false);
    if (
useNoCache) {
      return (
path.indexOf("?") === -"?" "&") + "nocache=" + new Date().getTime();
    } else {
      return 
"";
    }
  };
  var 
_vars = function(options) {
    var 
str = [];
    var 
origins = [];
    if (
options.trustedOrigins) {
      if (
typeof options.trustedOrigins === "string") {
        
origins.push(options.trustedOrigins);
      } else if (
typeof options.trustedOrigins === "object" && "length" in options.trustedOrigins) {
        
origins origins.concat(options.trustedOrigins);
      }
    }
    if (
options.trustedDomains) {
      if (
typeof options.trustedDomains === "string") {
        
origins.push(options.trustedDomains);
      } else if (
typeof options.trustedDomains === "object" && "length" in options.trustedDomains) {
        
origins origins.concat(options.trustedDomains);
      }
    }
    if (
origins.length) {
      
str.push("trustedOrigins=" encodeURIComponent(origins.join(",")));
    }
    if (
typeof options.amdModuleId === "string" && options.amdModuleId) {
      
str.push("amdModuleId=" encodeURIComponent(options.amdModuleId));
    }
    if (
typeof options.cjsModuleId === "string" && options.cjsModuleId) {
      
str.push("cjsModuleId=" encodeURIComponent(options.cjsModuleId));
    }
    return 
str.join("&");
  };
  var 
_inArray = function(elem, array) {
    if (array.
indexOf) {
      return array.
indexOf(elem);
    }
    for (var 
0length = array.lengthlengthi++) {
      if (array[
i] === elem) {
        return 
i;
      }
    }
    return -
1;
  };
  var 
_prepGlue = function(elements) {
    if (
typeof elements === "string") throw new TypeError("ZeroClipboard doesn't accept query strings.");
    if (!
elements.length) return [ elements ];
    return 
elements;
  };
  var 
_dispatchCallback = function(funcelementinstanceargsasync) {
    if (
async) {
      
window.setTimeout(function() {
        
func.call(elementinstanceargs);
      }, 
0);
    } else {
      
func.call(elementinstanceargs);
    }
  };
  var 
_getSafeZIndex = function(val) {
    var 
zIndextmp;
    if (
val) {
      if (
typeof val === "number" && val 0) {
        
zIndex val;
      } else if (
typeof val === "string" && (tmp parseInt(val10)) && !isNaN(tmp) && tmp 0) {
        
zIndex tmp;
      }
    }
    if (!
zIndex) {
      if (
typeof _defaults.zIndex === "number" && _defaults.zIndex 0) {
        
zIndex _defaults.zIndex;
      } else if (
typeof _defaults.zIndex === "string" && (tmp parseInt(_defaults.zIndex10)) && !isNaN(tmp) && tmp 0) {
        
zIndex tmp;
      }
    }
    return 
zIndex || 0;
  };
  var 
_deprecationWarning = function(deprecatedApiNamedebugEnabled) {
    if (
deprecatedApiName && debugEnabled !== false && typeof console !== "undefined" && console && (console.warn || console.log)) {
      var 
deprecationWarning "`" deprecatedApiName "` is deprecated. See docs for more info:n" "    https://github.com/zeroclipboard/zeroclipboard/blob/master/docs/instructions.md#deprecations";
      if (
console.warn) {
        
console.warn(deprecationWarning);
      } else {
        
console.log(deprecationWarning);
      }
    }
  };
  var 
ZeroClipboard = function(elementsoptions) {
    if (
elements) (ZeroClipboard.prototype._singleton || this).glue(elements);
    if (
ZeroClipboard.prototype._singleton) return ZeroClipboard.prototype._singleton;
    
ZeroClipboard.prototype._singleton this;
    
this.options = {};
    for (var 
kd in _defaultsthis.options[kd] = _defaults[kd];
    for (var 
ko in optionsthis.options[ko] = options[ko];
    
this.handlers = {};
    if (
typeof flashState.global.noflash !== "boolean") {
      
flashState.global.noflash = !_detectFlashSupport();
    }
    if (!
flashState.clients.hasOwnProperty(this.options.moviePath)) {
      
flashState.clients[this.options.moviePath] = {
        
readyfalse
      
};
    }
    if (
flashState.global.noflash === false) {
      
_bridge();
    }
  };
  
ZeroClipboard.prototype.setCurrent = function(element) {
    
currentElement element;
    
_reposition.call(this);
    var 
titleAttr element.getAttribute("title");
    if (
titleAttr) {
      
this.setTitle(titleAttr);
    }
    var 
useHandCursor this.options.forceHandCursor === true || _getStyle(element"cursor") === "pointer";
    
_setHandCursor.call(thisuseHandCursor);
    return 
this;
  };
  
ZeroClipboard.prototype.setText = function(newText) {
    if (
newText && newText !== "") {
      
this.options.text newText;
      if (
this.ready()) this.flashBridge.setText(newText);
    }
    return 
this;
  };
  
ZeroClipboard.prototype.setTitle = function(newTitle) {
    if (
newTitle && newTitle !== ""this.htmlBridge.setAttribute("title"newTitle);
    return 
this;
  };
  
ZeroClipboard.prototype.setSize = function(widthheight) {
    if (
this.ready()) this.flashBridge.setSize(widthheight);
    return 
this;
  };
  var 
_setHandCursor = function(enabled) {
    if (
this.ready()) this.flashBridge.setHandCursor(enabled);
  };
  var 
_detectFlashSupport = function() {
    var 
hasFlash false;
    if (
typeof flashState.global.noflash === "boolean") {
      
hasFlash flashState.global.noflash === false;
    } else {
      if (
typeof ActiveXObject === "function") {
        try {
          if (new 
ActiveXObject("ShockwaveFlash.ShockwaveFlash")) {
            
hasFlash true;
          }
        } catch (
error) {}
      }
      if (!
hasFlash && navigator.mimeTypes["application/x-shockwave-flash"]) {
        
hasFlash true;
      }
    }
    return 
hasFlash;
  };
  
ZeroClipboard.version "1.2.3";
  var 
_defaults = {
    
moviePath"ZeroClipboard.swf",
    
trustedOriginsnull,
    
textnull,
    
hoverClass"zeroclipboard-is-hover",
    
activeClass"zeroclipboard-is-active",
    
allowScriptAccess"sameDomain",
    
useNoCachetrue,
    
forceHandCursorfalse,
    
zIndex999999999,
    
debugtrue
  
};
  
ZeroClipboard.setDefaults = function(options) {
    for (var 
ko in options_defaults[ko] = options[ko];
  };
  
ZeroClipboard.destroy = function() {
    if (
ZeroClipboard.prototype._singleton) {
      
ZeroClipboard.prototype._singleton.unglue(gluedElements);
      var 
bridge ZeroClipboard.prototype._singleton.htmlBridge;
      if (
bridge && bridge.parentNode) {
        
bridge.parentNode.removeChild(bridge);
      }
      
delete ZeroClipboard.prototype._singleton;
    }
  };
  var 
_amdModuleId null;
  var 
_cjsModuleId null;
  var 
_bridge = function() {
    var 
flashBridgelen;
    var 
client ZeroClipboard.prototype._singleton;
    var 
container document.getElementById("global-zeroclipboard-html-bridge");
    if (!
container) {
      var 
opts = {};
      for (var 
ko in client.optionsopts[ko] = client.options[ko];
      
opts.amdModuleId _amdModuleId;
      
opts.cjsModuleId _cjsModuleId;
      var 
flashvars _vars(opts);
      var 
html '      <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="global-zeroclipboard-flash-bridge" width="100%" height="100%">         <param name="movie" value="' client.options.moviePath _noCache(client.options.moviePathclient.options) + '"/>         <param name="allowScriptAccess" value="' client.options.allowScriptAccess '"/>         <param name="scale" value="exactfit"/>         <param name="loop" value="false"/>         <param name="menu" value="false"/>         <param name="quality" value="best" />         <param name="bgcolor" value="#ffffff"/>         <param name="wmode" value="transparent"/>         <param name="flashvars" value="' flashvars '"/>         <embed src="' client.options.moviePath _noCache(client.options.moviePathclient.options) + '"           loop="false" menu="false"           quality="best" bgcolor="#ffffff"           width="100%" height="100%"           name="global-zeroclipboard-flash-bridge"           allowScriptAccess="always"           allowFullScreen="false"           type="application/x-shockwave-flash"           wmode="transparent"           pluginspage="http://www.macromedia.com/go/getflashplayer"           flashvars="' flashvars '"           scale="exactfit">         </embed>       </object>';
      
container document.createElement("div");
      
container.id "global-zeroclipboard-html-bridge";
      
container.setAttribute("class""global-zeroclipboard-container");
      
container.style.position "absolute";
      
container.style.left "0px";
      
container.style.top "-9999px";
      
container.style.width "15px";
      
container.style.height "15px";
      
container.style.zIndex "" _getSafeZIndex(client.options.zIndex);
      
document.body.appendChild(container);
      
container.innerHTML html;
    }
    
client.htmlBridge container;
    
flashBridge document["global-zeroclipboard-flash-bridge"];
    if (
flashBridge && (len flashBridge.length)) {
      
flashBridge flashBridge[len 1];
    }
    
client.flashBridge flashBridge || container.children[0].lastElementChild;
  };
  
ZeroClipboard.prototype.resetBridge = function() {
    if (
this.htmlBridge) {
      
this.htmlBridge.style.left "0px";
      
this.htmlBridge.style.top "-9999px";
      
this.htmlBridge.removeAttribute("title");
    }
    if (
currentElement) {
      
_removeClass(currentElementthis.options.activeClass);
      
currentElement null;
    }
    
this.options.text null;
    return 
this;
  };
  
ZeroClipboard.prototype.ready = function() {
    return 
flashState.clients[this.options.moviePath].ready === true;
  };
  var 
_reposition = function() {
    if (
currentElement) {
      var 
pos _getDOMObjectPosition(currentElementthis.options.zIndex);
      
this.htmlBridge.style.top pos.top "px";
      
this.htmlBridge.style.left pos.left "px";
      
this.htmlBridge.style.width pos.width "px";
      
this.htmlBridge.style.height pos.height "px";
      
this.htmlBridge.style.zIndex pos.zIndex 1;
      
this.setSize(pos.widthpos.height);
    }
    return 
this;
  };
  
ZeroClipboard.dispatch = function(eventNameargs) {
    if (
typeof eventName === "string" && eventName) {
      var 
client ZeroClipboard.prototype._singleton;
      var 
cleanEventName eventName.toLowerCase().replace(/^on/, "");
      if (
cleanEventName) {
        
_receiveEvent.call(clientcleanEventNameargs);
      }
    }
  };
  
ZeroClipboard.prototype.on = function(eventNamefunc) {
    var 
events eventName.toString().split(/s/g), added = {};
    for (var 
0len events.lengthleni++) {
      
eventName events[i].toLowerCase().replace(/^on/, "");
      
added[eventName] = true;
      if (!
this.handlers[eventName]) {
        
this.handlers[eventName] = func;
      }
    }
    if (
added.noflash && flashState.global.noflash) {
      
_receiveEvent.call(this"onNoFlash", {});
    }
    if (
added.wrongflash && flashState.global.wrongflash) {
      
_receiveEvent.call(this"onWrongFlash", {
        
flashVersionflashState.global.version
      
});
    }
    if (
added.load && flashState.clients[this.options.moviePath].ready) {
      
_receiveEvent.call(this"onLoad", {
        
flashVersionflashState.global.version
      
});
    }
    return 
this;
  };
  
ZeroClipboard.prototype.addEventListener ZeroClipboard.prototype.on;
  
ZeroClipboard.prototype.off = function(eventNamefunc) {
    var 
events eventName.toString().split(/s/g);
    for (var 
0events.lengthi++) {
      
eventName events[i].toLowerCase().replace(/^on/, "");
      for (var 
event in this.handlers) {
        if (
event === eventName && this.handlers[event] === func) {
          
delete this.handlers[event];
        }
      }
    }
    return 
this;
  };
  
ZeroClipboard.prototype.removeEventListener ZeroClipboard.prototype.off;
  var 
_receiveEvent = function(eventNameargs) {
    
eventName eventName.toString().toLowerCase().replace(/^on/, "");
    var 
element currentElement;
    var 
performCallbackAsync true;
    switch (
eventName) {
     case 
"load":
      if (
args && args.flashVersion) {
        if (!
_isFlashVersionSupported(args.flashVersion)) {
          
_receiveEvent.call(this"onWrongFlash", {
            
flashVersionargs.flashVersion
          
});
          return;
        }
        
flashState.clients[this.options.moviePath].ready true;
        
flashState.global.version args.flashVersion;
      }
      break;

     case 
"wrongflash":
      if (
args && args.flashVersion && !_isFlashVersionSupported(args.flashVersion)) {
        
flashState.global.wrongflash true;
        
flashState.global.version args.flashVersion;
      }
      break;

     case 
"mouseover":
      
_addClass(elementthis.options.hoverClass);
      break;

     case 
"mouseout":
      
_removeClass(elementthis.options.hoverClass);
      
this.resetBridge();
      break;

     case 
"mousedown":
      
_addClass(elementthis.options.activeClass);
      break;

     case 
"mouseup":
      
_removeClass(elementthis.options.activeClass);
      break;

     case 
"datarequested":
      var 
targetId element.getAttribute("data-clipboard-target"), targetEl = !targetId null document.getElementById(targetId);
      if (
targetEl) {
        var 
textContent targetEl.value || targetEl.textContent || targetEl.innerText;
        if (
textContent) {
          
this.setText(textContent);
        }
      } else {
        var 
defaultText element.getAttribute("data-clipboard-text");
        if (
defaultText) {
          
this.setText(defaultText);
        }
      }
      
performCallbackAsync false;
      break;

     case 
"complete":
      
this.options.text null;
      break;
    }
    if (
this.handlers[eventName]) {
      var 
func this.handlers[eventName];
      if (
typeof func === "string" && typeof window[func] === "function") {
        
func window[func];
      }
      if (
typeof func === "function") {
        
_dispatchCallback(funcelementthisargsperformCallbackAsync);
      }
    }
  };
  
ZeroClipboard.prototype.glue = function(elements) {
    
elements _prepGlue(elements);
    for (var 
0elements.lengthi++) {
      if (
elements[i] && elements[i].nodeType === 1) {
        if (
_inArray(elements[i], gluedElements) == -1) {
          
gluedElements.push(elements[i]);
          
_addEventHandler(elements[i], "mouseover"_elementMouseOver);
        }
      }
    }
    return 
this;
  };
  
ZeroClipboard.prototype.unglue = function(elements) {
    
elements _prepGlue(elements);
    for (var 
0elements.lengthi++) {
      
_removeEventHandler(elements[i], "mouseover"_elementMouseOver);
      var 
arrayIndex _inArray(elements[i], gluedElements);
      if (
arrayIndex != -1gluedElements.splice(arrayIndex1);
    }
    return 
this;
  };
  function 
_isFlashVersionSupported(flashVersion) {
    return 
parseFloat(flashVersion.replace(/,/g".").replace(/[^0-9.]/g"")) >= 10;
  }
  
ZeroClipboard.detectFlashSupport = function() {
    var 
debugEnabled ZeroClipboard.prototype._singleton && ZeroClipboard.prototype._singleton.options.debug || _defaults.debug;
    
_deprecationWarning("ZeroClipboard.detectFlashSupport"debugEnabled);
    return 
_detectFlashSupport();
  };
  
ZeroClipboard.prototype.setHandCursor = function(enabled) {
    
_deprecationWarning("ZeroClipboard.prototype.setHandCursor"this.options.debug);
    
enabled typeof enabled === "boolean" enabled : !!enabled;
    
_setHandCursor.call(thisenabled);
    
this.options.forceHandCursor enabled;
    return 
this;
  };
  
ZeroClipboard.prototype.reposition = function() {
    
_deprecationWarning("ZeroClipboard.prototype.reposition"this.options.debug);
    return 
_reposition.call(this);
  };
  
ZeroClipboard.prototype.receiveEvent = function(eventNameargs) {
    
_deprecationWarning("ZeroClipboard.prototype.receiveEvent"this.options.debug);
    if (
typeof eventName === "string" && eventName) {
      var 
cleanEventName eventName.toLowerCase().replace(/^on/, "");
      if (
cleanEventName) {
        
_receiveEvent.call(thiscleanEventNameargs);
      }
    }
  };
  if (
typeof define === "function" && define.amd) {
    
define([ "require""exports""module" ], function(require, exportsmodule) {
      
_amdModuleId module && module.id || null;
      return 
ZeroClipboard;
    });
  } else if (
typeof module === "object" && module && typeof module.exports === "object" && module.exports) {
    
_cjsModuleId module.id || null;
    
module.exports ZeroClipboard;
  } else {
    
window.ZeroClipboard ZeroClipboard;
  }
})();
?>
Онлайн: 2
Реклама