diff --git a/build/framer.js b/build/framer.js index 89db417a0..01f13ad5f 100644 --- a/build/framer.js +++ b/build/framer.js @@ -331,47 +331,6 @@ exports.extname = function(path) { return splitPathRe.exec(path)[3] || ''; }; -exports.relative = function(from, to) { - from = exports.resolve(from).substr(1); - to = exports.resolve(to).substr(1); - - function trim(arr) { - var start = 0; - for (; start < arr.length; start++) { - if (arr[start] !== '') break; - } - - var end = arr.length - 1; - for (; end >= 0; end--) { - if (arr[end] !== '') break; - } - - if (start > end) return []; - return arr.slice(start, end - start + 1); - } - - var fromParts = trim(from.split('/')); - var toParts = trim(to.split('/')); - - var length = Math.min(fromParts.length, toParts.length); - var samePartsLength = length; - for (var i = 0; i < length; i++) { - if (fromParts[i] !== toParts[i]) { - samePartsLength = i; - break; - } - } - - var outputParts = []; - for (var i = samePartsLength; i < fromParts.length; i++) { - outputParts.push('..'); - } - - outputParts = outputParts.concat(toParts.slice(samePartsLength)); - - return outputParts.join('/'); -}; - }); require.define("__browserify_process",function(require,module,exports,__dirname,__filename,process,global){var process = module.exports = {}; @@ -384,7 +343,7 @@ process.nextTick = (function () { ; if (canSetImmediate) { - return function (f) { return window.setImmediate(f) }; + return window.setImmediate; } if (canPost) { @@ -697,42 +656,47 @@ require.define("/src/debug.coffee",function(require,module,exports,__dirname,__f utils = require("./utils"); - window.document.onkeydown = function(event) { - var color, node, view, _i, _len, _ref, _results; - if (event.keyCode === 27) { - _ref = View.Views; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - view = _ref[_i]; - if (view._debug) { - view._element.removeChild(view._debug.node); - view.style = view._debug.style; - _results.push(delete view._debug); - } else { - color = "rgba(50,150,200,.35)"; - node = document.createElement("div"); - node.innerHTML = "" + (view.name || view.id); - if (view.superView) { - node.innerHTML += " in " + (view.superView.name || view.superView.id) + ""; - } - node.style.position = "absolute"; - node.style.padding = "3px"; - view._debug = { - style: utils.extend({}, view.style), - node: node - }; - view._element.appendChild(node); - _results.push(view.style = { - color: "white", - margin: "-1px", - font: "10px/1em Monaco", - backgroundColor: "" + color, - border: "1px solid " + color, - backgroundImage: null - }); + exports.debug = function() { + if (document._togglingDebug === true) { + return; + } + document._togglingDebug = true; + View.Views.map(function(view, i) { + var color, node; + if (view._debug) { + view._element.removeChild(view._debug.node); + view.style = view._debug.style; + return delete view._debug; + } else { + color = "rgba(50,150,200,.35)"; + node = document.createElement("div"); + node.innerHTML = "" + (view.name || view.id); + if (view.superView) { + node.innerHTML += " in " + (view.superView.name || view.superView.id) + ""; } + node.style.position = "absolute"; + node.style.padding = "3px"; + view._debug = { + style: utils.extend({}, view.style), + node: node + }; + view._element.appendChild(node); + return view.style = { + color: "white", + margin: "-1px", + font: "10px/1em Monaco", + backgroundColor: "" + color, + border: "1px solid " + color, + backgroundImage: null + }; } - return _results; + }); + return document._togglingDebug = false; + }; + + window.document.onkeydown = function(event) { + if (event.keyCode === 27) { + return exports.debug(); } }; @@ -1025,8 +989,10 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam return this._rotateX || 0; }, set: function(value) { + var oldValue; + oldValue = this.rotateX; this._rotateX = value; - this._matrix = this._matrix.rotate(this._rotateX, this._rotateY, this._rotateZ); + this._matrix = this._matrix.rotate(this._rotateX - oldValue, this._rotateY, this._rotateZ); this.emit("change:rotateX"); return this.emit("change:frame"); } @@ -1037,8 +1003,10 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam return this._rotateY || 0; }, set: function(value) { + var oldValue; + oldValue = this.rotateY; this._rotateY = value; - this._matrix = this._matrix.rotate(this._rotateX, this._rotateY, this._rotateZ); + this._matrix = this._matrix.rotate(this._rotateX, this._rotateY - oldValue, this._rotateZ); this.emit("change:rotateY"); return this.emit("change:frame"); } @@ -1049,8 +1017,10 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam return this._rotateZ || 0; }, set: function(value) { + var oldValue; + oldValue = this.rotateZ; this._rotateZ = value; - this._matrix = this._matrix.rotate(0, 0, this._rotateZ); + this._matrix = this._matrix.rotate(this._rotateX, this._rotateY, this._rotateZ - oldValue); this.emit("change:rotateZ"); return this.emit("change:frame"); } @@ -1279,9 +1249,9 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam require.define("/node_modules/underscore/package.json",function(require,module,exports,__dirname,__filename,process,global){module.exports = {"main":"underscore.js"} }); -require.define("/node_modules/underscore/underscore.js",function(require,module,exports,__dirname,__filename,process,global){// Underscore.js 1.4.4 +require.define("/node_modules/underscore/underscore.js",function(require,module,exports,__dirname,__filename,process,global){// Underscore.js 1.4.2 // http://underscorejs.org -// (c) 2009-2013 Jeremy Ashkenas, DocumentCloud Inc. +// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. // Underscore may be freely distributed under the MIT license. (function() { @@ -1305,6 +1275,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, var push = ArrayProto.push, slice = ArrayProto.slice, concat = ArrayProto.concat, + unshift = ArrayProto.unshift, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty; @@ -1341,11 +1312,11 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, } exports._ = _; } else { - root._ = _; + root['_'] = _; } // Current version. - _.VERSION = '1.4.4'; + _.VERSION = '1.4.2'; // Collection Functions // -------------------- @@ -1382,8 +1353,6 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, return results; }; - var reduceError = 'Reduce of empty array with no initial value'; - // **Reduce** builds up a single result from a list of values, aka `inject`, // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available. _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) { @@ -1401,7 +1370,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, memo = iterator.call(context, memo, value, index, list); } }); - if (!initial) throw new TypeError(reduceError); + if (!initial) throw new TypeError('Reduce of empty array with no initial value'); return memo; }; @@ -1412,7 +1381,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, if (obj == null) obj = []; if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { if (context) iterator = _.bind(iterator, context); - return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); + return arguments.length > 2 ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); } var length = obj.length; if (length !== +length) { @@ -1428,7 +1397,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, memo = iterator.call(context, memo, obj[index], index, list); } }); - if (!initial) throw new TypeError(reduceError); + if (!initial) throw new TypeError('Reduce of empty array with no initial value'); return memo; }; @@ -1459,9 +1428,12 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Return all the elements for which a truth test fails. _.reject = function(obj, iterator, context) { - return _.filter(obj, function(value, index, list) { - return !iterator.call(context, value, index, list); - }, context); + var results = []; + if (obj == null) return results; + each(obj, function(value, index, list) { + if (!iterator.call(context, value, index, list)) results[results.length] = value; + }); + return results; }; // Determine whether all of the elements match a truth test. @@ -1495,19 +1467,20 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Determine if the array or object contains a given value (using `===`). // Aliased as `include`. _.contains = _.include = function(obj, target) { - if (obj == null) return false; + var found = false; + if (obj == null) return found; if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; - return any(obj, function(value) { + found = any(obj, function(value) { return value === target; }); + return found; }; // Invoke a method (with arguments) on every item in a collection. _.invoke = function(obj, method) { var args = slice.call(arguments, 2); - var isFunc = _.isFunction(method); return _.map(obj, function(value) { - return (isFunc ? method : value[method]).apply(value, args); + return (_.isFunction(method) ? method : value[method]).apply(value, args); }); }; @@ -1517,10 +1490,10 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, }; // Convenience version of a common use case of `filter`: selecting only objects - // containing specific `key:value` pairs. - _.where = function(obj, attrs, first) { - if (_.isEmpty(attrs)) return first ? null : []; - return _[first ? 'find' : 'filter'](obj, function(value) { + // with specific `key:value` pairs. + _.where = function(obj, attrs) { + if (_.isEmpty(attrs)) return []; + return _.filter(obj, function(value) { for (var key in attrs) { if (attrs[key] !== value[key]) return false; } @@ -1528,12 +1501,6 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, }); }; - // Convenience version of a common use case of `find`: getting the first object - // containing specific `key:value` pairs. - _.findWhere = function(obj, attrs) { - return _.where(obj, attrs, true); - }; - // Return the maximum element or (element-based computation). // Can't optimize arrays of integers longer than 65,535 elements. // See: https://bugs.webkit.org/show_bug.cgi?id=80797 @@ -1542,7 +1509,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, return Math.max.apply(Math, obj); } if (!iterator && _.isEmpty(obj)) return -Infinity; - var result = {computed : -Infinity, value: -Infinity}; + var result = {computed : -Infinity}; each(obj, function(value, index, list) { var computed = iterator ? iterator.call(context, value, index, list) : value; computed >= result.computed && (result = {value : value, computed : computed}); @@ -1556,7 +1523,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, return Math.min.apply(Math, obj); } if (!iterator && _.isEmpty(obj)) return Infinity; - var result = {computed : Infinity, value: Infinity}; + var result = {computed : Infinity}; each(obj, function(value, index, list) { var computed = iterator ? iterator.call(context, value, index, list) : value; computed < result.computed && (result = {value : value, computed : computed}); @@ -1605,7 +1572,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // An internal function used for aggregate "group by" operations. var group = function(obj, value, context, behavior) { var result = {}; - var iterator = lookupIterator(value || _.identity); + var iterator = lookupIterator(value); each(obj, function(value, index) { var key = iterator.call(context, value, index, obj); behavior(result, key, value); @@ -1625,7 +1592,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // either a string attribute to count by, or a function that returns the // criterion. _.countBy = function(obj, value, context) { - return group(obj, value, context, function(result, key) { + return group(obj, value, context, function(result, key, value) { if (!_.has(result, key)) result[key] = 0; result[key]++; }); @@ -1647,14 +1614,12 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Safely convert anything iterable into a real, live array. _.toArray = function(obj) { if (!obj) return []; - if (_.isArray(obj)) return slice.call(obj); - if (obj.length === +obj.length) return _.map(obj, _.identity); + if (obj.length === +obj.length) return slice.call(obj); return _.values(obj); }; // Return the number of elements in an object. _.size = function(obj) { - if (obj == null) return 0; return (obj.length === +obj.length) ? obj.length : _.keys(obj).length; }; @@ -1665,7 +1630,6 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // values in the array. Aliased as `head` and `take`. The **guard** check // allows it to work with `_.map`. _.first = _.head = _.take = function(array, n, guard) { - if (array == null) return void 0; return (n != null) && !guard ? slice.call(array, 0, n) : array[0]; }; @@ -1680,7 +1644,6 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Get the last element of an array. Passing **n** will return the last N // values in the array. The **guard** check allows it to work with `_.map`. _.last = function(array, n, guard) { - if (array == null) return void 0; if ((n != null) && !guard) { return slice.call(array, Math.max(array.length - n, 0)); } else { @@ -1698,7 +1661,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Trim out all falsy values from an array. _.compact = function(array) { - return _.filter(array, _.identity); + return _.filter(array, function(value){ return !!value; }); }; // Internal implementation of a recursive `flatten` function. @@ -1727,11 +1690,6 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // been sorted, you have the option of using a faster algorithm. // Aliased as `unique`. _.uniq = _.unique = function(array, isSorted, iterator, context) { - if (_.isFunction(isSorted)) { - context = iterator; - iterator = isSorted; - isSorted = false; - } var initial = iterator ? _.map(array, iterator, context) : array; var results = []; var seen = []; @@ -1784,7 +1742,6 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // pairs, or two parallel arrays of the same length -- one of keys, and one of // the corresponding values. _.object = function(list, values) { - if (list == null) return {}; var result = {}; for (var i = 0, l = list.length; i < l; i++) { if (values) { @@ -1855,23 +1812,25 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Function (ahem) Functions // ------------------ + // Reusable constructor function for prototype setting. + var ctor = function(){}; + // Create a function bound to a given object (assigning `this`, and arguments, - // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if - // available. - _.bind = function(func, context) { + // optionally). Binding with arguments is also known as `curry`. + // Delegates to **ECMAScript 5**'s native `Function.bind` if available. + // We check for `func.bind` first, to fail fast when `func` is undefined. + _.bind = function bind(func, context) { + var bound, args; if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); - var args = slice.call(arguments, 2); - return function() { - return func.apply(context, args.concat(slice.call(arguments))); - }; - }; - - // Partially apply a function by creating a version that has had some of its - // arguments pre-filled, without changing its dynamic `this` context. - _.partial = function(func) { - var args = slice.call(arguments, 1); - return function() { - return func.apply(this, args.concat(slice.call(arguments))); + if (!_.isFunction(func)) throw new TypeError; + args = slice.call(arguments, 2); + return bound = function() { + if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments))); + ctor.prototype = func.prototype; + var self = new ctor; + var result = func.apply(self, args.concat(slice.call(arguments))); + if (Object(result) === result) return result; + return self; }; }; @@ -1879,7 +1838,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // all callbacks defined on an object belong to it. _.bindAll = function(obj) { var funcs = slice.call(arguments, 1); - if (funcs.length === 0) funcs = _.functions(obj); + if (funcs.length == 0) funcs = _.functions(obj); each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); return obj; }; @@ -1910,26 +1869,25 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Returns a function, that, when invoked, will only be triggered at most once // during a given window of time. _.throttle = function(func, wait) { - var context, args, timeout, result; - var previous = 0; - var later = function() { - previous = new Date; - timeout = null; - result = func.apply(context, args); - }; + var context, args, timeout, throttling, more, result; + var whenDone = _.debounce(function(){ more = throttling = false; }, wait); return function() { - var now = new Date; - var remaining = wait - (now - previous); - context = this; - args = arguments; - if (remaining <= 0) { - clearTimeout(timeout); + context = this; args = arguments; + var later = function() { timeout = null; - previous = now; + if (more) { + result = func.apply(context, args); + } + whenDone(); + }; + if (!timeout) timeout = setTimeout(later, wait); + if (throttling) { + more = true; + } else { + throttling = true; result = func.apply(context, args); - } else if (!timeout) { - timeout = setTimeout(later, remaining); } + whenDone(); return result; }; }; @@ -2047,10 +2005,8 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Extend a given object with all the properties in passed-in object(s). _.extend = function(obj) { each(slice.call(arguments, 1), function(source) { - if (source) { - for (var prop in source) { - obj[prop] = source[prop]; - } + for (var prop in source) { + obj[prop] = source[prop]; } }); return obj; @@ -2079,10 +2035,8 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Fill in a given object with default properties. _.defaults = function(obj) { each(slice.call(arguments, 1), function(source) { - if (source) { - for (var prop in source) { - if (obj[prop] == null) obj[prop] = source[prop]; - } + for (var prop in source) { + if (obj[prop] == null) obj[prop] = source[prop]; } }); return obj; @@ -2247,7 +2201,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Is a given object a finite number? _.isFinite = function(obj) { - return isFinite(obj) && !isNaN(parseFloat(obj)); + return _.isNumber(obj) && isFinite(obj); }; // Is the given value `NaN`? (NaN is the only number which does not equal itself). @@ -2293,9 +2247,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Run a function **n** times. _.times = function(n, iterator, context) { - var accum = Array(n); - for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i); - return accum; + for (var i = 0; i < n; i++) iterator.call(context, i); }; // Return a random integer between min and max (inclusive). @@ -2304,7 +2256,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, max = min; min = 0; } - return min + Math.floor(Math.random() * (max - min + 1)); + return min + (0 | Math.random() * (max - min + 1)); }; // List of HTML entities for escaping. @@ -2360,7 +2312,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Useful for temporary DOM ids. var idCounter = 0; _.uniqueId = function(prefix) { - var id = ++idCounter + ''; + var id = idCounter++; return prefix ? prefix + id : id; }; @@ -2395,7 +2347,6 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Underscore templating handles arbitrary delimiters, preserves whitespace, // and correctly escapes quotes within interpolated code. _.template = function(text, data, settings) { - var render; settings = _.defaults({}, settings, _.templateSettings); // Combine delimiters into one regular expression via alternation. @@ -2411,18 +2362,11 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { source += text.slice(index, offset) .replace(escaper, function(match) { return '\\' + escapes[match]; }); - - if (escape) { - source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; - } - if (interpolate) { - source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; - } - if (evaluate) { - source += "';\n" + evaluate + "\n__p+='"; - } + source += + escape ? "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'" : + interpolate ? "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'" : + evaluate ? "';\n" + evaluate + "\n__p+='" : ''; index = offset + match.length; - return match; }); source += "';\n"; @@ -2434,7 +2378,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, source + "return __p;\n"; try { - render = new Function(settings.variable || 'obj', '_', source); + var render = new Function(settings.variable || 'obj', '_', source); } catch (e) { e.source = source; throw e; @@ -3312,6 +3256,8 @@ require.define("/src/init.coffee",function(require,module,exports,__dirname,__fi Global.ViewList = ViewList; + Global.debug = debug.debug; + if (window) { window.Framer = Global; for (k in Global) { @@ -3320,8 +3266,6 @@ require.define("/src/init.coffee",function(require,module,exports,__dirname,__fi } } - console.log("Webkit", utils.isWebKit()); - if (!utils.isWebKit()) { alert("Sorry, only WebKit browsers are currently supported. \See https://github.com/koenbok/Framer/issues/2 for more info."); } diff --git a/src/animation.coffee b/src/animation.coffee index 3ab70acea..a074852f5 100644 --- a/src/animation.coffee +++ b/src/animation.coffee @@ -111,12 +111,6 @@ class exports.Animation extends EventEmitter for k, v of beginState nextState[k] = (deltas[k] * value) + beginState[k] - - # Let's round some variables to pixels to avoid pixel cracks. So not scale - # and opacity, but basically all others. I think it makes sense to avoid these - # for designers, but you lose some control wit this magic added. - # if k in ["x", "y", "z", "width", "height"] - # nextState[k] = parseInt nextState[k] if @modifiers[k] nextState[k] = @modifiers[k](nextState[k]) diff --git a/src/views/view.coffee b/src/views/view.coffee index aed045653..36e042d60 100644 --- a/src/views/view.coffee +++ b/src/views/view.coffee @@ -199,8 +199,9 @@ class View extends Frame get: -> @_rotateX or 0 set: (value) -> + oldValue = @rotateX @_rotateX = value - @_matrix = @_matrix.rotate @_rotateX,@_rotateY,@_rotateZ + @_matrix = @_matrix.rotate @_rotateX - oldValue, @_rotateY, @_rotateZ @emit "change:rotateX" @emit "change:frame" @@ -208,8 +209,9 @@ class View extends Frame get: -> @_rotateY or 0 set: (value) -> + oldValue = @rotateY @_rotateY = value - @_matrix = @_matrix.rotate @_rotateX,@_rotateY,@_rotateZ + @_matrix = @_matrix.rotate @_rotateX, @_rotateY - oldValue, @_rotateZ @emit "change:rotateY" @emit "change:frame" @@ -217,8 +219,9 @@ class View extends Frame get: -> @_rotateZ or 0 set: (value) -> + oldValue = @rotateZ @_rotateZ = value - @_matrix = @_matrix.rotate 0,0,@_rotateZ + @_matrix = @_matrix.rotate @_rotateX, @_rotateY, @_rotateZ - oldValue @emit "change:rotateZ" @emit "change:frame" diff --git a/template/framer.js b/template/framer.js index 89db417a0..01f13ad5f 100644 --- a/template/framer.js +++ b/template/framer.js @@ -331,47 +331,6 @@ exports.extname = function(path) { return splitPathRe.exec(path)[3] || ''; }; -exports.relative = function(from, to) { - from = exports.resolve(from).substr(1); - to = exports.resolve(to).substr(1); - - function trim(arr) { - var start = 0; - for (; start < arr.length; start++) { - if (arr[start] !== '') break; - } - - var end = arr.length - 1; - for (; end >= 0; end--) { - if (arr[end] !== '') break; - } - - if (start > end) return []; - return arr.slice(start, end - start + 1); - } - - var fromParts = trim(from.split('/')); - var toParts = trim(to.split('/')); - - var length = Math.min(fromParts.length, toParts.length); - var samePartsLength = length; - for (var i = 0; i < length; i++) { - if (fromParts[i] !== toParts[i]) { - samePartsLength = i; - break; - } - } - - var outputParts = []; - for (var i = samePartsLength; i < fromParts.length; i++) { - outputParts.push('..'); - } - - outputParts = outputParts.concat(toParts.slice(samePartsLength)); - - return outputParts.join('/'); -}; - }); require.define("__browserify_process",function(require,module,exports,__dirname,__filename,process,global){var process = module.exports = {}; @@ -384,7 +343,7 @@ process.nextTick = (function () { ; if (canSetImmediate) { - return function (f) { return window.setImmediate(f) }; + return window.setImmediate; } if (canPost) { @@ -697,42 +656,47 @@ require.define("/src/debug.coffee",function(require,module,exports,__dirname,__f utils = require("./utils"); - window.document.onkeydown = function(event) { - var color, node, view, _i, _len, _ref, _results; - if (event.keyCode === 27) { - _ref = View.Views; - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - view = _ref[_i]; - if (view._debug) { - view._element.removeChild(view._debug.node); - view.style = view._debug.style; - _results.push(delete view._debug); - } else { - color = "rgba(50,150,200,.35)"; - node = document.createElement("div"); - node.innerHTML = "" + (view.name || view.id); - if (view.superView) { - node.innerHTML += " in " + (view.superView.name || view.superView.id) + ""; - } - node.style.position = "absolute"; - node.style.padding = "3px"; - view._debug = { - style: utils.extend({}, view.style), - node: node - }; - view._element.appendChild(node); - _results.push(view.style = { - color: "white", - margin: "-1px", - font: "10px/1em Monaco", - backgroundColor: "" + color, - border: "1px solid " + color, - backgroundImage: null - }); + exports.debug = function() { + if (document._togglingDebug === true) { + return; + } + document._togglingDebug = true; + View.Views.map(function(view, i) { + var color, node; + if (view._debug) { + view._element.removeChild(view._debug.node); + view.style = view._debug.style; + return delete view._debug; + } else { + color = "rgba(50,150,200,.35)"; + node = document.createElement("div"); + node.innerHTML = "" + (view.name || view.id); + if (view.superView) { + node.innerHTML += " in " + (view.superView.name || view.superView.id) + ""; } + node.style.position = "absolute"; + node.style.padding = "3px"; + view._debug = { + style: utils.extend({}, view.style), + node: node + }; + view._element.appendChild(node); + return view.style = { + color: "white", + margin: "-1px", + font: "10px/1em Monaco", + backgroundColor: "" + color, + border: "1px solid " + color, + backgroundImage: null + }; } - return _results; + }); + return document._togglingDebug = false; + }; + + window.document.onkeydown = function(event) { + if (event.keyCode === 27) { + return exports.debug(); } }; @@ -1025,8 +989,10 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam return this._rotateX || 0; }, set: function(value) { + var oldValue; + oldValue = this.rotateX; this._rotateX = value; - this._matrix = this._matrix.rotate(this._rotateX, this._rotateY, this._rotateZ); + this._matrix = this._matrix.rotate(this._rotateX - oldValue, this._rotateY, this._rotateZ); this.emit("change:rotateX"); return this.emit("change:frame"); } @@ -1037,8 +1003,10 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam return this._rotateY || 0; }, set: function(value) { + var oldValue; + oldValue = this.rotateY; this._rotateY = value; - this._matrix = this._matrix.rotate(this._rotateX, this._rotateY, this._rotateZ); + this._matrix = this._matrix.rotate(this._rotateX, this._rotateY - oldValue, this._rotateZ); this.emit("change:rotateY"); return this.emit("change:frame"); } @@ -1049,8 +1017,10 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam return this._rotateZ || 0; }, set: function(value) { + var oldValue; + oldValue = this.rotateZ; this._rotateZ = value; - this._matrix = this._matrix.rotate(0, 0, this._rotateZ); + this._matrix = this._matrix.rotate(this._rotateX, this._rotateY, this._rotateZ - oldValue); this.emit("change:rotateZ"); return this.emit("change:frame"); } @@ -1279,9 +1249,9 @@ require.define("/src/views/view.coffee",function(require,module,exports,__dirnam require.define("/node_modules/underscore/package.json",function(require,module,exports,__dirname,__filename,process,global){module.exports = {"main":"underscore.js"} }); -require.define("/node_modules/underscore/underscore.js",function(require,module,exports,__dirname,__filename,process,global){// Underscore.js 1.4.4 +require.define("/node_modules/underscore/underscore.js",function(require,module,exports,__dirname,__filename,process,global){// Underscore.js 1.4.2 // http://underscorejs.org -// (c) 2009-2013 Jeremy Ashkenas, DocumentCloud Inc. +// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. // Underscore may be freely distributed under the MIT license. (function() { @@ -1305,6 +1275,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, var push = ArrayProto.push, slice = ArrayProto.slice, concat = ArrayProto.concat, + unshift = ArrayProto.unshift, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty; @@ -1341,11 +1312,11 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, } exports._ = _; } else { - root._ = _; + root['_'] = _; } // Current version. - _.VERSION = '1.4.4'; + _.VERSION = '1.4.2'; // Collection Functions // -------------------- @@ -1382,8 +1353,6 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, return results; }; - var reduceError = 'Reduce of empty array with no initial value'; - // **Reduce** builds up a single result from a list of values, aka `inject`, // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available. _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) { @@ -1401,7 +1370,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, memo = iterator.call(context, memo, value, index, list); } }); - if (!initial) throw new TypeError(reduceError); + if (!initial) throw new TypeError('Reduce of empty array with no initial value'); return memo; }; @@ -1412,7 +1381,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, if (obj == null) obj = []; if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { if (context) iterator = _.bind(iterator, context); - return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); + return arguments.length > 2 ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); } var length = obj.length; if (length !== +length) { @@ -1428,7 +1397,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, memo = iterator.call(context, memo, obj[index], index, list); } }); - if (!initial) throw new TypeError(reduceError); + if (!initial) throw new TypeError('Reduce of empty array with no initial value'); return memo; }; @@ -1459,9 +1428,12 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Return all the elements for which a truth test fails. _.reject = function(obj, iterator, context) { - return _.filter(obj, function(value, index, list) { - return !iterator.call(context, value, index, list); - }, context); + var results = []; + if (obj == null) return results; + each(obj, function(value, index, list) { + if (!iterator.call(context, value, index, list)) results[results.length] = value; + }); + return results; }; // Determine whether all of the elements match a truth test. @@ -1495,19 +1467,20 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Determine if the array or object contains a given value (using `===`). // Aliased as `include`. _.contains = _.include = function(obj, target) { - if (obj == null) return false; + var found = false; + if (obj == null) return found; if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; - return any(obj, function(value) { + found = any(obj, function(value) { return value === target; }); + return found; }; // Invoke a method (with arguments) on every item in a collection. _.invoke = function(obj, method) { var args = slice.call(arguments, 2); - var isFunc = _.isFunction(method); return _.map(obj, function(value) { - return (isFunc ? method : value[method]).apply(value, args); + return (_.isFunction(method) ? method : value[method]).apply(value, args); }); }; @@ -1517,10 +1490,10 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, }; // Convenience version of a common use case of `filter`: selecting only objects - // containing specific `key:value` pairs. - _.where = function(obj, attrs, first) { - if (_.isEmpty(attrs)) return first ? null : []; - return _[first ? 'find' : 'filter'](obj, function(value) { + // with specific `key:value` pairs. + _.where = function(obj, attrs) { + if (_.isEmpty(attrs)) return []; + return _.filter(obj, function(value) { for (var key in attrs) { if (attrs[key] !== value[key]) return false; } @@ -1528,12 +1501,6 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, }); }; - // Convenience version of a common use case of `find`: getting the first object - // containing specific `key:value` pairs. - _.findWhere = function(obj, attrs) { - return _.where(obj, attrs, true); - }; - // Return the maximum element or (element-based computation). // Can't optimize arrays of integers longer than 65,535 elements. // See: https://bugs.webkit.org/show_bug.cgi?id=80797 @@ -1542,7 +1509,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, return Math.max.apply(Math, obj); } if (!iterator && _.isEmpty(obj)) return -Infinity; - var result = {computed : -Infinity, value: -Infinity}; + var result = {computed : -Infinity}; each(obj, function(value, index, list) { var computed = iterator ? iterator.call(context, value, index, list) : value; computed >= result.computed && (result = {value : value, computed : computed}); @@ -1556,7 +1523,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, return Math.min.apply(Math, obj); } if (!iterator && _.isEmpty(obj)) return Infinity; - var result = {computed : Infinity, value: Infinity}; + var result = {computed : Infinity}; each(obj, function(value, index, list) { var computed = iterator ? iterator.call(context, value, index, list) : value; computed < result.computed && (result = {value : value, computed : computed}); @@ -1605,7 +1572,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // An internal function used for aggregate "group by" operations. var group = function(obj, value, context, behavior) { var result = {}; - var iterator = lookupIterator(value || _.identity); + var iterator = lookupIterator(value); each(obj, function(value, index) { var key = iterator.call(context, value, index, obj); behavior(result, key, value); @@ -1625,7 +1592,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // either a string attribute to count by, or a function that returns the // criterion. _.countBy = function(obj, value, context) { - return group(obj, value, context, function(result, key) { + return group(obj, value, context, function(result, key, value) { if (!_.has(result, key)) result[key] = 0; result[key]++; }); @@ -1647,14 +1614,12 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Safely convert anything iterable into a real, live array. _.toArray = function(obj) { if (!obj) return []; - if (_.isArray(obj)) return slice.call(obj); - if (obj.length === +obj.length) return _.map(obj, _.identity); + if (obj.length === +obj.length) return slice.call(obj); return _.values(obj); }; // Return the number of elements in an object. _.size = function(obj) { - if (obj == null) return 0; return (obj.length === +obj.length) ? obj.length : _.keys(obj).length; }; @@ -1665,7 +1630,6 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // values in the array. Aliased as `head` and `take`. The **guard** check // allows it to work with `_.map`. _.first = _.head = _.take = function(array, n, guard) { - if (array == null) return void 0; return (n != null) && !guard ? slice.call(array, 0, n) : array[0]; }; @@ -1680,7 +1644,6 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Get the last element of an array. Passing **n** will return the last N // values in the array. The **guard** check allows it to work with `_.map`. _.last = function(array, n, guard) { - if (array == null) return void 0; if ((n != null) && !guard) { return slice.call(array, Math.max(array.length - n, 0)); } else { @@ -1698,7 +1661,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Trim out all falsy values from an array. _.compact = function(array) { - return _.filter(array, _.identity); + return _.filter(array, function(value){ return !!value; }); }; // Internal implementation of a recursive `flatten` function. @@ -1727,11 +1690,6 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // been sorted, you have the option of using a faster algorithm. // Aliased as `unique`. _.uniq = _.unique = function(array, isSorted, iterator, context) { - if (_.isFunction(isSorted)) { - context = iterator; - iterator = isSorted; - isSorted = false; - } var initial = iterator ? _.map(array, iterator, context) : array; var results = []; var seen = []; @@ -1784,7 +1742,6 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // pairs, or two parallel arrays of the same length -- one of keys, and one of // the corresponding values. _.object = function(list, values) { - if (list == null) return {}; var result = {}; for (var i = 0, l = list.length; i < l; i++) { if (values) { @@ -1855,23 +1812,25 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Function (ahem) Functions // ------------------ + // Reusable constructor function for prototype setting. + var ctor = function(){}; + // Create a function bound to a given object (assigning `this`, and arguments, - // optionally). Delegates to **ECMAScript 5**'s native `Function.bind` if - // available. - _.bind = function(func, context) { + // optionally). Binding with arguments is also known as `curry`. + // Delegates to **ECMAScript 5**'s native `Function.bind` if available. + // We check for `func.bind` first, to fail fast when `func` is undefined. + _.bind = function bind(func, context) { + var bound, args; if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); - var args = slice.call(arguments, 2); - return function() { - return func.apply(context, args.concat(slice.call(arguments))); - }; - }; - - // Partially apply a function by creating a version that has had some of its - // arguments pre-filled, without changing its dynamic `this` context. - _.partial = function(func) { - var args = slice.call(arguments, 1); - return function() { - return func.apply(this, args.concat(slice.call(arguments))); + if (!_.isFunction(func)) throw new TypeError; + args = slice.call(arguments, 2); + return bound = function() { + if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments))); + ctor.prototype = func.prototype; + var self = new ctor; + var result = func.apply(self, args.concat(slice.call(arguments))); + if (Object(result) === result) return result; + return self; }; }; @@ -1879,7 +1838,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // all callbacks defined on an object belong to it. _.bindAll = function(obj) { var funcs = slice.call(arguments, 1); - if (funcs.length === 0) funcs = _.functions(obj); + if (funcs.length == 0) funcs = _.functions(obj); each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); return obj; }; @@ -1910,26 +1869,25 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Returns a function, that, when invoked, will only be triggered at most once // during a given window of time. _.throttle = function(func, wait) { - var context, args, timeout, result; - var previous = 0; - var later = function() { - previous = new Date; - timeout = null; - result = func.apply(context, args); - }; + var context, args, timeout, throttling, more, result; + var whenDone = _.debounce(function(){ more = throttling = false; }, wait); return function() { - var now = new Date; - var remaining = wait - (now - previous); - context = this; - args = arguments; - if (remaining <= 0) { - clearTimeout(timeout); + context = this; args = arguments; + var later = function() { timeout = null; - previous = now; + if (more) { + result = func.apply(context, args); + } + whenDone(); + }; + if (!timeout) timeout = setTimeout(later, wait); + if (throttling) { + more = true; + } else { + throttling = true; result = func.apply(context, args); - } else if (!timeout) { - timeout = setTimeout(later, remaining); } + whenDone(); return result; }; }; @@ -2047,10 +2005,8 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Extend a given object with all the properties in passed-in object(s). _.extend = function(obj) { each(slice.call(arguments, 1), function(source) { - if (source) { - for (var prop in source) { - obj[prop] = source[prop]; - } + for (var prop in source) { + obj[prop] = source[prop]; } }); return obj; @@ -2079,10 +2035,8 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Fill in a given object with default properties. _.defaults = function(obj) { each(slice.call(arguments, 1), function(source) { - if (source) { - for (var prop in source) { - if (obj[prop] == null) obj[prop] = source[prop]; - } + for (var prop in source) { + if (obj[prop] == null) obj[prop] = source[prop]; } }); return obj; @@ -2247,7 +2201,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Is a given object a finite number? _.isFinite = function(obj) { - return isFinite(obj) && !isNaN(parseFloat(obj)); + return _.isNumber(obj) && isFinite(obj); }; // Is the given value `NaN`? (NaN is the only number which does not equal itself). @@ -2293,9 +2247,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Run a function **n** times. _.times = function(n, iterator, context) { - var accum = Array(n); - for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i); - return accum; + for (var i = 0; i < n; i++) iterator.call(context, i); }; // Return a random integer between min and max (inclusive). @@ -2304,7 +2256,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, max = min; min = 0; } - return min + Math.floor(Math.random() * (max - min + 1)); + return min + (0 | Math.random() * (max - min + 1)); }; // List of HTML entities for escaping. @@ -2360,7 +2312,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Useful for temporary DOM ids. var idCounter = 0; _.uniqueId = function(prefix) { - var id = ++idCounter + ''; + var id = idCounter++; return prefix ? prefix + id : id; }; @@ -2395,7 +2347,6 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, // Underscore templating handles arbitrary delimiters, preserves whitespace, // and correctly escapes quotes within interpolated code. _.template = function(text, data, settings) { - var render; settings = _.defaults({}, settings, _.templateSettings); // Combine delimiters into one regular expression via alternation. @@ -2411,18 +2362,11 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { source += text.slice(index, offset) .replace(escaper, function(match) { return '\\' + escapes[match]; }); - - if (escape) { - source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; - } - if (interpolate) { - source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; - } - if (evaluate) { - source += "';\n" + evaluate + "\n__p+='"; - } + source += + escape ? "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'" : + interpolate ? "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'" : + evaluate ? "';\n" + evaluate + "\n__p+='" : ''; index = offset + match.length; - return match; }); source += "';\n"; @@ -2434,7 +2378,7 @@ require.define("/node_modules/underscore/underscore.js",function(require,module, source + "return __p;\n"; try { - render = new Function(settings.variable || 'obj', '_', source); + var render = new Function(settings.variable || 'obj', '_', source); } catch (e) { e.source = source; throw e; @@ -3312,6 +3256,8 @@ require.define("/src/init.coffee",function(require,module,exports,__dirname,__fi Global.ViewList = ViewList; + Global.debug = debug.debug; + if (window) { window.Framer = Global; for (k in Global) { @@ -3320,8 +3266,6 @@ require.define("/src/init.coffee",function(require,module,exports,__dirname,__fi } } - console.log("Webkit", utils.isWebKit()); - if (!utils.isWebKit()) { alert("Sorry, only WebKit browsers are currently supported. \See https://github.com/koenbok/Framer/issues/2 for more info."); }