1
0
Fork 0
forked from OpenNeo/impress

Your Items autocompleter is totally chill with moving items around to different lists

This commit is contained in:
Emi Matchu 2011-07-29 23:26:48 -04:00
parent c76c261444
commit 48ee765505
4 changed files with 74 additions and 36 deletions

View file

@ -177,7 +177,13 @@ body.closet_hangers-index
&:last-child
border-bottom: 0
.closet-list-autocomplete-item a
.closet-hangers-group-autocomplete-item, .closet-list-autocomplete-item
span
font-style: italic
padding: .2em .4em
.closet-list-autocomplete-item
a, span
font-size: 85%
padding-left: 2em

View file

@ -1,5 +1,5 @@
- show_controls ||= false # we could do user check here, but may as well do it once
.object
.object{'data-item-id' => closet_hanger.item_id}
= render :partial => 'items/item_link', :locals => {:item => closet_hanger.item}
.quantity{:class => "quantity-#{closet_hanger.quantity}"}
%span= closet_hanger.quantity

View file

@ -189,11 +189,12 @@
itemsSearchField.addClass("loading");
var closetHanger = {
quantity: 1,
owned: group.owned,
list_id: ui.item.list ? ui.item.list.id : ''
};
if(!item.hangerInGroup) closetHanger.quantity = 1;
$.ajax({
url: "/user/" + itemsSearchForm.data("current-user-id") + "/items/" + item.id + "/closet_hanger",
type: "post",
@ -228,21 +229,29 @@
});
} else { // item was chosen, now choose a group to insert
var groupInserts = [], group;
var item = input.term, itemEl, hangerInGroup, currentListId;
for(var i in hangerGroups) {
group = hangerGroups[i];
itemEl = $('div.closet-hangers-group[data-owned=' + group.owned + '] div.object[data-item-id=' + item.id + ']');
hangerInGroup = itemEl.length > 0;
currentListId = itemEl.closest('.closet-list').attr('data-id');
groupInserts[groupInserts.length] = {
group: group,
item: input.term,
label: input.term.label
item: item,
label: item.label,
hangerInGroup: hangerInGroup,
hangerInList: !!currentListId
}
for(var i = 0; i < group.lists.length; i++) {
groupInserts[groupInserts.length] = {
group: group,
item: input.term,
label: input.term.label,
list: group.lists[i]
item: item,
label: item.label,
list: group.lists[i],
hangerInGroup: hangerInGroup,
currentListId: currentListId
}
}
}
@ -258,11 +267,29 @@
if(item.is_item) { // these are items from the server
li.append("<a>Add <strong>" + item.label + "</strong>");
} else if(item.list) { // these are list inserts
li.append("<a>Add to <strong>" + item.list.label + "</strong>").
addClass("closet-list-autocomplete-item");
if(item.hangerInGroup) {
if(item.currentListId == item.list.id) {
li.append("<span>It's in <strong>" + item.list.label + "</strong> now");
} else {
li.append("<a>Move to <strong>" + item.list.label + "</strong>");
}
} else {
li.append("<a>Add to <strong>" + item.list.label + "</strong>");
}
li.addClass("closet-list-autocomplete-item");
} else { // these are group inserts
if(item.hangerInGroup) {
var groupName = item.group.label;
if(item.hangerInList) {
li.append("<a>Move to <strong>" + groupName.replace(/\s+$/, '') + "</strong>, no list");
} else {
li.append("<span>It's in <strong>" + groupName + "</strong> now");
}
} else {
li.append("<a>Add to <strong>" + item.group.label + "</strong>");
}
li.addClass('closet-hangers-group-autocomplete-item');
}
return li.appendTo(ul);
}

View file

@ -871,22 +871,27 @@ body.closet_hangers-index .closet-list:hover .closet-list-controls {
body.closet_hangers-index .closet-list:last-child {
border-bottom: 0;
}
/* line 180, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index .closet-list-autocomplete-item a {
/* line 181, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index .closet-hangers-group-autocomplete-item span, body.closet_hangers-index .closet-list-autocomplete-item span {
font-style: italic;
padding: 0.2em 0.4em;
}
/* line 186, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index .closet-list-autocomplete-item a, body.closet_hangers-index .closet-list-autocomplete-item span {
font-size: 85%;
padding-left: 2em;
}
/* line 187, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 193, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user #closet-hangers .object:hover form {
display: inline;
}
/* line 190, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 196, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user #closet-hangers .object:hover .closet-hanger-destroy {
position: absolute;
right: 18px;
top: 0;
}
/* line 195, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 201, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user #closet-hangers .object:hover .closet-hanger-destroy input {
/* http://www.zurb.com/blog_uploads/0000/0617/buttons-03.html */
-moz-border-radius: 5px;
@ -927,7 +932,7 @@ body.closet_hangers-index.current-user #closet-hangers .object:hover .closet-han
body.closet_hangers-index.current-user #closet-hangers .object:hover .closet-hanger-destroy input:hover {
background-color: #999999;
}
/* line 198, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 204, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user #closet-hangers .object:hover .quantity {
-moz-opacity: 1;
-webkit-opacity: 1;
@ -937,73 +942,73 @@ body.closet_hangers-index.current-user #closet-hangers .object:hover .quantity {
top: 56px;
padding: 0;
}
/* line 204, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 210, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user #closet-hangers .object:hover .quantity span {
display: none;
}
/* line 207, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 213, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user #closet-hangers .object:hover .quantity input[type=number] {
padding: 2px;
width: 2em;
}
/* line 211, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 217, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user #closet-hangers .object:hover .quantity input[type=submit] {
font-size: 85%;
}
/* line 216, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 222, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user.js #closet-hangers .object:hover .quantity {
display: block;
}
/* line 219, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 225, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user.js #closet-hangers .object:hover .quantity input[type=number] {
width: 2.5em;
}
/* line 222, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 228, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user.js #closet-hangers .object:hover .quantity input[type=submit] {
display: none;
}
/* line 225, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 231, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user.js #closet-hangers .object.loading {
background: #eeffee;
outline: 1px solid #006600;
}
/* line 229, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 235, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user.js #closet-hangers .object.loading .quantity {
display: block;
}
/* line 232, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 238, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user.js #closet-hangers .object.loading .quantity span:after {
content: "…";
}
/* line 236, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 242, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user.js #closet-hangers-contact form {
display: none;
}
/* line 239, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 245, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user.js #closet-hangers-contact .edit-contact-link, body.closet_hangers-index.current-user.js #closet-hangers-contact #cancel-contact-link {
display: inline;
}
/* line 243, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 249, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user.js #closet-hangers-contact.editing form {
display: block;
}
/* line 246, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 252, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user.js #closet-hangers-contact.editing .edit-contact-link {
display: none;
}
/* line 251, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 257, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user.js .closet-hangers-group header .show, body.closet_hangers-index.current-user.js .closet-hangers-group header .hide {
cursor: pointer;
}
/* line 254, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 260, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user.js .closet-hangers-group header .hide {
display: block;
}
/* line 258, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 264, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user.js .closet-hangers-group.hidden header .hide, body.closet_hangers-index.current-user.js .closet-hangers-group.hidden .closet-hangers-group-content {
display: none;
}
/* line 261, ../../../app/stylesheets/closet_hangers/_index.sass */
/* line 267, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index.current-user.js .closet-hangers-group.hidden header .show {
display: block;
}