Permalink
Browse files

coffeescript added

  • Loading branch information...
1 parent 588c645 commit 97e11a1e9fb263b937a13d27a38671101ea6ae32 @mathiashelin mathiashelin committed Jul 9, 2013
View
@@ -0,0 +1,2 @@
+compass: sh -c 'cd core/layout && compass watch'
+coffee: sh -c 'cd core && coffee -w -c -o js coffee'
@@ -0,0 +1,110 @@
+class Theme
+ # Class methods
+ @events: (events) ->
+ @::events ?= {}
+ @::events = $.extend({}, @::events) unless @::hasOwnProperty "events"
+ #@::events[key] = value for key, value of events
+ @::events = $.extend(true, {}, @::events, events)
+
+ @onDomReady: (initializers) ->
+ @::onDomReady ?= []
+ @::onDomReady = @::onDomReady[..] unless @::hasOwnProperty "onDomReady"
+ @::onDomReady.push initializer for initializer in initializers
+
+ constructor: ->
+ @_setupEventListeners()
+
+ domReady: ->
+ @_loadOnDomReadyMethods()
+
+ _loadOnDomReadyMethods: ->
+ for callback in @onDomReady
+ @[callback]()
+
+ _setupEventListeners: =>
+ $document = $(document)
+ for selector, actions of @events
+ for action, callback of actions
+ $document.on(action, selector, @[callback])
+
+class DefaultTheme extends Theme
+ @events
+ '#cookieBarAgree' : click : 'cookieBarAgree'
+ '#cookieBarDisagree' : click : 'cookieBarDisagree'
+ 'input:submit' : click : 'hijackSubmit'
+ 'a.backToTop': click : 'scrollToTop'
+ 'a[href*="#"]': click : 'scrollTo'
+
+ @onDomReady [
+ 'cookieBar'
+ 'removeImageHeight'
+ ]
+
+ cookieBar: ->
+ if utils.cookies.readCookie('cookie_bar_hide') == 'b%3A1%3B'
+ $('#cookieBar').remove()
+
+ cookieBarAgree: ->
+ utils.cookies.setCookie('cookie_bar_agree', 'b:1;')
+ utils.cookies.setCookie('cookie_bar_hide', 'b:1;')
+ $('#cookieBar').alert('close')
+ false
+
+ cookieBarDisagree: ->
+ utils.cookies.setCookie('cookie_bar_agree', 'b:0;')
+ utils.cookies.setCookie('cookie_bar_hide', 'b:1;')
+ $('#cookieBar').alert('close')
+ false
+
+ hijackSubmit: (e) ->
+ $(@).addClass('loading disabled')
+
+ scrollToTop: (e) ->
+ $('html, body').stop().animate(scrollTop: 0, 600)
+ false
+
+ scrollTo: (e) ->
+ $anchor = $(e.currentTarget)
+ href = $anchor.attr('href')
+ url = href.substr(0, href.indexOf('#'))
+ hash = href.substr(href.indexOf('#'))
+
+ # check if we have an url, and if it is on the current page and the element exists
+ if (url == '' or
+ url.indexOf(document.location.pathname) >= 0) and
+ not $anchor.is('[data-no-scroll]') and
+ $(hash).length > 0
+
+ $('html, body').stop().animate({
+ scrollTop: $(hash).offset().top
+ }, 600);
+ false
+
+ removeImageHeight: ->
+ $('img').css(height: 'auto')
+
+class SpecificTheme extends DefaultTheme
+ @events
+ # '#element' : event : 'functionName'
+ #'#navigation a' : click : 'showSubNav'
+
+ @onDomReady [
+ #'functionName'
+ 'initCarousel'
+ 'initFancybox'
+ ]
+
+ initCarousel: ->
+ $('.carousel').carousel()
+
+ initFancybox: ->
+ $('.fancybox').fancybox()
+ false
+
+
+SpecificTheme.current = new SpecificTheme()
+
+$ ->
+ SpecificTheme.current.domReady()
+
+window.SpecificTheme = SpecificTheme
View
@@ -0,0 +1,196 @@
+// Generated by CoffeeScript 1.6.3
+(function() {
+ var DefaultTheme, SpecificTheme, Theme, _ref, _ref1,
+ __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
+ __hasProp = {}.hasOwnProperty,
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
+
+ Theme = (function() {
+ Theme.events = function(events) {
+ var _base;
+ if ((_base = this.prototype).events == null) {
+ _base.events = {};
+ }
+ if (!this.prototype.hasOwnProperty("events")) {
+ this.prototype.events = $.extend({}, this.prototype.events);
+ }
+ return this.prototype.events = $.extend(true, {}, this.prototype.events, events);
+ };
+
+ Theme.onDomReady = function(initializers) {
+ var initializer, _base, _i, _len, _results;
+ if ((_base = this.prototype).onDomReady == null) {
+ _base.onDomReady = [];
+ }
+ if (!this.prototype.hasOwnProperty("onDomReady")) {
+ this.prototype.onDomReady = this.prototype.onDomReady.slice(0);
+ }
+ _results = [];
+ for (_i = 0, _len = initializers.length; _i < _len; _i++) {
+ initializer = initializers[_i];
+ _results.push(this.prototype.onDomReady.push(initializer));
+ }
+ return _results;
+ };
+
+ function Theme() {
+ this._setupEventListeners = __bind(this._setupEventListeners, this);
+ this._setupEventListeners();
+ }
+
+ Theme.prototype.domReady = function() {
+ return this._loadOnDomReadyMethods();
+ };
+
+ Theme.prototype._loadOnDomReadyMethods = function() {
+ var callback, _i, _len, _ref, _results;
+ _ref = this.onDomReady;
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ callback = _ref[_i];
+ _results.push(this[callback]());
+ }
+ return _results;
+ };
+
+ Theme.prototype._setupEventListeners = function() {
+ var $document, action, actions, callback, selector, _ref, _results;
+ $document = $(document);
+ _ref = this.events;
+ _results = [];
+ for (selector in _ref) {
+ actions = _ref[selector];
+ _results.push((function() {
+ var _results1;
+ _results1 = [];
+ for (action in actions) {
+ callback = actions[action];
+ _results1.push($document.on(action, selector, this[callback]));
+ }
+ return _results1;
+ }).call(this));
+ }
+ return _results;
+ };
+
+ return Theme;
+
+ })();
+
+ DefaultTheme = (function(_super) {
+ __extends(DefaultTheme, _super);
+
+ function DefaultTheme() {
+ _ref = DefaultTheme.__super__.constructor.apply(this, arguments);
+ return _ref;
+ }
+
+ DefaultTheme.events({
+ '#cookieBarAgree': {
+ click: 'cookieBarAgree'
+ },
+ '#cookieBarDisagree': {
+ click: 'cookieBarDisagree'
+ },
+ 'input:submit': {
+ click: 'hijackSubmit'
+ },
+ 'a.backToTop': {
+ click: 'scrollToTop'
+ },
+ 'a[href*="#"]': {
+ click: 'scrollTo'
+ }
+ });
+
+ DefaultTheme.onDomReady(['cookieBar', 'removeImageHeight']);
+
+ DefaultTheme.prototype.cookieBar = function() {
+ if (utils.cookies.readCookie('cookie_bar_hide') === 'b%3A1%3B') {
+ return $('#cookieBar').remove();
+ }
+ };
+
+ DefaultTheme.prototype.cookieBarAgree = function() {
+ utils.cookies.setCookie('cookie_bar_agree', 'b:1;');
+ utils.cookies.setCookie('cookie_bar_hide', 'b:1;');
+ $('#cookieBar').alert('close');
+ return false;
+ };
+
+ DefaultTheme.prototype.cookieBarDisagree = function() {
+ utils.cookies.setCookie('cookie_bar_agree', 'b:0;');
+ utils.cookies.setCookie('cookie_bar_hide', 'b:1;');
+ $('#cookieBar').alert('close');
+ return false;
+ };
+
+ DefaultTheme.prototype.hijackSubmit = function(e) {
+ return $(this).addClass('loading disabled');
+ };
+
+ DefaultTheme.prototype.scrollToTop = function(e) {
+ $('html, body').stop().animate({
+ scrollTop: 0
+ }, 600);
+ return false;
+ };
+
+ DefaultTheme.prototype.scrollTo = function(e) {
+ var $anchor, hash, href, url;
+ $anchor = $(e.currentTarget);
+ href = $anchor.attr('href');
+ url = href.substr(0, href.indexOf('#'));
+ hash = href.substr(href.indexOf('#'));
+ if ((url === '' || url.indexOf(document.location.pathname) >= 0) && !$anchor.is('[data-no-scroll]') && $(hash).length > 0) {
+ $('html, body').stop().animate({
+ scrollTop: $(hash).offset().top
+ }, 600);
+ return false;
+ }
+ };
+
+ DefaultTheme.prototype.removeImageHeight = function() {
+ return $('img').css({
+ height: 'auto'
+ });
+ };
+
+ return DefaultTheme;
+
+ })(Theme);
+
+ SpecificTheme = (function(_super) {
+ __extends(SpecificTheme, _super);
+
+ function SpecificTheme() {
+ _ref1 = SpecificTheme.__super__.constructor.apply(this, arguments);
+ return _ref1;
+ }
+
+ SpecificTheme.events;
+
+ SpecificTheme.onDomReady(['initCarousel', 'initFancybox']);
+
+ SpecificTheme.prototype.initCarousel = function() {
+ return $('.carousel').carousel();
+ };
+
+ SpecificTheme.prototype.initFancybox = function() {
+ $('.fancybox').fancybox();
+ return false;
+ };
+
+ return SpecificTheme;
+
+ })(DefaultTheme);
+
+ SpecificTheme.current = new SpecificTheme();
+
+ $(function() {
+ return SpecificTheme.current.domReady();
+ });
+
+ window.SpecificTheme = SpecificTheme;
+
+}).call(this);
@@ -1,5 +1,6 @@
# Require any additional compass plugins here.
require 'compass_twitter_bootstrap'
+require 'compass_sumo'
# Set this to the root of your project when deployed:
http_path = "/core/layout"
@@ -11,13 +12,13 @@
# You can select your preferred output style here (can be overridden via the command line):
# output_style = :expanded or :nested or :compact or :compressed
-output_style = :compressed
+# output_style = :compressed
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
# To disable debugging comments that display the original location of your selectors. Uncomment:
-line_comments = false
+# line_comments = false
# If you prefer the indented syntax, you might want to regenerate this
# project again passing --syntax sass, or you can uncomment this:
Binary file not shown.
Oops, something went wrong.

0 comments on commit 97e11a1

Please sign in to comment.