add bespoke.js v1.0.0

This commit is contained in:
Peter Dave Hello
2014-08-01 10:55:11 +08:00
parent e176aa7166
commit afc005a78e
3 changed files with 92 additions and 1 deletions
+89
View File
@@ -0,0 +1,89 @@
/*!
* Bespoke.js v1.0.0
*
* Copyright 2014, Mark Dalgleish
* This content is released under the MIT license
* http://mit-license.org/markdalgleish
*/
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.bespoke=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
var from = function(selectorOrElement, plugins) {
var parent = selectorOrElement.nodeType === 1 ? selectorOrElement : document.querySelector(selectorOrElement),
slides = [].filter.call(parent.children, function(el) { return el.nodeName !== 'SCRIPT'; }),
activeSlide = slides[0],
listeners = {},
activate = function(index, customData) {
if (!slides[index]) {
return;
}
fire('deactivate', createEventData(activeSlide, customData));
activeSlide = slides[index];
fire('activate', createEventData(activeSlide, customData));
},
slide = function(index, customData) {
if (arguments.length) {
fire('slide', createEventData(slides[index], customData)) && activate(index, customData);
} else {
return slides.indexOf(activeSlide);
}
},
step = function(offset, customData) {
var slideIndex = slides.indexOf(activeSlide) + offset;
fire(offset > 0 ? 'next' : 'prev', createEventData(activeSlide, customData)) && activate(slideIndex, customData);
},
on = function(eventName, callback) {
(listeners[eventName] || (listeners[eventName] = [])).push(callback);
return function() {
listeners[eventName] = listeners[eventName].filter(function(listener) {
return listener !== callback;
});
};
},
fire = function(eventName, eventData) {
return (listeners[eventName] || [])
.reduce(function(notCancelled, callback) {
return notCancelled && callback(eventData) !== false;
}, true);
},
createEventData = function(el, eventData) {
eventData = eventData || {};
eventData.index = slides.indexOf(el);
eventData.slide = el;
return eventData;
},
deck = {
on: on,
fire: fire,
slide: slide,
next: step.bind(null, 1),
prev: step.bind(null, -1),
parent: parent,
slides: slides
};
(plugins || []).forEach(function(plugin) {
plugin(deck);
});
activate(0);
return deck;
};
module.exports = {
from: from
};
},{}]},{},[1])
(1)
});
+2
View File
@@ -0,0 +1,2 @@
/*! Bespoke.js v1.0.0 © Mark Dalgleish, MIT License */
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;"undefined"!=typeof window?n=window:"undefined"!=typeof global?n=global:"undefined"!=typeof self&&(n=self),n.bespoke=e()}}(function(){return function e(n,r,t){function i(f,u){if(!r[f]){if(!n[f]){var d="function"==typeof require&&require;if(!u&&d)return d(f,!0);if(o)return o(f,!0);throw new Error("Cannot find module '"+f+"'")}var c=r[f]={exports:{}};n[f][0].call(c.exports,function(e){var r=n[f][1][e];return i(r?r:e)},c,c.exports,e,n,r,t)}return r[f].exports}for(var o="function"==typeof require&&require,f=0;f<t.length;f++)i(t[f]);return i}({1:[function(e,n){var r=function(e,n){var r=1===e.nodeType?e:document.querySelector(e),t=[].filter.call(r.children,function(e){return"SCRIPT"!==e.nodeName}),i=t[0],o={},f=function(e,n){t[e]&&(l("deactivate",a(i,n)),i=t[e],l("activate",a(i,n)))},u=function(e,n){return arguments.length?void(l("slide",a(t[e],n))&&f(e,n)):t.indexOf(i)},d=function(e,n){var r=t.indexOf(i)+e;l(e>0?"next":"prev",a(i,n))&&f(r,n)},c=function(e,n){return(o[e]||(o[e]=[])).push(n),function(){o[e]=o[e].filter(function(e){return e!==n})}},l=function(e,n){return(o[e]||[]).reduce(function(e,r){return e&&r(n)!==!1},!0)},a=function(e,n){return n=n||{},n.index=t.indexOf(e),n.slide=e,n},p={on:c,fire:l,slide:u,next:d.bind(null,1),prev:d.bind(null,-1),parent:r,slides:t};return(n||[]).forEach(function(e){e(p)}),f(0),p};n.exports={from:r}},{}]},{},[1])(1)});
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "bespoke.js",
"filename": "bespoke.min.js",
"version": "0.4.0",
"version": "1.0.0",
"description": "DIY Presentation Micro-Framework",
"homepage": "https://github.com/markdalgleish/bespoke.js",
"keywords": [