mass assignment on server #3

This commit is contained in:
Tyler Renelle 2013-01-18 17:36:14 -05:00
parent 3c8d18e55e
commit ef980102ba
3 changed files with 6 additions and 9 deletions

View file

@ -35,7 +35,7 @@ get '/', (page, model, next) ->
# support legacy Everyauth schema (now using derby-auth, Passport) # support legacy Everyauth schema (now using derby-auth, Passport)
if username = userObj.auth?.local?.username if username = userObj.auth?.local?.username
_view.loginName = username _view.loginName = username
else if fb = userObj.auth.facebook else if fb = userObj.auth?.facebook
_view.loginName = if fb._raw then "#{fb.name.givenName} #{fb.name.familyName}" else fb.name _view.loginName = if fb._raw then "#{fb.name.givenName} #{fb.name.familyName}" else fb.name
# Setup Item Store # Setup Item Store
@ -50,10 +50,7 @@ get '/', (page, model, next) ->
_.each ['habitIds','dailyIds','todoIds','rewardIds'], (path) -> _.each ['habitIds','dailyIds','todoIds','rewardIds'], (path) ->
unique = _.uniq userObj[path] #remove duplicates unique = _.uniq userObj[path] #remove duplicates
#remove empty grey tasks #remove empty grey tasks
userObj[path] = _.filter(unique, (val) -> userObj[path] = _.filter(unique, (val) -> _.contains(taskIds, val))
console.log {objId:val, taskIds:taskIds}
_.contains(taskIds, val)
)
# ========== Notifiations ========== # ========== Notifiations ==========
unless userObj.notifications.kickstarter unless userObj.notifications.kickstarter
@ -97,7 +94,7 @@ ready (model) ->
$('[rel=tooltip]').tooltip() $('[rel=tooltip]').tooltip()
$('[rel=popover]').popover() $('[rel=popover]').popover()
unless (model.get('_mobileDevice') == true) #don't do sortable on mobile unless (model.get('_view.mobileDevice') == true) #don't do sortable on mobile
# Make the lists draggable using jQuery UI # Make the lists draggable using jQuery UI
# Note, have to setup helper function here and call it for each type later # Note, have to setup helper function here and call it for each type later
# due to variable binding of "type" # due to variable binding of "type"

View file

@ -9,7 +9,7 @@ module.exports = (model) ->
# Load public/js/* files # Load public/js/* files
# TODO use Bower # TODO use Bower
require '../../public/js/jquery.min' require '../../public/js/jquery.min'
require '../../public/js/jquery-ui.min' unless model.get('_mobileDevice') require '../../public/js/jquery-ui.min' unless model.get('_view.mobileDevice')
require '../../public/js/bootstrap.min' #http://twitter.github.com/bootstrap/assets/js/bootstrap.min.js require '../../public/js/bootstrap.min' #http://twitter.github.com/bootstrap/assets/js/bootstrap.min.js
require '../../public/js/jquery.cookie' #https://raw.github.com/carhartl/jquery-cookie/master/jquery.cookie.js require '../../public/js/jquery.cookie' #https://raw.github.com/carhartl/jquery-cookie/master/jquery.cookie.js
require '../../public/js/bootstrap-tour' #https://raw.github.com/pushly/bootstrap-tour/master/bootstrap-tour.js require '../../public/js/bootstrap-tour' #https://raw.github.com/pushly/bootstrap-tour/master/bootstrap-tour.js
@ -17,7 +17,7 @@ module.exports = (model) ->
# JS files not needed right away (google charts) or entirely optional (analytics) # JS files not needed right away (google charts) or entirely optional (analytics)
# Each file getsload asyncronously via $.getScript, so it doesn't bog page-load # Each file getsload asyncronously via $.getScript, so it doesn't bog page-load
unless model.get('_mobileDevice') unless model.get('_view.mobileDevice')
# Addthis # Addthis
$.getScript "https://s7.addthis.com/js/250/addthis_widget.js#pubid=lefnire" $.getScript "https://s7.addthis.com/js/250/addthis_widget.js#pubid=lefnire"

View file

@ -11,7 +11,7 @@ model = undefined
setModel = (m) -> setModel = (m) ->
model = m model = m
user = model.at('_user') user = model.at('_user')
setupNotifications() unless model.get('_mobileDevice') setupNotifications() unless model.get('_view.mobileDevice')
setupNotifications = -> setupNotifications = ->
return unless jQuery? # Only run this in the browser return unless jQuery? # Only run this in the browser