Skip to content

Instantly share code, notes, and snippets.

@jetfire21
Last active May 18, 2017 19:52
Show Gist options
  • Save jetfire21/97b515df0c2ad10c4b0b2743866dc4ce to your computer and use it in GitHub Desktop.
Save jetfire21/97b515df0c2ad10c4b0b2743866dc4ce to your computer and use it in GitHub Desktop.
javascript & jquery functions
<script>
// ************ регулярные выражения на javascript (пример) **********
// var str = '<a id="show_fast_buy" rel="nofollow" href="#fast_buy" data-quantity="1" data-product_id="92" data-title="Мужские тапочки ручной работы" class="popup-modal_buy button add_to_cart_button">Быстрая покупка</a>';
// находим data-title="Мужские тапочки ручной работы
var title = link_cont.match(/data-title="[^"]+/i);
title = title[0];
// находим "Мужские тапочки ручной работы
title = title.match(/"[^"]+/i);
title = title[0];
title = title.substr(1);
// console.log(title);
// ************ регулярные выражения на javascript (пример) **********
</script>
<!-- /* **** as21 динмаическое добавление данных в метод плагина, например через ajax
http://www.jqueryscript.net/time-clock/Responsive-Dynamic-Timeline-Plugin-For-jQuery-Timeliner.html **** */
Timeliner.prototype = {
init: function() { // ...какой-то код метода },
add: function(_item){ // ...какой-то код метода }
render: function(){ // ...какой-то код метода }
};
-->
<!-- разметка для плагина -->
<div id="as21">
<li>
<div class="timeliner_element teal">
<div class="timeliner_title">
<span class="timeliner_label">Event Title</span><span class="timeliner_date">03 Nov 2014</span>
</div>
<div class="content">
<b>Lorem Ipsum</b> is simply dummy text of the printing and typesetting industry Lorem Ipsum has been the industry's standard dummy text evsince he 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only fcenturies, ut also the leap into electronic typesetting, remaining essentially unchang
</div>
<div class="readmore">
<a class="btn btn-primary" href="javascript:void(0);" ><i class="fa fa-pencil fa fa-white"></i></a>
<a class="btn btn-bricky" href="javascript:void(0);" ><i class="fa fa-trash fa fa-white"></i></a>
<a href="#" class="btn btn-info">
Read More <i class="fa fa-arrow-circle-right"></i>
</a>
</div>
</div>
</li>
<!-- ....... можно добавить сколько угодно li -->
</div>
<script type="text/javascript">
jQuery( document ).ready(function($) {
var new_li = '<li>\
<div class="timeliner_element teal">\
<div class="timeliner_title">\
<span class="timeliner_label">Event Title</span><span class="timeliner_date">10 Nov 2014</span>\
</div>\
<div class="content">\
11111111111\
</div>\
<div class="readmore">\
<a class="btn btn-primary" href="javascript:void(0);" ><i class="fa fa-pencil fa fa-white"></i></a>\
<a class="btn btn-bricky" href="javascript:void(0);" ><i class="fa fa-trash fa fa-white"></i></a>\
<a href="#" class="btn btn-info">\
Read More <i class="fa fa-arrow-circle-right"></i>\
</a>\
</div>\
</div>\
</li>\
<li>\
<div class="timeliner_element teal">\
<div class="timeliner_title">\
<span class="timeliner_label">Event Title</span><span class="timeliner_date">15 Nov 2014</span>\
</div>\
<div class="content">\
22222\
</div>\
<div class="readmore">\
<a class="btn btn-primary" href="javascript:void(0);" ><i class="fa fa-pencil fa fa-white"></i></a>\
<a class="btn btn-bricky" href="javascript:void(0);" ><i class="fa fa-trash fa fa-white"></i></a>\
<a href="#" class="btn btn-info">\
Read More <i class="fa fa-arrow-circle-right"></i>\
</a>\
</div>\
</div>\
</li>';
var tl = $('#as21').timeliner();
tl.add(new_li).render();
// tl.destroy(); //work
});
</script>
<!-- /* **** as21 динмаическое добавление данных в метод плагина, например через ajax
http://www.jqueryscript.net/time-clock/Responsive-Dynamic-Timeline-Plugin-For-jQuery-Timeliner.html **** */ -->
<!-- /* **** as21 prints the contents of the current window**** */ -->
jQuery(".print img").click(function (){
var styles = "<style>@media print{.print{ display: none; } body{ background: #000;} .mfp-close{display:none;} }</style>";
// var printContents = document.getElementById("show-signup-report-modal").innerHTML;
var printContents = jQuery("#show-signup-report-modal").html()+styles;
console.log(printContents);
// way 1
w=window.open();
w.document.write(printContents);
w.print();
w.close();
// way2
/*
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
body.innerHTML = originalContents;
*/
});
<!-- /* **** as21 prints the contents of the current window**** */ -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment