flight-for-rails 1.1.3 → 1.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a93dc1c47c9e3ba0bd06e30468a72b3562a7536c
4
- data.tar.gz: 57e09d4d2a18359ae41d446eef897cbd7971c7ae
3
+ metadata.gz: d88eda3b9ee66fd3f576a3ae5d16432d289405b5
4
+ data.tar.gz: d46961d373630ab7ee3b1b2fdcaf3ee598db915f
5
5
  SHA512:
6
- metadata.gz: 9f37a790cd4636b80bf1a0a4e3c3b838f2f84633216e4c3ca0ff2429b6b6e44dac5683e6bf2344aa6085345018553e29818b7a405ee077f74e9d9bee4ffa7456
7
- data.tar.gz: aac69228d7cabb3ad6e49551f0d2a6f0745633131f9b6b9fa9b7f1a9d34094b6d6d3fe57563b08a533ed12605a5e00979b3016c1477d4e97b17a0678eb2fb245
6
+ metadata.gz: 5c4eb45143451494d6510d3231e136218eebadf8a13f3f1f36432cf56385e237d0d81c7f5da46d34bd5d21b461fadabc335f0815b34d91ccc1ba5e194de8008e
7
+ data.tar.gz: e5b594a85fc77f9148d98a0028f885f098a925d1480af8ff4a7e4eaf08baf512b30928f2f94387e7a24fa3a0dbe8fcc2124f2fdbf75d36249121d245956c6d2c
data/.gitignore CHANGED
@@ -0,0 +1 @@
1
+ pkg/
data/README.md CHANGED
@@ -3,7 +3,7 @@ FlightForRails
3
3
 
4
4
  FlightForRails is a plugin for Rails assets pipeline, which integrates your applicaiton with Twitter Flight javascript framework. Flight is a lightweight, component-based javascript framework that maps behavior to DOM nodes. Twitter uses it for their web applications. Why do not you try it? :)
5
5
 
6
- For more information see [official Flight page](http://twitter.github.com/flight).
6
+ For more information see [official Flight page](http://twitter.github.com/flight) and [changelog](https://github.com/flightjs/flight/blob/master/CHANGELOG.md).
7
7
 
8
8
  ## Browser Support
9
9
 
@@ -16,7 +16,7 @@ This gem vendors Flight files and dependecies for Rails assets pipeline.
16
16
  First add the following lines to your application `Gemfile`:
17
17
 
18
18
  ``` ruby
19
- gem 'flight-for-rails', '~> 1.1.2'
19
+ gem 'flight-for-rails', '~> 1.1.3'
20
20
  ```
21
21
 
22
22
  Then run `bundle install` to update your's gems bundle.
@@ -40,7 +40,7 @@ Simple example:
40
40
  ``` coffeescript
41
41
  # app/assets/javascript/components/my-component.js.coffee
42
42
  $ ->
43
- MyComponent = flight.component
43
+ MyComponent = flight.component ->
44
44
  @after 'initialize', ->
45
45
  @on 'click', @triggerMyEvent
46
46
 
@@ -53,7 +53,7 @@ $ ->
53
53
  ``` coffeescript
54
54
  # app/assets/javascript/components/my-component-2.js.coffee
55
55
  $ ->
56
- MyComponent2 = flight.component
56
+ MyComponent2 = flight.component ->
57
57
  @after 'initialize', ->
58
58
  @on 'myEvent', @handleMyEvent
59
59
 
@@ -71,10 +71,6 @@ And don't forget add the following line to your manifest file (usualy `app/asset
71
71
 
72
72
  Pretty awesome! Enjoy!
73
73
 
74
- ## Authors
75
-
76
- + [Sergey Rezvanov](http://github.com/rezwyi)
77
-
78
74
  ## Copyright
79
75
 
80
76
  See LICENSE file.
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require File.expand_path('../lib/flight-for-rails/version', __FILE__)
2
+
2
3
  require 'rubygems'
3
4
  require 'bundler/setup'
5
+ require 'open-uri'
4
6
 
5
7
  Bundler::GemHelper.install_tasks
6
8
 
@@ -30,4 +32,4 @@ namespace :flight do
30
32
  end
31
33
  end
32
34
  end
33
- end
35
+ end
@@ -1,2 +1,2 @@
1
1
  # This file is generated automatically
2
- module FlightForRails; VERSION = '1.1.3'; end
2
+ module FlightForRails; VERSION = '1.1.4'; end
@@ -1,4 +1,4 @@
1
- /*! Flight v1.1.3 | (c) Twitter, Inc. | MIT License */
1
+ /*! Flight v1.1.4 | (c) Twitter, Inc. | MIT License */
2
2
  (function(context) {
3
3
  var factories = {}, loaded = {};
4
4
  var isArray = Array.isArray || function(obj) {
@@ -213,8 +213,8 @@ define('lib/utils', [], function () {
213
213
  if (ran) {
214
214
  return result;
215
215
  }
216
- result = func.apply(this, arguments);
217
216
  ran = true;
217
+ result = func.apply(this, arguments);
218
218
  return result;
219
219
  };
220
220
  }
@@ -310,10 +310,11 @@ define('lib/debug', [], function () {
310
310
  // ==========================================
311
311
  var ALL = 'all';
312
312
  //no filter
313
- //no logging by default
314
- var defaultEventNamesFilter = [];
315
- var defaultActionsFilter = [];
316
- var logFilter = retrieveLogFilter();
313
+ //log nothing by default
314
+ var logFilter = {
315
+ eventNames: [],
316
+ actions: []
317
+ };
317
318
  function filterEventLogsByAction() {
318
319
  var actions = [].slice.call(arguments);
319
320
  logFilter.eventNames.length || (logFilter.eventNames = ALL);
@@ -337,24 +338,32 @@ define('lib/debug', [], function () {
337
338
  saveLogFilter();
338
339
  }
339
340
  function saveLogFilter() {
340
- if (window.localStorage) {
341
- localStorage.setItem('logFilter_eventNames', logFilter.eventNames);
342
- localStorage.setItem('logFilter_actions', logFilter.actions);
341
+ try {
342
+ if (window.localStorage) {
343
+ localStorage.setItem('logFilter_eventNames', logFilter.eventNames);
344
+ localStorage.setItem('logFilter_actions', logFilter.actions);
345
+ }
346
+ } catch (ignored) {
343
347
  }
348
+ ;
344
349
  }
345
350
  function retrieveLogFilter() {
346
- var result = {
347
- eventNames: window.localStorage && localStorage.getItem('logFilter_eventNames') || defaultEventNamesFilter,
348
- actions: window.localStorage && localStorage.getItem('logFilter_actions') || defaultActionsFilter
349
- };
350
- // reconstitute arrays
351
- Object.keys(result).forEach(function (k) {
352
- var thisProp = result[k];
351
+ var eventNames, actions;
352
+ try {
353
+ eventNames = window.localStorage && localStorage.getItem('logFilter_eventNames');
354
+ actions = window.localStorage && localStorage.getItem('logFilter_actions');
355
+ } catch (ignored) {
356
+ return;
357
+ }
358
+ eventNames && (logFilter.eventNames = eventNames);
359
+ actions && (logFilter.actions = actions);
360
+ // reconstitute arrays in place
361
+ Object.keys(logFilter).forEach(function (k) {
362
+ var thisProp = logFilter[k];
353
363
  if (typeof thisProp == 'string' && thisProp !== ALL) {
354
- result[k] = thisProp.split(',');
364
+ logFilter[k] = thisProp ? thisProp.split(',') : [];
355
365
  }
356
366
  });
357
- return result;
358
367
  }
359
368
  return {
360
369
  enable: function (enable) {
@@ -363,6 +372,7 @@ define('lib/debug', [], function () {
363
372
  console.info('Booting in DEBUG mode');
364
373
  console.info('You can configure event logging with DEBUG.events.logAll()/logNone()/logByName()/logByAction()');
365
374
  }
375
+ retrieveLogFilter();
366
376
  window.DEBUG = this;
367
377
  },
368
378
  find: {
@@ -431,13 +441,13 @@ define('lib/compose', [
431
441
  }
432
442
  function mixin(base, mixins) {
433
443
  base.mixedIn = base.hasOwnProperty('mixedIn') ? base.mixedIn : [];
434
- mixins.forEach(function (mixin) {
435
- if (base.mixedIn.indexOf(mixin) == -1) {
444
+ for (var i = 0; i < mixins.length; i++) {
445
+ if (base.mixedIn.indexOf(mixins[i]) == -1) {
436
446
  setPropertyWritability(base, false);
437
- mixin.call(base);
438
- base.mixedIn.push(mixin);
447
+ mixins[i].call(base);
448
+ base.mixedIn.push(mixins[i]);
439
449
  }
440
- });
450
+ }
441
451
  setPropertyWritability(base, true);
442
452
  }
443
453
  return {
@@ -932,6 +942,7 @@ define('lib/logger', ['./utils'], function (utils) {
932
942
  payload && info.push(payload);
933
943
  info.push(elemToString(elem));
934
944
  info.push(component.constructor.describe.split(' ').slice(0, 3).join(' '));
945
+ console.groupCollapsed && action == 'trigger' && console.groupCollapsed(action, name);
935
946
  console.info.apply(console, info);
936
947
  }
937
948
  }
@@ -939,6 +950,11 @@ define('lib/logger', ['./utils'], function (utils) {
939
950
  this.before('trigger', function () {
940
951
  log('trigger', this, utils.toArray(arguments));
941
952
  });
953
+ if (console.groupCollapsed) {
954
+ this.after('trigger', function () {
955
+ console.groupEnd();
956
+ });
957
+ }
942
958
  this.before('on', function () {
943
959
  log('on', this, utils.toArray(arguments));
944
960
  });
@@ -1009,35 +1025,48 @@ define('lib/component', [
1009
1025
  new this().initialize(node, options);
1010
1026
  }.bind(this));
1011
1027
  }
1028
+ function prettyPrintMixins() {
1029
+ //could be called from constructor or constructor.prototype
1030
+ var mixedIn = this.mixedIn || this.prototype.mixedIn || [];
1031
+ return mixedIn.map(function (mixin) {
1032
+ if (mixin.name == null) {
1033
+ // function name property not supported by this browser, use regex
1034
+ var m = mixin.toString().match(functionNameRegEx);
1035
+ return m && m[1] ? m[1] : '';
1036
+ } else {
1037
+ return mixin.name != 'withBase' ? mixin.name : '';
1038
+ }
1039
+ }).filter(Boolean).join(', ');
1040
+ }
1041
+ ;
1012
1042
  // define the constructor for a custom component type
1013
1043
  // takes an unlimited number of mixin functions as arguments
1014
1044
  // typical api call with 3 mixins: define(timeline, withTweetCapability, withScrollCapability);
1015
1045
  function define() {
1016
1046
  // unpacking arguments by hand benchmarked faster
1017
1047
  var l = arguments.length;
1018
- // add three for common mixins
1019
- var mixins = new Array(l + 3);
1048
+ var mixins = new Array(l);
1020
1049
  for (var i = 0; i < l; i++)
1021
1050
  mixins[i] = arguments[i];
1022
1051
  var Component = function () {
1023
1052
  };
1024
- Component.toString = Component.prototype.toString = function () {
1025
- var prettyPrintMixins = mixins.map(function (mixin) {
1026
- if (mixin.name == null) {
1027
- // function name property not supported by this browser, use regex
1028
- var m = mixin.toString().match(functionNameRegEx);
1029
- return m && m[1] ? m[1] : '';
1030
- } else {
1031
- return mixin.name != 'withBase' ? mixin.name : '';
1032
- }
1033
- }).filter(Boolean).join(', ');
1034
- return prettyPrintMixins;
1035
- };
1053
+ Component.toString = Component.prototype.toString = prettyPrintMixins;
1036
1054
  if (debug.enabled) {
1037
1055
  Component.describe = Component.prototype.describe = Component.toString();
1038
1056
  }
1039
1057
  // 'options' is optional hash to be merged with 'defaults' in the component definition
1040
1058
  Component.attachTo = attachTo;
1059
+ // enables extension of existing "base" Components
1060
+ Component.mixin = function () {
1061
+ var newComponent = define();
1062
+ //TODO: fix pretty print
1063
+ var newPrototype = Object.create(Component.prototype);
1064
+ newPrototype.mixedIn = [].concat(Component.prototype.mixedIn);
1065
+ compose.mixin(newPrototype, arguments);
1066
+ newComponent.prototype = newPrototype;
1067
+ newComponent.prototype.constructor = newComponent;
1068
+ return newComponent;
1069
+ };
1041
1070
  Component.teardownAll = teardownAll;
1042
1071
  // prepend common mixins to supplied list, then mixin all flavors
1043
1072
  if (debug.enabled) {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flight-for-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Rezvanov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-19 00:00:00.000000000 Z
11
+ date: 2014-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  requirements: []
79
79
  rubyforge_project:
80
- rubygems_version: 2.0.6
80
+ rubygems_version: 2.2.2
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: Flight javascript framework for Rails assets pipeline