Create a gist now

Instantly share code, notes, and snippets.

@ryardley /phpfication.haml Secret
Last active Aug 29, 2015

What would you like to do?
PHPfication
.Address.ng-cloak{"ng-controller" => "addressCtrl", "ng-init" => "changingAddress = #{@user.full_address.blank?}"}
.Address-current(ng-hide="changingAddress")
.control-group
.control-label= t('listings.show.info.address')
.controls
.form_text {{full_address}}
.control-group
.controls
%a.Address-change.btn(ng-hide="changingAddress" ng-click="setChangingAddress()")= t('.change_address')
.ChangingAddress(ng-show="changingAddress")
.control-group
%label.control-label= t('listings.show.info.subaddress')
.controls
%span.input
%input{'ng-model'=>'subaddress', type: 'text', placeholder:t('listings.show.info.subaddress_placeholder')}
.control-group{class: @user.errors[:city].present? ? 'error' : ''}
%label.control-label(for="googleAddressAutocomplete")
%span.required.has-localeColor *
= t('listings.show.info.address')
.controls
%span.input.AddressAutocomplete{placeholder: t('listings.show.info.sample_address', company_address: t('company_address'))}
%span.help-inline
= @user.errors[:city].try(:first)
{{addressErrors}}
.hide
= text_field_tag 'user[full_address]', @user.full_address, 'ng-model' => 'full_address'
= text_field_tag 'user[address]', @user.address, 'ng-model' => 'address'
= text_field_tag 'user[city]', @user.city, 'ng-model' => 'city'
= text_field_tag 'user[postcode]', @user.postcode, 'ng-model' => 'postcode'
= text_field_tag 'user[region]', @user.region, 'ng-model' => 'region'
= text_field_tag 'user[latitude]', @user.latitude, 'ng-model' => 'latitude'
= text_field_tag 'user[longitude]', @user.longitude, 'ng-model' => 'longitude'
- if @user.account_type != 'private'
.control-groups
.controls
.StaticMap
- content_for :js_at_bottom do
:javascript
window.userMapsOptions = {
googleMapsApiKey: '#{@key}'
};
= javascript_include_tag GooglePlaceLibrary.javascript_path.html_safe
= javascript_include_tag 'angular/address/require'
:javascript
window.address = #{JSON.generate(@user.attributes.slice('latitude', 'longitude', 'address', 'city', 'postcode').merge(full_address: @user.full_address, region: @user.region))};
angular.bootstrap(jQuery('.Address'), ['address']);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment