Ray's changes for image upload component and sign-in page
This commit is contained in:
		
							parent
							
								
									6831a3dbbb
								
							
						
					
					
						commit
						b80339d704
					
				|  | @ -0,0 +1,112 @@ | ||||||
|  | /*! | ||||||
|  |  * jQuery imagesLoaded plugin v2.0.1 | ||||||
|  |  * http://github.com/desandro/imagesloaded
 | ||||||
|  |  * | ||||||
|  |  * MIT License. by Paul Irish et al. | ||||||
|  |  */ | ||||||
|  | 
 | ||||||
|  | /*jshint curly: true, eqeqeq: true, noempty: true, strict: true, undef: true, browser: true */ | ||||||
|  | /*global jQuery: false */ | ||||||
|  | 
 | ||||||
|  | ;(function($, undefined) { | ||||||
|  | 'use strict'; | ||||||
|  | 
 | ||||||
|  | // blank image data-uri bypasses webkit log warning (thx doug jones)
 | ||||||
|  | var BLANK = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw=='; | ||||||
|  | 
 | ||||||
|  | $.fn.imagesLoaded = function( callback ) { | ||||||
|  | 	var $this = this, | ||||||
|  | 		deferred = $.isFunction($.Deferred) ? $.Deferred() : 0, | ||||||
|  | 		hasNotify = $.isFunction(deferred.notify), | ||||||
|  | 		$images = $this.find('img').add( $this.filter('img') ), | ||||||
|  | 		loaded = [], | ||||||
|  | 		proper = [], | ||||||
|  | 		broken = []; | ||||||
|  | 
 | ||||||
|  | 	function doneLoading() { | ||||||
|  | 		var $proper = $(proper), | ||||||
|  | 			$broken = $(broken); | ||||||
|  | 
 | ||||||
|  | 		if ( deferred ) { | ||||||
|  | 			if ( broken.length ) { | ||||||
|  | 				deferred.reject( $images, $proper, $broken ); | ||||||
|  | 			} else { | ||||||
|  | 				deferred.resolve( $images ); | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		if ( $.isFunction( callback ) ) { | ||||||
|  | 			callback.call( $this, $images, $proper, $broken ); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	function imgLoaded( img, isBroken ) { | ||||||
|  | 		// don't proceed if BLANK image, or image is already loaded
 | ||||||
|  | 		if ( img.src === BLANK || $.inArray( img, loaded ) !== -1 ) { | ||||||
|  | 			return; | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		// store element in loaded images array
 | ||||||
|  | 		loaded.push( img ); | ||||||
|  | 
 | ||||||
|  | 		// keep track of broken and properly loaded images
 | ||||||
|  | 		if ( isBroken ) { | ||||||
|  | 			broken.push( img ); | ||||||
|  | 		} else { | ||||||
|  | 			proper.push( img ); | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		// cache image and its state for future calls
 | ||||||
|  | 		$.data( img, 'imagesLoaded', { isBroken: isBroken, src: img.src } ); | ||||||
|  | 
 | ||||||
|  | 		// trigger deferred progress method if present
 | ||||||
|  | 		if ( hasNotify ) { | ||||||
|  | 			deferred.notifyWith( $(img), [ isBroken, $images, $(proper), $(broken) ] ); | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		// call doneLoading and clean listeners if all images are loaded
 | ||||||
|  | 		if ( $images.length === loaded.length ){ | ||||||
|  | 			setTimeout( doneLoading ); | ||||||
|  | 			$images.unbind( '.imagesLoaded' ); | ||||||
|  | 		} | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	// if no images, trigger immediately
 | ||||||
|  | 	if ( !$images.length ) { | ||||||
|  | 		doneLoading(); | ||||||
|  | 	} else { | ||||||
|  | 		$images.bind( 'load.imagesLoaded error.imagesLoaded', function( event ){ | ||||||
|  | 			// trigger imgLoaded
 | ||||||
|  | 			imgLoaded( event.target, event.type === 'error' ); | ||||||
|  | 		}).each( function( i, el ) { | ||||||
|  | 			var src = el.src; | ||||||
|  | 
 | ||||||
|  | 			// find out if this image has been already checked for status
 | ||||||
|  | 			// if it was, and src has not changed, call imgLoaded on it
 | ||||||
|  | 			var cached = $.data( el, 'imagesLoaded' ); | ||||||
|  | 			if ( cached && cached.src === src ) { | ||||||
|  | 				imgLoaded( el, cached.isBroken ); | ||||||
|  | 				return; | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 			// if complete is true and browser supports natural sizes, try
 | ||||||
|  | 			// to check for image status manually
 | ||||||
|  | 			if ( el.complete && el.naturalWidth !== undefined ) { | ||||||
|  | 				imgLoaded( el, el.naturalWidth === 0 || el.naturalHeight === 0 ); | ||||||
|  | 				return; | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 			// cached images don't fire load sometimes, so we reset src, but only when
 | ||||||
|  | 			// dealing with IE, or image is complete (loaded) and failed manual check
 | ||||||
|  | 			// webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f
 | ||||||
|  | 			if ( el.readyState || el.complete ) { | ||||||
|  | 				el.src = BLANK; | ||||||
|  | 				el.src = src; | ||||||
|  | 			} | ||||||
|  | 		}); | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 	return deferred ? deferred.promise( $this ) : $this; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | })(jQuery); | ||||||
|  | @ -0,0 +1,79 @@ | ||||||
|  | /*permission-checkbox*/ | ||||||
|  | 
 | ||||||
|  | .checkblock { | ||||||
|  | 	display: inline-block; | ||||||
|  | 	float: left; | ||||||
|  | 	width: 200px; | ||||||
|  | } | ||||||
|  | .check[type="checkbox"]{ | ||||||
|  | 	display:none; | ||||||
|  | } | ||||||
|  | .checkbox{ | ||||||
|  | 	padding: 5px; | ||||||
|  | 	margin: 5px 5px 10px; | ||||||
|  | 	display: inline-block; | ||||||
|  | 	color:#777777; | ||||||
|  | 	text-shadow: 0 1px 0px rgba(255,255,255,.4); | ||||||
|  | 	border-radius: 3px; | ||||||
|  | 	-moz-border-radius: 3px; | ||||||
|  | 	-webkit-border-radius: 3px; | ||||||
|  | 	height: 30px; | ||||||
|  | 	position: relative; | ||||||
|  | 	cursor: pointer; | ||||||
|  | 	background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #ededed), color-stop(1, #dfdfdf) ); | ||||||
|  | 	background:-moz-linear-gradient( center top, #ededed 5%, #dfdfdf 100% ); | ||||||
|  | 	filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#dfdfdf'); | ||||||
|  | 	-webkit-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); | ||||||
|  | 	-moz-box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); | ||||||
|  | 	box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 1px 2px rgba(0, 0, 0, 0.05); | ||||||
|  | } | ||||||
|  | .checkbox .check-icon { | ||||||
|  | 	display: none; | ||||||
|  | 	position: absolute; | ||||||
|  | 	width: 32px; | ||||||
|  | 	height: 32px; | ||||||
|  | 	background: url(<%= asset_path 'check.png' %>) no-repeat left top; | ||||||
|  | 	right: -10px; | ||||||
|  |     top: 15px; | ||||||
|  | } | ||||||
|  | .checkbox .member-name { | ||||||
|  | 	cursor: pointer; | ||||||
|  | 	font-family: helvetica; | ||||||
|  | 	font-size: 12px; | ||||||
|  | 	line-height: 30px; | ||||||
|  | 	padding: 0 10px 0 40px; | ||||||
|  | 	color: #333333; | ||||||
|  | 	display: inline-block; | ||||||
|  | 	margin-bottom: 0; | ||||||
|  | } | ||||||
|  | .member-avatar { | ||||||
|  | 	position: absolute; | ||||||
|  |     width: 34px; | ||||||
|  |     height: 34px; | ||||||
|  |     overflow: hidden; | ||||||
|  |     margin-top: -2px; | ||||||
|  | } | ||||||
|  | img.member-img { | ||||||
|  |     max-width: 100%; | ||||||
|  | } | ||||||
|  | .checked .check-icon { | ||||||
|  | 	display: block; | ||||||
|  | } | ||||||
|  | .popover-inner { | ||||||
|  |     width: auto; | ||||||
|  |     display: inline-block; | ||||||
|  |     text-align: center; | ||||||
|  | } | ||||||
|  | .popover-title { | ||||||
|  |     display: block; | ||||||
|  |     font-size: 12px; | ||||||
|  |     font-weight: normal; | ||||||
|  |     padding: 3px 10px; | ||||||
|  | } | ||||||
|  | .popover-content { | ||||||
|  |     padding: 3px 10px; | ||||||
|  |     color: #898989; | ||||||
|  | } | ||||||
|  | .popover-content p { | ||||||
|  | 	font-size: 12px; | ||||||
|  | } | ||||||
|  | @ -5,8 +5,8 @@ | ||||||
|  *= require reset |  *= require reset | ||||||
|  *= require_self |  *= require_self | ||||||
|  *= require message |  *= require message | ||||||
|  *= require style |  | ||||||
|  *= require bootstrap |  *= require bootstrap | ||||||
|  |  *= require style | ||||||
|  *= require bootstrap-orbit |  *= require bootstrap-orbit | ||||||
|  *= require list |  *= require list | ||||||
|  *= require widgets |  *= require widgets | ||||||
|  |  | ||||||
|  | @ -565,7 +565,9 @@ | ||||||
|     padding: 5px; |     padding: 5px; | ||||||
| } | } | ||||||
| .popover-content { | .popover-content { | ||||||
|     border-radius: 3px; | 	-webkit-border-radius: 0 0 3px 3px; | ||||||
|  | 	-moz-border-radius: 0 0 3px 3px; | ||||||
|  | 	border-radius: 0 0 3px 3px; | ||||||
|     padding: 5px; |     padding: 5px; | ||||||
| } | } | ||||||
| .popover-title { | .popover-title { | ||||||
|  |  | ||||||
|  | @ -6,6 +6,7 @@ | ||||||
| 	<%= javascript_include_tag "lib/date.format"  %> | 	<%= javascript_include_tag "lib/date.format"  %> | ||||||
| 	<%= javascript_include_tag "inc/modal-preview" %> | 	<%= javascript_include_tag "inc/modal-preview" %> | ||||||
| 	<%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %> | 	<%= javascript_include_tag "/static/jquery.cycle.all.latest.js" %> | ||||||
|  | 	<%= javascript_include_tag "inc/jquery.imagesloaded" %> | ||||||
| 	 | 	 | ||||||
| <% end %> | <% end %> | ||||||
| 
 | 
 | ||||||
|  | @ -79,27 +80,29 @@ | ||||||
|                     <!--請程式務必將圖片尺寸加入到行內裡--> |                     <!--請程式務必將圖片尺寸加入到行內裡--> | ||||||
|                     <%= image_tag @ad_image.file,:width=> "456",:height=>'700' rescue ''%> |                     <%= image_tag @ad_image.file,:width=> "456",:height=>'700' rescue ''%> | ||||||
|                     <script type="text/javascript"> |                     <script type="text/javascript"> | ||||||
|                         var picH = $('.upload-picture').width()/$('.upload-picture').find('img').attr("width")*$('.upload-picture').find('img').attr("height") | 	                    $('.upload-picture').find('img').imagesLoaded(function(){; | ||||||
|                         var imgMarginTop = ($('.upload-picture').height()-picH)/2; | 	                        var picH = $('.upload-picture').width()/$('.upload-picture').find('img').width()*$('.upload-picture').find('img').height(); | ||||||
|                         var d = $('.upload-picture').height(); | 	                        var imgMarginTop = ($('.upload-picture').height()-picH)/2; | ||||||
|                         if(imgMarginTop>0){ | 	                        var d = $('.upload-picture').height(); | ||||||
|                             imgMarginTop = 0; | 	                        if(imgMarginTop>0){ | ||||||
|                             d = picH; | 	                            imgMarginTop = 0; | ||||||
|                             $('.upload-picture').css({height:d}) | 	                            d = picH; | ||||||
|                         } | 	                            $('.upload-picture').css({height:d}) | ||||||
|                         $('.upload-picture').find('img').css({marginTop:imgMarginTop}) | 	                        } | ||||||
|                         $('.upload-picture').each(function (i){ | 	                        $('.upload-picture').find('img').css({marginTop:imgMarginTop}) | ||||||
|                             $(this).mouseenter(function(){ | 	                        $('.upload-picture').each(function (i){ | ||||||
|                                 var h= picH; | 	                            $(this).mouseenter(function(){ | ||||||
|                                 $(this).stop().animate({height:h}, 500); | 	                                var h= picH; | ||||||
|                                 $(this).find('img').stop().animate({marginTop:0}, 500); | 	                                $(this).stop().animate({height:h}, 500); | ||||||
|                             }); | 	                                $(this).find('img').stop().animate({marginTop:0}, 500); | ||||||
|                             $(this).mouseleave(function(){ | 	                            }); | ||||||
|                                 $(this).stop().animate({height:d}, 500); | 	                            $(this).mouseleave(function(){ | ||||||
|                                 $(this).find('img').stop().animate({marginTop:imgMarginTop}, 500); | 	                                $(this).stop().animate({height:d}, 500); | ||||||
|                             }); | 	                                $(this).find('img').stop().animate({marginTop:imgMarginTop}, 500); | ||||||
|                         }); | 	                            }); | ||||||
|                     </script> | 	                        }); | ||||||
|  | 	                    }); | ||||||
|  |                       </script> | ||||||
|                 </div> |                 </div> | ||||||
|                 <span class="alert widgetInfo">此區塊圖片尺寸請使用580px × 225px</span> |                 <span class="alert widgetInfo">此區塊圖片尺寸請使用580px × 225px</span> | ||||||
|                 <div class="controls file-upload input-prepend"> |                 <div class="controls file-upload input-prepend"> | ||||||
|  | @ -181,16 +184,11 @@ | ||||||
| 					</div> | 					</div> | ||||||
| 				</div> | 				</div> | ||||||
| 				<div class="form-actions"> | 				<div class="form-actions"> | ||||||
| 					<button class="btn btn-success" type="submit">Preview/預覽</button> | 					<%= link_to t("modal.preview"), admin_realtime_preview_ad_banner_path(@ad_image.ad_banner.title) ,:class=>"preview_trigger btn btn-success" rescue nil%> | ||||||
| 					<button class="btn btn-primary" type="submit">Submit/送出</button> | 					<%= f.submit t("submit"),:class=>"btn btn-primary" %> | ||||||
| 					<button class="btn" type="reset">Cancel/取消</button> | 					<%= f.submit t("cancel"),:class=>"btn ",:type => 'reset' %> | ||||||
| 				</div> | 				</div> | ||||||
| 			</div> | 			</div> | ||||||
| 			<!--Post End--> | 			<!--Post End--> | ||||||
| 			<div class="form-actions"> |  | ||||||
| 				<%= link_to t("modal.preview"), admin_realtime_preview_ad_banner_path(@ad_image.ad_banner.title) ,:class=>"preview_trigger btn btn-success" rescue nil%> |  | ||||||
| 				<%= f.submit t("submit"),:class=>"btn btn-primary" %> |  | ||||||
| 				<%= f.submit t("cancel"),:class=>"btn ",:type => 'reset' %> |  | ||||||
| 			</div> |  | ||||||
| 		</form> | 		</form> | ||||||
| 	</div> | 	</div> | ||||||
|  | @ -5,7 +5,7 @@ | ||||||
| <div id="container" class="sign-in"> | <div id="container" class="sign-in"> | ||||||
| 	<%= form_for :user, :url => user_session_path, :html => {:class => 'user_new form-horizontal'} do |f| %> | 	<%= form_for :user, :url => user_session_path, :html => {:class => 'user_new form-horizontal'} do |f| %> | ||||||
| 		<div class="content"> | 		<div class="content"> | ||||||
| 			<p class="notice hide">Notice</p> | 			<p class="notice label label-warning">Notice</p> | ||||||
| 			<p class="alert hide">You need to sign in or sign up before continuing.</p> | 			<p class="alert hide">You need to sign in or sign up before continuing.</p> | ||||||
| 			<div class="main"> | 			<div class="main"> | ||||||
| 				<div class="control-group clear"> | 				<div class="control-group clear"> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue