Skip to content
Extraits de code Groupes Projets
Valider 218aa1c0 rédigé par Sarah Mei's avatar Sarah Mei
Parcourir les fichiers

MSSM aspect switcher in mobile interface plus tests; added check for ipad useragent

parent 752d50a6
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -28,7 +28,11 @@ class ApplicationController < ActionController::Base
def mobile_except_ipad
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
......
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
\ No newline at end of file
-# 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,10 +10,13 @@
%meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
= javascript_include_tag 'vendor/jquery144.min','rails'
= include_javascripts :mobile
= stylesheet_link_tag 'mobile', 'vendor/jquery_mobile.min'
= csrf_meta_tag
:javascript
$(document).ready(Mobile.initialize);
= yield(:head)
......@@ -24,7 +27,7 @@
= person_image_tag (current_user.person)
= current_user.real_name
%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
......
......@@ -15,8 +15,11 @@ javascripts:
- public/javascripts/image-picker.js
- public/javascripts/stream.js
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_mobile_a2.min.js
- public/javascripts/mobile.js
mailchimp:
- public/javascripts/vendor/mailchimp/jquery.form.js
- public/javascripts/vendor/mailchimp/jquery.validate.js
......
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;
},
};
Ce diff est replié.
# 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
\ No newline at end of file
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");
});
});
});
\ No newline at end of file
......@@ -14,6 +14,7 @@ src_files:
- public/javascripts/vendor/jquery144.js
- public/javascripts/vendor/jquery-ui-1.8.6.custom.min.js
- public/javascripts/vendor/jquery.tipsy.js
- public/javascripts/mobile.js
- public/javascripts/aspect-edit.js
- public/javascripts/web-socket-receiver.js
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter