overlay_me 0.12.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/overlay_me.js CHANGED
@@ -9403,8 +9403,8 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9403
9403
 
9404
9404
 
9405
9405
  })( window );
9406
- // Underscore.js 1.1.6
9407
- // (c) 2011 Jeremy Ashkenas, DocumentCloud Inc.
9406
+ // Underscore.js 1.3.3
9407
+ // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
9408
9408
  // Underscore is freely distributable under the MIT license.
9409
9409
  // Portions of Underscore are inspired or borrowed from Prototype,
9410
9410
  // Oliver Steele's Functional, and John Resig's Micro-Templating.
@@ -9453,36 +9453,39 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9453
9453
  // Create a safe reference to the Underscore object for use below.
9454
9454
  var _ = function(obj) { return new wrapper(obj); };
9455
9455
 
9456
- // Export the Underscore object for **CommonJS**, with backwards-compatibility
9457
- // for the old `require()` API. If we're not in CommonJS, add `_` to the
9458
- // global object.
9459
- if (typeof module !== 'undefined' && module.exports) {
9460
- module.exports = _;
9461
- _._ = _;
9456
+ // Export the Underscore object for **Node.js**, with
9457
+ // backwards-compatibility for the old `require()` API. If we're in
9458
+ // the browser, add `_` as a global object via a string identifier,
9459
+ // for Closure Compiler "advanced" mode.
9460
+ if (typeof exports !== 'undefined') {
9461
+ if (typeof module !== 'undefined' && module.exports) {
9462
+ exports = module.exports = _;
9463
+ }
9464
+ exports._ = _;
9462
9465
  } else {
9463
- root._ = _;
9466
+ root['_'] = _;
9464
9467
  }
9465
9468
 
9466
9469
  // Current version.
9467
- _.VERSION = '1.1.6';
9470
+ _.VERSION = '1.3.3';
9468
9471
 
9469
9472
  // Collection Functions
9470
9473
  // --------------------
9471
9474
 
9472
9475
  // The cornerstone, an `each` implementation, aka `forEach`.
9473
- // Handles objects implementing `forEach`, arrays, and raw objects.
9476
+ // Handles objects with the built-in `forEach`, arrays, and raw objects.
9474
9477
  // Delegates to **ECMAScript 5**'s native `forEach` if available.
9475
9478
  var each = _.each = _.forEach = function(obj, iterator, context) {
9476
9479
  if (obj == null) return;
9477
9480
  if (nativeForEach && obj.forEach === nativeForEach) {
9478
9481
  obj.forEach(iterator, context);
9479
- } else if (_.isNumber(obj.length)) {
9482
+ } else if (obj.length === +obj.length) {
9480
9483
  for (var i = 0, l = obj.length; i < l; i++) {
9481
- if (iterator.call(context, obj[i], i, obj) === breaker) return;
9484
+ if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) return;
9482
9485
  }
9483
9486
  } else {
9484
9487
  for (var key in obj) {
9485
- if (hasOwnProperty.call(obj, key)) {
9488
+ if (_.has(obj, key)) {
9486
9489
  if (iterator.call(context, obj[key], key, obj) === breaker) return;
9487
9490
  }
9488
9491
  }
@@ -9491,47 +9494,50 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9491
9494
 
9492
9495
  // Return the results of applying the iterator to each element.
9493
9496
  // Delegates to **ECMAScript 5**'s native `map` if available.
9494
- _.map = function(obj, iterator, context) {
9497
+ _.map = _.collect = function(obj, iterator, context) {
9495
9498
  var results = [];
9496
9499
  if (obj == null) return results;
9497
9500
  if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context);
9498
9501
  each(obj, function(value, index, list) {
9499
9502
  results[results.length] = iterator.call(context, value, index, list);
9500
9503
  });
9504
+ if (obj.length === +obj.length) results.length = obj.length;
9501
9505
  return results;
9502
9506
  };
9503
9507
 
9504
9508
  // **Reduce** builds up a single result from a list of values, aka `inject`,
9505
9509
  // or `foldl`. Delegates to **ECMAScript 5**'s native `reduce` if available.
9506
9510
  _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) {
9507
- var initial = memo !== void 0;
9511
+ var initial = arguments.length > 2;
9508
9512
  if (obj == null) obj = [];
9509
9513
  if (nativeReduce && obj.reduce === nativeReduce) {
9510
9514
  if (context) iterator = _.bind(iterator, context);
9511
9515
  return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator);
9512
9516
  }
9513
9517
  each(obj, function(value, index, list) {
9514
- if (!initial && index === 0) {
9518
+ if (!initial) {
9515
9519
  memo = value;
9516
9520
  initial = true;
9517
9521
  } else {
9518
9522
  memo = iterator.call(context, memo, value, index, list);
9519
9523
  }
9520
9524
  });
9521
- if (!initial) throw new TypeError("Reduce of empty array with no initial value");
9525
+ if (!initial) throw new TypeError('Reduce of empty array with no initial value');
9522
9526
  return memo;
9523
9527
  };
9524
9528
 
9525
9529
  // The right-associative version of reduce, also known as `foldr`.
9526
9530
  // Delegates to **ECMAScript 5**'s native `reduceRight` if available.
9527
9531
  _.reduceRight = _.foldr = function(obj, iterator, memo, context) {
9532
+ var initial = arguments.length > 2;
9528
9533
  if (obj == null) obj = [];
9529
9534
  if (nativeReduceRight && obj.reduceRight === nativeReduceRight) {
9530
9535
  if (context) iterator = _.bind(iterator, context);
9531
- return memo !== void 0 ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);
9536
+ return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator);
9532
9537
  }
9533
- var reversed = (_.isArray(obj) ? obj.slice() : _.toArray(obj)).reverse();
9534
- return _.reduce(reversed, iterator, memo, context);
9538
+ var reversed = _.toArray(obj).reverse();
9539
+ if (context && !initial) iterator = _.bind(iterator, context);
9540
+ return initial ? _.reduce(reversed, iterator, memo, context) : _.reduce(reversed, iterator);
9535
9541
  };
9536
9542
 
9537
9543
  // Return the first value which passes a truth test. Aliased as `detect`.
@@ -9579,7 +9585,7 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9579
9585
  each(obj, function(value, index, list) {
9580
9586
  if (!(result = result && iterator.call(context, value, index, list))) return breaker;
9581
9587
  });
9582
- return result;
9588
+ return !!result;
9583
9589
  };
9584
9590
 
9585
9591
  // Determine if at least one element in the object matches a truth test.
@@ -9591,9 +9597,9 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9591
9597
  if (obj == null) return result;
9592
9598
  if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context);
9593
9599
  each(obj, function(value, index, list) {
9594
- if (result = iterator.call(context, value, index, list)) return breaker;
9600
+ if (result || (result = iterator.call(context, value, index, list))) return breaker;
9595
9601
  });
9596
- return result;
9602
+ return !!result;
9597
9603
  };
9598
9604
 
9599
9605
  // Determine if a given value is included in the array or object using `===`.
@@ -9602,8 +9608,8 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9602
9608
  var found = false;
9603
9609
  if (obj == null) return found;
9604
9610
  if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1;
9605
- any(obj, function(value) {
9606
- if (found = value === target) return true;
9611
+ found = any(obj, function(value) {
9612
+ return value === target;
9607
9613
  });
9608
9614
  return found;
9609
9615
  };
@@ -9612,7 +9618,7 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9612
9618
  _.invoke = function(obj, method) {
9613
9619
  var args = slice.call(arguments, 2);
9614
9620
  return _.map(obj, function(value) {
9615
- return (method.call ? method || value : value[method]).apply(value, args);
9621
+ return (_.isFunction(method) ? method || value : value[method]).apply(value, args);
9616
9622
  });
9617
9623
  };
9618
9624
 
@@ -9623,7 +9629,8 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9623
9629
 
9624
9630
  // Return the maximum element or (element-based computation).
9625
9631
  _.max = function(obj, iterator, context) {
9626
- if (!iterator && _.isArray(obj)) return Math.max.apply(Math, obj);
9632
+ if (!iterator && _.isArray(obj) && obj[0] === +obj[0]) return Math.max.apply(Math, obj);
9633
+ if (!iterator && _.isEmpty(obj)) return -Infinity;
9627
9634
  var result = {computed : -Infinity};
9628
9635
  each(obj, function(value, index, list) {
9629
9636
  var computed = iterator ? iterator.call(context, value, index, list) : value;
@@ -9634,7 +9641,8 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9634
9641
 
9635
9642
  // Return the minimum element (or element-based computation).
9636
9643
  _.min = function(obj, iterator, context) {
9637
- if (!iterator && _.isArray(obj)) return Math.min.apply(Math, obj);
9644
+ if (!iterator && _.isArray(obj) && obj[0] === +obj[0]) return Math.min.apply(Math, obj);
9645
+ if (!iterator && _.isEmpty(obj)) return Infinity;
9638
9646
  var result = {computed : Infinity};
9639
9647
  each(obj, function(value, index, list) {
9640
9648
  var computed = iterator ? iterator.call(context, value, index, list) : value;
@@ -9643,8 +9651,20 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9643
9651
  return result.value;
9644
9652
  };
9645
9653
 
9654
+ // Shuffle an array.
9655
+ _.shuffle = function(obj) {
9656
+ var shuffled = [], rand;
9657
+ each(obj, function(value, index, list) {
9658
+ rand = Math.floor(Math.random() * (index + 1));
9659
+ shuffled[index] = shuffled[rand];
9660
+ shuffled[rand] = value;
9661
+ });
9662
+ return shuffled;
9663
+ };
9664
+
9646
9665
  // Sort the object's values by a criterion produced by an iterator.
9647
- _.sortBy = function(obj, iterator, context) {
9666
+ _.sortBy = function(obj, val, context) {
9667
+ var iterator = _.isFunction(val) ? val : function(obj) { return obj[val]; };
9648
9668
  return _.pluck(_.map(obj, function(value, index, list) {
9649
9669
  return {
9650
9670
  value : value,
@@ -9652,10 +9672,24 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9652
9672
  };
9653
9673
  }).sort(function(left, right) {
9654
9674
  var a = left.criteria, b = right.criteria;
9675
+ if (a === void 0) return 1;
9676
+ if (b === void 0) return -1;
9655
9677
  return a < b ? -1 : a > b ? 1 : 0;
9656
9678
  }), 'value');
9657
9679
  };
9658
9680
 
9681
+ // Groups the object's values by a criterion. Pass either a string attribute
9682
+ // to group by, or a function that returns the criterion.
9683
+ _.groupBy = function(obj, val) {
9684
+ var result = {};
9685
+ var iterator = _.isFunction(val) ? val : function(obj) { return obj[val]; };
9686
+ each(obj, function(value, index) {
9687
+ var key = iterator(value, index);
9688
+ (result[key] || (result[key] = [])).push(value);
9689
+ });
9690
+ return result;
9691
+ };
9692
+
9659
9693
  // Use a comparator function to figure out at what index an object should
9660
9694
  // be inserted so as to maintain order. Uses binary search.
9661
9695
  _.sortedIndex = function(array, obj, iterator) {
@@ -9669,29 +9703,47 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9669
9703
  };
9670
9704
 
9671
9705
  // Safely convert anything iterable into a real, live array.
9672
- _.toArray = function(iterable) {
9673
- if (!iterable) return [];
9674
- if (iterable.toArray) return iterable.toArray();
9675
- if (_.isArray(iterable)) return iterable;
9676
- if (_.isArguments(iterable)) return slice.call(iterable);
9677
- return _.values(iterable);
9706
+ _.toArray = function(obj) {
9707
+ if (!obj) return [];
9708
+ if (_.isArray(obj)) return slice.call(obj);
9709
+ if (_.isArguments(obj)) return slice.call(obj);
9710
+ if (obj.toArray && _.isFunction(obj.toArray)) return obj.toArray();
9711
+ return _.values(obj);
9678
9712
  };
9679
9713
 
9680
9714
  // Return the number of elements in an object.
9681
9715
  _.size = function(obj) {
9682
- return _.toArray(obj).length;
9716
+ return _.isArray(obj) ? obj.length : _.keys(obj).length;
9683
9717
  };
9684
9718
 
9685
9719
  // Array Functions
9686
9720
  // ---------------
9687
9721
 
9688
9722
  // Get the first element of an array. Passing **n** will return the first N
9689
- // values in the array. Aliased as `head`. The **guard** check allows it to work
9690
- // with `_.map`.
9691
- _.first = _.head = function(array, n, guard) {
9723
+ // values in the array. Aliased as `head` and `take`. The **guard** check
9724
+ // allows it to work with `_.map`.
9725
+ _.first = _.head = _.take = function(array, n, guard) {
9692
9726
  return (n != null) && !guard ? slice.call(array, 0, n) : array[0];
9693
9727
  };
9694
9728
 
9729
+ // Returns everything but the last entry of the array. Especcialy useful on
9730
+ // the arguments object. Passing **n** will return all the values in
9731
+ // the array, excluding the last N. The **guard** check allows it to work with
9732
+ // `_.map`.
9733
+ _.initial = function(array, n, guard) {
9734
+ return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n));
9735
+ };
9736
+
9737
+ // Get the last element of an array. Passing **n** will return the last N
9738
+ // values in the array. The **guard** check allows it to work with `_.map`.
9739
+ _.last = function(array, n, guard) {
9740
+ if ((n != null) && !guard) {
9741
+ return slice.call(array, Math.max(array.length - n, 0));
9742
+ } else {
9743
+ return array[array.length - 1];
9744
+ }
9745
+ };
9746
+
9695
9747
  // Returns everything but the first entry of the array. Aliased as `tail`.
9696
9748
  // Especially useful on the arguments object. Passing an **index** will return
9697
9749
  // the rest of the values in the array from that index onward. The **guard**
@@ -9700,20 +9752,15 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9700
9752
  return slice.call(array, (index == null) || guard ? 1 : index);
9701
9753
  };
9702
9754
 
9703
- // Get the last element of an array.
9704
- _.last = function(array) {
9705
- return array[array.length - 1];
9706
- };
9707
-
9708
9755
  // Trim out all falsy values from an array.
9709
9756
  _.compact = function(array) {
9710
9757
  return _.filter(array, function(value){ return !!value; });
9711
9758
  };
9712
9759
 
9713
9760
  // Return a completely flattened version of an array.
9714
- _.flatten = function(array) {
9761
+ _.flatten = function(array, shallow) {
9715
9762
  return _.reduce(array, function(memo, value) {
9716
- if (_.isArray(value)) return memo.concat(_.flatten(value));
9763
+ if (_.isArray(value)) return memo.concat(shallow ? value : _.flatten(value));
9717
9764
  memo[memo.length] = value;
9718
9765
  return memo;
9719
9766
  }, []);
@@ -9721,23 +9768,36 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9721
9768
 
9722
9769
  // Return a version of the array that does not contain the specified value(s).
9723
9770
  _.without = function(array) {
9724
- var values = slice.call(arguments, 1);
9725
- return _.filter(array, function(value){ return !_.include(values, value); });
9771
+ return _.difference(array, slice.call(arguments, 1));
9726
9772
  };
9727
9773
 
9728
9774
  // Produce a duplicate-free version of the array. If the array has already
9729
9775
  // been sorted, you have the option of using a faster algorithm.
9730
9776
  // Aliased as `unique`.
9731
- _.uniq = _.unique = function(array, isSorted) {
9732
- return _.reduce(array, function(memo, el, i) {
9733
- if (0 == i || (isSorted === true ? _.last(memo) != el : !_.include(memo, el))) memo[memo.length] = el;
9777
+ _.uniq = _.unique = function(array, isSorted, iterator) {
9778
+ var initial = iterator ? _.map(array, iterator) : array;
9779
+ var results = [];
9780
+ // The `isSorted` flag is irrelevant if the array only contains two elements.
9781
+ if (array.length < 3) isSorted = true;
9782
+ _.reduce(initial, function (memo, value, index) {
9783
+ if (isSorted ? _.last(memo) !== value || !memo.length : !_.include(memo, value)) {
9784
+ memo.push(value);
9785
+ results.push(array[index]);
9786
+ }
9734
9787
  return memo;
9735
9788
  }, []);
9789
+ return results;
9790
+ };
9791
+
9792
+ // Produce an array that contains the union: each distinct element from all of
9793
+ // the passed-in arrays.
9794
+ _.union = function() {
9795
+ return _.uniq(_.flatten(arguments, true));
9736
9796
  };
9737
9797
 
9738
9798
  // Produce an array that contains every item shared between all the
9739
- // passed-in arrays.
9740
- _.intersect = function(array) {
9799
+ // passed-in arrays. (Aliased as "intersect" for back-compat.)
9800
+ _.intersection = _.intersect = function(array) {
9741
9801
  var rest = slice.call(arguments, 1);
9742
9802
  return _.filter(_.uniq(array), function(item) {
9743
9803
  return _.every(rest, function(other) {
@@ -9746,6 +9806,13 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9746
9806
  });
9747
9807
  };
9748
9808
 
9809
+ // Take the difference between one array and a number of other arrays.
9810
+ // Only the elements present in just the first array will remain.
9811
+ _.difference = function(array) {
9812
+ var rest = _.flatten(slice.call(arguments, 1), true);
9813
+ return _.filter(array, function(value){ return !_.include(rest, value); });
9814
+ };
9815
+
9749
9816
  // Zip together multiple lists into a single array -- elements that share
9750
9817
  // an index go together.
9751
9818
  _.zip = function() {
@@ -9770,17 +9837,16 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9770
9837
  return array[i] === item ? i : -1;
9771
9838
  }
9772
9839
  if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item);
9773
- for (i = 0, l = array.length; i < l; i++) if (array[i] === item) return i;
9840
+ for (i = 0, l = array.length; i < l; i++) if (i in array && array[i] === item) return i;
9774
9841
  return -1;
9775
9842
  };
9776
9843
 
9777
-
9778
9844
  // Delegates to **ECMAScript 5**'s native `lastIndexOf` if available.
9779
9845
  _.lastIndexOf = function(array, item) {
9780
9846
  if (array == null) return -1;
9781
9847
  if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) return array.lastIndexOf(item);
9782
9848
  var i = array.length;
9783
- while (i--) if (array[i] === item) return i;
9849
+ while (i--) if (i in array && array[i] === item) return i;
9784
9850
  return -1;
9785
9851
  };
9786
9852
 
@@ -9809,15 +9875,25 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9809
9875
  // Function (ahem) Functions
9810
9876
  // ------------------
9811
9877
 
9878
+ // Reusable constructor function for prototype setting.
9879
+ var ctor = function(){};
9880
+
9812
9881
  // Create a function bound to a given object (assigning `this`, and arguments,
9813
9882
  // optionally). Binding with arguments is also known as `curry`.
9814
9883
  // Delegates to **ECMAScript 5**'s native `Function.bind` if available.
9815
9884
  // We check for `func.bind` first, to fail fast when `func` is undefined.
9816
- _.bind = function(func, obj) {
9885
+ _.bind = function bind(func, context) {
9886
+ var bound, args;
9817
9887
  if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1));
9818
- var args = slice.call(arguments, 2);
9819
- return function() {
9820
- return func.apply(obj, args.concat(slice.call(arguments)));
9888
+ if (!_.isFunction(func)) throw new TypeError;
9889
+ args = slice.call(arguments, 2);
9890
+ return bound = function() {
9891
+ if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));
9892
+ ctor.prototype = func.prototype;
9893
+ var self = new ctor;
9894
+ var result = func.apply(self, args.concat(slice.call(arguments)));
9895
+ if (Object(result) === result) return result;
9896
+ return self;
9821
9897
  };
9822
9898
  };
9823
9899
 
@@ -9836,7 +9912,7 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9836
9912
  hasher || (hasher = _.identity);
9837
9913
  return function() {
9838
9914
  var key = hasher.apply(this, arguments);
9839
- return hasOwnProperty.call(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
9915
+ return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments));
9840
9916
  };
9841
9917
  };
9842
9918
 
@@ -9844,7 +9920,7 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9844
9920
  // it with the arguments supplied.
9845
9921
  _.delay = function(func, wait) {
9846
9922
  var args = slice.call(arguments, 2);
9847
- return setTimeout(function(){ return func.apply(func, args); }, wait);
9923
+ return setTimeout(function(){ return func.apply(null, args); }, wait);
9848
9924
  };
9849
9925
 
9850
9926
  // Defers a function, scheduling it to run after the current call stack has
@@ -9853,31 +9929,46 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9853
9929
  return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1)));
9854
9930
  };
9855
9931
 
9856
- // Internal function used to implement `_.throttle` and `_.debounce`.
9857
- var limit = function(func, wait, debounce) {
9858
- var timeout;
9932
+ // Returns a function, that, when invoked, will only be triggered at most once
9933
+ // during a given window of time.
9934
+ _.throttle = function(func, wait) {
9935
+ var context, args, timeout, throttling, more, result;
9936
+ var whenDone = _.debounce(function(){ more = throttling = false; }, wait);
9859
9937
  return function() {
9860
- var context = this, args = arguments;
9861
- var throttler = function() {
9938
+ context = this; args = arguments;
9939
+ var later = function() {
9862
9940
  timeout = null;
9863
- func.apply(context, args);
9941
+ if (more) func.apply(context, args);
9942
+ whenDone();
9864
9943
  };
9865
- if (debounce) clearTimeout(timeout);
9866
- if (debounce || !timeout) timeout = setTimeout(throttler, wait);
9944
+ if (!timeout) timeout = setTimeout(later, wait);
9945
+ if (throttling) {
9946
+ more = true;
9947
+ } else {
9948
+ result = func.apply(context, args);
9949
+ }
9950
+ whenDone();
9951
+ throttling = true;
9952
+ return result;
9867
9953
  };
9868
9954
  };
9869
9955
 
9870
- // Returns a function, that, when invoked, will only be triggered at most once
9871
- // during a given window of time.
9872
- _.throttle = function(func, wait) {
9873
- return limit(func, wait, false);
9874
- };
9875
-
9876
9956
  // Returns a function, that, as long as it continues to be invoked, will not
9877
9957
  // be triggered. The function will be called after it stops being called for
9878
- // N milliseconds.
9879
- _.debounce = function(func, wait) {
9880
- return limit(func, wait, true);
9958
+ // N milliseconds. If `immediate` is passed, trigger the function on the
9959
+ // leading edge, instead of the trailing.
9960
+ _.debounce = function(func, wait, immediate) {
9961
+ var timeout;
9962
+ return function() {
9963
+ var context = this, args = arguments;
9964
+ var later = function() {
9965
+ timeout = null;
9966
+ if (!immediate) func.apply(context, args);
9967
+ };
9968
+ if (immediate && !timeout) func.apply(context, args);
9969
+ clearTimeout(timeout);
9970
+ timeout = setTimeout(later, wait);
9971
+ };
9881
9972
  };
9882
9973
 
9883
9974
  // Returns a function that will be executed at most one time, no matter how
@@ -9896,7 +9987,7 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9896
9987
  // conditionally execute the original function.
9897
9988
  _.wrap = function(func, wrapper) {
9898
9989
  return function() {
9899
- var args = [func].concat(slice.call(arguments));
9990
+ var args = [func].concat(slice.call(arguments, 0));
9900
9991
  return wrapper.apply(this, args);
9901
9992
  };
9902
9993
  };
@@ -9904,10 +9995,10 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9904
9995
  // Returns a function that is the composition of a list of functions, each
9905
9996
  // consuming the return value of the function that follows.
9906
9997
  _.compose = function() {
9907
- var funcs = slice.call(arguments);
9998
+ var funcs = arguments;
9908
9999
  return function() {
9909
- var args = slice.call(arguments);
9910
- for (var i=funcs.length-1; i >= 0; i--) {
10000
+ var args = arguments;
10001
+ for (var i = funcs.length - 1; i >= 0; i--) {
9911
10002
  args = [funcs[i].apply(this, args)];
9912
10003
  }
9913
10004
  return args[0];
@@ -9916,12 +10007,12 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9916
10007
 
9917
10008
  // Returns a function that will only be executed after being called N times.
9918
10009
  _.after = function(times, func) {
10010
+ if (times <= 0) return func();
9919
10011
  return function() {
9920
10012
  if (--times < 1) { return func.apply(this, arguments); }
9921
10013
  };
9922
10014
  };
9923
10015
 
9924
-
9925
10016
  // Object Functions
9926
10017
  // ----------------
9927
10018
 
@@ -9930,7 +10021,7 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9930
10021
  _.keys = nativeKeys || function(obj) {
9931
10022
  if (obj !== Object(obj)) throw new TypeError('Invalid object');
9932
10023
  var keys = [];
9933
- for (var key in obj) if (hasOwnProperty.call(obj, key)) keys[keys.length] = key;
10024
+ for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key;
9934
10025
  return keys;
9935
10026
  };
9936
10027
 
@@ -9942,19 +10033,32 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9942
10033
  // Return a sorted list of the function names available on the object.
9943
10034
  // Aliased as `methods`
9944
10035
  _.functions = _.methods = function(obj) {
9945
- return _.filter(_.keys(obj), function(key){ return _.isFunction(obj[key]); }).sort();
10036
+ var names = [];
10037
+ for (var key in obj) {
10038
+ if (_.isFunction(obj[key])) names.push(key);
10039
+ }
10040
+ return names.sort();
9946
10041
  };
9947
10042
 
9948
10043
  // Extend a given object with all the properties in passed-in object(s).
9949
10044
  _.extend = function(obj) {
9950
10045
  each(slice.call(arguments, 1), function(source) {
9951
10046
  for (var prop in source) {
9952
- if (source[prop] !== void 0) obj[prop] = source[prop];
10047
+ obj[prop] = source[prop];
9953
10048
  }
9954
10049
  });
9955
10050
  return obj;
9956
10051
  };
9957
10052
 
10053
+ // Return a copy of the object only containing the whitelisted properties.
10054
+ _.pick = function(obj) {
10055
+ var result = {};
10056
+ each(_.flatten(slice.call(arguments, 1)), function(key) {
10057
+ if (key in obj) result[key] = obj[key];
10058
+ });
10059
+ return result;
10060
+ };
10061
+
9958
10062
  // Fill in a given object with default properties.
9959
10063
  _.defaults = function(obj) {
9960
10064
  each(slice.call(arguments, 1), function(source) {
@@ -9967,6 +10071,7 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9967
10071
 
9968
10072
  // Create a (shallow-cloned) duplicate of an object.
9969
10073
  _.clone = function(obj) {
10074
+ if (!_.isObject(obj)) return obj;
9970
10075
  return _.isArray(obj) ? obj.slice() : _.extend({}, obj);
9971
10076
  };
9972
10077
 
@@ -9978,49 +10083,105 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
9978
10083
  return obj;
9979
10084
  };
9980
10085
 
9981
- // Perform a deep comparison to check if two objects are equal.
9982
- _.isEqual = function(a, b) {
9983
- // Check object identity.
9984
- if (a === b) return true;
9985
- // Different types?
9986
- var atype = typeof(a), btype = typeof(b);
9987
- if (atype != btype) return false;
9988
- // Basic equality test (watch out for coercions).
9989
- if (a == b) return true;
9990
- // One is falsy and the other truthy.
9991
- if ((!a && b) || (a && !b)) return false;
10086
+ // Internal recursive comparison function.
10087
+ function eq(a, b, stack) {
10088
+ // Identical objects are equal. `0 === -0`, but they aren't identical.
10089
+ // See the Harmony `egal` proposal: http://wiki.ecmascript.org/doku.php?id=harmony:egal.
10090
+ if (a === b) return a !== 0 || 1 / a == 1 / b;
10091
+ // A strict comparison is necessary because `null == undefined`.
10092
+ if (a == null || b == null) return a === b;
9992
10093
  // Unwrap any wrapped objects.
9993
10094
  if (a._chain) a = a._wrapped;
9994
10095
  if (b._chain) b = b._wrapped;
9995
- // One of them implements an isEqual()?
9996
- if (a.isEqual) return a.isEqual(b);
9997
- // Check dates' integer values.
9998
- if (_.isDate(a) && _.isDate(b)) return a.getTime() === b.getTime();
9999
- // Both are NaN?
10000
- if (_.isNaN(a) && _.isNaN(b)) return false;
10001
- // Compare regular expressions.
10002
- if (_.isRegExp(a) && _.isRegExp(b))
10003
- return a.source === b.source &&
10004
- a.global === b.global &&
10005
- a.ignoreCase === b.ignoreCase &&
10006
- a.multiline === b.multiline;
10007
- // If a is not an object by this point, we can't handle it.
10008
- if (atype !== 'object') return false;
10009
- // Check for different array lengths before comparing contents.
10010
- if (a.length && (a.length !== b.length)) return false;
10011
- // Nothing else worked, deep compare the contents.
10012
- var aKeys = _.keys(a), bKeys = _.keys(b);
10013
- // Different object sizes?
10014
- if (aKeys.length != bKeys.length) return false;
10015
- // Recursive comparison of contents.
10016
- for (var key in a) if (!(key in b) || !_.isEqual(a[key], b[key])) return false;
10017
- return true;
10096
+ // Invoke a custom `isEqual` method if one is provided.
10097
+ if (a.isEqual && _.isFunction(a.isEqual)) return a.isEqual(b);
10098
+ if (b.isEqual && _.isFunction(b.isEqual)) return b.isEqual(a);
10099
+ // Compare `[[Class]]` names.
10100
+ var className = toString.call(a);
10101
+ if (className != toString.call(b)) return false;
10102
+ switch (className) {
10103
+ // Strings, numbers, dates, and booleans are compared by value.
10104
+ case '[object String]':
10105
+ // Primitives and their corresponding object wrappers are equivalent; thus, `"5"` is
10106
+ // equivalent to `new String("5")`.
10107
+ return a == String(b);
10108
+ case '[object Number]':
10109
+ // `NaN`s are equivalent, but non-reflexive. An `egal` comparison is performed for
10110
+ // other numeric values.
10111
+ return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b);
10112
+ case '[object Date]':
10113
+ case '[object Boolean]':
10114
+ // Coerce dates and booleans to numeric primitive values. Dates are compared by their
10115
+ // millisecond representations. Note that invalid dates with millisecond representations
10116
+ // of `NaN` are not equivalent.
10117
+ return +a == +b;
10118
+ // RegExps are compared by their source patterns and flags.
10119
+ case '[object RegExp]':
10120
+ return a.source == b.source &&
10121
+ a.global == b.global &&
10122
+ a.multiline == b.multiline &&
10123
+ a.ignoreCase == b.ignoreCase;
10124
+ }
10125
+ if (typeof a != 'object' || typeof b != 'object') return false;
10126
+ // Assume equality for cyclic structures. The algorithm for detecting cyclic
10127
+ // structures is adapted from ES 5.1 section 15.12.3, abstract operation `JO`.
10128
+ var length = stack.length;
10129
+ while (length--) {
10130
+ // Linear search. Performance is inversely proportional to the number of
10131
+ // unique nested structures.
10132
+ if (stack[length] == a) return true;
10133
+ }
10134
+ // Add the first object to the stack of traversed objects.
10135
+ stack.push(a);
10136
+ var size = 0, result = true;
10137
+ // Recursively compare objects and arrays.
10138
+ if (className == '[object Array]') {
10139
+ // Compare array lengths to determine if a deep comparison is necessary.
10140
+ size = a.length;
10141
+ result = size == b.length;
10142
+ if (result) {
10143
+ // Deep compare the contents, ignoring non-numeric properties.
10144
+ while (size--) {
10145
+ // Ensure commutative equality for sparse arrays.
10146
+ if (!(result = size in a == size in b && eq(a[size], b[size], stack))) break;
10147
+ }
10148
+ }
10149
+ } else {
10150
+ // Objects with different constructors are not equivalent.
10151
+ if ('constructor' in a != 'constructor' in b || a.constructor != b.constructor) return false;
10152
+ // Deep compare objects.
10153
+ for (var key in a) {
10154
+ if (_.has(a, key)) {
10155
+ // Count the expected number of properties.
10156
+ size++;
10157
+ // Deep compare each member.
10158
+ if (!(result = _.has(b, key) && eq(a[key], b[key], stack))) break;
10159
+ }
10160
+ }
10161
+ // Ensure that both objects contain the same number of properties.
10162
+ if (result) {
10163
+ for (key in b) {
10164
+ if (_.has(b, key) && !(size--)) break;
10165
+ }
10166
+ result = !size;
10167
+ }
10168
+ }
10169
+ // Remove the first object from the stack of traversed objects.
10170
+ stack.pop();
10171
+ return result;
10172
+ }
10173
+
10174
+ // Perform a deep comparison to check if two objects are equal.
10175
+ _.isEqual = function(a, b) {
10176
+ return eq(a, b, []);
10018
10177
  };
10019
10178
 
10020
- // Is a given array or object empty?
10179
+ // Is a given array, string, or object empty?
10180
+ // An "empty" object has no enumerable own-properties.
10021
10181
  _.isEmpty = function(obj) {
10182
+ if (obj == null) return true;
10022
10183
  if (_.isArray(obj) || _.isString(obj)) return obj.length === 0;
10023
- for (var key in obj) if (hasOwnProperty.call(obj, key)) return false;
10184
+ for (var key in obj) if (_.has(obj, key)) return false;
10024
10185
  return true;
10025
10186
  };
10026
10187
 
@@ -10032,48 +10193,63 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
10032
10193
  // Is a given value an array?
10033
10194
  // Delegates to ECMA5's native Array.isArray
10034
10195
  _.isArray = nativeIsArray || function(obj) {
10035
- return toString.call(obj) === '[object Array]';
10196
+ return toString.call(obj) == '[object Array]';
10197
+ };
10198
+
10199
+ // Is a given variable an object?
10200
+ _.isObject = function(obj) {
10201
+ return obj === Object(obj);
10036
10202
  };
10037
10203
 
10038
10204
  // Is a given variable an arguments object?
10039
10205
  _.isArguments = function(obj) {
10040
- return !!(obj && hasOwnProperty.call(obj, 'callee'));
10206
+ return toString.call(obj) == '[object Arguments]';
10041
10207
  };
10208
+ if (!_.isArguments(arguments)) {
10209
+ _.isArguments = function(obj) {
10210
+ return !!(obj && _.has(obj, 'callee'));
10211
+ };
10212
+ }
10042
10213
 
10043
10214
  // Is a given value a function?
10044
10215
  _.isFunction = function(obj) {
10045
- return !!(obj && obj.constructor && obj.call && obj.apply);
10216
+ return toString.call(obj) == '[object Function]';
10046
10217
  };
10047
10218
 
10048
10219
  // Is a given value a string?
10049
10220
  _.isString = function(obj) {
10050
- return !!(obj === '' || (obj && obj.charCodeAt && obj.substr));
10221
+ return toString.call(obj) == '[object String]';
10051
10222
  };
10052
10223
 
10053
10224
  // Is a given value a number?
10054
10225
  _.isNumber = function(obj) {
10055
- return !!(obj === 0 || (obj && obj.toExponential && obj.toFixed));
10226
+ return toString.call(obj) == '[object Number]';
10227
+ };
10228
+
10229
+ // Is a given object a finite number?
10230
+ _.isFinite = function(obj) {
10231
+ return _.isNumber(obj) && isFinite(obj);
10056
10232
  };
10057
10233
 
10058
- // Is the given value `NaN`? `NaN` happens to be the only value in JavaScript
10059
- // that does not equal itself.
10234
+ // Is the given value `NaN`?
10060
10235
  _.isNaN = function(obj) {
10236
+ // `NaN` is the only value for which `===` is not reflexive.
10061
10237
  return obj !== obj;
10062
10238
  };
10063
10239
 
10064
10240
  // Is a given value a boolean?
10065
10241
  _.isBoolean = function(obj) {
10066
- return obj === true || obj === false;
10242
+ return obj === true || obj === false || toString.call(obj) == '[object Boolean]';
10067
10243
  };
10068
10244
 
10069
10245
  // Is a given value a date?
10070
10246
  _.isDate = function(obj) {
10071
- return !!(obj && obj.getTimezoneOffset && obj.setUTCFullYear);
10247
+ return toString.call(obj) == '[object Date]';
10072
10248
  };
10073
10249
 
10074
10250
  // Is the given value a regular expression?
10075
10251
  _.isRegExp = function(obj) {
10076
- return !!(obj && obj.test && obj.exec && (obj.ignoreCase || obj.ignoreCase === false));
10252
+ return toString.call(obj) == '[object RegExp]';
10077
10253
  };
10078
10254
 
10079
10255
  // Is a given value equal to null?
@@ -10086,6 +10262,11 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
10086
10262
  return obj === void 0;
10087
10263
  };
10088
10264
 
10265
+ // Has own property?
10266
+ _.has = function(obj, key) {
10267
+ return hasOwnProperty.call(obj, key);
10268
+ };
10269
+
10089
10270
  // Utility Functions
10090
10271
  // -----------------
10091
10272
 
@@ -10106,6 +10287,19 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
10106
10287
  for (var i = 0; i < n; i++) iterator.call(context, i);
10107
10288
  };
10108
10289
 
10290
+ // Escape a string for HTML interpolation.
10291
+ _.escape = function(string) {
10292
+ return (''+string).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g,'&#x2F;');
10293
+ };
10294
+
10295
+ // If the value of the named property is a function then invoke it;
10296
+ // otherwise, return it.
10297
+ _.result = function(object, property) {
10298
+ if (object == null) return null;
10299
+ var value = object[property];
10300
+ return _.isFunction(value) ? value.call(object) : value;
10301
+ };
10302
+
10109
10303
  // Add your own custom functions to the Underscore object, ensuring that
10110
10304
  // they're correctly added to the OOP wrapper as well.
10111
10305
  _.mixin = function(obj) {
@@ -10126,31 +10320,86 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
10126
10320
  // following template settings to use alternative delimiters.
10127
10321
  _.templateSettings = {
10128
10322
  evaluate : /<%([\s\S]+?)%>/g,
10129
- interpolate : /<%=([\s\S]+?)%>/g
10323
+ interpolate : /<%=([\s\S]+?)%>/g,
10324
+ escape : /<%-([\s\S]+?)%>/g
10325
+ };
10326
+
10327
+ // When customizing `templateSettings`, if you don't want to define an
10328
+ // interpolation, evaluation or escaping regex, we need one that is
10329
+ // guaranteed not to match.
10330
+ var noMatch = /.^/;
10331
+
10332
+ // Certain characters need to be escaped so that they can be put into a
10333
+ // string literal.
10334
+ var escapes = {
10335
+ '\\': '\\',
10336
+ "'": "'",
10337
+ 'r': '\r',
10338
+ 'n': '\n',
10339
+ 't': '\t',
10340
+ 'u2028': '\u2028',
10341
+ 'u2029': '\u2029'
10342
+ };
10343
+
10344
+ for (var p in escapes) escapes[escapes[p]] = p;
10345
+ var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g;
10346
+ var unescaper = /\\(\\|'|r|n|t|u2028|u2029)/g;
10347
+
10348
+ // Within an interpolation, evaluation, or escaping, remove HTML escaping
10349
+ // that had been previously added.
10350
+ var unescape = function(code) {
10351
+ return code.replace(unescaper, function(match, escape) {
10352
+ return escapes[escape];
10353
+ });
10130
10354
  };
10131
10355
 
10132
10356
  // JavaScript micro-templating, similar to John Resig's implementation.
10133
10357
  // Underscore templating handles arbitrary delimiters, preserves whitespace,
10134
10358
  // and correctly escapes quotes within interpolated code.
10135
- _.template = function(str, data) {
10136
- var c = _.templateSettings;
10137
- var tmpl = 'var __p=[],print=function(){__p.push.apply(__p,arguments);};' +
10138
- 'with(obj||{}){__p.push(\'' +
10139
- str.replace(/\\/g, '\\\\')
10140
- .replace(/'/g, "\\'")
10141
- .replace(c.interpolate, function(match, code) {
10142
- return "'," + code.replace(/\\'/g, "'") + ",'";
10143
- })
10144
- .replace(c.evaluate || null, function(match, code) {
10145
- return "');" + code.replace(/\\'/g, "'")
10146
- .replace(/[\r\n\t]/g, ' ') + "__p.push('";
10147
- })
10148
- .replace(/\r/g, '\\r')
10149
- .replace(/\n/g, '\\n')
10150
- .replace(/\t/g, '\\t')
10151
- + "');}return __p.join('');";
10152
- var func = new Function('obj', tmpl);
10153
- return data ? func(data) : func;
10359
+ _.template = function(text, data, settings) {
10360
+ settings = _.defaults(settings || {}, _.templateSettings);
10361
+
10362
+ // Compile the template source, taking care to escape characters that
10363
+ // cannot be included in a string literal and then unescape them in code
10364
+ // blocks.
10365
+ var source = "__p+='" + text
10366
+ .replace(escaper, function(match) {
10367
+ return '\\' + escapes[match];
10368
+ })
10369
+ .replace(settings.escape || noMatch, function(match, code) {
10370
+ return "'+\n_.escape(" + unescape(code) + ")+\n'";
10371
+ })
10372
+ .replace(settings.interpolate || noMatch, function(match, code) {
10373
+ return "'+\n(" + unescape(code) + ")+\n'";
10374
+ })
10375
+ .replace(settings.evaluate || noMatch, function(match, code) {
10376
+ return "';\n" + unescape(code) + "\n;__p+='";
10377
+ }) + "';\n";
10378
+
10379
+ // If a variable is not specified, place data values in local scope.
10380
+ if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n';
10381
+
10382
+ source = "var __p='';" +
10383
+ "var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n" +
10384
+ source + "return __p;\n";
10385
+
10386
+ var render = new Function(settings.variable || 'obj', '_', source);
10387
+ if (data) return render(data, _);
10388
+ var template = function(data) {
10389
+ return render.call(this, data, _);
10390
+ };
10391
+
10392
+ // Provide the compiled function source as a convenience for build time
10393
+ // precompilation.
10394
+ template.source = 'function(' + (settings.variable || 'obj') + '){\n' +
10395
+ source + '}';
10396
+
10397
+ return template;
10398
+ };
10399
+
10400
+ // Add a "chain" function, which will delegate to the wrapper.
10401
+ _.chain = function(obj) {
10402
+ return _(obj).chain();
10154
10403
  };
10155
10404
 
10156
10405
  // The OOP Wrapper
@@ -10185,8 +10434,11 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
10185
10434
  each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
10186
10435
  var method = ArrayProto[name];
10187
10436
  wrapper.prototype[name] = function() {
10188
- method.apply(this._wrapped, arguments);
10189
- return result(this._wrapped, this._chain);
10437
+ var wrapped = this._wrapped;
10438
+ method.apply(wrapped, arguments);
10439
+ var length = wrapped.length;
10440
+ if ((name == 'shift' || name == 'splice') && length === 0) delete wrapped[0];
10441
+ return result(wrapped, this._chain);
10190
10442
  };
10191
10443
  });
10192
10444
 
@@ -10209,7 +10461,7 @@ if ( typeof define === "function" && define.amd && define.amd.OMjQuery ) {
10209
10461
  return this._wrapped;
10210
10462
  };
10211
10463
 
10212
- })();
10464
+ }).call(this);
10213
10465
  // Backbone.js 0.5.2
10214
10466
  // (c) 2010 Jeremy Ashkenas, DocumentCloud Inc.
10215
10467
  // Backbone may be freely distributed under the MIT license.
@@ -11635,7 +11887,7 @@ function style(element, styles) {
11635
11887
  })();
11636
11888
  (function() {
11637
11889
 
11638
- $o('head').append('<style rel="stylesheet" type="text/css">button{font-size:9px;margin:0 3px;padding:0 3px}#overlay_me_page_container{position:relative}#overlay_me_menu{position:fixed;right:0;z-index:990}#overlay_me_menu *{line-height:14px}#overlay_me_menu .drag-me{line-height:100%;display:block;color:black;font-size:.7em;text-align:center;background-image:-webkit-gradient(linear,0deg,0deg,color-stop(0%,#999),color-stop(30%,#ddd),color-stop(70%,#ddd),color-stop(100%,#999));background-image:-webkit-linear-gradient(0deg,#999,#ddd 30%,#ddd 70%,#999 100%);background-image:-moz-linear-gradient(0deg,#999,#ddd 30%,#ddd 70%,#999 100%);background-image:-o-linear-gradient(0deg,#999,#ddd 30%,#ddd 70%,#999 100%);background-image:-ms-linear-gradient(0deg,#999,#ddd 30%,#ddd 70%,#999 100%);background-image:linear-gradient(0deg,#999,#ddd 30%,#ddd 70%,#999 100%);padding:1px}#overlay_me_menu .drag-me:hover{cursor:move}#overlay_me_menu ul{list-style:none;margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}.menu-item{text-align:left;background-color:#CCC;border:1px solid rgba(255,255,255,0.2);width:200px}.menu-item a.collaps-button{cursor:pointer;position:absolute;padding-top:9px;padding-left:5px;width:13px;height:9px;border:none;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAJCAYAAADpeqZqAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAIlJREFUeNpivHDhQujz589TmZiYvjMQAP/+/eOQkZGZyfD//38ZIL77nzhwG4ilQJpA2BiIPxHQ8BGIDUHqYZpAOIWApiSYWmRNIDfPxaYaKD4bWR2KJiDmA+KzaHrOQMVxagJhfSD+ALXhA5TPQEgTCCcD8V+gpmRs8rg0MQI1eANpJmzyAAEGAKD/bax/HrzbAAAAAElFTkSuQmCC) no-repeat center 3px}.menu-item a.collaps-button span{display:none;color:yellow}.menu-item a.collaps-button span:hover{color:yellow}.menu-item label.title{padding-left:20px;color:white;cursor:pointer;width:187px;line-height:1.1em;font-size:14px;background:none}.menu-item.collapsed .item-content{display:none}.menu-item.collapsed a.collaps-button{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAANCAYAAAB7AEQGAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAKtJREFUeNpiuHz5ctD///+lgJgBF2Z68uRJOgMDw0EgNmTAAZiA4AeQVgHiA0CchFUREpsPiOcCjZ8NZWNVBAaMjIwpQGofEOvjVAQFxkATDwJxMkgNCy7HAk3kB1KzgApf4DIJBD4CcRpQ8TZcJp2D+vQiVjcBjZ8HpBxhCtAVfQbiVKDxIMd+QtbI8u/fP04gfQ+Iw4D4LDa7WSQlJUGBdxyIn+DyAUCAAQDxsEXD9kreLQAAAABJRU5ErkJggg==) no-repeat center top}#overlay_panel .content-mgnt-block{position:relative;line-height:10px}#overlay_panel .content-mgnt-block .unicorns{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAklJREFUeNqEks1u00AQx3d27V3HdezY+SBpkKBFoBZxQEKIOwfegBs3rtwoPABvw3sgceKAuFWtUBBSaT6ctvHXer2zOElTVaoKI/2lWWl/O//ZGZi8jgSPxFv3JX93+CJvfJ4/09++vzH6S/SVH59+IohH5JagxBilC4zNHHigSLvtTCPRnLYxtB4b29ojGglBc1PG1PAyLfUxzszIX7B86MwLP/iVkS566DWeEgo+gfrWdV1VJoZgpUdqon84p1a+wxI1CA+l3Z+yqu89N5a9v65EVgK8TOpgH/edZS6JAZ97/AkfKjF3pTpRkUrlfQFnoGlaHNc2F0sAzPIFWIl9WMEGTYUZJfyB12ED2l9UE6bkDAcoy+0QznXJ8nIEBosNuIb3xLoBNIlRhNlc7Ho9dDA6l1OC8gKGUGEnhAyBFmpSu8zqf9jAzqZ/RIUxFDR0G2LQ6ueIwUzGFIuE95livS4p2RaUVQYas/p+xQ4eiavPqO2nKPUcCrvlCR50uqlirXGeiUWeua4uva6vebNDwHIJErq2fW0Mdfcxpjqmqe37Nnd73US64Ummt8a5bCpZhh5UrZanfS9gBw/5tcorGSz1TJ/rCTljoomOGDTLsh+NUz8Ypdz/ndBwlpFeIdn7Hevm9miD9QNxdVGNSQzGSR3ao6Duekm23fqT3Al/Ju3waAEnr1xyayxnymhgNcU9Z7sx5LtWA+6bquxXaeLr5J+wMZebRQwDiwW2x0O7I1y7ZxOrS+X/4Y0DXJ0pANhgM4sKRv4KMACD6UDbVgTzkgAAAABJRU5ErkJggg==) no-repeat center center;width:15px;height:15px;position:absolute;right:0;top:6px}#overlay_panel label{margin:0;font-size:14px}#overlay_panel .content-mgnt-block,#overlay_panel #images_mgnt{text-align:left;padding:3px 4px;margin:2px;border:1px #777 solid;-webkit-border-radius:5px;-moz-border-radius:5px;-ms-border-radius:5px;-o-border-radius:5px;border-radius:5px}#overlay_panel .content-mgnt-block legend,#overlay_panel #images_mgnt legend{font-size:10px;padding:0 3px;margin-left:10px}#overlay_panel .slider-block{display:block}#overlay_panel .slider-block label{font-size:70%;margin:0 5px 0 0;vertical-align:top}#overlay_panel .slider-block input[type=range]{margin:0}#overlay_panel #images_mgnt{width:186px}#overlay_panel #images_mgnt .controls{padding-bottom:5px}#overlay_panel #images_mgnt .controls label{margin-right:5px}#overlay_panel #images_mgnt .overlay-image-block{text-align:left;position:relative;width:186px;border:1px solid rgba(255,255,255,0.2);border-right:none;border-left:none}#overlay_panel #images_mgnt .overlay-image-block.hovered{background-color:rgba(255,255,0,0.5)}#overlay_panel #images_mgnt .overlay-image-block .del-button{position:absolute;right:0;top:0;margin:1px;cursor:pointer;border:1px #AAA solid;font-size:10px;line-height:13px;background-color:#444;color:white;font-weight:bold;padding:0 3px}#overlay_panel #images_mgnt .dynamic-adds label{font-size:75%}#overlay_panel #images_mgnt .dynamic-adds input{width:95px;font-size:10px}#overlay_panel input[type=checkbox],#overlay_panel label,#overlay_panel #contentSlider,#overlay_panel .zindex-switch{display:inline}#overlay_panel input[type=checkbox]{vertical-align:middle;margin:-3px 5px 0 0}#overlay_me_images_container{position:absolute;z-index:4;top:0;left:0}#overlay_me_images_container div{position:absolute}#overlay_me_images_container div.highlight{border:2px solid red;margin-top:-2px;margin-left:-2px}#overlay_me_images_container div:hover{cursor:move}#overlay_me_images_container img{position:absolute;top:0;left:0}#overlay_me_menu.collapsed .drag-me,#overlay_me_menu.collapsed .menu-item{width:25px}#overlay_me_menu.collapsed .drag-me{height:10px;overflow:hidden}#overlay_me_menu.collapsed button{height:10px;overflow:hidden}#overlay_me_menu.collapsed .overlay-image-block{height:14px;margin-top:3px}#overlay_me_menu.collapsed .overlay-image-block label,#overlay_me_menu.collapsed #content_div_management_block,#overlay_me_menu.collapsed .controls,#overlay_me_menu.collapsed input[type=range],#overlay_me_menu.collapsed #overlay_panel #contentSlider,#overlay_me_menu.collapsed legend,#overlay_me_menu.collapsed .dynamic-adds,#overlay_me_menu.collapsed .unicorns,#overlay_me_menu.collapsed button.reset,#overlay_me_menu.collapsed button.hide,#overlay_me_menu.collapsed button.del-button{display:none}</style>');
11890
+ $o('head').append('<style rel="stylesheet" type="text/css">button{font-size:9px;margin:0 3px;padding:0 3px}#overlay_me_page_container{position:relative}#overlay_me_menu{position:fixed;right:0;z-index:990}#overlay_me_menu *{line-height:14px}#overlay_me_menu .drag-me{line-height:100%;display:block;color:black;font-size:.7em;text-align:center;background-image:-webkit-gradient(linear,0deg,0deg,color-stop(0%,#999),color-stop(30%,#ddd),color-stop(70%,#ddd),color-stop(100%,#999));background-image:-webkit-linear-gradient(0deg,#999,#ddd 30%,#ddd 70%,#999 100%);background-image:-moz-linear-gradient(0deg,#999,#ddd 30%,#ddd 70%,#999 100%);background-image:-o-linear-gradient(0deg,#999,#ddd 30%,#ddd 70%,#999 100%);background-image:-ms-linear-gradient(0deg,#999,#ddd 30%,#ddd 70%,#999 100%);background-image:linear-gradient(0deg,#999,#ddd 30%,#ddd 70%,#999 100%);padding:1px}#overlay_me_menu .drag-me:hover{cursor:move}#overlay_me_menu ul{list-style:none;margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}.menu-item{text-align:left;background-color:#CCC;border:1px solid rgba(255,255,255,0.2);width:200px}.menu-item a.collaps-button{cursor:pointer;position:absolute;padding-top:9px;padding-left:5px;width:13px;height:9px;border:none;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAJCAYAAADpeqZqAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAIlJREFUeNpivHDhQujz589TmZiYvjMQAP/+/eOQkZGZyfD//38ZIL77nzhwG4ilQJpA2BiIPxHQ8BGIDUHqYZpAOIWApiSYWmRNIDfPxaYaKD4bWR2KJiDmA+KzaHrOQMVxagJhfSD+ALXhA5TPQEgTCCcD8V+gpmRs8rg0MQI1eANpJmzyAAEGAKD/bax/HrzbAAAAAElFTkSuQmCC) no-repeat center 3px}.menu-item a.collaps-button span{display:none;color:yellow}.menu-item a.collaps-button span:hover{color:yellow}.menu-item label.title{padding-left:20px;color:white;cursor:pointer;width:187px;line-height:1.1em;font-size:14px;background:none}.menu-item.collapsed .item-content{display:none}.menu-item.collapsed a.collaps-button{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAANCAYAAAB7AEQGAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAKtJREFUeNpiuHz5ctD///+lgJgBF2Z68uRJOgMDw0EgNmTAAZiA4AeQVgHiA0CchFUREpsPiOcCjZ8NZWNVBAaMjIwpQGofEOvjVAQFxkATDwJxMkgNCy7HAk3kB1KzgApf4DIJBD4CcRpQ8TZcJp2D+vQiVjcBjZ8HpBxhCtAVfQbiVKDxIMd+QtbI8u/fP04gfQ+Iw4D4LDa7WSQlJUGBdxyIn+DyAUCAAQDxsEXD9kreLQAAAABJRU5ErkJggg==) no-repeat center top}#overlay_panel .content-mgnt-block{position:relative;line-height:10px}#overlay_panel .content-mgnt-block .unicorns{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAPCAYAAAA71pVKAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAklJREFUeNqEks1u00AQx3d27V3HdezY+SBpkKBFoBZxQEKIOwfegBs3rtwoPABvw3sgceKAuFWtUBBSaT6ctvHXer2zOElTVaoKI/2lWWl/O//ZGZi8jgSPxFv3JX93+CJvfJ4/09++vzH6S/SVH59+IohH5JagxBilC4zNHHigSLvtTCPRnLYxtB4b29ojGglBc1PG1PAyLfUxzszIX7B86MwLP/iVkS566DWeEgo+gfrWdV1VJoZgpUdqon84p1a+wxI1CA+l3Z+yqu89N5a9v65EVgK8TOpgH/edZS6JAZ97/AkfKjF3pTpRkUrlfQFnoGlaHNc2F0sAzPIFWIl9WMEGTYUZJfyB12ED2l9UE6bkDAcoy+0QznXJ8nIEBosNuIb3xLoBNIlRhNlc7Ho9dDA6l1OC8gKGUGEnhAyBFmpSu8zqf9jAzqZ/RIUxFDR0G2LQ6ueIwUzGFIuE95livS4p2RaUVQYas/p+xQ4eiavPqO2nKPUcCrvlCR50uqlirXGeiUWeua4uva6vebNDwHIJErq2fW0Mdfcxpjqmqe37Nnd73US64Ummt8a5bCpZhh5UrZanfS9gBw/5tcorGSz1TJ/rCTljoomOGDTLsh+NUz8Ypdz/ndBwlpFeIdn7Hevm9miD9QNxdVGNSQzGSR3ao6Duekm23fqT3Al/Ju3waAEnr1xyayxnymhgNcU9Z7sx5LtWA+6bquxXaeLr5J+wMZebRQwDiwW2x0O7I1y7ZxOrS+X/4Y0DXJ0pANhgM4sKRv4KMACD6UDbVgTzkgAAAABJRU5ErkJggg==) no-repeat center center;width:15px;height:15px;position:absolute;right:0;top:6px}#overlay_panel label{margin:0;font-size:14px}#overlay_panel .content-mgnt-block,#overlay_panel #images_mgnt{text-align:left;padding:3px 4px;margin:2px;border:1px #777 solid;-webkit-border-radius:5px;-moz-border-radius:5px;-ms-border-radius:5px;-o-border-radius:5px;border-radius:5px}#overlay_panel .content-mgnt-block legend,#overlay_panel #images_mgnt legend{font-size:10px;padding:0 3px;margin-left:10px}#overlay_panel .slider-block{display:block}#overlay_panel .slider-block label{font-size:60%;margin:0 5px 0 0;vertical-align:top}#overlay_panel .slider-block input[type=range]{margin:0;height:14px;width:120px}#overlay_panel #images_mgnt{width:186px}#overlay_panel #images_mgnt .controls{padding-bottom:2px}#overlay_panel #images_mgnt .controls label{margin-right:5px}#overlay_panel #images_mgnt .overlay-image-block,#overlay_panel #images_mgnt .images_dir{border:1px solid rgba(255,255,255,0.2);border-right:none;border-left:none;padding-top:2px}#overlay_panel #images_mgnt .overlay-image-block:first-child,#overlay_panel #images_mgnt .images_dir:first-child{border-top:none;padding-top:0}#overlay_panel #images_mgnt .overlay-image-block{text-align:left;position:relative;width:186px}#overlay_panel #images_mgnt .overlay-image-block.hovered{background-color:rgba(255,255,0,0.5)}#overlay_panel #images_mgnt .overlay-image-block .del-button{position:absolute;right:0;top:0;margin:1px;cursor:pointer;border:1px #AAA solid;font-size:10px;line-height:13px;background-color:#444;color:white;font-weight:bold;padding:0 3px}#overlay_panel #images_mgnt .images_dir{line-height:18px}#overlay_panel #images_mgnt .images_dir .sub-block{border-left:2px white solid;padding-left:2px;margin-left:5px}#overlay_panel #images_mgnt .images_dir>input[type=checkbox]{-webkit-appearance:none;background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAANCAYAAAB7AEQGAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAKtJREFUeNpiuHz5ctD///+lgJgBF2Z68uRJOgMDw0EgNmTAAZiA4AeQVgHiA0CchFUREpsPiOcCjZ8NZWNVBAaMjIwpQGofEOvjVAQFxkATDwJxMkgNCy7HAk3kB1KzgApf4DIJBD4CcRpQ8TZcJp2D+vQiVjcBjZ8HpBxhCtAVfQbiVKDxIMd+QtbI8u/fP04gfQ+Iw4D4LDa7WSQlJUGBdxyIn+DyAUCAAQDxsEXD9kreLQAAAABJRU5ErkJggg==) no-repeat center center;display:inline-block;width:13px;height:13px}#overlay_panel #images_mgnt .images_dir>input[type=checkbox]:checked{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAJCAYAAADpeqZqAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAIlJREFUeNpivHDhQujz589TmZiYvjMQAP/+/eOQkZGZyfD//38ZIL77nzhwG4ilQJpA2BiIPxHQ8BGIDUHqYZpAOIWApiSYWmRNIDfPxaYaKD4bWR2KJiDmA+KzaHrOQMVxagJhfSD+ALXhA5TPQEgTCCcD8V+gpmRs8rg0MQI1eANpJmzyAAEGAKD/bax/HrzbAAAAAElFTkSuQmCC) no-repeat center center;width:13px;height:13px;margin:-2px 5px 0 0}#overlay_panel #images_mgnt .dynamic-adds{padding-top:4px}#overlay_panel #images_mgnt .dynamic-adds label{font-size:75%}#overlay_panel #images_mgnt .dynamic-adds input{width:95px;font-size:10px;margin-left:2px}#overlay_panel #images_mgnt .dynamic-adds button{font-size:10px}#overlay_panel input[type=checkbox],#overlay_panel label,#overlay_panel #contentSlider,#overlay_panel .zindex-switch{display:inline}#overlay_panel input[type=checkbox]{vertical-align:middle;margin:-3px 5px 0 0}#overlay_me_images_container{position:absolute;z-index:4;top:0;left:0}#overlay_me_images_container div{position:absolute}#overlay_me_images_container div.highlight{border:2px solid red;margin-top:-2px;margin-left:-2px}#overlay_me_images_container div:hover{cursor:move}#overlay_me_images_container img{position:absolute;top:0;left:0}#overlay_me_menu.collapsed .drag-me,#overlay_me_menu.collapsed .menu-item{width:25px}#overlay_me_menu.collapsed .drag-me{height:10px;overflow:hidden}#overlay_me_menu.collapsed button{height:10px;overflow:hidden}#overlay_me_menu.collapsed .overlay-image-block{height:14px;margin-top:3px}#overlay_me_menu.collapsed .overlay-image-block label,#overlay_me_menu.collapsed #content_div_management_block,#overlay_me_menu.collapsed .controls,#overlay_me_menu.collapsed input[type=range],#overlay_me_menu.collapsed #overlay_panel #contentSlider,#overlay_me_menu.collapsed legend,#overlay_me_menu.collapsed .dynamic-adds,#overlay_me_menu.collapsed .unicorns,#overlay_me_menu.collapsed button.reset,#overlay_me_menu.collapsed button.hide,#overlay_me_menu.collapsed button.del-button{display:none}</style>');
11639
11891
 
11640
11892
  window.OverlayMe = {};
11641
11893
 
@@ -11667,6 +11919,9 @@ function style(element, styles) {
11667
11919
  if (element == null) {
11668
11920
  element = this.el;
11669
11921
  }
11922
+ if (!this.id) {
11923
+ return;
11924
+ }
11670
11925
  if ((cssData = localStorage.getItem(this.id))) {
11671
11926
  return $o(element).css(JSON.parse(cssData));
11672
11927
  } else {
@@ -11680,6 +11935,9 @@ function style(element, styles) {
11680
11935
  if (element == null) {
11681
11936
  element = this.el;
11682
11937
  }
11938
+ if (!this.id) {
11939
+ return;
11940
+ }
11683
11941
  if (!this.css_attributes_to_save) {
11684
11942
  this.css_attributes_to_save = ['top', 'left', 'display', 'opacity'];
11685
11943
  }
@@ -11698,22 +11956,45 @@ function style(element, styles) {
11698
11956
 
11699
11957
  OverlayMe.Mixin.Hideable = {
11700
11958
  isDisplayed: function() {
11701
- return $o(this.el).css('display') !== 'none';
11959
+ var element;
11960
+ element = this.el || this;
11961
+ return $o(element).css('display') !== 'none';
11702
11962
  },
11703
11963
  toggleDisplay: function(default_display_type) {
11704
11964
  if (default_display_type == null) {
11705
11965
  default_display_type = 'block';
11706
11966
  }
11707
11967
  if (this.isDisplayed()) {
11708
- $o(this.el).css({
11709
- display: 'none'
11710
- });
11968
+ return this.hide();
11711
11969
  } else {
11712
- $o(this.el).css({
11713
- display: default_display_type
11714
- });
11970
+ return this.show(default_display_type);
11971
+ }
11972
+ },
11973
+ show: function(default_display_type) {
11974
+ var element;
11975
+ if (default_display_type == null) {
11976
+ default_display_type = 'block';
11977
+ }
11978
+ element = this.el || this;
11979
+ $o(element).css({
11980
+ display: default_display_type
11981
+ });
11982
+ return this.saveState();
11983
+ },
11984
+ hide: function() {
11985
+ var element;
11986
+ element = this.el || this;
11987
+ $o(element).css({
11988
+ display: 'none'
11989
+ });
11990
+ return this.saveState();
11991
+ },
11992
+ saveState: function() {
11993
+ var element;
11994
+ element = this.el || this;
11995
+ if (this.saveCss) {
11996
+ return this.saveCss(element);
11715
11997
  }
11716
- return this.saveCss();
11717
11998
  }
11718
11999
  };
11719
12000
 
@@ -11851,8 +12132,10 @@ function style(element, styles) {
11851
12132
 
11852
12133
  })(OverlayMe.Draggable);
11853
12134
 
11854
- if (!OverlayMe.menu_box) {
11855
- OverlayMe.menu = new OverlayMe.MenuClass();
12135
+ if (OverlayMe.mustLoad()) {
12136
+ if (!OverlayMe.menu_box) {
12137
+ OverlayMe.menu = new OverlayMe.MenuClass();
12138
+ }
11856
12139
  }
11857
12140
 
11858
12141
  }).call(this);
@@ -11936,7 +12219,7 @@ function style(element, styles) {
11936
12219
 
11937
12220
  }).call(this);
11938
12221
  (function() {
11939
- var basics_panel, clear_all_button, collapse_button, hide_button,
12222
+ var basics_panel, clear_all_button, collapse_button, hide_button, toggle_all_display,
11940
12223
  _this = this;
11941
12224
 
11942
12225
  if (OverlayMe.mustLoad()) {
@@ -11956,17 +12239,21 @@ function style(element, styles) {
11956
12239
  onClick: "javascript: OverlayMe.clearAndReload()"
11957
12240
  }, 'Reset All (r)');
11958
12241
  basics_panel.append(clear_all_button);
12242
+ toggle_all_display = function() {
12243
+ $o(window).trigger('overlay_me:toggle_all_display');
12244
+ return $o(window).trigger('overlay_me:toggle_overlay_me_images_container_display');
12245
+ };
11959
12246
  hide_button = (new Backbone.View).make('button', {
11960
12247
  "class": 'hide'
11961
12248
  }, 'Hide (h)');
11962
12249
  $o(hide_button).bind('click', function(event) {
11963
- return $o(window).trigger('overlay_me:toggle_all_display');
12250
+ return toggle_all_display();
11964
12251
  });
11965
12252
  basics_panel.append(hide_button);
11966
12253
  OverlayMe.menu.append(basics_panel.render());
11967
12254
  $o(window).bind('keypress', function(event) {
11968
12255
  if (event.charCode === 104) {
11969
- $o(window).trigger('overlay_me:toggle_all_display');
12256
+ toggle_all_display();
11970
12257
  }
11971
12258
  if (event.charCode === 99) {
11972
12259
  OverlayMe.menu.toggleCollapse();
@@ -11993,6 +12280,45 @@ function style(element, styles) {
11993
12280
  var __hasProp = {}.hasOwnProperty,
11994
12281
  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
11995
12282
 
12283
+ OverlayMe.Overlays.ContainerItself = (function(_super) {
12284
+
12285
+ __extends(ContainerItself, _super);
12286
+
12287
+ ContainerItself.name = 'ContainerItself';
12288
+
12289
+ function ContainerItself() {
12290
+ return ContainerItself.__super__.constructor.apply(this, arguments);
12291
+ }
12292
+
12293
+ ContainerItself.prototype.tagName = 'div';
12294
+
12295
+ ContainerItself.prototype.css_attributes_to_save = ['display'];
12296
+
12297
+ ContainerItself.prototype.initialize = function(attributes, options) {
12298
+ var _this = this;
12299
+ ContainerItself.__super__.initialize.call(this, attributes, options);
12300
+ this.loadCss();
12301
+ return $o(window).bind("overlay_me:toggle_" + this.id + "_display", function(event, options) {
12302
+ if (options) {
12303
+ if (options.show) {
12304
+ return _this.show();
12305
+ } else {
12306
+ return _this.hide();
12307
+ }
12308
+ } else {
12309
+ return _this.toggleDisplay();
12310
+ }
12311
+ });
12312
+ };
12313
+
12314
+ return ContainerItself;
12315
+
12316
+ })(Backbone.View);
12317
+
12318
+ _.extend(OverlayMe.Overlays.ContainerItself.prototype, OverlayMe.Mixin.Storable);
12319
+
12320
+ _.extend(OverlayMe.Overlays.ContainerItself.prototype, OverlayMe.Mixin.Hideable);
12321
+
11996
12322
  OverlayMe.Overlays.ImagesContainer = (function(_super) {
11997
12323
 
11998
12324
  __extends(ImagesContainer, _super);
@@ -12003,35 +12329,53 @@ function style(element, styles) {
12003
12329
  return ImagesContainer.__super__.constructor.apply(this, arguments);
12004
12330
  }
12005
12331
 
12006
- ImagesContainer.prototype.id = 'overlay_me_images_container';
12007
-
12008
- ImagesContainer.prototype.css_attributes_to_save = ['display'];
12009
-
12010
- ImagesContainer.prototype.initialize = function() {
12011
- var container,
12012
- _this = this;
12013
- container = $o('#overlay_me_images_container');
12014
- if (container.length < 1) {
12015
- container = this.make('div', {
12332
+ ImagesContainer.prototype.initialize = function(options) {
12333
+ var container;
12334
+ if (!OverlayMe.images_container) {
12335
+ OverlayMe.images_container = new OverlayMe.Overlays.ContainerItself({
12016
12336
  id: 'overlay_me_images_container'
12017
12337
  });
12018
- $o('body').append(container);
12019
- this.el = container;
12338
+ $o('body').append(OverlayMe.images_container.el);
12339
+ }
12340
+ if (options.parent_path) {
12341
+ container = this.subDirContainer(options.parent_path);
12342
+ } else {
12343
+ container = OverlayMe.images_container;
12344
+ }
12345
+ return this.el = container.el || container;
12346
+ };
12347
+
12348
+ ImagesContainer.prototype.subDirContainer = function(path, done_bits) {
12349
+ var path_bits, sub_container, sub_container_parent_post_string, the_dir;
12350
+ if (done_bits == null) {
12351
+ done_bits = [];
12352
+ }
12353
+ path_bits = _.difference(path.split('/'), _.union(done_bits, ''));
12354
+ the_dir = path_bits.slice(0, 1).toString();
12355
+ if (done_bits.length > 0) {
12356
+ sub_container_parent_post_string = done_bits.join(' ').replace(/\ ?(\w+)/g, ' #$1_container');
12357
+ } else {
12358
+ sub_container_parent_post_string = '';
12359
+ }
12360
+ sub_container = $o("#overlay_me_images_container " + sub_container_parent_post_string + " #" + (the_dir + '_container'));
12361
+ if (sub_container.length < 1) {
12362
+ sub_container = new OverlayMe.Overlays.ContainerItself({
12363
+ id: the_dir + '_container'
12364
+ });
12365
+ $o("#overlay_me_images_container " + sub_container_parent_post_string).append(sub_container.el);
12366
+ }
12367
+ if (path_bits.length > 1) {
12368
+ done_bits.push(the_dir);
12369
+ return this.subDirContainer(path, done_bits);
12370
+ } else {
12371
+ return sub_container;
12020
12372
  }
12021
- this.loadCss();
12022
- return $o(window).bind('overlay_me:toggle_all_display', function() {
12023
- return _this.toggleDisplay();
12024
- });
12025
12373
  };
12026
12374
 
12027
12375
  return ImagesContainer;
12028
12376
 
12029
12377
  })(Backbone.View);
12030
12378
 
12031
- _.extend(OverlayMe.Overlays.ImagesContainer.prototype, OverlayMe.Mixin.Storable);
12032
-
12033
- _.extend(OverlayMe.Overlays.ImagesContainer.prototype, OverlayMe.Mixin.Hideable);
12034
-
12035
12379
  }).call(this);
12036
12380
  (function() {
12037
12381
  var __hasProp = {}.hasOwnProperty,
@@ -12111,25 +12455,23 @@ function style(element, styles) {
12111
12455
  Image.prototype.className = 'overlay-image-block';
12112
12456
 
12113
12457
  Image.prototype.initialize = function(image_src, options) {
12114
- var slider_block,
12458
+ var images_container, slider_block,
12115
12459
  _this = this;
12116
- if (options == null) {
12117
- options = {
12118
- destroyable: false
12119
- };
12120
- }
12460
+ $o.extend({
12461
+ destroyable: false
12462
+ }, options);
12121
12463
  this.image_src = image_src;
12122
12464
  this.image_id = OverlayMe.Overlays.urlToId(image_src);
12123
12465
  $o(this.el).attr('data-img-id', this.image_id);
12124
- if (!OverlayMe.images_container) {
12125
- OverlayMe.images_container = new OverlayMe.Overlays.ImagesContainer();
12126
- }
12466
+ images_container = new OverlayMe.Overlays.ImagesContainer({
12467
+ parent_path: options.parent_path
12468
+ });
12127
12469
  this.default_css = $o.extend({
12128
12470
  display: 'none',
12129
12471
  opacity: 0.5
12130
12472
  }, options.default_css);
12131
- if (!($o("#" + this.image_id, OverlayMe.images_container.el).length > 0)) {
12132
- $o(OverlayMe.images_container.el).append(this.image());
12473
+ if (!($o("#" + this.image_id, images_container.el).length > 0)) {
12474
+ $o(images_container.el).append(this.image());
12133
12475
  }
12134
12476
  $o(this.el).append(this.checkbox());
12135
12477
  $o(this.el).append(this.label());
@@ -12142,7 +12484,8 @@ function style(element, styles) {
12142
12484
  if (options.destroyable) {
12143
12485
  $o(this.el).append(this.delButton());
12144
12486
  }
12145
- $o(this.el).bind('click', function(event) {
12487
+ $o(this.el).bind('click', function(e) {
12488
+ e.stopPropagation();
12146
12489
  return _this.flickCheckbox();
12147
12490
  });
12148
12491
  $o(this.el).bind('mouseover', function(event) {
@@ -12246,6 +12589,87 @@ function style(element, styles) {
12246
12589
 
12247
12590
  })(Backbone.View);
12248
12591
 
12592
+ }).call(this);
12593
+ (function() {
12594
+ var __hasProp = {}.hasOwnProperty,
12595
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
12596
+
12597
+ OverlayMe.Overlays.ImagesDirectory = (function(_super) {
12598
+
12599
+ __extends(ImagesDirectory, _super);
12600
+
12601
+ ImagesDirectory.name = 'ImagesDirectory';
12602
+
12603
+ function ImagesDirectory() {
12604
+ return ImagesDirectory.__super__.constructor.apply(this, arguments);
12605
+ }
12606
+
12607
+ ImagesDirectory.prototype.tagName = 'div';
12608
+
12609
+ ImagesDirectory.prototype.className = 'images_dir';
12610
+
12611
+ ImagesDirectory.prototype.initialize = function(dirname) {
12612
+ var _this = this;
12613
+ this.dirname = dirname;
12614
+ this.contentBlock = this.make('div', {
12615
+ id: this.dirname,
12616
+ "class": 'sub-block'
12617
+ });
12618
+ _.extend(this.contentBlock, OverlayMe.Mixin.Hideable);
12619
+ _.extend(this.contentBlock, OverlayMe.Mixin.Storable);
12620
+ this.contentBlock.css_attributes_to_save = ['display'];
12621
+ this.contentBlock.loadCss(this.contentBlock);
12622
+ $o(this.el).append(this.checkbox());
12623
+ $o(this.el).append(this.label());
12624
+ $o(this.el).append(this.contentBlock);
12625
+ return $o(this.el).bind('click', function(e) {
12626
+ e.stopPropagation();
12627
+ return _this.checkbox.click();
12628
+ });
12629
+ };
12630
+
12631
+ ImagesDirectory.prototype.checkbox = function() {
12632
+ var _this = this;
12633
+ this.checkbox = this.make('input', {
12634
+ type: "checkbox"
12635
+ });
12636
+ if (this.contentBlock.isDisplayed()) {
12637
+ this.checkbox.checked = true;
12638
+ }
12639
+ $o(this.checkbox).bind('click', function(e) {
12640
+ e.stopPropagation();
12641
+ return _this.flickVisibility();
12642
+ });
12643
+ return this.checkbox;
12644
+ };
12645
+
12646
+ ImagesDirectory.prototype.flickVisibility = function() {
12647
+ if (this.checkbox.checked) {
12648
+ this.contentBlock.show();
12649
+ } else {
12650
+ this.contentBlock.hide();
12651
+ }
12652
+ return $o(window).trigger("overlay_me:toggle_" + this.dirname + "_container_display", {
12653
+ show: this.checkbox.checked
12654
+ });
12655
+ };
12656
+
12657
+ ImagesDirectory.prototype.label = function() {
12658
+ return this.label = this.make('label', {}, '/' + this.dirname + '/');
12659
+ };
12660
+
12661
+ ImagesDirectory.prototype.append = function(block) {
12662
+ return this.contentBlock.appendChild(block);
12663
+ };
12664
+
12665
+ ImagesDirectory.prototype.render = function() {
12666
+ return this.el;
12667
+ };
12668
+
12669
+ return ImagesDirectory;
12670
+
12671
+ })(Backbone.View);
12672
+
12249
12673
  }).call(this);
12250
12674
  (function() {
12251
12675
  var __hasProp = {}.hasOwnProperty,
@@ -12504,19 +12928,7 @@ function style(element, styles) {
12504
12928
  ImagesManagementDiv.prototype.id = 'images_mgnt';
12505
12929
 
12506
12930
  ImagesManagementDiv.prototype.initialize = function() {
12507
- var check_all_label,
12508
- _this = this;
12509
12931
  $o(this.el).append(this.make('legend', {}, 'Overlaying images'));
12510
- this.controlBlock = this.make('div', {
12511
- "class": 'controls'
12512
- });
12513
- $o(this.el).append(this.controlBlock);
12514
- this.controlBlock.appendChild(this.checkAllbox());
12515
- check_all_label = this.make('label', {}, 'All/None');
12516
- $o(check_all_label).bind('click', function() {
12517
- return $o(_this.checkAllBox).trigger('click');
12518
- });
12519
- this.controlBlock.appendChild(check_all_label);
12520
12932
  this.overlaysListBlock = this.make('div', {
12521
12933
  "class": 'overlays-list'
12522
12934
  });
@@ -12563,33 +12975,6 @@ function style(element, styles) {
12563
12975
  return this.image_url_input.value = '';
12564
12976
  };
12565
12977
 
12566
- ImagesManagementDiv.prototype.checkAllbox = function() {
12567
- var _this = this;
12568
- this.checkAllBox = this.make('input', {
12569
- type: "checkbox",
12570
- "class": 'check-all'
12571
- });
12572
- $o(this.checkAllBox).bind('change', function(event) {
12573
- return _this.checkAll();
12574
- });
12575
- return this.checkAllBox;
12576
- };
12577
-
12578
- ImagesManagementDiv.prototype.checkAll = function() {
12579
- var checkbox, checkbox_state, _i, _len, _ref;
12580
- checkbox_state = this.checkAllBox.checked;
12581
- _ref = $o('.overlay-image-block input[type=checkbox]');
12582
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
12583
- checkbox = _ref[_i];
12584
- if (checkbox.checked !== checkbox_state) {
12585
- $o(checkbox).trigger('click');
12586
- }
12587
- }
12588
- return this.saveState();
12589
- };
12590
-
12591
- ImagesManagementDiv.prototype.saveState = function() {};
12592
-
12593
12978
  ImagesManagementDiv.prototype.render = function() {
12594
12979
  return this.el;
12595
12980
  };
@@ -12600,7 +12985,7 @@ function style(element, styles) {
12600
12985
 
12601
12986
  }).call(this);
12602
12987
  (function() {
12603
- var overlay_panel;
12988
+ var buildTree, displayTree, files_tree, overlay_panel, shiftTofiles;
12604
12989
 
12605
12990
  if (OverlayMe.mustLoad()) {
12606
12991
  overlay_panel = new OverlayMe.MenuItem({
@@ -12628,15 +13013,83 @@ function style(element, styles) {
12628
13013
  if (data.length === 0) {
12629
13014
  return OverlayMe.loadDefaultImage();
12630
13015
  } else {
12631
- return $o.each(data, function(index, img_path) {
12632
- return OverlayMe.images_management_div.append(new OverlayMe.Overlays.Image(img_path).render());
12633
- });
13016
+ return buildTree(data);
12634
13017
  }
12635
13018
  },
12636
13019
  error: function() {
12637
13020
  return OverlayMe.loadDefaultImage();
12638
13021
  }
12639
13022
  });
13023
+ files_tree = {};
13024
+ buildTree = function(data) {
13025
+ $o.each(data, function(index, img_path) {
13026
+ var bit, bits, parent_path, position, _results;
13027
+ bits = img_path.split('/');
13028
+ position = files_tree;
13029
+ parent_path = '/';
13030
+ _results = [];
13031
+ while (bits.length > 0) {
13032
+ bit = bits[0];
13033
+ bits = bits.slice(1);
13034
+ if (bit === "") {
13035
+ continue;
13036
+ }
13037
+ parent_path += bit + '/';
13038
+ if (position[bit] === void 0) {
13039
+ if (bits.length > 0) {
13040
+ position[bit] = {
13041
+ parent_path: parent_path
13042
+ };
13043
+ } else {
13044
+ if (position['files'] === void 0) {
13045
+ position['files'] = [];
13046
+ }
13047
+ position['files'].push(bit);
13048
+ }
13049
+ }
13050
+ _results.push(position = position[bit]);
13051
+ }
13052
+ return _results;
13053
+ });
13054
+ files_tree = shiftTofiles(files_tree);
13055
+ return displayTree(OverlayMe.images_management_div, files_tree);
13056
+ };
13057
+ shiftTofiles = function(tree) {
13058
+ var keys;
13059
+ if (tree.files) {
13060
+ return tree;
13061
+ }
13062
+ keys = Object.keys(tree);
13063
+ if (keys.length > 2) {
13064
+ return tree;
13065
+ }
13066
+ keys = _.without(keys, 'parent_path');
13067
+ return shiftTofiles(tree[keys[0]]);
13068
+ };
13069
+ displayTree = function(parent, tree) {
13070
+ var dir, img, sub_dir, _i, _j, _len, _len1, _ref, _ref1, _results;
13071
+ _ref = Object.keys(tree);
13072
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
13073
+ dir = _ref[_i];
13074
+ if (dir === 'files' || dir === 'parent_path') {
13075
+ continue;
13076
+ }
13077
+ sub_dir = new OverlayMe.Overlays.ImagesDirectory(dir);
13078
+ parent.append(sub_dir.render());
13079
+ displayTree(sub_dir, tree[dir]);
13080
+ }
13081
+ if (tree.files) {
13082
+ _ref1 = tree.files;
13083
+ _results = [];
13084
+ for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
13085
+ img = _ref1[_j];
13086
+ _results.push(parent.append(new OverlayMe.Overlays.Image(tree.parent_path + img, {
13087
+ parent_path: tree.parent_path
13088
+ }).render()));
13089
+ }
13090
+ return _results;
13091
+ }
13092
+ };
12640
13093
  }
12641
13094
 
12642
13095
  }).call(this);