This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
get exact cross browser mouse event coordinates workarounds (relative to offset parent) | |
*/ | |
/* with jquery */ | |
var x = event.offsetX || event.clientX - $(event.target).offset().left, | |
y = event.offsetY || event.clientY - $(event.target).offset().top; | |
/* on svg raphael paper */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
HELPER - extend raphael: draggable elements | |
*/ | |
Raphael.el.draggable = function(){ | |
//state | |
this.attr({cursor: "move"}); | |
this.drag( | |
//move | |
function(dx,dy){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Raphael.js: unbind all event listeners from an element | |
*/ | |
Raphael.el.unbindAll = function(){ | |
while(this.events.length){ | |
var e = this.events.pop(); | |
e.unbind(); | |
}; | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
extending Raphael.js: draggable sets | |
*/ | |
Raphael.st.draggable = function() { | |
var _this = this, | |
lx = 0, | |
ly = 0, | |
ox = 0, | |
oy = 0, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
DRAGGABLE PATHS IN RAPHAEL | |
hint: convert the x and y deltas into translate values which the path object understands | |
*/ | |
Raphael.el.draggablePath = function(){ | |
this.attr({cursor: "move"}); | |
this.drag( | |
function(dx,dy){ | |
this.translate(dx - this.odx, dy - this.ody); | |
this.odx = dx; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
export whole canvas as JSON via RaphaelJSON | |
*/ | |
exportJSON:function(){ | |
var _this = this, | |
json = this.paper.toJSON(function(el, data){ | |
data.ft = {}; | |
if ( el.freeTransform != null ){ | |
data.ft.attrs = el.freeTransform.attrs; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Raphael.js: find the center of element | |
*/ | |
// element = paper.rect(......); | |
var cX = element.getBBox().x + element.getBBox().width/2, | |
cY = element.getBBox().y + element.getBBox().height/2; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.product-page dl{ | |
overflow: hidden; | |
width:100%; | |
} | |
.product-page dt{ | |
width: 30%; | |
font-weight: bold; | |
} | |
.product-page dd{ | |
width: 70%; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*============================== | |
BROWSER DETECTION | |
================================ | |
quick: console.log(/WebKit/.test(navigator.userAgent)) */ | |
function getBrowser(){ | |
var ua = window.navigator.userAgent.toLowerCase(); | |
var ver = window.navigator.appVersion.toLowerCase(); | |
var name = 'unknown'; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//============================== | |
//JAVASCRIPT @MEDIA QUERIES | |
//================================ | |
var widthMax832px = window.matchMedia('(max-width: 832px)'); | |
console.log('widthMax832px: ', widthMax832px); | |
//always check if window.matchMedia exist (older IE can crash on this. If still needed, use Paul Irish polyfill) | |
if(window.matchMedia && window.matchMedia("(max-width: 1201px)").matches) { |
OlderNewer