MSSM aspect switcher in mobile interface plus tests; added check for ipad useragent
This commit is contained in:
parent
752d50a6a9
commit
218aa1c0d6
10 changed files with 501 additions and 416 deletions
|
|
@ -28,7 +28,11 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
def mobile_except_ipad
|
def mobile_except_ipad
|
||||||
if is_mobile_device?
|
if is_mobile_device?
|
||||||
session[:mobile_view] = false if request.env["HTTP_USER_AGENT"].include? "iPad"
|
if request.env["HTTP_USER_AGENT"].include? "iPad"
|
||||||
|
session[:mobile_view] = false
|
||||||
|
else
|
||||||
|
session[:mobile_view] = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
6
app/helpers/mobile_helper.rb
Normal file
6
app/helpers/mobile_helper.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
module MobileHelper
|
||||||
|
def aspect_select_options(aspects, selected)
|
||||||
|
selected_id = selected == :all ? "" : selected.id
|
||||||
|
'<option value="" >All</option>\n'.html_safe + options_from_collection_for_select(aspects, "id", "name", selected_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
11
app/views/aspects/show.mobile.haml
Normal file
11
app/views/aspects/show.mobile.haml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
-# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
-# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
|
= render 'shared/publisher', :aspect => @aspect
|
||||||
|
|
||||||
|
= render 'shared/stream', :posts => @posts
|
||||||
|
|
||||||
|
#pagination
|
||||||
|
= will_paginate @posts
|
||||||
|
|
||||||
|
|
@ -10,11 +10,14 @@
|
||||||
|
|
||||||
%meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
|
%meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
|
||||||
|
|
||||||
= javascript_include_tag 'vendor/jquery144.min','rails'
|
|
||||||
= include_javascripts :mobile
|
= include_javascripts :mobile
|
||||||
= stylesheet_link_tag 'mobile', 'vendor/jquery_mobile.min'
|
= stylesheet_link_tag 'mobile', 'vendor/jquery_mobile.min'
|
||||||
= csrf_meta_tag
|
= csrf_meta_tag
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
$(document).ready(Mobile.initialize);
|
||||||
|
|
||||||
|
|
||||||
= yield(:head)
|
= yield(:head)
|
||||||
|
|
||||||
%body
|
%body
|
||||||
|
|
@ -24,7 +27,7 @@
|
||||||
= person_image_tag (current_user.person)
|
= person_image_tag (current_user.person)
|
||||||
= current_user.real_name
|
= current_user.real_name
|
||||||
%div{:data => {:role => 'fieldcontain'}}
|
%div{:data => {:role => 'fieldcontain'}}
|
||||||
=select_tag "aspects", options_from_collection_for_select(@aspects, "id", "name")
|
= select_tag "aspect_picker", aspect_select_options(@aspects, @aspect)
|
||||||
|
|
||||||
= yield
|
= yield
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,11 @@ javascripts:
|
||||||
- public/javascripts/image-picker.js
|
- public/javascripts/image-picker.js
|
||||||
- public/javascripts/stream.js
|
- public/javascripts/stream.js
|
||||||
mobile:
|
mobile:
|
||||||
|
- public/javascripts/vendor/jquery144.min.js
|
||||||
|
- public/javascripts/rails.js
|
||||||
- public/javascripts/vendor/jquery-ui-1.8.6.custom.min.js
|
- public/javascripts/vendor/jquery-ui-1.8.6.custom.min.js
|
||||||
- public/javascripts/vendor/jquery_mobile_a2.min.js
|
- public/javascripts/vendor/jquery_mobile_a2.min.js
|
||||||
|
- public/javascripts/mobile.js
|
||||||
mailchimp:
|
mailchimp:
|
||||||
- public/javascripts/vendor/mailchimp/jquery.form.js
|
- public/javascripts/vendor/mailchimp/jquery.form.js
|
||||||
- public/javascripts/vendor/mailchimp/jquery.validate.js
|
- public/javascripts/vendor/mailchimp/jquery.validate.js
|
||||||
|
|
|
||||||
14
public/javascripts/mobile.js
Normal file
14
public/javascripts/mobile.js
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
var Mobile = {
|
||||||
|
initialize : function(){
|
||||||
|
$('#aspect_picker').change(Mobile.changeAspect);
|
||||||
|
},
|
||||||
|
|
||||||
|
changeAspect : function() {
|
||||||
|
Mobile.windowLocation('/aspects/' + $('#aspect_picker option:selected').val());
|
||||||
|
},
|
||||||
|
|
||||||
|
windowLocation : function(url) {
|
||||||
|
window.location = url;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
826
spec/fixtures/users.yaml
vendored
826
spec/fixtures/users.yaml
vendored
File diff suppressed because it is too large
Load diff
19
spec/helpers/mobile_helper_spec.rb
Normal file
19
spec/helpers/mobile_helper_spec.rb
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||||
|
# licensed under the Affero General Public License version 3 or later. See
|
||||||
|
# the COPYRIGHT file.
|
||||||
|
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe MobileHelper do
|
||||||
|
|
||||||
|
describe "#aspect_select_options" do
|
||||||
|
it "adds an all option to the list of aspects" do
|
||||||
|
# options_from_collection_for_select(@aspects, "id", "name", @aspect.id)
|
||||||
|
|
||||||
|
n = Factory(:aspect)
|
||||||
|
|
||||||
|
options = aspect_select_options([n], n).split('\n')
|
||||||
|
options.first.should =~ /All/
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
24
spec/javascripts/mobile-interface-spec.js
Normal file
24
spec/javascripts/mobile-interface-spec.js
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
describe("mobile interface", function() {
|
||||||
|
describe("initialize", function() {
|
||||||
|
it("attaches a change event to the select box", function() {
|
||||||
|
spyOn($.fn, 'change');
|
||||||
|
Mobile.initialize();
|
||||||
|
expect($.fn.change).toHaveBeenCalledWith(Mobile.changeAspect);
|
||||||
|
expect($.fn.change.mostRecentCall.object.selector).toEqual("#aspect_picker");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
describe("change", function() {
|
||||||
|
it("changes to the aspect show page", function() {
|
||||||
|
$('#jasmine_content').html(
|
||||||
|
'<select id="aspect_picker" name="aspect_picker" tabindex="-1">' +
|
||||||
|
' <option value="family-aspect-id">Family</option>' +
|
||||||
|
' <option value="work-aspect-id">Work</option>' +
|
||||||
|
'</select>');
|
||||||
|
spyOn(Mobile, "windowLocation");
|
||||||
|
$.proxy(Mobile.changeAspect, $('#aspect_picker > option').first())()
|
||||||
|
expect(Mobile.windowLocation).toHaveBeenCalledWith("/aspects/family-aspect-id");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -14,6 +14,7 @@ src_files:
|
||||||
- public/javascripts/vendor/jquery144.js
|
- public/javascripts/vendor/jquery144.js
|
||||||
- public/javascripts/vendor/jquery-ui-1.8.6.custom.min.js
|
- public/javascripts/vendor/jquery-ui-1.8.6.custom.min.js
|
||||||
- public/javascripts/vendor/jquery.tipsy.js
|
- public/javascripts/vendor/jquery.tipsy.js
|
||||||
|
- public/javascripts/mobile.js
|
||||||
- public/javascripts/aspect-edit.js
|
- public/javascripts/aspect-edit.js
|
||||||
- public/javascripts/web-socket-receiver.js
|
- public/javascripts/web-socket-receiver.js
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue