diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-07-02 08:51:10 -0400 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-07-02 08:51:10 -0400 |
commit | 5f9a4ebef493997557ef4470268bed0e5799b6cb (patch) | |
tree | f9a06c1773e511d3273c5d9223d06ca0806d5341 /js | |
parent | e52997e52fe02960908eb6a9637a3349a2c74dad (diff) | |
parent | d04ab14a5a15f9119bedca1332eb516ecf5ca483 (diff) |
Merge branch '0.8.x' into queuemanager
Diffstat (limited to 'js')
-rw-r--r-- | js/jquery.joverlay.js | 271 | ||||
-rw-r--r-- | js/jquery.joverlay.min.js | 5 | ||||
-rw-r--r-- | js/util.js | 12 |
3 files changed, 281 insertions, 7 deletions
diff --git a/js/jquery.joverlay.js b/js/jquery.joverlay.js new file mode 100644 index 000000000..e4effec8e --- /dev/null +++ b/js/jquery.joverlay.js @@ -0,0 +1,271 @@ +/* Copyright (c) 2009 Alvaro A. Lima Jr http://alvarojunior.com/jquery/joverlay.html + * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) + * Version: 0.7.1 (JUN 15, 2009) + * Requires: jQuery 1.3+ + */ + +(function($) { + + // Global vars + var isIE6 = $.browser.msie && $.browser.version == 6.0; // =( + var JOVERLAY_TIMER = null; + var JOVERLAY_ELEMENT_PREV = null; + + $.fn.jOverlay = function(options) { + + // Element exist? + if ( $('#jOverlay').length ) {$.closeOverlay();} + + // Clear Element Prev + JOVERLAY_ELEMENT_PREV = null; + + // Clear Timer + if (JOVERLAY_TIMER !== null) { + clearTimeout( JOVERLAY_TIMER ); + } + + // Set Options + var options = $.extend({}, $.fn.jOverlay.options, options); + + // private function + function center(id) { + if (options.center) { + $.center(id); + } + } + + var element = this.is('*') ? this : '#jOverlayContent'; + var position = isIE6 ? 'absolute' : 'fixed'; + var isImage = /([^\/\\]+)\.(png|gif|jpeg|jpg|bmp)$/i.test( options.url ); + + var imgLoading = options.imgLoading ? "<img id='jOverlayLoading' src='"+options.imgLoading+"' style='position:"+position+"; z-index:"+(options.zIndex + 9)+";'/>" : ''; + + $('body').prepend(imgLoading + "<div id='jOverlay' />" + + "<div id='jOverlayContent' style='position:"+position+"; z-index:"+(options.zIndex + 5)+"; display:none;'/>" + ); + + // Loading Centered + $('#jOverlayLoading').load(function(){ + center(this); + }); + + //IE 6 FIX + if ( isIE6 ) { + $('select').hide(); + $('#jOverlayContent select').show(); + } + + // Overlay Style + $('#jOverlay').css({ + backgroundColor : options.color, + position : position, + top : '0px', + left : '0px', + filter : 'alpha(opacity='+ (options.opacity * 100) +')', // IE =( + opacity : options.opacity, // Good Browser =D + zIndex : options.zIndex, + width : !isIE6 ? '100%' : $(window).width() + 'px', + height : !isIE6 ? '100%' : $(document).height() + 'px' + }).show(); + + // ELEMENT + if ( this.is('*') ) { + + JOVERLAY_ELEMENT_PREV = this.prev(); + + $('#jOverlayContent').html( + this.show().attr('display', options.autoHide ? 'none' : this.css('display') ) + ); + + if ( !isImage ) { + + center('#jOverlayContent'); + + $('#jOverlayContent').show(); + + // Execute callback + if ( !options.url && $.isFunction( options.success ) ) { + options.success( this ); + } + + } + + } + + // IMAGE + if ( isImage ) { + + $('<img/>').load(function(){ + var resize = $.resize(this.width, this.height); + + $(this).css({ + width : resize.width, + height : resize.height + }); + + $( element ).html(this); + + center('#jOverlayContent'); + + $('#jOverlayLoading').fadeOut(500); + $('#jOverlayContent').show(); + + // Execute callback + if ( $.isFunction( options.success ) ) { + options.success( this ); + } + + }).error(function(){ + alert('Image ('+options.url+') not found.'); + $.closeOverlay(); + }).attr({'src' : options.url, 'alt' : options.url}); + + } + + // AJAX + if ( options.url && !isImage ) { + + $.ajax({ + type: options.method, + data: options.data, + url: options.url, + success: function(responseText) { + + $('#jOverlayLoading').fadeOut(500); + + $( element ).html(responseText).show(); + + center('#jOverlayContent'); + + // Execute callback + if ($.isFunction( options.success )) { + options.success(responseText); + } + + }, + error : function() { + alert('URL ('+options.url+') not found.'); + $.closeOverlay(); + } + }); + + } + + // :( + if ( isIE6 ) { + + // Window scroll + $(window).scroll(function(){ + center('#jOverlayContent'); + }); + + // Window resize + $(window).resize(function(){ + + $('#jOverlay').css({ + width: $(window).width() + 'px', + height: $(document).height() + 'px' + }); + + center('#jOverlayContent'); + + }); + + } + + // Press ESC to close + $(document).keydown(function(event){ + if (event.keyCode == 27) { + $.closeOverlay(); + } + }); + + // Click to close + if ( options.bgClickToClose ) { + $('#jOverlay').click($.closeOverlay); + } + + // Timeout (auto-close) + // time in millis to wait before auto-close + // set to 0 to disable + if ( Number(options.timeout) > 0 ) { + jOverlayTimer = setTimeout( $.closeOverlay, Number(options.timeout) ); + } + + // ADD CSS + $('#jOverlayContent').css(options.css || {}); + }; + + // Resizing large images - orginal by Christian Montoya. + // Edited by - Cody Lindley (http://www.codylindley.com) (Thickbox 3.1) + $.resize = function(imageWidth, imageHeight) { + var x = $(window).width() - 150; + var y = $(window).height() - 150; + if (imageWidth > x) { + imageHeight = imageHeight * (x / imageWidth); + imageWidth = x; + if (imageHeight > y) { + imageWidth = imageWidth * (y / imageHeight); + imageHeight = y; + } + } else if (imageHeight > y) { + imageWidth = imageWidth * (y / imageHeight); + imageHeight = y; + if (imageWidth > x) { + imageHeight = imageHeight * (x / imageWidth); + imageWidth = x; + } + } + return {width:imageWidth, height:imageHeight}; + }; + + // Centered Element + $.center = function(element) { + var element = $(element); + var elemWidth = element.width(); + + element.css({ + width : elemWidth + 'px', + marginLeft : '-' + (elemWidth / 2) + 'px', + marginTop : '-' + element.height() / 2 + 'px', + height : 'auto', + top : !isIE6 ? '50%' : $(window).scrollTop() + ($(window).height() / 2) + 'px', + left : '50%' + }); + }; + + // Options default + $.fn.jOverlay.options = { + method : 'GET', + data : '', + url : '', + color : '#000', + opacity : '0.6', + zIndex : 9999, + center : true, + imgLoading : '', + bgClickToClose : true, + success : null, + timeout : 0, + autoHide : true, + css : {} + }; + + // Close + $.closeOverlay = function() { + + if (isIE6) { $("select").show(); } + + if ( JOVERLAY_ELEMENT_PREV !== null ) { + if ( JOVERLAY_ELEMENT_PREV !== null ) { + var element = $('#jOverlayContent').children(); + JOVERLAY_ELEMENT_PREV.after( element.css('display', element.attr('display') ) ); + element.removeAttr('display'); + } + } + + $('#jOverlayLoading, #jOverlayContent, #jOverlay').remove(); + + }; + +})(jQuery);
\ No newline at end of file diff --git a/js/jquery.joverlay.min.js b/js/jquery.joverlay.min.js index c9168506a..44cd46043 100644 --- a/js/jquery.joverlay.min.js +++ b/js/jquery.joverlay.min.js @@ -1,6 +1,7 @@ /* Copyright (c) 2009 Alvaro A. Lima Jr http://alvarojunior.com/jquery/joverlay.html * Licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) - * Version: 0.6 (Abr 23, 2009) + * Version: 0.7.1 (JUN 15, 2009 * Requires: jQuery 1.3+ + * Packer from http://dean.edwards.name/packer/ */ -(function($){var f=$.browser.msie&&$.browser.version==6.0;var g=null;$.fn.jOverlay=function(b){var b=$.extend({},$.fn.jOverlay.options,b);if(g!=null){clearTimeout(g)}var c=this.is('*')?this:'#jOverlayContent';var d=f?'absolute':'fixed';var e=b.imgLoading?"<img id='jOverlayLoading' src='"+b.imgLoading+"' style='position:"+d+"; z-index:"+(b.zIndex+9)+";'/>":'';$('body').prepend(e+"<div id='jOverlay' />"+"<div id='jOverlayContent' style='position:"+d+"; z-index:"+(b.zIndex+5)+"; display:none;'/>");$('#jOverlayLoading').load(function(){if(b.center){$.center(this)}});if(f){$("select").hide();$("#jOverlayContent select").show()}$('#jOverlay').css({backgroundColor:b.color,position:d,top:'0px',left:'0px',filter:'alpha(opacity='+(b.opacity*100)+')',opacity:b.opacity,zIndex:b.zIndex,width:!f?'100%':$(window).width()+'px',height:!f?'100%':$(document).height()+'px'}).show();if(this.is('*')){$('#jOverlayContent').html(this.addClass('jOverlayChildren').show()).show();if(b.center){$.center('#jOverlayContent')}if(!b.url&&$.isFunction(b.success)){b.success(this.html())}}if(b.url){$.ajax({type:b.method,data:b.data,url:b.url,success:function(a){$('#jOverlayLoading').fadeOut(600);$(c).html(a).show();if(b.center){$.center('#jOverlayContent')}if($.isFunction(b.success)){b.success(a)}}})}if(f){$(window).scroll(function(){if(b.center){$.center('#jOverlayContent')}});$(window).resize(function(){$('#jOverlay').css({width:$(window).width()+'px',height:$(document).height()+'px'});if(b.center){$.center('#jOverlayContent')}})}$(document).keydown(function(a){if(a.keyCode==27){$.closeOverlay()}});if(b.bgClickToClose){$('#jOverlay').click($.closeOverlay)}if(Number(b.timeout)>0){g=setTimeout($.closeOverlay,Number(b.timeout))}};$.center=function(a){var a=$(a);var b=a.height();var c=a.width();a.css({width:c+'px',marginLeft:'-'+(c/2)+'px',marginTop:'-'+b/2+'px',height:'auto',top:!f?'50%':$(window).scrollTop()+($(window).height()/2)+"px",left:'50%'})};$.fn.jOverlay.options={method:'GET',data:'',url:'',color:'#000',opacity:'0.6',zIndex:9999,center:true,imgLoading:'',bgClickToClose:true,success:null,timeout:0};$.closeOverlay=function(){if(f){$("select").show()}$('#jOverlayContent .jOverlayChildren').hide().prependTo($('body'));$('#jOverlayLoading, #jOverlayContent, #jOverlay').remove()}})(jQuery);
\ No newline at end of file +(function($){var g=$.browser.msie&&$.browser.version==6.0;var h=null;var i=null;$.fn.jOverlay=function(b){if($('#jOverlay').length){$.closeOverlay()}i=null;if(h!==null){clearTimeout(h)}var b=$.extend({},$.fn.jOverlay.options,b);function center(a){if(b.center){$.center(a)}}var c=this.is('*')?this:'#jOverlayContent';var d=g?'absolute':'fixed';var e=/([^\/\\]+)\.(png|gif|jpeg|jpg|bmp)$/i.test(b.url);var f=b.imgLoading?"<img id='jOverlayLoading' src='"+b.imgLoading+"' style='position:"+d+"; z-index:"+(b.zIndex+9)+";'/>":'';$('body').prepend(f+"<div id='jOverlay' />"+"<div id='jOverlayContent' style='position:"+d+"; z-index:"+(b.zIndex+5)+"; display:none;'/>");$('#jOverlayLoading').load(function(){center(this)});if(g){$('select').hide();$('#jOverlayContent select').show()}$('#jOverlay').css({backgroundColor:b.color,position:d,top:'0px',left:'0px',filter:'alpha(opacity='+(b.opacity*100)+')',opacity:b.opacity,zIndex:b.zIndex,width:!g?'100%':$(window).width()+'px',height:!g?'100%':$(document).height()+'px'}).show();if(this.is('*')){i=this.prev();$('#jOverlayContent').html(this.show().attr('display',b.autoHide?'none':this.css('display')));if(!e){center('#jOverlayContent');$('#jOverlayContent').show();if(!b.url&&$.isFunction(b.success)){b.success(this)}}}if(e){$('<img/>').load(function(){var a=$.resize(this.width,this.height);$(this).css({width:a.width,height:a.height});$(c).html(this);center('#jOverlayContent');$('#jOverlayLoading').fadeOut(500);$('#jOverlayContent').show();if($.isFunction(b.success)){b.success(this)}}).error(function(){alert('Image ('+b.url+') not found.');$.closeOverlay()}).attr({'src':b.url,'alt':b.url})}if(b.url&&!e){$.ajax({type:b.method,data:b.data,url:b.url,success:function(a){$('#jOverlayLoading').fadeOut(500);$(c).html(a).show();center('#jOverlayContent');if($.isFunction(b.success)){b.success(a)}},error:function(){alert('URL ('+b.url+') not found.');$.closeOverlay()}})}if(g){$(window).scroll(function(){center('#jOverlayContent')});$(window).resize(function(){$('#jOverlay').css({width:$(window).width()+'px',height:$(document).height()+'px'});center('#jOverlayContent')})}$(document).keydown(function(a){if(a.keyCode==27){$.closeOverlay()}});if(b.bgClickToClose){$('#jOverlay').click($.closeOverlay)}if(Number(b.timeout)>0){jOverlayTimer=setTimeout($.closeOverlay,Number(b.timeout))}$('#jOverlayContent').css(b.css||{})};$.resize=function(a,b){var x=$(window).width()-150;var y=$(window).height()-150;if(a>x){b=b*(x/a);a=x;if(b>y){a=a*(y/b);b=y}}else if(b>y){a=a*(y/b);b=y;if(a>x){b=b*(x/a);a=x}}return{width:a,height:b}};$.center=function(a){var a=$(a);var b=a.width();a.css({width:b+'px',marginLeft:'-'+(b/2)+'px',marginTop:'-'+a.height()/2+'px',height:'auto',top:!g?'50%':$(window).scrollTop()+($(window).height()/2)+'px',left:'50%'})};$.fn.jOverlay.options={method:'GET',data:'',url:'',color:'#000',opacity:'0.6',zIndex:9999,center:true,imgLoading:'',bgClickToClose:true,success:null,timeout:0,autoHide:true,css:{}};$.closeOverlay=function(){if(g){$("select").show()}if(i!==null){if(i!==null){var a=$('#jOverlayContent').children();i.after(a.css('display',a.attr('display')));a.removeAttr('display')}}$('#jOverlayLoading, #jOverlayContent, #jOverlay').remove()}})(jQuery); diff --git a/js/util.js b/js/util.js index e7c54b74a..638104c1c 100644 --- a/js/util.js +++ b/js/util.js @@ -272,21 +272,23 @@ function NoticeAttachments() { color : '#000', opacity : '0.6', zIndex : 99, - center : true, + center : false, imgLoading : $('address .url')[0].href+'theme/base/images/illustrations/illu_progress_loading-01.gif', bgClickToClose : true, success : function() { $('#jOverlayContent').append('<button>×</button>'); $('#jOverlayContent button').click($.closeOverlay); }, - timeout : 0 + timeout : 0, + autoHide : true, + css : {'max-width':'502px', 'top':'22.5%', 'left':'32.5%'} }; $('#content .notice a.attachment').click(function() { - $().jOverlay({url: $('address .url')[0].href+'/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); + $().jOverlay({url: $('address .url')[0].href+'attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; }); - + var t; $("body:not(#shownotice) #content .notice a.thumbnail").hover( function() { @@ -296,7 +298,7 @@ function NoticeAttachments() { if (anchor.children('img').length == 0) { t = setTimeout(function() { - $.get($('address .url')[0].href+'/attachment/' + (anchor.attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) { + $.get($('address .url')[0].href+'attachment/' + (anchor.attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) { anchor.append(data); }); }, 500); |