$(function(){
$('textarea').on('keypress',function(event){
var text = $('textarea').val();
var lines = text.split("\n");
var currentLine = this.value.substr(0, this.selectionStart).split("\n").length;
console.log(lines);
console.log(currentLine);
console.log(lines[currentLine-1]);
if(event.keyCode == 13) {
if (lines.length >= $(this).attr('rows'))
return false;
}
else{
if(lines[currentLine-1].length >= $(this).attr('cols')) {
if (lines.length <= $(this).attr('rows') - 1) {
$(this).val(text + '\n');
} else {
return false;
}
}
}
});
});
/*global console*/
var greet = 'Hello';
function say() {
"use strict";
return function (name) {
return greet + " " + name;
};
}
var en = say();
console.log(say("John"));
console.log(say("Martin"));
$(document).ready(function () {
var hash = window.location.hash;
if (hash === "#myNameModal") {
$('#myModal').modal(options);
}
});
<video autoplay poster="test.jpg" id="vidos">
<source src="test.mp4" type="video/mp4">
</video>
#vidos {
position: fixed;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 100%;
width: auto;
height: auto;
z-index: -1;
background: url(test.jpg) no-repeat;
background-size: cover;
}
$(document).ready(function () {
var selects = $('select'), ln = selects.length;
for(var i = 0; i < ln; i++) {
var loc = $(selects[i]), tmenu ;
loc.selectmenu();
tmenu = '#' + loc .attr('id') + '-menu';
var style = loc.data('style');
$(tmenu).parent().addClass(style);
}
});
createPreloading: function() {
QueryLoader.preloader = $("<div></div>").appendTo(QueryLoader.selectorPreload);
$(QueryLoader.preloader).css({
height: "0px",
width: "0px",
overflow: "hidden"
});
var length = QueryLoader.items.length;
QueryLoader.doneStatus = length;
for (var i = 0; i < length; i++) {
var imgLoad = $("<img></img>");
$(imgLoad).attr("src", QueryLoader.items[i]);
$(imgLoad).unbind("load");
$(imgLoad).bind("load", function() {
QueryLoader.imgCallback();
});
$(imgLoad).bind("error", function () {
console.warn(this.src + ' картинка не найдена!');
QueryLoader.imgCallback();
});
$(imgLoad).appendTo($(QueryLoader.preloader));
}
}
$(document).ready(function () {
var close = function() {
var player = $('iframe'), video = player.attr("src");
player.attr("src","");
player.attr("src", video);
}
$(document).on('click', '.fancybox-close', function () {
close();
});
});
function close() {
$('#player').get(0).stopVideo();
}
var app = angular.module("App", [])
.value("test", {})
.controller("first", ['$scope', '$testFactory', function ($scope, $testFactory) {
var test = $testFactory.setTest(1);
console.log(test);
}])
.controller("second",['$scope', '$testFactory', function ($scope, $testFactory) {
var test = $testFactory.setTest(2);
console.log(test);
}])
.factory('$testFactory', [function () {
var test = 0;
return {
setTest: function (val) {
test = val
return test;
}
}
}]);
"content_scripts": [{
"matches":["http://vk.com/*"],
"css":["css/style.css"],
"js":["js/base.js"]
}]
function autoResize(selector) {
var newheight, newwidth, frame = document.querySelector(selector);
if (frame) {
newheight = frame.contentWindow.document.body.scrollHeight;
newwidth = frame.contentWindow.document.body.scrollWidth;
frame.height= (newheight) + "px";
frame.width= (newwidth) + "px";
} else {
console.warn('Не чего не найдено!');
}
}
<html ng-app="App">
<body ng-controller="baseController">
<textarea name="notCrypt" ng-model="noCript"></textarea>
<textarea name="crypt">{{noCript|cript}}</textarea>
</body>
</html>
var app = angular.module("App", []).
controller("baseController",['$scope', function ($scope) {
$scope.noCrypt = "";
}]).
filter('cript', function () {
return function(input) {
// и вот тут, перед выводом, вы можете делать с вашим кодом все что вы захотите в том числе и кодировать
return input;
}
});
<form role="form" id="form" action="catalog/vse-tovaryi/" data-def="catalog/vse-tovaryi/">
<select name="ms|price">
<option value="">Любая</option>
<option value="500">500 рублей</option>
</select>
<select name="msoption|tags">
<option value="1">Тэг 1</option>
<option value="2">Тэг 2</option>
</select>
<button type="submit">Подобрать</button>
</form>
window.onload = function () {
var form = $('#form'), def = form.data('def'), data = {}, action;
$(document).on('change', '#form select', function () {
var el = $(this), val = el.val(), name = el.attr('name');
if (val) {
data[name] = val;
} else {
delete data[name];
}
action = def + "?";
for(var i in data) {
action += i + "=" + data[i] + '&';
}
action = action.substr(0, action.length - 1);
form.attr('action', action);
});
};
var latestKnownScrollY = $('html').scrollTop() || $('body').scrollTop();
$(window).on("scroll", function () {
latestKnownScrollY = $('html').scrollTop() || $('body').scrollTop();
});
$(window).on("mousewheel DOMMouseScroll", function(event) {
var scrollTo,
scrollDistance = 400,
delta;
if (event.type == 'mousewheel') {
delta = event.originalEvent.wheelDelta / 120;
} else if (event.type == 'DOMMouseScroll') {
delta = - event.originalEvent.detail / 3;
}
scrollTo = latestKnownScrollY - delta * scrollDistance;
if (scrollTo) {
event.preventDefault();
event.stopPropagation();
$('body,html').stop().animate( {
scrollTop : scrollTo
} , 500);
}
} );