Rabu, 19 Agustus 2015

Make Recent Post with News Ticker Style use jQuery

Tutorial lawas berbicara tentang news ticker Jika ingin penjelasan apakah yang di maksud dengan news ticker, silahkan baca via wikipedia :D AA Koben akan berbagi info bagaimana cara membuat recent post blogger using jQuery! Kalau sobat tertarik dengan yang memakai JavaScript murni, anda bisa meluncur ke alamat www.kompiajaib.com/2015/06/animated-news-ticker-recent-posts.html. Seperti yg gue bilang, tuts ini terhubung dengan jQuery script! Template sodara harus sudah tertanam script:<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>Kalau sudah ada abaikan langkah ini jangan pasang lagi, lanjut ke langkah berikutnya.
.tickerwrapper {
position: relative;
}
.tickhead {
background: #dd4c39 url(https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh_GC3FlmhQFUWVuyj137wSvdrttPXJz-_vPhYpunuDtoVWao02cd0vNddk-Gij6fx_40Jeib_CS53zf5pgccBUG3z7pBeWMHYr38D1achar64UJhWvBCpLfjzbZjqTbEDuxGh7UIhRvm4/) no-repeat;
background-position: 125px 10px;
background-size: 20px;
position: absolute;
line-height: 41px !important;
height: 40px;
width: 125px;
padding: 0 40px 0 5px;
text-align: center;
color: #fff;
font: 600 15px 'pt sans', sans-serif;
z-index: 1;
top: 0;
left: 0;
}
.tick-er {
padding-left: 180px;
height: 40px !important;
overflow: hidden;
background: #555;
line-height: 40px !important;
}
.tick-er ul {
padding: 0;
margin: 0;
list-style: none;
}
.tick-er ul li a {
color: #fff;
font: 400 15px 'pt sans', sans-serif;
text-decoration: none;
}
Silahkan atur-atur en edit-edit kode CSS itu.
<script type='text/javascript'>//<![CDATA[
!function(t,e,n){function i(i,o){function a(){h.elem.children().css("margin",0).children().css("margin",0),h.elem.css({position:"relative",height:h.opts.height,overflow:"hidden"}),h.targ.css({position:"absolute",margin:0}),setInterval(function(){d()},100)}function r(){h.timer=setInterval(function(){1==h.winFocus&&l(h.opts.direction)},h.opts.interval),t(h.opts.controls.toggle).addClass("et-run").html(h.opts.controls.stopText)}function c(){clearInterval(h.timer),h.timer=0,t(h.opts.controls.toggle).removeClass("et-run").html(h.opts.controls.playText)}function l(t){var e,n,i;if(h.elem.is(":visible")){"up"==t?(e=":first-child",n="-=",i="appendTo") : (e=": last-child",n="+=",i="prependTo");var o=h.targ.children(e),s=o.outerHeight();h.targ.stop(!0,!0).animate({top:n+s+"px"},h.opts.speed,h.opts.easing,function(){o.hide()[i](h.targ).fadeIn(),h.targ.css("top",0),d()})}}function u(t){c(),l("up"==t?"up":"down")}function p(){var e=0,n=h.elem.css("display");h.elem.css("display","block"),h.targ.children().each(function(){e+=t(this).outerHeight()}),h.elem.css({display:n,height:e})}function f(e){var n=0;h.targ.children(": lt("+h.opts.visible+")").each(function(){n+=t(this).outerHeight()}),1==e?h.elem.stop(!0,!0).animate({height:n},h.opts.speed):h.elem.css("height",n)}function d(){"auto"==h.opts.height&&0!=h.opts.visible?(anim="init"==arguments.callee.caller.name?0:1,f(anim)):"auto"==h.opts.height&&p()}var h=this;return h.opts=t.extend({},s,o),h.elem=t(i),h.targ=t(i).children(":first-child"),h.timer=0,h.mHover=0,h.winFocus=1,a(),r(),t([e,n]).off("focus.jqet").on("focus.jqet",function(){h.winFocus=1}).off("blur.jqet").on("blur.jqet",function(){h.winFocus=0}),1==h.opts.mousePause&&h.elem.mouseenter(function(){h.timerTemp=h.timer,c()}).mouseleave(function(){0!==h.timerTemp&&r()}),t(h.opts.controls.up).on("click",function(t){t.preventDefault(),u("up")}),t(h.opts.controls.down).on("click",function(t){t.preventDefault(),u("down")}),t(h.opts.controls.toggle).on("click",function(t){t.preventDefault(),0==h.timer?r():c()}),{up:function(){u("up")},down:function(){u("down")},start:r,stop:c,options:h.opts}}var o="easyTicker",s={direction:"up",easing:"swing",speed:"slow",interval:2e3,height:"auto",visible:0,mousePause:1,controls:{up:"",down:"",toggle:"",playText:"Play",stopText:"Stop"}};t.fn[o]=function(e){return this.each(function(){t.data(this,o)||t.data(this,o,new i(this,e))})}}(jQuery,window,document),$(function(){$(".news-ticker").each(function(){var t=$(this).attr("data-domain"),e="http://www."+t+"/feeds/posts/summary/?max-results=99&alt=json-in-script",n=$(this);n.append('<div class="tickerwrapper"><span class="tickhead">Latest News</span><div class="tick-er"><ul></ul></div></div>'),$.ajax ({type:"GET",url:e,async:!1,contentType:"application/json",dataType:"jsonp",success:function(t){for(var e=1;e<t.feed.entry.length;e++){for(var i=0;i<t.feed.entry[e].link.length;i++)if("alternate"==t.feed.entry[e].link[i].rel){var o=t.feed.entry[e].link[i].href;break}var s=t.feed.entry[e].title.$t,a='<li><a href="'+o+'">'+s+"</a></li>";$(".tick-er ul",n).append(a)}$(".tick-er").easyTicker({direction:"up",easing:"swing",speed:"slow",interval:2e3,height:"auto",visible:0,mousePause:1})}})})});
//]]></script>
Pasang script itu, terserah mau telanjang macam begituh atau dihostingkan terlebih dahulu.

Pada script dengan tulisan /feeds/posts/summary/?max-results=99 Gantikan nominal 99 sesuai dengan kebutuhan. Makin besar nominal, makin lama loading :p
Untuk pemasangan/pemanggilan sobat tinggal membuat syntax HTML sebagai berikut<div class='news-ticker' data-domain='DOMAIN-OR-NAMA-BLOG'></div>Contoh<div class='news-ticker' data-domain='beben-koben.blogspot.com'></div>Silahkan pasang mau berapa biji, bebas asalkan jangan sama domainnya :))

Artikel ini saya comot dari bloggerever How to add recent post news ticker widget in Blogger using jQuery www.bloggerever.com/2014/08/how-to-add-recent-post-news-ticker.html Jika kalian kunjungi site tersbut, maka cari artikel dengan judul "Download free Magazine style template for Blogger" Sikat template keren punya \m/

Permiooosss...:-h

Sabtu, 15 Agustus 2015

Get CanIUse Info just One Click

Sebagai developer sudah seharusnya memahami ilmu yang dikuasainya. Jika berkecimpung dengan bahasa HTML ya harus sudah paham, kalau bahasa CSS musti begitu juga dan lain sebagainya. Cerita punya alur AA Koben akan berbagi tutorial bagaimana cara memberitahukan support CSS code! Salah satu web yg menjadi rujukan dalam kasus ini adalah www.caniuse.com Dengan memberikan link info kepada website tersebut, sobat tidak usah lagi capek-capek menuliskan/memberitahukan bahwa kode CSS ini mendukung terhadap mozilla, google chrome, safari, etc. Plus opsi link ke website dokumen www.w3.org
Contoh begini...

Ketika kita akan memberitahukan salah satu properti HTML5 (Video), kita cukup menuliskan dengan syntax HTML seperti berikut <get-caniuse>video</get-caniuse> Nanti akan muncul ikon kecil di sebelah kanan tulisan video, tinggal klik ikon tersebut maka akan muncul gambar support browser engine plus link info ke 2 web yg gue bicarakan tadi.
Demo & source: codepen.io/tevko/full/OVQeyP - github.com/tevko/getCaniuse

get-caniuse {
display: inline-block;
}
get-caniuse * {
box-sizing: border-box;
}
get-caniuse .caniuse-card {
max-width: 500px;
position: absolute;
border: solid 1px #555;
background-color: #fff;
padding: 15px;
border-radius: 15px;
box-shadow: 5px 5px 15px #000;
}
get-caniuse .caniuse-card p {
margin-top: 0;
}
get-caniuse .caniuse-card .title {
font-weight: bold;
font-size: 21px;
}
get-caniuse .caniuse-card .caniuse-close {
cursor: pointer;
position: absolute;
top: 15px;
right: 15px;
font-size: 19px;
}
get-caniuse .caniuse-card .caniuse-supports {
padding: 15px 0;
text-align: center;
}
get-caniuse img {
cursor: pointer;
padding-left: 3px;
vertical-align: middle;
}
get-caniuse .CIU_bs_supported {
width: 75px;
height: 75px;
}

Silahkan hias-hias sendiri kode css dasar itu.

<script type='text/javascript'>//<![CDATA[
(function(){window.CIU={settings:{elems:'get-caniuse',cIco:'http://www.google.com/s2/favicons?domain=caniuse.com',CIUData:'',dataURL:'https://raw.githubusercontent.com/Fyrd/caniuse/master/data.json',objFormatted:false},init:function(){this.createLinks();},createLinks:function(){var s=this.settings,cElems=document.querySelectorAll(s.elems);Array.apply(null,cElems).forEach(function(elem,idx){elem.addEventListener('click',this.getCIUData.bind(elem,elem.innerHTML,s));var i=new Image();i.src=s.cIco;i.style.width='15px';i.style.display='inline-block';elem.appendChild(i);}.bind(this));},getCIUData:function(string,s,e){if(!this.classList.contains('caniuse-disabled')){s.CIUData===''?CIU.retrieveJSON(string,this):CIU.getClosestMatch(string,this);}},retrieveJSON:function(string,elem){var s=this.settings,request=new XMLHttpRequest();request.open('GET',s.dataURL,true);request.onload=function(){if(request.status>=200&&request.status<400){s.CIUData=JSON.parse(request.responseText).data;this.getClosestMatch(string,elem);}else{this.fallBack(string);}}.bind(this);request.onerror=function(){this.fallBack(string);}.bind(this);request.send();},fallBack:function(string){window.open('http://caniuse.com/#search='+string);},getClosestMatch:function(string,elem){if(elem.querySelector('.caniuse-card')!==null){elem.querySelector('.caniuse-card').style.display='block';elem.classList.add('caniuse-disabled');}else{var s=this.settings,strFormat=string.replace(/-/g,'').toUpperCase(),regexp=new RegExp('\('+strFormat+'\)'),keys=Object.keys(s.CIUData),requestedKey;if(!s.objFormatted){keys.forEach(function(key){var keyFormatted=key.replace(/-/g,'').toUpperCase();s.CIUData[keyFormatted]=s.CIUData[key];delete s.CIUData[key];console.log(key)});s.objFormatted=true;keys=Object.keys(s.CIUData);}
keys.forEach(function(key){if(key.match(regexp)){requestedKey=key;}});requestedKey===undefined&&this.fallBack(string);this.makeCard(s.CIUData[requestedKey],elem,string);}},makeCard:function(obj,elem,string){var getSupportData=function(){var stats=obj.stats,checking=[stats.ie,stats.firefox,stats.chrome,stats.safari,stats.opera,stats.edge],supported='';
stats.ie.name = 'https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjviH7dfGMceOkk-4xJFkPm0nIghL6wLwGkup373ethgBLM3xTU3CB3h1tTonziWPGXP3R-fEWV2Klr25wK6chG1IQch-DiR4pX31bWaO-M2UEqsftdxzn-cdX6X4PYGLaKYYrBe_BbNR0/s100-c/';
stats.firefox.name = 'https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglQiO8QHFa12chaBq9SsfxfOjPOjWaifGP-Xsz5zkf-jvXEcPUM6MxMKsYctDJBiUvE8bheMWvvZw4TGeeETI9jyCL9udObHhCVVSfUhyphenhyphenL7Qc64hcxSkKbH4dvio9XGuSldR7_KRFIOkWl/s100-c/';
stats.chrome.name = 'https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjt4GpYLtEXjWk0vT7J80ig6dQsP-Os_ZYPcE0i7SU41OMzCXMPP1_hQMlQ-uI3y-E4cZt1_6gwoD6yMNeA66XaQw3yaHjZgSXNwpBdjxVyz-0W7z7GYR15NLbMfJ1jSmk10AR_d0B8FMvx/s100-c/';
stats.safari.name = 'https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjIL4NZ0_V7_Hp5WaDCy_Qz9wkv_wAaOR_8xePv3tSNBnkGX4zrDEsR85O08gv4o3jIHLfvOycPBFyt1vVaeTiyG9YRnWKGmYkNkev-oW7fN0NpUt8UrBn1mgnxDA8lfsQ3qhrpv6LKlmdV/s100-c/';
stats.opera.name = 'https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsHjML1KPF5euR7n0Ajop9fnM5Cg8bWCGIFWDrML0ZI6FkMymb-01L6EN4-eMPh9TiIgODO2GXfADzZVlBuppfJR8CknMldnqW9FeU5bfuJ31rKFGfACn5jyZ-FasivgLerlh6CqOPhK4/s100-c/';
stats.edge.name = 'https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgbffS9P_HGojQ3pg6orVeS4osT_hIiyf6-5ePtKitNyUnpDNGd2TG2IAr92z1INTz4iMXf6_loj25u3j50ZRhMivkqGM4d3MJS8HLlIHGHCSFAe6yhe21Mc37xyN4zf6ZsRDB5zl4t2ew/s100-c/';
checking.forEach(function(check){Object.keys(check).forEach(function(key){if(supported.indexOf('<img class="CIU_bs_supported" src="'+check.name+'">')===-1&&(check[key]==='y'||check[key]==='p'||check[key]==='a x #2'||check[key]==='a #1')){supported+='<img class="CIU_bs_supported" src="'+check.name+'">';}});});return supported;};var card='<div class="caniuse-card">'
+'<p class="title">'
+obj.title
+'</p>'
+'<p class="description">'
+obj.description
+'</p>'
+'<a class="speclink" href="'+obj.spec+'" target="top">W3C Spec</a>'
+'<div class="caniuse-supports">'+getSupportData()+'</div>'
+'<a class="speclink" href="http://caniuse.com/#search='+string+'" target="top">See more on CanIUse.com...</a>'
+'<span class="caniuse-close">X</span>'
+'</div>';elem.innerHTML+=card;elem.classList.add('caniuse-disabled');elem.addEventListener('click',function(e){if(e.target.classList.contains('caniuse-close')){elem.classList.remove('caniuse-disabled');elem.querySelector('.caniuse-card').style.display='none';}});}};})();CIU.init();
//]]></script>

Simpan JavaScript itu sebelum/di atas tag </body> (Recommended) atau tag </head>

Pemakaian ketika akan melakukan postingan, harus pakek syntax <get-caniuse>BLAH-BLEH-BLOH</get-caniuse>

Browser Detection - codepen.io/brandonkennedy/pen/XbQdbW
Kalau kepengen link info via wikipedia, you dapat baca get wikipedia headline using jquery wiki.

Sabtu, 08 Agustus 2015

Get W3 CSS for Responsive Web Sites and Web Dock

Malas mosting sebenarnya :)) Dalam postingan sebelumnya what your choice bootstrap or material design google gue memberikan satu link extra source ke halaman w3schools yang berbicara tentang "faster and more beautiful responsive web sites inspired by google material design" Nah, AA Koben sudah buatkan versi offline halaman tersebut bagi kalian! Tetapi hanya berjalan pada browser mozilla ;)) Bagi yg mau silahkan download Google Material Design.zip downloads.ziddu.com/download/24947130/Google-Material-Design.zip.html Ekstrak file.zip kemudian buka pada address bar browser file dengan nama W3.CSS Home.htmW3-CSS Dari codepen dengan nama user Akshay Nair, saya mencomot beberapa tutorial ringan. Yang akan ane bahas yaitu tentang web dock
#dock {
position: fixed;
bottom: 0;
width: 100%;
min-height: 30px;
}
#dock .dock {
margin: 0 auto -17px;
transform-style: preserve-3d;
transform: translateY(100px);
perspective: 5000px;
perspective-origin: 50% 0;
transition: all 0.4s ease;
text-align: center;
}
#dock .dock ul {
list-style-type: none;
padding: 0;
z-index: 100;
margin-bottom: -119px;
transform: translateZ(100px);
}
#dock .dock ul li {
display: inline-block;
}
#dock .dock ul li a {
display: inline-block;
background: #fff;
border: 2px solid #aaa;
width: 50px;
height: 50px;
border-radius: 50%;
vertical-align: center;
text-decoration: none;
transition: all 0.4s ease;
text-align: center;
line-height: 50px;
font-size: 13px !important;
color: #555;
font-family: Helvetica,sans-serif;
}
#dock .dock ul li a:hover ~ .label {
opacity: 1;
top: -20px;
}
#dock .dock ul li span.label {
position: absolute;
top: -5px;
margin-left: -50px;
opacity: 0;
transition: all 0.2s ease;
color: #888;
}
#dock .dock .back-dock {
width: 400px;
margin: 0 auto -80px;
z-index: -1;
height: 200px;
background: #333;
transform: rotateX_(260deg);
border-radius: 10px;
}
#dock .dock .back-dock ul {
text-align: center;
opacity: 0.2;
-webkit-filter: blur(3px);
filter: url(#blur-effect);
/********
This Is Snippet CSS Blur for Mozilla
http://beben-koben.blogspot.com/2013/12/snippet-inline-css-filter-for-mozilla-ii.html
http://codepen.io/beben-koben/pen/ckKzh
*********/
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'blur-effect\'><feGaussianBlur stdDeviation=\'3\' /></filter></svg>#blur-effect");
transform: scale(1.01, 2);
}
#dock .dock .back-dock ul a {
cursor: default;
}
#dock:hover > .dock {
transform: translateY(0px);
}
Tolong ganti kode transform: rotateX_(260deg); tanpa garis bawah X_( (bentrok ama kode emot)

<div id='dock'>
<div class='dock'>
<ul>
<li><a href='#'>Home</a><span class='label'>Home</span></li>
<li><a href='#'>Post</a><span class='label'>Link1</span></li>
<li><a href='#'>Project</a><span class='label'>Link2</span></li>
<li><a href='#'>About</a><span class='label'>Link3</span></li>
<li><a href='#'>Contact</a><span class='label'>Link4</span></li>
</ul>
<div class='back-dock'>
<ul>
<li><a>A</a></li>
<li><a>B</a></li>
<li><a>C</a></li>
<li><a>D</a></li>
<li><a>E</a></li>
</ul>
</div>
</div>
</div>
Jika efek CSS tidak berjalan, maka code CSS harap di fix/prefix terlebih dahulu :D
Demo and other source:
>> WebDock - codepen.io/phenax/pen/LVqLdK
>> Custom Context Menu - codepen.io/phenax/pen/BNGjBO
>> Pure CSS Sidemenu - codepen.io/phenax/pen/GJPwKg
>> Fixed-width buttons - www.steliosconstantinides.com/FormButtons
>> FontCDN - fontcdn.org