From 04adfbcd66691487cb702c15c145fca335d97c87 Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Mon, 15 Sep 2014 15:47:51 +0200 Subject: [PATCH] user upgrades --- Gemfile | 2 +- Gemfile.lock | 13 +++-- .../javascripts/user/app/router.js.coffee | 1 + .../routes/application_route.js.coffee.erb | 51 ++++++++++--------- .../user/app/templates/scanning.emblem | 3 ++ .../_foundation_and_overrides.css.sass | 1 - .../user/foundation/application.css.sass | 4 +- .../foundation/components/_menu_main.css.sass | 2 + .../_modal.css.sass} | 5 +- .../_index.css.sass} | 0 .../user/foundation/pages/_scanning.css.sass | 27 ++++++++++ 11 files changed, 75 insertions(+), 34 deletions(-) create mode 100644 app/assets/javascripts/user/app/templates/scanning.emblem rename app/assets/stylesheets/user/foundation/{_qmodal.css.sass => components/_modal.css.sass} (75%) rename app/assets/stylesheets/user/foundation/{_qindex.css.sass => pages/_index.css.sass} (100%) create mode 100644 app/assets/stylesheets/user/foundation/pages/_scanning.css.sass diff --git a/Gemfile b/Gemfile index 7ad3e083..ec7ec985 100644 --- a/Gemfile +++ b/Gemfile @@ -35,7 +35,7 @@ group :assets do gem 'uglifier', '>= 1.0.3' gem 'emblem-rails' - gem 'foundation-rails' + gem 'foundation-rails', github: 'bterkuile/foundation-rails' #gem 'mustache' #, :require => 'mustache/railtie' end diff --git a/Gemfile.lock b/Gemfile.lock index e8a58088..71b87f22 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -26,6 +26,14 @@ GIT devise_simply_stored (0.3.0) devise +GIT + remote: git://github.com/bterkuile/foundation-rails.git + revision: a2e857867e93a3e3bc74b4a61fe72349a86158e9 + specs: + foundation-rails (5.4.3.1) + railties (>= 3.1.0) + sass (>= 3.2.0) + GIT remote: git://github.com/bterkuile/simply_stored.git revision: 354fde89a88c1384ccc9d82989e3f05ac6977bd1 @@ -199,9 +207,6 @@ GEM websocket-driver (>= 0.3.1) font-awesome-rails (4.2.0.0) railties (>= 3.2, < 5.0) - foundation-rails (5.4.3.1) - railties (>= 3.1.0) - sass (>= 3.2.0) fuubar (2.0.0) rspec (~> 3.0) ruby-progressbar (~> 1.4) @@ -436,7 +441,7 @@ DEPENDENCIES factory_girl_rails faye font-awesome-rails - foundation-rails + foundation-rails! fuubar iso_country_codes jquery-rails diff --git a/app/assets/javascripts/user/app/router.js.coffee b/app/assets/javascripts/user/app/router.js.coffee index 8722ee0b..7ac3571d 100644 --- a/app/assets/javascripts/user/app/router.js.coffee +++ b/app/assets/javascripts/user/app/router.js.coffee @@ -15,3 +15,4 @@ App.Router.map -> @route 'settings' @route 'product_orders' @route 'error' + @route 'scanning' diff --git a/app/assets/javascripts/user/app/routes/application_route.js.coffee.erb b/app/assets/javascripts/user/app/routes/application_route.js.coffee.erb index 28a38bc3..b3b7597f 100644 --- a/app/assets/javascripts/user/app/routes/application_route.js.coffee.erb +++ b/app/assets/javascripts/user/app/routes/application_route.js.coffee.erb @@ -101,34 +101,35 @@ App.ApplicationRoute = Ember.Route.extend <% if Rails.env.user_app? %> ar = @ scanner = cordova.require("cordova/plugin/BarcodeScanner") - scanner.scan (result)-> - if result.cancelled - ar.transitionTo('index') - $log - action: 'qrscan' - result: 'cancel' - else - table_id_index = result.text.indexOf('s?t='); - if table_id_index > -1 - table_id = result.text.substr(table_id_index + 4); - # ar.transitionTo 'table', table_id - # ar.actions.selectQr.call(ar, table: {_id: table_id}) - ar.send('selectQr', _id: table_id) - else - ar.transitionTo('index').then (route)-> - route.get('controller.controllers.application').set 'notice', "we got a barcode: '#{result.text}' but cannot extract a table id" + @transitionTo('scanning').then -> + scanner.scan (result)-> + if result.cancelled + ar.transitionTo('index') $log action: 'qrscan' - error: 'cannot extract table id' - info: result.text + result: 'cancel' + else + table_id_index = result.text.indexOf('s?t='); + if table_id_index > -1 + table_id = result.text.substr(table_id_index + 4); + # ar.transitionTo 'table', table_id + # ar.actions.selectQr.call(ar, table: {_id: table_id}) + ar.send('selectQr', _id: table_id) + else + ar.transitionTo('index').then (route)-> + route.get('controller.controllers.application').set 'notice', "we got a barcode: '#{result.text}' but cannot extract a table id" + $log + action: 'qrscan' + error: 'cannot extract table id' + info: result.text - , (error)-> - $log - action: 'qrscan' - error: 'scan failed' - info: error - ar.transitionTo('index').then (route)-> - route.get('controller.controllers.application').set 'notice', "scanning failed: #{error}" + , (error)-> + $log + action: 'qrscan' + error: 'scan failed' + info: error + ar.transitionTo('index').then (route)-> + route.get('controller.controllers.application').set 'notice', "scanning failed: #{error}" <% else %> @transitionTo 'select_qrcode' <% end %> diff --git a/app/assets/javascripts/user/app/templates/scanning.emblem b/app/assets/javascripts/user/app/templates/scanning.emblem new file mode 100644 index 00000000..c925dfe4 --- /dev/null +++ b/app/assets/javascripts/user/app/templates/scanning.emblem @@ -0,0 +1,3 @@ +.page-scanning + .scanning-qr-image: span + .scanning-laser diff --git a/app/assets/stylesheets/supplier/foundation1/_foundation_and_overrides.css.sass b/app/assets/stylesheets/supplier/foundation1/_foundation_and_overrides.css.sass index f50c00d8..26c09ae8 100644 --- a/app/assets/stylesheets/supplier/foundation1/_foundation_and_overrides.css.sass +++ b/app/assets/stylesheets/supplier/foundation1/_foundation_and_overrides.css.sass @@ -1257,4 +1257,3 @@ $button-edit-color: #ffa $button-destroy-color: #faa $button-submit-color: $primary-color $button-cancel-color: $secondary-color - diff --git a/app/assets/stylesheets/user/foundation/application.css.sass b/app/assets/stylesheets/user/foundation/application.css.sass index 4d64efef..6bd6b01b 100644 --- a/app/assets/stylesheets/user/foundation/application.css.sass +++ b/app/assets/stylesheets/user/foundation/application.css.sass @@ -1,11 +1,11 @@ @import constants +@import bourbon @import ./qconstants @import ./foundation_and_overrides @import font-awesome @import ./structure @import ./components/* -@import ./qmodal +@import ./pages/* @import ./display_fields @import ./qproduct_orders -@import ./qindex @import ./qlists diff --git a/app/assets/stylesheets/user/foundation/components/_menu_main.css.sass b/app/assets/stylesheets/user/foundation/components/_menu_main.css.sass index e9e226f1..758f936b 100644 --- a/app/assets/stylesheets/user/foundation/components/_menu_main.css.sass +++ b/app/assets/stylesheets/user/foundation/components/_menu_main.css.sass @@ -20,6 +20,8 @@ header.top-menu .top-menu-logo @media #{$small-only} display: none + img + margin-top: -6px .menu-content background-color: white background-repeat: repeat-x diff --git a/app/assets/stylesheets/user/foundation/_qmodal.css.sass b/app/assets/stylesheets/user/foundation/components/_modal.css.sass similarity index 75% rename from app/assets/stylesheets/user/foundation/_qmodal.css.sass rename to app/assets/stylesheets/user/foundation/components/_modal.css.sass index 5fbbe4f4..94b84e97 100644 --- a/app/assets/stylesheets/user/foundation/_qmodal.css.sass +++ b/app/assets/stylesheets/user/foundation/components/_modal.css.sass @@ -1,8 +1,10 @@ .modal - margin: 10px auto + margin: auto + margin-top: 90px width: 300px background-color: #fff padding: 1em + z-index: 9085 .overlay height: 100% @@ -11,6 +13,7 @@ top: 0 left: 0 background-color: rgba(0, 0, 0, 0.2) + z-index: 9084 .flush--top margin-top: 0 diff --git a/app/assets/stylesheets/user/foundation/_qindex.css.sass b/app/assets/stylesheets/user/foundation/pages/_index.css.sass similarity index 100% rename from app/assets/stylesheets/user/foundation/_qindex.css.sass rename to app/assets/stylesheets/user/foundation/pages/_index.css.sass diff --git a/app/assets/stylesheets/user/foundation/pages/_scanning.css.sass b/app/assets/stylesheets/user/foundation/pages/_scanning.css.sass new file mode 100644 index 00000000..c94dc53b --- /dev/null +++ b/app/assets/stylesheets/user/foundation/pages/_scanning.css.sass @@ -0,0 +1,27 @@ +$scanning-code-width: 200px +$scanning-code-height: $scanning-code-width/0.785 +.page-scanning + width: $scanning-code-width + margin-left: auto + margin-right: auto + position: relative + margin-top: 30px + .scanning-qr-image + position: absolute + font-size: $scanning-code-height + span + @extend .fa + @extend .fa-qrcode + .scanning-laser + position: absolute + height: $scanning-code-height + border-right: 2px solid #f00 + +animation(scanning 1s infinite) + +animation-direction(alternate) + +animation-timing-function(linear) + ++keyframes(scanning) + from + left: 0 + to + left: $scanning-code-width