arcabouco 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c3c0a87f4e4f9d8a80184108b76a6436d710d59a
4
- data.tar.gz: 2cccd14159b35e932860546fbc5d28e22436ee09
3
+ metadata.gz: 80cb888b4be443d4b22f15fbb3dbbe5e0107e734
4
+ data.tar.gz: f0e8eeddc1979d7c8a5d5d3011ef5c3501e10d21
5
5
  SHA512:
6
- metadata.gz: ec25aae37ccfddd695471e68f342f4b820093d5e0e194c773e9a8b9124a4cc19df0736ae3a3d7e7800289924f6ad7e940c9b7690840370c8433aabf4021fe2c9
7
- data.tar.gz: 70124443e671e04b03f5e4155408a1f85184eadb5e87cf37596ca419423d2cc1716eb26680e9733541137429e828d2666ab75dbe8fd734172d8d073ab5e7d89e
6
+ metadata.gz: 7a819d4822c785ded6d14ee9fb6db51fdcaf07e64e8b258478da3d28bf357fa47f0700c5caa721a8790bd127a4a3e9f114d5495401cc949f23289abca2026472
7
+ data.tar.gz: d1587804498b4faab776e23541ef0a26722576d499729b1c3e027e4add87840438b1205a7541a780f4ced3adb5b26a58bad62da93263ec524cad4bd4b08c1afe
@@ -40,7 +40,7 @@ module Arcabouco
40
40
  mattr_accessor :asset_list
41
41
  mattr_accessor :application_name
42
42
 
43
- self.asset_list = %w(app.css app.js vendor.js vendor.css *.png *.jpg *.gif *.mp3 *.wav)
43
+ self.asset_list = %w(app.css app.js app.vendor.js app.vendor.css *.png *.jpg *.gif *.mp3 *.wav)
44
44
  self.application_name = "Arcabouco Application"
45
45
 
46
46
  def self.setup
@@ -1,3 +1,3 @@
1
1
  module Arcabouco
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Adding a UTF-8 Character to Fix áé
3
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
4
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
5
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
6
+ *= require vendor
7
+ */
8
+
data/lib/assets/js/app.js CHANGED
@@ -1,7 +1,8 @@
1
+ //= require './core/debug'
2
+ //= require './core/helpers'
1
3
  //= require './core/capabilities'
4
+ //= require './core/extends'
2
5
  //= require './core/environment'
3
- //= require './core/debug'
4
- //= require './core/sound'
5
6
  //= require 'config'
6
7
  //= require './core/boot'
7
8
  //= require 'main'
@@ -0,0 +1,2 @@
1
+ //= require handlebars.runtime
2
+ //= require 'vendor'
@@ -1,2 +1,33 @@
1
1
  app.debug "Starting WebApp Framework"
2
2
 
3
+ app.module_load = (name) ->
4
+ app._bootstrap_list[name] = false
5
+
6
+ app.module_ready = (name) ->
7
+ app._bootstrap_list[name] = true
8
+
9
+ app.load_modules = ->
10
+ for module,status of app._bootstrap_list
11
+ return if status == 1
12
+
13
+ app.debug 'Loaded modules: '
14
+ for name of app._bootstrap_list
15
+ app.debug ' - ' + name
16
+
17
+ clearInterval app._bootstrap_list_loader
18
+ delete app._bootstrap_list
19
+ delete app._bootstrap_list_loader
20
+
21
+ if app.main
22
+ app.main()
23
+
24
+ app.boot = ->
25
+ app.debug "Booting started..."
26
+ app.debug 'Detected capabilities: ' + document.documentElement.className + ' ' + navigator.oscpu + ' ' + navigator.platform + navigator.userAgent
27
+ app.debug 'Detected language: ' + detectLanguage()
28
+
29
+ if app.document_domain
30
+ document.domain = app.document_domain
31
+
32
+ app._bootstrap_list_loader = setInterval( @load_modules, 250 )
33
+ app.load_modules()
@@ -126,86 +126,4 @@ var BrowserDetect = {
126
126
  };
127
127
  BrowserDetect.init();
128
128
 
129
- $( function() {
130
-
131
- window.IS_MOBILE = false;
132
- window.IS_DESKTOP = false;
133
- window.IS_IOS = false;
134
- window.IS_ANDROID = false;
135
- window.IS_DEPRECATED_ANDROID = false;
136
-
137
- $("html").removeClass("no-js").addClass("js");
138
- $("html").removeClass("not-ready").addClass("ready");
139
- if (navigator.userAgent.match(/Android/i)) { $("html").addClass("android mobile"); window.IS_MOBILE=true; window.IS_ANDROID=true; }
140
- else if (navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i)) { $("html").addClass("ios mobile"); window.IS_MOBILE=true; window.IS_IOS=true }
141
- else { $("html").addClass("desktop"); window.IS_DESKTOP=true }
142
-
143
- $("html").addClass( BrowserDetect.browser.toLowerCase() )
144
- $("html").addClass( BrowserDetect.browser.toLowerCase() + '_' + BrowserDetect.version )
145
- $("html").addClass( 'os_' + BrowserDetect.OS.toLowerCase() )
146
-
147
- var ua = navigator.userAgent;
148
- if( ua.indexOf("Android") >= 0 )
149
- {
150
- var androidversion = parseFloat(ua.slice(ua.indexOf("Android")+8));
151
- if (androidversion < 3)
152
- {
153
- $("html").addClass( 'deprecated_android' );
154
- window.IS_DEPRECATED_ANDROID = true;
155
- }
156
- }
157
-
158
- window.TOUCH_SUPPORT = jQuery.support.touch;
159
-
160
- window.matchMedia = window.matchMedia || (function(doc, undefined){
161
-
162
- var bool,
163
- docElem = doc.documentElement,
164
- refNode = docElem.firstElementChild || docElem.firstChild,
165
- // fakeBody required for <FF4 when executed in <head>
166
- fakeBody = doc.createElement('body'),
167
- div = doc.createElement('div');
168
-
169
- div.id = 'mq-test-1';
170
- div.style.cssText = "position:absolute;top:-100em";
171
- fakeBody.style.background = "none";
172
- fakeBody.appendChild(div);
173
-
174
- return function(q){
175
-
176
- div.innerHTML = '&shy;<style media="'+q+'"> #mq-test-1 { width: 42px; }</style>';
177
-
178
- docElem.insertBefore(fakeBody, refNode);
179
- bool = div.offsetWidth == 42;
180
- docElem.removeChild(fakeBody);
181
-
182
- return { matches: bool, media: q };
183
- };
184
-
185
- })(document);
186
-
187
- window.HAS_MEDIAQUERY = window.matchMedia && window.matchMedia( "only all" ).matches;
188
-
189
- function configureMediaQuery() {
190
- $("body").removeClass("mq-mp"); // Mobile Portrait
191
- $("body").removeClass("mq-ml"); // Mobile Landscape
192
- $("body").removeClass("mq-tb"); // For Tablets
193
- $("body").removeClass("mq-ls"); // For Large Screens
194
- $("body").removeClass("mq-sm"); // For Small Screens
195
- var queryWidth = $(window).width();
196
- if (queryWidth < 480) $("body").addClass("mq-mp");
197
- else if (queryWidth < 768 && queryWidth > 479) $("body").addClass("mq-mp");
198
- else if (queryWidth < 1023 && queryWidth > 767) $("body").addClass("mq-tb");
199
- else if (queryWidth > 768) $("body").addClass("mq-ls");
200
- else if (queryWidth < 769) $("body").addClass("mq-sm");
201
- }
202
-
203
- if (window.HAS_MEDIAQUERY) {
204
- $("html").addClass("mediaquery");
205
- } else {
206
- configureMediaQuery();
207
- $(window).resize(configureMediaQuery);
208
- }
209
-
210
- });
211
-
129
+ // TODO - Convert detect capabilities
@@ -1,3 +1,4 @@
1
1
  window.app.debug = (message) ->
2
- if (window.app.enable_debug)
3
- console.log message
2
+ return unless window.app.enable_debug
3
+ console.log message
4
+
@@ -1,9 +1,12 @@
1
1
  @app = window.app
2
+
3
+ # List of Modules/Features to Load
4
+ @app._bootstrap_list = {}
5
+
2
6
  # @app._routers = []
3
7
  # @app.routes = {}
4
8
  # @app.activeView = null
5
9
  # @app.ui = {}
6
- # @app._features = {}
7
10
  # @app.domain = ''
8
11
  @app.enable_debug = true
9
12
 
@@ -0,0 +1,6 @@
1
+ String.prototype.capitalize = ->
2
+ @replace( /(^|\s)([a-z])/g , (m,p1,p2) ->
3
+ p1+p2.toUpperCase()
4
+ )
5
+
6
+
@@ -0,0 +1,16 @@
1
+ @getMousePos = ( event ) ->
2
+ if TOUCH_SUPPORT
3
+ touch = event.originalEvent.touches[0] || event.originalEvent.changedTouches[0]
4
+ cur_x = touch.pageX
5
+ cur_y = touch.pageY
6
+ else
7
+ cur_x = event.clientX
8
+ cur_y = event.clientY
9
+ return { x: cur_x, y: cur_y }
10
+
11
+ @distanceFrom = ( x, y, x0, y0 ) ->
12
+ Math.sqrt((x -= x0) * x + (y -= y0) * y)
13
+
14
+ @detectLanguage = ->
15
+ language = window.navigator.userLanguage || window.navigator.language
16
+ language = language.toLowerCase().replace('-','').replace('_','')
@@ -1,7 +0,0 @@
1
- //= require handlebars.runtime
2
- //= require ./vendor/jquery.js
3
- //= require ./vendor/underscore.js
4
- //= require ./vendor/backbone.js
5
- //= require ./vendor/async.js
6
- //= require ./vendor/tasks.js
7
-
@@ -1,3 +1,5 @@
1
+ app._lastUpdate = (new Date()).getTime();
2
+
1
3
  function _getJSON(url,callback) {
2
4
  var xobj = new XMLHttpRequest();
3
5
  xobj.overrideMimeType("application/json");
@@ -27,14 +29,16 @@ function _loadCSS(src)
27
29
  function bootstrapApplication()
28
30
  {
29
31
  if (app.bootstraped) return;
30
- app.bootstraped = true;
31
32
  if (app.enable_debug) console.log("DEBUG: Bootstrap Application. Manifest (" + app.assets_manifest + ")");
32
33
  _getJSON( app.assets_manifest, function(data) {
33
- _loadCSS( data.assets['vendor.css'] );
34
+ _loadCSS( data.assets['app.vendor.css'] );
34
35
  _loadCSS( data.assets['app.css'] );
35
- _loadJS( data.assets['vendor.js'], function() {
36
+ _loadJS( data.assets['app.vendor.js'], function() {
36
37
  _loadJS( data.assets['app.js'], function() {
37
- $('#application_preload_layer').remove();
38
+ app.boot();
39
+ app.bootstraped = true;
40
+ var el = document.getElementById('application_preload_layer');
41
+ el.parentNode.removeChild(el);
38
42
  });
39
43
  });
40
44
  });
@@ -48,6 +52,13 @@ function updateApplicationDownloadProgress(progress)
48
52
 
49
53
  function refreshApplicationFiles()
50
54
  {
55
+ // Fix to browser finding new content
56
+ _lastUpdate = Math.ceil( app._lastUpdate/1000 );
57
+ _currentUpdate = Math.ceil( (new Date()).getTime()/1000 );
58
+ if (app.enable_debug) console.log("DEBUG: Last Update: " + _lastUpdate);
59
+ if (_lastUpdate+5 < _currentUpdate) return;
60
+ app._lastUpdate = _currentUpdate;
61
+
51
62
  app.applicationCache.swapCache();
52
63
  if (app.bootstraped == false) {
53
64
  bootstrapApplication();
@@ -6,7 +6,9 @@ CACHE:
6
6
 
7
7
  <% if assets['app.js'] %>/app.assets/<%= assets['app.js'].digest_path %><% end %>
8
8
 
9
- <% if assets['vendor.js'] %>/app.assets/<%= assets['vendor.js'].digest_path %><% end %>
9
+ <% if assets['app.vendor.css'] %>/app.assets/<%= assets['app.vendor.css'].digest_path %><% end %>
10
+
11
+ <% if assets['app.vendor.js'] %>/app.assets/<%= assets['app.vendor.js'].digest_path %><% end %>
10
12
 
11
13
  NETWORK:
12
14
  *
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arcabouco
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Negri
@@ -296,6 +296,7 @@ files:
296
296
  - lib/arcabouco/version.rb
297
297
  - lib/assets/css/adaptative-mixins.sass
298
298
  - lib/assets/css/app.css
299
+ - lib/assets/css/app.vendor.css
299
300
  - lib/assets/css/arcabouco-entry.sass
300
301
  - lib/assets/css/base.css
301
302
  - lib/assets/css/core.sass
@@ -304,20 +305,18 @@ files:
304
305
  - lib/assets/css/reset.sass
305
306
  - lib/assets/css/vendor.css
306
307
  - lib/assets/js/app.js
308
+ - lib/assets/js/app.vendor.js
307
309
  - lib/assets/js/config.js.coffee
308
310
  - lib/assets/js/core/boot.js.coffee
309
311
  - lib/assets/js/core/capabilities.js
310
312
  - lib/assets/js/core/debug.js.coffee
311
313
  - lib/assets/js/core/environment.js.coffee
312
- - lib/assets/js/core/sound.coffee
314
+ - lib/assets/js/core/extends.coffee
315
+ - lib/assets/js/core/helpers.js.coffee
313
316
  - lib/assets/js/main.js
314
317
  - lib/assets/js/vendor.js
315
318
  - lib/assets/js/vendor/async.js
316
- - lib/assets/js/vendor/backbone.js
317
- - lib/assets/js/vendor/handlebars.js
318
- - lib/assets/js/vendor/jquery.js
319
319
  - lib/assets/js/vendor/tasks.js.coffee
320
- - lib/assets/js/vendor/underscore.js
321
320
  - lib/templates/bootstrap_code.js
322
321
  - lib/templates/index.html.erb
323
322
  - lib/templates/manifest.erb
@@ -1,67 +0,0 @@
1
- class _Sound
2
- format: if $.browser.webkit then ".mp3" else ".wav"
3
- soundPath: "/app.assets/"
4
- sound: []
5
- environmentSound: null
6
- maxChannels: 8
7
-
8
- constructor: () ->
9
- @sound.size = 8
10
- for i in [0..7]
11
- @sound[i] = null
12
-
13
- loadSoundChannel: (name) ->
14
- snd = new Audio( @soundPath + name + @format )
15
- snd.preload = false
16
- snd.load()
17
- snd
18
-
19
- enableDesktopLoop: ( env ) ->
20
- if typeof env.loop == 'boolean'
21
- env.loop = true
22
- else
23
- env.addEventListener( 'ended',
24
- () ->
25
- this.currentTime = 0
26
- this.play()
27
- false
28
- )
29
-
30
- playDesktop: (name, options = {}) ->
31
- if options.environmentSound
32
- @environmentSound.stop() if @environmentSound
33
- @environmentSound = @loadSoundChannel( name )
34
- @enableDesktopLoop( @environmentSound ) if options.environmentSound
35
- @environmentSound.play()
36
- return
37
-
38
- aChannel = false
39
- for i in [0..8]
40
- if @sound[i] == null
41
- aChannel = i
42
- break
43
- else if @sound[i] and (@sound[i].currentTime == @sound[i].duration || @sound[i].currentTime == 0)
44
- aChannel = i
45
- break
46
-
47
- @sound[ aChannel ] = @loadSoundChannel( name )
48
- @enableDesktopLoop( @sound[ aChannel ] ) if options.environmentSound
49
- @sound[ aChannel ].play()
50
-
51
- stopDesktop: (channel) ->
52
- @sound[channel].stop() if @sound[channel] and (@sound[channel].currentTime == @sound[channel].duration || @sound[channel].currentTime == 0)
53
-
54
- stopEnvironmentDesktop: ->
55
- @environmentSound.stop() if @environmentSound
56
-
57
- # SUPPORT CORDOVA
58
- play: (name, options = {}) ->
59
- @playDesktop name, options unless IS_MOBILE
60
-
61
- stop: (channel) ->
62
- @stopDesktop channel unless IS_MOBILE
63
-
64
- stopEnvironment: ->
65
- @stopEnvironmentDesktop() unless IS_MOBILE
66
-
67
- window.Sound = new _Sound()