(function() { 'use strict'; var $html, Album, Carousel, Feed, FeedBrowser, FeedBrowserItem, Feeds, Modal, Photo, h264, html, ogg, ua, v, webm, __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; }; v = document.createElement('video'); h264 = webm = ogg = false; if (v.canPlayType) { h264 = '' !== (v.canPlayType('video/mp4; codecs="avc1.42E01E"') || v.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"')); ogg = '' !== v.canPlayType('video/ogg; codecs="theora"'); webm = '' !== v.canPlayType('video/webm; codecs="vp8, vorbis"'); } ua = navigator.userAgent; html = document.getElementsByTagName('html')[0]; html.className += ' js'; if (h264 && !/(iPhone|Android|iPod|iPad)/.test(ua)) { html.className += ' video'; } if (/(iPod|iPhone|Android)/.test(ua)) { html.className += ' mobile'; } if (/iPad/.test(ua)) { html.className += ' ipad'; } if (/(iPhone|iPod)/.test(ua)) { html.className += ' iphone'; } if (/Chrome/.test(ua)) { html.className += ' chrome'; } if (!/Chrome/.test(ua) && /Safari/.test(ua)) { html.className += ' safari'; } html.className += ' rld-loadstart'; Modal = (function(_super) { __extends(Modal, _super); function Modal() { return Modal.__super__.constructor.apply(this, arguments); } Modal.prototype.$window = jQuery(window); Modal.prototype.touch = false; Modal.prototype.disabled = false; Modal.prototype.scrollTop = 0; Modal.prototype.transition = { end: 'webkitTransitionEnd MozTransitionEnd mozTransitionEnd msTransitionEnd oTransitionEnd transitionEnd transitionend' }; Modal.prototype.events = { 'click [data-dismiss="modal"]': 'close', 'click': '_close' }; Modal.prototype.initialize = function(options) { if (options == null) { options = {}; } if (this.disabled) { return; } this.external = Boolean(this.$el.data('external')); this.loader = null; this.href = null; this.$body = jQuery('body'); this.$backdrop = this.$body.find('.modal-backdrop'); this.$content = this.$el.find('.modal-content'); return this.$body.on('click.' + this.cid, '[data-toggle="modal"][data-target="' + this.$el.attr('id') + '"]', (function(_this) { return function(event) { return _this.modal(event); }; })(this)); }; /* Clear modal */ Modal.prototype.clear = function(backdrop) { var tid; if (backdrop == null) { backdrop = true; } this.$el.removeClass('in'); if (backdrop && !this.$body.find('.moda.in').size()) { this.$backdrop.removeClass('in'); } tid = setTimeout((function(_this) { return function() { return _this.$el.trigger('transitionEnd'); }; })(this), 1000); return this.$el.unbind(this.transition.end).one(this.transition.end, (function(_this) { return function() { if (_this.$loader != null) { _this.$loader.abort(); _this.$loader = null; _this.$content.empty(); } clearTimeout(tid); _this.$el.unbind(_this.transition.end); return _this.trigger('clear'); }; })(this)); }; /* Close modal */ Modal.prototype._close = function(event) { if ((event == null) || event.target !== this.el) { return; } if (this.$el.data('href') != null) { return this.$el.find('a[href="' + this.$el.data('href') + '"]:first').trigger('click'); } else { if ((event != null) && event.target === this.el) { return this.close(event); } } }; /* Close modal */ Modal.prototype.close = function(event) { var one; if (this.disabled) { return; } one = 1 === this.$body.find('.modal.in').size(); if (this.touch && one) { this.$body.removeClass('modal-fixed'); this.$window.scrollTop(this.scrollTop); } this.listenToOnce(this, 'clear', (function(_this) { return function() { _this.$el.removeClass('active'); if (one) { _this.$body.css('padding-right', ''); _this.$body.removeClass('modal-open'); } return _this.trigger('close', event); }; })(this)); this.clear(one); return this; }; /* Open modal */ Modal.prototype.modal = function(event) { var $target; if (this.disabled) { return; } this.scrollbarWidth = Modal.measureScrollbar(); if (this.$el.hasClass('in')) { this.clear(false); this.listenToOnce(this, 'clear', (function(_this) { return function() { return _this.modal(event); }; })(this)); return false; } if (event && this.external) { $target = jQuery(event.currentTarget); this.href = $target.attr('href'); } this.$body.addClass('modal-open'); this.$body.css('padding-right', this.scrollbarWidth); this.$el.addClass('active'); _.defer((function(_this) { return function() { return _this.$backdrop.addClass('in'); }; })(this)); if (this.href != null) { this.$loader = jQuery.ajax({ type: 'GET', url: this.href, dataType: 'html' }); this.$loader.done((function(_this) { return function() { return _this.build(event); }; })(this)); return false; } _.defer((function(_this) { return function() { return _this.build(event); }; })(this)); return false; }; /* Build modal */ Modal.prototype.build = function(event) { var $content, selector, tid; if (this.$loader) { selector = this.href.match(/(#.*)$/); selector = selector && selector[1] || '.modal-content'; $content = jQuery('
').append(jQuery.parseHTML(this.$loader.responseText)).find(selector); this.$content.before($content); this.$content.remove(); this.$content = $content; } tid = setTimeout((function(_this) { return function() { return _this.$el.trigger('transitionEnd'); }; })(this), 2000); this.$el.unbind(this.transition.end).one(this.transition.end, (function(_this) { return function() { _this.$el.unbind(_this.transition.end); _this.scrollTop = _this.$window.scrollTop(); if (_this.touch) { _this.$window.scrollTop(0); return _.defer(function() { _this.$body.addClass('modal-fixed'); return _this.$body.css('top', -_this.scrollTop); }); } }; })(this)); this.$el.scrollTop(0); this.$el.addClass('in'); return this.trigger('modal', event); }; /* Bootstrap measure scrollbar */ Modal.measureScrollbar = function() { var $body, scrollDiv, scrollbarWidth; $body = jQuery('body'); scrollDiv = document.createElement('div'); scrollDiv.className = 'modal-scrollbar-measure'; $body.append(scrollDiv); scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; $body[0].removeChild(scrollDiv); return scrollbarWidth; }; return Modal; })(Backbone.View); if (typeof jQuery === "function") { jQuery(function($) { if ($ == null) { $ = jQuery; } return $('.modal').each(function() { return $(this).data('modal', new Modal({ el: this })); }); }); } /* Carousel */ Carousel = (function(_super) { __extends(Carousel, _super); function Carousel() { return Carousel.__super__.constructor.apply(this, arguments); } Carousel.prototype.interval = 4000; Carousel.prototype.autoplay = false; Carousel.prototype.transition = { end: 'webkitTransitionEnd MozTransitionEnd mozTransitionEnd msTransitionEnd oTransitionEnd transitionEnd transitionend' }; Carousel.prototype.selector = { container: '.carousel-container', slider: '.carousel-slider', indicators: '.carousel-indicators', slides: '.carousel-item', control: '.carousel-control' }; Carousel.prototype.events = { 'touchstart .carousel-container': 'touchstart', 'touchmove .carousel-container': 'touchmove', 'touchend .carousel-container': 'touchend' }; Carousel.prototype._posx = null; Carousel.prototype._tmpx = null; Carousel.prototype._posy = null; Carousel.prototype._multitouch = false; Carousel.prototype.$window = jQuery(window); Carousel.prototype.initialize = function(options) { if (options == null) { options = {}; } Carousel.__super__.initialize.call(this, options); this.autoplay = (this.$el.data('autoplay') != null) && true || false; this.interval = (this.$el.data('interval') != null) && this.$el.data('interval') || this.interval; this.cursor = this.$el.data('cursor') || 0; this.enableskip = (this.$el.data('enable-skip') != null) && true || false; this.autoplay = (options.autoplay != null) && options.autoplay || this.autoplay; this.selector = (options.selector != null) && options.selector || this.selector; this.cursor = (options.cursor != null) && options.cursor || this.cursor; this.enableskip = (options.enableskip != null) && options.enableskip || this.enableskip; this.retrieve(); this.events['click [data-slide="prev"]'] = 'previous'; this.events['click [data-slide="next"]'] = 'next'; this.events['click ' + this.selector.indicators + '>*'] = 'carousel'; this.iid = null; this.tid = null; this.render(); this.slide(this.cursor); return this.autoplay && this.play(); }; /* Remove Self */ Carousel.prototype.remove = function() { Carousel.__super__.remove.apply(this, arguments); return this.$window.unbind('resize.' + this.cid); }; /* Touchstart Handler */ Carousel.prototype.touchstart = function(event) { if (this.$el.hasClass('carousel-transition')) { return; } this._gesture = false; clearInterval(this.iid); event = event.originalEvent; this._posx = event.touches[0].screenX; return this._posy = event.touches[0].screenY; }; /* Touchmove Handler */ Carousel.prototype.touchmove = function(event) { var dist, _y; if (this.multitouch || (this._posx == null) || this.$el.hasClass('carousel-transition')) { return; } event = event.originalEvent; if (event.touches.length > 1) { return this._multitouch = true; } this._tmpx = event.touches[0].screenX; _y = event.touches[0].screenY; if (5 < Math.abs(this._posy - _y)) { return; } event.preventDefault(); dist = this._tmpx - this._posx; this.$slider.css('transform', 'translateX(' + dist + 'px)'); return this._posy = _y; }; /* Touch controls */ Carousel.prototype.touchend = function(event) { var dist; if ((this._posx == null) || (this._tmpx == null) || this._multitouch || this.$el.hasClass('carousel-transition')) { return; } dist = this._tmpx - this._posx; if (50 > Math.abs(dist)) { this.$slider.css('transform', 'none'); this.autoplay && this.play(); return; } if (0 > dist) { this.next(); } else { this.previous(); } this._posx = this._posy = this._tmpx = null; return false; }; /* Slide to specified page */ Carousel.prototype.carousel = function(event) { var $indicator, page; page = 0; if ((event != null ? event.currentTarget : void 0) != null) { $indicator = jQuery(event.currentTarget); page = $indicator.index(); } else if (!isNaN(event)) { page = event; } else { return; } if (page === this.cursor) { return; } return this.slide(page); }; /* Next panel */ Carousel.prototype.next = function(page) { if (isNaN(page)) { page = this.cursor + 1; } if (page === this.cursor) { return; } if (page >= this.$slides.size()) { page = 0; } return this.slide(page); }; /* Previous panel */ Carousel.prototype.previous = function(page) { if (isNaN(page)) { page = this.cursor - 1; } if (page === this.cursor) { return; } if (page < 0) { page = this.$slides.size() - 1; } return this.slide(page); }; /* Slide panels */ Carousel.prototype.slide = function(page) { var $current, $next, distance; if (this.$el.hasClass('carousel-transition')) { return; } clearInterval(this.iid); $current = this.$slides.filter(':eq(' + this.cursor + ')'); $next = this.$slides.filter(':eq(' + page + ')'); if (page === this.cursor) { $next.addClass('carousel-item-current').removeClass('carousel-item-next'); return this; } distance = +$next.css('left').replace('px', ''); if (this.enableskip && 1 !== Math.abs(this.cursor - page) && this.$slides.size() - 1 !== Math.abs(this.cursor - page)) { distance = $current.outerWidth(true); page < this.cursor && (distance *= -1); this.$el.addClass('carousel-transition-skip'); } this.$slider.bind(this.transition.end, (function(_this) { return function(event) { if (event.target !== _this.$slider.get(0)) { return; } clearTimeout(_this.tid); _this.$slider.unbind(_this.transition.end); _this.$el.removeClass('carousel-transition'); return _.defer(function() { _this.$el.removeClass('carousel-transition-next carousel-transition-previous carousel-transition-skip'); $current.removeClass('carousel-item-previous'); $next.addClass('carousel-item-current').removeClass('carousel-item-next'); _this.$slider.css('transform', 'none'); _this.resize(); _this.autoplay && _this.play(); return _this.trigger('carousel-slid'); }); }; })(this)); this.$slides.removeClass('carousel-item-current'); $current.addClass('carousel-item-previous'); $next.addClass('carousel-item-next'); page > this.cursor && this.$el.addClass('carousel-transition-next'); page < this.cursor && this.$el.addClass('carousel-transition-previous'); this.$el.addClass('carousel-transition'); _.defer((function(_this) { return function() { return _this.$slider.css('transform', 'translateX(' + -distance + 'px)'); }; })(this)); this.tid = setTimeout((function(_this) { return function() { return _this.$slider.trigger('transitionend'); }; })(this), 3000); this.cursor = page; this.update(); this.trigger('carousel-slide'); return this; }; /* Auto play */ Carousel.prototype.play = function() { clearInterval(this.iid); return this.iid = setInterval((function(_this) { return function() { return _this.next(); }; })(this), this.interval); }; /* Update indicators */ Carousel.prototype.update = function() { return jQuery(this.$indicators).each((function(_this) { return function(i, item) { var $item; $item = jQuery(item); return $item.children().removeClass('carousel-current').filter(':eq(' + _this.cursor + ')').addClass('carousel-current'); }; })(this)); }; /* Resize Handler */ Carousel.prototype.resize = function() { var l, left, slides, _i, _ref, _results; l = this.cursor + Math.ceil(this.$slides.size() / 2); if (l >= this.$slides.size()) { l -= this.$slides.size(); } slides = this.$slides.get().slice(l); slides = slides.concat(this.$slides.get().slice(0, l)); left = _.reduce((function() { _results = []; for (var _i = 0, _ref = ~~(slides.length / 2) - 1; 0 <= _ref ? _i <= _ref : _i >= _ref; 0 <= _ref ? _i++ : _i--){ _results.push(_i); } return _results; }).apply(this), function(memo, i) { return memo - jQuery(slides[i]).outerWidth(true); }, 0); return _.each(slides, (function(_this) { return function(item) { var $item, ow; $item = jQuery(item); ow = $item.outerWidth(true); $item.css('left', left + 'px'); return left += ow; }; })(this)); }; /* Render carousel */ Carousel.prototype.render = function() { this.$el.addClass('carousel-render'); this.retrieve(); this.$window.unbind('resize.' + this.cid).bind('resize.' + this.cid, (function(_this) { return function() { return _this.resize(); }; })(this)); this.resize(); this.update(); return Carousel.__super__.render.apply(this, arguments); }; /* Retrieve dom elements */ Carousel.prototype.retrieve = function() { this.$container = this.$el.find(this.selector.container); this.$slider = this.$el.find(this.selector.slider); this.$indicators = this.$el.find(this.selector.indicators); return this.$slides = this.$container.find(this.selector.slides); }; return Carousel; })(Backbone.View); if (typeof jQuery === "function") { jQuery(function($) { if ($ == null) { $ = jQuery; } return $('.carousel').each(function() { var carousel; carousel = new Carousel({ el: this }); return $(this).data('tc-carousel', carousel); }); }); } /* SNS BG jQuery? ($=jQuery) -> $window = $ window $sns = $ '#social-web' $bg = $sns.find '.social-web-background' ww = 0 wh = 0 st = 0 sh = 0 ratio = 1600/1600 # Ratio of the background image _scroll = -> top = $window.scrollTop() bh = $bg.outerHeight() d = sh - wh p = top - st per = p/d per = 0 if per < 0 per = 1 if per > 1 $bg.css 'height', '' $bg.css 'transform', 'translate3d(0,' + (sh-bh)*per + 'px, 0)' $bg.removeClass 'social-web-background-full' _resize = -> ww = $window.width() wh = $window.height() st = $sns.offset().top sh = $sns.outerHeight() if ww/wh > ratio $window.bind 'scroll.sns-web', _scroll $bg.removeClass 'social-web-background-full' _scroll() else $window.unbind 'scroll.sns-web' $bg.addClass 'social-web-background-full' $bg.css 'height', wh + 'px' $bg.css 'transform', '' $window.bind 'scroll', -> top = $window.scrollTop() if top <= st $bg.removeClass 'social-web-background-fixed' else $bg.addClass 'social-web-background-fixed' $bg.find('img').load -> $window.bind 'resize.sns-web', _resize _resize() */ /* Photo */ Photo = (function(_super) { __extends(Photo, _super); function Photo() { return Photo.__super__.constructor.apply(this, arguments); } Photo.prototype.defaults = { id: '', images: [], link: '', name: '', created_time: '', updated_time: '', width: 0, height: 0, likes: { summary: { total_count: 0, can_like: true, has_liked: false } } }; return Photo; })(Backbone.Model); /* Album */ Album = (function(_super) { __extends(Album, _super); function Album() { return Album.__super__.constructor.apply(this, arguments); } Album.prototype.model = Photo; Album.prototype.created_time = ''; Album.prototype.parse = function(response) { var limit, parseDate, photos; photos = response.data || []; parseDate = function(str) { var date, time; str = str.split('T'); date = str[0].split('-'); time = str[1].split(':'); return new Date(date[0] + '/' + parseInt(date[1]) + '/' + parseInt(date[2]) + ' ' + time[0] + ':' + time[1] + ':' + time[2].replace('+', ' +')); }; limit = parseDate(this.created_time).getTime() + 60 * 1000; photos = _.filter(photos, function(photo) { var _t; _t = parseDate(photo.created_time).getTime(); return _t <= limit && _t >= limit - .9 * 3600 * 1000; }); photos.sort(function(a, b) { var d; d = parseDate(a.updated_time).getTime() - parseDate(b.updated_time).getTime(); if (d === 0) { return 0; } else { return d / Math.abs(d); } }); return photos; }; return Album; })(Backbone.Collection); /* Feed */ Feed = (function(_super) { __extends(Feed, _super); function Feed() { return Feed.__super__.constructor.apply(this, arguments); } Feed.prototype.defaults = { hash: '', id: '', message: '', link: '', icon: '', type: '', youtube: false, photo_detail: { width: 0, height: 0, images: [] }, status_type: '', created_time: '', updated_time: '', album_id: '', album: null, fb_page: '', path: '', feed_targeting: { locales: [] }, likes: { summary: { total_count: 0, can_like: true, has_liked: false } } }; Feed.prototype.album = function() { var defer, _album; defer = jQuery.Deferred(); _album = new Album; _album.created_time = this.get('created_time'); _album.url = this.get('path') + 'fb_album_' + this.get('fb_page') + '_' + this.get('album_id') + '.json'; _album.fetch({ success: function() { return defer.resolve(); }, error: function() { return defer.resolve(); } }); this.set('album', _album); return defer.promise(); }; return Feed; })(Backbone.Model); /* Feeds */ Feeds = (function(_super) { __extends(Feeds, _super); function Feeds() { return Feeds.__super__.constructor.apply(this, arguments); } Feeds.prototype.model = Feed; Feeds.prototype.api = ''; Feeds.prototype.path = ''; Feeds.prototype.fb_page = ''; Feeds.prototype.cursor = 0; Feeds.prototype.filters = []; Feeds.prototype.defer = null; Feeds.prototype.youtube = []; Feeds.prototype.initialize = function(model, options) { if (options == null) { options = {}; } this.path = options.path || ''; this.api = options.api || ''; if ((options.filter != null) && options.filter !== '') { this.filters = options.filter.split(','); } this.youtube = options.youtube || []; this.fb_page = this.api.split('_')[2].replace('.json', ''); return this.url = this.path + this.api; }; Feeds.prototype.parse = function(response) { var a, full, _strToDate; if (response.next == null) { response.next = ''; } this.url = this.path + response.next; response = _.filter(response.data, (function(_this) { return function(feed) { var filter, result, _filters, _i, _len; feed.fb_page = _this.fb_page; feed.path = _this.path.replace(/^\//, 'http://'); if (!feed.message || feed.message === '') { return false; } _filters = []; if ((feed.feed_targeting != null) && (feed.feed_targeting.locales != null)) { _filters = feed.feed_targeting.locales; } if (!_filters.length && !_this.filters.length) { return true; } result = false; for (_i = 0, _len = _filters.length; _i < _len; _i++) { filter = _filters[_i]; if (-1 !== _.indexOf(_this.filters, filter.toString())) { result = true; break; } } return result; }; })(this)); a = []; _strToDate = function(str) { var array, date, time; array = str.split('T'); date = array[0].split('-'); time = array[1].split(':'); return new Date(date[0] + '/' + date[1] + '/' + date[2] + ' ' + time[0] + ':' + time[1] + ':' + time[2].substr(0, 2)); }; full = this.url === this.path && true || false; while (response.length) { if (!this.youtube.length || _strToDate(response[0].created_time).getTime() > _strToDate(this.youtube[0].created_time).getTime()) { a.push(response.shift()); } else { a.push(this.youtube.shift()); } } if (full) { a = a.concat(this.youtube); } return a; }; Feeds.prototype.retrieve = function(limit) { var _ref, _ref1, _ref2; if (limit == null) { limit = 20; } this.cursor += limit; if (this.url === this.path) { if ((_ref = this.defer) != null) { _ref.resolve(); } return this.defer = null; } if (this.length < this.cursor) { if (!this.defer) { this.defer = jQuery.Deferred(); this.once('sync', (function(_this) { return function() { return _this.retrieve(0); }; })(this)); this.fetch({ remove: false }); } } else { if ((_ref1 = this.defer) != null) { _ref1.resolve(); } this.defer = null; return; } return (_ref2 = this.defer) != null ? _ref2.promise() : void 0; }; return Feeds; })(Backbone.Collection); /* Feed Browser Item */ FeedBrowserItem = (function(_super) { __extends(FeedBrowserItem, _super); function FeedBrowserItem() { return FeedBrowserItem.__super__.constructor.apply(this, arguments); } FeedBrowserItem.prototype.tagName = 'li'; FeedBrowserItem.prototype.excludes = []; FeedBrowserItem.prototype.model = new Feed; FeedBrowserItem.prototype.compact = false; FeedBrowserItem.prototype._template = _.template(''); FeedBrowserItem.prototype._klass = ''; FeedBrowserItem.prototype._data = {}; FeedBrowserItem.template = function($dom) { FeedBrowserItem.prototype._template = _.template($dom.html()); FeedBrowserItem.prototype._klass = $dom.attr('class'); return FeedBrowserItem.prototype._data = $dom.data(); }; FeedBrowserItem.prototype.initialize = function(options) { if (options == null) { options = {}; } return this.compact = options.compact || this.compact; }; FeedBrowserItem.prototype.col = function() { var $textarea, c, limit, message, text, _ok, _stack, _text; $textarea = jQuery(this.$el.find('.sns-post-text')); text = this.model.get('message'); text = text.replace(new RegExp('#' + this.model.get('hash') + '[ \n]?'), ''); limit = 120; _ok = ''; _text = text.substr(0, ~~(text.length / 2)); _stack = text.substr(~~(text.length / 2), text.length); c = 0; while (c < 10 && _text !== '') { $textarea.html((_ok + _text + '...').replace(/\n/g, '
')); if ($textarea.height() > limit) { _stack = _text.substr(~~(_text.length / 2), _text.length); _text = _text.substr(0, ~~(_text.length / 2)); } else { _ok += _text; if (_stack.length === 1) { _text = _stack; _stack = ''; } else { _text = _stack.substr(0, ~~(_stack.length / 2)); _stack = _stack.substr(~~(_stack.length / 2), _stack.length); } } c++; } message = _ok + _text; if (message !== text) { message = message.substr(0, message.length - 2) + '...'; } message = message.replace(/(https?:\/\/[^ \n]*)/g, '$1'); message = message.replace(/(www.roland.co[^ \n]*)/g, '$1'); message = message.replace(/\n/g, '
'); return $textarea.html(message); }; FeedBrowserItem.prototype.render = function(defer) { var json; if (defer == null) { defer = jQuery.Deferred(); } if ('added_photos' === this.model.get('status_type') && this.model.get('album') === null && '' !== this.model.get('album_id') && -1 === _.indexOf(this.excludes, this.model.get('album_id'))) { this.model.album().done((function(_this) { return function() { return _this.render(defer); }; })(this)); return defer.promise(); } this.$el.addClass(this._klass); _.each(this._data, (function(_this) { return function(val, key) { return _this.$el.attr('data-' + key, val); }; })(this)); json = this.model.toJSON(); json.message = json.message.replace(/(https?:\/\/[^ \n]*)/g, '$1'); json.message = json.message.replace(/(www.roland.co[^ \n]*)/g, '$1'); json.message = json.message.replace(/\n/g, '
'); json.message = json.message.replace(new RegExp('#' + this.model.get('hash') + '[ \n]?'), ''); this.$el.html(this._template(json)); if (this.model.get('youtube')) { this.$el.addClass('sns-item-youtube'); } jQuery.when.apply(jQuery, _.map(this.$el.find('img'), function(img) { var $img, iid, _defer; _defer = jQuery.Deferred(); $img = jQuery(img); if (img.readyState != null) { iid = setInterval(function() { if (img.readyState === 'complete') { clearInterval(iid); return $img.trigger('resolve'); } }, 100); } else { $img.bind('load error', function() { return $img.trigger('resolve'); }); } $img.bind('resolve', function() { var $p, $this; $this = jQuery(this); $p = $this.parent(); if ($p.width() > $this.width()) { $this.css('width', '100%').css('height', 'auto'); } if ($p.height() > $this.height()) { $this.css('height', '100%').css('width', 'auto'); } return _defer.resolve(); }); return _defer.promise(); })).done(function() { return defer.resolve(); }); return defer.promise(); }; return FeedBrowserItem; })(Backbone.View); /* Feed Browser */ FeedBrowser = (function(_super) { __extends(FeedBrowser, _super); function FeedBrowser() { return FeedBrowser.__super__.constructor.apply(this, arguments); } FeedBrowser.prototype.$window = jQuery(window); FeedBrowser.prototype.items = []; FeedBrowser.prototype.limit = 20; FeedBrowser.prototype.autoload = false; FeedBrowser.prototype.compact = false; FeedBrowser.prototype._loading = false; FeedBrowser.prototype._sid = null; FeedBrowser.prototype.initialize = function(options) { if (options == null) { options = {}; } this.limit = options.limit || this.limit; this.autoload = options.autoload || this.autoload; this.compact = options.compact || this.compact; this.items = options.items || []; this.more(); if (this.autoload) { return this.model.once('sync', (function(_this) { return function() { return _this.$window.bind('scroll.feedbrowser', function() { if (!_this._loading && _this.$el.offset().top + _this.$el.height() <= _this.$window.scrollTop() + _this.$window.height() + 100 && !_this.model.defer) { return _this.more(); } }); }; })(this)); } /* if @compact jQuery(window).bind 'resize.' + @cid, => clearTimeout @_sid if @_sid @_sid = setTimeout => _.each @items, (item) -> item.col() @trigger 'relayout' , 1000 */ }; /* Render */ FeedBrowser.prototype.render = function() { if (this.compact) { _.each(this.items, function(item) { return item.col(); }); } return _.defer((function(_this) { return function() { return _this.trigger('relayout'); }; })(this)); }; FeedBrowser.prototype.more = function() { var cursor; cursor = this.model.cursor; this._loading = true; this.trigger('more'); return jQuery.when.apply($, [this.model.retrieve(this.limit)]).done((function(_this) { return function() { return jQuery.when.apply(jQuery, _.map(_this.model.slice(cursor, cursor + _this.limit), function(feed) { var item; item = new FeedBrowserItem({ model: feed, compact: _this.compact }); _this.$el.append(item.$el); item.render(); return _this.items.push(item); })).done(function() { _this.trigger('render'); return _.delay(function() { return _this._loading = false; }, 500); }); }; })(this)); }; return FeedBrowser; })(Backbone.View); /* Connect */ if (typeof jQuery === "function") { jQuery(function($) { var $html, $modal, $modal_timeline, $timeline, $window, cram, _ref, _ref1; if ($ == null) { $ = jQuery; } $window = $(window); $html = $(html); $timeline = $('.social-web .content-social-timeline'); $modal_timeline = $('.social-web .modal-social-timeline'); if (!$timeline.size()) { return; } $timeline.addClass('hidden'); $modal_timeline.addClass('hidden'); $modal = $('#modal-timeline'); FeedBrowserItem.template($('#feedbrowseritem-template')); _.each([$timeline, $modal_timeline], function($container) { var api, autoload, compact, excludes, filter, hash, limit, path, tid, yt; tid = null; api = $container.data('api'); hash = 'FP90'; limit = $container.data('limit'); filter = $container.data('filter').toString() || ''; autoload = $container.data('autoload') || false; compact = $container.data('compact') || false; excludes = ''; if ($container === $modal_timeline) { autoload = true; } if (!$container.size() || (!api || api === '')) { return; } if (($container.data('hash') != null) && '' !== $container.data('hash')) { hash = $container.data('hash'); } path = 'https://cdn.roland.com/promos/fp-90/connect/sns/'; if ((hash != null) && hash !== '') { path += hash + '/'; } FeedBrowserItem.prototype.excludes = excludes.split(','); yt = []; return $.ajax({ url: path + 'youtube_feeds_UC4vbiZMU_yrheYVZH393-Zw.json', dataType: 'json' }).done(function(json) { return _.each(json.data, function(j) { var y; y = {}; y.created_time = j.snippet.publishedAt; y.id = j.id; y.message = j.snippet.title; y.fb_page = j.snippet.channelTitle; y.link = 'https://www.youtube.com/watch?v=' + j.id; y.youtube = true; y.video_detail = { thumbnails: { data: [ { is_preferred: true, uri: (j.snippet.thumbnails.maxres != null) && j.snippet.thumbnails.maxres.url || (j.snippet.thumbnails.standard != null) && j.snippet.thumbnails.standard.url || (j.snippet.thumbnails.medium != null) && j.snippet.thumbnails.medium.url } ] } }; return yt.push(y); }); }).always(function() { var browser, feeds; Feed.prototype.defaults.hash = hash; feeds = new Feeds([], { filter: filter, path: path, api: api, youtube: yt }); browser = new FeedBrowser({ el: $container.empty().get(0), model: feeds, limit: limit, autoload: autoload, compact: compact }); browser.on('more', function() { return $html.addClass('timeline-load-progress'); }); browser.on('render', function() { $window.trigger('resize.in-view'); return $window.trigger('resize.timeline'); }); browser.on('relayout', function() { return _.delay(function() { return $container.cram.update(); }, 100); }); if ($container === $modal_timeline) { $modal.find('.cta').bind('click', function() { browser.once('render', function() { if (browser.model.length <= browser.model.cursor) { return $modal.addClass('timeline-full'); } }); return browser.more(); }); } return $container.data('browser', browser); }); }); cram = function($container) { $container.unbind('cram.update').bind('cram.update', function() { setTimeout(function() { $container.removeClass('hidden'); $window.trigger('resize.in-view'); return $window.trigger('resize.sns-web'); }, 300); if ($container.hasClass('hidden')) { return $container.children().removeClass('in-view'); } }); if ($container.width() !== 0 && $container.width() < 768) { $container.removeClass('hidden'); $window.unbind('resize.timeline').bind('resize.timeline', function() { var _ref; return (_ref = $container.data('browser')) != null ? _ref.render() : void 0; }); return; } $container.cram({ cellWidth: 376, itemSelector: ".sns-item", marginWidth: 26, marginHeight: 26, isAutoLayout: true, isWindowResizeUpdate: false }, 1180); return $window.unbind('resize.timeline').bind('resize.timeline', function() { var tid; if (tid) { clearTimeout(tid); } return tid = setTimeout(function() { var w; w = ~~(($container.parent().width() - 26 * 2) / 3); $container.children().width(w); $container.cram.setOptions({ cellWidth: w }); return $container.data('browser').render(); }, 0); }); }; $('a[href*="/features/"]').click(function() { return _.delay(function() { return $window.trigger('resize.timeline'); }, 1000); }); if ((_ref = $modal.data('modal')) != null) { _ref.on('modal', function() { var _t; cram($modal_timeline); $window.trigger('resize.timeline'); _t = $modal.offset().top; return $modal.find('.modal-content').unbind('scroll').bind('scroll', function() { var $this, h, t; $this = $(this); t = $this.scrollTop(); h = $window.height(); return $('[data-show="on-scroll"]').each(function() { var height, offset, top; $this = $(this); top = $this.offset().top - _t; height = $this.outerHeight(); offset = $this.data('offset') || 0; if (top < t + h + offset) { if (top + height < t && $this.data('show-strict')) { return $this.removeClass('in-view'); } else { return $this.addClass('in-view'); } } else if (top > t + h) { return $this.removeClass('in-view'); } }); }); }); } if ((_ref1 = $modal.data('modal')) != null) { _ref1.on('close', function() { cram($timeline); return $window.trigger('resize.timeline'); }); } return cram($timeline); }); } /* Modal Gallery */ if (typeof jQuery === "function") { jQuery(function($) { var $gallery, $window, _ref; if ($ == null) { $ = jQuery; } $window = $(window); $gallery = $('.modal-gallery'); if ((_ref = $gallery.find('.carousel').data('tc-carousel')) != null) { _ref.slide(0); } $gallery.data('modal').on('modal', function() { var _ref1; $window.trigger('resize.modal-gallery'); return (_ref1 = $gallery.find('.carousel').data('tc-carousel')) != null ? _ref1.resize() : void 0; }); return $window.bind('resize.modal-gallery', function() { return $gallery.filter(':visible').each(function() { var $images; $images = $(this).find('.modal-gallery-image'); return $images.each(function() { var $image, $img; $image = $(this); $img = $image.find('img'); if ($img.width() / $img.height() > $image.width() / $image.height()) { return $image.removeClass('modal-gallery-image-vertical'); } else { return $image.addClass('modal-gallery-image-vertical'); } }); }); }); }); } /* Photo Gallery */ if (typeof jQuery === "function") { jQuery(function($) { if ($ == null) { $ = jQuery; } $('.experience-image').click(function(event) { if (event.target !== $(this).find('.rc-icon-play-ex-large').get(0)) { return false; } }); return $('.photo-gallery').each(function() { var $this; $this = $(this); $this.find('.photo-gallery-image').click(function(event) { if (event.target !== $(this).find('.rc-icon-play-large').get(0)) { return false; } }); return $this.find('.photo-gallery-item-copy').each(function() { var $headline, $textarea, c, limit, message, text, _ok, _stack, _text; $headline = $(this).find('.photo-gallery-item-headline'); $textarea = $(this).find('.photo-gallery-item-text'); limit = 133; if ($headline.height() > 30) { limit = 90; } text = $textarea.text(); _ok = ''; _text = text.substr(0, ~~(text.length / 2)); _stack = text.substr(~~(text.length / 2), text.length); c = 0; while (c < 10 && _text !== '') { $textarea.html((_ok + _text + '...').replace(/\n/g, '
')); if ($textarea.height() > limit) { _stack = _text.substr(~~(_text.length / 2), _text.length); _text = _text.substr(0, ~~(_text.length / 2)); } else { _ok += _text; if (_stack.length === 1) { _text = _stack; _stack = ''; } else { _text = _stack.substr(0, ~~(_stack.length / 2)); _stack = _stack.substr(~~(_stack.length / 2), _stack.length); } } c++; } message = _ok + _text; if (message !== text) { message = message + '...'; } $textarea.html(message.replace(/\n/g, '
')); $this.find('.photo-gallery-image').mouseenter(function() { $this.addClass('photo-gallery-image-hover'); return false; }); $this.find('.rc-paddle').mouseenter(function() { return false; }); return $this.mouseover(function() { return $this.removeClass('photo-gallery-image-hover'); }); }); }); }); } /* Product Gallery */ if (typeof jQuery === "function") { jQuery(function($) { var $gallery; if ($ == null) { $ = jQuery; } $gallery = $('#product-gallery'); return $gallery.each(function() { var $colors, $products, $this, _resize; $this = $(this); $products = $this.find('.product-gallery-item'); $colors = $this.find('.color-indicator'); _resize = function() { return $products.filter(':visible').each(function() { var $img; $this = $(this); $img = $this.find('.product-gallery-image img, .product-gallery-image video'); return $img.each(function() { var $t; $(this).load(function() { return _resize(); }); $t = $(this); $t.width('auto'); if ($t.width() < 980) { return; } return $t.width($t.width() / 980 * 100 + '%'); }); }); }; _resize(); return $colors.bind('click', function() { var $current, $next, index; $this = $(this); index = $this.index(); $current = $products.filter('.product-gallery-item-active'); $next = $products.filter(':eq(' + index + ')'); if ($current.get(0) === $next.get(0)) { return; } $products.removeClass('in'); $next.addClass('product-gallery-item-active'); _.defer(function() { _resize(); $next.addClass('in'); return $next.unbind('oTransitionEnd mozTransitionEnd webkitTransitionEnd transitionend').bind('oTransitionEnd mozTransitionEnd webkitTransitionEnd transitionend', function() { $next.unbind('oTransitionEnd mozTransitionEnd webkitTransitionEnd transitionend'); $current.removeClass('product-gallery-item-active'); return $(window).trigger('resize.autoplay'); }); }); $colors.removeClass('color-indicator-active'); return $this.addClass('color-indicator-active'); }); }); }); } /* Modal Video Player */ if (typeof jQuery === "function") { jQuery(function($) { var $modal, $window, iid; if ($ == null) { $ = jQuery; } $window = $(window); $modal = $('#modal-youtube'); $('#content-container').after($modal); iid = null; $window.bind('resize.modal-video-player', function() { if ($window.width() / $window.height() > 16 / 9) { return $modal.addClass('modal-video-player-vertical'); } else { return $modal.removeClass('modal-video-player-vertical'); } }); $window.trigger('resize.modal-video-player'); $modal.on('mouseenter', 'iframe', function() { $modal.addClass('mousemove'); return clearTimeout(iid); }); return $modal.bind('mousemove', function() { $modal.addClass('mousemove'); if (iid) { clearTimeout(iid); } return iid = setTimeout(function() { return $modal.removeClass('mousemove'); }, 2000); }); }); } /* Masthead */ if (typeof jQuery === "function") { jQuery(function($) { var $headline, $hero, $masthead, $window; if ($ == null) { $ = jQuery; } if ($('html').hasClass('mobile')) { return; } $window = $(window); $masthead = $('#hero'); $hero = $masthead.find('.hero-image'); $headline = $masthead.find('.hero-copy-fixed'); return $window.bind('scroll resize', function() { var d, dist, mh, mt, per, t; t = $window.scrollTop(); mt = $masthead.offset().top; mh = $masthead.outerHeight(); if (t < 0) { t = 0; } d = mh - (t - mt); if (d < 0) { d = 0; } if (d > mh) { d = mh; } dist = ($hero.height() - d) / 2; $hero.css('transform', 'translateY(' + dist + 'px)'); $headline.css('transform', 'translateY(' + dist + 'px) translate3d(0, 0, 0)'); per = 100 - t / mh * 100; if (per > 0) { $hero.fadeTo(0, per / 100); return $headline.fadeTo(0, per / 100); } else { $hero.fadeTo(0, 0); return $headline.fadeTo(0, 0); } }); }); } /* Cover */ if (typeof jQuery === "function") { jQuery(function($) { var $body, $html, $middle, $parallax, $top, $window; if ($ == null) { $ = jQuery; } $html = $('html'); $window = $(window); $body = $('body'); $parallax = $('.sound-system .features-column-hero'); $top = $('.sound-system-panel-top'); $middle = $('.sound-system-panel-middle'); $window.bind('scroll.cover resize.cover', function(event) { var bh, bias, height, top; top = $window.scrollTop(); if (top < 0) { top = 0; } height = $window.height(); bh = $body.height(); bias = 0; /* Parallax */ return $parallax.each(function(i) { var $this, h, per, t; $this = $(this); t = $this.offset().top; h = $this.outerHeight(); per = (top - (t - height)) / (height + h); if (t === 0) { per = (top - t) / h; } per *= 2; if (per < 0) { per = 0; } if (per > 1) { per = 1; } if (t + h + bias > top && t < top + height + bias) { if ($html.hasClass('mobile')) { per *= .8; } $top.css('transform', 'translateY(-' + 270 * per * h / 760 + 'px)'); return $middle.css('transform', 'translateY(-' + 140 * per * h / 760 + 'px)'); } }); }); return $window.trigger('scroll.parallax2'); }); } $html = jQuery('html'); if ($html.hasClass('mobile')) { RLD.browser.ios = true; RLD.browser.iphone = false; RLD.browser.android = false; if ($html.hasClass('iphone')) { RLD.browser.tablet = true; } } }).call(this);