101101111001010

JQuery scroll up down event function

Автор: Administrator.

function fun(el, curScrlTop){
 if(curScrlTop - lastScrollTop < 0){...}
 else{...}
 lastScrollTop = curScrlTop;
}

JQuery when stop scrolling event function

Автор: Administrator.

$(window).scroll(function() {
 clearTimeout($.data(this, 'scrollTimer'));
 $.data(this, 'scrollTimer', setTimeout(function() {
 myFunc()
 }, 40));
});

CSS View and Hide div block information by title click

Автор: Administrator.

После клика по элементу с классом project-title следующий элемент с классом project-info будет сперва скрыт, а по еще одному клику по project-title раскрыт с анимацией длительностью 700мс.

$('.project-title').click(function(){
    $(this).next('.project-info:first').toggle(700);
});

C# add application in autorun (regedit | реестр)

Автор: Administrator.

private static void autorun()
 {
 const string name = "my_app";
 string ExePath = Application.ExecutablePath;
 RegistryKey reg;
 reg = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Run\");
 reg.SetValue(name, """ + ExePath + "" /hide");
 reg.Close();
 }

C# Run Console application hidden

Автор: Administrator.

Change the output type from Console Application to Windows Application. This can be done underProject -> Properties -> Application in Visual Studio:

js function set default param value (параметр по умолчанию)

Автор: Administrator.

function showMessage(from, text) {
if (text === undefined) {
 text = 'текст не передан';
 }
 alert(from + ": " + text);
}
 
showMessage("Маша", "Привет!"); // Маша: Привет!
showMessage("Маша"); // Маша: текст не передан
 

Второй вариант: 

function showMessage(from, text) {
 text = text || 'текст не передан';
 ...
}

IE11+ meta X-UA-Compatible проблемы совместимости

Автор: Administrator.

<code><!DOCTYPE html> <html> <head> <meta http-equiv="X-UA-Compatible" content="IE=edge"> 

</code>
The X-UA-Compatible meta tag allows web authors to choose what version of Internet Explorer the page should be rendered as. IE11+ have changes to these modes. See IE11 note below.
Here are your options:
<ul>
<li>"IE=edge"</li>
<li>"IE=10"</li>
<li>"IE=EmulateIE10"</li>
<li>"IE=9"</li>
<li>"IE=EmulateIE9</li>
<li>"IE=8"</li>
<li>"IE=EmulateIE8"</li>
<li>"IE=7"</li>
<li>"IE=EmulateIE7"</li>
<li>"IE=5"</li>
</ul>

Search input text

Автор: Administrator.

<input type="text" placeholder="search" />

C++. CString to string

CString str = "12345";
std::string str2(static_cast<const char*>(str));
str = str2.c_str();

JS oop objects properties, prototype sample

Автор: Administrator.

function Widget(size,containerId,html,rowNumber){
 this.size = size;
 this.containerId = containerId;
 this.container = $(this.containerId);
 this.html = html;
 this.rowNumber = rowNumber;
 this.rowId = 'row' + this.rowNumber;
}
Widget.prototype = {
 render: function(){
 this.row = $('#' + this.rowId);
 var div = $('<div></div>').addClass('col-md-' + this.size).text(this.html);
 
 if(!this.row.length){
 this.row = $('<div></div>').addClass('row').attr('id', this.rowId);
 this.container.append(this.row);
 }
 this.row.append(div);
 }
}
var widgets = [];
widgets.push(new Widget(5,'#container','vjvjy',2));
widgets.push(new Widget(3,'#container','343456',1));
widgets.push(new Widget(3,'#container','343456',2));
function Render(){
 for(var i = 0; i< widgets.length;i++){
 widgets[i].render();
 }
};
$(document).ready(Render)

Is Element Visible on screen (display) JS

Автор: Administrator.

function <strong>isElementVisible</strong>(elementToBeChecked)
{
   var TopView = $(window).scrollTop();
   var BotView = TopView + $(window).height();
   var TopElement = $(elementToBeChecked).offset().top;
   var BotElement = TopElement + $(elementToBeChecked).height();
   return ((BotElement = TopView));
}
<strong>Sample</strong>
map_diagram('.map_diagram');
function map_diagram(el){
   if(<strong>isElementVisible</strong>(el)){
      $(el).animate({'width': '360px',opacity: 1}, 1000);
   }
}

@media for mobile device zoom

Автор: Administrator.

@media only screen and (max-device-width: 1024px) { 
     body { zoom: 0.8;} 
}

Detecting browsers javascript hacks

Автор: Administrator.

/Firefox detector 2/3 by DoctorDan
FF=/a/[-1]=='a'
//Firefox 3 by me:-
FF3=(function x(){})[-5]=='x'
//Firefox 2 by me:-
FF2=(function x(){})[-6]=='x'
//IE detector I posted previously
IE='v'=='v'
//Safari detector by me
Saf=/a/.__proto__=='//'
//Chrome by me
Chr=/source/.test((/a/.toString+''))
//Opera by me
Op=/^function (/.test([].sort)
//IE6 detector using conditionals 
try {IE6=@cc_on @_jscript_version

loader for site

Автор: Administrator.

html:

<div id="loader">
<p id="loader_text ">
Loading...
</p>
</div>
 
css: 
#loader{height: 100%;left: 50%;position: fixed;top: 40%;width: 100%;z-index: 9999;}
.loader_text {
font-family: 'Open Sans', sans-serif;
font-size: 20px;
width: 150px;
height: 40px;
background: silver;
color: green;
text-align: center;
padding-top: 10px;
opacity: 0.7;
border-radius: 5%;
overflow: hidden;
}
js:
jQuery(window).load(function() { 
if('v'=='v'){IEoperation();} //if IE
$("#loader").delay(600).fadeOut("slow");
});

Built with HTML5 and CSS3 | Copyright © 2012 - 2015 Зарембо Александр