From: Minoo Date: Wed, 9 Mar 2011 04:14:21 +0000 (-0500) Subject: added text overlay to the image plugin, made a default size for images -#368 X-Git-Tag: v0.5~15^2~12 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=cba7dc8ade60882ed171ad494303b744b12f420c;p=popcorn-js.git added text overlay to the image plugin, made a default size for images -#368 --- diff --git a/plugins/image/popcorn.image.html b/plugins/image/popcorn.image.html index ec1abcc..168a4e9 100644 --- a/plugins/image/popcorn.image.html +++ b/plugins/image/popcorn.image.html @@ -15,6 +15,7 @@ end: 15, // seconds href: 'http://www.drumbeat.org/', src: 'https://www.drumbeat.org/media//images/drumbeat-logo-splash.png', + text: 'DRUMBEAT', target: 'imagediv' } ) .image({ @@ -22,6 +23,7 @@ end: 45, // seconds // no href src: 'http://patriciabergeron.net/wp-content/uploads/web.made_.movie_marquee.gif', + text: 'WEB MADE MOVIES', target: 'imagediv' } ); diff --git a/plugins/image/popcorn.image.js b/plugins/image/popcorn.image.js index c2e4310..9fe50a9 100644 --- a/plugins/image/popcorn.image.js +++ b/plugins/image/popcorn.image.js @@ -22,6 +22,7 @@ end: 15, // seconds href: 'http://www.drumbeat.org/', src: 'http://www.drumbeat.org/sites/default/files/domain-2/drumbeat_logo.png', + text: 'DRUMBEAT', target: 'imagediv' } ) * @@ -40,7 +41,8 @@ end : {elem:'input', type:'number', label:'Out'}, href : {elem:'input', type:'text', label:'Link URL'}, target : 'Image-container', - src : {elem:'input', type:'text', label:'Source URL'} + src : {elem:'input', type:'text', label:'Source URL'}, + text: {elem:'input', type:'text', label:'TEXT'} } }, @@ -55,11 +57,35 @@ if ( document.getElementById( options.target ) ) { document.getElementById( options.target ).appendChild( options.link ); // add the widget's div to the target div } - var img = document.createElement( 'img' ); - img.src = options.src; - img.style.borderStyle = "none"; // borders look really bad, if someone wants it they can put it on their div target - - options.link.appendChild( img ); + var div = document.createElement( 'div' ); + divStyle = { + width : '200px', + height : '200px', + background : "url( " + options.src + " ) no-repeat ", + backgroundSize : '100%', + MozBackgroundSize: '100%', + borderStyle : 'none' + } + for (s in divStyle) { + div.style[s] = divStyle[s]; + } + + var divText = document.createElement( 'div' ); // add the inner div for overlaying text + divTextStyle = { + width : '50%', + margin : 'auto', + marginTop : '20px', + color : 'black', + fontWeight : 'bold', + textAlign : 'center' + } + for (st in divTextStyle) { + divText.style[st] = divTextStyle[st]; + } + divText.innerHTML = options.text + + div.appendChild( divText); + options.link.appendChild( div ); },