1
0
Fork 0
forked from OpenNeo/impress

prep wardrobe js for standalone server use

This commit is contained in:
Emi Matchu 2010-10-11 18:37:20 -04:00
parent 1a6bbd8dbd
commit d984f84445
4 changed files with 7 additions and 8 deletions

View file

@ -13,6 +13,7 @@ class ItemsController < ApplicationController
@items = Item.search(@query).alphabetize.paginate :page => params[:page], :per_page => per_page
respond_to do |format|
format.html { render }
format.json { render :json => {:items => @items, :total_pages => @items.total_pages} }
format.js { render :json => {:items => @items, :total_pages => @items.total_pages}, :callback => params[:callback] }
end
rescue

View file

@ -2,8 +2,10 @@ OpenneoImpressItems::Application.routes.draw do |map|
match '/' => 'items#index', :as => :items
match '/index.js' => 'items#index', :format => :js
match '/items.json' => 'items#index', :format => :json
match '/items/:id' => 'items#show', :as => :item
match '/item_zone_sets.js' => 'ItemZoneSets#index'
match '/item_zone_sets.json' => 'ItemZoneSets#index'
match '/bodies/:body_id/swf_assets.json' => 'swf_assets#index', :as => :body_swf_assets
match '/items/:item_id/swf_assets.json' => 'swf_assets#index', :as => :item_swf_assets
@ -17,5 +19,4 @@ OpenneoImpressItems::Application.routes.draw do |map|
resources :pets, :only => [:show]
match '/wardrobe' => 'outfits#edit', :as => :wardrobe
match '/:id' => 'items#show', :as => :item
end

View file

@ -69,7 +69,7 @@ Partial.ItemSet = function ItemSet(wardrobe, selector) {
info_link = $('<a/>', {
'class': 'object-info',
html: '<span>i</span>',
href: ITEMS_SERVER + '/' + item.id,
href: '/items/' + item.id,
target: '_blank'
});
if(

View file

@ -1,5 +1,4 @@
var ITEMS_SERVER = '',
SHORT_URL_HOST = 'http://bit.ly/';
var SHORT_URL_HOST = 'http://bit.ly/';
window.log = window.SWFLog = $.noop;
@ -184,13 +183,11 @@ function Wardrobe() {
return items;
}
var ITEMS_URL = ITEMS_SERVER + '/index.js?callback=?';
Item.PER_PAGE = 21;
Item.loadByQuery = function (query, offset, success, error) {
var page = Math.round(offset / Item.PER_PAGE) + 1;
$.getJSON(ITEMS_URL, {q: query, per_page: Item.PER_PAGE, page: page}, function (data) {
$.getJSON('/items.json', {q: query, per_page: Item.PER_PAGE, page: page}, function (data) {
var items = [], item, item_data;
if(data.items) {
for(var i = 0; i < data.items.length; i++) {
@ -213,7 +210,7 @@ function Wardrobe() {
}
ItemZoneSet.loadAll = function (success) {
$.getJSON(ITEMS_SERVER + '/item_zone_sets.js?callback=?', function (data) {
$.getJSON('/item_zone_sets.json', function (data) {
for(var i = 0, l = data.length; i < l; i++) {
ItemZoneSet.all.push(new ItemZoneSet(data[i]));
}