new sites picker

This commit is contained in:
did 2011-07-05 18:30:12 +02:00
parent 71d7e86acd
commit bd28f4c1ec
17 changed files with 220 additions and 625 deletions

View File

@ -13,7 +13,7 @@ module Admin
respond_with @membership, :location => edit_admin_current_site_url
when :error
respond_with @membership, :flash => true
when :nothing
when :already_created
respond_with @membership, :alert => t('flash.admin.memberships.create.already_created'), :location => edit_admin_current_site_url
end
end

View File

@ -36,9 +36,9 @@ class Membership
:error
elsif self.account.blank?
:create_account
elsif self.site.memberships.find_all { |m| m.account_id == self.account_id }.size > 1
elsif self.site.memberships.any? { |m| m.account_id == self.account_id && m._id != self._id }
self.errors.add(:base, 'Already created')
:nothing
:already_created
else
self.save
:save_it

View File

@ -1,14 +1,25 @@
%h1
- if current_admin.sites.size > 1
= form_tag new_admin_cross_domain_session_url, :method => 'get' do
= select_tag 'target_id', options_for_select(current_admin.sites.collect { |site| [truncate(site.name, :length => 32), site.id] }, current_site.id), :id => 'site-selector'
= submit_tag 'Switch', :style => 'display: none'
- else
= link_to current_site.name, admin_pages_url, :class => 'single'
#global-actions-bar
!= t('.welcome', :name => link_to(current_admin.name, edit_admin_my_account_url))
%span= '|'
= link_to t('.see'), current_site_url
- if multi_sites? && current_admin.sites.size > 1
%span= '|'
= link_to t('.switch'), '#', :id => 'sites-picker-link'
%span= '|'
= link_to t('.logout'), destroy_admin_session_url, :confirm => t('admin.messages.confirm')
- if multi_sites? && current_admin.sites.size > 1
#sites-picker{ :style => 'display: none' }
%ul
- current_admin.sites.each do |site|
- unless current_site._id == site._id
%li
= link_to site.name, new_admin_cross_domain_session_url(:target_id => site._id)
- if can?(:manage, Site)
%p.action
= link_to t('admin.sites_picker.new'), new_admin_site_url

View File

@ -21,7 +21,6 @@ javascripts:
- public/javascripts/admin/plugins/toggle.js
- public/javascripts/admin/plugins/growl.js
- public/javascripts/admin/plugins/cookie.js
- public/javascripts/admin/plugins/selectmenu.js
- public/javascripts/admin/locales/datepicker_de.js
- public/javascripts/admin/locales/datepicker_fr.js
- public/javascripts/admin/locales/datepicker_pt-BR.js
@ -82,12 +81,12 @@ stylesheets:
- public/stylesheets/admin/layout.css
- public/stylesheets/admin/jquery/ui.css
- public/stylesheets/admin/plugins/toggle.css
- public/stylesheets/admin/plugins/selectmenu.css
- public/stylesheets/admin/menu.css
- public/stylesheets/admin/buttons.css
- public/stylesheets/admin/formtastic.css
- public/stylesheets/admin/formtastic_changes.css
- public/stylesheets/admin/assets.css
- public/stylesheets/admin/sites_picker.css
- public/stylesheets/admin/application.css
- public/stylesheets/admin/safari.css
fancybox:

View File

@ -7,16 +7,16 @@ Locomotive.configure do |config|
# your own domain name (ex: locomotivehosting.com).
#
# Ex:
# config.multi_sites do |multi_sites|
# # each new website you add will have a default entry based on a subdomain
# # and the multi_site_domain value (ex: website_1.locomotivehosting.com).
# multi_sites.domain = 'example.com' #'myhostingplatform.com'
#
# # define the reserved subdomains
# # Ex:
# multi_sites.reserved_subdomains = %w(www admin email blog webmail mail support help site sites)
# end
config.multi_sites = false
config.multi_sites do |multi_sites|
# each new website you add will have a default entry based on a subdomain
# and the multi_site_domain value (ex: website_1.locomotivehosting.com).
multi_sites.domain = 'example.com' #'myhostingplatform.com'
# define the reserved subdomains
# Ex:
multi_sites.reserved_subdomains = %w(www admin email blog webmail mail support help site sites)
end
# config.multi_sites = false
# configure the hosting target for the production environment. Locomotive can be installed in:
# - your own server

View File

@ -15,6 +15,7 @@ en:
header:
welcome: Welcome, %{name}
see: See website
switch: Switch to another site
logout: Log out
menu:
contents: Contents
@ -49,6 +50,9 @@ en:
title: "Hi %{name}, just to let you know that a new instance has been created on %{date}"
type: "Model: %{type}"
sites_picker:
new: + new site
custom_fields:
edit:
title: Editing custom field

View File

@ -25,6 +25,7 @@ fr:
header:
welcome: "Bonjour, %{name}"
see: Voir le site web
switch: Passer à un autre site
logout: Se déconnecter
menu:
contents: Contenu
@ -49,6 +50,9 @@ fr:
title: "Bonjour %{name}, nous voulions vous faire savoir qu'une nouvelle instance a été créée le %{date}"
type: "Modèle: %{type}"
sites_picker:
new: + nouveau site
custom_fields:
edit:
title: Editer champ personnalisé
@ -145,6 +149,10 @@ fr:
ask_for_name: "Veuillez entrer le nouveau nom"
memberships:
roles:
admin: Administrateur
designer: Designeur
author: Auteur
new:
title: "Ajout d'un compte"
help: "Donnez l'adresse email du compte à ajouter. S'il n'existe pas, vous serez redirigé(e) vers le formulaire de création d'un compte."

View File

@ -11,16 +11,14 @@ Background:
Scenario: Successful authentication
When I go to pages
Then I should see "Locomotive test website"
When I select "Locomotive test website #2" from "target_id"
And I press "Switch"
When I follow "Locomotive test website #2"
Then I should see "Cross-domain authentication"
When I press "Go"
Then I should see "Locomotive test website #2"
Scenario: Failed authentication because of an outdated token
When I go to pages
And I select "Locomotive test website #2" from "target_id"
And I press "Switch"
And I follow "Locomotive test website #2"
And I forget to press the button on the cross-domain notice page
And I press "Go"
Then I should see "You need to sign in"

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 553 B

View File

@ -122,11 +122,16 @@ $(document).ready(function() {
// nifty checkboxes
$('.formtastic li.toggle input[type=checkbox]').checkToggle();
// site selector
$('#site-selector').selectmenu({ style: 'dropdown', width: 395, offsetTop: 8, change: function(event, ui) {
$('#site-selector').parent().submit();
} });
// sites picker
(function() {
var link = $('#sites-picker-link');
var picker = $('#sites-picker');
var left = link.position().left + link.parent().position().left - (picker.width() - link.width());
picker.css('left', left);
})();
$('#sites-picker-link').click(function(e) { $('#sites-picker').toggle(); e.stopPropagation(); e.preventDefault(); });
// separator between form fields
$('.formtastic fieldset.inputs').bind('refresh', function(e) { $(this).find('ol li:not(.item)').removeClass('last').filter(':visible').last().addClass('last'); })
.trigger('refresh');

View File

@ -1,527 +0,0 @@
/*
* jQuery UI selectmenu
*
* Copyright (c) 2009 AUTHORS.txt (http://jqueryui.com/about)
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* http://docs.jquery.com/UI
*/
(function($) {
$.widget("ui.selectmenu", {
_init: function() {
var self = this, o = this.options;
//quick array of button and menu id's
this.ids = [this.element.attr('id') + '-' + 'button', this.element.attr('id') + '-' + 'menu'];
//define safe mouseup for future toggling
this._safemouseup = true;
//create menu button wrapper
this.newelement = $('<a class="'+ this.widgetBaseClass +' ui-widget ui-state-default ui-corner-all" id="'+this.ids[0]+'" role="button" href="#" aria-haspopup="true" aria-owns="'+this.ids[1]+'"></a>')
.insertAfter(this.element);
//transfer tabindex
var tabindex = this.element.attr('tabindex');
if(tabindex){ this.newelement.attr('tabindex', tabindex); }
//save reference to select in data for ease in calling methods
this.newelement.data('selectelement', this.element);
//menu icon
this.selectmenuIcon = $('<span class="'+ this.widgetBaseClass +'-icon ui-icon"></span>')
.prependTo(this.newelement)
.addClass( (o.style == "popup")? 'ui-icon-triangle-2-n-s' : 'ui-icon-triangle-1-s' );
//make associated form label trigger focus
$('label[for='+this.element.attr('id')+']')
.attr('for', this.ids[0])
.bind('click', function(){
self.newelement[0].focus();
return false;
});
//click toggle for menu visibility
this.newelement
.bind('mousedown', function(event){
self._toggle(event);
//make sure a click won't open/close instantly
if(o.style == "popup"){
self._safemouseup = false;
setTimeout(function(){self._safemouseup = true;}, 300);
}
return false;
})
.bind('click',function(){
return false;
})
.keydown(function(event){
var ret = true;
switch (event.keyCode) {
case $.ui.keyCode.ENTER:
ret = true;
break;
case $.ui.keyCode.SPACE:
ret = false;
self._toggle(event);
break;
case $.ui.keyCode.UP:
case $.ui.keyCode.LEFT:
ret = false;
self._moveSelection(-1);
break;
case $.ui.keyCode.DOWN:
case $.ui.keyCode.RIGHT:
ret = false;
self._moveSelection(1);
break;
case $.ui.keyCode.TAB:
ret = true;
break;
default:
ret = false;
self._typeAhead(event.keyCode, 'mouseup');
break;
}
return ret;
})
.bind('mouseover focus', function(){
$(this).addClass(self.widgetBaseClass+'-focus ui-state-hover');
})
.bind('mouseout blur', function(){
$(this).removeClass(self.widgetBaseClass+'-focus ui-state-hover');
});
//document click closes menu
$(document)
.mousedown(function(event){
self.close(event);
});
//change event on original selectmenu
this.element
.click(function(){ this._refreshValue(); })
.focus(function(){ this.newelement[0].focus(); });
//create menu portion, append to body
var cornerClass = (o.style == "dropdown")? " ui-corner-bottom" : " ui-corner-all"
this.list = $('<ul class="' + self.widgetBaseClass + '-menu ui-widget ui-widget-content'+cornerClass+'" aria-hidden="true" role="listbox" aria-labelledby="'+this.ids[0]+'" id="'+this.ids[1]+'"></ul>').appendTo('body');
//serialize selectmenu element options
var selectOptionData = [];
this.element
.find('option')
.each(function(){
selectOptionData.push({
value: $(this).attr('value'),
text: self._formatText(jQuery(this).text()),
selected: $(this).attr('selected'),
classes: $(this).attr('class'),
parentOptGroup: $(this).parent('optgroup').attr('label')
});
});
//active state class is only used in popup style
var activeClass = (self.options.style == "popup") ? " ui-state-active" : "";
//write li's
for(var i in selectOptionData){
var thisLi = $('<li role="presentation"><a href="#" tabindex="-1" role="option" aria-selected="false">'+ selectOptionData[i].text +'</a></li>')
.data('index',i)
.addClass(selectOptionData[i].classes)
.data('optionClasses', selectOptionData[i].classes|| '')
.mouseup(function(event){
if(self._safemouseup){
var changed = $(this).data('index') != self._selectedIndex();
self.value($(this).data('index'));
self.select(event);
if(changed){ self.change(event); }
self.close(event,true);
}
return false;
})
.click(function(){
return false;
})
.bind('mouseover focus', function(){
self._selectedOptionLi().addClass(activeClass);
self._focusedOptionLi().removeClass(self.widgetBaseClass+'-item-focus ui-state-hover');
$(this).removeClass('ui-state-active').addClass(self.widgetBaseClass + '-item-focus ui-state-hover');
})
.bind('mouseout blur', function(){
if($(this).is( self._selectedOptionLi() )){ $(this).addClass(activeClass); }
$(this).removeClass(self.widgetBaseClass + '-item-focus ui-state-hover');
});
//optgroup or not...
if(selectOptionData[i].parentOptGroup){
var optGroupName = self.widgetBaseClass + '-group-' + selectOptionData[i].parentOptGroup;
if(this.list.find('li.' + optGroupName).size()){
this.list.find('li.' + optGroupName + ':last ul').append(thisLi);
}
else{
$('<li role="presentation" class="'+self.widgetBaseClass+'-group '+optGroupName+'"><span class="'+self.widgetBaseClass+'-group-label">'+selectOptionData[i].parentOptGroup+'</span><ul></ul></li>')
.appendTo(this.list)
.find('ul')
.append(thisLi);
}
}
else{
thisLi.appendTo(this.list);
}
//this allows for using the scrollbar in an overflowed list
this.list.bind('mousedown mouseup', function(){return false;});
//append icon if option is specified
if(o.icons){
for(var j in o.icons){
if(thisLi.is(o.icons[j].find)){
thisLi
.data('optionClasses', selectOptionData[i].classes + ' ' + self.widgetBaseClass + '-hasIcon')
.addClass(self.widgetBaseClass + '-hasIcon');
var iconClass = o.icons[j].icon || "";
thisLi
.find('a:eq(0)')
.prepend('<span class="'+self.widgetBaseClass+'-item-icon ui-icon '+iconClass + '"></span>');
}
}
}
}
//add corners to top and bottom menu items
this.list.find('li:last').addClass("ui-corner-bottom");
if(o.style == 'popup'){ this.list.find('li:first').addClass("ui-corner-top"); }
//transfer classes to selectmenu and list
if(o.transferClasses){
var transferClasses = this.element.attr('class') || '';
this.newelement.add(this.list).addClass(transferClasses);
}
//original selectmenu width
var selectWidth = this.element.width();
//set menu button width
this.newelement.width( (o.width) ? o.width : selectWidth);
//set menu width to either menuWidth option value, width option value, or select width
if(o.style == 'dropdown'){ this.list.width( (o.menuWidth) ? o.menuWidth : ((o.width) ? o.width : selectWidth)); }
else { this.list.width( (o.menuWidth) ? o.menuWidth : ((o.width) ? o.width - o.handleWidth : selectWidth - o.handleWidth)); }
//set max height from option
if(o.maxHeight && o.maxHeight < this.list.height()){ this.list.height(o.maxHeight); }
//save reference to actionable li's (not group label li's)
this._optionLis = this.list.find('li:not(.'+ self.widgetBaseClass +'-group)');
//transfer menu click to menu button
this.list
.keydown(function(event){
var ret = true;
switch (event.keyCode) {
case $.ui.keyCode.UP:
case $.ui.keyCode.LEFT:
ret = false;
self._moveFocus(-1);
break;
case $.ui.keyCode.DOWN:
case $.ui.keyCode.RIGHT:
ret = false;
self._moveFocus(1);
break;
case $.ui.keyCode.HOME:
ret = false;
self._moveFocus(':first');
break;
case $.ui.keyCode.PAGE_UP:
ret = false;
self._scrollPage('up');
break;
case $.ui.keyCode.PAGE_DOWN:
ret = false;
self._scrollPage('down');
break;
case $.ui.keyCode.END:
ret = false;
self._moveFocus(':last');
break;
case $.ui.keyCode.ENTER:
case $.ui.keyCode.SPACE:
ret = false;
self.close(event,true);
$(event.target).parents('li:eq(0)').trigger('mouseup');
break;
case $.ui.keyCode.TAB:
ret = true;
self.close(event,true);
break;
case $.ui.keyCode.ESCAPE:
ret = false;
self.close(event,true);
break;
default:
ret = false;
self._typeAhead(event.keyCode,'focus');
break;
}
return ret;
});
//selectmenu style
if(o.style == 'dropdown'){
this.newelement
.addClass(self.widgetBaseClass+"-dropdown");
this.list
.addClass(self.widgetBaseClass+"-menu-dropdown");
}
else {
this.newelement
.addClass(self.widgetBaseClass+"-popup");
this.list
.addClass(self.widgetBaseClass+"-menu-popup");
}
//append status span to button
this.newelement.prepend('<span class="'+self.widgetBaseClass+'-status">'+ selectOptionData[this._selectedIndex()].text +'</span>');
//hide original selectmenu element
this.element.hide();
//transfer disabled state
if(this.element.attr('disabled') == true){ this.disable(); }
//update value
this.value(this._selectedIndex());
},
destroy: function() {
this.element.removeData(this.widgetName)
.removeClass(this.widgetBaseClass + '-disabled' + ' ' + this.namespace + '-state-disabled')
.removeAttr('aria-disabled');
//unbind click on label, reset its for attr
$('label[for='+this.newelement.attr('id')+']')
.attr('for',this.element.attr('id'))
.unbind('click');
this.newelement.remove();
this.list.remove();
this.element.show();
},
_typeAhead: function(code, eventType){
var self = this;
//define self._prevChar if needed
if(!self._prevChar){ self._prevChar = ['',0]; }
var C = String.fromCharCode(code);
c = C.toLowerCase();
var focusFound = false;
function focusOpt(elem, ind){
focusFound = true;
$(elem).trigger(eventType);
self._prevChar[1] = ind;
};
this.list.find('li a').each(function(i){
if(!focusFound){
var thisText = $(this).text();
if( thisText.indexOf(C) == 0 || thisText.indexOf(c) == 0){
if(self._prevChar[0] == C){
if(self._prevChar[1] < i){ focusOpt(this,i); }
}
else{ focusOpt(this,i); }
}
}
});
this._prevChar[0] = C;
},
_uiHash: function(){
return {
index: this.value(),
value: this.element[0].options[this.value()].value
};
},
open: function(event){
var self = this;
var disabledStatus = this.newelement.attr("aria-disabled");
if(disabledStatus != 'true'){
this._refreshPosition();
this._closeOthers(event);
this.newelement
.addClass('ui-state-active');
this.list
.appendTo('body')
.addClass(self.widgetBaseClass + '-open')
.attr('aria-hidden', false)
.find('li:not(.'+ self.widgetBaseClass +'-group):eq('+ this._selectedIndex() +') a')[0].focus();
if(this.options.style == "dropdown"){ this.newelement.removeClass('ui-corner-all').addClass('ui-corner-top'); }
this._refreshPosition();
this._trigger("open", event, this._uiHash());
}
},
close: function(event, retainFocus){
if(this.newelement.is('.ui-state-active')){
this.newelement
.removeClass('ui-state-active');
this.list
.attr('aria-hidden', true)
.removeClass(this.widgetBaseClass+'-open');
if(this.options.style == "dropdown"){ this.newelement.removeClass('ui-corner-top').addClass('ui-corner-all'); }
if(retainFocus){this.newelement[0].focus();}
this._trigger("close", event, this._uiHash());
}
},
change: function(event) {
this.element.trigger('change');
this._trigger("change", event, this._uiHash());
},
select: function(event) {
this._trigger("select", event, this._uiHash());
},
_closeOthers: function(event){
$('.'+ this.widgetBaseClass +'.ui-state-active').not(this.newelement).each(function(){
$(this).data('selectelement').selectmenu('close',event);
});
$('.'+ this.widgetBaseClass +'.ui-state-hover').trigger('mouseout');
},
_toggle: function(event,retainFocus){
if(this.list.is('.'+ this.widgetBaseClass +'-open')){ this.close(event,retainFocus); }
else { this.open(event); }
},
_formatText: function(text){
return this.options.format ? this.options.format(text) : text;
},
_selectedIndex: function(){
return this.element[0].selectedIndex;
},
_selectedOptionLi: function(){
return this._optionLis.eq(this._selectedIndex());
},
_focusedOptionLi: function(){
return this.list.find('.'+ this.widgetBaseClass +'-item-focus');
},
_moveSelection: function(amt){
var currIndex = parseInt(this._selectedOptionLi().data('index'), 10);
var newIndex = currIndex + amt;
return this._optionLis.eq(newIndex).trigger('mouseup');
},
_moveFocus: function(amt){
if(!isNaN(amt)){
var currIndex = parseInt(this._focusedOptionLi().data('index'), 10);
var newIndex = currIndex + amt;
}
else { var newIndex = parseInt(this._optionLis.filter(amt).data('index'), 10); }
if(newIndex < 0){ newIndex = 0; }
if(newIndex > this._optionLis.size()-1){
newIndex = this._optionLis.size()-1;
}
var activeID = this.widgetBaseClass + '-item-' + Math.round(Math.random() * 1000);
this._focusedOptionLi().find('a:eq(0)').attr('id','');
this._optionLis.eq(newIndex).find('a:eq(0)').attr('id',activeID)[0].focus();
this.list.attr('aria-activedescendant', activeID);
},
_scrollPage: function(direction){
var numPerPage = Math.floor(this.list.outerHeight() / this.list.find('li:first').outerHeight());
numPerPage = (direction == 'up') ? -numPerPage : numPerPage;
this._moveFocus(numPerPage);
},
_setData: function(key, value) {
this.options[key] = value;
if (key == 'disabled') {
this.close();
this.element
.add(this.newelement)
.add(this.list)
[value ? 'addClass' : 'removeClass'](
this.widgetBaseClass + '-disabled' + ' ' +
this.namespace + '-state-disabled')
.attr("aria-disabled", value);
}
},
value: function(newValue) {
if (arguments.length) {
this.element[0].selectedIndex = newValue;
this._refreshValue();
this._refreshPosition();
}
return this.element[0].selectedIndex;
},
_refreshValue: function() {
var activeClass = (this.options.style == "popup") ? " ui-state-active" : "";
var activeID = this.widgetBaseClass + '-item-' + Math.round(Math.random() * 1000);
//deselect previous
this.list
.find('.'+ this.widgetBaseClass +'-item-selected')
.removeClass(this.widgetBaseClass + "-item-selected" + activeClass)
.find('a')
.attr('aria-selected', 'false')
.attr('id', '');
//select new
this._selectedOptionLi()
.addClass(this.widgetBaseClass + "-item-selected"+activeClass)
.find('a')
.attr('aria-selected', 'true')
.attr('id', activeID);
//toggle any class brought in from option
var currentOptionClasses = this.newelement.data('optionClasses') ? this.newelement.data('optionClasses') : "";
var newOptionClasses = this._selectedOptionLi().data('optionClasses') ? this._selectedOptionLi().data('optionClasses') : "";
this.newelement
.removeClass(currentOptionClasses)
.data('optionClasses', newOptionClasses)
.addClass( newOptionClasses )
.find('.'+this.widgetBaseClass+'-status')
.html(
this._selectedOptionLi()
.find('a:eq(0)')
.html()
);
this.list.attr('aria-activedescendant', activeID)
},
_refreshPosition: function(){
//set left value
this.list.css('left', this.newelement.offset().left);
//set top value
var menuTop = this.newelement.offset().top;
menuTop+=this.options.offsetTop;
var scrolledAmt = this.list[0].scrollTop;
this.list.find('li:lt('+this._selectedIndex()+')').each(function(){
scrolledAmt -= $(this).outerHeight();
});
if(this.newelement.is('.'+this.widgetBaseClass+'-popup')){
menuTop+=scrolledAmt;
this.list.css('top', menuTop);
}
else {
menuTop += this.newelement.height();
this.list.css('top', menuTop);
}
}
});
$.extend($.ui.selectmenu, {
getter: "value",
version: "@VERSION",
eventPrefix: "selectmenu",
defaults: {
transferClasses: true,
style: 'popup',
width: null,
menuWidth: null,
handleWidth: 26,
maxHeight: null,
icons: null,
format: null,
offsetTop: 0
}
});
})(jQuery);

View File

@ -1,64 +0,0 @@
/* Selectmenu
----------------------------------*/
.ui-selectmenu { display: block; position:relative; height:2em; text-decoration: none; overflow:hidden;}
.ui-selectmenu-icon { position:absolute; right:6px; margin-top:-8px; top: 50%; }
.ui-selectmenu-menu { padding:0; margin:0; list-style:none; position:absolute; top: 0; visibility: hidden; overflow: auto; }
.ui-selectmenu-open { visibility: visible; }
.ui-selectmenu-menu-popup { margin-top: -1px; }
.ui-selectmenu-menu-dropdown { }
.ui-selectmenu-menu li { padding:0; margin:0; display: block; border-top: 1px dotted transparent; border-bottom: 1px dotted transparent; border-right-width: 0 !important; border-left-width: 0 !important; font-weight: normal !important; }
.ui-selectmenu-menu li a,.ui-selectmenu-status {line-height: 1.4em; display:block; padding:.3em 1em; outline:none; text-decoration:none; }
.ui-selectmenu-menu li.ui-selectmenu-hasIcon a,
.ui-selectmenu-hasIcon .ui-selectmenu-status { padding-left: 20px; position: relative; margin-left: 5px; }
.ui-selectmenu-menu li .ui-icon, .ui-selectmenu-status .ui-icon { position: absolute; top: 1em; margin-top: -8px; left: 0; }
.ui-selectmenu-status { line-height: 1.4em; }
.ui-selectmenu-open li.ui-selectmenu-item-focus a { }
.ui-selectmenu-open li.ui-selectmenu-item-selected { }
.ui-selectmenu-menu li span,.ui-selectmenu-status span { display:block; margin-bottom: .2em; }
.ui-selectmenu-menu li .ui-selectmenu-item-header { font-weight: bold; }
.ui-selectmenu-menu li .ui-selectmenu-item-content { }
.ui-selectmenu-menu li .ui-selectmenu-item-footer { opacity: .8; }
/*for optgroups*/
.ui-selectmenu-menu .ui-selectmenu-group { font-size: 1em; }
.ui-selectmenu-menu .ui-selectmenu-group .ui-selectmenu-group-label { line-height: 1.4em; display:block; padding:.6em .5em 0; font-weight: bold; }
.ui-selectmenu-menu .ui-selectmenu-group ul { margin: 0; padding: 0; }
/* site selector */
#site-selector-button {
background: transparent;
border: none;
font-size: 1.5em;
color: #f0f0f0;
text-shadow: 1px 1px 1px #000;
margin-left: 8px;
font-family: "Helvetica Neue",Arial,Helvetica,sans-serif;
line-height: 1.5em;
height: 24px;
overflow: visible;
}
#site-selector-button .ui-icon { background: transparent url("/images/admin/plugins/selectmenu/arrow.png") repeat 0 0; height: 9px; width: 15px; }
#site-selector-button.ui-state-active .ui-icon { background: transparent url("/images/admin/plugins/selectmenu/arrow.png") repeat 0 -9px; }
#site-selector-button .ui-selectmenu-status { padding: 0px; line-height: 1em; float: left; }
#site-selector-button .ui-selectmenu-icon { float: left; margin: 11px 0 0 10px; position: static; top: 0px; left: 0px; }
#site-selector-menu {
background: transparent url("/images/admin/plugins/selectmenu/background.png") repeat 0 0;
border: 1px solid transparent;
-moz-border-radius: 7px;
-webkit-border-radius: 7px;
padding: 5px 0;
z-index: 999;
}
#site-selector-menu li a { color: #aaa; font-size: 0.8em; text-shadow: 1px 1px 1px #000; }
#site-selector-menu .ui-corner-bottom {
-moz-border-radius: none;
-webkit-border-radius: none;
border-bottom: 1px solid transparent;
}
#site-selector-menu.ui-selectmenu-open .ui-selectmenu-item-focus { background: transparent; border-color: transparent; }
#site-selector-menu .ui-state-hover a, #site-selector-menu .ui-state-hover a:hover { color: #fff; text-shadow: 1px 1px 1px #000; }

View File

@ -0,0 +1,61 @@
/* ___ AUTOMATICALLY GENERATED: see admin/sites_picker.scss for the source file */
/* ___ rounded ___ */
/* ___ box shadow ___ */
/* ___ others ___ */
#sites-picker {
position: absolute;
top: 97px;
padding: 0px 0 0 0;
border-radius: 4px;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.17), 3px 3px 5px 0 rgba(0, 0, 0, 0.41);
-moz-box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.17), 3px 3px 5px 0 rgba(0, 0, 0, 0.41);
-webkit-box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.17), 3px 3px 5px 0 rgba(0, 0, 0, 0.41);
border: 1px solid #000;
background: #32333b;
min-width: 160px;
z-index: 999;
font-size: 12px; }
#sites-picker p {
margin-bottom: 0px;
padding: 0 8px; }
#sites-picker p, #sites-picker p a {
color: #fff;
text-shadow: #000 0px 1px; }
#sites-picker p a {
text-decoration: none; }
#sites-picker p a:hover {
text-decoration: underline; }
#sites-picker p.action {
margin-top: 0px;
padding: 2px 8px 4px 8px;
text-align: right;
font-size: 11px; }
#sites-picker ul {
padding: 0px;
margin: 0px;
list-style: none;
margin: 1px 0 0 0; }
#sites-picker ul a {
text-decoration: none; }
#sites-picker ul li {
color: #aaa;
text-shadow: #000 0px 1px;
background: transparent url(/images/admin/plugins/sites_picker_entry_bg.png) repeat-x 0 bottom;
padding: 3px 8px 4px 8px;
cursor: pointer; }
#sites-picker ul li a {
text-decoration: none;
color: #aaa; }
#sites-picker ul li:hover, #sites-picker ul li:hover a {
color: #fff; }
#sites-picker:before {
content: " ";
display: block;
width: 21px;
height: 13px;
position: absolute;
top: -11px;
right: 20px;
background: transparent url(/images/admin/plugins/sites_picker_top_arrow.png) no-repeat 0 0; }

View File

@ -1,5 +1,3 @@
/* ___ rounded ___ */
@mixin clearfix {
&:after {
content: ".";
@ -10,6 +8,8 @@
};
}
/* ___ rounded ___ */
@mixin rounded($side, $radius: 10px, $important: false) {
@if $important == true {
$important: !important; }
@ -70,6 +70,13 @@
-webkit-box-shadow: none $important;
}
@mixin popup-box {
@include full-rounded(4px);
box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.17), 3px 3px 5px 0 rgba(0, 0, 0, 0.41);
-moz-box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.17), 3px 3px 5px 0 rgba(0, 0, 0, 0.41);
-webkit-box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.17), 3px 3px 5px 0 rgba(0, 0, 0, 0.41);
}
/* ___ others ___ */
@mixin reset {

View File

@ -0,0 +1,88 @@
/* ___ AUTOMATICALLY GENERATED: see admin/sites_picker.scss for the source file */
@import "helpers";
#sites-picker {
position: absolute;
top: 97px;
padding: 0px 0 0 0;
@include popup-box;
border: 1px solid #000;
background: rgba(50, 51, 59, 1);
min-width: 160px;
z-index: 999;
font-size: 12px;
p {
margin-bottom: 0px;
padding: 0 8px;
&, a {
color: #fff;
text-shadow: #000 0px 1px;
}
a {
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
&.action {
// background: transparent url(/images/admin/plugins/sites_picker_entry_bg.png) repeat-x 0 top;
margin-top: 0px;
padding: 2px 8px 4px 8px;
text-align: right;
font-size: 11px;
}
}
ul {
@include reset;
margin: 1px 0 0 0;
li {
color: #aaa;
text-shadow: #000 0px 1px;
background: transparent url(/images/admin/plugins/sites_picker_entry_bg.png) repeat-x 0 bottom;
padding: 3px 8px 4px 8px;
cursor: pointer;
a {
text-decoration: none;
color: #aaa;
}
&:hover {
&, a { color: #fff; }
}
// &:before {
// content: "\25B8";
// margin-right: 5px;
// }
}
}
&:before {
content: " ";
display: block;
width: 21px;
height: 13px;
position: absolute;
top: -11px;
right: 20px;
background: transparent url(/images/admin/plugins/sites_picker_top_arrow.png) no-repeat 0 0;
}
}

View File

@ -43,14 +43,19 @@ describe Membership do
it 'should tell nothing to do' do
@membership.email = 'bart@simpson.net'
@membership.site.stubs(:memberships).returns([@membership, @membership])
@membership.process!.should == :nothing
@membership.site.stubs(:memberships).returns([self.build_membership(@account), self.build_membership])
@membership.process!.should == :already_created
end
it 'should tell membership has to be saved' do
@membership.email = 'bart@simpson.net'
@membership.process!.should == :save_it
end
def build_membership(account = nil)
Factory.build(:membership, :site => Factory.build(:site), :account => account || Factory.build(:account))
end
end
end