Skip to content

Instantly share code, notes, and snippets.

@rochnyak-d-i
Created October 28, 2014 05:03
Show Gist options
  • Save rochnyak-d-i/bf61a45488d16aa864fd to your computer and use it in GitHub Desktop.
Save rochnyak-d-i/bf61a45488d16aa864fd to your computer and use it in GitHub Desktop.
JS шаблон фасад
var module = (function() {
var _private = {
i: 5,
get: function() {
console.log('Текущее значение:' + this.i);
},
set: function(val) {
this.i = val;
},
run: function() {
console.log('процесс запущен');
},
jump: function() {
console.log('резкое изменение');
}
};
return {
facade: function(args) {
_private.set(args.val);
_private.get();
if (args.run) {
_private.run();
}
}
}
}());
module.facade({run:true, val:10}); // Текущее значение: 10, процесс запущен
var myevent = {
stop: function(e) {
if(typeof e.preventDefault === 'function') {
e.preventDefault();
}
if(typeof e.stopPropagation === 'function') {
e.stopPropagation();
}
if(typeof e.returnValue === 'boolean') {
e.returnValue = false;
}
if(typeof e.cancelBubble == 'boolean') {
e.cancelBubble = true;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment