Skip to content

Instantly share code, notes, and snippets.

@ChuckJHardy
Created May 10, 2013 11:52
Show Gist options
  • Select an option

  • Save ChuckJHardy/5553946 to your computer and use it in GitHub Desktop.

Select an option

Save ChuckJHardy/5553946 to your computer and use it in GitHub Desktop.
Javascript Prototype Template
var HotelDescription = (function ($) {
"use strict";
var HotelDescription = function ($element) {
this.$long = $('.long-description', $element);
this.$short = $('.short-description', $element);
this.$more = $('.read-more', $element);
this.$less = $('.read-less', $element);
this.bind();
};
HotelDescription.init = function($element) {
new HotelDescription($element);
};
HotelDescription.prototype = {
bind: function() {
var self = this;
this.$more.on('click', function(e) {
self.showLong();
e.preventDefault();
});
this.$less.on('click', function(e) {
self.showShort();
e.preventDefault();
});
},
showLong: function() {
this.$short.hide();
this.$long.show();
},
showShort: function() {
this.$long.hide();
this.$short.show();
}
};
return HotelDescription;
}(jQuery));
$(document).ready(function () {
HotelDescription.init($("div.hotel-details .hotel-description"));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment