constructor-core 0.2.12 → 0.2.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,33 @@
1
+ if (!Object.keys) {
2
+ Object.keys = (function () {
3
+ var hasOwnProperty = Object.prototype.hasOwnProperty,
4
+ hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),
5
+ dontEnums = [
6
+ 'toString',
7
+ 'toLocaleString',
8
+ 'valueOf',
9
+ 'hasOwnProperty',
10
+ 'isPrototypeOf',
11
+ 'propertyIsEnumerable',
12
+ 'constructor'
13
+ ],
14
+ dontEnumsLength = dontEnums.length;
15
+
16
+ return function (obj) {
17
+ if (typeof obj !== 'object' && typeof obj !== 'function' || obj === null) throw new TypeError('Object.keys called on non-object');
18
+
19
+ var result = [];
20
+
21
+ for (var prop in obj) {
22
+ if (hasOwnProperty.call(obj, prop)) result.push(prop);
23
+ }
24
+
25
+ if (hasDontEnumBug) {
26
+ for (var i=0; i < dontEnumsLength; i++) {
27
+ if (hasOwnProperty.call(obj, dontEnums[i])) result.push(dontEnums[i]);
28
+ }
29
+ }
30
+ return result;
31
+ }
32
+ })()
33
+ };
@@ -0,0 +1,142 @@
1
+ (function() {
2
+
3
+ var root = (typeof exports == 'undefined' ? window : exports);
4
+
5
+ var config = {
6
+ // Ensure Content-Type is an image before trying to load @2x image
7
+ // https://github.com/imulus/retinajs/pull/45)
8
+ check_mime_type: true
9
+ };
10
+
11
+
12
+
13
+ root.Retina = Retina;
14
+
15
+ function Retina() {}
16
+
17
+ Retina.configure = function(options) {
18
+ if (options == null) options = {};
19
+ for (var prop in options) config[prop] = options[prop];
20
+ };
21
+
22
+ Retina.init = function(context) {
23
+ if (context == null) context = root;
24
+
25
+ var existing_onload = context.onload || new Function;
26
+
27
+ context.onload = function() {
28
+ var images = document.getElementsByTagName("img"), retinaImages = [], i, image;
29
+ for (i = 0; i < images.length; i++) {
30
+ image = images[i];
31
+ retinaImages.push(new RetinaImage(image));
32
+ }
33
+ existing_onload();
34
+ }
35
+ };
36
+
37
+ Retina.isRetina = function(){
38
+ var mediaQuery = "(-webkit-min-device-pixel-ratio: 1.5),\
39
+ (min--moz-device-pixel-ratio: 1.5),\
40
+ (-o-min-device-pixel-ratio: 3/2),\
41
+ (min-resolution: 1.5dppx)";
42
+
43
+ if (root.devicePixelRatio > 1)
44
+ return true;
45
+
46
+ if (root.matchMedia && root.matchMedia(mediaQuery).matches)
47
+ return true;
48
+
49
+ return false;
50
+ };
51
+
52
+
53
+ root.RetinaImagePath = RetinaImagePath;
54
+
55
+ function RetinaImagePath(path, at_2x_path) {
56
+ this.path = path;
57
+ if (typeof at_2x_path !== "undefined" && at_2x_path !== null) {
58
+ this.at_2x_path = at_2x_path;
59
+ this.perform_check = false;
60
+ } else {
61
+ this.at_2x_path = path.replace(/\.\w+$/, function(match) { return "@2x" + match; });
62
+ this.perform_check = true;
63
+ }
64
+ }
65
+
66
+ RetinaImagePath.confirmed_paths = [];
67
+
68
+ RetinaImagePath.prototype.is_external = function() {
69
+ return !!(this.path.match(/^https?\:/i) && !this.path.match('//' + document.domain) )
70
+ }
71
+
72
+ RetinaImagePath.prototype.check_2x_variant = function(callback) {
73
+ var http, that = this;
74
+ if (this.is_external()) {
75
+ return callback(false);
76
+ } else if (!this.perform_check && typeof this.at_2x_path !== "undefined" && this.at_2x_path !== null) {
77
+ return callback(true);
78
+ } else if (this.at_2x_path in RetinaImagePath.confirmed_paths) {
79
+ return callback(true);
80
+ } else {
81
+ http = new XMLHttpRequest;
82
+ http.open('HEAD', this.at_2x_path);
83
+ http.onreadystatechange = function() {
84
+ if (http.readyState != 4) {
85
+ return callback(false);
86
+ }
87
+
88
+ if (http.status >= 200 && http.status <= 399) {
89
+ if (config.check_mime_type) {
90
+ var type = http.getResponseHeader('Content-Type');
91
+ if (type == null || !type.match(/^image/i)) {
92
+ return callback(false);
93
+ }
94
+ }
95
+
96
+ RetinaImagePath.confirmed_paths.push(that.at_2x_path);
97
+ return callback(true);
98
+ } else {
99
+ return callback(false);
100
+ }
101
+ }
102
+ http.send();
103
+ }
104
+ }
105
+
106
+
107
+
108
+ function RetinaImage(el) {
109
+ this.el = el;
110
+ this.path = new RetinaImagePath(this.el.getAttribute('src'), this.el.getAttribute('data-at2x'));
111
+ var that = this;
112
+ this.path.check_2x_variant(function(hasVariant) {
113
+ if (hasVariant) that.swap();
114
+ });
115
+ }
116
+
117
+ root.RetinaImage = RetinaImage;
118
+
119
+ RetinaImage.prototype.swap = function(path) {
120
+ if (typeof path == 'undefined') path = this.path.at_2x_path;
121
+
122
+ var that = this;
123
+ function load() {
124
+ if (! that.el.complete) {
125
+ setTimeout(load, 5);
126
+ } else {
127
+ that.el.setAttribute('width', that.el.offsetWidth);
128
+ that.el.setAttribute('height', that.el.offsetHeight);
129
+ that.el.setAttribute('src', path);
130
+ }
131
+ }
132
+ load();
133
+ }
134
+
135
+
136
+
137
+
138
+ if (Retina.isRetina()) {
139
+ Retina.init(root);
140
+ }
141
+
142
+ })();
@@ -3,7 +3,7 @@
3
3
  Gem::Specification.new do |s|
4
4
  s.platform = Gem::Platform::RUBY
5
5
  s.name = %q{constructor-core}
6
- s.version = '0.2.12'
6
+ s.version = '0.2.14'
7
7
  s.summary = %q{Default for Constructor}
8
8
  s.authors = ['Ivan Zotov']
9
9
  s.require_paths = %w(lib)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: constructor-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.12
4
+ version: 0.2.14
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-27 00:00:00.000000000 Z
12
+ date: 2013-05-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: devise
@@ -60,6 +60,8 @@ files:
60
60
  - app/assets/javascripts/constructor_core/jquery.cookie.js
61
61
  - app/assets/javascripts/constructor_core/jquery.treeview.js
62
62
  - app/assets/javascripts/constructor_core/jquery_bundle.js.coffee
63
+ - app/assets/javascripts/constructor_core/keys_snippet.js
64
+ - app/assets/javascripts/constructor_core/retina.js
63
65
  - app/assets/javascripts/constructor_core/urlify.js
64
66
  - app/assets/stylesheets/constructor_core/application.css.scss
65
67
  - app/assets/stylesheets/constructor_core/bootstrap-responsive.css