Created
November 21, 2012 15:32
-
-
Save ricogallo/4125469 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class window.Application extends Page | |
bind: -> | |
@facebook_app_id = $("meta[property='fb:app_id']").attr('content') | |
@app_url = window.location.protocol + "//" + window.location.host | |
@authenticity_token = $('meta[name="csrf-token"]').attr('content') | |
new Cities | |
setTimeout () -> | |
new AppPusher | |
, 2000 | |
if window.user | |
if user.is_seller | |
#... | |
@topnavigation_el.append """ | |
<div class="menu"> | |
<a href="#/">Store Builder</a> | |
<a href="#{router.myBookingsPath()}"> | |
<span class="bubble"> | |
<div id="unreadCount"></div> | |
</span> | |
My Bookings | |
</a> | |
<a href="#{router.inviteBuddiesPath()}">Invite Friends</a> | |
<a href="#/my_profile">Preview</a> | |
<a el="submit_for_approval" class="lastElement">Publish</a> | |
</div> | |
""" | |
# unread messages on right of the header | |
@unread_counter = new JSCounter.NumberCounter('unreadCount',{start:0}) | |
@unread_counter.render() | |
setTimeout () => | |
@setUnreadCount(_unread_count) | |
, 1 | |
CurrentUser.onChange (e) => | |
@showUser(e.user) | |
@showUser(user) | |
@assignNodes(".menu") | |
@submit_for_approval_el.click => | |
console.log "ciaooooooo" | |
question = | |
if user.profile_waiting_approval | |
'Really wish to cancel your request to publish your store?' | |
else | |
""" | |
<p>We carefully review each store before it gets published.</p> | |
<p>Use the short statement and your bio to tell us your personal story; Why you do what you do and what makes you unique.</p> | |
<p>A picture is worth a thousand words. Take full advantage of the front cover by using a clear / high resolution photo.</p> | |
<p>Make your service cards look amazing with relevant pictures and good copy. Be descriptive and make people dream.</p> | |
<p>Ask your friends and clients for endorsements: it will make you look more personal and professional.</p> | |
<p>Steady, ready, go!</p> | |
""" | |
ConfirmDialogue.open( | |
question: question | |
ok: 'Submit' | |
width: 600 | |
callback: (choice) => | |
if choice == yes | |
Model.post( | |
'/api/users/submit_for_approval', | |
{cancel:user.profile_waiting_approval}, | |
(user) => | |
window.user = new CurrentUser(user) | |
@showUser(window.user) | |
) | |
) | |
showUser: (user) -> | |
@username_el.text(user.displayName()) | |
$(".whiteStripe .progressBar .bar").css("width", perc + '%') | |
setUnreadCount: (count)-> | |
@unread_count = count | |
if count >= 0 | |
@unread_counter.setNumber(count) | |
$('#unreadCount').toggleClass('zero', count == 0) | |
showing_upon_visit = false | |
route: (path) -> | |
if window.user | |
unless showing_upon_visit | |
action = user.show_upon_visit | |
if !user.is_seller && path == '' && action | |
showing_upon_visit = true | |
@go action | |
@current_view.onHide => | |
Model.delete('/api/user/show_upon_visit') | |
return | |
super(path) | |
default: -> | |
if user.is_seller | |
return 'doer' | |
else | |
'feed' | |
doer: -> | |
new DoersPage $('#pageContent') | |
feed: -> | |
new FeedView $('#pageContent') | |
invite_buddies: -> | |
new InviteBuddies $('#pageContent') | |
my_activity: -> | |
new MyActivity(document.body) | |
private_profile: -> | |
new PrivateProfile $('#pageContent'), user | |
public_profile: -> | |
new PublicProfile $('#pageContent') | |
my_profile: -> | |
if user.is_seller | |
new PublicProfile $('#pageContent') | |
else | |
new PosterProfile $('#pageContent') | |
wallet: -> | |
$('#pageContent').append(root = $("<div>")) | |
new Wallet(root) | |
requests: -> | |
$('#pageContent').append(root = $("<div>")) | |
new TasksStatus(root) | |
tasks: -> | |
new CallFunctionView () => | |
@go 'requests' | |
showPrivateProfile: -> | |
@go 'private_profile' | |
user: -> | |
new UserView | |
showUserById: (id) -> | |
return unless id | |
@route "public_profile;id=#{id}/default" | |
showOffer: (offer, params = {}) -> | |
params.id = offer.permalink | |
@route "" | |
#@current_view.go "browse" | |
@current_view.current_view.current_view.go("offer", params) | |
showNewOffer: (offer) -> | |
params = {id:offer.permalink} | |
@route "" | |
v = @current_view.current_view.current_view | |
v.go("offer", params) | |
v.current_view.go 'just_posted' | |
openOfferForm: (offer) -> | |
Offer.findByPermalink offer.permalink, (offer) => | |
unless offer.assigned_to | |
@go 'my_activity' | |
@current_view.go 'edit_offer', id: offer.permalink | |
else | |
@error "Can't edit task which is in progress." | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment