domReady(function() { // InitAlbum(); }); function InitAlbum() { $$('body')[0].insert($('PhotoViewer')); $$('body')[0].select('[albumimage="true"]').each(function(e) { var photo = { albumId: e.readAttribute('albumid'), id: e.readAttribute('photoid'), photoUrl: e.readAttribute('photourl'), title: e.readAttribute('title') }; InitAlbumPhoto(e, photo); }); } var onImageClick = function(e) { ViewAlbumPhoto(photo); }; function InitAlbumPhoto(element,photo){ var album = Cache.get('album'+photo.albumId); if(album == null){ album = new Hash(); Cache.set('album'+photo.albumId,album); } album.set(photo.id,photo); element.select('img')[0].stopObserving('click',onImageClick); element.select('img')[0].observe('click', onImageClick); } function ClosePhotoViewer(){ var cc = $('PhotoViewer'); cc.fade({duration: 0.5}); } //Not in use?? function ViewAlbumPhoto(photo){ var album = Cache.get('album'+photo.albumId); var viewer = $('PhotoViewer'); var modal = $('modalWindow'); viewer.select('img')[0].writeAttribute('src', album.get(photo.id).photoUrl); viewer.select('div.Name')[0].update(photo.title); OpenPhotoViewer(viewer); } function NavigatePhotos(e){ var direction = $A(arguments)[1]; var albumId = $('photo'+this.id).readAttribute('album'); var imageId = this.id var album = Cache.get('album'+albumId); for(var i = 0;i 0) { $('PhotoViewer').setStyle({ width: w + 'px' }); pe.stop(); MoveToCenter(el); } }, .1); } function MoveToCenter(e) { var cc = e.up(0); var ccDim = cc.getDimensions(); var vp = document.viewport.getDimensions(); var offset = document.viewport.getScrollOffsets(); var top = (vp.height / 2) + offset.top - (ccDim.height / 2); var left = (vp.width / 2) + offset.left - (ccDim.width / 2); new Effect.Move(cc, { x: left, y: top, duration: .5, mode: 'absolute' }); } function OpenPhotoViewer(element) { var cc = element; var ccDim = cc.getDimensions(); var vp = document.viewport.getDimensions(); var offset = document.viewport.getScrollOffsets(); var top = (vp.height / 2) + offset.top - (ccDim.height / 2); var left = (vp.width / 2) + offset.left - (ccDim.width / 2); // new Effect.Move(cc, { x: left, y: top, duration: .5, mode: 'absolute' }); cc.appear({ duration: .5 }); new Draggable(cc, { scroll: window, handle: 'Handle' }); } function ViewProfilePhoto(e){ var photo = this; if(photo.id == null){ photo = e; } var viewer = $('PhotoViewer'); var modal = $('modalWindow'); var img = viewer.select('img')[0]; img.observe('load', CenterOnReload); img.writeAttribute('src', photo.fileUrl); viewer.select('div.Name')[0].update(photo.fileInfo); viewer.select('div.Next')[0].stopObserving('click'); viewer.select('div.Prev')[0].stopObserving('click'); viewer.select('div.Next')[0].observe('click', NavigatePhotos.bindAsEventListener(photo,true)); viewer.select('div.Prev')[0].observe('click', NavigatePhotos.bindAsEventListener(photo,false)); OpenPhotoViewer(viewer); } function DeletePhoto(sender){ var owner = $(sender); var albumId = owner.readAttribute('albumid'); var request = {uniqueId: sender, albumId: albumId}; var me = this; new Ajax.Request(WEBSERVICE_URL+"DeletePhoto", { method: 'post', contentType: 'application/json', encoding: 'utf-8', postBody: Object.toJSON(request), onSuccess: function(transport) { var response = transport.responseJSON.d.evalJSON(); if(!response.success){ alert(response.description); return; } owner.fade({duration: 0.5}); }, onFailure: function(transport) { alert(Lang.General_Error); } }); } /*presentation*/ function LoadAlbumWidgets(catId){ var dataContainer = $(catId).select('div.dataContainer')[0]; deleteChildElements(dataContainer); var categoryId = catId.sub('album_', ''); var album = Cache.get('album' + categoryId); album = null; var request = { albumId: categoryId }; var onSuccess = function(response){ PopulateAlbumWidgets(response,dataContainer); }; var onFailed = function(e){ alert(e); }; JSONRequest(request,'GetAlbumPhotos',onSuccess, onFailed ); } function PopulateAlbumWidgets(response,container){ /* var album = Cache.get('album'+response.id); if(album == null){ album = new Hash(); Cache.set('album'+response.id,response); } */ Cache.set('album' + response.id, response); var i = 0; for(i = 0;i0){ InitAlbumWidget(response.id,i); // gallery scroller } InitAlbum(); } var navEvt = function(e){ ScrollData(this.readAttribute('nav'),this); }; function InitAlbumWidget(id,count){ var nextButton = $('album_'+id).select('div.NavNext')[0]; var prevButton = $('album_'+id).select('div.NavPrev')[0]; var container = $('album_'+id).select('div.dataContainer')[0]; var width = (120*count)+'px'; container.setStyle({ width: width }); nextButton.observe('click',navEvt); prevButton.observe('click',navEvt); } function DownloadFile(e) { var id = ''; if (typeof e == 'string') { id = e; } else { id = this.uniqueId } document.location.href = '/files/download.aspx?fileId='+id; } function OpenAlbumFolder(sender) { var obj = $(sender).up(0); var galleryId = obj.readAttribute('album'); var filesDiv = obj.select('div.Files')[0]; var friend = obj.readAttribute('friend'); friend = friend == 'true'; var noDl = function(e) { FeedBackBox(Lang.File_Download_Err); }; var onload = function(album) { deleteChildElements(filesDiv); var hlFileName = new Element('div', { 'class': 'HlFilename' }).update('File name'); var hlDls = new Element('div', { 'class': 'HlDls' }).update('Downloads'); var hlRate = new Element('div', { 'class': 'HlRate' }).update('Rating'); var hlInfo = new Element('div', { 'class': 'HlInfo' }).update('Info'); filesDiv.insert({ 'bottom': hlFileName }); filesDiv.insert({ 'bottom': hlDls }); filesDiv.insert({ 'bottom': hlRate }); filesDiv.insert({ 'bottom': hlInfo }); filesDiv.insert({ 'bottom': new Element('div', { 'style': 'clear:both;' }) }); var onRate = function(e) { var rateValue = this.value; var id = this.itemId; FeedBackBox('Thanks for the rating!'); JSONRequest({ rateType: 'file', value: rateValue, itemId: id }, 'RateItem', null, null); } album.files.each(function(f) { var row = new Element('div', { 'class': 'Row' }); var name = new Element('div', { 'class': 'Name' }).update(f.virtualFileName); if (!friend) { name.observe('click', noDl); } else { name.observe('click', DownloadFile.bindAsEventListener(f)); } var dls = new Element('div', { 'class': 'DownloadCount' }).update(f.downloadCount); var rating = new Element('div', { 'class': 'Rating' }) var info = new Element('div', { 'class': 'Info', 'title': f.fileInfo }).update(ShortString(f.fileInfo, 15)); var br = new Element('div', { 'style': 'clear:both' }); row.insert({ 'bottom': name }); row.insert({ 'bottom': dls }); row.insert({ 'bottom': rating }); var rate = new RatePanel(rating, f.rating, f.uniqueId, onRate, friend); row.insert({ 'bottom': info }); row.insert({ 'bottom': br }); filesDiv.insert({ 'bottom': row }); }); }; JSONRequest({ galleryId: galleryId }, 'GetGalleryFiles', onload, null); } var swfu; function UlImages(galleryId, callBack) { UlFileDialog(galleryId, '*.jpg;*.gif;*.png;*.bmp', callBack); } function UlFiles(galleryId, callBack) { UlFileDialog(galleryId, '*.*', callBack); } function onFileUpload(galleryId) { // OpenAlbumFolder($('galleryTitle' + galleryId)); var href = document.location.href; var cut = href.lastIndexOf("/", 0); document.location.href = href.substring(0, cut) + "1"; } function onImageUpload(galleryId) { document.location.href = document.location.href; // LoadAlbumWidgets('album_' + galleryId); } function UlFileDialog(galleryId, fileTypes, cb) { var main = $('uldialog'); if (main != null) { main.remove(); } // if (main == null) { var title = new Element('h1').update(Lang.File_Upload_Txt_1); var butt = new Element('div', { 'id': 'FileUploadButtonPlaceholder' }); var progress = new Element('div', { 'id': 'divFileProgressContainer', 'style': 'height:10px;width:100%;' }); main = new Element('div', { 'id': 'uldialog' }); main.insert({ 'bottom': title }); main.insert({ 'bottom': butt }); main.insert({ 'bottom': progress }); // } var onclose = function() { // swfu = null; }; FeedBackBox(main, true, 220, 300, { title: Lang.File_Upload_Txt_1, onClose: onclose }); ResetSWFUpload(); swfu = new SWFUpload({ // Backend Settings upload_url: "/galleryUpload.aspx", // Relative to the SWF file post_params: { "sessionId": readCookie("sessionId"), "galleryId": galleryId }, // File Upload Settings file_size_limit: "10 MB", file_types: fileTypes, file_types_description: Lang.File_Txt_1, file_upload_limit: "0", // Zero means unlimited // Event Handler Settings - these functions as defined in Handlers.js // The handlers are not part of SWFUpload but are part of my website and control how // my website reacts to the SWFUpload events. file_queue_error_handler: fileQueueError, file_dialog_complete_handler: fileDialogComplete, upload_progress_handler: uploadProgress, upload_error_handler: uploadError, upload_success_handler: uploadSuccess, upload_complete_handler: uploadComplete, // Button settings button_image_url: "/img/XPButtonNoText_160x22.png", // Relative to the SWF file button_placeholder_id: "FileUploadButtonPlaceholder", button_width: 160, button_height: 22, button_text: Lang.File_Txt_2, button_text_style: '.button { font-family: Helvetica, Arial, sans-serif; font-size: 14pt; } .buttonSmall { font-size: 10pt; }', button_text_top_padding: 1, button_text_left_padding: 5, // Flash Settings flash_url: "/script/swfUpload/swfupload.swf", // Relative to this file custom_settings: { upload_target: "divFileProgressContainer", onCallBack: function() { //cb(galleryId); }, onComplete: function() { cb(galleryId); } }, dispose: function() { this.custom_settings = null; this.post_params = null; }, // Debug Settings debug: false }); // } }