forked from OpenNeo/impress
zones_restrict respected in preview
This commit is contained in:
parent
5e5032d671
commit
c8f20b2f34
4 changed files with 20 additions and 8 deletions
|
@ -25,7 +25,8 @@ class SwfAsset < ActiveRecord::Base
|
||||||
:id => id,
|
:id => id,
|
||||||
:depth => depth,
|
:depth => depth,
|
||||||
:local_url => local_url,
|
:local_url => local_url,
|
||||||
:body_id => body_id
|
:body_id => body_id,
|
||||||
|
:zone_id => zone_id
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,6 +12,9 @@
|
||||||
#item-preview-swf{'data-impress-host' => RemoteImpressHost}
|
#item-preview-swf{'data-impress-host' => RemoteImpressHost}
|
||||||
Javascript and Flash are required to preview wearables. Sorry!
|
Javascript and Flash are required to preview wearables. Sorry!
|
||||||
|
|
||||||
|
:javascript
|
||||||
|
var CURRENT_ITEM_ZONES_RESTRICT = #{@item.zones_restrict.inspect};
|
||||||
|
|
||||||
- content_for :javascripts do
|
- content_for :javascripts do
|
||||||
= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js',
|
= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js',
|
||||||
'http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js',
|
'http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js',
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
// TODO: zones_restrict
|
|
||||||
|
|
||||||
var PREVIEW_SWF_ID = 'item-preview-swf',
|
var PREVIEW_SWF_ID = 'item-preview-swf',
|
||||||
PREVIEW_SWF = document.getElementById(PREVIEW_SWF_ID),
|
PREVIEW_SWF = document.getElementById(PREVIEW_SWF_ID),
|
||||||
IMPRESS_HOST = PREVIEW_SWF.getAttribute('data-impress-host'),
|
IMPRESS_HOST = PREVIEW_SWF.getAttribute('data-impress-host'),
|
||||||
|
@ -163,7 +161,14 @@ function Item(id) {
|
||||||
Item.LOAD_ERROR = new LoadError("$species_article $species wear a $item");
|
Item.LOAD_ERROR = new LoadError("$species_article $species wear a $item");
|
||||||
|
|
||||||
Item.createFromLocation = function () {
|
Item.createFromLocation = function () {
|
||||||
var item = new Item(parseInt(document.location.pathname.substr(1)));
|
var item = new Item(parseInt(document.location.pathname.substr(1))),
|
||||||
|
z = CURRENT_ITEM_ZONES_RESTRICT, zl = z.length;
|
||||||
|
item.restricted_zones = [];
|
||||||
|
for(i = 0; i < zl; i++) {
|
||||||
|
if(z.charAt(i) == '1') {
|
||||||
|
item.restricted_zones.push(i + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,8 +189,10 @@ Preview = new function Preview() {
|
||||||
$.each(asset_sources, function () {
|
$.each(asset_sources, function () {
|
||||||
assets = assets.concat(this);
|
assets = assets.concat(this);
|
||||||
});
|
});
|
||||||
$.each(assets, function () {
|
assets = $.grep(assets, function (asset) {
|
||||||
this.local_path = this.local_url;
|
var visible = $.inArray(asset.zone_id, Item.current.restricted_zones) == -1;
|
||||||
|
if(visible) asset.local_path = asset.local_url;
|
||||||
|
return visible;
|
||||||
});
|
});
|
||||||
swf.setAssets(assets);
|
swf.setAssets(assets);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -20,7 +20,7 @@ describe SwfAsset do
|
||||||
asset.local_url.should == 'http://impress.openneo.net/assets/swf/outfit/items/000/000/012/12211_9969430b3a.swf'
|
asset.local_url.should == 'http://impress.openneo.net/assets/swf/outfit/items/000/000/012/12211_9969430b3a.swf'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should contain id, depth, and local_url as JSON" do
|
it "should contain id, depth, zone ID, and local_url as JSON" do
|
||||||
zone = Factory.create :zone, :depth => 12
|
zone = Factory.create :zone, :depth => 12
|
||||||
asset = Factory.create :swf_asset,
|
asset = Factory.create :swf_asset,
|
||||||
:id => 123,
|
:id => 123,
|
||||||
|
@ -31,7 +31,8 @@ describe SwfAsset do
|
||||||
:id => 123,
|
:id => 123,
|
||||||
:depth => 12,
|
:depth => 12,
|
||||||
:body_id => 234,
|
:body_id => 234,
|
||||||
:local_url => 'http://impress.openneo.net/assets/swf/outfit/items/000/000/012/12211_9969430b3a.swf'
|
:local_url => 'http://impress.openneo.net/assets/swf/outfit/items/000/000/012/12211_9969430b3a.swf',
|
||||||
|
:zone_id => 1
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue