1
0
Fork 0
forked from OpenNeo/impress

remember whether user prefers flash or image mode

This commit is contained in:
Emi Matchu 2011-08-07 20:13:39 -04:00
parent 09fcc7fa4b
commit c54030f3b3
2 changed files with 34 additions and 10 deletions

View file

@ -837,16 +837,20 @@ View.PreviewAdapterForm = function (wardrobe) {
$(el).addClass('active'); $(el).addClass('active');
} }
$('#preview-mode-flash').click(function () { var flashToggle = $('#preview-mode-flash').click(function () {
activate(this, 'flash', 'image'); activate(this, 'flash', 'image');
preview.useSWFAdapter(); preview.useSWFAdapter();
}); });
$('#preview-mode-image').click(function () { var imageToggle = $('#preview-mode-image').click(function () {
activate(this, 'image', 'flash'); activate(this, 'image', 'flash');
preview.useImageAdapter(); preview.useImageAdapter();
}); });
if(preview.usingImageAdapter()) {
activate(imageToggle, 'image', 'flash');
}
$('#preview-download-image').click(function () { $('#preview-download-image').click(function () {
preview.adapter.saveImage(); preview.adapter.saveImage();
}); });

View file

@ -1213,8 +1213,9 @@ Wardrobe.getStandardView = function (options) {
var preview = this; var preview = this;
var preview_el = $(options.Preview.wrapper), var preview_el = $(options.Preview.wrapper),
preview_swf_placeholder = $(options.Preview.placeholder); preview_swf_placeholder = $(options.Preview.placeholder);
var Adapter = {};
function SWFAdapter() { Adapter.SWF = function () {
var preview_swf_id = preview_swf_placeholder.attr('id'), var preview_swf_id = preview_swf_placeholder.attr('id'),
preview_swf, preview_swf,
update_pending_flash = false; update_pending_flash = false;
@ -1254,7 +1255,7 @@ Wardrobe.getStandardView = function (options) {
} }
} }
function ImageAdapter() { Adapter.Image = function () {
var pendingAssets = {}, pendingAssetIds = [], pendingInterval, var pendingAssets = {}, pendingAssetIds = [], pendingInterval,
pendingAssetsCount = 0, pendingAssetsCount = 0,
pendingMessageEl = $('<span/>', {id: 'preview-images-pending'}), pendingMessageEl = $('<span/>', {id: 'preview-images-pending'}),
@ -1460,7 +1461,11 @@ Wardrobe.getStandardView = function (options) {
} }
} }
this.adapter = new SWFAdapter(); if(typeof options.Preview.image_container == 'undefined' || document.cookie.indexOf('previewAdapter=Image') == -1) {
this.adapter = new Adapter.SWF();
} else {
this.adapter = new Adapter.Image();
}
function updateAssets() { function updateAssets() {
preview.adapter.updateAssets(); preview.adapter.updateAssets();
@ -1470,12 +1475,27 @@ Wardrobe.getStandardView = function (options) {
wardrobe.outfit.bind('updateItemAssets', updateAssets); wardrobe.outfit.bind('updateItemAssets', updateAssets);
wardrobe.outfit.bind('updatePetState', updateAssets); wardrobe.outfit.bind('updatePetState', updateAssets);
this.useSWFAdapter = function () { preview.adapter = new SWFAdapter(); updateAssets(); } function useAdapter(name) {
this.useImageAdapter = function () { preview.adapter = new ImageAdapter(); updateAssets(); } preview.adapter = new Adapter[name]();
this.toggleAdapter = function () {
var nextAdapter = preview.adapter.constructor == SWFAdapter ? ImageAdapter : SWFAdapter;
preview.adapter = new nextAdapter();
updateAssets(); updateAssets();
var expiryDate = new Date();
expiryDate.setTime(expiryDate.getTime() + 365*24*60*60*1000); // one year from now
document.cookie = "previewAdapter=" + name + "; expires=" + expiryDate.toGMTString();
}
this.useSWFAdapter = function () { useAdapter('SWF') }
this.useImageAdapter = function () { useAdapter('Image') }
this.toggleAdapter = function () {
var nextAdapter = preview.adapter.constructor == 'SWF' ? 'Image' : 'SWF';
useAdapter(nextAdapter);
}
this.usingSWFAdapter = function () {
return preview.adapter.constructor == Adapter.SWF;
}
this.usingImageAdapter = function () {
return preview.adapter.constructor == Adapter.Image;
} }
} }