增加后台功能
This commit is contained in:
@@ -0,0 +1,270 @@
|
||||
|
||||
|
||||
/**
|
||||
* hasOwnProperty.
|
||||
*/
|
||||
|
||||
var has = Object.prototype.hasOwnProperty;
|
||||
|
||||
/**
|
||||
* Require the given path.
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {Object} exports
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function require(path, parent, orig) {
|
||||
var resolved = require.resolve(path);
|
||||
|
||||
// lookup failed
|
||||
if (null == resolved) {
|
||||
orig = orig || path;
|
||||
parent = parent || 'root';
|
||||
var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
|
||||
err.path = orig;
|
||||
err.parent = parent;
|
||||
err.require = true;
|
||||
throw err;
|
||||
}
|
||||
|
||||
var module = require.modules[resolved];
|
||||
|
||||
// perform real require()
|
||||
// by invoking the module's
|
||||
// registered function
|
||||
if (!module.exports) {
|
||||
module.exports = {};
|
||||
module.client = module.component = true;
|
||||
module.call(this, module.exports, require.relative(resolved), module);
|
||||
}
|
||||
|
||||
return module.exports;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registered modules.
|
||||
*/
|
||||
|
||||
require.modules = {};
|
||||
|
||||
/**
|
||||
* Registered aliases.
|
||||
*/
|
||||
|
||||
require.aliases = {};
|
||||
|
||||
/**
|
||||
* Resolve `path`.
|
||||
*
|
||||
* Lookup:
|
||||
*
|
||||
* - PATH/index.js
|
||||
* - PATH.js
|
||||
* - PATH
|
||||
*
|
||||
* @param {String} path
|
||||
* @return {String} path or null
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.resolve = function(path) {
|
||||
if (path.charAt(0) === '/') path = path.slice(1);
|
||||
var index = path + '/index.js';
|
||||
|
||||
var paths = [
|
||||
path,
|
||||
path + '.js',
|
||||
path + '.json',
|
||||
path + '/index.js',
|
||||
path + '/index.json'
|
||||
];
|
||||
|
||||
for (var i = 0; i < paths.length; i++) {
|
||||
var path = paths[i];
|
||||
if (has.call(require.modules, path)) return path;
|
||||
}
|
||||
|
||||
if (has.call(require.aliases, index)) {
|
||||
return require.aliases[index];
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Normalize `path` relative to the current path.
|
||||
*
|
||||
* @param {String} curr
|
||||
* @param {String} path
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.normalize = function(curr, path) {
|
||||
var segs = [];
|
||||
|
||||
if ('.' != path.charAt(0)) return path;
|
||||
|
||||
curr = curr.split('/');
|
||||
path = path.split('/');
|
||||
|
||||
for (var i = 0; i < path.length; ++i) {
|
||||
if ('..' == path[i]) {
|
||||
curr.pop();
|
||||
} else if ('.' != path[i] && '' != path[i]) {
|
||||
segs.push(path[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return curr.concat(segs).join('/');
|
||||
};
|
||||
|
||||
/**
|
||||
* Register module at `path` with callback `definition`.
|
||||
*
|
||||
* @param {String} path
|
||||
* @param {Function} definition
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.register = function(path, definition) {
|
||||
require.modules[path] = definition;
|
||||
};
|
||||
|
||||
/**
|
||||
* Alias a module definition.
|
||||
*
|
||||
* @param {String} from
|
||||
* @param {String} to
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.alias = function(from, to) {
|
||||
if (!has.call(require.modules, from)) {
|
||||
throw new Error('Failed to alias "' + from + '", it does not exist');
|
||||
}
|
||||
require.aliases[to] = from;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return a require function relative to the `parent` path.
|
||||
*
|
||||
* @param {String} parent
|
||||
* @return {Function}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
require.relative = function(parent) {
|
||||
var p = require.normalize(parent, '..');
|
||||
|
||||
/**
|
||||
* lastIndexOf helper.
|
||||
*/
|
||||
|
||||
function lastIndexOf(arr, obj) {
|
||||
var i = arr.length;
|
||||
while (i--) {
|
||||
if (arr[i] === obj) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* The relative require() itself.
|
||||
*/
|
||||
|
||||
function localRequire(path) {
|
||||
var resolved = localRequire.resolve(path);
|
||||
return require(resolved, parent, path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve relative to the parent.
|
||||
*/
|
||||
|
||||
localRequire.resolve = function(path) {
|
||||
var c = path.charAt(0);
|
||||
if ('/' == c) return path.slice(1);
|
||||
if ('.' == c) return require.normalize(p, path);
|
||||
|
||||
// resolve deps by returning
|
||||
// the dep in the nearest "deps"
|
||||
// directory
|
||||
var segs = parent.split('/');
|
||||
var i = lastIndexOf(segs, 'deps') + 1;
|
||||
if (!i) i = 0;
|
||||
path = segs.slice(0, i + 1).join('/') + '/deps/' + path;
|
||||
return path;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if module is defined at `path`.
|
||||
*/
|
||||
|
||||
localRequire.exists = function(path) {
|
||||
return has.call(require.modules, localRequire.resolve(path));
|
||||
};
|
||||
|
||||
return localRequire;
|
||||
};
|
||||
require.register("horwheel/index.js", function(exports, require, module){
|
||||
// a.onwheel = function (e) {
|
||||
// e.preventDefault();
|
||||
// a.scrollLeft += (e.deltaY*40);
|
||||
// };
|
||||
|
||||
// FF viejo
|
||||
// a.addEventListener('DOMMouseScroll', function (e) {
|
||||
// e.preventDefault();
|
||||
// a.scrollLeft += (e.detail*40);
|
||||
// }, false);
|
||||
|
||||
// a.onmousewheel = function (e) {
|
||||
// e = e || window.event;
|
||||
// a.scrollLeft -= (e.detail === undefined || e.detail === 0) ? e.wheelDelta : -e.detail*40;
|
||||
|
||||
// Delta
|
||||
// wheelDelta / 120;
|
||||
// -event.detail / 3;
|
||||
|
||||
// // Opera on window need: -e.detail*40;
|
||||
// // Opera on osx doesn't need *40
|
||||
// return false;
|
||||
// };
|
||||
/**
|
||||
* Privates
|
||||
*/
|
||||
var bind = (window.addEventListener !== undefined) ? 'addEventListener' : 'attachEvent',
|
||||
wheel = (window.onwheel !== undefined) ? 'wheel' :
|
||||
(window.onmousewheel !== undefined) ? 'mousewheel' :
|
||||
(window.attachEvent) ? 'onmousewheel' : 'DOMMouseScroll';
|
||||
|
||||
function horizontalWheel(eve, el) {
|
||||
el.scrollLeft += (eve.deltaY !== undefined) ? eve.deltaY :
|
||||
(eve.detail !== undefined && eve.detail !== 0) ? eve.detail :
|
||||
-eve.wheelDelta;
|
||||
}
|
||||
|
||||
/**
|
||||
* horwheel
|
||||
*/
|
||||
function horwheel(el) {
|
||||
if (el === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
document[bind](wheel, function (eve) {
|
||||
eve = eve || window.eve;
|
||||
if (eve.preventDefault) {
|
||||
eve.preventDefault();
|
||||
}
|
||||
horizontalWheel(eve, el);
|
||||
return false;
|
||||
}, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expose horwheel
|
||||
*/
|
||||
exports = module.exports = horwheel;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user