Skip to content

Instantly share code, notes, and snippets.

@kucukharf
Created May 20, 2015 05:53
Show Gist options
  • Save kucukharf/1f50b121d08a6be8bf24 to your computer and use it in GitHub Desktop.
Save kucukharf/1f50b121d08a6be8bf24 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/nohexisike
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
// teb.events.js
teb.events = {
RESIZE: 'app.window.resize'
}
// teb.ui.button.js
var Button = {
title: 'Untitled',
click: function(){
$container.isotope({
// filter element with numbers greater than 50
filter: function() {
// _this_ is the item element. Get text of element's .number
var number = $(this).find('.number').text();
// return true to show, false to hide
return parseInt( number, 10 ) > 50;
}
})
},
hover: function(){
$container.isotope({
// filter element with numbers greater than 50
filter: function() {
// _this_ is the item element. Get text of element's .number
var number = $(this).find('.number').text();
// return true to show, false to hide
return parseInt( number, 10 ) > 50;
}
})
}
};
var FakeButton = {
click: function(){
console.log(this.title + ' clicked!');
},
hover: function(){
console.log(this.title + ' hovered!');
}
};
// teb.page.home.js
var teb.page.Home = (function(){
function HomePage(btn) {
this.button = btn;
}
HomePage.prototype.init: function(){
this.initButtons();
this.attachListeners();
};
HomePage.prototype.attachListeners = function(){
$(document).on(teb.events.RESIZE, onWindowResize);
};
HomePage.prototype.onWindowResize = function(){
this.refresh();
};
HomePage.prototype.initButtons = function(){
var subscribeButton = Object.create(this.button);
subscribe.click();
subscribe.hover();
};
HomePage.prototype.refresh = function(){
// refresh logic
};
return HomePage;
})();
// teb.app.js
$(function(){
$.getScript('js/lib/goog.maps.js', function(){
var homePage = new teb.page.Home(FakeButton);
homePage.init();
});
})
$(window).on('resize', function(){
$(document).trigger(teb.events.RESIZE); // custom event
});
</script>
<script id="jsbin-source-javascript" type="text/javascript">// teb.events.js
teb.events = {
RESIZE: 'app.window.resize'
}
// teb.ui.button.js
var Button = {
title: 'Untitled',
click: function(){
$container.isotope({
// filter element with numbers greater than 50
filter: function() {
// _this_ is the item element. Get text of element's .number
var number = $(this).find('.number').text();
// return true to show, false to hide
return parseInt( number, 10 ) > 50;
}
})
},
hover: function(){
$container.isotope({
// filter element with numbers greater than 50
filter: function() {
// _this_ is the item element. Get text of element's .number
var number = $(this).find('.number').text();
// return true to show, false to hide
return parseInt( number, 10 ) > 50;
}
})
}
};
var FakeButton = {
click: function(){
console.log(this.title + ' clicked!');
},
hover: function(){
console.log(this.title + ' hovered!');
}
};
// teb.page.home.js
var teb.page.Home = (function(){
function HomePage(btn) {
this.button = btn;
}
HomePage.prototype.init: function(){
this.initButtons();
this.attachListeners();
};
HomePage.prototype.attachListeners = function(){
$(document).on(teb.events.RESIZE, onWindowResize);
};
HomePage.prototype.onWindowResize = function(){
this.refresh();
};
HomePage.prototype.initButtons = function(){
var subscribeButton = Object.create(this.button);
subscribe.click();
subscribe.hover();
};
HomePage.prototype.refresh = function(){
// refresh logic
};
return HomePage;
})();
// teb.app.js
$(function(){
$.getScript('js/lib/goog.maps.js', function(){
var homePage = new teb.page.Home(FakeButton);
homePage.init();
});
})
$(window).on('resize', function(){
$(document).trigger(teb.events.RESIZE); // custom event
});
</script></body>
</html>
// teb.events.js
teb.events = {
RESIZE: 'app.window.resize'
}
// teb.ui.button.js
var Button = {
title: 'Untitled',
click: function(){
$container.isotope({
// filter element with numbers greater than 50
filter: function() {
// _this_ is the item element. Get text of element's .number
var number = $(this).find('.number').text();
// return true to show, false to hide
return parseInt( number, 10 ) > 50;
}
})
},
hover: function(){
$container.isotope({
// filter element with numbers greater than 50
filter: function() {
// _this_ is the item element. Get text of element's .number
var number = $(this).find('.number').text();
// return true to show, false to hide
return parseInt( number, 10 ) > 50;
}
})
}
};
var FakeButton = {
click: function(){
console.log(this.title + ' clicked!');
},
hover: function(){
console.log(this.title + ' hovered!');
}
};
// teb.page.home.js
var teb.page.Home = (function(){
function HomePage(btn) {
this.button = btn;
}
HomePage.prototype.init: function(){
this.initButtons();
this.attachListeners();
};
HomePage.prototype.attachListeners = function(){
$(document).on(teb.events.RESIZE, onWindowResize);
};
HomePage.prototype.onWindowResize = function(){
this.refresh();
};
HomePage.prototype.initButtons = function(){
var subscribeButton = Object.create(this.button);
subscribe.click();
subscribe.hover();
};
HomePage.prototype.refresh = function(){
// refresh logic
};
return HomePage;
})();
// teb.app.js
$(function(){
$.getScript('js/lib/goog.maps.js', function(){
var homePage = new teb.page.Home(FakeButton);
homePage.init();
});
})
$(window).on('resize', function(){
$(document).trigger(teb.events.RESIZE); // custom event
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment