forked from OpenNeo/impress
prep wardrobe js for standalone server use
This commit is contained in:
parent
1a6bbd8dbd
commit
d984f84445
4 changed files with 7 additions and 8 deletions
|
@ -13,6 +13,7 @@ class ItemsController < ApplicationController
|
||||||
@items = Item.search(@query).alphabetize.paginate :page => params[:page], :per_page => per_page
|
@items = Item.search(@query).alphabetize.paginate :page => params[:page], :per_page => per_page
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render }
|
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] }
|
format.js { render :json => {:items => @items, :total_pages => @items.total_pages}, :callback => params[:callback] }
|
||||||
end
|
end
|
||||||
rescue
|
rescue
|
||||||
|
|
|
@ -2,8 +2,10 @@ OpenneoImpressItems::Application.routes.draw do |map|
|
||||||
match '/' => 'items#index', :as => :items
|
match '/' => 'items#index', :as => :items
|
||||||
match '/index.js' => 'items#index', :format => :js
|
match '/index.js' => 'items#index', :format => :js
|
||||||
match '/items.json' => 'items#index', :format => :json
|
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.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 '/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
|
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]
|
resources :pets, :only => [:show]
|
||||||
|
|
||||||
match '/wardrobe' => 'outfits#edit', :as => :wardrobe
|
match '/wardrobe' => 'outfits#edit', :as => :wardrobe
|
||||||
match '/:id' => 'items#show', :as => :item
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -69,7 +69,7 @@ Partial.ItemSet = function ItemSet(wardrobe, selector) {
|
||||||
info_link = $('<a/>', {
|
info_link = $('<a/>', {
|
||||||
'class': 'object-info',
|
'class': 'object-info',
|
||||||
html: '<span>i</span>',
|
html: '<span>i</span>',
|
||||||
href: ITEMS_SERVER + '/' + item.id,
|
href: '/items/' + item.id,
|
||||||
target: '_blank'
|
target: '_blank'
|
||||||
});
|
});
|
||||||
if(
|
if(
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
var ITEMS_SERVER = '',
|
var SHORT_URL_HOST = 'http://bit.ly/';
|
||||||
SHORT_URL_HOST = 'http://bit.ly/';
|
|
||||||
|
|
||||||
window.log = window.SWFLog = $.noop;
|
window.log = window.SWFLog = $.noop;
|
||||||
|
|
||||||
|
@ -184,13 +183,11 @@ function Wardrobe() {
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ITEMS_URL = ITEMS_SERVER + '/index.js?callback=?';
|
|
||||||
|
|
||||||
Item.PER_PAGE = 21;
|
Item.PER_PAGE = 21;
|
||||||
|
|
||||||
Item.loadByQuery = function (query, offset, success, error) {
|
Item.loadByQuery = function (query, offset, success, error) {
|
||||||
var page = Math.round(offset / Item.PER_PAGE) + 1;
|
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;
|
var items = [], item, item_data;
|
||||||
if(data.items) {
|
if(data.items) {
|
||||||
for(var i = 0; i < data.items.length; i++) {
|
for(var i = 0; i < data.items.length; i++) {
|
||||||
|
@ -213,7 +210,7 @@ function Wardrobe() {
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemZoneSet.loadAll = function (success) {
|
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++) {
|
for(var i = 0, l = data.length; i < l; i++) {
|
||||||
ItemZoneSet.all.push(new ItemZoneSet(data[i]));
|
ItemZoneSet.all.push(new ItemZoneSet(data[i]));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue