(function(w, d){
var childOf = function (child, parent) {
while((child=child.parentNode) && child!==parent);
return !!child;
};
var initApp = function() {
var activeTab,
menu = d.querySelector('#menu'),
firstLevel = menu.children || [],
ln = firstLevel.length;
var tabClickHandler = function (e) {
e.preventDefault();
if (!activeTab) {
activeTab = this;
} else {
activeTab.classList.remove('active');
activeTab = this;
}
this.classList.add('active');
};
var innerTabClickHandler = function (e) {
e.preventDefault();
e.stopPropagation();
if (activeTab) {
activeTab.classList.remove('active');
}
};
var closeMenuHandler = function (e) {
var target = e.target || e.srcElement;
if(!childOf(target, menu)) {
if (activeTab) {
activeTab.classList.remove('active');
}
}
};
if (!ln) return;
while(ln--) {
var tab = firstLevel[ln],
secondLevel = tab.querySelectorAll('ul > li') || [],
lnS = secondLevel.length;
tab.addEventListener('click', tabClickHandler, false);
while(lnS--) {
var innerTab = secondLevel[lnS];
innerTab.addEventListener('click', innerTabClickHandler, false);
}
}
d.addEventListener('click', closeMenuHandler, false);
};
w.addEventListener('DOMContentLoaded', initApp);
}(window, document));
$(document).on('click', '.news h2 a', function(){
$(this).parent('h2').parent('.news').children('.text_from_news').slideToggle();
return false;
});
var Comp1 = React.createClass({
//code
render: function() {
return (
<div>
<Comp2 data={this.state.data} />
</div>
);
}
});
var Comp2 = React.createClass({
render: function() {
return (
var fromOne = this.props.data;
<div>
{fromOne}
</div>
);
}
});
$("input[type=text]").each(function() {
var input = $(this), id = this.id;
input.attr('name', id);
});
$(document).ready(function() {
$('.scroll-pane').jScrollPane({
autoReinitialise: true
});
});
<meta name="viewport" content="width=device-width,initial-scale=1" id="viewport" />
(function (w, d) {
var viewport = d.querySelector('#viewport'),
viewports = {
default: viewport.getAttribute('content'),
small: 'width=320'
};
var viewport_set = function() {
screen.width <= 320 ? viewport.setAttribute( 'content', viewports.small) : viewport.setAttribute( 'content', viewports.default );
}
//При загрузке
viewport_set();
// При изменении
w.onresize = function() {
viewport_set();
}
}(window, document));
<link rel="stylesheet" type="text/css" media="only screen and (max-device-width: 480px)" href="mobile-device.css" />
if (obj.nextSibling){
console.log(obj.nextSibling);
document.getElementById('inputi').insertBefore(new_input,obj.nextSibling)
}else{ document.getElementById('inputi').appendChild(new_input);}
document.getElementById('inputi').appendChild(new_input);
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']
|| window[vendors[x]+'CancelRequestAnimationFrame'];
}
if (!window.requestAnimationFrame)
window.requestAnimationFrame = function(callback, element) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout(function() { callback(currTime + timeToCall); },
timeToCall);
lastTime = currTime + timeToCall;
return id;
};
if (!window.cancelAnimationFrame)
window.cancelAnimationFrame = function(id) {
clearTimeout(id);
};
}());
$flexslider.hide();
$flexslider.css({'visibility': 'hidden'});
//и
$flexslider.css({'visibility': 'visibility'});
flexsliderInit: function () {
$('.slider').flexslider({
controlsContainer: ".flex-control-thumbs",
animation: 'slide',
direction: "horizontal",
animationLoop: false,
slideshow: false,
controlNav: true,
directionNav:true,
manualControls: ".flex-control-thumbs .list-cell",
start: function(slider){
var $flexslider = $('.flexslider');
$flexslider.css({'visibility': 'hidden'});
var $thumbs = $('.list-cell'), timer;
$('.list-cell').each(function(){
$(this).on('click', function(e){
clearTimeout(timer);
timer = setTimeout(function () {
$flexslider.css({'visibility': 'visible'});
}, 500);
e.preventDefault();
$(window).trigger('resize');
$slideItems = $('.list-cell--overlay');
$slideItems.each(function () {
var $item = $(this), $close = $item.find('.close');
$close.on('click', function () {
$flexslider.hide();
});
});
});
});
}
});
}
(function() {
var app = angular.module('testApp', [
'ngRoute'
]);
app.config(function($routeProvider) {
$routeProvider.when('/page', {
templateUrl: 'test.tpl.html',
controller: 'TestCtrl'
});
});
app.controller('TestCtrl', function($scope) {
console.log('тут уже можно пользоваться теми скриптами, которые подгрузили во вьюхе');
});
})();
<div class="testView">
<script src="testFunction.js"></script>
</div>
document.addEventListener( "DOMContentLoaded", function () {
alert('Меня подгрузили!!!');
}, false );
});
var div = document.querySelector('тут селектор вашего блока с прокруткой');
div.scrollTop = 0;