enyo / opentip

Opentip is an open source javascript tooltip based on the protoype framework.
http://www.opentip.org
1.25k stars 401 forks source link

Browserify support #122

Open franciscolourenco opened 9 years ago

franciscolourenco commented 9 years ago
path.js:313
        throw new TypeError('Arguments to path.resolve must be strings');
        ^
TypeError: Arguments to path.resolve must be strings
    at Object.exports.resolve (path.js:313:15)
    at /usr/local/lib/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:97:37
    at fs.js:272:14
    at Object.oncomplete (fs.js:108:15)
dottodot commented 8 years ago

Same issue for me too.

x-yuri commented 8 years ago

I was able to overcome it by fixing package.json's main field (set it to just "./lib/opentip.js"). But that's not all if you want to use native adapter. The thing is, the native adapter automatically tries to attach itself to opentip at the end of the file. The workaround is to create /opentip.js (relative to document root) of the following content:

/opentip.js:

var Opentip = require('./node_modules/opentip/lib/opentip.js');
<here goes contents of /lib/adapter-native.js>
module.exports = Opentip;

Then you can do the following:

/index.html:

<!doctype html>
<html>
<head>
    <link href="/opentip.css" rel="stylesheet" type="text/css">
</head>
<body>
    <input id="i1" type="text">
    <script src="/bundle.js"></script>
</body>
</html>

/index.js:

var Opentip = require('./opentip.js');
new Opentip('#i1', 'Optional content', {
    target: document.getElementById('i1')
    , targetJoint: 'right'
    , tipJoint: 'left'
    , showOn: 'focus'
    , hideOn: 'blur'
    , style: 'alert'
    , fixed: true
})
$ browserify index.js -o bundle.js

Looking forward to a better workaround...