» » [jQuery] - featured slider hover Automatic post

Flat News – News & Magazine Blogger Template

วันนี้ แต่งบล็อกขอนำ jquery featured slider  สวยๆงามๆ มานำเสนอ
jquery featured slider สวยๆ จากเว็บ http://allmysteryworld.blogspot.com


โดยหลัการ เป็นการแสดงบทความ อัตโนมัติ จาก label  หรือ ป้ายกำกับ


ขั้นตอนการติดตั้ง



ก่อนอื่นให้คุณ Login เข้าไปที่ blogger.com และจากแผงควบคุมให้เข้าไปที่ แม่แบบ >> แก้ไข HTML

ขั้นที่ 1 ติดตั้ง CSS โค้ดเพื่อกำหนดรูปแบบ 

ให้คุณค้นหาโค้ด ]]></b:skin> และเมื่อพบแล้วให้วางโค้ดด้านล่างนี้ลงไปก่อนหน้าโค้ด ]]></b:skin> 

/*---------------------------------------------------------------------------------*/
/* /Features Slider - There are two featured slider in */
/*---------------------------------------------------------------------------------*/
#featuredContent {
background:#343434;
border:1px solid #3D3D3D;
float:left;
width:650px;
margin:5px 5px 5px 5px;
display:inline;
}
#featured-slider {
position: relative; /*leave as is*/
overflow: hidden; /*leave as is*/
width: 650px; /*width of featured content slider*/
height: 300px;
}
#featured-slider .sliderPostInfo { /* Post title and if enabled excerpt wrapper for featured slider */
position:absolute;
bottom:0px;
width:650px;
min-height:100px;
height: auto !important; /* IE6 Min height hack */
height: 100px;
background: url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSoMYAbafpvacCc2nN6ED2XZWvsGCDK9nJvDpUJEPdOzhB02uCG3_zPmkzvipq3wZt0Kow5H4bx250F2RVkrN2N0gYNSIboPNvROhzvd7VLhGUXSrGLpQbZ6OAQWn4LPmQfdI_d-0Z_-I2/s1600/bgtransparent.png);
}
#featured-slider .sliderPostInfo p { /* Post excerpt style on featured slider */
color:#fff;
font-size:1.1em;
padding:3px 5px 5px 6px;
}
#featured-slider .contentdiv{ /* do not change the name of class - The size of contentdiv is 495x270 (after excluding padding value) */
visibility: hidden; /*leave as is*/
position: absolute; /*leave as is*/
left: 0;  /*leave as is*/
top: 0;  /*leave as is*/
z-index:1;
}
#paginate-featured-slider{ /* do not change the name of class - used to wrap thumbnails for featured area */
display:block;
padding:0 0 5px 10px;
margin-bottom:10px;
}
#paginate-featured-slider ul {
width:620px;
padding-bottom:0;
list-style: none;
}
#paginate-featured-slider ul li {
display: inline;
width:75px;
float:left;
margin-left:0;
padding:0 0 0 0;
margin-right:9px;
margin-bottom:3px;
}
#paginate-featured-slider img{
padding-top:5px;
background: #343434;
}
#paginate-featured-slider a img{
border-top:4px solid #fff;
box-shadow: 2px 2px 2px #211c18;
}
#paginate-featured-slider a:hover img, #paginate-featured-slider a.selected img{
border-top:4px solid #cd1713;
box-shadow: 5px 5px 5px #211c18;
}
/* // Features Slider  */
.featuredPost2 { /*Posts displayed below the featured section */
padding-top:5px;
padding-bottom:5px;
}
.featuredPost2Meta {
clear:both;
display:block;
font-style:italic;
font-size:.8em;
padding-top:3px;
padding-bottom:5px;
border-bottom:1px solid #efefef;
}
.featuredPost2Meta a{
color:#CB6F00;
}
.featuredPost2Meta a:hover {
text-decoration:underline;
}
.featuredTitle a { color:#CB6F00; margin-left: 10px ; line-height:1.25; font-family:Arial,serif; font-size:18px; font-weight:bold; }
.featuredTitle a:hover { color:#CB6F00; }



ขั้นที่ 2 ติดตั้ง Javascript (jQuery)

ให้คุณค้นหาโค้ด </head> และเมื่อพบแล้วให้วางโค้ดด้านล่างนี้ลงไปก่อนหน้าโค้ด </head>



 <script src='https://sites.google.com/site/siani3d99/home/code/jquery-v1.7.1.js' type='text/javascript'/>
<script src='https://sites.google.com/site/siani3d99/home/code/jquery-hover-effect.js'/>

<script src='https://sites.google.com/site/siani3d99/home/code/template-jCarouselLite.js' type='text/javascript'/>
  <script src='https://sites.google.com/site/siani3d99/home/code/template-jqueryslidemenu.js' type='text/javascript'/>
 <script src='https://sites.google.com/site/siani3d99/home/code/template-contentslider.js'/>

 <script type='text/javascript'>
   imgr = new Array();
imgr[0] = &quot;http://sites.google.com/site/fdblogsite/Home/nothumbnail.gif&quot;;
showRandomImg = true;
aBold = true;
summaryPost = 140;
summaryTitle = 25;
numposts8 = 7;
function removeHtmlTag(strx,chop){
var s = strx.split(&quot;&lt;&quot;);
for(var i=0;i&lt;s.length;i++){
if(s[i].indexOf(&quot;&gt;&quot;)!=-1){
s[i] = s[i].substring(s[i].indexOf(&quot;&gt;&quot;)+1,s[i].length);
}
}
s =  s.join(&quot;&quot;);
s = s.substring(0,chop-1);
return s;
}
function showsliderA(json) {
j = (showRandomImg) ? Math.floor((imgr.length+1)*Math.random()) : 0;
img  = new Array();
  for (var i = 0; i &lt; numposts8; i++) {
    var entry = json.feed.entry[i];
    var posttitle = entry.title.$t;
var pcm;
    var posturl;
    if (i == json.feed.entry.length) break;
    for (var k = 0; k &lt; entry.link.length; k++) {
      if (entry.link[k].rel == &#39;alternate&#39;) {
        posturl = entry.link[k].href;
        break;
      }
    }
for (var k = 0; k &lt; entry.link.length; k++) {
      if (entry.link[k].rel == &#39;replies&#39; &amp;&amp; entry.link[k].type == &#39;text/html&#39;) {
        pcm = entry.link[k].title.split(&quot; &quot;)[0];
        break;
      }
    }
    if (&quot;content&quot; in entry) {
      var postcontent = entry.content.$t;}
    else
    if (&quot;summary&quot; in entry) {
      var postcontent = entry.summary.$t;}
    else var postcontent = &quot;&quot;;
        postdate = entry.published.$t;
if(j&gt;imgr.length-1) j=0;
img[i] = imgr[j];
s = postcontent ; a = s.indexOf(&quot;&lt;img&quot;); b = s.indexOf(&quot;src=\&quot;&quot;,a); c = s.indexOf(&quot;\&quot;&quot;,b+5); d = s.substr(b+5,c-b-5);
if((a!=-1)&amp;&amp;(b!=-1)&amp;&amp;(c!=-1)&amp;&amp;(d!=&quot;&quot;)) img[i] = d;
//cmtext = (text != &#39;no&#39;) ? &#39;&lt;i&gt;&lt;font color=&quot;&#39;+acolor+&#39;&quot;&gt;(&#39;+pcm+&#39; &#39;+text+&#39;)&lt;/font&gt;&lt;/i&gt;&#39; : &#39;&#39;;

var month = [1,2,3,4,5,6,7,8,9,10,11,12];
var month2 = [&quot;Jan&quot;,&quot;Feb&quot;,&quot;Mar&quot;,&quot;Apr&quot;,&quot;May&quot;,&quot;Jun&quot;,&quot;Jul&quot;,&quot;Aug&quot;,&quot;Sep&quot;,&quot;Oct&quot;,&quot;Nov&quot;,&quot;Dec&quot;];
var day = postdate.split(&quot;-&quot;)[2].substring(0,2);
var m = postdate.split(&quot;-&quot;)[1];
var y = postdate.split(&quot;-&quot;)[0];
for(var u2=0;u2&lt;month.length;u2++){
if(parseInt(m)==month[u2]) {
m = month2[u2] ; break;
}
}
var daystr = day+ &#39; &#39; + m + &#39; &#39; + y ;
var trtd = &#39;&lt;div class=&quot;contentdiv&quot;&gt;&lt;a href=&quot;&#39;+posturl+&#39;&quot;&gt;&lt;img width=&quot;650&quot; height=&quot;300&quot; class=&quot;alignnone&quot; src=&quot;&#39;+img[i]+&#39;&quot;/&gt;&lt;/a&gt;&lt;div class=&quot;sliderPostInfo&quot;&gt;&lt;h2 class=&quot;featuredTitle&quot;&gt;&lt;a href=&quot;&#39;+posturl+&#39;&quot;&gt;&#39;+posttitle+&#39;&lt;/a&gt;&lt;/h2&gt;&lt;p&gt;&#39;+removeHtmlTag(postcontent,summaryPost)+&#39;...&lt;/p&gt;&lt;/div&gt;&lt;/div&gt;&#39;;
document.write(trtd);

j++;
}
}
function showsliderB(json) {
j = (showRandomImg) ? Math.floor((imgr.length+1)*Math.random()) : 0;
img  = new Array();
  for (var i = 0; i &lt; numposts8; i++) {
    var entry = json.feed.entry[i];
    var posttitle = entry.title.$t;
var pcm;
    var posturl;
    if (i == json.feed.entry.length) break;
    for (var k = 0; k &lt; entry.link.length; k++) {
      if (entry.link[k].rel == &#39;alternate&#39;) {
        posturl = entry.link[k].href;
        break;
      }
    }
for (var k = 0; k &lt; entry.link.length; k++) {
      if (entry.link[k].rel == &#39;replies&#39; &amp;&amp; entry.link[k].type == &#39;text/html&#39;) {
        pcm = entry.link[k].title.split(&quot; &quot;)[0];
        break;
      }
    }
    if (&quot;content&quot; in entry) {
      var postcontent = entry.content.$t;}
    else
    if (&quot;summary&quot; in entry) {
      var postcontent = entry.summary.$t;}
    else var postcontent = &quot;&quot;;
        postdate = entry.published.$t;
if(j&gt;imgr.length-1) j=0;
img[i] = imgr[j];
s = postcontent ; a = s.indexOf(&quot;&lt;img&quot;); b = s.indexOf(&quot;src=\&quot;&quot;,a); c = s.indexOf(&quot;\&quot;&quot;,b+5); d = s.substr(b+5,c-b-5);
if((a!=-1)&amp;&amp;(b!=-1)&amp;&amp;(c!=-1)&amp;&amp;(d!=&quot;&quot;)) img[i] = d;
//cmtext = (text != &#39;no&#39;) ? &#39;&lt;i&gt;&lt;font color=&quot;&#39;+acolor+&#39;&quot;&gt;(&#39;+pcm+&#39; &#39;+text+&#39;)&lt;/font&gt;&lt;/i&gt;&#39; : &#39;&#39;;

var month = [1,2,3,4,5,6,7,8,9,10,11,12];
var month2 = [&quot;Jan&quot;,&quot;Feb&quot;,&quot;Mar&quot;,&quot;Apr&quot;,&quot;May&quot;,&quot;Jun&quot;,&quot;Jul&quot;,&quot;Aug&quot;,&quot;Sep&quot;,&quot;Oct&quot;,&quot;Nov&quot;,&quot;Dec&quot;];
var day = postdate.split(&quot;-&quot;)[2].substring(0,2);
var m = postdate.split(&quot;-&quot;)[1];
var y = postdate.split(&quot;-&quot;)[0];
for(var u2=0;u2&lt;month.length;u2++){
if(parseInt(m)==month[u2]) {
m = month2[u2] ; break;
}
}
var daystr = day+ &#39; &#39; + m + &#39; &#39; + y ;
var trtd = &#39;&lt;li&gt;&lt;a class=&quot;toc&quot; href=&quot;#&quot;&gt;&lt;img width=&quot;75&quot; height=&quot;50&quot; class=&quot;alignnone&quot; src=&quot;&#39;+img[i]+&#39;&quot;/&gt;&lt;/a&gt;&lt;/li&gt;&#39;;
document.write(trtd);

j++;
}
}
</script>



ขั้นที่ 3 ติดตั้ง HTML ตำแหน่ง slideshow ที่ต้องการแสดง

โดยแก้ไขา่วนของ label   (ป้ายกำกับของบทความที่จะแสดง)


 <div id='featuredContent'>
<div class="sliderwrapper" id="featured-slider">
<script>
          document.write(&quot;&lt;script src=\&quot;/feeds/posts/default/-/label?max-results=&quot;+numposts8+&quot;&amp;orderby=published&amp;alt=json-in-script&amp;callback=showsliderA\&quot;&gt;&lt;\/script&gt;&quot;);
         </script>      
     </div>
<div id="paginate-featured-slider">
<ul>
          <script>
              document.write(&quot;&lt;script src=\&quot;/feeds/posts/default/-/label?max-results=&quot;+numposts8+&quot;&amp;orderby=published&amp;alt=json-in-script&amp;callback=showsliderB\&quot;&gt;&lt;\/script&gt;&quot;);
             </script>
      </ul>
  <div class="clear"/>
</div>
<!-- End of featured slider -->
     <script type="text/javascript">
        featuredcontentslider.init({
         id: &quot;featured-slider&quot;, //id of main slider DIV
      contentsource: [&quot;inline&quot;, &quot;&quot;], //Valid values: [&quot;inline&quot;, &quot;&quot;] or [&quot;ajax&quot;, &quot;path_to_file&quot;]
      toc: &quot;markup&quot;, //Valid values: &quot;#increment&quot;, &quot;markup&quot;, [&quot;label1&quot;, &quot;label2&quot;, etc]
      nextprev: [&quot;&quot;, &quot;&quot;], //labels for &quot;prev&quot; and &quot;next&quot; links. Set to &quot;&quot; to hide.
      revealtype: &quot;mouseover&quot;, //Behavior of pagination links to reveal the slides: &quot;click&quot; or &quot;mouseover&quot;
      enablefade: [true, 0.4], //[true/false, fadedegree]
      autorotate: [true, 5000], //[true/false, pausetime]
      onChange: function(previndex, curindex){ //event handler fired whenever script changes slide
      //previndex holds index of last slide viewed b4 current (1=1st slide, 2nd=2nd etc)
      //curindex holds index of currently shown slide (1=1st slide, 2nd=2nd etc)
      }
     })
    </script>     
     <!-- Entries below the featured section -->     
    
    </div>
<!-- Enf of featuredContent -->


ตัวอย่าง

jquery featured slider hover Automatic post

«
Next
บทความใหม่กว่า
»
Previous
บทความที่เก่ากว่า

ไม่มีความคิดเห็น:

Leave a Reply

//SEO SCRIPT POWERED BY www.seoinsiter.com