Created
April 22, 2015 15:44
-
-
Save luqmaan/a46816b4ccdf9ebee3ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* / | |
function() { | |
var e, t, n; | |
di.provide("di.ui.CanvasBlur"), t = [512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292, 512, 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292, 273, 512, 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259, 496, 475, 456, 437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292, 282, 273, 265, 512, 497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373, 364, 354, 345, 337, 328, 320, 312, 305, 298, 291, 284, 278, 271, 265, 259, 507, 496, 485, 475, 465, 456, 446, 437, 428, 420, 412, 404, 396, 388, 381, 374, 367, 360, 354, 347, 341, 335, 329, 323, 318, 312, 307, 302, 297, 292, 287, 282, 278, 273, 269, 265, 261, 512, 505, 497, 489, 482, 475, 468, 461, 454, 447, 441, 435, 428, 422, 417, 411, 405, 399, 394, 389, 383, 378, 373, 368, 364, 359, 354, 350, 345, 341, 337, 332, 328, 324, 320, 316, 312, 309, 305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271, 268, 265, 262, 259, 257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456, 451, 446, 442, 437, 433, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 388, 385, 381, 377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335, 332, 329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292, 289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259], n = [9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24], e = function() { | |
return this.r = 0, this.g = 0, this.b = 0, this.a = 0, this.next = null | |
}, di.ui.CanvasBlur = function(i, r, o, a, s, l) { | |
var u, c, d, h, p, f, m, g, y, v, _, b, w, x, k, C, A, S, T, P, M, E, I, F, O, R, D, L, B, N, $, V, j, H, z, U, W, q, Y, K, G, J, Q, X, Z, et, tt, nt, it; | |
if (!(isNaN(l) || 1 > l)) { | |
for (l |= 0, m = i.getContext("2d"), x = null, x = m.getImageData(r, o, a, s), P = x.data, U = W = w = C = Y = q = K = null, F = _ = f = d = null, I = v = p = c = null, E = y = h = u = null, M = T = S = A = R = null, g = l + l + 1, H = a << 2, z = a - 1, b = s - 1, O = l + 1, j = O * (O + 1) / 2, V = new e, L = V, w = G = 1; g >= 1 ? g > G : G > g; w = g >= 1 ? ++G : --G) L = L.next = new e, w === O && (B = L); | |
for (L.next = V, N = null, $ = null, K = q = 0, k = t[l], D = n[l], W = J = 0; s >= 0 ? s > J : J > s; W = s >= 0 ? ++J : --J) { | |
for (E = y = h = u = F = _ = f = d = 0, I = O * (M = P[q]), v = O * (T = P[q + 1]), p = O * (S = P[q + 2]), c = O * (A = P[q + 3]), F += j * M, _ += j * T, f += j * S, d += j * A, L = V, w = Q = 0; O >= 0 ? O > Q : Q > O; w = O >= 0 ? ++Q : --Q) L.r = M, L.g = T, L.b = S, L.a = A, L = L.next; | |
for (w = X = 1; O >= 1 ? O > X : X > O; w = O >= 1 ? ++X : --X) C = q + ((w > z ? z : w) << 2), F += (L.r = M = P[C]) * (R = O - w), _ += (L.g = T = P[C + 1]) * R, f += (L.b = S = P[C + 2]) * R, d += (L.a = A = P[C + 3]) * R, E += M, y += T, h += S, u += A, L = L.next; | |
for (N = V, $ = B, U = Z = 0; a >= 0 ? a > Z : Z > a; U = a >= 0 ? ++Z : --Z) P[q + 3] = A = d * k >> D, 0 !== A ? (A = 255 / A, P[q] = (F * k >> D) * A, P[q + 1] = (_ * k >> D) * A, P[q + 2] = (f * k >> D) * A) : P[q] = P[q + 1] = P[q + 2] = 0, F -= I, _ -= v, f -= p, d -= c, I -= N.r, v -= N.g, p -= N.b, c -= N.a, C = K + ((C = U + l + 1) < z ? C : z) << 2, E += N.r = P[C], y += N.g = P[C + 1], h += N.b = P[C + 2], u += N.a = P[C + 3], F += E, _ += y, f += h, d += u, N = N.next, I += M = $.r, v += T = $.g, p += S = $.b, c += A = $.a, E -= M, y -= T, h -= S, u -= A, $ = $.next, q += 4; | |
K += a | |
} | |
for (U = et = 0; a >= 0 ? a > et : et > a; U = a >= 0 ? ++et : --et) { | |
for (y = h = u = E = _ = f = d = F = 0, q = U << 2, I = O * (M = P[q]), v = O * (T = P[q + 1]), p = O * (S = P[q + 2]), c = O * (A = P[q + 3]), F += j * M, _ += j * T, f += j * S, d += j * A, L = V, w = tt = 0; O >= 0 ? O > tt : tt > O; w = O >= 0 ? ++tt : --tt) L.r = M, L.g = T, L.b = S, L.a = A, L = L.next; | |
for (Y = a, w = nt = 1; l >= 1 ? l >= nt : nt >= l; w = l >= 1 ? ++nt : --nt) q = Y + U << 2, F += (L.r = M = P[q]) * (R = O - w), _ += (L.g = T = P[q + 1]) * R, f += (L.b = S = P[q + 2]) * R, d += (L.a = A = P[q + 3]) * R, E += M, y += T, h += S, u += A, L = L.next, b > w && (Y += a); | |
for (q = U, N = V, $ = B, W = it = 0; s >= 0 ? s > it : it > s; W = s >= 0 ? ++it : --it) C = q << 2, P[C + 3] = A = d * k >> D, A > 0 ? (A = 255 / A, P[C] = (F * k >> D) * A, P[C + 1] = (_ * k >> D) * A, P[C + 2] = (f * k >> D) * A) : P[C] = P[C + 1] = P[C + 2] = 0, F -= I, _ -= v, f -= p, d -= c, I -= N.r, v -= N.g, p -= N.b, c -= N.a, C = U + ((C = W + O) < b ? C : b) * a << 2, F += E += N.r = P[C], _ += y += N.g = P[C + 1], f += h += N.b = P[C + 2], d += u += N.a = P[C + 3], N = N.next, I += M = $.r, v += T = $.g, p += S = $.b, c += A = $.a, E -= M, y -= T, h -= S, u -= A, $ = $.next, q += a | |
} | |
return m.putImageData(x, r, o) | |
} | |
} | |
}.call(this), | |
function() { | |
di.app.module("ShowHeroApp.Views", function(e, t, n, i, r, o) { | |
var a, s, l, u, c; | |
return u = "#hero.show-detail", a = "active", l = 4, s = 80, e.Layout = i.LayoutView.extend({ | |
el: u, | |
regions: { | |
controlsRegion: ".controls-region", | |
nowPlayingRegion: ".now-playing-region", | |
statusRegion: ".status-region" | |
}, | |
ui: { | |
bgFX: ".bg-fx" | |
}, | |
initialize: function() { | |
return this.bindUIElements(), this.heroBackgroundFX() | |
}, | |
heroBackgroundFX: function() { | |
var e, t, n; | |
return t = this.ui.bgFX[0], e = new Image, e.onload = function() { | |
var n, i, r, o, a; | |
return i = t.getContext("2d"), i.scale(l, l), r = t.width, n = t.height, o = -(r - r / l) / 2, a = -(n - n / l) / 2, i.drawImage(e, o, a, r, n), di.ui.CanvasBlur(t, 0, 0, r, n, s) | |
}, n = this.ui.bgFX.data("bg-img"), e.src = "//" + document.domain + "/_papi/" + n | |
} | |
}), e.Status = i.ItemView.extend({ | |
template: "di/ui/show_hero/status" | |
}), c = { | |
initialize: function() { | |
var e; | |
return e = this.model.get("channels")[0].id, this.sharedChannelEntity = t.request("channel:entity", e), this.model.set("channel", this.sharedChannelEntity), this.listenTo(this.sharedChannelEntity, "change:playing", this.render) | |
}, | |
serializeData: function() { | |
var e; | |
return e = this.model.toJSON(), e.channel.playing = e.channel.playing || !1, e | |
} | |
}, e.NowPlaying = i.ItemView.extend(o.extend({ | |
template: "di/ui/show_hero/now_playing", | |
className: "now-playing", | |
ui: { | |
tuneInButton: ".tune-in" | |
}, | |
events: { | |
"click @ui.tuneInButton": "playChannel" | |
}, | |
behaviors: { | |
TuneIn: {} | |
} | |
}, c)), e.Controls = i.ItemView.extend(o.extend({ | |
tagName: "ul", | |
className: "controls", | |
behaviors: { | |
TuneIn: {}, | |
Popdown: {}, | |
Share: { | |
scope: "show" | |
} | |
} | |
}, c)), e.LiveControls = e.Controls.extend({ | |
template: "di/ui/show_hero/live_controls" | |
}), e.UpcomingControls = e.Controls.extend({ | |
template: "di/ui/show_hero/upcoming_controls" | |
}) | |
}) | |
}.call(this), | |
function() {}.call(this), | |
function() { | |
di.app.module("ChannelInfoApp", function(e) { | |
var t; | |
return this.startWithParent = !1, t = { | |
showChannelInfo: function(t) { | |
return e.Controller.show(t) | |
}, | |
destroyChannelInfo: function() { | |
return e.Controller.destroy() | |
} | |
}, e.addInitializer(function(e) { | |
return null != (null != e ? e.channel_id : void 0) ? t.showChannelInfo(e.channel_id) : void 0 | |
}), e.addFinalizer(function() { | |
return t.destroyChannelInfo() | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("ChannelInfoApp", function(e, t, n, i, r) { | |
return e.Controller = { | |
show: function(e) { | |
return this.channel = t.request("channel:entity", e), this.attachLayout(), this.showNowPlaying(), this.notifySocialModule() | |
}, | |
attachLayout: function() { | |
return this.layout = new e.Views.Layout({ | |
model: this.channel | |
}), this.layout.render(), this.tileView = new e.Views.Tile({ | |
model: this.channel | |
}), this.layout.tileRegion.show(this.tileView) | |
}, | |
destroyLayout: function() { | |
return this.layout.destroy() | |
}, | |
showNowPlaying: function() { | |
return t.request("nowPlaying:entity", { | |
channel_id: this.channel.get("id") | |
}, function(t) { | |
return function(n) { | |
return t.nowPlaying = n, t.nowPlayingView = new e.Views.NowPlaying({ | |
model: t.nowPlaying | |
}), t.layout.nowPlayingRegion.show(t.nowPlayingView) | |
} | |
}(this)) | |
}, | |
notifySocialModule: function() { | |
return r(document).trigger("Channel.Changed", this.channel.toJSON()) | |
}, | |
destroy: function() { | |
return this.destroyLayout() | |
} | |
} | |
}) | |
}.call(this), | |
function() { | |
di.app.module("ChannelInfoApp.Views", function(e, t, n, i, r) { | |
var o, a, s; | |
return a = "#channel-info", s = "favorited", o = "active", e.Layout = i.LayoutView.extend({ | |
template: "di/ui/channel_info/layout", | |
el: a, | |
regions: { | |
nowPlayingRegion: ".now-playing-region", | |
tileRegion: ".tile-region" | |
}, | |
ui: { | |
shareButton: ".share", | |
sharePopdown: ".share-buttons", | |
subscribeButton: ".subscribe", | |
subscribePopdown: ".calendar-subscribe", | |
favButton: ".fav-btn" | |
}, | |
events: { | |
"click @ui.shareButton": "setActive", | |
"click @ui.subscribeButton": "setActive", | |
"mouseleave @ui.sharePopdown": "removeActiveParent", | |
"mouseleave @ui.subscribePopdown": "removeActiveParent" | |
}, | |
triggers: { | |
"click @ui.favButton": "favorite" | |
}, | |
behaviors: { | |
Favorite: {}, | |
Popdown: {}, | |
Share: { | |
scope: "channel" | |
} | |
}, | |
serializeData: function() { | |
var e; | |
return e = this.model.toJSON(), null == e.favorite && (e.favorite = !1), e | |
}, | |
setActive: function(e) { | |
return r(e.currentTarget).addClass(o) | |
}, | |
removeActiveParent: function(e) { | |
return r(e.currentTarget).parent().removeClass(o) | |
} | |
}), e.NowPlaying = i.ItemView.extend({ | |
template: "di/ui/channel_info/now_playing", | |
className: "now-playing", | |
modelEvents: { | |
change: "render" | |
} | |
}), e.Tile = i.ItemView.extend({ | |
template: "di/ui/channel_info/tile", | |
className: "image", | |
modelEvents: { | |
"change:playing": "render" | |
}, | |
behaviors: { | |
TuneIn: {} | |
} | |
}) | |
}) | |
}.call(this), | |
function() {}.call(this), | |
function() { | |
di.app.module("CommentsApp", function(e, t, n, i, r, o) { | |
var a, s, l, u; | |
return this.startWithParent = !1, s = "#fb-comments", u = 12e4, l = i.ItemView.extend({ | |
el: r(s), | |
ui: { | |
count: ".comments-cnt" | |
}, | |
initialize: function() { | |
return this.bindUIElements(), this.listenTo(di.eventbus, "fb:comment:create", this.updateCount), this.listenTo(di.eventbus, "fb:comment:remove", this.updateCount), this.refreshInterval = setInterval(o.bind(this.render, this), u) | |
}, | |
render: function() { | |
return FB.XFBML.parse(this.el) | |
}, | |
updateCount: function() { | |
return FB.XFBML.parse(this.ui.count[0]) | |
}, | |
onDestroy: function() { | |
return clearInterval(this.refreshInterval) | |
} | |
}), a = { | |
start: function() { | |
return window.FB ? this.currentView = new l : this.listenToOnce(di.eventbus, "fb:sdk:ready", a.start) | |
}, | |
stop: function() { | |
return this.currentView.destroy(), this.currentView = null | |
} | |
}, e.addInitializer(a.start), e.addFinalizer(a.stop) | |
}) | |
}.call(this), | |
function() {}.call(this), | |
function() { | |
di.app.module("ActivityFeedApp", function(e) { | |
var t; | |
return this.startWithParent = !1, t = { | |
showActivityFeed: function() { | |
return e.Controller.show() | |
}, | |
destroyActivityFeed: function() { | |
return e.Controller.destroy() | |
} | |
}, e.addInitializer(function() { | |
return t.showActivityFeed() | |
}), e.addFinalizer(function() { | |
return t.destroyActivityFeed() | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("Components.Pagination", function(e, t, n, i, r) { | |
var o, a; | |
return a = 5, o = "current", e.View = i.ItemView.extend({ | |
template: "di/ui/components/pagination", | |
ui: { | |
pageBtn: ".page-btn" | |
}, | |
events: { | |
"click @ui.pageBtn": "onPageBtnClick" | |
}, | |
modelEvents: { | |
change: "render" | |
}, | |
onPageBtnClick: function(e) { | |
var t; | |
return t = r(e.currentTarget).data("page"), t ? (r(e.currentTarget).addClass(o), this.model.set("selection", t)) : void 0 | |
}, | |
templateHelpers: { | |
getPrevRange: function() { | |
var e, t; | |
return e = null != this.page ? function() { | |
t = []; | |
for (var e = 1, n = this.page; n >= 1 ? n > e : e > n; n >= 1 ? e++ : e--) t.push(e); | |
return t | |
}.apply(this) : [], e.length > a && (e = [1, "..."].concat(e.slice(this.page - a, this.page))), e | |
}, | |
getNextRange: function() { | |
var e, t, n; | |
return e = null != this.page && null != this.last ? function() { | |
n = []; | |
for (var e = t = this.page + 1, i = this.last; i >= t ? i >= e : e >= i; i >= t ? e++ : e--) n.push(e); | |
return n | |
}.apply(this) : [], e.length > a && (e = e.slice(0, a - 1).concat(["...", this.last])), e | |
} | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("ActivityFeedApp", function(e, t, n) { | |
return e.Controller = { | |
show: function() { | |
return this.initModels(), this.attachViews(), this.paginationState.set("selection", 1) | |
}, | |
updateFeed: function() { | |
return this.trackVotesView.$childViewContainer.fadeOut("fast", function(e) { | |
return function() { | |
return e.trackVotesView.collection.reset(e.trackVoteFeed.models) | |
} | |
}(this)), this.updatePagination() | |
}, | |
updatePagination: function() { | |
return this.paginationState.clear({ | |
silent: !0 | |
}), this.paginationState.set(this.trackVoteFeed.link) | |
}, | |
initModels: function() { | |
return this.trackVoteFeed = new t.Entities.TrackVoteFeed, this.paginationState = new n.Model, this.paginationState.on("change:selection", function(e) { | |
return function(t, n) { | |
return e.trackVoteFeed.getPage(n).done(function() { | |
return e.updateFeed() | |
}) | |
} | |
}(this)) | |
}, | |
attachViews: function() { | |
return this.layout = new e.Views.Layout, this.trackVotesView = new e.Views.TrackVotes({ | |
collection: new n.Collection | |
}), this.trackVotesView.on("render:collection", function() { | |
return this.$childViewContainer.fadeIn() | |
}), this.layout.trackVotesRegion.show(this.trackVotesView), this.paginationView = new t.Components.Pagination.View({ | |
model: this.paginationState | |
}), this.layout.paginationRegion.show(this.paginationView), this.trackVotesView.on("childview:vote:altered", function(e) { | |
return function() { | |
return e.trackVoteFeed.updatePagination().done(function() { | |
return e.updatePagination() | |
}) | |
} | |
}(this)) | |
}, | |
destroy: function() { | |
var e; | |
return null != (e = this.layout) ? e.destroy() : void 0 | |
} | |
} | |
}) | |
}.call(this), | |
function() { | |
di.app.module("ActivityFeedApp.Views", function(e, t, n, i) { | |
var r, o, a; | |
return r = "#activity-feed", o = "53x53", a = "retracted", e.Layout = i.LayoutView.extend({ | |
el: r, | |
regions: { | |
trackVotesRegion: ".track-votes-region", | |
paginationRegion: ".pagination-region" | |
} | |
}), e.TrackVoteItem = i.ItemView.extend({ | |
template: "di/ui/activity_feed/track_vote_item", | |
tagName: "li", | |
className: "feed-item", | |
ui: { | |
retractBtn: ".retract-btn" | |
}, | |
events: { | |
"click @ui.retractBtn": "onRetractBtnClicked" | |
}, | |
initialize: function() { | |
return this.listenTo(this.model.get("track"), "change:votes", this.onVotesChanged) | |
}, | |
onRetractBtnClicked: function() { | |
return this.model.vote() | |
}, | |
onVotesChanged: function() { | |
return this.trigger("vote:altered"), this.render() | |
}, | |
onRender: function() { | |
return this.$el.toggleClass(a, !this.model.get("track").get("votes").cast.up) | |
}, | |
templateHelpers: { | |
trackImage: function(e) { | |
return this.channel && (e = AudioAddict.UI.img_uri(this.channel.toJSON(), { | |
size: o | |
})), AudioAddict.UI.img_uri(this.track.toJSON(), { | |
size: o | |
}) || e | |
}, | |
trackDetailUrl: function() { | |
var e; | |
return e = { | |
track_id: this.track.get("id") | |
}, this.channel && (e.channel_key = this.channel.get("key")), Routes.tracks_path(e) | |
}, | |
channelUrl: function() { | |
return Routes.channel_path(this.channel.get("key")) | |
}, | |
isRetracted: function() { | |
return !this.track.get("votes").cast.up | |
} | |
} | |
}), e.NoTracks = i.ItemView.extend({ | |
template: "di/ui/activity_feed/no_tracks" | |
}), e.TrackVotes = i.CompositeView.extend({ | |
template: "di/ui/activity_feed/track_votes", | |
childView: e.TrackVoteItem, | |
emptyView: e.NoTracks, | |
childViewContainer: ".feed-body" | |
}) | |
}) | |
}.call(this), | |
function() {}.call(this), | |
function(e, t) { | |
"function" == typeof define && define.amd ? define(["exports", "backbone", "underscore"], t) : "undefined" != typeof exports ? t(exports, require("backbone"), require("underscore")) : t(e, e.Backbone, e._) | |
}(this, function(e, t, n) { | |
"use strict"; | |
t.Relational = { | |
showWarnings: !0 | |
}, t.Semaphore = { | |
_permitsAvailable: null, | |
_permitsUsed: 0, | |
acquire: function() { | |
if (this._permitsAvailable && this._permitsUsed >= this._permitsAvailable) throw new Error("Max permits acquired"); | |
this._permitsUsed++ | |
}, | |
release: function() { | |
if (0 === this._permitsUsed) throw new Error("All permits released"); | |
this._permitsUsed-- | |
}, | |
isLocked: function() { | |
return this._permitsUsed > 0 | |
}, | |
setAvailablePermits: function(e) { | |
if (this._permitsUsed > e) throw new Error("Available permits cannot be less than used permits"); | |
this._permitsAvailable = e | |
} | |
}, t.BlockingQueue = function() { | |
this._queue = [] | |
}, n.extend(t.BlockingQueue.prototype, t.Semaphore, { | |
_queue: null, | |
add: function(e) { | |
this.isBlocked() ? this._queue.push(e) : e() | |
}, | |
process: function() { | |
var e = this._queue; | |
for (this._queue = []; e && e.length;) e.shift()() | |
}, | |
block: function() { | |
this.acquire() | |
}, | |
unblock: function() { | |
this.release(), this.isBlocked() || this.process() | |
}, | |
isBlocked: function() { | |
return this.isLocked() | |
} | |
}), t.Relational.eventQueue = new t.BlockingQueue, t.Store = function() { | |
this._collections = [], this._reverseRelations = [], this._orphanRelations = [], this._subModels = [], this._modelScopes = [e] | |
}, n.extend(t.Store.prototype, t.Events, { | |
initializeRelation: function(e, i, r) { | |
var o = n.isString(i.type) ? t[i.type] || this.getObjectByName(i.type) : i.type; | |
o && o.prototype instanceof t.Relation ? new o(e, i, r) : t.Relational.showWarnings && "undefined" != typeof console && console.warn("Relation=%o; missing or invalid relation type!", i) | |
}, | |
addModelScope: function(e) { | |
this._modelScopes.push(e) | |
}, | |
removeModelScope: function(e) { | |
this._modelScopes = n.without(this._modelScopes, e) | |
}, | |
addSubModels: function(e, t) { | |
this._subModels.push({ | |
superModelType: t, | |
subModels: e | |
}) | |
}, | |
setupSuperModel: function(e) { | |
n.find(this._subModels, function(t) { | |
return n.filter(t.subModels || [], function(n, i) { | |
var r = this.getObjectByName(n); | |
return e === r ? (t.superModelType._subModels[i] = e, e._superModel = t.superModelType, e._subModelTypeValue = i, e._subModelTypeAttribute = t.superModelType.prototype.subModelTypeAttribute, !0) : void 0 | |
}, this).length | |
}, this) | |
}, | |
addReverseRelation: function(e) { | |
var t = n.any(this._reverseRelations, function(t) { | |
return n.all(e || [], function(e, n) { | |
return e === t[n] | |
}) | |
}); | |
!t && e.model && e.type && (this._reverseRelations.push(e), this._addRelation(e.model, e), this.retroFitRelation(e)) | |
}, | |
addOrphanRelation: function(e) { | |
var t = n.any(this._orphanRelations, function(t) { | |
return n.all(e || [], function(e, n) { | |
return e === t[n] | |
}) | |
}); | |
!t && e.model && e.type && this._orphanRelations.push(e) | |
}, | |
processOrphanRelations: function() { | |
n.each(this._orphanRelations.slice(0), function(e) { | |
var i = t.Relational.store.getObjectByName(e.relatedModel); | |
i && (this.initializeRelation(null, e), this._orphanRelations = n.without(this._orphanRelations, e)) | |
}, this) | |
}, | |
_addRelation: function(e, t) { | |
e.prototype.relations || (e.prototype.relations = []), e.prototype.relations.push(t), n.each(e._subModels || [], function(e) { | |
this._addRelation(e, t) | |
}, this) | |
}, | |
retroFitRelation: function(e) { | |
var t = this.getCollection(e.model, !1); | |
t && t.each(function(t) { | |
t instanceof e.model && new e.type(t, e) | |
}, this) | |
}, | |
getCollection: function(e, i) { | |
e instanceof t.RelationalModel && (e = e.constructor); | |
for (var r = e; r._superModel;) r = r._superModel; | |
var o = n.find(this._collections, function(e) { | |
return e.model === r | |
}); | |
return o || i === !1 || (o = this._createCollection(r)), o | |
}, | |
getObjectByName: function(e) { | |
var t = e.split("."), | |
i = null; | |
return n.find(this._modelScopes, function(e) { | |
return i = n.reduce(t || [], function(e, t) { | |
return e ? e[t] : void 0 | |
}, e), i && i !== e ? !0 : void 0 | |
}, this), i | |
}, | |
_createCollection: function(e) { | |
var n; | |
return e instanceof t.RelationalModel && (e = e.constructor), e.prototype instanceof t.RelationalModel && (n = new t.Collection, n.model = e, this._collections.push(n)), n | |
}, | |
resolveIdForItem: function(e, i) { | |
var r = n.isString(i) || n.isNumber(i) ? i : null; | |
return null === r && (i instanceof t.RelationalModel ? r = i.id : n.isObject(i) && (r = i[e.prototype.idAttribute])), r || 0 === r || (r = null), r | |
}, | |
find: function(e, t) { | |
var n = this.resolveIdForItem(e, t), | |
i = this.getCollection(e); | |
if (i) { | |
var r = i.get(n); | |
if (r instanceof e) return r | |
} | |
return null | |
}, | |
register: function(e) { | |
var t = this.getCollection(e); | |
if (t) { | |
var n = e.collection; | |
t.add(e), e.collection = n | |
} | |
}, | |
checkId: function(e, n) { | |
var i = this.getCollection(e), | |
r = i && i.get(n); | |
if (r && e !== r) throw t.Relational.showWarnings && "undefined" != typeof console && console.warn("Duplicate id! Old RelationalModel=%o, new RelationalModel=%o", r, e), new Error("Cannot instantiate more than one Backbone.RelationalModel with the same id per type!") | |
}, | |
update: function(e) { | |
var t = this.getCollection(e); | |
t.contains(e) || this.register(e), t._onModelEvent("change:" + e.idAttribute, e, t), e.trigger("relational:change:id", e, t) | |
}, | |
unregister: function(e) { | |
var i, r; | |
e instanceof t.Model ? (i = this.getCollection(e), r = [e]) : e instanceof t.Collection ? (i = this.getCollection(e.model), r = n.clone(e.models)) : (i = this.getCollection(e), r = n.clone(i.models)), n.each(r, function(e) { | |
this.stopListening(e), n.invoke(e.getRelations(), "stopListening") | |
}, this), n.contains(this._collections, e) ? i.reset([]) : n.each(r, function(e) { | |
i.get(e) ? i.remove(e) : i.trigger("relational:remove", e, i) | |
}, this) | |
}, | |
reset: function() { | |
this.stopListening(), n.each(this._collections, function(e) { | |
this.unregister(e) | |
}, this), this._collections = [], this._subModels = [], this._modelScopes = [e] | |
} | |
}), t.Relational.store = new t.Store, t.Relation = function(e, i, r) { | |
if (this.instance = e, i = n.isObject(i) ? i : {}, this.reverseRelation = n.defaults(i.reverseRelation || {}, this.options.reverseRelation), this.options = n.defaults(i, this.options, t.Relation.prototype.options), this.reverseRelation.type = n.isString(this.reverseRelation.type) ? t[this.reverseRelation.type] || t.Relational.store.getObjectByName(this.reverseRelation.type) : this.reverseRelation.type, this.key = this.options.key, this.keySource = this.options.keySource || this.key, this.keyDestination = this.options.keyDestination || this.keySource || this.key, this.model = this.options.model || this.instance.constructor, this.relatedModel = this.options.relatedModel, !n.isFunction(this.relatedModel) || this.relatedModel.prototype instanceof t.RelationalModel || (this.relatedModel = n.result(this, "relatedModel")), n.isString(this.relatedModel) && (this.relatedModel = t.Relational.store.getObjectByName(this.relatedModel)), this.checkPreconditions() && (!this.options.isAutoRelation && this.reverseRelation.type && this.reverseRelation.key && t.Relational.store.addReverseRelation(n.defaults({ | |
isAutoRelation: !0, | |
model: this.relatedModel, | |
relatedModel: this.model, | |
reverseRelation: this.options | |
}, this.reverseRelation)), e)) { | |
var o = this.keySource; | |
o !== this.key && "object" == typeof this.instance.get(this.key) && (o = this.key), this.setKeyContents(this.instance.get(o)), this.relatedCollection = t.Relational.store.getCollection(this.relatedModel), this.keySource !== this.key && delete this.instance.attributes[this.keySource], this.instance._relations[this.key] = this, this.initialize(r), this.options.autoFetch && this.instance.fetchRelated(this.key, n.isObject(this.options.autoFetch) ? this.options.autoFetch : {}), this.listenTo(this.instance, "destroy", this.destroy).listenTo(this.relatedCollection, "relational:add relational:change:id", this.tryAddRelated).listenTo(this.relatedCollection, "relational:remove", this.removeRelated) | |
} | |
}, t.Relation.extend = t.Model.extend, n.extend(t.Relation.prototype, t.Events, t.Semaphore, { | |
options: { | |
createModels: !0, | |
includeInJSON: !0, | |
isAutoRelation: !1, | |
autoFetch: !1, | |
parse: !1 | |
}, | |
instance: null, | |
key: null, | |
keyContents: null, | |
relatedModel: null, | |
relatedCollection: null, | |
reverseRelation: null, | |
related: null, | |
checkPreconditions: function() { | |
var e = this.instance, | |
i = this.key, | |
r = this.model, | |
o = this.relatedModel, | |
a = t.Relational.showWarnings && "undefined" != typeof console; | |
if (!r || !i || !o) return a && console.warn("Relation=%o: missing model, key or relatedModel (%o, %o, %o).", this, r, i, o), !1; | |
if (!(r.prototype instanceof t.RelationalModel)) return a && console.warn("Relation=%o: model does not inherit from Backbone.RelationalModel (%o).", this, e), !1; | |
if (!(o.prototype instanceof t.RelationalModel)) return a && console.warn("Relation=%o: relatedModel does not inherit from Backbone.RelationalModel (%o).", this, o), !1; | |
if (this instanceof t.HasMany && this.reverseRelation.type === t.HasMany) return a && console.warn("Relation=%o: relation is a HasMany, and the reverseRelation is HasMany as well.", this), !1; | |
if (e && n.keys(e._relations).length) { | |
var s = n.find(e._relations, function(e) { | |
return e.key === i | |
}, this); | |
if (s) return a && console.warn("Cannot create relation=%o on %o for model=%o: already taken by relation=%o.", this, i, e, s), !1 | |
} | |
return !0 | |
}, | |
setRelated: function(e) { | |
this.related = e, this.instance.attributes[this.key] = e | |
}, | |
_isReverseRelation: function(e) { | |
return e.instance instanceof this.relatedModel && this.reverseRelation.key === e.key && this.key === e.reverseRelation.key | |
}, | |
getReverseRelations: function(e) { | |
var t = [], | |
i = n.isUndefined(e) ? this.related && (this.related.models || [this.related]) : [e]; | |
return n.each(i || [], function(e) { | |
n.each(e.getRelations() || [], function(e) { | |
this._isReverseRelation(e) && t.push(e) | |
}, this) | |
}, this), t | |
}, | |
destroy: function() { | |
this.stopListening(), this instanceof t.HasOne ? this.setRelated(null) : this instanceof t.HasMany && this.setRelated(this._prepareCollection()), n.each(this.getReverseRelations(), function(e) { | |
e.removeRelated(this.instance) | |
}, this) | |
} | |
}), t.HasOne = t.Relation.extend({ | |
options: { | |
reverseRelation: { | |
type: "HasMany" | |
} | |
}, | |
initialize: function(e) { | |
this.listenTo(this.instance, "relational:change:" + this.key, this.onChange); | |
var t = this.findRelated(e); | |
this.setRelated(t), n.each(this.getReverseRelations(), function(t) { | |
t.addRelated(this.instance, e) | |
}, this) | |
}, | |
findRelated: function(e) { | |
var t = null; | |
if (e = n.defaults({ | |
parse: this.options.parse | |
}, e), this.keyContents instanceof this.relatedModel) t = this.keyContents; | |
else if (this.keyContents || 0 === this.keyContents) { | |
var i = n.defaults({ | |
create: this.options.createModels | |
}, e); | |
t = this.relatedModel.findOrCreate(this.keyContents, i) | |
} | |
return t && (this.keyId = null), t | |
}, | |
setKeyContents: function(e) { | |
this.keyContents = e, this.keyId = t.Relational.store.resolveIdForItem(this.relatedModel, this.keyContents) | |
}, | |
onChange: function(e, i, r) { | |
if (!this.isLocked()) { | |
this.acquire(), r = r ? n.clone(r) : {}; | |
var o = n.isUndefined(r.__related), | |
a = o ? this.related : r.__related; | |
if (o) { | |
this.setKeyContents(i); | |
var s = this.findRelated(r); | |
this.setRelated(s) | |
} | |
if (a && this.related !== a && n.each(this.getReverseRelations(a), function(e) { | |
e.removeRelated(this.instance, null, r) | |
}, this), n.each(this.getReverseRelations(), function(e) { | |
e.addRelated(this.instance, r) | |
}, this), !r.silent && this.related !== a) { | |
var l = this; | |
this.changed = !0, t.Relational.eventQueue.add(function() { | |
l.instance.trigger("change:" + l.key, l.instance, l.related, r, !0), l.changed = !1 | |
}) | |
} | |
this.release() | |
} | |
}, | |
tryAddRelated: function(e, t, n) { | |
!this.keyId && 0 !== this.keyId || e.id !== this.keyId || (this.addRelated(e, n), this.keyId = null) | |
}, | |
addRelated: function(e, t) { | |
var i = this; | |
e.queue(function() { | |
if (e !== i.related) { | |
var r = i.related || null; | |
i.setRelated(e), i.onChange(i.instance, e, n.defaults({ | |
__related: r | |
}, t)) | |
} | |
}) | |
}, | |
removeRelated: function(e, t, i) { | |
if (this.related && e === this.related) { | |
var r = this.related || null; | |
this.setRelated(null), this.onChange(this.instance, e, n.defaults({ | |
__related: r | |
}, i)) | |
} | |
} | |
}), t.HasMany = t.Relation.extend({ | |
collectionType: null, | |
options: { | |
reverseRelation: { | |
type: "HasOne" | |
}, | |
collectionType: t.Collection, | |
collectionKey: !0, | |
collectionOptions: {} | |
}, | |
initialize: function(e) { | |
if (this.listenTo(this.instance, "relational:change:" + this.key, this.onChange), this.collectionType = this.options.collectionType, !n.isFunction(this.collectionType) || this.collectionType === t.Collection || this.collectionType.prototype instanceof t.Collection || (this.collectionType = n.result(this, "collectionType")), n.isString(this.collectionType) && (this.collectionType = t.Relational.store.getObjectByName(this.collectionType)), this.collectionType !== t.Collection && !(this.collectionType.prototype instanceof t.Collection)) throw new Error("`collectionType` must inherit from Backbone.Collection"); | |
var i = this.findRelated(e); | |
this.setRelated(i) | |
}, | |
_prepareCollection: function(e) { | |
if (this.related && this.stopListening(this.related), !(e && e instanceof t.Collection)) { | |
var i = n.isFunction(this.options.collectionOptions) ? this.options.collectionOptions(this.instance) : this.options.collectionOptions; | |
e = new this.collectionType(null, i) | |
} | |
if (e.model = this.relatedModel, this.options.collectionKey) { | |
var r = this.options.collectionKey === !0 ? this.options.reverseRelation.key : this.options.collectionKey; | |
e[r] && e[r] !== this.instance ? t.Relational.showWarnings && "undefined" != typeof console && console.warn("Relation=%o; collectionKey=%s already exists on collection=%o", this, r, this.options.collectionKey) : r && (e[r] = this.instance) | |
} | |
return this.listenTo(e, "relational:add", this.handleAddition).listenTo(e, "relational:remove", this.handleRemoval).listenTo(e, "relational:reset", this.handleReset), e | |
}, | |
findRelated: function(e) { | |
var i = null; | |
if (e = n.defaults({ | |
parse: this.options.parse | |
}, e), this.keyContents instanceof t.Collection) this._prepareCollection(this.keyContents), i = this.keyContents; | |
else { | |
var r = []; | |
n.each(this.keyContents, function(t) { | |
if (t instanceof this.relatedModel) var i = t; | |
else i = this.relatedModel.findOrCreate(t, n.extend({ | |
merge: !0 | |
}, e, { | |
create: this.options.createModels | |
})); | |
i && r.push(i) | |
}, this), i = this.related instanceof t.Collection ? this.related : this._prepareCollection(), i.set(r, n.defaults({ | |
merge: !1, | |
parse: !1 | |
}, e)) | |
} | |
return this.keyIds = n.difference(this.keyIds, n.pluck(i.models, "id")), i | |
}, | |
setKeyContents: function(e) { | |
this.keyContents = e instanceof t.Collection ? e : null, this.keyIds = [], this.keyContents || !e && 0 !== e || (this.keyContents = n.isArray(e) ? e : [e], n.each(this.keyContents, function(e) { | |
var n = t.Relational.store.resolveIdForItem(this.relatedModel, e); | |
(n || 0 === n) && this.keyIds.push(n) | |
}, this)) | |
}, | |
onChange: function(e, i, r) { | |
r = r ? n.clone(r) : {}, this.setKeyContents(i), this.changed = !1; | |
var o = this.findRelated(r); | |
if (this.setRelated(o), !r.silent) { | |
var a = this; | |
t.Relational.eventQueue.add(function() { | |
a.changed && (a.instance.trigger("change:" + a.key, a.instance, a.related, r, !0), a.changed = !1) | |
}) | |
} | |
}, | |
handleAddition: function(e, i, r) { | |
r = r ? n.clone(r) : {}, this.changed = !0, n.each(this.getReverseRelations(e), function(e) { | |
e.addRelated(this.instance, r) | |
}, this); | |
var o = this; | |
!r.silent && t.Relational.eventQueue.add(function() { | |
o.instance.trigger("add:" + o.key, e, o.related, r) | |
}) | |
}, | |
handleRemoval: function(e, i, r) { | |
r = r ? n.clone(r) : {}, this.changed = !0, n.each(this.getReverseRelations(e), function(e) { | |
e.removeRelated(this.instance, null, r) | |
}, this); | |
var o = this; | |
!r.silent && t.Relational.eventQueue.add(function() { | |
o.instance.trigger("remove:" + o.key, e, o.related, r) | |
}) | |
}, | |
handleReset: function(e, i) { | |
var r = this; | |
i = i ? n.clone(i) : {}, !i.silent && t.Relational.eventQueue.add(function() { | |
r.instance.trigger("reset:" + r.key, r.related, i) | |
}) | |
}, | |
tryAddRelated: function(e, t, i) { | |
var r = n.contains(this.keyIds, e.id); | |
r && (this.addRelated(e, i), this.keyIds = n.without(this.keyIds, e.id)) | |
}, | |
addRelated: function(e, t) { | |
var i = this; | |
e.queue(function() { | |
i.related && !i.related.get(e) && i.related.add(e, n.defaults({ | |
parse: !1 | |
}, t)) | |
}) | |
}, | |
removeRelated: function(e, t, n) { | |
this.related.get(e) && this.related.remove(e, n) | |
} | |
}), t.RelationalModel = t.Model.extend({ | |
relations: null, | |
_relations: null, | |
_isInitialized: !1, | |
_deferProcessing: !1, | |
_queue: null, | |
_attributeChangeFired: !1, | |
subModelTypeAttribute: "type", | |
subModelTypes: null, | |
constructor: function(e, i) { | |
if (i && i.collection) { | |
var r = this, | |
o = this.collection = i.collection; | |
delete i.collection, this._deferProcessing = !0; | |
var a = function(e) { | |
e === r && (r._deferProcessing = !1, r.processQueue(), o.off("relational:add", a)) | |
}; | |
o.on("relational:add", a), n.defer(function() { | |
a(r) | |
}) | |
} | |
t.Relational.store.processOrphanRelations(), t.Relational.store.listenTo(this, "relational:unregister", t.Relational.store.unregister), this._queue = new t.BlockingQueue, this._queue.block(), t.Relational.eventQueue.block(); | |
try { | |
t.Model.apply(this, arguments) | |
} finally { | |
t.Relational.eventQueue.unblock() | |
} | |
}, | |
trigger: function(e) { | |
if (e.length > 5 && 0 === e.indexOf("change")) { | |
var n = this, | |
i = arguments; | |
t.Relational.eventQueue.isLocked() ? t.Relational.eventQueue.add(function() { | |
var r = !0; | |
if ("change" === e) r = n.hasChanged() || n._attributeChangeFired, n._attributeChangeFired = !1; | |
else { | |
var o = e.slice(7), | |
a = n.getRelation(o); | |
a ? (r = i[4] === !0, r ? n.changed[o] = i[2] : a.changed || delete n.changed[o]) : r && (n._attributeChangeFired = !0) | |
} | |
r && t.Model.prototype.trigger.apply(n, i) | |
}) : t.Model.prototype.trigger.apply(n, i) | |
} else "destroy" === e ? (t.Model.prototype.trigger.apply(this, arguments), t.Relational.store.unregister(this)) : t.Model.prototype.trigger.apply(this, arguments); | |
return this | |
}, | |
initializeRelations: function(e) { | |
this.acquire(), this._relations = {}, n.each(this.relations || [], function(n) { | |
t.Relational.store.initializeRelation(this, n, e) | |
}, this), this._isInitialized = !0, this.release(), this.processQueue() | |
}, | |
updateRelations: function(e, t) { | |
this._isInitialized && !this.isLocked() && n.each(this._relations, function(n) { | |
if (!e || n.keySource in e || n.key in e) { | |
var i = this.attributes[n.keySource] || this.attributes[n.key], | |
r = e && (e[n.keySource] || e[n.key]); | |
(n.related !== i || null === i && null === r) && this.trigger("relational:change:" + n.key, this, i, t || {}) | |
} | |
n.keySource !== n.key && delete this.attributes[n.keySource] | |
}, this) | |
}, | |
queue: function(e) { | |
this._queue.add(e) | |
}, | |
processQueue: function() { | |
this._isInitialized && !this._deferProcessing && this._queue.isBlocked() && this._queue.unblock() | |
}, | |
getRelation: function(e) { | |
return this._relations[e] | |
}, | |
getRelations: function() { | |
return n.values(this._relations) | |
}, | |
fetchRelated: function(e, i, r) { | |
i = n.extend({ | |
update: !0, | |
remove: !1 | |
}, i); | |
var o, a, s = [], | |
l = this.getRelation(e), | |
u = l && (l.keyIds && l.keyIds.slice(0) || (l.keyId || 0 === l.keyId ? [l.keyId] : [])); | |
if (r && (o = l.related instanceof t.Collection ? l.related.models : [l.related], n.each(o, function(e) { | |
(e.id || 0 === e.id) && u.push(e.id) | |
})), u && u.length) { | |
var c = []; | |
if (o = n.map(u, function(e) { | |
var t = l.relatedModel.findModel(e); | |
if (!t) { | |
var n = {}; | |
n[l.relatedModel.prototype.idAttribute] = e, t = l.relatedModel.findOrCreate(n, i), c.push(t) | |
} | |
return t | |
}, this), l.related instanceof t.Collection && n.isFunction(l.related.url) && (a = l.related.url(o)), a && a !== l.related.url()) { | |
var d = n.defaults({ | |
error: function() { | |
var e = arguments; | |
n.each(c, function(t) { | |
t.trigger("destroy", t, t.collection, i), i.error && i.error.apply(t, e) | |
}) | |
}, | |
url: a | |
}, i); | |
s = [l.related.fetch(d)] | |
} else s = n.map(o, function(e) { | |
var t = n.defaults({ | |
error: function() { | |
n.contains(c, e) && (e.trigger("destroy", e, e.collection, i), i.error && i.error.apply(e, arguments)) | |
} | |
}, i); | |
return e.fetch(t) | |
}, this) | |
} | |
return s | |
}, | |
get: function(e) { | |
var i = t.Model.prototype.get.call(this, e); | |
if (!this.dotNotation || -1 === e.indexOf(".")) return i; | |
var r = e.split("."), | |
o = n.reduce(r, function(e, i) { | |
if (n.isNull(e) || n.isUndefined(e)) return void 0; | |
if (e instanceof t.Model) return t.Model.prototype.get.call(e, i); | |
if (e instanceof t.Collection) return t.Collection.prototype.at.call(e, i); | |
throw new Error("Attribute must be an instanceof Backbone.Model or Backbone.Collection. Is: " + e + ", currentSplit: " + i) | |
}, this); | |
if (void 0 !== i && void 0 !== o) throw new Error("Ambiguous result for '" + e + "'. direct result: " + i + ", dotNotation: " + o); | |
return i || o | |
}, | |
set: function(e, i, r) { | |
t.Relational.eventQueue.block(); | |
var o; | |
n.isObject(e) || null == e ? (o = e, r = i) : (o = {}, o[e] = i); | |
try { | |
var a = this.id, | |
s = o && this.idAttribute in o && o[this.idAttribute]; | |
t.Relational.store.checkId(this, s); | |
var l = t.Model.prototype.set.apply(this, arguments); | |
this._isInitialized || this.isLocked() ? s && s !== a && t.Relational.store.update(this) : (this.constructor.initializeModelHierarchy(), (s || 0 === s) && t.Relational.store.register(this), this.initializeRelations(r)), o && this.updateRelations(o, r) | |
} finally { | |
t.Relational.eventQueue.unblock() | |
} | |
return l | |
}, | |
clone: function() { | |
var e = n.clone(this.attributes); | |
return n.isUndefined(e[this.idAttribute]) || (e[this.idAttribute] = null), n.each(this.getRelations(), function(t) { | |
delete e[t.key] | |
}), new this.constructor(e) | |
}, | |
toJSON: function(e) { | |
if (this.isLocked()) return this.id; | |
this.acquire(); | |
var i = t.Model.prototype.toJSON.call(this, e); | |
return !this.constructor._superModel || this.constructor._subModelTypeAttribute in i || (i[this.constructor._subModelTypeAttribute] = this.constructor._subModelTypeValue), n.each(this._relations, function(r) { | |
var o = i[r.key], | |
a = r.options.includeInJSON, | |
s = null; | |
a === !0 ? o && n.isFunction(o.toJSON) && (s = o.toJSON(e)) : n.isString(a) ? (o instanceof t.Collection ? s = o.pluck(a) : o instanceof t.Model && (s = o.get(a)), a === r.relatedModel.prototype.idAttribute && (r instanceof t.HasMany ? s = s.concat(r.keyIds) : r instanceof t.HasOne && (s = s || r.keyId, s || n.isObject(r.keyContents) || (s = r.keyContents || null)))) : n.isArray(a) ? o instanceof t.Collection ? (s = [], o.each(function(e) { | |
var t = {}; | |
n.each(a, function(n) { | |
t[n] = e.get(n) | |
}), s.push(t) | |
})) : o instanceof t.Model && (s = {}, n.each(a, function(e) { | |
s[e] = o.get(e) | |
})) : delete i[r.key], a && (i[r.keyDestination] = s), r.keyDestination !== r.key && delete i[r.key] | |
}), this.release(), i | |
} | |
}, { | |
setup: function() { | |
return this.prototype.relations = (this.prototype.relations || []).slice(0), this._subModels = {}, this._superModel = null, this.prototype.hasOwnProperty("subModelTypes") ? t.Relational.store.addSubModels(this.prototype.subModelTypes, this) : this.prototype.subModelTypes = null, n.each(this.prototype.relations || [], function(e) { | |
if (e.model || (e.model = this), e.reverseRelation && e.model === this) { | |
var i = !0; | |
if (n.isString(e.relatedModel)) { | |
var r = t.Relational.store.getObjectByName(e.relatedModel); | |
i = r && r.prototype instanceof t.RelationalModel | |
} | |
i ? t.Relational.store.initializeRelation(null, e) : n.isString(e.relatedModel) && t.Relational.store.addOrphanRelation(e) | |
} | |
}, this), this | |
}, | |
build: function(e, t) { | |
this.initializeModelHierarchy(); | |
var n = this._findSubModelType(this, e) || this; | |
return new n(e, t) | |
}, | |
_findSubModelType: function(e, t) { | |
if (e._subModels && e.prototype.subModelTypeAttribute in t) { | |
var n = t[e.prototype.subModelTypeAttribute], | |
i = e._subModels[n]; | |
if (i) return i; | |
for (n in e._subModels) | |
if (i = this._findSubModelType(e._subModels[n], t)) return i | |
} | |
return null | |
}, | |
initializeModelHierarchy: function() { | |
if (this.inheritRelations(), this.prototype.subModelTypes) { | |
var e = n.keys(this._subModels), | |
i = n.omit(this.prototype.subModelTypes, e); | |
n.each(i, function(e) { | |
var n = t.Relational.store.getObjectByName(e); | |
n && n.initializeModelHierarchy() | |
}) | |
} | |
}, | |
inheritRelations: function() { | |
if (n.isUndefined(this._superModel) || n.isNull(this._superModel)) | |
if (t.Relational.store.setupSuperModel(this), this._superModel) { | |
if (this._superModel.inheritRelations(), this._superModel.prototype.relations) { | |
var e = n.filter(this._superModel.prototype.relations || [], function(e) { | |
return !n.any(this.prototype.relations || [], function(t) { | |
return e.relatedModel === t.relatedModel && e.key === t.key | |
}, this) | |
}, this); | |
this.prototype.relations = e.concat(this.prototype.relations) | |
} | |
} else this._superModel = !1 | |
}, | |
findOrCreate: function(e, t) { | |
t || (t = {}); | |
var i = n.isObject(e) && t.parse && this.prototype.parse ? this.prototype.parse(n.clone(e)) : e, | |
r = this.findModel(i); | |
return n.isObject(e) && (r && t.merge !== !1 ? (delete t.collection, delete t.url, r.set(i, t)) : r || t.create === !1 || (r = this.build(i, n.defaults({ | |
parse: !1 | |
}, t)))), r | |
}, | |
find: function(e, t) { | |
return t || (t = {}), t.create = !1, this.findOrCreate(e, t) | |
}, | |
findModel: function(e) { | |
return t.Relational.store.find(this, e) | |
} | |
}), n.extend(t.RelationalModel.prototype, t.Semaphore), t.Collection.prototype.__prepareModel = t.Collection.prototype._prepareModel, t.Collection.prototype._prepareModel = function(e, i) { | |
var r; | |
return e instanceof t.Model ? (e.collection || (e.collection = this), r = e) : (i = i ? n.clone(i) : {}, i.collection = this, r = "undefined" != typeof this.model.findOrCreate ? this.model.findOrCreate(e, i) : new this.model(e, i), r && r.validationError && (this.trigger("invalid", this, e, i), r = !1)), r | |
}; | |
var i = t.Collection.prototype.__set = t.Collection.prototype.set; | |
t.Collection.prototype.set = function(e, r) { | |
if (!(this.model.prototype instanceof t.RelationalModel)) return i.apply(this, arguments); | |
r && r.parse && (e = this.parse(e, r)); | |
var o = !n.isArray(e), | |
a = [], | |
s = []; | |
e = o ? e ? [e] : [] : n.clone(e), n.each(e, function(e) { | |
e instanceof t.Model || (e = t.Collection.prototype._prepareModel.call(this, e, r)), e && (s.push(e), this.get(e) || this.get(e.cid) ? null != e.id && (this._byId[e.id] = e) : a.push(e)) | |
}, this), s = o ? s.length ? s[0] : null : s; | |
var l = i.call(this, s, n.defaults({ | |
parse: !1 | |
}, r)); | |
return n.each(a, function(e) { | |
(this.get(e) || this.get(e.cid)) && this.trigger("relational:add", e, this, r) | |
}, this), l | |
}; | |
var r = t.Collection.prototype.__remove = t.Collection.prototype.remove; | |
t.Collection.prototype.remove = function(e, i) { | |
if (!(this.model.prototype instanceof t.RelationalModel)) return r.apply(this, arguments); | |
var o = !n.isArray(e), | |
a = []; | |
e = o ? e ? [e] : [] : n.clone(e), i || (i = {}), n.each(e, function(e) { | |
e = this.get(e) || e && this.get(e.cid), e && a.push(e) | |
}, this); | |
var s = r.call(this, o ? a.length ? a[0] : null : a, i); | |
return n.each(a, function(e) { | |
this.trigger("relational:remove", e, this, i) | |
}, this), s | |
}; | |
var o = t.Collection.prototype.__reset = t.Collection.prototype.reset; | |
t.Collection.prototype.reset = function(e, i) { | |
i = n.extend({ | |
merge: !0 | |
}, i); | |
var r = o.call(this, e, i); | |
return this.model.prototype instanceof t.RelationalModel && this.trigger("relational:reset", this, i), r | |
}; | |
var a = t.Collection.prototype.__sort = t.Collection.prototype.sort; | |
t.Collection.prototype.sort = function(e) { | |
var n = a.call(this, e); | |
return this.model.prototype instanceof t.RelationalModel && this.trigger("relational:reset", this, e), n | |
}; | |
var s = t.Collection.prototype.__trigger = t.Collection.prototype.trigger; | |
t.Collection.prototype.trigger = function(e) { | |
if (!(this.model.prototype instanceof t.RelationalModel)) return s.apply(this, arguments); | |
if ("add" === e || "remove" === e || "reset" === e || "sort" === e) { | |
var i = this, | |
r = arguments; | |
n.isObject(r[3]) && (r = n.toArray(r), r[3] = n.clone(r[3])), t.Relational.eventQueue.add(function() { | |
s.apply(i, r) | |
}) | |
} else s.apply(this, arguments); | |
return this | |
}, t.RelationalModel.extend = function() { | |
var e = t.Model.extend.apply(this, arguments); | |
return e.setup(this), e | |
} | |
}), | |
function() { | |
var e = {}.hasOwnProperty, | |
t = function(t, n) { | |
function i() { | |
this.constructor = t | |
} | |
for (var r in n) e.call(n, r) && (t[r] = n[r]); | |
return i.prototype = n.prototype, t.prototype = new i, t.__super__ = n.prototype, t | |
}; | |
di.provide("di.model.PaymentType"), di.model.PaymentType = function(e) { | |
function n() { | |
return n.__super__.constructor.apply(this, arguments) | |
} | |
return t(n, e), n.prototype.defaults = { | |
billable: null, | |
id: null, | |
key: null, | |
label: null, | |
legacy: null, | |
name: null, | |
require_address: null | |
}, n.prototype.parse = function(e) { | |
return null != e.payment_type && (e = e.payment_type), e | |
}, n | |
}(Backbone.RelationalModel) | |
}.call(this), | |
function() { | |
var e = {}.hasOwnProperty, | |
t = function(t, n) { | |
function i() { | |
this.constructor = t | |
} | |
for (var r in n) e.call(n, r) && (t[r] = n[r]); | |
return i.prototype = n.prototype, t.prototype = new i, t.__super__ = n.prototype, t | |
}; | |
di.provide("di.model.Plan"), di.model.Plan = function(e) { | |
function n() { | |
return n.__super__.constructor.apply(this, arguments) | |
} | |
return t(n, e), n.prototype.defaults = { | |
"active?": null, | |
allow_trial: null, | |
availability_ends_at: null, | |
availability_starts_at: null, | |
created_at: null, | |
id: null, | |
key: null, | |
name: null, | |
services: [], | |
trial_duration_days: null, | |
updated_at: null | |
}, n.prototype.parse = function(e) { | |
return null != e.plan && (e = e.plan), e | |
}, n | |
}(Backbone.RelationalModel) | |
}.call(this), | |
function() { | |
var e = {}.hasOwnProperty, | |
t = function(t, n) { | |
function i() { | |
this.constructor = t | |
} | |
for (var r in n) e.call(n, r) && (t[r] = n[r]); | |
return i.prototype = n.prototype, t.prototype = new i, t.__super__ = n.prototype, t | |
}; | |
di.provide("di.model.PaymentMethod"), di.model.PaymentMethod = function(e) { | |
function n() { | |
return n.__super__.constructor.apply(this, arguments) | |
} | |
return t(n, e), n.prototype.defaults = { | |
address: null, | |
city: null, | |
country: null, | |
description: null, | |
expires_at: null, | |
external_account_id: null, | |
external_client_id: null, | |
first_name: null, | |
id: null, | |
ident_hash: null, | |
iin: null, | |
last_name: null, | |
payment_type: {}, | |
payment_type_id: null, | |
postal_code: null, | |
state: null, | |
card_number: null, | |
card_type: null, | |
card_name: null | |
}, n.prototype.relations = [{ | |
type: "HasOne", | |
key: "payment_type", | |
relatedModel: di.model.PaymentType, | |
parse: !0 | |
}], n.prototype.parseDescription = function(e) { | |
var t, n, i; | |
switch (n = e.match(/[\d]+/).join("").trim(), t = e.match(/[a-zA-Z\s]+/).join("").trim(), i = t.toLowerCase().replace(/\s/gi, "_")) { | |
case "american_express": | |
n = "**** ****** *" + n; | |
break; | |
case "diners_club": | |
n = "**** **** **" + n.replace(/^(.{2})/, "$1 "); | |
break; | |
default: | |
n = "**** **** **** " + n | |
} | |
return { | |
cardNumber: n, | |
cardType: i, | |
cardName: t | |
} | |
}, n.prototype.parse = function(e) { | |
var t, n; | |
return "stripe" === (null != (n = e.payment_type) ? n.key : void 0) && (t = this.parseDescription(e.description), e.card_number = t.cardNumber, e.card_type = t.cardType, e.card_name = t.cardName), null != e.id && (e.is_new = !1), e | |
}, n | |
}(Backbone.RelationalModel) | |
}.call(this), | |
function() { | |
var e = {}.hasOwnProperty, | |
t = function(t, n) { | |
function i() { | |
this.constructor = t | |
} | |
for (var r in n) e.call(n, r) && (t[r] = n[r]); | |
return i.prototype = n.prototype, t.prototype = new i, t.__super__ = n.prototype, t | |
}; | |
di.provide("di.model.Subscription"), di.model.Subscription = function(e) { | |
function n() { | |
return n.__super__.constructor.apply(this, arguments) | |
} | |
return t(n, e), n.prototype.defaults = { | |
"active?": null, | |
auto_renew: null, | |
billable: null, | |
created_at: null, | |
currency: null, | |
expired_on: null, | |
first_purchase_at: null, | |
first_trial_at: null, | |
id: null, | |
member_id: null, | |
network_id: null, | |
payment_method: null, | |
payment_type: null, | |
payment_type_id: null, | |
payments: [], | |
plan: null, | |
plan_id: null, | |
plan_price: null, | |
price: null, | |
services: [], | |
starts_on: null, | |
status: null, | |
term_duration: null, | |
term_unit: null, | |
trial: null, | |
updated_at: null | |
}, n.prototype.relations = [{ | |
type: "HasOne", | |
key: "payment_type", | |
relatedModel: di.model.PaymentType, | |
parse: !0 | |
}, { | |
type: "HasOne", | |
key: "plan", | |
relatedModel: di.model.Plan, | |
parse: !0 | |
}, { | |
type: "HasOne", | |
key: "payment_method", | |
relatedModel: di.model.PaymentMethod, | |
parse: !0 | |
}], n.prototype.isTrial = function() { | |
var e; | |
return this.get("trial") && (null != (e = this.get("plan")) ? e.has("trial_duration_days") : void 0) | |
}, n | |
}(Backbone.RelationalModel) | |
}.call(this), | |
function() { | |
var e = {}.hasOwnProperty, | |
t = function(t, n) { | |
function i() { | |
this.constructor = t | |
} | |
for (var r in n) e.call(n, r) && (t[r] = n[r]); | |
return i.prototype = n.prototype, t.prototype = new i, t.__super__ = n.prototype, t | |
}; | |
di.provide("di.model.EmailCampaign"), di.model.EmailCampaign = function(e) { | |
function n() { | |
return n.__super__.constructor.apply(this, arguments) | |
} | |
return t(n, e), n.prototype.defaults = { | |
auto_opt_in: null, | |
created_at: null, | |
id: null, | |
key: null, | |
name: null, | |
network: null, | |
position: null, | |
sailthru_name: null, | |
updated_at: null | |
}, n | |
}(Backbone.RelationalModel) | |
}.call(this), | |
function() { | |
var e = {}.hasOwnProperty, | |
t = function(t, n) { | |
function i() { | |
this.constructor = t | |
} | |
for (var r in n) e.call(n, r) && (t[r] = n[r]); | |
return i.prototype = n.prototype, t.prototype = new i, t.__super__ = n.prototype, t | |
}; | |
di.provide("di.model.Member"), di.model.Member = function(e) { | |
function n() { | |
return n.__super__.constructor.apply(this, arguments) | |
} | |
return t(n, e), n.prototype.defaults = { | |
activated: null, | |
active: null, | |
amember_id: null, | |
api_key: null, | |
api_key_created_at: null, | |
avatar_url: null, | |
confirmation_token: null, | |
confirmed: null, | |
confirmed_at: null, | |
created_at: null, | |
delete_token: null, | |
email: null, | |
email_campaigns: [], | |
failed_login_count: null, | |
first_name: null, | |
fraudulent: null, | |
has_set_password: null, | |
id: null, | |
images: null, | |
last_login_attempt: null, | |
last_name: null, | |
listen_key: null, | |
locale: null, | |
network_favorite_channels: [], | |
network_id: null, | |
password_reset_token: null, | |
payment_method: null, | |
signup_country: null, | |
signup_ip_address: null, | |
subscriptions: [], | |
timezone: null, | |
tracking_code_id: null, | |
updated_at: null, | |
user_type: null, | |
webplayer_preferences: null | |
}, n.prototype.relations = [{ | |
type: "HasMany", | |
key: "subscriptions", | |
relatedModel: di.model.Subscription, | |
parse: !0 | |
}, { | |
type: "HasOne", | |
key: "payment_method", | |
relatedModel: di.model.PaymentMethod, | |
parse: !0 | |
}, { | |
type: "HasMany", | |
key: "email_campaigns", | |
relatedModel: di.model.EmailCampaign, | |
parse: !0 | |
}], n.prototype.isPremiumSubscriber = function() { | |
var e; | |
return e = this.get("subscriptions").find(function(e) { | |
return e.get("active?") | |
}), null != e | |
}, n | |
}(Backbone.RelationalModel) | |
}.call(this), | |
function() { | |
var e = {}.hasOwnProperty, | |
t = function(t, n) { | |
function i() { | |
this.constructor = t | |
} | |
for (var r in n) e.call(n, r) && (t[r] = n[r]); | |
return i.prototype = n.prototype, t.prototype = new i, t.__super__ = n.prototype, t | |
}; | |
di.provide("di.model.CurrentUser"), di.model.CurrentUser = function(e) { | |
function n() { | |
return n.__super__.constructor.apply(this, arguments) | |
} | |
return t(n, e), n.prototype.initialize = function() { | |
return di.app.reqres.setHandler("currentUser", function(e) { | |
return function() { | |
return e | |
} | |
}(this)) | |
}, n.prototype.currentSubscription = function() { | |
return this.get("subscriptions").findWhere({ | |
"active?": !0 | |
}) | |
}, n | |
}(di.model.Member) | |
}.call(this), | |
function() { | |
var e = {}.hasOwnProperty, | |
t = function(t, n) { | |
function i() { | |
this.constructor = t | |
} | |
for (var r in n) e.call(n, r) && (t[r] = n[r]); | |
return i.prototype = n.prototype, t.prototype = new i, t.__super__ = n.prototype, t | |
}; | |
di.provide("di.model.PlayerSettings"), di.model.PlayerSettings = function(e) { | |
function n() { | |
return n.__super__.constructor.apply(this, arguments) | |
} | |
return t(n, e), n.prototype.defaults = { | |
speed: "aac_medium", | |
wptype: "embedded", | |
player: "webplayer", | |
external_filetype: "aac", | |
external_channel_key: "favorites", | |
external_quality: "high", | |
hardware_channel_key: "", | |
hardware_quality: "premium" | |
}, n.prototype.initialize = function() { | |
return this.loadSettingsFromCookie() | |
}, n.prototype.loadSettingsFromCookie = function() { | |
var e, t, n, i, r; | |
i = this.defaults, r = []; | |
for (t in i) n = i[t], e = $.cookie(t), r.push(null != e ? this.set(t, e) : void 0); | |
return r | |
}, n.prototype.save = function() { | |
var e, t, n, i; | |
n = this.toJSON(), i = []; | |
for (e in n) t = n[e], i.push($.cookie(e, t, { | |
expires: 3650, | |
path: "/" | |
})); | |
return i | |
}, n | |
}(Backbone.RelationalModel) | |
}.call(this), | |
function() { | |
di.app.module("MemberApp", function(e, t, n, i, r, o) { | |
var a; | |
return a = i.Region.extend({ | |
el: "#member-content-region", | |
initialize: function() { | |
return this.listenTo(t, "member:navigate", o.bind(this.fadeOut, this)) | |
}, | |
onShow: function(e) { | |
return window.scrollTo(0, 0), null == e.hasTransitionedIn && (o.delay(function() { | |
return function() { | |
return e.$el.find(".transition-in").each(function(e, t) { | |
return o.delay(function() { | |
var e; | |
return e = r(t), e.addClass("visible") | |
}, 50 * e) | |
}) | |
} | |
}(this), 10), e.hasTransitionedIn = !0), e.listenTo(e, "render", function() { | |
return e.$el.find(".transition-in").each(function(e, t) { | |
return r(t).removeClass("transition-in") | |
}) | |
}) | |
}, | |
fadeOut: function() { | |
return this.$el.find(".transition-in").each(function(e, t) { | |
return o.delay(function() { | |
return r(t).removeClass("visible") | |
}, 50 * e) | |
}) | |
} | |
}), e.Controller = { | |
regions: { | |
memberHeaderRegion: "#member-header-region", | |
memberContentRegion: a | |
}, | |
views: { | |
profile: "Profile", | |
email_preferences: "EmailPreferences", | |
subscription: "Subscription", | |
"favorite/channels": "FavoriteChannels", | |
settings: "PlayerSettings" | |
}, | |
initialize: function(e) { | |
return this.models = e, this.disableWaitAnim(), this.setupRegions(), this.createHeader(), this.setupListeners(), this.showHeader(), this.navigate(location.pathname) | |
}, | |
disableWaitAnim: function() { | |
return t.execute("xhrpages:wait:disable") | |
}, | |
setupListeners: function() { | |
return this.models.state.on("change:section", function(e) { | |
return function(t, n) { | |
return e.showSection(n) | |
} | |
}(this)), r(window).on("statechange.memberapp", function(e) { | |
return function() { | |
return e.navigate(History.getState().url) | |
} | |
}(this)) | |
}, | |
setupRegions: function() { | |
return t.addRegions(this.regions) | |
}, | |
createHeader: function() { | |
return null != this.headerView ? this.headerView : this.headerView = new e.Views.Header({ | |
model: this.models.state | |
}) | |
}, | |
showHeader: function() { | |
return t.memberHeaderRegion.show(this.headerView) | |
}, | |
navigate: function(e) { | |
var t; | |
return null == location.origin && (location.origin = location.protocol + "//" + location.host), e = e.replace(location.origin, ""), t = e.match(e.indexOf("member") > -1 ? /\/member\/(.*)\/?/ : /\/(.*)\/?/), t = null != t ? t[1] : null, this.models.state.set({ | |
section: t, | |
section_path: e | |
}) | |
}, | |
showSection: function(n) { | |
var i, o, a; | |
return null == n && (n = "profile"), o = null != (a = this.views[n]) ? a : this.views.profile, i = new e.Views[o]({ | |
model: this.models.member | |
}), t.memberContentRegion.show(i), r(document.body).removeClass("wait") | |
}, | |
destroy: function() { | |
return this.removeListeners(), this.removeRegions(), this.enableWaitAnim(), this.headerView = null | |
}, | |
removeListeners: function() { | |
return this.models.state.off("change:section"), r(window).off("statechange.memberapp") | |
}, | |
removeRegions: function() { | |
var e, n, i, r; | |
i = this.regions, r = []; | |
for (e in i) n = i[e], t[e].empty(), r.push(t.removeRegion(e)); | |
return r | |
}, | |
enableWaitAnim: function() { | |
return t.execute("xhrpages:wait:enable") | |
} | |
} | |
}) | |
}.call(this), | |
function() { | |
di.app.module("MemberApp", function(e, t, n, i, r) { | |
var o, a, s; | |
return this.startWithParent = !1, s = "#member-header-region", a = "#member-content-region", o = { | |
models: {}, | |
initialize: function(t) { | |
var i, o, a, s, l; | |
if (null != t.paypal_response && null != (null != (s = window.opener) ? s.onPayPalResponse : void 0)) return window.opener.onPayPalResponse(t.paypal_response, t.payment_method), void window.close(); | |
for (null == t && (t = {}), r("#page-wrap").addClass("member-account"), t.member.payment_method = t.payment_method, this.models.member = di.model.CurrentUser.findOrCreate(t.member, { | |
parse: !0 | |
}), this.models.state = new n.Model({ | |
section: "", | |
section_path: "" | |
}), di.model.Subscription.findOrCreate(t.subscription, { | |
parse: !0 | |
}), l = t.email_campaigns, o = 0, a = l.length; a > o; o++) i = l[o], di.model.EmailCampaign.findOrCreate(i, { | |
parse: !0 | |
}); | |
return e.Controller.initialize(this.models) | |
}, | |
finalize: function() { | |
return e.Controller.destroy(), r("#page-wrap").removeClass("member-account") | |
} | |
}, e.addInitializer(function(e) { | |
return o.initialize(e) | |
}), e.addFinalizer(function() { | |
return o.finalize() | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("MemberApp.Views", function(e, t, n, i) { | |
return e.BaseMemberView = i.ItemView.extend({}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("MemberApp.Views", function(e, t, n, i, r, o) { | |
var a; | |
return a = { | |
"default": { | |
"class": "" | |
}, | |
submitting: { | |
"class": "submitting", | |
message: "Updating your Email Preferences" | |
}, | |
success: { | |
"class": "success", | |
message: '<i class="icon-check-circle"></i> Your Email Preferences have been updated.' | |
} | |
}, e.EmailPreferences = i.ItemView.extend({ | |
id: "member-email-preferences", | |
template: "di/ui/member/email_preferences", | |
ui: { | |
form: ".email-preferences-form" | |
}, | |
events: { | |
"ajax:beforeSend @ui.form": "ajaxSending", | |
"ajax:error @ui.form": "ajaxError", | |
"ajax:success @ui.form": "ajaxSuccess" | |
}, | |
modelEvents: { | |
change: "render" | |
}, | |
templateHelpers: function() { | |
return { | |
emailCampaigns: function() { | |
var e; | |
return e = n.Relational.store.getCollection(di.model.EmailCampaign).models, e = o.filter(e, function(e) { | |
return e.get("network").key === t.options.network_key | |
}), o.map(e, function(e) { | |
return e.attributes | |
}) | |
}, | |
subscribedTo: function(e) { | |
var t; | |
return t = o.map(this.email_campaigns, function(e) { | |
return e.id | |
}), t.indexOf(e.id) > -1 | |
} | |
} | |
}, | |
ajaxSending: function() { | |
return this.setState("submitting", this.ui.form) | |
}, | |
ajaxError: function() { | |
return this.setState("default", this.ui.form) | |
}, | |
ajaxSuccess: function(e, t) { | |
return this.setState("success", this.ui.form), this.model.set("email_campaigns", t.result.email_campaigns, { | |
parse: !0, | |
silent: !0 | |
}), o.delay(function(e) { | |
return function() { | |
return e.setState("default"), e.model.trigger("change") | |
} | |
}(this), 3e3) | |
}, | |
setState: function(e, t) { | |
var n, i, r, o; | |
return null == t && (t = this.$el), e.indexOf(".") > -1 && (o = e.split("."), e = o[0], r = o[1]), n = t.find("#status-msg"), i = a[e], null != r && (i = i[r]), t.attr("data-state", e), null != i.message && n.html("<p>" + i.message + "</p>"), n.attr("class", i["class"]) | |
} | |
}) | |
}) | |
}.call(this), | |
function(e) { | |
"use strict"; | |
"function" == typeof define && define.amd ? define(e) : "undefined" != typeof module && "undefined" != typeof module.exports ? module.exports = e() : window.Sortable = e() | |
}(function() { | |
"use strict"; | |
function e(e, n) { | |
this.el = e, this.options = n = n || {}; | |
var i = { | |
group: Math.random(), | |
store: null, | |
handle: null, | |
draggable: e.children[0] && e.children[0].nodeName || (/[uo]l/i.test(e.nodeName) ? "li" : "*"), | |
ghostClass: "sortable-ghost", | |
ignore: "a, img", | |
filter: null | |
}; | |
for (var o in i) n[o] = n[o] || i[o]; | |
I.forEach(function(i) { | |
n[i] = t(this, n[i] || F), r(e, i.substr(2).toLowerCase(), n[i]) | |
}, this), e[k] = n.group; | |
for (var a in this) "_" === a.charAt(0) && (this[a] = t(this, this[a])); | |
r(e, "mousedown", this._onTapStart), r(e, "touchstart", this._onTapStart), T && r(e, "selectstart", this._onTapStart), r(e, "dragover", this._onDragOver), r(e, "dragenter", this._onDragOver), R.push(this._onDragOver), n.store && this.sort(n.store.get(this)) | |
} | |
function t(e, t) { | |
var n = O.call(arguments, 2); | |
return t.bind ? t.bind.apply(t, [e].concat(n)) : function() { | |
return t.apply(e, n.concat(O.call(arguments))) | |
} | |
} | |
function n(e, t, n) { | |
if ("*" === t) return e; | |
if (e) { | |
n = n || A, t = t.split("."); | |
var i = t.shift().toUpperCase(), | |
r = new RegExp("\\s(" + t.join("|") + ")\\s", "g"); | |
do | |
if (!("" !== i && e.nodeName != i || t.length && ((" " + e.className + " ").match(r) || []).length != t.length)) return e; | |
while (e !== n && (e = e.parentNode)) | |
} | |
return null | |
} | |
function i(e) { | |
e.dataTransfer.dropEffect = "move", e.preventDefault() | |
} | |
function r(e, t, n) { | |
e.addEventListener(t, n, !1) | |
} | |
function o(e, t, n) { | |
e.removeEventListener(t, n, !1) | |
} | |
function a(e, t, n) { | |
if (e) | |
if (e.classList) e.classList[n ? "add" : "remove"](t); | |
else { | |
var i = (" " + e.className + " ").replace(/\s+/g, " ").replace(" " + t + " ", ""); | |
e.className = i + (n ? " " + t : "") | |
} | |
} | |
function s(e, t, n) { | |
if (e && e.style) { | |
if (void 0 === n) return A.defaultView && A.defaultView.getComputedStyle ? n = A.defaultView.getComputedStyle(e, "") : e.currentStyle && (n = e.currentStyle), void 0 === t ? n : n[t]; | |
e.style[t] = n + ("string" == typeof n ? "" : "px") | |
} | |
} | |
function l(e, t, n) { | |
if (e) { | |
var i = e.getElementsByTagName(t), | |
r = 0, | |
o = i.length; | |
if (n) | |
for (; o > r; r++) n(i[r], r); | |
return i | |
} | |
return [] | |
} | |
function u(e) { | |
return e.draggable = !1 | |
} | |
function c() { | |
P = !1 | |
} | |
function d(e, t) { | |
var n = e.lastElementChild.getBoundingClientRect(); | |
return t.clientY - (n.top + n.height) > 5 | |
} | |
function h(e) { | |
for (var t = e.tagName + e.className + e.src + e.href + e.textContent, n = t.length, i = 0; n--;) i += t.charCodeAt(n); | |
return i.toString(36) | |
} | |
var p, f, m, g, y, v, _, b, w, x, k = "Sortable" + (new Date).getTime(), | |
C = window, | |
A = C.document, | |
S = C.parseInt, | |
T = !!A.createElement("div").dragDrop, | |
P = !1, | |
M = function(e, t) { | |
var n = A.createEvent("Event"); | |
return n.initEvent(e, !0, !0), n.item = t, n | |
}, | |
E = function(e, t, n) { | |
e.dispatchEvent(M(t, n || e)) | |
}, | |
I = "onAdd onUpdate onRemove onStart onEnd onFilter".split(" "), | |
F = function() {}, | |
O = [].slice, | |
R = []; | |
return e.prototype = { | |
constructor: e, | |
_applyEffects: function() { | |
a(p, this.options.ghostClass, !0) | |
}, | |
_onTapStart: function(e) { | |
var t = e.touches && e.touches[0], | |
o = (t || e).target, | |
a = this.options, | |
s = this.el, | |
c = a.filter; | |
if ("mousedown" !== e.type || 0 === e.button) { | |
if ("function" == typeof c) { | |
if (c.call(this, o, this)) return void E(s, "filter", o) | |
} else if (c && (c = c.split(",").filter(function(e) { | |
return n(o, e.trim(), s) | |
}), c.length)) return void E(s, "filter", o); | |
if (a.handle && (o = n(o, a.handle, s)), o = n(o, a.draggable, s), o && "selectstart" == e.type && "A" != o.tagName && "IMG" != o.tagName && o.dragDrop(), o && !p && o.parentNode === s) { | |
w = e, m = this.el, p = o, g = p.nextSibling, b = this.options.group, p.draggable = !0, a.ignore.split(",").forEach(function(e) { | |
l(o, e.trim(), u) | |
}), t && (w = { | |
target: o, | |
clientX: t.clientX, | |
clientY: t.clientY | |
}, this._onDragStart(w, !0), e.preventDefault()), r(A, "mouseup", this._onDrop), r(A, "touchend", this._onDrop), r(A, "touchcancel", this._onDrop), r(this.el, "dragstart", this._onDragStart), r(this.el, "dragend", this._onDrop), r(A, "dragover", i); | |
try { | |
A.selection ? A.selection.empty() : window.getSelection().removeAllRanges() | |
} catch (d) {} | |
E(p, "start") | |
} | |
} | |
}, | |
_emulateDragOver: function() { | |
if (x) { | |
s(f, "display", "none"); | |
var e = A.elementFromPoint(x.clientX, x.clientY), | |
t = e, | |
n = this.options.group, | |
i = R.length; | |
if (t) | |
do { | |
if (t[k] === n) { | |
for (; i--;) R[i]({ | |
clientX: x.clientX, | |
clientY: x.clientY, | |
target: e, | |
rootEl: t | |
}); | |
break | |
} | |
e = t | |
} while (t = t.parentNode); | |
s(f, "display", "") | |
} | |
}, | |
_onTouchMove: function(e) { | |
if (w) { | |
var t = e.touches[0], | |
n = t.clientX - w.clientX, | |
i = t.clientY - w.clientY, | |
r = "translate3d(" + n + "px," + i + "px,0)"; | |
x = t, s(f, "webkitTransform", r), s(f, "mozTransform", r), s(f, "msTransform", r), s(f, "transform", r), e.preventDefault() | |
} | |
}, | |
_onDragStart: function(e, t) { | |
var n = e.dataTransfer; | |
if (this._offUpEvents(), t) { | |
var i, o = p.getBoundingClientRect(), | |
a = s(p); | |
f = p.cloneNode(!0), s(f, "top", o.top - S(a.marginTop, 10)), s(f, "left", o.left - S(a.marginLeft, 10)), s(f, "width", o.width), s(f, "height", o.height), s(f, "opacity", "0.8"), s(f, "position", "fixed"), s(f, "zIndex", "100000"), m.appendChild(f), i = f.getBoundingClientRect(), s(f, "width", 2 * o.width - i.width), s(f, "height", 2 * o.height - i.height), r(A, "touchmove", this._onTouchMove), r(A, "touchend", this._onDrop), r(A, "touchcancel", this._onDrop), this._loopId = setInterval(this._emulateDragOver, 150) | |
} else n.effectAllowed = "move", n.setData("Text", p.textContent), r(A, "drop", this._onDrop); | |
setTimeout(this._applyEffects) | |
}, | |
_onDragOver: function(e) { | |
if (!P && b === this.options.group && (void 0 === e.rootEl || e.rootEl === this.el)) { | |
var t = this.el, | |
i = n(e.target, this.options.draggable, t); | |
if (0 === t.children.length || t.children[0] === f || t === e.target && d(t, e)) t.appendChild(p); | |
else if (i && i !== p && void 0 !== i.parentNode[k]) { | |
y !== i && (y = i, v = s(i), _ = i.getBoundingClientRect()); | |
var r, o = _, | |
a = o.right - o.left, | |
l = o.bottom - o.top, | |
u = /left|right|inline/.test(v.cssFloat + v.display), | |
h = i.offsetWidth > p.offsetWidth, | |
m = i.offsetHeight > p.offsetHeight, | |
g = (u ? (e.clientX - o.left) / a : (e.clientY - o.top) / l) > .5, | |
w = i.nextElementSibling; | |
P = !0, setTimeout(c, 30), r = u ? i.previousElementSibling === p && !h || g && h : w !== p && !m || g && m, r && !w ? t.appendChild(p) : i.parentNode.insertBefore(p, r ? w : i) | |
} | |
} | |
}, | |
_offUpEvents: function() { | |
o(A, "mouseup", this._onDrop), o(A, "touchmove", this._onTouchMove), o(A, "touchend", this._onDrop), o(A, "touchcancel", this._onDrop) | |
}, | |
_onDrop: function(e) { | |
clearInterval(this._loopId), o(A, "drop", this._onDrop), o(A, "dragover", i), o(this.el, "dragend", this._onDrop), o(this.el, "dragstart", this._onDragStart), o(this.el, "selectstart", this._onTapStart), this._offUpEvents(), e && (e.preventDefault(), e.stopPropagation(), f && f.parentNode.removeChild(f), p && (u(p), a(p, this.options.ghostClass, !1), m.contains(p) ? p.nextSibling !== g && E(p, "update") : (E(m, "remove", p), E(p, "add")), E(p, "end")), m = p = f = g = w = x = y = v = b = null, this.options.store && this.options.store.set(this)) | |
}, | |
toArray: function() { | |
for (var e, t = [], i = this.el.children, r = 0, o = i.length; o > r; r++) e = i[r], n(e, this.options.draggable, this.el) && t.push(e.getAttribute("data-id") || h(e)); | |
return t | |
}, | |
sort: function(e) { | |
var t = {}, | |
i = this.el; | |
this.toArray().forEach(function(e, r) { | |
var o = i.children[r]; | |
n(o, this.options.draggable, i) && (t[e] = o) | |
}, this), e.forEach(function(e) { | |
t[e] && (i.removeChild(t[e]), i.appendChild(t[e])) | |
}) | |
}, | |
closest: function(e, t) { | |
return n(e, t || this.options.draggable, this.el) | |
}, | |
destroy: function() { | |
var e = this.el, | |
t = this.options; | |
I.forEach(function(n) { | |
o(e, n.substr(2).toLowerCase(), t[n]) | |
}), o(e, "mousedown", this._onTapStart), o(e, "touchstart", this._onTapStart), o(e, "selectstart", this._onTapStart), o(e, "dragover", this._onDragOver), o(e, "dragenter", this._onDragOver), Array.prototype.forEach.call(e.querySelectorAll("[draggable]"), function(e) { | |
e.removeAttribute("draggable") | |
}), R.splice(R.indexOf(this._onDragOver), 1), this._onDrop(), this.el = null | |
} | |
}, e.utils = { | |
on: r, | |
off: o, | |
css: s, | |
find: l, | |
bind: t, | |
closest: n, | |
toggleClass: a, | |
createEvent: M, | |
dispatchEvent: E | |
}, e.version = "0.5.2", e | |
}), | |
function() { | |
di.app.module("MemberApp.Views", function(e, t, n, i, r, o) { | |
var a; | |
return a = "#webplayer-region", e.EmptyView = i.ItemView.extend({ | |
tagName: "li", | |
className: "drag-channels-msg", | |
message: "Drag any channels here to favorite them", | |
render: function() { | |
return this.$el.text(this.message) | |
} | |
}), e.ChannelItemView = i.ItemView.extend({ | |
tagName: "li", | |
className: "channel-item", | |
template: "di/ui/member/favorite_channels_list_item", | |
modelEvents: { | |
"change:favorite_position": "render" | |
}, | |
onRender: function() { | |
return this.$el.data("id", this.model.get("id")) | |
}, | |
templateHelpers: { | |
channelArt: function() { | |
return AudioAddict.UI.img_uri(this, { | |
size: "36x36" | |
}) | |
} | |
}, | |
serializeData: function(e) { | |
return e = this.model.toJSON(), null == e.favorite_position && (e.favorite_position = null), e | |
} | |
}), e.ChannelListView = i.CollectionView.extend({ | |
template: "di/ui/member/favorite_channels_list", | |
tagName: "ol", | |
childView: e.ChannelItemView, | |
emptyView: e.EmptyView, | |
className: function() { | |
return "channel-list " + this.options.listType | |
}, | |
events: { | |
add: "onSortItemAdded", | |
update: "onSortOrderUpdated" | |
}, | |
saveChanges: function() { | |
return t.commands.execute("favorites:save") | |
}, | |
onSortItemAdded: function(e) { | |
var t, n; | |
return n = this.options.otherCollection.get(r(e.target).data("id")), t = r(e.target).index(), this.options.otherCollection.remove(n), this.collection.add(n, { | |
at: t | |
}), "favorites" === this.options.listType ? this.collection.each(function(e, t) { | |
return e.set({ | |
favorite: !0, | |
favorite_position: t | |
}) | |
}) : (n.set({ | |
favorite: !1, | |
favorite_position: null | |
}), this.options.otherCollection.each(function(e, t) { | |
return e.set({ | |
favorite_position: t | |
}) | |
})), this.saveChanges() | |
}, | |
onSortOrderUpdated: function(e) { | |
var t, n; | |
return "favorites" === this.options.listType ? (n = this.collection.get(r(e.target).data("id")), t = r(e.target).index(), this.collection.remove(n), this.collection.add(n, { | |
at: t | |
}), this.collection.each(function(e, t) { | |
return e.set({ | |
favorite_position: t | |
}) | |
}), this.saveChanges()) : void 0 | |
}, | |
onBeforeRender: function() { | |
var e; | |
return null != (e = this.sortable) && e.destroy(), this.sortable = new Sortable(this.el, { | |
group: "channels", | |
filter: ".drag-channels-msg" | |
}) | |
} | |
}), e.FavoriteChannels = i.LayoutView.extend({ | |
id: "member-favorite-channels", | |
template: "di/ui/member/favorite_channels", | |
regions: { | |
favoriteChannelsRegion: ".favorite-channels .region", | |
availableChannelsRegion: ".available-channels .region" | |
}, | |
ui: { | |
favoritesColumn: ".favorite-channels", | |
availableColumn: ".available-channels", | |
emptyMessage: ".drag-channels-msg" | |
}, | |
initialize: function() { | |
return this.initViewStateModel(), this.initCollections() | |
}, | |
initViewStateModel: function() { | |
return this.viewStateModel = new n.Model({ | |
position: "default" | |
}), this.listenTo(this.viewStateModel, "change:position", o.bind(this.onViewStateModelChanged, this)) | |
}, | |
initCollections: function() { | |
return this.allChannels = t.request("channel:entities"), this.listenTo(this.allChannels, "change:favorite", o.bind(this.onFavoriteChanged, this)), this.favoritesCollection = new n.Collection(this.allChannels.where({ | |
favorite: !0 | |
})), this.favoritesCollection.comparator = "favorite_position", this.favoritesCollection.sort(), this.availableCollection = new n.Collection(this.allChannels.where({ | |
favorite: !1 | |
})) | |
}, | |
onBeforeShow: function() { | |
return this.favoriteChannelsRegion.show(new e.ChannelListView({ | |
collection: this.favoritesCollection, | |
otherCollection: this.availableCollection, | |
listType: "favorites" | |
})), this.availableChannelsRegion.show(new e.ChannelListView({ | |
collection: this.availableCollection, | |
otherCollection: this.favoritesCollection, | |
listType: "available" | |
})), this.ui.favoritesList = this.favoriteChannelsRegion.currentView.$el | |
}, | |
onShow: function() { | |
return r(window).on({ | |
"scroll.favoriteChannels": o.throttle(o.bind(this.checkScrollPosition, this), 100), | |
"resize.favoriteChannels": o.throttle(o.bind(this.checkFavoritesMaxHeight, this), 100) | |
}), this.checkScrollPosition() | |
}, | |
onFavoriteChanged: function(e, t) { | |
return t ? -1 === this.favoritesCollection.indexOf(e) && (this.favoritesCollection.add(e, { | |
at: 0 | |
}), this.availableCollection.remove(e)) : -1 === this.availableCollection.indexOf(e) && (this.availableCollection.add(e), this.favoritesCollection.remove(e)), this.checkFavoritesMaxHeight() | |
}, | |
checkFavoritesMaxHeight: function() { | |
var e, t; | |
if (!(this.ui.favoritesColumn.height() > this.ui.availableColumn.height())) return this.heightAdjust || (this.ui.window = r(window), this.heightAdjust = 30, this.heightAdjust = this.ui.favoritesColumn.find(".column-title").outerHeight(), this.heightAdjust += parseInt(this.ui.favoritesList.css("padding-top")), this.heightAdjust += parseInt(this.ui.favoritesList.css("padding-bottom")), this.heightAdjust += r(a).height()), t = this.ui.window.height() - this.heightAdjust, e = this.favoriteChannelsRegion.currentView.$el.height(), e >= t && "default" !== this.viewStateModel.get("position") ? this.ui.favoritesList.css({ | |
maxHeight: t | |
}).perfectScrollbar({ | |
suppressScrollX: !0 | |
}).addClass("with-scrollbar") : this.ui.favoritesList.css({ | |
maxHeight: "" | |
}).perfectScrollbar("destroy").removeClass("with-scrollbar") | |
}, | |
checkScrollPosition: function() { | |
var e, t, n, i, o; | |
return o = r(window).scrollTop(), t = this.ui.availableColumn.offset(), t.bottom = t.top + this.ui.availableColumn.outerHeight(), n = this.ui.favoritesColumn.outerHeight() + 10, e = this.ui.availableColumn.height(), i = this.ui.favoritesColumn.height(), o >= t.top && e > i ? o + n >= t.bottom ? this.viewStateModel.set("position", "fixed-bottom") : this.viewStateModel.set("position", "fixed-top") : this.viewStateModel.set("position", "default") | |
}, | |
onViewStateModelChanged: function(e, t) { | |
var n, i, r, o; | |
switch (t) { | |
case "fixed-top": | |
this.ui.favoritesColumn.css({ | |
left: this.ui.favoritesColumn.offset().left, | |
width: this.ui.favoritesColumn.width() | |
}); | |
break; | |
case "fixed-bottom": | |
case "default": | |
this.ui.favoritesColumn.css({ | |
width: "", | |
left: "" | |
}) | |
} | |
for (o = ["fixed-top", "fixed-bottom", "default"], i = 0, r = o.length; r > i; i++) n = o[i], this.ui.favoritesColumn.removeClass(n); | |
return this.ui.favoritesColumn.addClass(t), this.checkFavoritesMaxHeight() | |
}, | |
onBeforeDestroy: function() { | |
return this.ui.favoritesList.perfectScrollbar("destroy"), r(window).off(".favoriteChannels") | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("MemberApp.Views", function(e, t, n, i, r, o) { | |
return e.Header = i.ItemView.extend({ | |
id: "member-header", | |
template: "di/ui/member/header", | |
modelEvents: { | |
"change:section_path": "setActiveNavOnModelChange" | |
}, | |
ui: { | |
nav: ".member-header-nav" | |
}, | |
events: { | |
"click @ui.nav a[href]": "setActiveNavOnClick" | |
}, | |
onShow: function() { | |
return o.delay(function(e) { | |
return function() { | |
return e.$el.addClass("show") | |
} | |
}(this), 100) | |
}, | |
setActiveNavOnModelChange: function() { | |
return this.setActiveNav(this.model.get("section_path")) | |
}, | |
setActiveNavOnClick: function(e) { | |
return r(e.currentTarget).parent().is(".active") ? void e.preventDefault() : (this.setActiveNav(r(e.currentTarget).attr("href")), t.trigger("member:navigate")) | |
}, | |
setActiveNav: function(e) { | |
var t; | |
return this.ui.nav.find("li.active").removeClass("active"), t = this.$el.find('a[href="' + e + '"]').closest("li"), t.addClass("active") | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("MemberApp.Views", function(e, t, n, i, r, o) { | |
var a; | |
return a = new n.Model({}), e.PlayerSettings = e.BaseMemberView.extend({ | |
id: "member-player-settings", | |
template: "di/ui/member/player_settings", | |
ui: { | |
webplayerQualitySelect: "#webplayer-quality", | |
qualitySavedMsg: ".quality-saved-msg", | |
extenalFileTypRadios: 'input[name="external_filetype"]', | |
externalPlaylistContent: 'input[name="external_playlist_content"]', | |
externalChannelSelector: "#external-channel-selector", | |
externalQualitySelector: "#external-quality-selector", | |
downloadPlaylist: ".download-playlist", | |
hardwareChannelSelector: "#hardware-channel-selector", | |
hardwareQualitySelector: "#hardware-quality-selector", | |
listenKeyForm: ".listen-key-form", | |
listenKeyActions: ".listen-key-actions" | |
}, | |
events: { | |
"change @ui.webplayerQualitySelect": "updatePlayerQuality", | |
"change @ui.extenalFileTypRadios": "updateExternalFileType", | |
"change @ui.externalPlaylistContent": "updateExternalPlaylistContent", | |
"change @ui.externalChannelSelector": "updateExternalChannel", | |
"change @ui.externalQualitySelector": "updateExternalQuality", | |
"change @ui.hardwareChannelSelector": "updateHardwareChannel", | |
"change @ui.hardwareQualitySelector": "updateHardwareQuality", | |
"click @ui.downloadPlaylist": "downloadPlaylist", | |
"ajax:beforeSend @ui.listenKeyForm": "showListenKeySpinner", | |
"ajax:success @ui.listenKeyForm": "updateListenKey" | |
}, | |
modelEvents: { | |
change: "render" | |
}, | |
templateHelpers: { | |
streamSetConfigs: function(e) { | |
var n; | |
return null == e && (e = "webplayer"), n = t.request("streamSetConfig:entities", { | |
format_name: e | |
}), n.toJSON() | |
}, | |
channels: function() { | |
var e; | |
return e = t.request("channel:entities").toJSON(), e = o.sortBy(e, function(e) { | |
return e.name | |
}) | |
}, | |
hardwareServers: function() { | |
var e; | |
return e = t.request("playlists:entity", { | |
channel: this.hardware_channel_key, | |
quality: this.hardware_quality | |
}), e.get("servers").length || e.once("change:servers", function() { | |
return a.set("render", new Date) | |
}), e.get("servers") | |
}, | |
hardwarePlaylistUrl: function() { | |
var e, n, i; | |
return n = t.request("playlists:listen_url"), e = this.listenKey(), i = [n, this.hardware_quality, this.hardware_channel_key].join("/"), i += ".pls?listen_key=" + e | |
}, | |
listenKey: function() { | |
return t.request("currentUser").get("listen_key") | |
}, | |
listenKeyUpdated: function() { | |
var e; | |
return e = a.get("listen_key_updated"), a.set("listen_key_updated", !1), e | |
}, | |
isPremium: function() { | |
return null != t.request("currentUser").currentSubscription() | |
} | |
}, | |
initialize: function() { | |
return this.model = new di.model.PlayerSettings, this.listenTo(a, "change:render", o.bind(this.render, this)) | |
}, | |
onDomRefresh: function() { | |
return this.$el.find("select").each(function(e, t) { | |
var n, i; | |
return i = r(t), n = i.find("option"), i.chosen({ | |
disable_search_threshold: 10 | |
}), 1 === n.length ? i.next(".chzn-container").addClass("disabled") : void 0 | |
}) | |
}, | |
updatePlayerQuality: function(e) { | |
var t, n; | |
return t = r(e.currentTarget), n = t.val(), this.model.set("speed", n), this.model.save(), this.ui.qualitySavedMsg.addClass("visible"), o.delay(function(e) { | |
return function() { | |
return e.ui.qualitySavedMsg.removeClass("visible") | |
} | |
}(this), 3e3) | |
}, | |
updateExternalFileType: function(e) { | |
var t, n; | |
return t = r(e.currentTarget), n = t.val(), this.model.set("external_filetype", n) | |
}, | |
updateExternalPlaylistContent: function(e) { | |
var t, n; | |
return t = r(e.currentTarget), n = t.val(), "favorites" === n ? this.model.set("external_channel_key", "favorites") : this.model.set("external_channel_key", "") | |
}, | |
updateExternalChannel: function(e) { | |
var t, n; | |
return t = r(e.currentTarget), n = t.val(), this.model.set("external_channel_key", n) | |
}, | |
updateExternalQuality: function(e) { | |
var t, n; | |
return t = r(e.currentTarget), n = t.val(), this.model.set("external_quality", n) | |
}, | |
updateHardwareChannel: function(e) { | |
var t, n; | |
return t = r(e.currentTarget), n = t.val(), this.model.set("hardware_channel_key", n), this.model.save() | |
}, | |
updateHardwareQuality: function(e) { | |
var t, n; | |
return t = r(e.currentTarget), n = t.val(), this.model.set("hardware_quality", n), this.model.save() | |
}, | |
downloadPlaylist: function() { | |
var e, n, i, r; | |
return n = "/playlist?", e = t.request("currentUser"), i = e.isPremiumSubscriber() ? "premium" : "public", r = ["channel_key=" + this.model.get("external_channel_key"), "subscription=" + i, "file_type=" + this.model.get("external_filetype"), "quality=" + this.model.get("external_quality")], n += r.join("&"), window.open(n, "_blank"), this.model.save() | |
}, | |
showListenKeySpinner: function() { | |
return this.ui.listenKeyActions.attr("data-state", "submitting") | |
}, | |
updateListenKey: function(e, n) { | |
var i; | |
return i = t.request("currentUser"), i.set("listen_key", n.listen_key), a.set("listen_key_updated", !0), this.ui.listenKeyActions.attr("data-state", "success"), o.delay(function() { | |
return function() { | |
return a.set("render", new Date) | |
} | |
}(this), 1500) | |
}, | |
onBeforeDestroy: function() { | |
return this.$el.find("select").chosen("destroy") | |
} | |
}) | |
}) | |
}.call(this), | |
function(e) { | |
var t; | |
t = function() { | |
function e() {} | |
return e.prototype.setup = function(e, t, n, i) { | |
var r, o; | |
return null == n && (n = 1), o = t.w / e.w, r = t.h / e.h, this.minZoom = (null != i ? i.fitWidth : void 0) && !(null != i ? i.fitHeight : void 0) ? o : (null != i ? i.fitHeight : void 0) && !(null != i ? i.fitWidth : void 0) ? r : (null != i ? i.fitWidth : void 0) && (null != i ? i.fitHeight : void 0) ? r > o ? o : r : r > o ? r : o, this.maxZoom = this.minZoom < 1 / n ? 1 / n : this.minZoom | |
}, e.prototype.getZoom = function(e) { | |
return this.minZoom && this.maxZoom ? e * (this.maxZoom - this.minZoom) + this.minZoom : null | |
}, e.prototype.getSliderPos = function(e) { | |
return this.minZoom && this.maxZoom ? this.minZoom === this.maxZoom ? 0 : (e - this.minZoom) / (this.maxZoom - this.minZoom) : null | |
}, e.prototype.isZoomable = function() { | |
return this.minZoom && this.maxZoom ? this.minZoom !== this.maxZoom : null | |
}, e.prototype.fixZoom = function(e) { | |
return e < this.minZoom ? this.minZoom : e > this.maxZoom ? this.maxZoom : e | |
}, e | |
}(); | |
var n; | |
n = function() { | |
function n(t, i) { | |
var r; | |
this.element = t, this.$el = e(this.element), r = { | |
$fileInput: this.$("input.cropit-image-input"), | |
$preview: this.$(".cropit-image-preview"), | |
$zoomSlider: this.$("input.cropit-image-zoom-input"), | |
$previewContainer: this.$(".cropit-image-preview-container") | |
}, this.options = e.extend({}, n._DEFAULTS, r, i), this.init() | |
} | |
return n._DEFAULTS = { | |
exportZoom: 1, | |
imageBackground: !1, | |
imageBackgroundBorderWidth: 0, | |
imageState: null, | |
allowCrossOrigin: !1, | |
fitWidth: !1, | |
fitHeight: !1 | |
}, n.PREVIEW_EVENTS = function() { | |
return ["mousedown", "mouseup", "mouseleave", "touchstart", "touchend", "touchcancel", "touchleave"].map(function(e) { | |
return "" + e + ".cropit" | |
}).join(" ") | |
}(), n.PREVIEW_MOVE_EVENTS = "mousemove.cropit touchmove.cropit", n.ZOOM_INPUT_EVENTS = function() { | |
return ["mousemove", "touchmove", "change"].map(function(e) { | |
return "" + e + ".cropit" | |
}).join(" ") | |
}(), n.prototype.init = function() { | |
var n, i, r, o; | |
return this.image = new Image, this.options.allowCrossOrigin && (this.image.crossOrigin = "Anonymous"), this.$fileInput = this.options.$fileInput.attr({ | |
accept: "image/*" | |
}), this.$preview = this.options.$preview.css({ | |
backgroundRepeat: "no-repeat" | |
}), this.$zoomSlider = this.options.$zoomSlider.attr({ | |
min: 0, | |
max: 1, | |
step: .01 | |
}), this.previewSize = { | |
w: this.options.width || this.$preview.width(), | |
h: this.options.height || this.$preview.height() | |
}, this.options.width && this.$preview.width(this.previewSize.w), this.options.height && this.$preview.height(this.previewSize.h), this.options.imageBackground && (e.isArray(this.options.imageBackgroundBorderWidth) ? this.imageBgBorderWidthArray = this.options.imageBackgroundBorderWidth : (this.imageBgBorderWidthArray = [], [0, 1, 2, 3].forEach(function(e) { | |
return function(t) { | |
return e.imageBgBorderWidthArray[t] = e.options.imageBackgroundBorderWidth | |
} | |
}(this))), n = this.options.$previewContainer, this.$imageBg = e("<img />").addClass("cropit-image-background").attr("alt", "").css("position", "absolute"), this.$imageBgContainer = e("<div />").addClass("cropit-image-background-container").css({ | |
position: "absolute", | |
zIndex: 0, | |
left: -this.imageBgBorderWidthArray[3] + window.parseInt(this.$preview.css("border-left-width")), | |
top: -this.imageBgBorderWidthArray[0] + window.parseInt(this.$preview.css("border-top-width")), | |
width: this.previewSize.w + this.imageBgBorderWidthArray[1] + this.imageBgBorderWidthArray[3], | |
height: this.previewSize.h + this.imageBgBorderWidthArray[0] + this.imageBgBorderWidthArray[2] | |
}).append(this.$imageBg), this.imageBgBorderWidthArray[0] > 0 && this.$imageBgContainer.css({ | |
overflow: "hidden" | |
}), n.css("position", "relative").prepend(this.$imageBgContainer), this.$preview.css("position", "relative"), this.$preview.hover(function(e) { | |
return function() { | |
return e.$imageBg.addClass("cropit-preview-hovered") | |
} | |
}(this), function(e) { | |
return function() { | |
return e.$imageBg.removeClass("cropit-preview-hovered") | |
} | |
}(this))), this.initialOffset = { | |
x: 0, | |
y: 0 | |
}, this.initialZoom = 0, this.initialZoomSliderPos = 0, this.imageLoaded = !1, this.moveContinue = !1, this.zoomer = new t, this.bindListeners(), this.$zoomSlider.val(this.initialZoomSliderPos), this.setOffset((null != (i = this.options.imageState) ? i.offset : void 0) || this.initialOffset), this.zoom = (null != (r = this.options.imageState) ? r.zoom : void 0) || this.initialZoom, this.loadImage((null != (o = this.options.imageState) ? o.src : void 0) || null) | |
}, n.prototype.bindListeners = function() { | |
return this.$fileInput.on("change.cropit", this.onFileChange.bind(this)), this.$preview.on(n.PREVIEW_EVENTS, this.onPreviewEvent.bind(this)), this.$zoomSlider.on(n.ZOOM_INPUT_EVENTS, this.onZoomSliderChange.bind(this)) | |
}, n.prototype.unbindListeners = function() { | |
return this.$fileInput.off("change.cropit"), this.$preview.off(n.PREVIEW_EVENTS), this.$zoomSlider.off(n.ZOOM_INPUT_EVENTS) | |
}, n.prototype.reset = function() { | |
return this.zoom = this.initialZoom, this.offset = this.initialOffset | |
}, n.prototype.onFileChange = function() { | |
var e, t, n; | |
return "function" == typeof(n = this.options).onFileChange && n.onFileChange(), t = new FileReader, e = this.$fileInput.get(0).files[0], (null != e ? e.type.match("image") : void 0) ? (this.setImageLoadingClass(), t.readAsDataURL(e), t.onload = this.onFileReaderLoaded.bind(this), t.onerror = this.onFileReaderError.bind(this)) : void 0 | |
}, n.prototype.onFileReaderLoaded = function(e) { | |
return this.reset(), this.loadImage(e.target.result) | |
}, n.prototype.onFileReaderError = function() { | |
var e; | |
return "function" == typeof(e = this.options).onFileReaderError ? e.onFileReaderError() : void 0 | |
}, n.prototype.loadImage = function(e) { | |
var t; | |
return this.imageSrc = e, this.imageSrc ? ("function" == typeof(t = this.options).onImageLoading && t.onImageLoading(), this.setImageLoadingClass(), this.image.onload = this.onImageLoaded.bind(this), this.image.onerror = this.onImageError.bind(this), this.image.src = this.imageSrc) : void 0 | |
}, n.prototype.onImageLoaded = function() { | |
var e; | |
return this.setImageLoadedClass(), this.setOffset(this.offset), this.$preview.css("background-image", "url(" + this.imageSrc + ")"), this.options.imageBackground && this.$imageBg.attr("src", this.imageSrc), this.imageSize = { | |
w: this.image.width, | |
h: this.image.height | |
}, this.setupZoomer(), this.imageLoaded = !0, "function" == typeof(e = this.options).onImageLoaded ? e.onImageLoaded() : void 0 | |
}, n.prototype.onImageError = function() { | |
var e; | |
return "function" == typeof(e = this.options).onImageError ? e.onImageError() : void 0 | |
}, n.prototype.setImageLoadingClass = function() { | |
return this.$preview.removeClass("cropit-image-loaded").addClass("cropit-image-loading") | |
}, n.prototype.setImageLoadedClass = function() { | |
return this.$preview.removeClass("cropit-image-loading").addClass("cropit-image-loaded") | |
}, n.prototype.getEventPosition = function(e) { | |
var t, n, i, r; | |
return (null != (t = e.originalEvent) && null != (n = t.touches) ? n[0] : void 0) && (e = null != (i = e.originalEvent) && null != (r = i.touches) ? r[0] : void 0), e.clientX && e.clientY ? { | |
x: e.clientX, | |
y: e.clientY | |
} : void 0 | |
}, n.prototype.onPreviewEvent = function(t) { | |
return this.imageLoaded ? (this.moveContinue = !1, this.$preview.off(n.PREVIEW_MOVE_EVENTS), "mousedown" === t.type || "touchstart" === t.type ? (this.origin = this.getEventPosition(t), this.moveContinue = !0, this.$preview.on(n.PREVIEW_MOVE_EVENTS, this.onMove.bind(this))) : e(document.body).focus(), t.stopPropagation(), !1) : void 0 | |
}, n.prototype.onMove = function(e) { | |
var t; | |
return t = this.getEventPosition(e), this.moveContinue && t && this.setOffset({ | |
x: this.offset.x + t.x - this.origin.x, | |
y: this.offset.y + t.y - this.origin.y | |
}), this.origin = t, e.stopPropagation(), !1 | |
}, n.prototype.setOffset = function(e) { | |
return this.offset = this.fixOffset(e), this.$preview.css("background-position", "" + this.offset.x + "px " + this.offset.y + "px"), this.options.imageBackground ? this.$imageBg.css({ | |
left: this.offset.x + this.imageBgBorderWidthArray[3], | |
top: this.offset.y + this.imageBgBorderWidthArray[0] | |
}) : void 0 | |
}, n.prototype.fixOffset = function(e) { | |
var t; | |
return this.imageLoaded ? (t = { | |
x: e.x, | |
y: e.y | |
}, this.imageSize.w * this.zoom <= this.previewSize.w ? t.x = 0 : t.x > 0 ? t.x = 0 : t.x + this.imageSize.w * this.zoom < this.previewSize.w && (t.x = this.previewSize.w - this.imageSize.w * this.zoom), this.imageSize.h * this.zoom <= this.previewSize.h ? t.y = 0 : t.y > 0 ? t.y = 0 : t.y + this.imageSize.h * this.zoom < this.previewSize.h && (t.y = this.previewSize.h - this.imageSize.h * this.zoom), t.x = this.round(t.x), t.y = this.round(t.y), t) : e | |
}, n.prototype.onZoomSliderChange = function() { | |
var e; | |
if (this.imageLoaded) return this.zoomSliderPos = Number(this.$zoomSlider.val()), e = this.zoomer.getZoom(this.zoomSliderPos), this.setZoom(e) | |
}, n.prototype.enableZoomSlider = function() { | |
var e; | |
return this.$zoomSlider.removeAttr("disabled"), "function" == typeof(e = this.options).onZoomEnabled ? e.onZoomEnabled() : void 0 | |
}, n.prototype.disableZoomSlider = function() { | |
var e; | |
return this.$zoomSlider.attr("disabled", !0), "function" == typeof(e = this.options).onZoomDisabled ? e.onZoomDisabled() : void 0 | |
}, n.prototype.setupZoomer = function() { | |
return this.zoomer.setup(this.imageSize, this.previewSize, this.options.exportZoom, this.options), this.zoom = this.fixZoom(this.zoom), this.setZoom(this.zoom), this.isZoomable() ? this.enableZoomSlider() : this.disableZoomSlider() | |
}, n.prototype.setZoom = function(e) { | |
var t, n, i, r, o; | |
return e = this.fixZoom(e), o = this.round(this.imageSize.w * e), r = this.round(this.imageSize.h * e), i = this.zoom, t = this.previewSize.w / 2 - (this.previewSize.w / 2 - this.offset.x) * e / i, n = this.previewSize.h / 2 - (this.previewSize.h / 2 - this.offset.y) * e / i, this.zoom = e, this.setOffset({ | |
x: t, | |
y: n | |
}), this.zoomSliderPos = this.zoomer.getSliderPos(this.zoom), this.$zoomSlider.val(this.zoomSliderPos), this.$preview.css("background-size", "" + o + "px " + r + "px"), this.options.imageBackground ? this.$imageBg.css({ | |
width: o, | |
height: r | |
}) : void 0 | |
}, n.prototype.fixZoom = function(e) { | |
return this.zoomer.fixZoom(e) | |
}, n.prototype.isZoomable = function() { | |
return this.zoomer.isZoomable() | |
}, n.prototype.getCroppedImageData = function(t) { | |
var n, i, r, o, a; | |
return this.imageSrc ? (o = { | |
type: "image/png", | |
quality: .75, | |
originalSize: !1, | |
fillBg: "#fff" | |
}, t = e.extend({}, o, t), r = { | |
w: this.previewSize.w, | |
h: this.previewSize.h | |
}, this.options.fitHeight && !this.options.fitWidth && this.imageSize.w * this.zoom < this.previewSize.w ? r.w = this.imageSize.w * this.zoom : this.options.fitWidth && !this.options.fitHeight && this.imageSize.h * this.zoom < this.previewSize.h && (r.h = this.imageSize.h * this.zoom), a = t.originalSize ? 1 / this.zoom : this.options.exportZoom, n = e("<canvas />").attr({ | |
width: r.w * a, | |
height: r.h * a | |
}).get(0), i = n.getContext("2d"), "image/jpeg" === t.type && (i.fillStyle = t.fillBg, i.fillRect(0, 0, n.width, n.height)), i.drawImage(this.image, this.offset.x * a, this.offset.y * a, this.zoom * a * this.imageSize.w, this.zoom * a * this.imageSize.h), n.toDataURL(t.type, t.quality)) : null | |
}, n.prototype.getImageState = function() { | |
return { | |
src: this.imageSrc, | |
offset: this.offset, | |
zoom: this.zoom | |
} | |
}, n.prototype.getImageSrc = function() { | |
return this.imageSrc | |
}, n.prototype.getOffset = function() { | |
return this.offset | |
}, n.prototype.getZoom = function() { | |
return this.zoom | |
}, n.prototype.getImageSize = function() { | |
return this.imageSize ? { | |
width: this.imageSize.w, | |
height: this.imageSize.h | |
} : null | |
}, n.prototype.getPreviewSize = function() { | |
return { | |
width: this.previewSize.w, | |
height: this.previewSize.h | |
} | |
}, n.prototype.setPreviewSize = function(e) { | |
return (null != e ? e.width : void 0) > 0 && (null != e ? e.height : void 0) > 0 ? (this.previewSize = { | |
w: e.width, | |
h: e.height | |
}, this.$preview.css({ | |
width: this.previewSize.w, | |
height: this.previewSize.h | |
}), this.options.imageBackground && this.$imageBgContainer.css({ | |
width: this.previewSize.w + this.imageBgBorderWidthArray[1] + this.imageBgBorderWidthArray[3], | |
height: this.previewSize.h + this.imageBgBorderWidthArray[0] + this.imageBgBorderWidthArray[2] | |
}), this.imageLoaded ? this.setupZoomer() : void 0) : void 0 | |
}, n.prototype.disable = function() { | |
return this.unbindListeners(), this.disableZoomSlider(), this.$el.addClass("cropit-disabled") | |
}, n.prototype.reenable = function() { | |
return this.bindListeners(), this.enableZoomSlider(), this.$el.removeClass("cropit-disabled") | |
}, n.prototype.round = function(e) { | |
return Math.round(1e5 * e) / 1e5 | |
}, n.prototype.$ = function(e) { | |
return this.$el ? this.$el.find(e) : null | |
}, n | |
}(); | |
var i, r; | |
i = "cropit", r = { | |
init: function(t) { | |
return this.each(function() { | |
var r; | |
return e.data(this, i) ? void 0 : (r = new n(this, t), e.data(this, i, r)) | |
}) | |
}, | |
destroy: function() { | |
return this.each(function() { | |
return e.removeData(this, i) | |
}) | |
}, | |
isZoomable: function() { | |
var e; | |
return e = this.first().data(i), null != e ? e.isZoomable() : void 0 | |
}, | |
"export": function(e) { | |
var t; | |
return t = this.first().data(i), null != t ? t.getCroppedImageData(e) : void 0 | |
}, | |
imageState: function() { | |
var e; | |
return e = this.first().data(i), null != e ? e.getImageState() : void 0 | |
}, | |
imageSrc: function(t) { | |
var n; | |
return null != t ? this.each(function() { | |
var n; | |
return n = e.data(this, i), null != n && n.reset(), null != n ? n.loadImage(t) : void 0 | |
}) : (n = this.first().data(i), null != n ? n.getImageSrc() : void 0) | |
}, | |
offset: function(t) { | |
var n; | |
return null != t && null != t.x && null != t.y ? this.each(function() { | |
var n; | |
return n = e.data(this, i), null != n ? n.setOffset(t) : void 0 | |
}) : (n = this.first().data(i), null != n ? n.getOffset() : void 0) | |
}, | |
zoom: function(t) { | |
var n; | |
return null != t ? this.each(function() { | |
var n; | |
return n = e.data(this, i), null != n ? n.setZoom(t) : void 0 | |
}) : (n = this.first().data(i), null != n ? n.getZoom() : void 0) | |
}, | |
imageSize: function() { | |
var e; | |
return e = this.first().data(i), null != e ? e.getImageSize() : void 0 | |
}, | |
previewSize: function(t) { | |
var n; | |
return null != t ? this.each(function() { | |
var n; | |
return n = e.data(this, i), null != n ? n.setPreviewSize(t) : void 0 | |
}) : (n = this.first().data(i), null != n ? n.getPreviewSize() : void 0) | |
}, | |
disable: function() { | |
return this.each(function() { | |
var t; | |
return t = e.data(this, i), t.disable() | |
}) | |
}, | |
reenable: function() { | |
return this.each(function() { | |
var t; | |
return t = e.data(this, i), t.reenable() | |
}) | |
} | |
}, e.fn.cropit = function(e) { | |
return r[e] ? r[e].apply(this, [].slice.call(arguments, 1)) : r.init.apply(this, arguments) | |
} | |
}(window.jQuery), | |
function() { | |
di.app.module("MemberApp.Views", function(e, t, n, i, r, o) { | |
var a, s, l; | |
return a = ";base64,", l = { | |
"default": { | |
"class": "" | |
}, | |
submitting: { | |
avatar: { | |
"class": "submitting", | |
message: "Updating your Avatar Info..." | |
}, | |
profile: { | |
"class": "submitting", | |
message: "Updating your Profile Info..." | |
} | |
}, | |
success: { | |
avatar: { | |
"class": "success", | |
message: '<i class="icon-check-circle"></i> Your Avatar has been successfully updated.' | |
}, | |
profile: { | |
"class": "success", | |
message: '<i class="icon-check-circle"></i> Your Profile Information has been successfully updated.' | |
} | |
} | |
}, s = null, e.Profile = e.BaseMemberView.extend({ | |
id: "member-profile", | |
template: "di/ui/member/profile", | |
ui: { | |
memberAvatar: ".member-avatar", | |
memberAvatarImg: ".member-avatar-img", | |
memberAvatarTools: ".member-avatar-tools", | |
avatarEditControls: ".member-avatar-edit-controls", | |
avatarUploadControls: ".member-avatar-upload-controls", | |
uploadImgIE: ".upload-img-ie", | |
saveAvatarIE: ".save-avatar-ie", | |
saveAvatar: ".member-avatar-save", | |
removeAvatar: ".remove-avatar", | |
avatarFileInputIE: ".member-avatar-file-input-ie", | |
avatarFileInput: ".member-avatar-file-input", | |
avatarBase64Input: ".member-avatar-base64-input", | |
memberAvatarForm: "form.member_avatar", | |
editProfileForm: "form.edit_member", | |
statusMsg: "#status-msg", | |
gigyaErrors: ".gigya-errors" | |
}, | |
events: { | |
"click @ui.uploadImgIE": "showInputField", | |
"click @ui.saveAvatar": "saveAvatar", | |
"click @ui.removeAvatar": "removeAvatar", | |
"change @ui.avatarFileInputIE": "showSaveButton", | |
"click @ui.saveAvatarIE": "saveAvatarIE", | |
"ajax:error @ui.memberAvatarForm": "ajaxErrorAvatar", | |
"ajax:success @ui.memberAvatarForm": "ajaxSuccessAvatar", | |
"ajax:beforeSend @ui.editProfileForm": "ajaxSendingProfile", | |
"ajax:error @ui.editProfileForm": "ajaxErrorProfile", | |
"ajax:success @ui.editProfileForm": "ajaxSuccessProfile", | |
"ajax:complete @ui.editProfileForm": "ajaxCompleteProfile" | |
}, | |
modelEvents: { | |
change: "render" | |
}, | |
templateHelpers: { | |
avatar: function() { | |
var e; | |
return e = location.protocol + "//" + location.host + this.default_avatar_url, this.avatar_url || "http://www.gravatar.com/avatar/" + this.email_md5 + "?s=100&d=" + encodeURIComponent(e) | |
}, | |
isOldIE: function() { | |
return r("html").hasClass("lt-ie10") | |
} | |
}, | |
behaviors: { | |
ParsleyValidation: {} | |
}, | |
initialize: function() { | |
return this.listenTo(this, "render", o.bind(this.checkAvatar, this)), r(document).on("social.Auth.error.member-profile", o.bind(this.socialAuthError, this)) | |
}, | |
onRender: function() { | |
return this.setAvatarFormURL(), this.ui.avatarEditControls.hide(), this.ui.memberAvatarTools.cropit({ | |
height: 100, | |
width: 100, | |
onImageLoaded: function(e) { | |
return function() { | |
return e.ui.memberAvatarImg.hide(), e.ui.avatarEditControls.show(), e.ui.avatarUploadControls.hide() | |
} | |
}(this) | |
}) | |
}, | |
checkAvatar: function() { | |
var e; | |
if (Modernizr.backgroundsize) return e = this.ui.memberAvatarImg[0], this.ui.memberAvatarImg.hide(), e.complete || 0 !== e.naturalWidth ? this.showAvatar() : this.ui.memberAvatarImg.on("load", function(e) { | |
return function() { | |
return e.showAvatar() | |
} | |
}(this)) | |
}, | |
showAvatar: function() { | |
return this.ui.memberAvatar.css({ | |
"background-image": 'url("' + this.ui.memberAvatarImg.attr("src") + '")' | |
}) | |
}, | |
setAvatarFormURL: function() { | |
return this.ui.memberAvatarForm.attr("action", t.options.api.url + "members/" + this.model.get("id") + "/avatar") | |
}, | |
showInputField: function() { | |
return this.ui.uploadImgIE.addClass("show-input-field") | |
}, | |
showSaveButton: function() { | |
return this.ui.saveAvatarIE.removeClass("hide") | |
}, | |
saveAvatarIE: function() { | |
var e, t; | |
return this.ui.memberAvatarForm.find('input[name="_method"]').val("post"), this.ui.memberAvatarForm.attr("action", this._avatarApiURL()), this.ui.memberAvatarForm.attr("enctype", "multipart/form-data"), this.ui.memberAvatarForm.attr("target", "avatar-upload-frame"), t = this.ui.memberAvatarForm.find('iframe[name="avatar-upload-frame"]'), e = setInterval(function(n) { | |
return function() { | |
var i; | |
return i = t[0].contentWindow.location.href, /member\/avatar\/result/.test(i) ? (clearInterval(e), n.updateAvatarIE(i)) : void 0 | |
} | |
}(this), 100), this.setState("submitting.avatar", this.ui.memberAvatarForm), this.ui.memberAvatarForm.submit() | |
}, | |
updateAvatarIE: function(e) { | |
var t, n, i; | |
return i = e.match(/json\=(.*?)$/)[1], t = decodeURIComponent(i), n = JSON.parse(t), this.model.set("avatar_url", n.url), this.model.trigger("change") | |
}, | |
saveAvatar: function(e) { | |
var t, n, i; | |
return e.preventDefault(), t = this.ui.memberAvatarTools.cropit("export", { | |
type: "image/jpeg", | |
quality: 1 | |
}), n = this._convertBase64toBlob(t), i = new FormData, i.append("image", n), r.ajax(this._avatarApiURL(), { | |
data: i, | |
cache: !1, | |
contentType: !1, | |
processData: !1, | |
type: "POST", | |
beforeSend: o.bind(this.ajaxSendingAvatar, this), | |
success: o.bind(this.ajaxSuccessAvatar, this), | |
error: o.bind(this.ajaxErrorAvatar, this) | |
}) | |
}, | |
_convertBase64toBlob: function(e) { | |
var t, n, i, r, o, a, s, l, u, c, d; | |
for (l = e.match(/^data:(.*?);base64/)[1], d = 512, t = e.match(/;base64,(.*?)$/)[1], u = 0, o = window.atob(t), r = []; u < o.length;) { | |
for (c = o.slice(u, u + d), a = new Array(c.length), s = 0; s < c.length;) a[s] = c.charCodeAt(s), s++; | |
i = new Uint8Array(a), r.push(i), u += d | |
} | |
return n = new Blob(r, { | |
type: l | |
}) | |
}, | |
_avatarApiURL: function() { | |
return t.options.api.url + "/members/" + this.model.get("id") + "/avatar?api_key=" + this.model.get("api_key") | |
}, | |
removeAvatar: function() { | |
return r.ajax(this._avatarApiURL(), { | |
type: "delete", | |
data: { | |
image: { | |
"delete": 1 | |
} | |
}, | |
beforeSend: o.bind(this.ajaxSendingAvatar, this), | |
success: o.bind(this.ajaxSuccessAvatar, this), | |
error: o.bind(this.ajaxErrorAvatar, this) | |
}) | |
}, | |
ajaxSendingAvatar: function() { | |
return this.setState("submitting.avatar", this.ui.memberAvatarForm) | |
}, | |
ajaxErrorAvatar: function() { | |
return this.setState("default", this.ui.memberAvatarForm) | |
}, | |
ajaxSuccessAvatar: function(e) { | |
return this.setState("success.avatar", this.ui.memberAvatarForm), this.model.set(e, { | |
silent: !0 | |
}), o.delay(function(e) { | |
return function() { | |
return e.model.trigger("change") | |
} | |
}(this), 2e3) | |
}, | |
ajaxSendingProfile: function(e, t) { | |
return this.ui.editProfileForm.trigger("validate"), this.ui.editProfileForm[0].validator.isValid() ? this.setState("submitting.profile", this.ui.editProfileForm) : t.abort() | |
}, | |
ajaxErrorProfile: function() { | |
return this.setState("default", this.ui.editProfileForm) | |
}, | |
ajaxSuccessProfile: function(e, n) { | |
var i; | |
return null != n.verify_action ? (t.commands.execute("modal:verifyAction"), i = t.Modals.currentView, i.on("verified", function(e) { | |
return function(t) { | |
return null != t.errors ? e.displayProfileErrors(t.errors) : e.displaySuccess(), i.destroy() | |
} | |
}(this)), i.on("cancelled", function(e) { | |
return function() { | |
return e.setState("default", e.ui.editProfileForm) | |
} | |
}(this))) : (console.info(n), null != n.errors ? this.displayProfileErrors(n.errors) : this.displaySuccess()) | |
}, | |
displayProfileErrors: function(e) { | |
var t, n, i, r, o, a, s; | |
this.setState("default", this.ui.editProfileForm), this.removeProfileErrors(), s = []; | |
for (o in e) r = e[o], n = this.ui.editProfileForm.find('[name="member[' + o + ']"]').closest(".field-group"), t = n.find(".parsley-errors-list"), t.empty(), t.addClass("filled"), a = o.charAt(0).toUpperCase() + o.slice(1), s.push(function() { | |
var e, n, o; | |
for (o = [], e = 0, n = r.length; n > e; e++) i = r[e], o.push(t.append("<li>" + a + " " + i + "</li>")); | |
return o | |
}()); | |
return s | |
}, | |
removeProfileErrors: function() { | |
return this.ui.editProfileForm.find(".parsley-errors-list.filled").each(function(e, t) { | |
return r(t).removeClass("filled").empty() | |
}) | |
}, | |
displaySuccess: function() { | |
return this.setState("success.profile", this.ui.editProfileForm), this.removeProfileErrors(), o.delay(function(e) { | |
return function() { | |
return e.$el.find('[type="password"]').val(""), e.setState("default", e.ui.editProfileForm) | |
} | |
}(this), 3e3) | |
}, | |
ajaxCompleteProfile: function() {}, | |
socialAuthError: function(e, t, n) { | |
return this.ui.gigyaErrors.empty(), this.ui.gigyaErrors.append('<li class="error">' + n + "</li>"), this.ui.gigyaErrors.addClass("filled") | |
}, | |
setState: function(e, t) { | |
var n, i, r, o; | |
return null == t && (t = this.$el), e.indexOf(".") > -1 && (o = e.split("."), e = o[0], r = o[1]), n = t.find("#status-msg"), i = l[e], null != r && (i = i[r]), t.attr("data-state", e), null != i.message && n.html("<p>" + i.message + "</p>"), n.attr("class", i["class"]) | |
}, | |
onBeforeDestroy: function() { | |
return r(document).off("social.Auth.error.member-profile"), this.ui.memberAvatarTools.cropit("disable") | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
var e = {}.hasOwnProperty, | |
t = function(t, n) { | |
function i() { | |
this.constructor = t | |
} | |
for (var r in n) e.call(n, r) && (t[r] = n[r]); | |
return i.prototype = n.prototype, t.prototype = new i, t.__super__ = n.prototype, t | |
}; | |
di.provide("di.model.CurrencySymbols"), di.model.CurrencySymbols = function(e) { | |
function n() { | |
return n.__super__.constructor.apply(this, arguments) | |
} | |
return t(n, e), n.prototype.defaults = { | |
AED: { | |
symbol: "AED", | |
symbol_native: "\u062f.\u0625.\u200f", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "AED" | |
}, | |
AFN: { | |
symbol: "AFN", | |
symbol_native: "\u060b", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "AFN" | |
}, | |
ALL: { | |
symbol: "ALL", | |
symbol_native: "Lek", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "ALL" | |
}, | |
AMD: { | |
symbol: "AMD", | |
symbol_native: "\u0564\u0580.", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "AMD" | |
}, | |
AOA: { | |
symbol: "AOA", | |
symbol_native: "Kz", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "AOA" | |
}, | |
ARS: { | |
symbol: "ARS", | |
symbol_native: "$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "ARS" | |
}, | |
AUD: { | |
symbol: "AU$", | |
symbol_native: "$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "AUD" | |
}, | |
AWG: { | |
symbol: "AWG", | |
symbol_native: "Afl.", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "AWG" | |
}, | |
AZN: { | |
symbol: "AZN", | |
symbol_native: "\u043c\u0430\u043d.", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "AZN" | |
}, | |
BAM: { | |
symbol: "BAM", | |
symbol_native: "KM", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "BAM" | |
}, | |
BBD: { | |
symbol: "BBD", | |
symbol_native: "$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "BBD" | |
}, | |
BDT: { | |
symbol: "BDT", | |
symbol_native: "\u09f3", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "BDT" | |
}, | |
BGN: { | |
symbol: "BGN", | |
symbol_native: "\u043b\u0432.", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "BGN" | |
}, | |
BHD: { | |
symbol: "BHD", | |
symbol_native: "\u062f.\u0628.\u200f", | |
decimal_digits: 3, | |
rounding: 0, | |
code: "BHD" | |
}, | |
BIF: { | |
symbol: "BIF", | |
symbol_native: "FBu", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "BIF" | |
}, | |
BMD: { | |
symbol: "BMD", | |
symbol_native: "$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "BMD" | |
}, | |
BND: { | |
symbol: "BND", | |
symbol_native: "$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "BND" | |
}, | |
BOB: { | |
symbol: "BOB", | |
symbol_native: "Bs", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "BOB" | |
}, | |
BRL: { | |
symbol: "R$", | |
symbol_native: "R$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "BRL" | |
}, | |
BWP: { | |
symbol: "BWP", | |
symbol_native: "P", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "BWP" | |
}, | |
BYR: { | |
symbol: "BYR", | |
symbol_native: "BYR", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "BYR" | |
}, | |
BZD: { | |
symbol: "BZD", | |
symbol_native: "$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "BZD" | |
}, | |
CAD: { | |
symbol: "CA$", | |
symbol_native: "$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "CAD" | |
}, | |
CDF: { | |
symbol: "CDF", | |
symbol_native: "FrCD", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "CDF" | |
}, | |
CHF: { | |
symbol: "CHF", | |
symbol_native: "CHF", | |
decimal_digits: 2, | |
rounding: .05, | |
code: "CHF" | |
}, | |
CLP: { | |
symbol: "CLP", | |
symbol_native: "$", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "CLP" | |
}, | |
CNY: { | |
symbol: "CN\xa5", | |
symbol_native: "CN\xa5", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "CNY" | |
}, | |
COP: { | |
symbol: "COP", | |
symbol_native: "$", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "COP" | |
}, | |
CRC: { | |
symbol: "CRC", | |
symbol_native: "\u20a1", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "CRC" | |
}, | |
CVE: { | |
symbol: "CVE", | |
symbol_native: "CVE", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "CVE" | |
}, | |
CZK: { | |
symbol: "CZK", | |
symbol_native: "K\u010d", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "CZK" | |
}, | |
DJF: { | |
symbol: "DJF", | |
symbol_native: "Fdj", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "DJF" | |
}, | |
DKK: { | |
symbol: "DKK", | |
symbol_native: "kr", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "DKK" | |
}, | |
DOP: { | |
symbol: "DOP", | |
symbol_native: "$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "DOP" | |
}, | |
DZD: { | |
symbol: "DZD", | |
symbol_native: "\u062f.\u062c.\u200f", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "DZD" | |
}, | |
EGP: { | |
symbol: "EGP", | |
symbol_native: "\u062c.\u0645.\u200f", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "EGP" | |
}, | |
ERN: { | |
symbol: "ERN", | |
symbol_native: "Nfk", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "ERN" | |
}, | |
ETB: { | |
symbol: "ETB", | |
symbol_native: "\u1265\u122d", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "ETB" | |
}, | |
EUR: { | |
symbol: "\u20ac", | |
symbol_native: "\u20ac", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "EUR" | |
}, | |
GBP: { | |
symbol: "\xa3", | |
symbol_native: "\xa3", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "GBP" | |
}, | |
GEL: { | |
symbol: "GEL", | |
symbol_native: "GEL", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "GEL" | |
}, | |
GHS: { | |
symbol: "GHS", | |
symbol_native: "GHS", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "GHS" | |
}, | |
GNF: { | |
symbol: "GNF", | |
symbol_native: "FG", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "GNF" | |
}, | |
GTQ: { | |
symbol: "GTQ", | |
symbol_native: "Q", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "GTQ" | |
}, | |
GYD: { | |
symbol: "GYD", | |
symbol_native: "GYD", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "GYD" | |
}, | |
HKD: { | |
symbol: "HK$", | |
symbol_native: "$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "HKD" | |
}, | |
HNL: { | |
symbol: "HNL", | |
symbol_native: "L", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "HNL" | |
}, | |
HRK: { | |
symbol: "HRK", | |
symbol_native: "kn", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "HRK" | |
}, | |
HUF: { | |
symbol: "HUF", | |
symbol_native: "Ft", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "HUF" | |
}, | |
IDR: { | |
symbol: "IDR", | |
symbol_native: "Rp", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "IDR" | |
}, | |
ILS: { | |
symbol: "\u20aa", | |
symbol_native: "\u20aa", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "ILS" | |
}, | |
INR: { | |
symbol: "\u20b9", | |
symbol_native: "\u20b9", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "INR" | |
}, | |
IQD: { | |
symbol: "IQD", | |
symbol_native: "\u062f.\u0639.\u200f", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "IQD" | |
}, | |
IRR: { | |
symbol: "IRR", | |
symbol_native: "\ufdfc", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "IRR" | |
}, | |
ISK: { | |
symbol: "ISK", | |
symbol_native: "kr", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "ISK" | |
}, | |
JMD: { | |
symbol: "JMD", | |
symbol_native: "$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "JMD" | |
}, | |
JOD: { | |
symbol: "JOD", | |
symbol_native: "\u062f.\u0623.\u200f", | |
decimal_digits: 3, | |
rounding: 0, | |
code: "JOD" | |
}, | |
JPY: { | |
symbol: "\xa5", | |
symbol_native: "\uffe5", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "JPY" | |
}, | |
KES: { | |
symbol: "KES", | |
symbol_native: "Ksh", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "KES" | |
}, | |
KHR: { | |
symbol: "KHR", | |
symbol_native: "\u17db", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "KHR" | |
}, | |
KMF: { | |
symbol: "KMF", | |
symbol_native: "CF", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "KMF" | |
}, | |
KRW: { | |
symbol: "\u20a9", | |
symbol_native: "\u20a9", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "KRW" | |
}, | |
KWD: { | |
symbol: "KWD", | |
symbol_native: "\u062f.\u0643.\u200f", | |
decimal_digits: 3, | |
rounding: 0, | |
code: "KWD" | |
}, | |
KZT: { | |
symbol: "KZT", | |
symbol_native: "\u20b8", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "KZT" | |
}, | |
LBP: { | |
symbol: "LBP", | |
symbol_native: "\u0644.\u0644.\u200f", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "LBP" | |
}, | |
LKR: { | |
symbol: "LKR", | |
symbol_native: "\u0dbb\u0dd4.", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "LKR" | |
}, | |
LRD: { | |
symbol: "LRD", | |
symbol_native: "$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "LRD" | |
}, | |
LTL: { | |
symbol: "LTL", | |
symbol_native: "Lt", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "LTL" | |
}, | |
LVL: { | |
symbol: "LVL", | |
symbol_native: "Ls", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "LVL" | |
}, | |
LYD: { | |
symbol: "LYD", | |
symbol_native: "\u062f.\u0644.\u200f", | |
decimal_digits: 3, | |
rounding: 0, | |
code: "LYD" | |
}, | |
MAD: { | |
symbol: "MAD", | |
symbol_native: "\u062f.\u0645.\u200f", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "MAD" | |
}, | |
MDL: { | |
symbol: "MDL", | |
symbol_native: "MDL", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "MDL" | |
}, | |
MGA: { | |
symbol: "MGA", | |
symbol_native: "MGA", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "MGA" | |
}, | |
MKD: { | |
symbol: "MKD", | |
symbol_native: "MKD", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "MKD" | |
}, | |
MMK: { | |
symbol: "MMK", | |
symbol_native: "K", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "MMK" | |
}, | |
MOP: { | |
symbol: "MOP", | |
symbol_native: "MOP", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "MOP" | |
}, | |
MUR: { | |
symbol: "MUR", | |
symbol_native: "MUR", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "MUR" | |
}, | |
MXN: { | |
symbol: "MX$", | |
symbol_native: "$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "MXN" | |
}, | |
MYR: { | |
symbol: "MYR", | |
symbol_native: "RM", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "MYR" | |
}, | |
MZN: { | |
symbol: "MZN", | |
symbol_native: "MTn", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "MZN" | |
}, | |
NAD: { | |
symbol: "NAD", | |
symbol_native: "$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "NAD" | |
}, | |
NGN: { | |
symbol: "NGN", | |
symbol_native: "\u20a6", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "NGN" | |
}, | |
NIO: { | |
symbol: "NIO", | |
symbol_native: "C$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "NIO" | |
}, | |
NOK: { | |
symbol: "NOK", | |
symbol_native: "kr", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "NOK" | |
}, | |
NPR: { | |
symbol: "NPR", | |
symbol_native: "\u0928\u0947\u0930\u0942", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "NPR" | |
}, | |
NZD: { | |
symbol: "NZ$", | |
symbol_native: "$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "NZD" | |
}, | |
OMR: { | |
symbol: "OMR", | |
symbol_native: "\u0631.\u0639.\u200f", | |
decimal_digits: 3, | |
rounding: 0, | |
code: "OMR" | |
}, | |
PAB: { | |
symbol: "PAB", | |
symbol_native: "B/.", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "PAB" | |
}, | |
PEN: { | |
symbol: "PEN", | |
symbol_native: "S/.", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "PEN" | |
}, | |
PHP: { | |
symbol: "PHP", | |
symbol_native: "\u20b1", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "PHP" | |
}, | |
PKR: { | |
symbol: "PKR", | |
symbol_native: "\u20a8", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "PKR" | |
}, | |
PLN: { | |
symbol: "PLN", | |
symbol_native: "z\u0142", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "PLN" | |
}, | |
PYG: { | |
symbol: "PYG", | |
symbol_native: "\u20b2", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "PYG" | |
}, | |
QAR: { | |
symbol: "QAR", | |
symbol_native: "\u0631.\u0642.\u200f", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "QAR" | |
}, | |
RON: { | |
symbol: "RON", | |
symbol_native: "RON", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "RON" | |
}, | |
RSD: { | |
symbol: "RSD", | |
symbol_native: "\u0434\u0438\u043d.", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "RSD" | |
}, | |
RUB: { | |
symbol: "RUB", | |
symbol_native: "\u0440\u0443\u0431.", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "RUB" | |
}, | |
RWF: { | |
symbol: "RWF", | |
symbol_native: "FR", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "RWF" | |
}, | |
SAR: { | |
symbol: "SAR", | |
symbol_native: "\u0631.\u0633.\u200f", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "SAR" | |
}, | |
SDG: { | |
symbol: "SDG", | |
symbol_native: "SDG", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "SDG" | |
}, | |
SEK: { | |
symbol: "SEK", | |
symbol_native: "kr", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "SEK" | |
}, | |
SGD: { | |
symbol: "SGD", | |
symbol_native: "$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "SGD" | |
}, | |
SOS: { | |
symbol: "SOS", | |
symbol_native: "SOS", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "SOS" | |
}, | |
STD: { | |
symbol: "STD", | |
symbol_native: "Db", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "STD" | |
}, | |
SYP: { | |
symbol: "SYP", | |
symbol_native: "\u0644.\u0633.\u200f", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "SYP" | |
}, | |
THB: { | |
symbol: "\u0e3f", | |
symbol_native: "\u0e3f", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "THB" | |
}, | |
TND: { | |
symbol: "TND", | |
symbol_native: "\u062f.\u062a.\u200f", | |
decimal_digits: 3, | |
rounding: 0, | |
code: "TND" | |
}, | |
TOP: { | |
symbol: "TOP", | |
symbol_native: "T$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "TOP" | |
}, | |
TRY: { | |
symbol: "TRY", | |
symbol_native: "TL", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "TRY" | |
}, | |
TTD: { | |
symbol: "TTD", | |
symbol_native: "$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "TTD" | |
}, | |
TWD: { | |
symbol: "NT$", | |
symbol_native: "NT$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "TWD" | |
}, | |
TZS: { | |
symbol: "TZS", | |
symbol_native: "TSh", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "TZS" | |
}, | |
UAH: { | |
symbol: "UAH", | |
symbol_native: "\u20b4", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "UAH" | |
}, | |
UGX: { | |
symbol: "UGX", | |
symbol_native: "USh", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "UGX" | |
}, | |
USD: { | |
symbol: "$", | |
symbol_native: "$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "USD" | |
}, | |
UYU: { | |
symbol: "UYU", | |
symbol_native: "$", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "UYU" | |
}, | |
UZS: { | |
symbol: "UZS", | |
symbol_native: "UZS", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "UZS" | |
}, | |
VEF: { | |
symbol: "VEF", | |
symbol_native: "Bs.F.", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "VEF" | |
}, | |
VND: { | |
symbol: "\u20ab", | |
symbol_native: "\u20ab", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "VND" | |
}, | |
XAF: { | |
symbol: "FCFA", | |
symbol_native: "FCFA", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "XAF" | |
}, | |
XOF: { | |
symbol: "CFA", | |
symbol_native: "CFA", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "XOF" | |
}, | |
YER: { | |
symbol: "YER", | |
symbol_native: "\u0631.\u064a.\u200f", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "YER" | |
}, | |
ZAR: { | |
symbol: "ZAR", | |
symbol_native: "R", | |
decimal_digits: 2, | |
rounding: 0, | |
code: "ZAR" | |
}, | |
ZMK: { | |
symbol: "ZMK", | |
symbol_native: "ZK", | |
decimal_digits: 0, | |
rounding: 0, | |
code: "ZMK" | |
} | |
}, n | |
}(Backbone.Model) | |
}.call(this), | |
function() { | |
di.app.module("MemberApp.Views", function(e, t, n, i, r, o) { | |
var a; | |
return a = new di.model.CurrencySymbols, e.Subscription = i.LayoutView.extend({ | |
id: "member-subscription", | |
template: "di/ui/member/subscription", | |
ui: { | |
editSubscription: ".edit-subscription", | |
editTerm: ".edit-term", | |
termInstruction: ".term.instruction", | |
upadatePaymentInfo: ".update-payment-info", | |
paymentInfo: ".payment-info", | |
removePaymentMethod: ".remove-payment-method" | |
}, | |
regions: { | |
editSubscriptionForm: ".edit-subscription-form-region", | |
editTermForm: ".edit-term-form-region", | |
paymentMethodForm: ".billing-form-region", | |
removePaymentMethodForm: ".remove-payment-method-form-region" | |
}, | |
events: { | |
"click @ui.editSubscription": "showEditSubscriptionForm", | |
"click @ui.editTerm": "showEditTermForm", | |
"click @ui.upadatePaymentInfo": "showPaymentMethodForm", | |
"click @ui.removePaymentMethod": "showRemovePaymentMethodForm" | |
}, | |
modelEvents: { | |
change: "render" | |
}, | |
templateHelpers: { | |
activeSubscription: function() { | |
var e; | |
return e = o.find(this.subscriptions, function(e) { | |
return e["active?"] | |
}), null != e ? e : {} | |
}, | |
isPremium: function() { | |
var e; | |
return e = this.activeSubscription(), null == e.id && (e = this.expiredSubscription()), null == e.id ? !1 : !0 | |
}, | |
isTrial: function() { | |
var e, t; | |
return e = this.activeSubscription(), null == e.id ? !1 : (t = di.model.Subscription.find(e.id), t.isTrial()) | |
}, | |
expiredSubscription: function() { | |
var e, t; | |
return t = o.sortBy(this.subscriptions, function(e) { | |
return moment(e.expires_on) | |
}), null != this.activeSubscription().id ? !1 : t.length ? (e = o.find(t, function(e) { | |
var t; | |
return null == (null != e && null != (t = e.plan) ? t.trial_duration_days : void 0) | |
}), null == e && (e = !1), e) : !1 | |
}, | |
expiredDate: function() { | |
var e; | |
return e = this.expiredSubscription(), moment(e.expires_on).format("MMMM D, YYYY") | |
}, | |
hasPaymentMethod: function() { | |
var e, t, n; | |
return null != (null != (e = this.payment_method) ? e.id : void 0) && null != (null != (t = this.payment_method) && null != (n = t.payment_type) ? n.key : void 0) | |
}, | |
canAutoRenew: function() { | |
return this.hasPaymentMethod() && !this.isTrial | |
}, | |
showPaymentMethod: function() { | |
return this.hasPaymentMethod() ? !0 : null == this.activeSubscription().id || this.isTrial ? !1 : !0 | |
}, | |
trialLabel: function() { | |
var e; | |
return e = this.plan.trial_duration_days | |
}, | |
titleize: function(e) { | |
var t, n, i, r, o; | |
for (i = e.split(" "), t = [], r = 0, o = i.length; o > r; r++) n = i[r], t.push(n.charAt(0).toUpperCase() + n.toLowerCase().slice(1)); | |
return t.join(" ") | |
}, | |
dateFormat: function(e, t) { | |
return moment(e).format(t) | |
}, | |
currencySymbol: function() { | |
return null != a.get(subscription.currency) ? a.get(subscription.currency).symbol_native : "(USD) $" | |
}, | |
planPrice: function() { | |
return (1 * this.activeSubscription().plan_price).toFixed(2) | |
}, | |
daysLeft: function() { | |
var e, t, n; | |
return n = moment(), t = moment(this.activeSubscription().expires_on), e = t.diff(n, "days"), this.pluralize(e, "day") | |
}, | |
subscriptionTerm: function() { | |
var e, t; | |
return e = this.activeSubscription(), t = e.term_unit, e.term_duration > 1 && (t = this.pluralize(e.term_duration, e.term_unit)), t | |
}, | |
pluralize: function(e, t) { | |
return t = 1 === e ? t : t + "s", e + " " + t | |
} | |
}, | |
showEditSubscriptionForm: function() { | |
var e, n, i; | |
return i = this.model.get("subscriptions").find(function(e) { | |
return e.get("active?") | |
}), n = this.getRegion("editSubscriptionForm"), e = t.request("billing:form", { | |
form: "EditSubscriptionForm", | |
model: i | |
}), this.listenTo(e, "submission:successful", function(e) { | |
return function(t) { | |
return i.set("auto_renew", t), o.delay(function() { | |
return e.model.trigger("change") | |
}, 2e3) | |
} | |
}(this)), n.show(e), this.listenToOnce(e, "close:form", function() { | |
return n.empty() | |
}) | |
}, | |
showEditTermForm: function() { | |
var e, n, i; | |
return i = this.model.get("subscriptions").find(function(e) { | |
return e.get("active?") | |
}), n = this.getRegion("editTermForm"), e = t.request("billing:form", { | |
form: "SubscriptionTermForm", | |
model: i | |
}), this.ui.editTerm.hide(), this.ui.termInstruction.hide(), this.listenToOnce(e, "destroy", function(e) { | |
return function() { | |
return e.ui.editTerm.show(), e.ui.termInstruction.show() | |
} | |
}(this)), this.listenToOnce(e, "submission:successful", function(e) { | |
return function(t) { | |
var r; | |
return r = di.model.Subscription.findOrCreate(t, { | |
parse: !0 | |
}), i.set(r, { | |
silent: !0 | |
}), o.delay(function() { | |
return n.empty(), e.model.trigger("change") | |
}, 2e3) | |
} | |
}(this)), n.show(e), this.listenToOnce(e, "close:form", function() { | |
return n.empty() | |
}) | |
}, | |
showPaymentMethodForm: function() { | |
var e, n; | |
return n = this.getRegion("paymentMethodForm"), e = t.request("billing:form", { | |
form: "PaymentMethodForm", | |
model: this.model.get("payment_method") | |
}), this.ui.paymentInfo.hide(), this.listenToOnce(e, "destroy", function(e) { | |
return function() { | |
return e.ui.paymentInfo.show() | |
} | |
}(this)), this.listenToOnce(e, "submission:successful", function(e) { | |
return function(t) { | |
return e.model.set("payment_method", t, { | |
parse: !0, | |
silent: !0 | |
}), o.delay(function() { | |
return n.empty(), e.model.trigger("change") | |
}, 2e3) | |
} | |
}(this)), n.show(e), this.listenToOnce(e, "close:form", function() { | |
return n.empty() | |
}) | |
}, | |
showRemovePaymentMethodForm: function() { | |
var e, n; | |
return n = this.getRegion("removePaymentMethodForm"), e = t.request("billing:form", { | |
form: "RemovePaymentMethodForm" | |
}), this.ui.upadatePaymentInfo.hide(), this.listenToOnce(e, "destroy", function(e) { | |
return function() { | |
return e.ui.upadatePaymentInfo.show() | |
} | |
}(this)), this.listenToOnce(e, "submission:successful", function(e) { | |
return function() { | |
return e.model.set("payment_method", {}, { | |
parse: !0, | |
silent: !0 | |
}), o.delay(function() { | |
return n.empty(), e.model.trigger("change") | |
}, 2e3) | |
} | |
}(this)), n.show(e), this.listenToOnce(e, "close:form", function() { | |
return n.empty() | |
}) | |
} | |
}) | |
}) | |
}.call(this), | |
function() {}.call(this); | |
var swfobject = di.swfobject = function() { | |
function e() { | |
if (!W && document.getElementsByTagName("body")[0]) { | |
try { | |
var e, t = y("span"); | |
t.style.display = "none", e = N.getElementsByTagName("body")[0].appendChild(t), e.parentNode.removeChild(e), e = null, t = null | |
} catch (n) { | |
return | |
} | |
W = !0; | |
for (var i = j.length, r = 0; i > r; r++) j[r]() | |
} | |
} | |
function t(e) { | |
W ? e() : j[j.length] = e | |
} | |
function n(e) { | |
if (typeof B.addEventListener !== E) B.addEventListener("load", e, !1); | |
else if (typeof N.addEventListener !== E) N.addEventListener("load", e, !1); | |
else if (typeof B.attachEvent !== E) _(B, "onload", e); | |
else if ("function" == typeof B.onload) { | |
var t = B.onload; | |
B.onload = function() { | |
t(), e() | |
} | |
} else B.onload = e | |
} | |
function i() { | |
var e = N.getElementsByTagName("body")[0], | |
t = y(I); | |
t.setAttribute("style", "visibility: hidden;"), t.setAttribute("type", R); | |
var n = e.appendChild(t); | |
if (n) { | |
var i = 0; | |
! function o() { | |
if (typeof n.GetVariable !== E) try { | |
var a = n.GetVariable("$version"); | |
a && (a = a.split(" ")[1].split(","), G.pv = [v(a[0]), v(a[1]), v(a[2])]) | |
} catch (s) { | |
G.pv = [8, 0, 0] | |
} else if (10 > i) return i++, void setTimeout(o, 10); | |
e.removeChild(t), n = null, r() | |
}() | |
} else r() | |
} | |
function r() { | |
var e = H.length; | |
if (e > 0) | |
for (var t = 0; e > t; t++) { | |
var n = H[t].id, | |
i = H[t].callbackFn, | |
r = { | |
success: !1, | |
id: n | |
}; | |
if (G.pv[0] > 0) { | |
var u = g(n); | |
if (u) | |
if (!b(H[t].swfVersion) || G.wk && G.wk < 312) | |
if (H[t].expressInstall && a()) { | |
var c = {}; | |
c.data = H[t].expressInstall, c.width = u.getAttribute("width") || "0", c.height = u.getAttribute("height") || "0", u.getAttribute("class") && (c.styleclass = u.getAttribute("class")), u.getAttribute("align") && (c.align = u.getAttribute("align")); | |
for (var d = {}, h = u.getElementsByTagName("param"), p = h.length, f = 0; p > f; f++) "movie" !== h[f].getAttribute("name").toLowerCase() && (d[h[f].getAttribute("name")] = h[f].getAttribute("value")); | |
s(c, d, n, i) | |
} else l(u), i && i(r); | |
else x(n, !0), i && (r.success = !0, r.ref = o(n), r.id = n, i(r)) | |
} else if (x(n, !0), i) { | |
var m = o(n); | |
m && typeof m.SetVariable !== E && (r.success = !0, r.ref = m, r.id = m.id), i(r) | |
} | |
} | |
} | |
function o(e) { | |
var t = null, | |
n = g(e); | |
return n && "OBJECT" === n.nodeName.toUpperCase() && (t = typeof n.SetVariable !== E ? n : n.getElementsByTagName(I)[0] || n), t | |
} | |
function a() { | |
return !q && b("6.0.65") && (G.win || G.mac) && !(G.wk && G.wk < 312) | |
} | |
function s(e, t, n, i) { | |
var r = g(n); | |
if (n = m(n), q = !0, S = i || null, T = { | |
success: !1, | |
id: n | |
}, r) { | |
"OBJECT" === r.nodeName.toUpperCase() ? (C = u(r), A = null) : (C = r, A = n), e.id = D, (typeof e.width === E || !/%$/.test(e.width) && v(e.width) < 310) && (e.width = "310"), (typeof e.height === E || !/%$/.test(e.height) && v(e.height) < 137) && (e.height = "137"); | |
var o = G.ie ? "ActiveX" : "PlugIn", | |
a = "MMredirectURL=" + encodeURIComponent(B.location.toString().replace(/&/g, "%26")) + "&MMplayerType=" + o + "&MMdoctitle=" + encodeURIComponent(N.title.slice(0, 47) + " - Flash Player Installation"); | |
if (typeof t.flashvars !== E ? t.flashvars += "&" + a : t.flashvars = a, G.ie && 4 != r.readyState) { | |
var s = y("div"); | |
n += "SWFObjectNew", s.setAttribute("id", n), r.parentNode.insertBefore(s, r), r.style.display = "none", p(r) | |
} | |
d(e, t, n) | |
} | |
} | |
function l(e) { | |
if (G.ie && 4 != e.readyState) { | |
e.style.display = "none"; | |
var t = y("div"); | |
e.parentNode.insertBefore(t, e), t.parentNode.replaceChild(u(e), t), p(e) | |
} else e.parentNode.replaceChild(u(e), e) | |
} | |
function u(e) { | |
var t = y("div"); | |
if (G.win && G.ie) t.innerHTML = e.innerHTML; | |
else { | |
var n = e.getElementsByTagName(I)[0]; | |
if (n) { | |
var i = n.childNodes; | |
if (i) | |
for (var r = i.length, o = 0; r > o; o++) 1 == i[o].nodeType && "PARAM" === i[o].nodeName || 8 == i[o].nodeType || t.appendChild(i[o].cloneNode(!0)) | |
} | |
} | |
return t | |
} | |
function c(e, t) { | |
var n = y("div"); | |
return n.innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'><param name='movie' value='" + e + "'>" + t + "</object>", n.firstChild | |
} | |
function d(e, t, n) { | |
var i, r = g(n); | |
if (n = m(n), G.wk && G.wk < 312) return i; | |
if (r) { | |
var o, a, s, l = y(G.ie ? "div" : I); | |
typeof e.id === E && (e.id = n); | |
for (s in t) t.hasOwnProperty(s) && "movie" !== s.toLowerCase() && h(l, s, t[s]); | |
G.ie && (l = c(e.data, l.innerHTML)); | |
for (o in e) e.hasOwnProperty(o) && (a = o.toLowerCase(), "styleclass" === a ? l.setAttribute("class", e[o]) : "classid" !== a && "data" !== a && l.setAttribute(o, e[o])); | |
G.ie ? z[z.length] = e.id : (l.setAttribute("type", R), l.setAttribute("data", e.data)), r.parentNode.replaceChild(l, r), i = l | |
} | |
return i | |
} | |
function h(e, t, n) { | |
var i = y("param"); | |
i.setAttribute("name", t), i.setAttribute("value", n), e.appendChild(i) | |
} | |
function p(e) { | |
var t = g(e); | |
t && "OBJECT" === t.nodeName.toUpperCase() && (G.ie ? (t.style.display = "none", function n() { | |
if (4 == t.readyState) { | |
for (var e in t) "function" == typeof t[e] && (t[e] = null); | |
t.parentNode.removeChild(t) | |
} else setTimeout(n, 10) | |
}()) : t.parentNode.removeChild(t)) | |
} | |
function f(e) { | |
return e && e.nodeType && 1 === e.nodeType | |
} | |
function m(e) { | |
return f(e) ? e.id : e | |
} | |
function g(e) { | |
if (f(e)) return e; | |
var t = null; | |
try { | |
t = N.getElementById(e) | |
} catch (n) {} | |
return t | |
} | |
function y(e) { | |
return N.createElement(e) | |
} | |
function v(e) { | |
return parseInt(e, 10) | |
} | |
function _(e, t, n) { | |
e.attachEvent(t, n), U[U.length] = [e, t, n] | |
} | |
function b(e) { | |
e += ""; | |
var t = G.pv, | |
n = e.split("."); | |
return n[0] = v(n[0]), n[1] = v(n[1]) || 0, n[2] = v(n[2]) || 0, t[0] > n[0] || t[0] == n[0] && t[1] > n[1] || t[0] == n[0] && t[1] == n[1] && t[2] >= n[2] ? !0 : !1 | |
} | |
function w(e, t, n, i) { | |
var r = N.getElementsByTagName("head")[0]; | |
if (r) { | |
var o = "string" == typeof n ? n : "screen"; | |
if (i && (P = null, M = null), !P || M != o) { | |
var a = y("style"); | |
a.setAttribute("type", "text/css"), a.setAttribute("media", o), P = r.appendChild(a), G.ie && typeof N.styleSheets !== E && N.styleSheets.length > 0 && (P = N.styleSheets[N.styleSheets.length - 1]), M = o | |
} | |
P && (typeof P.addRule !== E ? P.addRule(e, t) : typeof N.createTextNode !== E && P.appendChild(N.createTextNode(e + " {" + t + "}"))) | |
} | |
} | |
function x(e, t) { | |
if (Y) { | |
var n = t ? "visible" : "hidden", | |
i = g(e); | |
W && i ? i.style.visibility = n : "string" == typeof e && w("#" + e, "visibility:" + n) | |
} | |
} | |
function k(e) { | |
var t = /[\\\"<>\.;]/, | |
n = null !== t.exec(e); | |
return n && typeof encodeURIComponent !== E ? encodeURIComponent(e) : e | |
} { | |
var C, A, S, T, P, M, E = "undefined", | |
I = "object", | |
F = "Shockwave Flash", | |
O = "ShockwaveFlash.ShockwaveFlash", | |
R = "application/x-shockwave-flash", | |
D = "SWFObjectExprInst", | |
L = "onreadystatechange", | |
B = window, | |
N = document, | |
$ = navigator, | |
V = !1, | |
j = [], | |
H = [], | |
z = [], | |
U = [], | |
W = !1, | |
q = !1, | |
Y = !0, | |
K = !1, | |
G = function() { | |
var e = typeof N.getElementById !== E && typeof N.getElementsByTagName !== E && typeof N.createElement !== E, | |
t = $.userAgent.toLowerCase(), | |
n = $.platform.toLowerCase(), | |
i = /win/.test(n ? n : t), | |
r = /mac/.test(n ? n : t), | |
o = /webkit/.test(t) ? parseFloat(t.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : !1, | |
a = "Microsoft Internet Explorer" === $.appName, | |
s = [0, 0, 0], | |
l = null; | |
if (typeof $.plugins !== E && typeof $.plugins[F] === I) l = $.plugins[F].description, l && typeof $.mimeTypes !== E && $.mimeTypes[R] && $.mimeTypes[R].enabledPlugin && (V = !0, a = !1, l = l.replace(/^.*\s+(\S+\s+\S+$)/, "$1"), s[0] = v(l.replace(/^(.*)\..*$/, "$1")), s[1] = v(l.replace(/^.*\.(.*)\s.*$/, "$1")), s[2] = /[a-zA-Z]/.test(l) ? v(l.replace(/^.*[a-zA-Z]+(.*)$/, "$1")) : 0); | |
else if (typeof B.ActiveXObject !== E) try { | |
var u = new ActiveXObject(O); | |
u && (l = u.GetVariable("$version"), l && (a = !0, l = l.split(" ")[1].split(","), s = [v(l[0]), v(l[1]), v(l[2])])) | |
} catch (c) {} | |
return { | |
w3: e, | |
pv: s, | |
wk: o, | |
ie: a, | |
win: i, | |
mac: r | |
} | |
}(); | |
! function() { | |
G.w3 && ((typeof N.readyState !== E && ("complete" === N.readyState || "interactive" === N.readyState) || typeof N.readyState === E && (N.getElementsByTagName("body")[0] || N.body)) && e(), W || (typeof N.addEventListener !== E && N.addEventListener("DOMContentLoaded", e, !1), G.ie && (N.attachEvent(L, function t() { | |
"complete" === N.readyState && (N.detachEvent(L, t), e()) | |
}), B == top && ! function n() { | |
if (!W) { | |
try { | |
N.documentElement.doScroll("left") | |
} catch (t) { | |
return void setTimeout(n, 0) | |
} | |
e() | |
} | |
}()), G.wk && ! function i() { | |
return W ? void 0 : /loaded|complete/.test(N.readyState) ? void e() : void setTimeout(i, 0) | |
}())) | |
}() | |
} | |
j[0] = function() { | |
V ? i() : r() | |
}; | |
! function() { | |
G.ie && window.attachEvent("onunload", function() { | |
for (var e = U.length, t = 0; e > t; t++) U[t][0].detachEvent(U[t][1], U[t][2]); | |
for (var n = z.length, i = 0; n > i; i++) p(z[i]); | |
for (var r in G) G[r] = null; | |
G = null; | |
for (var o in swfobject) swfobject[o] = null; | |
swfobject = null | |
}) | |
}(); | |
return { | |
registerObject: function(e, t, n, i) { | |
if (G.w3 && e && t) { | |
var r = {}; | |
r.id = e, r.swfVersion = t, r.expressInstall = n, r.callbackFn = i, H[H.length] = r, x(e, !1) | |
} else i && i({ | |
success: !1, | |
id: e | |
}) | |
}, | |
getObjectById: function(e) { | |
return G.w3 ? o(e) : void 0 | |
}, | |
embedSWF: function(e, n, i, r, o, l, u, c, h, p) { | |
var f = m(n), | |
g = { | |
success: !1, | |
id: f | |
}; | |
G.w3 && !(G.wk && G.wk < 312) && e && n && i && r && o ? (x(f, !1), t(function() { | |
i += "", r += ""; | |
var t = {}; | |
if (h && typeof h === I) | |
for (var m in h) t[m] = h[m]; | |
t.data = e, t.width = i, t.height = r; | |
var y = {}; | |
if (c && typeof c === I) | |
for (var v in c) y[v] = c[v]; | |
if (u && typeof u === I) | |
for (var _ in u) | |
if (u.hasOwnProperty(_)) { | |
var w = K ? encodeURIComponent(_) : _, | |
k = K ? encodeURIComponent(u[_]) : u[_]; | |
typeof y.flashvars !== E ? y.flashvars += "&" + w + "=" + k : y.flashvars = w + "=" + k | |
} | |
if (b(o)) { | |
var C = d(t, y, n); | |
t.id == f && x(f, !0), g.success = !0, g.ref = C, g.id = C.id | |
} else { | |
if (l && a()) return t.data = l, void s(t, y, n, p); | |
x(f, !0) | |
} | |
p && p(g) | |
})) : p && p(g) | |
}, | |
switchOffAutoHideShow: function() { | |
Y = !1 | |
}, | |
enableUriEncoding: function(e) { | |
K = typeof e === E ? !0 : e | |
}, | |
ua: G, | |
getFlashPlayerVersion: function() { | |
return { | |
major: G.pv[0], | |
minor: G.pv[1], | |
release: G.pv[2] | |
} | |
}, | |
hasFlashPlayerVersion: b, | |
createSWF: function(e, t, n) { | |
return G.w3 ? d(e, t, n) : void 0 | |
}, | |
showExpressInstall: function(e, t, n, i) { | |
G.w3 && a() && s(e, t, n, i) | |
}, | |
removeSWF: function(e) { | |
G.w3 && p(e) | |
}, | |
createCSS: function(e, t, n, i) { | |
G.w3 && w(e, t, n, i) | |
}, | |
addDomLoadEvent: t, | |
addLoadEvent: n, | |
getQueryParamValue: function(e) { | |
var t = N.location.search || N.location.hash; | |
if (t) { | |
if (/\?/.test(t) && (t = t.split("?")[1]), !e) return k(t); | |
for (var n = t.split("&"), i = 0; i < n.length; i++) | |
if (n[i].substring(0, n[i].indexOf("=")) == e) return k(n[i].substring(n[i].indexOf("=") + 1)) | |
} | |
return "" | |
}, | |
expressInstallCallback: function() { | |
if (q) { | |
var e = g(D); | |
e && C && (e.parentNode.replaceChild(C, e), A && (x(A, !0), G.ie && (C.style.display = "block")), S && S(T)), q = !1 | |
} | |
}, | |
version: "2.3" | |
} | |
}(); | |
NS("AudioAddict.API").Channels = function(e, t, n) { | |
if (!(this instanceof arguments.callee)) return $.log(LogPrefix() + "AudioAddict.API.Channels: Forcing instantiation"), new AudioAddict.API.Channels(e, t, n); | |
$.log(LogPrefix() + "AudioAddict.API.Channels: Instantiating", arguments); | |
var i, r = NS("AudioAddict.API"), | |
o = e + "/" + t + "/", | |
a = "channel_filters", | |
s = "jsonp", | |
l = n || {}; | |
this.getTimeout = function() { | |
return "undefined" == typeof i && (i = l.timeout >= 100 ? i = 1e3 * i : r.Default.timeout), i | |
}, this.allUrl = function() { | |
return o + a + "/key/default." + s | |
}, this.channelFilterUrl = function(e) { | |
return o + a + "/key/" + e + "." + s | |
}, this.getAll = function(e, t) { | |
$.log(LogPrefix() + "AudioAddict.API.Channels.getAll(): Fetching all channels\u2026"), $.ajax({ | |
url: this.allUrl(), | |
dataType: "jsonp", | |
jsonpCallback: "_API_Channels_getAll", | |
timeout: this.getTimeout(), | |
success: e, | |
error: t || function(e, t) { | |
"timeout" == t && $.log(LogPrefix() + "AudioAddict.API.Channels.getAll(): Timed out!", e, t) | |
} | |
}) | |
}, this.getChannelFilter = function(e, t, n) { | |
$.log(LogPrefix() + "AudioAddict.API.Channels.getChannelFilter(): Fetching channels for filter {" + e + "}\u2026"), $.ajax({ | |
url: this.channelFilterUrl(e), | |
dataType: "jsonp", | |
jsonpCallback: "_API_Channels_getChannelFilter", | |
timeout: this.getTimeout(), | |
success: t, | |
error: n || function(e, t) { | |
"timeout" == t && $.log(LogPrefix() + "AudioAddict.API.Channels.getChannelFilter(): Timed out!", e, t) | |
} | |
}) | |
} | |
}, NS("AudioAddict.API.Channels").getChannelById = function(e) { | |
return this._channels = this._channels || _.pluck(AudioAddict.API.Config.channels, "channel"), this._keysById = this._keysById || {}, this._keysById[e] = this._keysById[e] || _.findWhere(this._channels, { | |
id: e | |
}), this._keysById[e] | |
}, NS("AudioAddict.API.Channels").getChannelByKey = function(e) { | |
return this._channels = this._channels || _.pluck(AudioAddict.API.Config.channels, "channel"), this._idsByKey = this._idsByKey || {}, this._idsByKey[e] = this._idsByKey[e] || _.findWhere(this._channels, { | |
key: e | |
}), this._idsByKey[e] | |
}, NS("AudioAddict.API").Playlists = function(e, t) { | |
if (!(this instanceof arguments.callee)) return $.log(LogPrefix() + "AudioAddict.API.Playlists: Forcing instantiation"), new AudioAddict.API.Playlists(e, t); | |
$.log(LogPrefix() + "AudioAddict.API.Playlists: Instantiating", arguments); | |
var n, i = NS("AudioAddict.API"), | |
r = e, | |
o = i.Config.listenKey, | |
a = t || {}; | |
a.streamset || (a.streamset = "webplayer"), a.ext || (a.ext = "jsonp"), this.getTimeout = function() { | |
return "undefined" == typeof n && (n = a.timeout >= 100 ? n = 1e3 * n : i.Default.timeout), n | |
}, this.appendListenKey = function(e) { | |
return null !== o ? e + "?listen_key=" + o : e | |
}, this.allUrl = function() { | |
var e = r + "/" + a.streamset + "." + a.ext; | |
return this.appendListenKey(e) | |
}, this.channelUrl = function(e) { | |
var t = r + "/" + a.streamset + "/" + e + "." + a.ext; | |
return this.appendListenKey(t) | |
}, this.getAll = function(e, t) { | |
$.log(LogPrefix() + "AudioAddict.API.Playlists.getAll(): Fetching playlists for all channels\u2026"), $.ajax({ | |
url: this.allUrl(), | |
dataType: "jsonp", | |
jsonpCallback: "_API_Playlists_getAll", | |
timeout: this.getTimeout(), | |
success: e, | |
error: t || function(e, t) { | |
"timeout" == t && $.log(LogPrefix() + "AudioAddict.API.Playlists.getAll(): Timed out!", e, t) | |
} | |
}) | |
}, this.getChannel = function(e, t, n) { | |
$.log(LogPrefix() + "AudioAddict.API.Playlists.getChannel(): Fetching playlists for channel {" + e + "}\u2026"), $.ajax({ | |
url: this.channelUrl(e), | |
dataType: "jsonp", | |
cache: !0, | |
jsonpCallback: "_API_Playlists_getChannel", | |
timeout: this.getTimeout(), | |
success: t, | |
error: n || function(e, t) { | |
"timeout" == t && $.log(LogPrefix() + "AudioAddict.API.Playlists.getChannel(): Timed out!", e, t) | |
} | |
}) | |
} | |
}, window.Channel = Class.extend({ | |
init: function(e) { | |
if ("undefined" == typeof e) throw "AudioAddict.WP.Channel: FATAL: No parameters provided"; | |
if (!e.channels) throw "AudioAddict.WP.Channel: FATAL: channels not provided"; | |
var t = this; | |
t.channels = e.channels, t.channelsByKey = {}, t.channelsById = {}, t.assetsByKey = {}, t.changedTs = null, $.each(t.channels, function() { | |
this.channel ? (t.channelsByKey[this.channel.key] = this.channel, t.channelsById[this.channel.id] = this.channel) : (t.channelsByKey[this.key] = this, t.channelsById[this.id] = this) | |
}), e.assets && $.each(e.assets.channel_assets, function() { | |
t.channelsByKey[this.key] && (t.channelsByKey[this.key].assets = this.assets[0]) | |
}), $.log(LogPrefix() + "AudioAddict.WP.Channel: Initialized") | |
}, | |
set: function(e, t) { | |
return !this.channelsByKey[e] || this.channel && this.channel.key === e ? ($(document).trigger("Channel.Set", { | |
id: t | |
}), !1) : (this.changedTs = getUnixTimestamp(), this.channel = this.channelsByKey[e], $.log(LogPrefix() + "AudioAddict.WP.Channel: Channel set to {" + e + "}", this.channel), $(document).trigger("Channel.Set", this.channel), di.eventbus.trigger("webplayer:channel:change", this.channel), this.channel) | |
}, | |
get: function() { | |
return this.channel | |
}, | |
getByKey: function(e) { | |
return this.channelsByKey[e] | |
}, | |
getById: function(e) { | |
return this.channelsById[e] | |
}, | |
getLastChangedTimestamp: function() { | |
return this.changedTs | |
} | |
}), di.provide("di.math.ExponentialBackoff"), di.math.ExponentialBackoff = function(e, t) { | |
if (1 > e) throw "Initial value must be greater than zero."; | |
if (e > t) throw "Max value must be be equal to or greater than the initial value."; | |
this.initialValue_ = e, this.maxValue_ = t, this.currValue_ = e | |
}, di.math.ExponentialBackoff.prototype.currCount_ = 0, di.math.ExponentialBackoff.prototype.reset = function() { | |
this.currValue_ = this.initialValue_, this.currCount_ = 0 | |
}, di.math.ExponentialBackoff.prototype.getValue = function() { | |
return this.currValue_ | |
}, di.math.ExponentialBackoff.prototype.getMaxValue = function() { | |
return this.maxValue_ | |
}, di.math.ExponentialBackoff.prototype.getCount = function() { | |
return this.currCount_ | |
}, di.math.ExponentialBackoff.prototype.backoff = function() { | |
this.currValue_ = Math.min(this.maxValue_, 2 * this.currValue_), this.currCount_++ | |
}, | |
function(e, t, n) { | |
function i(e) { | |
function t(e) { | |
return s ? e && e.type === s.type && e.track === s.track : !1 | |
} | |
function i() { | |
var e = getUnixTimestamp(), | |
i = []; | |
n.each(o, function() { | |
this.started < e && !this.isJingle && !t(this) && (!this.ended || this.ended <= e + 25) ? i.push(this) : p.log("removing track from trackHistory: ", this) | |
}), o = i.slice(0, l) | |
} | |
function r() { | |
i(), p.log("sending metadata-history-update with tracks:", o), n(document).trigger("metadata-history-update", [o]) | |
} | |
e = e || {}; | |
var o = [], | |
a = null, | |
s = null, | |
l = e.maxHistory || 40; | |
this.load = function(e) { | |
o = e.slice(0), r() | |
}, this.trackStarted = function(e) { | |
s = e, a = getUnixTimestamp(), p.log("New now playing track: ", s), i() | |
}, this.trackComplete = function(e) { | |
var t = getUnixTimestamp(); | |
return e.type === s.type && e.track === s.track && 5 > t - a ? void p.log("ad caused early track-complete event, ignoring:", e) : e.isJingle ? void p.log("Track too short, ignoring", e) : (o.unshift(e), void r()) | |
} | |
} | |
function r(e, t) { | |
var i = { | |
started: getUnixTimestamp() | |
}; | |
if (p.log("AudioAddict.WP.Metadata: Flash metadata received", t), t.audiosamplerate) p.log("Flash metadata is a premium track"), i = n.extend(i, { | |
type: "track", | |
track: t.title, | |
apiDependent: !0 | |
}); | |
else if (t.adw_ad) { | |
if (p.log("Flash metadata is an AdsWizz ad"), i = n.extend(i, { | |
type: "advertisement", | |
provider: "adswizz", | |
banner: !0, | |
track: S, | |
apiDependent: !1, | |
duration: parseInt(t.durationMilliseconds, 10) | |
}), "string" == typeof t.metadata) { | |
var r = t.metadata.indexOf("adswizzContext="); | |
i.context = -1 !== r ? t.metadata.slice(r + 15) : null | |
} | |
} else t.StreamTitle && t.StreamTitle.indexOf("TSTAG") > -1 || (t.StreamTitle ? (p.log("Flash metadata is a public track"), i = n.extend(i, { | |
type: "track", | |
track: t.StreamTitle, | |
apiDependent: !0 | |
})) : (p.log("Flash metadata is unrecognised"), i = n.extend(i, { | |
type: "track", | |
track: "Track Information Unavailable", | |
apiDependent: !1, | |
accurate: !1 | |
}))); | |
return p.log("Flash metadata: {" + i.track + "}"), k && s(k, i) || C && s(C, i) ? (p.log("Flash metadata is duplicate of the current or previous track; ignoring {" + k.track + "}"), p.log("Resetting timecode for accuracy"), g.wp.timecode.reset(), !1) : (k = i, void(i.apiDependent ? o(i) : c(i))) | |
} | |
function o(e) { | |
var t = function() { | |
var n = a(e); | |
n ? (c(n), E.getCount() > 0 && di.analytics.trackNonInteractiveEvent("WP.Error", "api-dependent track resolved after retries", JSON.stringify({ | |
retries: E.getCount(), | |
item: { | |
type: n.type, | |
id: n.track_id || n.id || n.track || n | |
} | |
}))) : (0 === E.getCount() && c(e), p.log("No match found in history. Retrying API (#" + (E.getCount() + 1) + ") in " + E.getValue() / 1e3 + "s"), p.resolverTimeoutId = setTimeout(function() { | |
h(t) | |
}, E.getValue()), E.backoff()) | |
}; | |
p.resolverTimeoutId && (clearTimeout(p.resolverTimeoutId), p.resolverTimeoutId = null), E.reset(), clearTimeout(b), b = null, v = y, h(t) | |
} | |
function a(e) { | |
var t = _.map(_.pluck(w, "track"), O), | |
n = O(F(e.track)); | |
window._forceTrackHistoryNoMatch && (n += Math.random().toString()); | |
var i = t ? t.indexOf(n) : -1, | |
r = w[i]; | |
return r ? (p.log("Found match {" + n + "} amongst API results"), 0 === i && T && (p.log("Using existing local start time:", e.started), r.started = e.started, r.ended = r.started + r.length)) : p.log("ERROR: Could not find {" + n + "} amongst API metadata; using Flash metadata only"), r | |
} | |
function s(e, t) { | |
return "track" === e.type ? e.track === t.track : e.provider === t.provider && "adswizz" === e.provider ? !1 : e.track === t.track && e.provider === t.provider | |
} | |
function l() { | |
var e = I[g.wp.member.getAccess()][g.wp.streamlist.getCurrentBitrate()]; | |
return "undefined" == typeof e ? 0 : e | |
} | |
function u(e) { | |
{ | |
var t; | |
n.extend(!0, {}, e) | |
} | |
"advertisement" === e.type && (e.length = e.duration, e.url = null, e.banner = null, e.track = F(e.track), 0 === e.track.trim().length && (e.track = S), "undefined" == typeof e.provider && (e.provider = "internal"), "internal" === e.provider && (e.url = A, e.track.indexOf(" - ") > -1 && (t = e.track.split(" - "), e.track = t[0], e.url = t[1]), "object" == typeof e.ad && (e.ad.banner && e.ad.banner.length > 0 && (e.banner = e.ad.banner), e.ad.url && e.ad.url.length > 0 && (e.url = e.ad.url)))), e.isJingle = "track" == e.type && e.length > 0 && e.length < 30, e.timeDeterminate = !0, e.started ? e.started += l() : (e.started = getUnixTimestamp(), e.timeDeterminate = !1), e.length ? e.ended = e.started + e.length : (e.length = 0, e.ended = null, e.timeDeterminate = !1), e.normalized = !0 | |
} | |
function c(e) { | |
if (T || (T = !0), p.log("Metadata parsed", e), x && (x = null), e.normalized || u(e), e.timeDeterminate && e.ended < getUnixTimestamp() && (p.log("end time for current track is in the past, time is indeterminate"), e.timeDeterminate = !1), "track" == e.type) { | |
if (g.wp.adManager && g.wp.adManager.isExternal()) return p.log("External ad is playing {" + g.wp.adManager.type() + "}, deferring track change", e), x = e, void n(document).on("ad-end", d); | |
p.log("External ad is NOT playing, triggering track begin event", e), P.trackStarted(e), n(document).trigger("metadata-track", [e]), di.eventbus.trigger("webplayer:track:begin", e) | |
} else p.log("Triggering ad event", e), n(document).trigger("ad-new", [e]); | |
null != C && (C.ended || (C.ended = Math.floor((Date.now() - 100) / 1e3)), p.log("Triggering track end event", C), P.trackComplete(C), n(document).trigger("metadata-track-complete", [C]), p.log("Triggering track end event: complete")), C = e | |
} | |
function d(e, t) { | |
p.log("External ad ended; triggering deferred track change", x, e, t), n(document).off("ad-end", d), x ? c(x) : p.log("Deferred track change information unavailable") | |
} | |
function h(e) { | |
var t = g.wp.getState(); | |
if ("connected" !== t) return p.log("Not allowed to query the API because player is currently {" + t + "}"), !1; | |
var i = function(t) { | |
v = y; | |
var i = "premium" === g.wp.member.getAccess(); | |
p.log("API metadata received", t), w = [], n(t).each(function() { | |
this.started -= g.wp.timeKeeper.serverTimeOffsetSec, u(this), ("advertisement" != this.type || !i && this.url) && w.push(this) | |
}), e(), P.load(w), n(document).trigger("metadata-load", [w]) | |
}, | |
r = function(e) { | |
if (p.log("track history request failed"), v--, 429 === e.statusCode()) p.log("ERROR: 429 reponse code; halting requests"); | |
else if (v > -1) { | |
var t = Math.round(29e3 * Math.random() + 1e3); | |
p.log("retry " + (y - v) + "/" + y + " in: " + t / 1e3 + " seconds"), b = setTimeout(function() { | |
M.getChannel(m, i, r) | |
}, t) | |
} else p.log(y + " retries exahusted") | |
}; | |
M.getChannel(m, i, r) | |
} | |
var p, f, m, g = (NS("AudioAddict.Util"), NS("AudioAddict.WP")), | |
y = 3, | |
v = y, | |
b = null, | |
w = [], | |
x = null, | |
k = null, | |
C = null, | |
A = "", | |
S = "Sponsored Message", | |
T = !1, | |
P = null, | |
M = new AudioAddict.API.TrackHistory(AudioAddict.API.Config.url, AudioAddict.API.Config.network), | |
E = new di.math.ExponentialBackoff(Math.round(500 + 1e3 * Math.random()), 12e4), | |
I = { | |
"public": { | |
40: 26, | |
64: 26 | |
}, | |
premium: { | |
40: 12, | |
64: 7, | |
96: 3, | |
128: 1 | |
} | |
}, | |
F = _.memoize(function(e) { | |
return (e || "").replace(/ADWTAG_\d{5}_START=0|TSTAG_\d{2}|\[SJ247\]/g, "") | |
}), | |
O = _.memoize(function(e) { | |
return e.replace(/[^A-z]/g, "").toLowerCase() | |
}); | |
NS(e).Metadata = t.extend({ | |
NS: e + ".Metadata", | |
_required: ["url"], | |
init: function(e) { | |
p = this, f = e.url, A = NS("AudioAddict.API").Static.urlPremium, P = new i, n(document).on("player-metadata", r), n(document).on("Channel.Set", function(e, t) { | |
m = t.id | |
}), n(document).on("wp-disconnect wp-stop", function() { | |
k = C = x = null, T = !1 | |
}), p.log("Initialized") | |
} | |
}) | |
}("AudioAddict.WP", AudioAddict.Modules.Base, jQuery), NS("AudioAddict.WP").Error = { | |
BufferTimeout: 1, | |
FlashBlocked: 2 | |
}, | |
function() { | |
var e = {}.hasOwnProperty, | |
t = function(t, n) { | |
function i() { | |
this.constructor = t | |
} | |
for (var r in n) e.call(n, r) && (t[r] = n[r]); | |
return i.prototype = n.prototype, t.prototype = new i, t.__super__ = n.prototype, t | |
}; | |
di.provide("AudioAddict.WP.Streamlist"), AudioAddict.WP.Streamlist = function(e) { | |
function n(e) { | |
this.delegateEventMaps(), this.settings = new o, this.settings.set(e) | |
} | |
var i, r, o, a, s, l; | |
return t(n, e), r = 10, a = "stream:ready", s = "stream:timeout", l = "stream:unavailable", o = function(e) { | |
function n() { | |
return n.__super__.constructor.apply(this, arguments) | |
} | |
var i; | |
return t(n, e), i = "webplayer", n.prototype.defaults = { | |
channel: void 0, | |
access: null, | |
listenKey: "", | |
speed: null, | |
streamsets: null | |
}, n.prototype.getStreamset = function() { | |
var e, t; | |
return e = this.getSpeeds(), t = e[this.get("speed")] || _.first(_.values(e)) | |
}, n.prototype.getStreamsetKey = function() { | |
return this.getStreamset().key | |
}, n.prototype.getBitrate = function() { | |
return this.getStreamset().bitrate | |
}, n.prototype.getSpeeds = function() { | |
return this.get("streamsets")[this.get("access")][i] | |
}, n.prototype.getChannelKey = function() { | |
var e; | |
return e = this.get("channel"), e ? e.get("key") : void 0 | |
}, n | |
}(Backbone.Model), i = function(e) { | |
function n() { | |
return n.__super__.constructor.apply(this, arguments) | |
} | |
var i, r, o; | |
return t(n, e), o = "pub", r = ".flv", i = "com_adswizz_synchro_decorateUrl", n.prototype.initialize = function(e) { | |
this.settings = e | |
}, n.prototype.path = function() { | |
var e; | |
return e = "listen/" + this.settings.getStreamsetKey() + "/" + this.settings.getChannelKey(), this.settings.get("listenKey") && (e += "?listen_key=" + this.settings.get("listenKey")), e | |
}, n.prototype.parse = function(e) { | |
var t; | |
return t = this.settings.get("listenKey") ? this.settings.get("listenKey") + "&" : "", _.map(e, function(e) { | |
var n, a, s, l; | |
if (s = e.replace(r, "").split("?"), n = s[0], a = { | |
type: r | |
}, l = n + "?" + t + $.param(a), l.indexOf(o) > -1) try { | |
l = window[i](l) | |
} catch (u) {} | |
return { | |
url: l | |
} | |
}) | |
}, n | |
}(di.mixOf(Backbone.Collection, di.api.Adapter)), n.prototype.logger = new di.log.Console("AudioAddict.WP.Streamlists"), n.prototype.documentEvents = { | |
"member-access": "onAccessChanged_", | |
"member-listenkey": "onListenKeyChanged_", | |
"member-speed": "onSpeedChanged_" | |
}, n.prototype.onAccessChanged_ = function(e, t) { | |
return this.settings.set({ | |
access: t | |
}) | |
}, n.prototype.onListenKeyChanged_ = function(e, t) { | |
return this.settings.set({ | |
listenKey: t | |
}) | |
}, n.prototype.onSpeedChanged_ = function(e, t) { | |
return this.settings.set({ | |
speed: t | |
}) | |
}, n.prototype.fetchStreamlists_ = function(e) { | |
return null == e && (e = 0), null == this.apiPlaylistsCollection && (this.apiPlaylistsCollection = new i(this.settings)), this.apiPlaylistsCollection.fetch({ | |
success: function(e) { | |
return function(t) { | |
var n; | |
return t.length < 1 ? (e.logger.log("Empty streamlist received, giving up"), e.trigger(l), e.promise.rejectWith(null, [l])) : (n = t.sample().get("url"), e.trigger(a, n), e.promise.resolveWith(null, [n])) | |
} | |
}(this), | |
error: function(t) { | |
return function() { | |
return ++e < r ? (t.logger.log("attempting to fetch another streamlist..."), t.fetchStreamlists_(e)) : (t.logger.log("Failed to fetch streamlists, giving up"), t.trigger(s), t.promise.rejectWith(null, [s])) | |
} | |
}(this) | |
}) | |
}, n.prototype.getStreamForChannel = function(e) { | |
return e ? (this.promise = new $.Deferred, this.settings.set({ | |
channel: e | |
}), this.fetchStreamlists_(), this.promise) : void 0 | |
}, n.prototype.getSpeeds = function() { | |
return this.settings.getSpeeds() | |
}, n.prototype.getCurrentBitrate = function() { | |
return this.settings.getBitrate() | |
}, n | |
}(di.mixin.EventMapper) | |
}.call(this), | |
function() { | |
var e, t = {}.hasOwnProperty, | |
n = function(e, n) { | |
function i() { | |
this.constructor = e | |
} | |
for (var r in n) t.call(n, r) && (e[r] = n[r]); | |
return i.prototype = n.prototype, e.prototype = new i, e.__super__ = n.prototype, e | |
}; | |
di.provide("AudioAddict.WP.WebPlayer"), e = function() { | |
function e() {} | |
var t, n, i, r; | |
return t = swfobject.getFlashPlayerVersion(), n = { | |
major: 10, | |
minor: 2 | |
}, i = 0 === t.major, r = t.major < n.major || t.major === n.major && t.minor < n.minor, e.prototype.enforce = function() { | |
return Modernizr.addTest("flash", !(i || r)), i ? di.app.commands.execute("flash:error", "install") : r ? di.app.commands.execute("flash:error", "update") : $.log("Flash Version: " + t.major + "." + t.minor + "." + t.release) | |
}, e | |
}(), AudioAddict.WP.WebPlayer = function(t) { | |
function i(e) { | |
var t; | |
this.options = e, this.delegateEventMaps(), $.log(" "), $.log("\u250f\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513"), $.log("\u2503 \u2588\u2593\u2592\u2591 WebPlayer 4.0 \u2591\u2592\u2593\u2588 \u2503"), $.log("\u2520\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2528"), $.log("\u2503 \xa9 AudioAddict Inc \u2503"), $.log("\u2503 All Rights Reserved \u2503"), $.log("\u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251b"), $.log(" "), this.flashPolicy.enforce(), "public" === AudioAddict.API.Config.access && (AudioAddict.webplayer.adblocks.initialize(), AudioAddict.webplayer.ui.ads.initialize()), di.app.commands.setHandler("webplayer:reconnect", this.play, this), di.app.commands.setHandler("webplayer:unmute", this.unMute, this), di.app.commands.setHandler("webplayer:mute", this.mute, this), di.app.commands.setHandler("webplayer:setVolume", this.setVolume, this), di.app.commands.setHandler("webplayer:audio:start", this.play, this), di.app.commands.setHandler("webplayer:audio:stop", this.stop, this), di.app.reqres.setHandler("webplayer:state", this.getState, this), t = new AudioAddict.Modules.PlayerSettings({ | |
authenticated: AudioAddict.API.Config.authenticated, | |
access: AudioAddict.API.Config.access, | |
listenUrl: AudioAddict.API.Config.listenUrl, | |
listenKey: AudioAddict.API.Config.listenKey, | |
streams: AudioAddict.API.Streamsets | |
}), this.member = new Member({ | |
access: AudioAddict.API.Config.access, | |
listenKey: AudioAddict.API.Config.listenKey, | |
speed: t.getBitrate() | |
}), this.streamlist = new AudioAddict.WP.Streamlist({ | |
access: AudioAddict.API.Config.access, | |
listenKey: AudioAddict.API.Config.listenKey, | |
listenUrl: AudioAddict.API.Config.listenUrl, | |
streamsets: AudioAddict.API.Streamsets, | |
speed: t.getBitrate() | |
}), this.listenTo(this.streamlist, "stream:timeout", this.onConnectTimeout), this.listenTo(this.streamlist, "stream:unavailable", this.onConnectTimeout), new AudioAddict.WP.Metadata({ | |
url: "http://api.audioaddict.com/v1/" + AudioAddict.API.Config.network + "/track_history/channel/{id}.jsonp" | |
}), new Ping({ | |
url: AudioAddict.API.Config.url + "/ping.jsonp", | |
interval: h | |
}), this.timeKeeper = new TimeKeeper, this.adapter = new Player, this.adapter.init({ | |
bufferTimeoutDuration: s, | |
swfPath: g, | |
swfContainer: m, | |
playerId: p, | |
onError: _.bind(this.onError, this), | |
onConnect: _.bind(this.onConnect, this), | |
onReady: _.bind(this.onAdapterReady, this) | |
}) | |
} | |
var r, o, a, s, l, u, c, d, h, p, f, m, g, y; | |
return n(i, t), h = 900, s = 1e4, d = "disconnected", u = "connecting", l = "connected", f = "stopped", c = 3e5, r = 6e4, y = 1, p = "player", m = "player-swf", g = "/assets/webplayer/AudioAddict.WP2-1d5c7214cbd6f665907e5a77c73c09d7.swf", o = "#sponsor", a = 18e4, i.prototype.model = new Backbone.Model({ | |
state: d, | |
stream: null | |
}), i.prototype.modelEvents = { | |
"change:state": "onStateChanged" | |
}, i.prototype.logger = new di.log.Console("AudioAddict.WP.WebPlayer"), i.prototype.flashPolicy = new e, i.prototype.initChannel = function() { | |
var e; | |
return this.channel = new Channel({ | |
channels: di.app.options.channels | |
}), (e = di.app.request("webplayer:channel")) ? this.channel.set(e.get("key"), e.get("id")) : void 0 | |
}, i.prototype.initAdManager = function() { | |
return this.adManager = new AdManager({ | |
canvas: o, | |
cutoff: a, | |
providers: { | |
internal: "ad.int" !== AudioAddict.WP.debug, | |
adswizz: "ad.aw" !== AudioAddict.WP.debug | |
} | |
}) | |
}, i.prototype.showConnectTimeoutModal = function() { | |
throw di.app.commands.execute("webplayer:modal:connectiontimeout"), new Error("Connection timed out") | |
}, i.prototype.onDisconnect = function() { | |
return this.stop(), this.model.set({ | |
state: d | |
}) | |
}, i.prototype.onConnect = function() { | |
return this.model.set({ | |
state: l | |
}) | |
}, i.prototype.onAdapterReady = function() { | |
return this.logger.log("Webplayer Adapter is OMG, ready!"), this.initChannel(), this.initAdManager(), this.adapter.ready = !0, clearTimeout(this.adapterTimeoutId) | |
}, i.prototype.onError = function(e, t) { | |
return null == t && (t = ""), e === AudioAddict.WP.Error.BufferTimeout ? (this.logger.log("onError(): Buffer timeout triggered"), this.onDisconnect(), this.connect()) : di.app.commands.execute("flash:error", "blocked") | |
}, i.prototype.play = function() { | |
return this.connect() | |
}, i.prototype.stop = function() { | |
var e; | |
if ((e = this.getState()) !== d && e !== f) return this.logger.log("stop"), this.model.set({ | |
state: f | |
}), this.adManager.stop(), this.adapter.stop() | |
}, i.prototype.setVolume = function(e) { | |
var t; | |
return null != (t = this.adapter) ? t.setVolume(e) : void 0 | |
}, i.prototype.getVolume = function() { | |
var e; | |
return null != (e = this.adapter) ? e.getVolume() : void 0 | |
}, i.prototype.getPlayerVolume = function() { | |
return this.getVolume() | |
}, i.prototype.isMuted = function() { | |
return this.volumeProxy().isMuted() | |
}, i.prototype.muteToggle = function() { | |
return this.isMuted() ? this.unMute() : this.mute() | |
}, i.prototype.volumeProxy = function() { | |
try { | |
return this.adManager && this.adManager.isExternal() ? this.adManager : this.adapter | |
} catch (e) { | |
return this.adapter | |
} | |
}, i.prototype.mute = function() { | |
return this.volumeProxy().mute(), di.eventbus.trigger("webplayer:muted:change", !0) | |
}, i.prototype.unMute = function() { | |
return this.volumeProxy().unMute(), di.eventbus.trigger("webplayer:muted:change", !1) | |
}, i.prototype.fadeIn = function(e, t) { | |
return this.adapter.fadeIn(e || $.noop, t) | |
}, i.prototype.fadeOut = function(e) { | |
return this.adapter.fadeOut(e || $.noop) | |
}, i.prototype.tempMute = function() { | |
return this.adapter.tempMute() | |
}, i.prototype.tempUnMute = function() { | |
return this.adapter.tempUnMute() | |
}, i.prototype.onStateChanged = function(e, t) { | |
switch (t !== u && clearTimeout(this.connectTimeoutId), this.logger.log("state changed to: " + t), di.eventbus.trigger("webplayer:state:change", t), t) { | |
case u: | |
return this.adapter.ready || (this.adapterTimeoutId = setTimeout(this.flashPolicy.showFlashBlockError, r)), this.connectTimeoutId = setTimeout(_.bind(this.onConnectTimeout, this), c), $(document).trigger("wp-connecting"), di.eventbus.trigger("webplayer:connecting"); | |
case d: | |
return $(document).trigger("wp-stop"), $(document).trigger("wp-disconnect"), di.eventbus.trigger("webplayer:stop"), di.eventbus.trigger("webplayer:stream:disconnect"); | |
case l: | |
return $(document).trigger("wp-connect"), di.eventbus.trigger("webplayer:stream:connect"); | |
case f: | |
return $(document).trigger("wp-stop"), di.eventbus.trigger("webplayer:stop") | |
} | |
}, i.prototype.onConnectTimeout = function() { | |
return this.showConnectTimeoutModal(), this.logger.log("connect attempt timeout reached, stopping.") | |
}, i.prototype.connect = function() { | |
var e; | |
return this.stop(), this.model.set({ | |
state: u | |
}), e = this.getChannel(), e ? this.streamlist.getStreamForChannel(e).done(this.adapter.load) : void 0 | |
}, i.prototype.getState = function() { | |
return this.model.get("state") | |
}, i.prototype.setLocale = function(e) { | |
return this.model.set("locale", e) | |
}, i.prototype.getLocale = function() { | |
return this.model.get("locale") | |
}, i.prototype.getChannel = function() { | |
return di.app.reqres.request("webplayer:channel") | |
}, i | |
}(di.mixin.EventMapper) | |
}.call(this), NS("AudioAddict.WP.AdManager.providers").adswizz = function(e) { | |
function t(e) { | |
return decodeURIComponent(e) === e ? encodeURIComponent(e) : e | |
} | |
function n(e) { | |
var n = a + "&context=" + ($.trim(t(e)) || "") + "&cb=" + Date.now(); | |
$.log(LogPrefix() + "AudioAddict.WP.AdProvider_Adswizz: Setting banner url:", n), s.find("iframe")[0].src = n, s.show() | |
} | |
var i = "http://deliveryengine.di.adswizz.com/afr?zoneid=1", | |
r = null; | |
if (this.type = "adswizz", this.isReady = e.yes, this.isExternal = e.no, this.hasBanner = e.yes, this.begin = function(e) { | |
return $.log(LogPrefix() + "AudioAddict.WP.AdProvider_Adswizz: Beginning ad block"), clearTimeout(r), o = e, o.context && "" !== o.context ? (n(o.context), s.show(), $(document).trigger("ad-begin", [o]), di.eventbus.trigger("webplayer:ad:begin", o), this) : ($.log(LogPrefix() + "AudioAddict.WP.AdProvider_Adswizz: No ad context found."), !1) | |
}, this.end = function() { | |
return $.log(LogPrefix() + "AudioAddict.WP.AdProvider_Adswizz: Ending ad block"), s.find("iframe").attr("src", i), s.hide(), $(document).trigger("ad-end"), di.eventbus.trigger("webplayer:ad:end"), this | |
}, "undefined" == typeof e) throw "AudioAddict.WP.AdProvider_Adswizz: FATAL: Ad manager reference object not provided"; | |
var o, a = (NS("AudioAddict.WP"), NS("AudioAddict.Ad").adswizz.baseUrl), | |
s = $('<div id="adprovider-adswizz" style="position: absolute; z-index: 2; top: 0; left: 0;"><iframe width="300" height="250" frameborder="0" scrolling="no"></iframe></div>').appendTo(e.canvas()).hide(); | |
$.log(LogPrefix() + "AudioAddict.WP.AdProvider_Adswizz: Initialized") | |
}, NS("AudioAddict.WP.AdManager.providers")["default"] = function(e) { | |
if (this.type = "default", this.isReady = e.yes, this.isExternal = e.no, this.hasBanner = e.yes, this.begin = function() { | |
return $.log(LogPrefix() + "AudioAddict.WP.AdProvider_Default: Beginning ad"), t.show(), this | |
}, this.end = function() { | |
return $.log(LogPrefix() + "AudioAddict.WP.AdProvider_Default: Ending ad"), t.hide(), this | |
}, "undefined" == typeof e) throw "AudioAddict.WP.AdProvider_Default: FATAL: Ad manager reference object not provided"; | |
var t = $("#adprovider-default").appendTo(e.canvas()).hide() | |
}, NS("AudioAddict.WP.AdManager.providers").internal = function(e) { | |
if (this.type = "internal", this.isReady = e.yes, this.isExternal = e.no, this.hasBanner = function() { | |
return t.banner | |
}, this.begin = function(r) { | |
return "undefined" != typeof r && r ? ($.log(LogPrefix() + "AudioAddict.WP.AdProvider_Internal: Beginning new ad"), t = r, t.banner && (i.html('<img border="0" style="position: relative;" src="' + t.banner + '"></div>'), t.url && (i.indexOf("<a href") > -1 && i.unwrap(), i.wrap('<a href="' + t.url + '" target="_blank">')), n = i.find("img").load(function() { | |
setTimeout(function() { | |
n.width() > e.canvas().width() && n.css("width", e.canvas().width()), n.height() > e.canvas().height() && n.css("height", e.canvas().height()), n.css("left", e.canvas().width() / 2 - n.width() / 2), n.css("top", e.canvas().height() / 2 - n.height() / 2), i.show() | |
}, 100) | |
})), $(document).trigger("ad-begin", [t]), di.eventbus.trigger("webplayer:ad:begin", t), this) : ($.log(LogPrefix() + "AudioAddict.WP.AdProvider_Internal: Ad is not support by this provider, aborting", r, t), $(document).trigger("ad-end"), di.eventbus.trigger("webplayer:ad:end"), this) | |
}, this.end = function() { | |
return $.log(LogPrefix() + "AudioAddict.WP.AdProvider_Internal: Ending ad"), t.banner && i.hide().empty(), $(document).trigger("ad-end"), di.eventbus.trigger("webplayer:ad:end"), this | |
}, "undefined" == typeof e) throw "AudioAddict.WP.AdProvider_Internal: FATAL: Ad manager reference object not provided"; | |
var t, n, i = $('<div id="adprovider-internal" style="position: absolute; z-index: 1; top: 0; left: 0;"></div>').appendTo(e.canvas()).hide(); | |
$.log(LogPrefix() + "AudioAddict.WP.AdProvider_Internal: Initialized") | |
}, | |
function() { | |
var e, t, n, i, r, o, a, s; | |
s = "AudioAddict.webplayer.adblocks", r = di.provide(s), r.initialized || (i = 5, e = "webplayer:adblock:begin", t = "webplayer:adblock:durationupdate", n = "webplayer:adblock:end", a = new di.log.Console(s), r.adBlockPlaying_ = !1, r.gracePeriodTimer_ = null, r.adBlockBegin = function(t) { | |
return r.adBlockPlaying_ = !0, a.log("Ad block begun"), di.eventbus.trigger(e, t) | |
}, r.adBlockDurationUpdate = function(e) { | |
return a.log("Received duration update for ad block, {" + e + "} secs remaining + {" + i + "} secs grace period"), di.eventbus.trigger(t, e + i) | |
}, r.adBlockEnd = function() { | |
return r.adBlockPlaying_ = !1, a.log("Ad gap grace period (if applicable) over, ad block ended"), di.eventbus.trigger(n) | |
}, r.hasVisual_ = function(e) { | |
return !("internal" === (null != e ? e.provider : void 0) && null === e.banner && e.url.indexOf("/premium") < 0) | |
}, r.adBegin_ = function(e, t) { | |
var n; | |
return r.adBlockPlaying_ && r.gracePeriodTimer_.reset(), t || !r.adBlockPlaying_ ? r.hasVisual_(e) ? (n = "preroll" === ("function" == typeof e.get ? e.get("position") : void 0), r.adBlockPlaying_ || r.adBlockBegin(n), t > 0 ? r.adBlockDurationUpdate(t) : void 0) : void a.log("Ad has no visual part, so not starting ad block") : void 0 | |
}, r.adEnd_ = function() { | |
return r.adBlockPlaying_ ? r.gracePeriodTimer_.start() : void 0 | |
}, r.prerollEnd_ = function() { | |
return r.gracePeriodTimer_.reset(), r.adBlockEnd() | |
}, o = { | |
"webplayer:ad:begin": r.adBegin_, | |
"webplayer:ad:end webplayer:track:begin": r.adEnd_, | |
"webplayer:ads:preroll-end": r.prerollEnd_ | |
}, r.initialize = function() { | |
return di.eventbus.bind(o), null == r.gracePeriodTimer_ && (r.gracePeriodTimer_ = new di.date.Timer(1e3 * i, r.adBlockEnd)), r.initialized = !0, a.log("Initialized.") | |
}, r.destroy = function() { | |
var e; | |
return di.eventbus.unbind(o), null != (e = r.gracePeriodTimer_) && e.reset(), r.adBlockPlaying_ = !1, r.initialized = !1, a.log("Destroyed.") | |
}) | |
}.call(this), | |
function(e) { | |
e.fn.serializeJSON = function() { | |
var t = {}; | |
return e.map(e(this).serializeArray(), function(e) { | |
t[e.name] = e.value | |
}), t | |
} | |
}(jQuery), | |
function(e) { | |
function t(e, t) { | |
return this.stop().animate({ | |
top: e | |
}, this.data("settings").duration, t) | |
} | |
function n() { | |
return this.find(".errors").empty() | |
} | |
var i = { | |
duration: 300, | |
panelClass: ".panel", | |
closeClass: ".panel-close", | |
saveClass: ".panel-save", | |
forceVisible: !1, | |
spinOpt: { | |
lines: 9, | |
length: 7, | |
width: 4, | |
radius: 14, | |
corners: 1, | |
trail: 75, | |
speed: 1.2, | |
shadow: "on" | |
} | |
}, | |
r = [], | |
o = { | |
init: function(t) { | |
var r = {}, | |
a = this.outerHeight(!0), | |
s = this; | |
return e.extend(!0, r, i, t), this.find(r.closeClass).unbind("click").click(function(t) { | |
e(this).attr("disabled") || o.hide.call(s), t.preventDefault() | |
}), r.save && this.find(r.saveClass).unbind("click").click(function(e) { | |
e.preventDefault(); | |
var t = s.find(":input").serializeJSON(); | |
(!r.beforeSave || r.beforeSave.call(s, t)) && (n.call(s), r.save.call(s, t) && s.panel("hide")) | |
}), this.data("initialized", !0), this.data("height", a), this.data("settings", r), this | |
}, | |
wait: function(e) { | |
var t = this.find(".wait"); | |
0 === t.length && (t = this.prepend('<div class="overlay wait"><div class="spin"></div></div>').find(".wait")); | |
var n = t.is(":visible"); | |
return "undefined" == typeof e && (e = !n), e && !n ? t.fadeIn().find(".spin").spin(this.data("settings").spinOpt) : !e && n && (t.is(":animated") ? t.hide() : t.fadeOut(), t.find(".spin").spin(!1)), this.data("waiting", t.is(":visible")) | |
}, | |
error: function(t) { | |
var n = this.find(".errors"); | |
return 0 !== n.length && (n.empty(), "string" == typeof t && (t = [t]), e.each(t, function(e, t) { | |
n.append("<li>" + t + "</li>") | |
})), this | |
}, | |
message: function(e, t, n) { | |
var i = this, | |
r = this.find(".message"); | |
0 === r.length && (r = this.prepend('<div class="overlay message"><h1></h1><p></p><div class="buttons"><button class="button main-button panel-save">OK</button></div></div>').find(".message")); | |
var o = (r.is(":visible"), r.find("p")), | |
a = r.find("h1"), | |
s = r.find(".panel-save"); | |
return o.html(t), a.html(e), r.fadeIn(200, function() { | |
i.data("waiting") && i.panel("wait", !1) | |
}), s.click(function() { | |
s.unbind("click"), "function" == typeof n && n.call(i) || n ? i.panel("hide", function() { | |
r.hide(), o.empty(), a.empty() | |
}) : (r.fadeOut(), o.empty(), a.empty()) | |
}), this | |
}, | |
show: function(n) { | |
var i, o = 0, | |
a = 1; | |
i = _.partition(r, function(t) { | |
return e(t).is(".forced") | |
}); | |
for (var s = 0; s < i[a].length; s++) e(i[a][s]).panel("hide"); | |
r = i[o], this.show(), r.push(this); | |
try { | |
this.data("settings").show.call(this) | |
} catch (l) {} | |
return t.call(this, "-" + this.data("height"), n) | |
}, | |
hide: function(e) { | |
n.call(this); | |
try { | |
this.data("settings").hide.call(this) | |
} catch (i) {} | |
var r = this; | |
return t.call(this, 0, function() { | |
r.data("settings").forceVisible || r.hide(); | |
try { | |
e.call(r) | |
} catch (t) {} | |
}) | |
}, | |
toggle: function() { | |
return o[this.is(":visible") ? "hide" : "show"].call(this) | |
} | |
}; | |
e.fn.panel = function(t) { | |
return 0 === this.length ? e.error("unable to locate element") : t && "object" != typeof t ? o[t] ? ("undefined" == typeof this.data("initialized") && o.init.call(this, {}), o[t].apply(this, Array.prototype.slice.call(arguments, 1))) : void e.error("Method " + t + " does not exist on jQuery.panel") : o.init.apply(this, arguments) | |
} | |
}(jQuery), | |
function() { | |
var e, t, n, i; | |
i = "AudioAddict.webplayer.ui.ads", e = di.provide(i), e.initialized || (n = new di.log.Console(i), e.panelId = "panel-ad", e.closeSelector = ".panel-close", e.remainingTimeSelector = ".remaining-time", e.fallbackDelay = 180, e.$panel = null, e.$closeButton = null, e.$closeButtonTimer = null, e.initialized = !1, e.uiInitialized_ = !1, e.secondsRemaining_ = null, e.countdownTimer_ = null, e.fallbackTimer_ = null, e.initializeUi_ = function() { | |
return e.$panel = $("#" + e.panelId), e.$closeButton = e.$panel.find(e.closeSelector), e.$closeButtonTimer = e.$panel.find(e.remainingTimeSelector), e.$panel.exists() ? e.$closeButton.exists() ? (n.log("Initialized UI components"), e.uiInitialized_ = !0) : (n.log("Close button with selector {" + e.closeSelector + " not found, failed UI init."), !1) : (n.log("Panel element with id {" + e.panelId + "} not found, failed UI init."), !1) | |
}, e.forceAdPanel_ = function() { | |
var t; | |
return null != (t = e.$panel) ? t.show() : void 0 | |
}, e.clearCountdown_ = function() { | |
return e.$closeButton.hasClass("timer") && n.log("Removing close button countdown"), e.secondsRemaining_ = null, e.$closeButtonTimer.text(""), e.$closeButton.removeClass("timer"), null != e.countdownTimer_ ? (n.log("Clearing countdown timer"), e.countdownTimer_.reset(), e.countdownTimer_.off(), e.countdownTimer_ = null) : void 0 | |
}, e.countdownTick_ = function() { | |
return e.$closeButtonTimer.text(e.secondsRemaining_ + ""), e.secondsRemaining_ -= 1 | |
}, e.enableClosing_ = function() { | |
return e.$closeButton.removeClass("pending").removeAttr("disabled") | |
}, e.fallbackAdBlockEnd_ = function() { | |
return e.clearCountdown_(), n.log("Fallback timeout reached, making ad panel closeable"), e.enableClosing_(), e.fallbackTimer_.reset() | |
}, e.adblockBegin = function(t) { | |
return e.uiInitialized_ || e.initializeUi_() ? (n.log("Ad block begun, showing ad panel"), e.fallbackTimer_.reset(), e.fallbackTimer_.start(), e.$panel.toggleClass("preroll", t), e.jqueryPanelDisabled || e.$panel.panel("show"), e.$closeButton.addClass("pending").removeClass("timer").attr("disabled", "disabled")) : void 0 | |
}, e.adblockDurationUpdate = function(t) { | |
return e.uiInitialized_ || e.initializeUi_() ? (e.clearCountdown_(), n.log("Received duration update, displaying countdown for {" + t + "} seconds"), e.$closeButton.addClass("timer"), e.secondsRemaining_ = t, e.countdownTimer_ = new di.date.Timer(1e3, t), e.countdownTimer_.on(di.date.Timer.TICK, e.countdownTick_), e.countdownTimer_.on(di.date.Timer.COMPLETE, e.clearCountdown_), e.countdownTimer_.start(), e.countdownTick_()) : void 0 | |
}, e.prerollEnd = function() { | |
return e.enableClosing_(), e.jqueryPanelDisabled ? void 0 : e.$panel.panel("hide") | |
}, e.adblockEnd = function() { | |
return e.uiInitialized_ || e.initializeUi_() ? (e.fallbackTimer_.reset(), e.clearCountdown_(), n.log("Ad block ended, enabling close button"), e.enableClosing_()) : void 0 | |
}, t = { | |
"webplayer:stream:connect": e.forceAdPanel_, | |
"webplayer:adblock:begin": e.adblockBegin, | |
"webplayer:adblock:durationupdate": e.adblockDurationUpdate, | |
"webplayer:adblock:end": e.adblockEnd, | |
"webplayer:ads:preroll-end": e.prerollEnd | |
}, e.initialize = function() { | |
return e.initialized ? void n.log("Already initialized, not initializing again.") : (di.eventbus.on(t), e.fallbackTimer_ = new di.date.Timer(1e3 * e.fallbackDelay, e.fallbackAdBlockEnd_), e.initialized = !0, n.log("Initialized.")) | |
}, e.destroy = function() { | |
return e.initialized ? (di.eventbus.off(t), e.fallbackTimer_.reset(), e.clearCountdown_(), e.$panel = e.$closeButton = e.$closeButtonTimer = null, e.uiInitialized_ = !1, e.initialized = !1, n.log("Destroyed.")) : void 0 | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.Adapters", function(e, t, n, i, r, o) { | |
var a, s; | |
return s = { | |
IcecastPlayer: !1, | |
OnDemandPlayer: !1 | |
}, a = { | |
allAdpatersReady: function() { | |
return e.options.legacy || s.OnDemandPlayer && s.IcecastPlayer | |
}, | |
onAdapterReady: function(e) { | |
return console.info("Adapter Ready: " + e), s[e] = !0, a.allAdpatersReady() ? (t.WebplayerApp.model.set("ready", !0), t.vent.trigger("webplayer:ready")) : void 0 | |
} | |
}, this.addInitializer(function(e) { | |
return this.options = e, t.vent.on("webplayer:adapter:ready", o.bind(a.onAdapterReady, this)) | |
}) | |
}) | |
}.call(this), | |
function() { | |
var e = {}.hasOwnProperty, | |
t = function(t, n) { | |
function i() { | |
this.constructor = t | |
} | |
for (var r in n) e.call(n, r) && (t[r] = n[r]); | |
return i.prototype = n.prototype, t.prototype = new i, t.__super__ = n.prototype, t | |
}; | |
di.provide("di.model.Ad"), di.model.Ad = function(e) { | |
function n() { | |
return n.__super__.constructor.apply(this, arguments) | |
} | |
return t(n, e), n.prototype.defaults = { | |
width: 300, | |
height: 250 | |
}, n.prototype.initialize = function() { | |
var e, t; | |
return null == (e = this.attributes).width && (e.width = 300), null != (t = this.attributes).height ? t.height : t.height = 250 | |
}, n | |
}(Backbone.RelationalModel) | |
}.call(this), | |
function() { | |
var e = {}.hasOwnProperty, | |
t = function(t, n) { | |
function i() { | |
this.constructor = t | |
} | |
for (var r in n) e.call(n, r) && (t[r] = n[r]); | |
return i.prototype = n.prototype, t.prototype = new i, t.__super__ = n.prototype, t | |
}; | |
di.provide("di.collection.Ads"), di.collection.Ads = function(e) { | |
function n() { | |
return n.__super__.constructor.apply(this, arguments) | |
} | |
return t(n, e), n.prototype.model = di.model.Ad, n | |
}(Backbone.Collection) | |
}.call(this), | |
function() { | |
var e = {}.hasOwnProperty, | |
t = function(t, n) { | |
function i() { | |
this.constructor = t | |
} | |
for (var r in n) e.call(n, r) && (t[r] = n[r]); | |
return i.prototype = n.prototype, t.prototype = new i, t.__super__ = n.prototype, t | |
}; | |
di.provide("di.model.AdRuleset"), di.model.AdRuleset = function(e) { | |
function n() { | |
return n.__super__.constructor.apply(this, arguments) | |
} | |
return t(n, e), n.prototype.relations = [{ | |
type: "HasMany", | |
key: "ads", | |
keySource: "blocks", | |
keyDestination: "ads", | |
relatedModel: di.model.Ad, | |
relatedCollection: di.collection.Ads | |
}], n | |
}(Backbone.RelationalModel) | |
}.call(this), | |
function() { | |
var e = function(e, t) { | |
return function() { | |
return e.apply(t, arguments) | |
} | |
}, | |
t = {}.hasOwnProperty, | |
n = function(e, n) { | |
function i() { | |
this.constructor = e | |
} | |
for (var r in n) t.call(n, r) && (e[r] = n[r]); | |
return i.prototype = n.prototype, e.prototype = new i, e.__super__ = n.prototype, e | |
}; | |
di.provide("di.collection.AdRulesets"), di.collection.AdRulesets = function(t) { | |
function i() { | |
return this.parse = e(this.parse, this), i.__super__.constructor.apply(this, arguments) | |
} | |
return n(i, t), i.prototype.logger = new di.log.Console("di.collection.AdRulesets"), i.prototype.path = "ads/webplayer", i.prototype.model = di.model.AdRuleset, i.prototype.initialize = function(e, t) { | |
if (null == t.countryCode) throw "AdRulesets: missing countryCode"; | |
return this.countryCode = t.countryCode | |
}, i.prototype.findRulesets = function(e) { | |
var t; | |
return t = this.logger, this.filter(function(t) { | |
return null == t.get("channel_id") ? !0 : t.get("channel_id") === e | |
}) | |
}, i.prototype.parse = function(e) { | |
return this.logger.log("Parsing server response; filtering by country"), _.reject(e, function(e) { | |
return function(t) { | |
return null != t.country_code && t.country_code !== e.countryCode | |
} | |
}(this)) | |
}, i | |
}(di.collection.Base) | |
}.call(this), | |
function() { | |
var e = function(e, t) { | |
return function() { | |
return e.apply(t, arguments) | |
} | |
}, | |
t = {}.hasOwnProperty, | |
n = function(e, n) { | |
function i() { | |
this.constructor = e | |
} | |
for (var r in n) t.call(n, r) && (e[r] = n[r]); | |
return i.prototype = n.prototype, e.prototype = new i, e.__super__ = n.prototype, e | |
}; | |
di.provide("di.application.module.webplayer.ads.provider.Base"), di.application.module.webplayer.ads.provider.Base = function(t) { | |
function i() { | |
return this.volumeChanged_ = e(this.volumeChanged_, this), i.__super__.constructor.apply(this, arguments) | |
} | |
return n(i, t), i.prototype.logger = new di.log.Console("di.module.weplayer.ads.provider.Base"), i.prototype.eventbusEvents = { | |
"webplayer:volume:change": "volumeChanged_" | |
}, i.prototype.activeAd = null, i.prototype.pendingAd = null, i.prototype.startAd = function(e) { | |
if (this.logger.log("Ad triggered for provider {" + this.moduleName + "}"), !(e instanceof di.model.Ad)) throw new TypeError("Ad requested is not properly formatted, should be di.model.Ad"); | |
if (e.get("network") !== this.moduleName) throw new TypeError("Ad passed does not match provider. " + e.get("network") + " vs " + this.moduleName); | |
return "preroll" === e.get("position") && di.eventbus.trigger("webplayer:ad:preroll-loading"), this.pendingAd = e | |
}, i.prototype.stopAd = function() { | |
return this.logger.log("Stopping any active ads for provider {" + this.moduleName + "}") | |
}, i.prototype.adBegin_ = function() { | |
return this.logger.log("Ad begun for provider {" + this.moduleName + "}, dispatching event."), this.activeAd = this.pendingAd, this.pendingAd = null, di.eventbus.trigger("webplayer:ad:begin", this.activeAd) | |
}, i.prototype.adEnd_ = function() { | |
return this.activeAd ? (di.eventbus.trigger("webplayer:ad:end", this.activeAd), this.activeAd = null) : void 0 | |
}, i.prototype.noAdsAvailable_ = function() { | |
return this.activeAd || this.pendingAd ? (di.eventbus.trigger("webplayer:ad:none_available", this.activeAd || this.pendingAd), this.activeAd && (this.activeAd = null), this.pendingAd ? this.pendingAd = null : void 0) : void 0 | |
}, i.prototype.getWebplayerVolume_ = function() { | |
return this.app.request("webplayer:volume") | |
}, i.prototype.volumeChanged_ = function(e) { | |
return "function" == typeof this.onVolumeChanged ? this.onVolumeChanged(e) : void 0 | |
}, i | |
}(di.application.module.Base) | |
}.call(this), window.Modernizr = function(e, t, n) { | |
function i(e) { | |
_.cssText = e | |
} | |
function r(e, t) { | |
return i(x.join(e + ";") + (t || "")) | |
} | |
function o(e, t) { | |
return typeof e === t | |
} | |
function a(e, t) { | |
return !!~("" + e).indexOf(t) | |
} | |
function s(e, t) { | |
for (var i in e) { | |
var r = e[i]; | |
if (!a(r, "-") && _[r] !== n) return "pfx" == t ? r : !0 | |
} | |
return !1 | |
} | |
function l(e, t, i) { | |
for (var r in e) { | |
var a = t[e[r]]; | |
if (a !== n) return i === !1 ? e[r] : o(a, "function") ? a.bind(i || t) : a | |
} | |
return !1 | |
} | |
function u(e, t, n) { | |
var i = e.charAt(0).toUpperCase() + e.slice(1), | |
r = (e + " " + C.join(i + " ") + i).split(" "); | |
return o(t, "string") || o(t, "undefined") ? s(r, t) : (r = (e + " " + A.join(i + " ") + i).split(" "), l(r, t, n)) | |
} | |
function c() { | |
f.input = function(n) { | |
for (var i = 0, r = n.length; r > i; i++) M[n[i]] = n[i] in b; | |
return M.list && (M.list = !!t.createElement("datalist") && !!e.HTMLDataListElement), M | |
}("autocomplete autofocus list placeholder max min multiple pattern required step".split(" ")), f.inputtypes = function(e) { | |
for (var i, r, o, a = 0, s = e.length; s > a; a++) b.setAttribute("type", r = e[a]), i = "text" !== b.type, i && (b.value = w, b.style.cssText = "position:absolute;visibility:hidden;", /^range$/.test(r) && b.style.WebkitAppearance !== n ? (g.appendChild(b), o = t.defaultView, i = o.getComputedStyle && "textfield" !== o.getComputedStyle(b, null).WebkitAppearance && 0 !== b.offsetHeight, g.removeChild(b)) : /^(search|tel)$/.test(r) || (i = /^(url|email)$/.test(r) ? b.checkValidity && b.checkValidity() === !1 : b.value != w)), P[e[a]] = !!i; | |
return P | |
}("search tel url email datetime date month week time datetime-local number range color".split(" ")) | |
} | |
var d, h, p = "2.8.3", | |
f = {}, | |
m = !0, | |
g = t.documentElement, | |
y = "modernizr", | |
v = t.createElement(y), | |
_ = v.style, | |
b = t.createElement("input"), | |
w = ":)", | |
x = ({}.toString, " -webkit- -moz- -o- -ms- ".split(" ")), | |
k = "Webkit Moz O ms", | |
C = k.split(" "), | |
A = k.toLowerCase().split(" "), | |
S = { | |
svg: "http://www.w3.org/2000/svg" | |
}, | |
T = {}, | |
P = {}, | |
M = {}, | |
E = [], | |
I = E.slice, | |
F = function(e, n, i, r) { | |
var o, a, s, l, u = t.createElement("div"), | |
c = t.body, | |
d = c || t.createElement("body"); | |
if (parseInt(i, 10)) | |
for (; i--;) s = t.createElement("div"), s.id = r ? r[i] : y + (i + 1), u.appendChild(s); | |
return o = ["­", '<style id="s', y, '">', e, "</style>"].join(""), u.id = y, (c ? u : d).innerHTML += o, d.appendChild(u), c || (d.style.background = "", d.style.overflow = "hidden", l = g.style.overflow, g.style.overflow = "hidden", g.appendChild(d)), a = n(u, e), c ? u.parentNode.removeChild(u) : (d.parentNode.removeChild(d), g.style.overflow = l), !!a | |
}, | |
O = function(t) { | |
var n = e.matchMedia || e.msMatchMedia; | |
if (n) return n(t) && n(t).matches || !1; | |
var i; | |
return F("@media " + t + " { #" + y + " { position: absolute; } }", function(t) { | |
i = "absolute" == (e.getComputedStyle ? getComputedStyle(t, null) : t.currentStyle).position | |
}), i | |
}, | |
R = function() { | |
function e(e, r) { | |
r = r || t.createElement(i[e] || "div"), e = "on" + e; | |
var a = e in r; | |
return a || (r.setAttribute || (r = t.createElement("div")), r.setAttribute && r.removeAttribute && (r.setAttribute(e, ""), a = o(r[e], "function"), o(r[e], "undefined") || (r[e] = n), r.removeAttribute(e))), r = null, a | |
} | |
var i = { | |
select: "input", | |
change: "input", | |
submit: "form", | |
reset: "form", | |
error: "img", | |
load: "img", | |
abort: "img" | |
}; | |
return e | |
}(), | |
D = {}.hasOwnProperty; | |
h = o(D, "undefined") || o(D.call, "undefined") ? function(e, t) { | |
return t in e && o(e.constructor.prototype[t], "undefined") | |
} : function(e, t) { | |
return D.call(e, t) | |
}, Function.prototype.bind || (Function.prototype.bind = function(e) { | |
var t = this; | |
if ("function" != typeof t) throw new TypeError; | |
var n = I.call(arguments, 1), | |
i = function() { | |
if (this instanceof i) { | |
var r = function() {}; | |
r.prototype = t.prototype; | |
var o = new r, | |
a = t.apply(o, n.concat(I.call(arguments))); | |
return Object(a) === a ? a : o | |
} | |
return t.apply(e, n.concat(I.call(arguments))) | |
}; | |
return i | |
}), T.canvas = function() { | |
var e = t.createElement("canvas"); | |
return !!e.getContext && !!e.getContext("2d") | |
}, T.webgl = function() { | |
return !!e.WebGLRenderingContext | |
}, T.touch = function() { | |
var n; | |
return "ontouchstart" in e || e.DocumentTouch && t instanceof DocumentTouch ? n = !0 : F(["@media (", x.join("touch-enabled),("), y, ")", "{#modernizr{top:9px;position:absolute}}"].join(""), function(e) { | |
n = 9 === e.offsetTop | |
}), n | |
}, T.geolocation = function() { | |
return "geolocation" in navigator | |
}, T.postmessage = function() { | |
return !!e.postMessage | |
}, T.hashchange = function() { | |
return R("hashchange", e) && (t.documentMode === n || t.documentMode > 7) | |
}, T.history = function() { | |
return !!e.history && !!history.pushState | |
}, T.draganddrop = function() { | |
var e = t.createElement("div"); | |
return "draggable" in e || "ondragstart" in e && "ondrop" in e | |
}, T.websockets = function() { | |
return "WebSocket" in e || "MozWebSocket" in e | |
}, T.rgba = function() { | |
return i("background-color:rgba(150,255,150,.5)"), a(_.backgroundColor, "rgba") | |
}, T.backgroundsize = function() { | |
return u("backgroundSize") | |
}, T.borderimage = function() { | |
return u("borderImage") | |
}, T.borderradius = function() { | |
return u("borderRadius") | |
}, T.boxshadow = function() { | |
return u("boxShadow") | |
}, T.textshadow = function() { | |
return "" === t.createElement("div").style.textShadow | |
}, T.opacity = function() { | |
return r("opacity:.55"), /^0.55$/.test(_.opacity) | |
}, T.cssanimations = function() { | |
return u("animationName") | |
}, T.csscolumns = function() { | |
return u("columnCount") | |
}, T.cssgradients = function() { | |
var e = "background-image:", | |
t = "gradient(linear,left top,right bottom,from(#9f9),to(white));", | |
n = "linear-gradient(left top,#9f9, white);"; | |
return i((e + "-webkit- ".split(" ").join(t + e) + x.join(n + e)).slice(0, -e.length)), a(_.backgroundImage, "gradient") | |
}, T.cssreflections = function() { | |
return u("boxReflect") | |
}, T.csstransforms = function() { | |
return !!u("transform") | |
}, T.csstransforms3d = function() { | |
var e = !!u("perspective"); | |
return e && "webkitPerspective" in g.style && F("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}", function(t) { | |
e = 9 === t.offsetLeft && 3 === t.offsetHeight | |
}), e | |
}, T.csstransitions = function() { | |
return u("transition") | |
}, T.fontface = function() { | |
var e; | |
return F('@font-face {font-family:"font";src:url("https://")}', function(n, i) { | |
var r = t.getElementById("smodernizr"), | |
o = r.sheet || r.styleSheet, | |
a = o ? o.cssRules && o.cssRules[0] ? o.cssRules[0].cssText : o.cssText || "" : ""; | |
e = /src/i.test(a) && 0 === a.indexOf(i.split(" ")[0]) | |
}), e | |
}, T.generatedcontent = function() { | |
var e; | |
return F(["#", y, "{font:0/0 a}#", y, ':after{content:"', w, '";visibility:hidden;font:3px/1 a}'].join(""), function(t) { | |
e = t.offsetHeight >= 3 | |
}), e | |
}, T.video = function() { | |
var e = t.createElement("video"), | |
n = !1; | |
try { | |
(n = !!e.canPlayType) && (n = new Boolean(n), n.ogg = e.canPlayType('video/ogg; codecs="theora"').replace(/^no$/, ""), n.h264 = e.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/, ""), n.webm = e.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/, "")) | |
} catch (i) {} | |
return n | |
}, T.audio = function() { | |
var e = t.createElement("audio"), | |
n = !1; | |
try { | |
(n = !!e.canPlayType) && (n = new Boolean(n), n.ogg = e.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ""), n.mp3 = e.canPlayType("audio/mpeg;").replace(/^no$/, ""), n.wav = e.canPlayType('audio/wav; codecs="1"').replace(/^no$/, ""), n.m4a = (e.canPlayType("audio/x-m4a;") || e.canPlayType("audio/aac;")).replace(/^no$/, "")) | |
} catch (i) {} | |
return n | |
}, T.localstorage = function() { | |
try { | |
return localStorage.setItem(y, y), localStorage.removeItem(y), !0 | |
} catch (e) { | |
return !1 | |
} | |
}, T.webworkers = function() { | |
return !!e.Worker | |
}, T.svg = function() { | |
return !!t.createElementNS && !!t.createElementNS(S.svg, "svg").createSVGRect | |
}; | |
for (var L in T) h(T, L) && (d = L.toLowerCase(), f[d] = T[L](), E.push((f[d] ? "" : "no-") + d)); | |
return f.input || c(), f.addTest = function(e, t) { | |
if ("object" == typeof e) | |
for (var i in e) h(e, i) && f.addTest(i, e[i]); | |
else { | |
if (e = e.toLowerCase(), f[e] !== n) return f; | |
t = "function" == typeof t ? t() : t, "undefined" != typeof m && m && (g.className += " " + (t ? "" : "no-") + e), f[e] = t | |
} | |
return f | |
}, i(""), v = b = null, | |
function(e, t) { | |
function n(e, t) { | |
var n = e.createElement("p"), | |
i = e.getElementsByTagName("head")[0] || e.documentElement; | |
return n.innerHTML = "x<style>" + t + "</style>", i.insertBefore(n.lastChild, i.firstChild) | |
} | |
function i() { | |
var e = v.elements; | |
return "string" == typeof e ? e.split(" ") : e | |
} | |
function r(e) { | |
var t = y[e[m]]; | |
return t || (t = {}, g++, e[m] = g, y[g] = t), t | |
} | |
function o(e, n, i) { | |
if (n || (n = t), c) return n.createElement(e); | |
i || (i = r(n)); | |
var o; | |
return o = i.cache[e] ? i.cache[e].cloneNode() : f.test(e) ? (i.cache[e] = i.createElem(e)).cloneNode() : i.createElem(e), !o.canHaveChildren || p.test(e) || o.tagUrn ? o : i.frag.appendChild(o) | |
} | |
function a(e, n) { | |
if (e || (e = t), c) return e.createDocumentFragment(); | |
n = n || r(e); | |
for (var o = n.frag.cloneNode(), a = 0, s = i(), l = s.length; l > a; a++) o.createElement(s[a]); | |
return o | |
} | |
function s(e, t) { | |
t.cache || (t.cache = {}, t.createElem = e.createElement, t.createFrag = e.createDocumentFragment, t.frag = t.createFrag()), e.createElement = function(n) { | |
return v.shivMethods ? o(n, e, t) : t.createElem(n) | |
}, e.createDocumentFragment = Function("h,f", "return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&(" + i().join().replace(/[\w\-]+/g, function(e) { | |
return t.createElem(e), t.frag.createElement(e), 'c("' + e + '")' | |
}) + ");return n}")(v, t.frag) | |
} | |
function l(e) { | |
e || (e = t); | |
var i = r(e); | |
return v.shivCSS && !u && !i.hasCSS && (i.hasCSS = !!n(e, "article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")), c || s(e, i), e | |
} | |
var u, c, d = "3.7.0", | |
h = e.html5 || {}, | |
p = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i, | |
f = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i, | |
m = "_html5shiv", | |
g = 0, | |
y = {}; | |
! function() { | |
try { | |
var e = t.createElement("a"); | |
e.innerHTML = "<xyz></xyz>", u = "hidden" in e, c = 1 == e.childNodes.length || function() { | |
t.createElement("a"); | |
var e = t.createDocumentFragment(); | |
return "undefined" == typeof e.cloneNode || "undefined" == typeof e.createDocumentFragment || "undefined" == typeof e.createElement | |
}() | |
} catch (n) { | |
u = !0, c = !0 | |
} | |
}(); | |
var v = { | |
elements: h.elements || "abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video", | |
version: d, | |
shivCSS: h.shivCSS !== !1, | |
supportsUnknownElements: c, | |
shivMethods: h.shivMethods !== !1, | |
type: "default", | |
shivDocument: l, | |
createElement: o, | |
createDocumentFragment: a | |
}; | |
e.html5 = v, l(t) | |
}(this, t), f._version = p, f._prefixes = x, f._domPrefixes = A, f._cssomPrefixes = C, f.mq = O, f.hasEvent = R, f.testProp = function(e) { | |
return s([e]) | |
}, f.testAllProps = u, f.testStyles = F, g.className = g.className.replace(/(^|\s)no-js(\s|$)/, "$1$2") + (m ? " js " + E.join(" ") : ""), f | |
}(this, this.document), Modernizr.addTest("cors", !!(window.XMLHttpRequest && "withCredentials" in new XMLHttpRequest)), Modernizr.addTest("csscalc", function() { | |
var e = "width:", | |
t = "calc(10px);", | |
n = document.createElement("div"); | |
return n.style.cssText = e + Modernizr._prefixes.join(t + e), !!n.style.length | |
}), Modernizr.addTest("cssfilters", function() { | |
var e = document.createElement("div"); | |
return e.style.cssText = Modernizr._prefixes.join("filter:blur(2px); "), !!e.style.length && (void 0 === document.documentMode || document.documentMode > 9) | |
}), Modernizr.addTest("placeholder", function() { | |
return "placeholder" in (Modernizr.input || document.createElement("input")) && "placeholder" in (Modernizr.textarea || document.createElement("textarea")) | |
}), | |
function() { | |
var e = function(e, t) { | |
return function() { | |
return e.apply(t, arguments) | |
} | |
}, | |
t = {}.hasOwnProperty, | |
n = function(e, n) { | |
function i() { | |
this.constructor = e | |
} | |
for (var r in n) t.call(n, r) && (e[r] = n[r]); | |
return i.prototype = n.prototype, e.prototype = new i, e.__super__ = n.prototype, e | |
}; | |
di.provide("di.application.module.webplayer.ads.provider.Liverail"), di.application.module.webplayer.ads.provider.Liverail = function(t) { | |
function i() { | |
return this.onVolumeChanged = e(this.onVolumeChanged, this), this.abortStartAd_ = e(this.abortStartAd_, this), this.abortInitAd_ = e(this.abortInitAd_, this), this.lrAdLog_ = e(this.lrAdLog_, this), this.lrAdError_ = e(this.lrAdError_, this), this.lrAdClickThru_ = e(this.lrAdClickThru_, this), this.lrAdPaused_ = e(this.lrAdPaused_, this), this.lrAdStopped_ = e(this.lrAdStopped_, this), this.lrAdStarted_ = e(this.lrAdStarted_, this), this.lrAdLoaded_ = e(this.lrAdLoaded_, this), this.trackEvent_ = e(this.trackEvent_, this), i.__super__.constructor.apply(this, arguments) | |
} | |
var r, o, a, s, i; | |
return n(i, t), i.prototype.logger = new di.log.Console("ads.provider.Liverail"), r = "#sponsor", s = 25416, o = 1331, a = "Ads:LiveRail", i = i, i.INTERFACE_SCRIPT_URL = "http://cdn-static.liverail.com/js/LiveRail.AdManager-1.0.js", i.AD_LOAD_TIMEOUT = 5, i.AD_START_TIMEOUT = 2.5, i.prototype.startWithParent = !1, i.prototype.lrInterface_ = null, i.prototype.$lrIframe_ = null, i.prototype.$adContainer_ = null, i.prototype.$adPlayer_ = null, i.prototype.hasVideo_ = !1, i.prototype.adInitTimeout_ = null, i.prototype.adStartTimeout_ = null, i.prototype.adAborted_ = !1, i.prototype.lrEventMap_ = { | |
AdLoaded: "lrAdLoaded_", | |
AdStarted: "lrAdStarted_", | |
AdStopped: "lrAdStopped_", | |
AdPaused: "lrAdPaused_", | |
AdClickThru: "lrAdClickThru_", | |
AdError: "lrAdError_", | |
AdLog: "lrAdLog_" | |
}, i.prototype.trackEvent_ = function(e, t) { | |
var n, i; | |
return n = "clickThru" === e ? "trackEvent" : "trackNonInteractiveEvent", null == t && (i = null != this.activeAd ? this.activeAd : this.pendingAd, t = (null != i ? i.has("position") : void 0) ? i.get("position") : "unknown"), di.analytics[n](a, e, t) | |
}, i.prototype.lrAdLoaded_ = function() { | |
return this.adAborted_ ? void this.logger.log("Ad loaded, but too late for anyone to care.") : (this.trackEvent_("loaded"), null != this.adInitTimeout_ && clearTimeout(this.adInitTimeout_), this.adInitTimeout_ = null, this.lrInterface_.setAdVolume(this.getWebplayerVolume_() / 100), this.adStartTimeout_ && clearTimeout(this.adStartTimeout_), this.adStartTimeout_ = setTimeout(this.abortStartAd_, 1e3 * i.AD_START_TIMEOUT), this.lrInterface_.startAd()) | |
}, i.prototype.lrAdStarted_ = function() { | |
return this.adAborted_ ? void 0 : (this.trackEvent_("started"), this.adStartTimeout_ && clearTimeout(this.adStartTimeout_), this.adStartTimeout_ = null, this.adBegin_()) | |
}, i.prototype.lrAdStopped_ = function() { | |
var e; | |
return this.trackEvent_("stopped"), null != this.adInitTimeout_ && clearTimeout(this.adInitTimeout_), this.adInitTimeout_ = null, null != (e = this.$adPlayer_) && e.remove(), this.adEnd_() | |
}, i.prototype.lrAdPaused_ = function() { | |
return this.lrInterface_.resumeAd() | |
}, i.prototype.lrAdClickThru_ = function() { | |
return this.trackEvent_("clickThru") | |
}, i.prototype.lrAdError_ = function(e) { | |
var t; | |
return null != this.adInitTimeout_ && clearTimeout(this.adInitTimeout_), this.adInitTimeout_ = null, this.logger.log("Ad Error: " + e), null != (t = this.$adPlayer_) && t.remove(), this.noAdsAvailable_(), "No ads available." !== e ? this.trackEvent_("error", e) : void 0 | |
}, i.prototype.lrAdLog_ = function(e) { | |
return null == di.env.production ? this.logger.log("Ad Log: " + e) : void 0 | |
}, i.prototype.initLrSubscriptions_ = function() { | |
return null != this.lrInterface_ ? _.each(this.lrEventMap_, function(e) { | |
return function(t, n) { | |
return "function" == typeof e[t] ? e.lrInterface_.subscribe(e[t], n) : void 0 | |
} | |
}(this)) : void 0 | |
}, i.prototype.teardownLrSubscriptions_ = function() { | |
var e; | |
if (null != (null != (e = this.lrInterface_) ? e.unsubscribe : void 0)) return _.each(this.lrEventMap_, function(e) { | |
return function(t, n) { | |
return "function" == typeof e[t] ? e.lrInterface_.unsubscribe(e[t], n) : void 0 | |
} | |
}(this)) | |
}, i.prototype.initLiverail_ = function() { | |
return (null != this.lrIframe_ || null != this.lrInterface_) && this.teardownLiverail_(), this.logger.log("Initializing Liverail ad manager"), this.$lrIframe_ = $("<iframe>").hide().load(function(e) { | |
return function() { | |
var t, n, r, o, a, s; | |
return n = e.$lrIframe_[0].contentWindow, o = n.document.createElement("script"), o.src = i.INTERFACE_SCRIPT_URL, r = e, a = !1, s = function() { | |
var e; | |
if (!a && null != n.getVPAIDAd) return r.logger.log("DEBUG: liverail script in iframe onload"), a = !0, r.lrInterface_ = "function" == typeof n.getVPAIDAd ? n.getVPAIDAd() : void 0, "function" == typeof(e = r.lrInterface_).handshakeVersion && e.handshakeVersion("2.0"), null == r.lrInterface_ ? (r.logger.log("Error: Couldn't retrieve LiveRail interface. Aborting init."), r.$lrIframe_.remove(), void(r.$lrIframe_ = null)) : (r.initLrSubscriptions_(), r.logger.log("Liverail Ad manager initialized.")) | |
}, t = function() { | |
return a ? void 0 : "loaded" !== o.readyState && "completed" !== o.readyState || null == n.getVPAIDAd ? setTimeout(t, 50) : s() | |
}, o.onload = function() { | |
return s() | |
}, t(), n.document.body.appendChild(o) | |
} | |
}(this)), this.$lrIframe_.appendTo(document.body) | |
}, i.prototype.teardownLiverail_ = function() { | |
var e, t; | |
if (null != this.$lrIframe_ || null != this.lrInterface_) return this.logger.log("Tearing down Liverail ad manager"), null != (e = this.lrInterface_) && "function" == typeof e.stopAd && e.stopAd(), this.teardownLrSubscriptions_(), null != (t = this.$adPlayer_) && t.remove(), this.$adPlayer_ = null, this.lrInterface_ = null, this.$lrIframe_.remove(), this.$lrIframe_ = null | |
}, i.prototype.setupAdElement_ = function(e) { | |
var t, n, i; | |
return this.logger.log("Setting up ad element for ", e), n = e.get("width"), t = e.get("height"), null != (i = this.$adPlayer_) && i.remove(), this.$adPlayer_ = $("<div>", { | |
"class": "adprovider-liverail" | |
}).css("width", n).css("height", t), this.hasVideo_ && this.$adPlayer_.append($("<video>").css("width", n).css("height", t)), this.$adContainer_.append(this.$adPlayer_), this.$adPlayer_[0] | |
}, i.prototype.startAd = function(e) { | |
var t, n, r, a, l; | |
return i.__super__.startAd.apply(this, arguments), n = this.setupAdElement_(e), this.adAborted_ = !1, t = this.app.request("webplayer:channel"), r = {}, a = { | |
slot: n, | |
LR_PUBLISHER_ID: null != di.env.production ? s : o, | |
LR_SCHEMA: "vast2-vpaid", | |
LR_CONTENT: 4, | |
LR_TITLE: t.get("name"), | |
LR_VIDEO_ID: t.get("id"), | |
LR_AUTOPLAY: 1, | |
LR_TAGS: "music," + t.get("key"), | |
LR_ENVIRONMENT: this.hasVideo_ ? "html5" : "flash" | |
}, this.hasVideo_ && (a.videoSlot = this.$adPlayer_.find("video")[0], a.videoSlotCanAutoPlay = !0), this.logger.log("Requesting an ad from LiveRail..."), this.adInitTimeout_ = setTimeout(this.abortInitAd_, 1e3 * i.AD_LOAD_TIMEOUT), null != (l = this.lrInterface_) && "function" == typeof l.initAd ? l.initAd(e.get("width"), e.get("height"), "normal", 600, r, a) : void 0 | |
}, i.prototype.abortInitAd_ = function() { | |
var e; | |
return this.logger.log("Ad is taking too long to load, aborting."), this.adInitTimeout_ = null, null != (e = this.$adPlayer_) && e.remove(), this.noAdsAvailable_(), this.adAborted_ = !0 | |
}, i.prototype.abortStartAd_ = function() { | |
var e; | |
return this.logger.log("Ad is taking too long to start playing, aborting."), this.lrInterface_.stopAd(), this.adStartTimeout_ = null, null != (e = this.$adPlayer_) && e.remove(), this.noAdsAvailable_(), this.adAborted_ = !0 | |
}, i.prototype.stopAd = function() { | |
var e, t; | |
return i.__super__.stopAd.apply(this, arguments), null != (e = this.lrInterface_) && e.stopAd(), null != (t = this.$adPlayer_) && t.remove(), this.adEnd_() | |
}, i.prototype.onVolumeChanged = function(e) { | |
var t; | |
return null != (t = this.lrInterface_) && "function" == typeof t.setAdVolume ? t.setAdVolume(e / 100) : void 0 | |
}, i.prototype.onStart = function() { | |
var e; | |
this.$adContainer_ = $(r); | |
try { | |
this.initLiverail_() | |
} catch (t) { | |
e = t, this.logger.log("Caught error on init liverail: ", e.message, e) | |
} | |
return this.hasVideo_ = Modernizr.video | |
}, i.prototype.onBeforeStop = function() { | |
return this.teardownLiverail_(), this.$adContainer_ = null, this.hasVideo_ = !1 | |
}, i | |
}(di.application.module.webplayer.ads.provider.Base) | |
}.call(this), | |
function() { | |
var e = function(e, t) { | |
return function() { | |
return e.apply(t, arguments) | |
} | |
}, | |
t = {}.hasOwnProperty, | |
n = function(e, n) { | |
function i() { | |
this.constructor = e | |
} | |
for (var r in n) t.call(n, r) && (e[r] = n[r]); | |
return i.prototype = n.prototype, e.prototype = new i, e.__super__ = n.prototype, e | |
}; | |
di.provide("di.application.module.webplayer.Ads"), di.application.module.webplayer.Ads = function(t) { | |
function i() { | |
return this.onStart = e(this.onStart, this), this.adNoneAvailable_ = e(this.adNoneAvailable_, this), this.adEnded_ = e(this.adEnded_, this), this.initProviders_ = e(this.initProviders_, this), i.__super__.constructor.apply(this, arguments) | |
} | |
return n(i, t), i.prototype.logger = new di.log.Console("di.module.webplayer.Ads"), i.prototype.startWithParent = !1, i.prototype.eventbusEvents = { | |
"webplayer:ad:end": "adEnded_", | |
"webplayer:ad:none_available": "adNoneAvailable_" | |
}, i.prototype.collection = null, i.prototype.availableProviders_ = {}, i.prototype.adQueue_ = new di.collection.Ads, i.prototype.adQueueCurrentAd_ = null, i.prototype.initProviders_ = function() { | |
var e; | |
return e = [], this.collection.each(function(t) { | |
return t.get("ads").each(function(t) { | |
return e.indexOf(t.get("network")) > -1 ? void 0 : e.push(t.get("network")) | |
}) | |
}), _.each(e, function(e) { | |
return function(t) { | |
var n; | |
return n = e.app.module("webplayer.ads." + t), n instanceof di.application.module.webplayer.ads.provider.Base ? (e.availableProviders_[t] = n, n.start()) : (e.logger.log("Warning: Ad found in AdRuleset which does not have a matching implemented provider module. These ads will be ignored. Network: {" + t + "}"), e.trackNonInteractiveEvent({ | |
category: "WebplayerAds", | |
action: "MissingProviderModule", | |
label: t | |
})) | |
} | |
}(this)) | |
}, i.prototype.teardownProviders_ = function() { | |
var e; | |
return e = _.keys(this.availableProviders_), _.each(e, function(e) { | |
return function(t) { | |
return e.availableProviders_[t].stop() | |
} | |
}(this)) | |
}, i.prototype.prerollEnd_ = function() { | |
return this.logger.log("Finished all queued up prerolls, triggering event."), di.eventbus.trigger("webplayer:ads:preroll-end") | |
}, i.prototype.nextInQueue_ = function() { | |
var e; | |
return (e = 0 === this.adQueue_.length) ? (this.logger.log("Finished all ads in queue."), "preroll" === this.adQueueCurrentAd_.get("position") && this.prerollEnd_(), void(this.adQueueCurrentAd_ = null)) : (this.logger.log("Playing ad from queue, " + this.adQueue_.length + " to go (including this one)"), this.adQueueCurrentAd_ = this.adQueue_.shift(), this.startAd_(this.adQueueCurrentAd_)) | |
}, i.prototype.adEnded_ = function(e) { | |
return null != e ? e === this.adQueueCurrentAd_ ? this.nextInQueue_() : "preroll" === ("function" == typeof e.get ? e.get("position") : void 0) ? this.prerollEnd_() : void 0 : void 0 | |
}, i.prototype.adNoneAvailable_ = function() { | |
return this.adEnded_() | |
}, i.prototype.selectAds_ = function(e) { | |
var t, n, i, r, o; | |
return o = [], t = this.app.request("webplayer:channel").get("id"), r = this.collection.findRulesets(t), i = this.app.request("webplayer:isPlaying"), n = this.app.request("webplayer:isFirstTimeListener"), _.each(r, function(t) { | |
return function(r) { | |
var a; | |
return a = r.get("ads").where(e), o.push.apply(o, _.filter(a, function(e) { | |
return e.has("display_for_first_time_visits") && e.get("display_for_first_time_visits") === !1 && n ? !1 : "preroll" === e.get("position") && i ? !1 : _.has(t.availableProviders_, e.get("network")) | |
})) | |
} | |
}(this)), o | |
}, i.prototype.startAd_ = function(e) { | |
var t; | |
this.logger.log("Requesting ad from provider {" + e.get("network") + "}"); | |
try { | |
return this.availableProviders_[e.get("network")].startAd(e) | |
} catch (n) { | |
return t = n, this.logger.log("startAd_ error: " + t.message) | |
} | |
}, i.prototype.requestAds = function(e) { | |
var t, n; | |
return t = this.selectAds_(e), 0 === this.adQueue.length && 0 === t.length && di.eventbus.trigger("webplayer:ad:none_available"), (n = this.adQueue_).push.apply(n, t), null == this.adQueueCurrentAd_ ? this.nextInQueue_() : void 0 | |
}, i.prototype.requestAd = function(e) { | |
var t; | |
return t = this.selectAds_(e), 0 === t.length ? (di.eventbus.trigger("webplayer:ad:none_available"), void this.logger.log("requestAd: no relevant ads available")) : this.startAd_(_.sample(t)) | |
}, i.prototype.stopAds = function() { | |
var e; | |
return e = _.keys(this.availableProviders_), _.each(e, function(e) { | |
return function(t) { | |
return e.availableProviders_[t].stopAd() | |
} | |
}(this)), this.adQueue_ = [] | |
}, i.prototype.stopAd = function() { | |
return this.stopAds() | |
}, i.prototype.onStart = function() { | |
return this.collection = new di.collection.AdRulesets(null, { | |
countryCode: this.app.options.requestEnv.countryCode | |
}), this.collection.fetch({ | |
success: this.initProviders_ | |
}) | |
}, i.prototype.onStop = function() { | |
return this.collection = null, this.teardownProviders_() | |
}, i | |
}(di.application.module.Base) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.IcecastPlayer", function(e, t, n, i, r, o) { | |
return e.Config = n.Model.extend({ | |
attempts: 0, | |
url: "/webplayer3/config", | |
parse: function(e) { | |
return AudioAddict.API.Static = AudioAddict.API.Static || {}, AudioAddict.WP = AudioAddict.WP || {}, AudioAddict.Ad = AudioAddict.Ad || {}, o.extend(AudioAddict.API.Config, e.API.Config), o.extend(AudioAddict.API.Static, e.API.Static), o.extend(AudioAddict.WP, e.WP), o.extend(AudioAddict.Ad, e.Ad), e | |
}, | |
initialize: function() { | |
return this.on("request", function(e) { | |
return function() { | |
return e.attempts++ | |
} | |
}(this)) | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
var e = {}.hasOwnProperty, | |
t = function(t, n) { | |
function i() { | |
this.constructor = t | |
} | |
for (var r in n) e.call(n, r) && (t[r] = n[r]); | |
return i.prototype = n.prototype, t.prototype = new i, t.__super__ = n.prototype, t | |
}; | |
di.provide("di.model.Channel"), di.model.Channel = function(e) { | |
function n() { | |
return n.__super__.constructor.apply(this, arguments) | |
} | |
return t(n, e), n | |
}(Backbone.Model) | |
}.call(this), | |
function() { | |
var e = {}.hasOwnProperty, | |
t = function(t, n) { | |
function i() { | |
this.constructor = t | |
} | |
for (var r in n) e.call(n, r) && (t[r] = n[r]); | |
return i.prototype = n.prototype, t.prototype = new i, t.__super__ = n.prototype, t | |
}; | |
di.provide("di.model.Webplayer"), di.model.Webplayer = function(e) { | |
function n() { | |
return n.__super__.constructor.apply(this, arguments) | |
} | |
var i; | |
return t(n, e), i = 80, n.prototype.localStorageKey = "webplayer-0.1", n.prototype.previousLevel = i, n.prototype.defaults = { | |
ready: !1, | |
playerType: null, | |
volume: i, | |
muted: !1, | |
track: null, | |
ad: null, | |
channel: null, | |
showing: !1, | |
playing: !1, | |
connecting: !1, | |
firstTimeListener: !0, | |
hasPlayed: !1, | |
src: null, | |
currentTime: 0, | |
duration: 0 / 0, | |
loadProgress: 100, | |
seeking: !1 | |
}, n.prototype.autosave = !0, n.prototype.modelEvents = { | |
"change:track": "onTrackChanged", | |
"change:playing": "onPlayingChanged", | |
"change:src": "onSrcChanged", | |
"change:volume": "onVolumeChanged" | |
}, n.prototype.initialize = function() { | |
return Marionette.bindEntityEvents(this, this, this.modelEvents) | |
}, n.prototype.onVolumeChanged = function(e, t) { | |
return "IcecastPlayer" === e.get("playerType") ? di.eventbus.trigger("webplayer:volume:change", t) : void 0 | |
}, n.prototype.onSrcChanged = function(e, t) { | |
return di.app.commands.execute("webplayer:src", t) | |
}, n.prototype.onPlayingChanged = function(e, t) { | |
return t ? e.set({ | |
firstTimeListener: !1, | |
hasPlayed: !0 | |
}) : void 0 | |
}, n.prototype.onTrackChanged = function(e) { | |
return e.set({ | |
loadProgress: e.defaults.loadProgress, | |
currentTime: e.defaults.currentTime | |
}) | |
}, n.prototype.setVolume = function(e) { | |
return this.previousLevel = Math.max(.1, this.get("volume")), this.set({ | |
volume: e, | |
muted: 0 === e | |
}) | |
}, n.prototype.toggleMute = function() { | |
return this.isMuted() ? this.set({ | |
volume: this.previousLevel, | |
muted: !1 | |
}) : (this.previousLevel = Math.max(1, this.get("volume")), this.set({ | |
volume: 0, | |
muted: !0 | |
})) | |
}, n.prototype.isMuted = function() { | |
return this.get("muted") | |
}, n.prototype.isPlaying = function() { | |
return this.get("playing") | |
}, n.prototype.toJSON = function() { | |
var e; | |
e = n.__super__.toJSON.call(this); | |
try { | |
e.track = e.track.toJSON() | |
} catch (t) {} | |
try { | |
e.channel = e.channel.toJSON() | |
} catch (t) {} | |
return e | |
}, n.prototype.parse = function(e) { | |
if (e) { | |
switch (e.playerType) { | |
case "OnDemandPlayer": | |
e.volume > 1 && (e.volume = e.volume / 100), e.channel = null, e.track && (e.track = di.app.request("track:entity", e.track)); | |
break; | |
case "IcecastPlayer": | |
e.track = null, e.duration = 0 / 0, e.channel && (e.channel = di.app.request("channel:entity", e.channel.key), e.channel.set("playing", !1)); | |
break; | |
default: | |
e.channel = null, e.track = null | |
} | |
e.showing = !1, e.ad = null, e.seeking = !1, e.ready = !1, e.src = null, e.hasPlayed = !1, e.playing = !1, e.connecting = !1, 0 === e.volume && (e.volume = i), e.muted = !1, e.progress = 0, e.currentTime = 0, e.loadProgress = 0, this.legacy && (e = _.omit(e, "channel")) | |
} | |
return e | |
}, n | |
}(Backbone.AmplifyStoreModel) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.IcecastPlayer.Views", function(e, t, n, i) { | |
return e.ChannelDetail = i.ItemView.extend({ | |
template: "di/ui/webplayer/channel/detail", | |
modelEvents: { | |
"change:favorite": "render" | |
}, | |
initialize: function() { | |
return this.listenTo(this.options.channelNavMenu, "change:open", function(e) { | |
return function(t) { | |
return e.ui.channelNavButton.toggleClass("open", t) | |
} | |
}(this)) | |
}, | |
onBeforeShow: function() { | |
return this.ui.channelNavButton.toggleClass("open", this.options.channelNavMenu.isOpen()) | |
}, | |
ui: { | |
favoriteButton: ".favorite", | |
channelNavButton: ".channel-nav" | |
}, | |
events: { | |
"click @ui.favoriteButton": "onFavoriteClicked", | |
"click @ui.channelNavButton": "toggleMenuOpenClose" | |
}, | |
toggleMenuOpenClose: function() { | |
return this.options.channelNavMenu.toggleOpenClose() | |
}, | |
onFavoriteClicked: function() { | |
return this.model.toggleFavorite() | |
}, | |
templateHelpers: { | |
imageSrc: function() { | |
return AudioAddict.UI.img_uri(this, { | |
size: "64x64" | |
}) | |
}, | |
favoriteClass: function() { | |
return this.favorite ? "icon-star" : "icon-star-empty" | |
}, | |
tooltip: function() { | |
return this.favorite ? "Remove '" + this.name + "' from favorite channels" : "Add '" + this.name + "' to favorite channels" | |
} | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.IcecastPlayer.Views", function(e, t, n, i, r, o) { | |
var a, s, l, u, c, d, h; | |
return l = 42, u = 190, s = 64, h = 64, c = 24, d = "channel-nav-visible", a = 500, e.ChannelNavMenuItem = i.ItemView.extend({ | |
template: "di/ui/webplayer/channel/nav_item", | |
tagName: "li", | |
modelEvents: { | |
"change:favorite": "render", | |
"change:playing": "render" | |
}, | |
ui: { | |
playButton: ".tune-in", | |
channelName: ".title" | |
}, | |
events: { | |
"click @ui.playButton": "onPlayClicked", | |
"click @ui.channelName": "onChannelLinkClicked" | |
}, | |
onChannelLinkClicked: function() { | |
return this.trigger("close:menu") | |
}, | |
onPlayClicked: function() { | |
var e; | |
return e = t.request("webplayer:channel"), t.execute("webplayer:play:channel", this.model), this.model !== e ? this.trigger("close:menu") : void 0 | |
}, | |
templateHelpers: { | |
imageSrc: function() { | |
return AudioAddict.UI.img_uri(this, { | |
size: "30x30" | |
}) | |
} | |
} | |
}), e.ChannelNavMenuColumn = i.CollectionView.extend({ | |
tagName: "ul", | |
childView: e.ChannelNavMenuItem, | |
childEvents: { | |
"close:menu": function() { | |
return this.trigger("close:menu") | |
} | |
}, | |
collectionEvents: { | |
"change:favorite": "onFavoriteChanged" | |
}, | |
onFavoriteChanged: function() { | |
return this.trigger("change:favorite") | |
}, | |
initialize: function() { | |
return this.collection = new n.Collection(o.values(this.model.toJSON())) | |
} | |
}), e.ChannelNavMenu = i.CompositeView.extend({ | |
el: r("#channel-nav"), | |
childView: e.ChannelNavMenuColumn, | |
childViewContainer: ".wrap", | |
template: "di/ui/webplayer/channel/nav_menu", | |
collection: new n.Collection, | |
needsRender_: !0, | |
ui: { | |
wrap: ".wrap" | |
}, | |
model: new n.Model({ | |
open: !1 | |
}), | |
modelEvents: { | |
"change:open": "onOpenChanged" | |
}, | |
collectionEvents: { | |
reset: "render" | |
}, | |
childEvents: { | |
"close:menu": "close", | |
"change:favorite": "buildCollection_" | |
}, | |
events: { | |
mousenter: "abortAutoclose_", | |
mouseleave: "onMouseleave" | |
}, | |
onOpenChanged: function(e, t) { | |
return this.abortAutoclose_(), r(document.body).toggleClass(d, t), this.trigger("change:open", t) | |
}, | |
initialize: function() { | |
return r(window).on("resize.channelnav", o.debounce(o.bind(this.onResize, this), 1e3, { | |
leading: !0 | |
})), this.buildCollection_() | |
}, | |
onDestroy: function() { | |
return r(window).off("resize.channelnav") | |
}, | |
abortAutoclose_: function() { | |
return this.autocloseId ? clearTimeout(this.autocloseId) : void 0 | |
}, | |
onMouseleave: function() { | |
return this.autocloseId = setTimeout(o.bind(this.close, this), a) | |
}, | |
onRender: function() { | |
return this.needsRender_ = !1, this.ui.wrap.width(this.collection.length * u + c) | |
}, | |
onResize: function() { | |
return this.close(!0), this.needsRender_ = !0 | |
}, | |
isOpen: function() { | |
return this.model.get("open") | |
}, | |
getMaxHeight: function() { | |
return r(window).height() - (s + h + c) | |
}, | |
getMaxWidth: function() { | |
return r(document.body).width() - c | |
}, | |
getMaxRows: function() { | |
return Math.floor(this.getMaxHeight() / l) | |
}, | |
getMaxCols: function() { | |
return Math.floor(this.getMaxWidth() / u) | |
}, | |
getMaxNumItems: function() { | |
return this.getMaxRows() * this.getMaxCols() | |
}, | |
canFitInViewport: function() { | |
return this.options.channels.length <= this.getMaxNumItems() | |
}, | |
buildCollection_: function() { | |
var e, t, i, r, o, a, s, l, u, c; | |
for (t = new n.Collection(this.options.channels.where({ | |
favorite: !0 | |
})), t.comparator = "name", t.sort(), a = this.options.channels.clone(), a.remove(t.models), a.comparator = "name", a.sort(), o = t.slice().concat(a.slice()), s = this.getMaxCols(), l = Math.ceil(o.length / s), r = [], i = c = 0; s >= 0 ? s > c : c > s; i = s >= 0 ? ++c : --c) u = Math.min(i * l, o.length), e = Math.min((i + 1) * l, o.length), r.push(o.slice(u, e)); | |
return this.collection.reset(r) | |
}, | |
toggleOpenClose: function() { | |
return this.model.get("open") ? this.close() : this.open() | |
}, | |
addVisibleClass_: function() { | |
return r(document.body).addClass(d) | |
}, | |
removeVisibleClass_: function() { | |
return r(document.body).removeClass(d) | |
}, | |
slideUp_: function() { | |
return this.$el.css("bottom", 0) | |
}, | |
slideDown_: function() { | |
return this.$el.css("bottom", -1 * (this.$el.outerHeight() + c)) | |
}, | |
open: function() { | |
return this.canFitInViewport() ? (this.needsRender_ && this.buildCollection_(), this.slideUp_(), this.model.set({ | |
open: !0 | |
})) : t.commands.execute("xhrpages:navigate", Routes.channels_path()) | |
}, | |
close: function(e) { | |
return e === !0 ? this.$el.empty() : this.slideDown_(), this.model.set({ | |
open: !1 | |
}) | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.IcecastPlayer.Views", function(e, t) { | |
return e.ConnectionTimeoutModal = di.ui.Modal.extend({ | |
image: null, | |
template: "di/ui/webplayer/modal/connection_timeout", | |
events: { | |
"click [data-reconnect]": "onTryReconnect" | |
}, | |
onTryReconnect: function() { | |
return t.commands.execute("transportmanager:play") | |
} | |
}), e.FlashInstallModal = di.ui.Modal.extend({ | |
image: null, | |
template: "di/ui/webplayer/modal/flash_install" | |
}), e.FlashUpdateModal = di.ui.Modal.extend({ | |
image: null, | |
template: "di/ui/webplayer/modal/flash_update" | |
}), e.FlashBlockedModal = di.ui.Modal.extend({ | |
image: null, | |
template: "di/ui/webplayer/modal/flash_blocked" | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.IcecastPlayer.Views", function(e, t, n, i, r, o) { | |
return e.ActionsMenu = i.ItemView.extend({ | |
template: "di/ui/webplayer/settings/actions_menu", | |
behaviors: { | |
Popdown: {}, | |
Share: {} | |
}, | |
modelEvents: { | |
"change:track": "render" | |
}, | |
ui: { | |
share: ".icon-share" | |
}, | |
events: { | |
"click @ui.share": "toggleSubMenu", | |
mouseleave: "onLeaveSubMenu" | |
}, | |
onLeaveSubMenu: function() { | |
return this.collapseTimeout = setTimeout(o.bind(this.collapseSubMenu, this), 400) | |
}, | |
collapseSubMenu: function() { | |
return this.$el.removeClass("expanded") | |
}, | |
onRender: function() { | |
var e; | |
return e = this.model.get("track") && this.model.get("track").get("uri"), this.ui.share.toggleClass("disabled", !e) | |
}, | |
toggleSubMenu: function() { | |
return clearTimeout(this.collapseTimeout), this.$el.toggleClass("expanded") | |
} | |
}), e.Settings = i.LayoutView.extend({ | |
template: "di/ui/webplayer/settings", | |
regions: { | |
volumeRegion: ".volume-region", | |
actionMenu: ".actions-menu" | |
}, | |
ui: { | |
settingsButton: ".preferences" | |
}, | |
events: { | |
"click @ui.settingsButton": "onSettingsButtonClick" | |
}, | |
onBeforeShow: function() { | |
return this.volumeRegion.show(new e.Volume({ | |
model: this.model | |
})), this.actionMenu.show(new e.ActionsMenu({ | |
model: this.model | |
})) | |
}, | |
onSettingsButtonClick: function() { | |
return t.options.user.authenticated ? t.commands.execute("xhrpages:navigate", Routes.settings_path()) : t.execute("modal:gatekeeper", { | |
prompt: "You must be logged in to change player preferences" | |
}) | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.IcecastPlayer.Views.Track", function(e, t, n, i) { | |
var r; | |
return r = "[data-comments-region]", e.Actions = i.ItemView.extend({ | |
template: "di/ui/webplayer/track/actions", | |
behaviors: { | |
Popdown: {}, | |
Voting: {}, | |
Share: { | |
scope: "track" | |
} | |
}, | |
serializeData: function() { | |
var e; | |
return e = i.ItemView.prototype.serializeData.call(this), e || { | |
id: null | |
} | |
}, | |
modelEvents: { | |
"change:uri": "render", | |
"change:votes": "render" | |
}, | |
templateHelpers: t.Mixins.Voting.templateHelpers | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.IcecastPlayer.Views.Track", function(e, t, n, i) { | |
return e.Artwork = i.ItemView.extend({ | |
template: "di/ui/webplayer/track/artwork", | |
modelEvents: { | |
"change:track": "render", | |
"change:channel": "render" | |
}, | |
templateHelpers: { | |
imageSrc: function() { | |
return AudioAddict.UI.img_uri(this.track, { | |
size: "46x46" | |
}) || AudioAddict.UI.img_uri(this.channel, { | |
size: "46x46" | |
}) | |
} | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.IcecastPlayer.Views.Track", function(e, t, n, i) { | |
var r, o, a; | |
return a = "icon-spinner3", o = "icon-play", r = "icon-pause", e.PlayButton = i.ItemView.extend({ | |
template: "di/ui/webplayer/track/play_button", | |
modelEvents: { | |
"change:connecting": "render", | |
"change:track": "render", | |
"change:playing": "render", | |
"change:ad": "render" | |
}, | |
events: { | |
click: "onPlayPauseClick" | |
}, | |
behaviors: { | |
KeyCommands: { | |
" ": "onPlayPauseClick" | |
} | |
}, | |
onPlayPauseClick: function(e) { | |
return e.preventDefault(), this.model.get("connecting") || this.model.get("ad") ? void 0 : t.execute("webplayer:play:channel", this.model.get("channel")) | |
}, | |
templateHelpers: function() { | |
return { | |
iconClass: function() { | |
return this.ad || this.connecting ? a : this.playing ? r : o | |
}, | |
ariaLabel: function() { | |
return this.connecting ? "connecting" : this.playing ? "stop" : "play" | |
}, | |
ariaAttr: function() { | |
return this.connecting || this.ad ? "aria-disabled" : "" | |
} | |
} | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.provide("di.date.format"), di.date.format.secondsToTimecode = function(e, t) { | |
var n, i, r; | |
return null == e && (e = 0), null == t && (t = {}), e = Math.ceil(Math.max(e, 0)), e > 0 ? (n = Math.floor(e / 3600), e -= 3600 * n, i = di.math.pad(Math.floor(e / 60)), r = di.math.pad(e - 60 * i), n = n > 0 ? di.math.pad(n) + ":" : t.includeZeroHours ? "00:" : "", n + i + ":" + r) : "00:00" | |
} | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.IcecastPlayer.Views.Track", function(e, t, n, i, r, o) { | |
var a, s, l; | |
return a = "animated", l = di.date.format.secondsToTimecode, s = n.Model.extend({ | |
initialize: function() { | |
var e, t; | |
return t = this.getUnixTime(), e = this.get("started") - 2, this.get("timeDeterminate") && e > t && this.set("timeDeterminate", !1), 100 === this.getPercentComplete() ? this.set("timeDeterminate", !1) : void 0 | |
}, | |
getUnixTime: function() { | |
return Math.ceil(Date.now() / 1e3) | |
}, | |
getRemainingSeconds: function() { | |
return Math.ceil(this.get("ended") - this.getUnixTime()) | |
}, | |
getElapsedSeconds: function() { | |
var e; | |
return e = this.getUnixTime() - this.get("started"), 0 > e && (console.warn("ProgressStateModel: ELAPSED time is negative. Using indeterminate progress."), e = 0, this.set({ | |
started: this.getUnixTime(), | |
timeDeterminate: !1 | |
})), Math.max(0, e) | |
}, | |
getDurationFormatted: function() { | |
return this.get("timeDeterminate") ? l(this.get("length")) : "" | |
}, | |
getElapsedFormatted: function() { | |
var e; | |
return e = this.getElapsedSeconds(), this.get("timeDeterminate") && (e = Math.min(e, this.get("length"))), l(e) | |
}, | |
getPercentComplete: function() { | |
var e; | |
return this.get("timeDeterminate") ? (e = this.getElapsedSeconds() / this.get("length") * 100, Math.round(1e3 * e) / 1e3) : 100 | |
}, | |
getDisplayTime: function() { | |
var e; | |
return e = this.getElapsedFormatted(), this.get("timeDeterminate") && (e += " / " + this.getDurationFormatted()), e | |
} | |
}), e.ProgressBar = i.ItemView.extend({ | |
template: "di/ui/webplayer/track/progress_bar", | |
progressModel: new s, | |
modelEvents: { | |
"change:playing": "onPlayingChanged", | |
"change:track": "onTrackChanged", | |
"change:ad": "onAdChanged", | |
"change:connecting": "onConnectingChanged" | |
}, | |
ui: { | |
progress: ".bar", | |
ticker: ".timecode" | |
}, | |
updateTicker: function() { | |
return this.ui.ticker.html(this.model.get("playing") ? this.progressModel.getDisplayTime() : "") | |
}, | |
onPlayingChanged: function(e, t) { | |
return t ? this.updateIntervalId = setInterval(o.bind(this.updateTicker, this), 1e3) : clearInterval(this.updateIntervalId), this.render() | |
}, | |
onTrackChanged: function(e, t) { | |
return t ? (this.progressModel = new s(t.toJSON()), this.ui.progress.clearQueue(), this.render(), this.updateTicker(), this.updateProgress()) : void 0 | |
}, | |
onConnectingChanged: function() { | |
return this.toggleAnimated(!0) | |
}, | |
onAdChanged: function(e, t) { | |
return t ? (this.progressModel = new s(t), this.ui.progress.clearQueue(), this.render(), this.updateTicker(), this.updateProgress()) : void 0 | |
}, | |
toggleAnimated: function(e) { | |
return e ? this.ui.progress.addClass(a).width("100%") : this.render() | |
}, | |
updateProgress: function() { | |
var e; | |
return this.model.get("connecting") ? this.toggleAnimated(!0) : this.model.get("playing") ? (this.ui.progress.removeClass(a), e = this.progressModel.getPercentComplete(), this.ui.progress.toggleClass(a, 100 === e), this.ui.progress.width(e + "%"), 100 !== e ? this.ui.progress.animate({ | |
width: "100%" | |
}, { | |
duration: 1e3 * this.progressModel.getRemainingSeconds(), | |
easing: "linear", | |
queue: !1 | |
}) : void 0) : this.toggleAnimated(!1) | |
}, | |
onDestroy: function() { | |
return clearInterval(this.updateIntervalId) | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.IcecastPlayer.Views.Track", function(e, t, n, i, r, o) { | |
return e.TitleBar = di.ui.View.extend({ | |
template: "di/ui/webplayer/track/title", | |
modelEvents: { | |
"change:track": "render", | |
"change:ad": "render", | |
"change:playing": "render", | |
"change:connecting": "render", | |
"change:volume": "onVolumeChanged" | |
}, | |
onVolumeChanged: function(e, t) { | |
return this.status = 0 === t ? "Volume: Muted" : "Volume: " + t + "%", clearTimeout(this.timeoutId), this.timeoutId = setTimeout(function(e) { | |
return function() { | |
return e.status = null, e.render() | |
} | |
}(this), 2e3), this.render() | |
}, | |
onBeforeDestroy: function() { | |
return clearTimeout(this.timeoutId) | |
}, | |
serializeData: function() { | |
var e, t, n; | |
return e = this.model.toJSON(), e.status = this.status, e.ad && (o.isFunction(e.ad.toJSON) && (e.ad = e.ad.toJSON()), null == (t = e.ad).track && (t.track = "Sponsored Message"), null == (n = e.ad).url && (n.url = Routes.premium_path())), e | |
}, | |
templateHelpers: { | |
statusText: function() { | |
return this.status ? this.status : this.connecting ? "connecting..." : this.playing ? void 0 : "stopped" | |
}, | |
primaryText: function() { | |
var e; | |
return this.statusText() ? "" : (this.track && (e = "", this.track.artist && (e = this.track.artist.name || this.track.artist), e === this.track.title && (e = ""), e && (e += " - ")), e || "") | |
}, | |
secondaryText: function() { | |
return this.statusText() ? "" : this.track ? this.track.title || this.track.track : this.ad ? this.ad.track : "" | |
} | |
} | |
}) | |
}) | |
}.call(this), | |
function() {}.call(this), | |
function() { | |
di.app.module("WebplayerApp.IcecastPlayer.Views", function(e, t, n, i, r) { | |
var o, a, s, l; | |
return a = 1, l = "icon-sound", s = "icon-mute", o = 5, e.Volume = i.ItemView.extend({ | |
template: "di/ui/webplayer/settings/volume", | |
modelEvents: { | |
"change:volume": "invalidateView" | |
}, | |
ui: { | |
muteToggleButton: "[data-toggle-mute]", | |
minButton: "[data-min-volume]", | |
maxButton: "[data-max-volume]", | |
sliderHandle: ".handle", | |
sliderContainer: ".progress-container", | |
sliderBar: ".progress-bar" | |
}, | |
events: { | |
mousewheel: "onMousewheel", | |
mousemove: "onMousemove", | |
"mousedown @ui.sliderContainer": "onVolumeSliderClick", | |
"mousedown @ui.sliderHandle": "onSliderHandleClick", | |
"click @ui.muteToggleButton": "onMuteToggleClick", | |
"click @ui.minButton": "onMinVolumeClick", | |
"click @ui.maxButton": "onMaxVolumeClick" | |
}, | |
behaviors: { | |
Popdown: {}, | |
KeyCommands: { | |
"+": "keyVolumeUp", | |
"=": "keyVolumeUp", | |
"-": "keyVolumeDown" | |
} | |
}, | |
limitVolume: function(e) { | |
return Math.min(100, Math.max(0, e)) | |
}, | |
keyVolumeUp: function() { | |
var e; | |
return e = this.model.get("volume") + o, this.model.setVolume(this.limitVolume(e)) | |
}, | |
keyVolumeDown: function() { | |
var e; | |
return e = this.model.get("volume") - o, this.model.setVolume(this.limitVolume(e)) | |
}, | |
onMousewheel: function(e, t) { | |
var n; | |
return e.preventDefault(), n = this.model.get("volume") + t * a, this.model.setVolume(this.limitVolume(n)) | |
}, | |
onMousemove: function(e) { | |
var t; | |
if (this.dragging) return t = e.clientX - this.handleOffset, this.model.setVolume(this.limitVolume(t)) | |
}, | |
invalidateView: function() { | |
return this.ui.muteToggleButton.toggleClass(s, this.model.isMuted()), this.ui.muteToggleButton.toggleClass(l, !this.model.isMuted()), this.ui.sliderHandle.css("left", this.model.get("volume") + "%"), this.ui.sliderBar.width(this.model.get("volume") + "%") | |
}, | |
onVolumeSliderClick: function(e) { | |
return e.preventDefault(), this.startDrag(), e.offsetX = e.offsetX - 2 || e.clientX - this.ui.progressContainer.offset().left + 2, this.handleOffset = e.clientX - e.offsetX, this.model.setVolume(this.limitVolume(e.offsetX)) | |
}, | |
onSliderHandleClick: function(e) { | |
return e.preventDefault(), this.startDrag(), this.handleOffset = e.clientX - e.target.offsetLeft | |
}, | |
onMuteToggleClick: function() { | |
return this.model.toggleMute() | |
}, | |
onMinVolumeClick: function() { | |
return this.model.setVolume(0) | |
}, | |
onMaxVolumeClick: function() { | |
return this.model.setVolume(100) | |
}, | |
startDrag: function() { | |
return this.dragging = !0, r(document).one("mouseup", function(e) { | |
return function() { | |
return e.dragging = !1 | |
} | |
}(this)) | |
}, | |
templateHelpers: { | |
iconClass: function() { | |
return 0 === this.volume ? s : l | |
} | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.IcecastPlayer.Views", function(e, t, n, i) { | |
return e.WebplayerLayout = i.LayoutView.extend({ | |
template: "di/ui/webplayer/webplayer_layout", | |
className: "wrap", | |
regions: { | |
trackRegion: ".track-region", | |
settingsRegion: ".settings-region", | |
channelRegion: ".channel-region" | |
}, | |
modelEvents: { | |
"change:playerType": "onPlayerTypeChanged" | |
}, | |
onPlayerTypeChanged: function(e, t) { | |
return "IcecastPlayer" !== t ? this.destroy() : void 0 | |
}, | |
onBeforeShow: function() { | |
return this.trackRegion.show(new e.TrackLayout({ | |
model: this.model | |
})), this.settingsRegion.show(new e.Settings({ | |
model: this.model | |
})), this.channelRegion.show(new e.ChannelLayout({ | |
model: this.model | |
})) | |
} | |
}), e.TrackLayout = i.LayoutView.extend({ | |
template: "di/ui/webplayer/track/track_layout", | |
modelEvents: { | |
"change:track": "onTrackChanged" | |
}, | |
regions: { | |
controlsRegion: ".controls", | |
progressRegion: ".progress", | |
titleRegion: ".track-title", | |
artworkRegion: ".artwork", | |
actionsRegion: ".actions-container" | |
}, | |
onBeforeShow: function() { | |
return this.controlsRegion.show(new e.Track.PlayButton({ | |
model: this.model | |
})), this.progressRegion.show(new e.Track.ProgressBar({ | |
model: this.model | |
})), this.titleRegion.show(new e.Track.TitleBar({ | |
model: this.model | |
})), this.artworkRegion.show(new e.Track.Artwork({ | |
model: this.model | |
})), this.actionsRegion.show(new e.Track.Actions({ | |
template: "di/ui/webplayer/track/actions_disabled" | |
})) | |
}, | |
onTrackChanged: function(t, n) { | |
return this.actionsRegion.show(n && n.get("uri") ? new e.Track.Actions({ | |
model: n | |
}) : new e.Track.Actions({ | |
template: "di/ui/webplayer/track/actions_disabled" | |
})) | |
} | |
}), e.ChannelLayout = i.LayoutView.extend({ | |
template: "di/ui/webplayer/channel_layout", | |
modelEvents: { | |
"change:channel": "onChannelChanged" | |
}, | |
regions: { | |
detailRegion: ".channel-detail" | |
}, | |
onBeforeShow: function() { | |
return this.channelNavMenu = new e.ChannelNavMenu({ | |
channels: t.request("channel:entities") | |
}), this.detailRegion.show(new e.ChannelDetail({ | |
model: this.model.get("channel"), | |
channelNavMenu: this.channelNavMenu | |
})) | |
}, | |
onChannelChanged: function(t, n) { | |
return this.detailRegion.show(new e.ChannelDetail({ | |
model: n, | |
channelNavMenu: this.channelNavMenu | |
})) | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.IcecastPlayer", function(e, t, n, i, r, o) { | |
var a, s, l, u, c; | |
return this.startWithParent = !1, u = 3, a = "ad-visible", l = "IcecastPlayer", c = new di.log.Console(l), s = { | |
playChannel: function(n) { | |
var i, r, a, u; | |
if (u = t.request("channel:entity", n), i = u && u === s.getCurrentChannel(), a = di.app.request("webplayer:isShowingAd"), r = s.getIsPlaying(), i) { | |
if (a) return; | |
if (r) return t.commands.execute("transportmanager:stop") | |
} | |
return t.commands.execute("transportmanager:stop"), e.model.set({ | |
playerType: l, | |
channel: u | |
}), o.defer(function() { | |
return t.commands.execute("transportmanager:play") | |
}) | |
}, | |
getCurrentTrack: function() { | |
return e.model.get("track") | |
}, | |
getCurrentChannel: function() { | |
return e.model.get("channel") | |
}, | |
getIsReady: function() { | |
return e.model.get("ready") | |
}, | |
getIsPlaying: function() { | |
return e.model.get("playing") | |
}, | |
getVolume: function() { | |
return e.model.get("volume") | |
}, | |
getIsMuted: function() { | |
return e.model.get("muted") | |
}, | |
getIsFirstTimeListener: function() { | |
return e.model.get("firstTimeListener") | |
}, | |
onVolumeChanged: function(e, n) { | |
return e.get("ready") === !0 ? t.commands.execute("webplayer:setVolume", n) : void 0 | |
}, | |
onAdapterReady: function() { | |
return s.attachCommandHandlers(), s.initVolume() | |
}, | |
initVolume: function() { | |
var n; | |
if (e.model.get("playerType") === l) return n = s.getVolume(), 1 > n && (n = 100 * n), t.commands.execute("webplayer:setVolume", n), e.model.set({ | |
volume: n | |
}) | |
}, | |
onPlaybackStarted: function() { | |
var n; | |
return e.model.set({ | |
connecting: !1, | |
playing: !0 | |
}), n = t.request("channel:entity", { | |
playing: !0 | |
}), null != n && n.set("playing", !1), e.model.get("channel").set("playing", !0) | |
}, | |
onPlaybackStopped: function() { | |
return e.model.get("playerType") === l ? (e.model.set({ | |
connecting: !1, | |
playing: !1, | |
track: null, | |
ad: null | |
}), e.model.get("channel").set("playing", !1)) : void 0 | |
}, | |
onConnecting: function() { | |
return e.model.set({ | |
playing: !1, | |
connecting: !0, | |
showing: !0 | |
}) | |
}, | |
onAdStarted: function(t) { | |
return e.model.set({ | |
playerType: l, | |
ad: t, | |
track: null, | |
playing: !0, | |
connecting: !1 | |
}) | |
}, | |
onAdblockBegin: function() { | |
return r(document.body).addClass(a) | |
}, | |
onAdblockEnd: function() { | |
return r(document.body).removeClass(a) | |
}, | |
onTrackStarted: function(i) { | |
var r; | |
return i.track_id ? (r = t.request("trackHistory:entity", { | |
id: i.track_id, | |
channel_id: i.channel_id | |
}), r.set(i, { | |
silent: !0 | |
})) : (console.warn("Warning: track lacks an ID:", i), r = new n.Model(i)), e.model.set({ | |
track: r, | |
ad: null, | |
playing: !0, | |
connecting: !1 | |
}) | |
}, | |
onChannelChanged: function(e, t) { | |
var n; | |
if (t) return n = t.toJSON(), AudioAddict.API.Config.channelId = t.get("id"), r(document).trigger("Channel.Set", n), r(document).trigger("Channel.Changed", n), AudioAddict.API.Config.channel = n.key | |
}, | |
attachEventbusHandlers: function() { | |
return e.listenTo(di.eventbus, "webplayer:playback:start", s.onPlaybackStarted), e.listenTo(di.eventbus, "webplayer:playback:stop", s.onPlaybackStopped), e.listenTo(di.eventbus, "webplayer:track:begin", s.onTrackStarted), e.listenTo(di.eventbus, "webplayer:ad:begin", s.onAdStarted), e.listenTo(di.eventbus, "webplayer:connecting", s.onConnecting), e.listenTo(di.eventbus, "webplayer:adblock:begin", s.onAdblockBegin), e.listenTo(di.eventbus, "webplayer:adblock:end", s.onAdblockEnd) | |
}, | |
attachModelEventHandlers: function() { | |
return e.listenTo(e.model, "change:channel", s.onChannelChanged), e.listenTo(e.model, "change:volume", s.onVolumeChanged), e.listenTo(e.model, "change:playerType", s.onPlayerTypeChanged) | |
}, | |
attachCommandHandlers: function() { | |
return t.commands.getHandler("webplayer:play:channel") ? void 0 : t.commands.setHandlers({ | |
"webplayer:play:channel": s.playChannel, | |
"webplayer:adpanel:close": s.onAdblockEnd | |
}) | |
}, | |
attachHandlers: function() { | |
return s.attachEventbusHandlers(), s.attachModelEventHandlers() | |
}, | |
createAdapter: function() { | |
return e.player = AudioAddict.WP.wp = new AudioAddict.WP.WebPlayer | |
}, | |
fetchConfig: function() { | |
if (!e.config || !e.config.ready) { | |
if (null == e.config && (e.config = new e.Config), e.config.attempts < u) return e.config.fetch().done(function() { | |
return e.config.ready = !0, s.createAdapter() | |
}).fail(s.fetchConfig); | |
throw "FATAL: unable to fetch webplayer config" | |
} | |
}, | |
start: function() { | |
return s.fetchConfig(), t.vent.once("webplayer:ready", s.onAdapterReady) | |
}, | |
startLegacy: function(n) { | |
return e.listenTo(di.eventbus, "webplayer:playback:start", s.onPlaybackStarted), e.listenTo(di.eventbus, "webplayer:playback:stop", s.onPlaybackStopped), t.vent.once("webplayer:ready", s.initVolume), t.commands.setHandler("webplayer:legacy:setVolume", function(t) { | |
return e.model.set("volume", t) | |
}), s.attachModelEventHandlers(), e.model.set({ | |
playerType: l, | |
channel: t.request("channel:entity", n) | |
}), c.log("IcecastPlayer started {legacy mode}") | |
} | |
}, e.addInitializer(function(e) { | |
return this.options = e, this.model = this.options.model, this.options.legacy ? s.startLegacy(this.options.channelKey) : (AudioAddict.webplayer.ui.ads.jqueryPanelDisabled = !0, s.start()) | |
}), e.startListening = function() { | |
return s.attachHandlers() | |
} | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.OnDemandPlayer.Adapter", function(e, t, n, i, r, o) { | |
return e.Base = function() { | |
function e() { | |
t.commands.setHandlers({ | |
"webplayer:play": o.bind(this.play, this), | |
"webplayer:pause": o.bind(this.pause, this), | |
"webplayer:stop": o.bind(this.stop, this), | |
"webplayer:volume": o.bind(this.setVolume, this), | |
"webplayer:mute:toggle": o.bind(this.muteToggle, this), | |
"webplayer:mute": o.bind(this.mute, this), | |
"webplayer:unmute": o.bind(this.unmute, this), | |
"webplayer:src": o.bind(this.src, this), | |
"webplayer:seek": o.bind(this.seek, this) | |
}), (this.initialize || r.noop).apply(this, arguments) | |
} | |
var i; | |
return o.extend(e.prototype, n.Events), i = function(e) { | |
throw new Error("" + e + " must be implemented") | |
}, e.prototype.play = function() { | |
return i("play") | |
}, e.prototype.pause = function() { | |
return i("pause") | |
}, e.prototype.stop = function() { | |
return i("stop") | |
}, e.prototype.mute = function() { | |
return i("mute") | |
}, e.prototype.unmute = function() { | |
return i("unmute") | |
}, e.prototype.muteToggle = function() { | |
return i("muteToggle") | |
}, e.prototype.getVolume = function() { | |
return i("getVolume") | |
}, e.prototype.setVolume = function() { | |
return i("setVolume") | |
}, e.prototype.seek = function() { | |
return i("seek") | |
}, e.prototype.src = function() { | |
return i("src") | |
}, e | |
}() | |
}) | |
}.call(this), | |
function() { | |
var e; | |
di.provide("di.math.round10"), di.provide("di.math.floor10"), di.provide("di.math.ceil10"), e = function(e, t, n) { | |
return "undefined" == typeof n || 0 === +n ? Math[e](t) : (t = +t, n = +n, isNaN(t) || "number" != typeof n || n % 1 !== 0 ? 0 / 0 : (t = t.toString().split("e"), t = Math[e](+(t[0] + "e" + (t[1] ? +t[1] - n : -n))), t = t.toString().split("e"), +(t[0] + "e" + (t[1] ? +t[1] + n : n)))) | |
}, di.math.round10 = function(t, n) { | |
return e("round", t, n) | |
}, di.math.floor10 = function(t, n) { | |
return e("floor", t, n) | |
}, di.math.ceil10 = function(t, n) { | |
return e("ceil", t, n) | |
} | |
}.call(this), | |
function() { | |
var e; | |
e = $("<object>").attr("type", "application/x-shockwave-flash").attr("name", "flashblockdetect").css({ | |
position: "absolute", | |
left: "-5000px", | |
width: 10, | |
height: 10 | |
}).appendTo(document.body), _.delay(function() { | |
var t, n; | |
if (n = !1, navigator.plugins["Shockwave Flash"]) e.exists() ? "none" === e[0].style.display ? n = !0 : $("div.flc-panel").exists() ? n = !0 : $("div[bginactive]").exists() ? n = !0 : e.hasClass("CTPnodisplay") && (n = !0) : n = !0; | |
else if (navigator.userAgent.indexOf("MSIE") > -1) try { | |
new ActiveXObject("ShockwaveFlash.ShockwaveFlash") | |
} catch (i) { | |
t = i, n = !0 | |
} | |
return e.remove(), n ? (console.warn("Flash is blocked"), di.app.commands.execute("flash:error", "blocked")) : void 0 | |
}, 1e3) | |
}.call(this), | |
function() { | |
di.provide("di.swf.Injector"), di.swf.Embed = function() { | |
function e(e) { | |
var n; | |
if (e.params = _.extend({}, t.params, e.params), e.attrs = _.extend({}, t.attrs, e.attrs), e.flashvars = _.extend({}, t.flashvars, e.flashvars), this.options = _.extend({}, t, e), null == (n = this.options.attrs).id && (n.id = _.uniqueId("swf")), this.options.target || (this.options.target = _.uniqueId("swf"), $("<div>").attr("id", this.options.target).appendTo(document.body)), !this.options.swfUrl) throw "swfUrl is required"; | |
di.env.development && (this.options.swfUrl += "?_=" + Date.now()), this.enforcePolicy() | |
} | |
var t; | |
return t = { | |
swfUrl: null, | |
target: null, | |
swfWidth: 10, | |
swfHeight: 10, | |
hidden: !0, | |
minVersion: "10.2", | |
flashvars: {}, | |
params: { | |
allownetworking: !0, | |
allowscriptaccess: !0, | |
wmode: "transparent", | |
allowfullscreen: !1 | |
}, | |
attrs: {}, | |
success: $.noop, | |
error: $.noop | |
}, e.prototype.enforcePolicy = function() { | |
return this.hasFlash = swfobject.getFlashPlayerVersion().major > 0, this.hasMinVersion = this.hasFlash && swfobject.hasFlashPlayerVersion(this.options.minVersion), this.doEmbed() | |
}, e.prototype.doEmbed = function() { | |
var e; | |
return this.hasMinVersion || (e = "update"), this.hasFlash || (e = "install"), e ? (console.warn("swf embed failed; reason: " + e), this.options.error(e), di.app.commands.execute("flash:error", e)) : di.swfobject.embedSWF(this.options.swfUrl, this.options.target, this.options.swfWidth, this.options.swfHeight, this.options.minVersion, null, this.options.flashvars, this.options.params, this.options.attrs, _.bind(this.onSwfObjectComplete, this)) | |
}, e.prototype.onSwfObjectComplete = function(e) { | |
var t; | |
return e.success ? (this.el = e.ref, this.options.hidden && $(this.el).css({ | |
position: "absolute", | |
left: -1 * this.options.swfWidth, | |
top: 0 | |
}), this.options.success(this.el)) : (t = "unknown", console.warn("swf embed failed; reason: " + t), this.options.error(t), void di.app.commands.execute("flash:error", t)) | |
}, e | |
}() | |
}.call(this), | |
function() { | |
var e = {}.hasOwnProperty, | |
t = function(t, n) { | |
function i() { | |
this.constructor = t | |
} | |
for (var r in n) e.call(n, r) && (t[r] = n[r]); | |
return i.prototype = n.prototype, t.prototype = new i, t.__super__ = n.prototype, t | |
}; | |
di.app.module("WebplayerApp.OnDemandPlayer.Adapter", function(e, n, i, r, o, a) { | |
return e.Flash = function(e) { | |
function n() { | |
return n.__super__.constructor.apply(this, arguments) | |
} | |
return t(n, e), n.prototype.type = "flash", n.prototype.initialize = function(e) { | |
var t, n; | |
return t = a.uniqueId("_flashJsBridge") + Date.now(), this.model = e.model, n = this, new di.swf.Embed({ | |
swfUrl: e.swfUrl, | |
flashvars: { | |
callback: t | |
}, | |
success: function(e) { | |
return n.el = e, a.defer(function() { | |
return n.trigger("ready", e) | |
}) | |
} | |
}), window[t] = a.bind(this.flashJsBridge, this) | |
}, n.prototype.play = function() { | |
return this.el.play2() | |
}, n.prototype.pause = function() { | |
return this.el.pause() | |
}, n.prototype.stop = function() { | |
return this.el.stop2() | |
}, n.prototype.setPosition = function(e) { | |
return this.seek(e) | |
}, n.prototype.seek = function(e) { | |
return this.model.get("src") && this.el.canSeekTo(e) ? (this.model.set({ | |
currentTime: e | |
}), this.el.seek(e)) : void 0 | |
}, n.prototype.setVolume = function(e) { | |
return this.el.setVolume(e) | |
}, n.prototype.getVolume = function() { | |
return this.el.getVolume() | |
}, n.prototype.mute = function() { | |
return this.el.setMuted(!0) | |
}, n.prototype.unmute = function() { | |
return this.el.setMuted(!1) | |
}, n.prototype.muteToggle = function() { | |
return this.el.getMuted() ? this.unmute() : this.mute() | |
}, n.prototype.src = function(e) { | |
return a.isArray(e) || (e = [e]), this.el.setSrc(e) | |
}, n.prototype.flashJsBridge = function(e, t) { | |
switch (null == this.updateModel && (this.updateModel = function(e) { | |
return function(t) { | |
return a.defer(a.bind(e.model.set, e.model, t)) | |
} | |
}(this)), e) { | |
case "loading": | |
return this.updateModel({ | |
connecting: !0 | |
}); | |
case "timeupdate": | |
return this.updateModel({ | |
currentTime: t, | |
connecting: !1 | |
}); | |
case "playing": | |
case "stopped": | |
case "paused": | |
return this.updateModel({ | |
playing: "playing" === e, | |
connecting: !1 | |
}); | |
case "ended": | |
return this.updateModel({ | |
ended: !0, | |
playing: !1, | |
connecting: !1, | |
currentTime: 0 | |
}); | |
case "seeking": | |
return this.updateModel({ | |
seeking: t | |
}); | |
case "volumechange": | |
return this.updateModel({ | |
volume: t | |
}); | |
case "progress": | |
return this.updateModel({ | |
loadProgress: t | |
}) | |
} | |
}, n | |
}(e.Base) | |
}) | |
}.call(this), | |
function() { | |
var e = {}.hasOwnProperty, | |
t = function(t, n) { | |
function i() { | |
this.constructor = t | |
} | |
for (var r in n) e.call(n, r) && (t[r] = n[r]); | |
return i.prototype = n.prototype, t.prototype = new i, t.__super__ = n.prototype, t | |
}; | |
di.app.module("WebplayerApp.OnDemandPlayer.Adapter", function(e, n, i, r, o, a) { | |
var s; | |
return e.HTML5 = function(e) { | |
function i() { | |
return i.__super__.constructor.apply(this, arguments) | |
} | |
return t(i, e), i.prototype.type = "html5", i.prototype.initialize = function(e) { | |
if (o.browser.msie || n.options.webplayer.html5AudioEnabled === !1) throw new Error("html5 audio not enabled"); | |
if (!this.canPlayTypes(e.formats)) throw new Error("html5 audio formats not supported: " + this.unsupportedFormats.join(", ")); | |
return this.model = e.model, this.el = this.createElement(), a.defer(function(e) { | |
return function() { | |
return e.trigger("ready", e.el) | |
} | |
}(this)) | |
}, i.prototype.createElement = function() { | |
var e, t; | |
return e = o(document.createElement("audio")), t = a.bind(this.onAudioEvent_, this), a.each(s, function(n) { | |
return e.on(n, t) | |
}), e[0] | |
}, i.prototype.canPlayTypes = function(e) { | |
var t; | |
return e.length > 0 ? (t = a.filter(e, function(e) { | |
return Modernizr.audio && !!Modernizr.audio[e] | |
}), this.unsupportedFormats = a.difference(e, t), 0 === this.unsupportedFormats.length) : !1 | |
}, i.prototype.play = function() { | |
return this.el.play() | |
}, i.prototype.pause = function() { | |
return this.el.pause() | |
}, i.prototype.stop = function() { | |
return this.el.pause(), this.el.src = "" | |
}, i.prototype.seek = function(e) { | |
return this.model.get("src") ? (this.model.get("playing") || o(this.el).one("canplay", a.bind(this.el.pause, this.el)), this.el.currentTime = e) : void 0 | |
}, i.prototype.setVolume = function(e) { | |
var t; | |
return this.el.volume !== e ? (this.el.volume = e, t = this.el.muted, this.el.muted = 0 === e) : void 0 | |
}, i.prototype.getVolume = function() { | |
return this.el.volume | |
}, i.prototype.mute = function() { | |
return this.el.muted ? void 0 : (this.prevVolume = this.getVolume(), this.setVolume(0)) | |
}, i.prototype.unmute = function() { | |
return this.el.muted ? this.setVolume(this.prevVolume) : void 0 | |
}, i.prototype.muteToggle = function() { | |
return this.el.muted ? this.unmute() : this.mute() | |
}, i.prototype.src = function(e) { | |
return e ? (this.stop(), a.isArray(e) || (e = [e]), this.el.src = a.first(a.filter(e, function(e) { | |
return e.indexOf("http") > -1 | |
}))) : void 0 | |
}, i.prototype.onAudioEvent_ = function(e) { | |
switch (e.type) { | |
case "canplay": | |
return this.model.get("ended") ? this.pause() : this.play(); | |
case "timeupdate": | |
return this.model.set({ | |
currentTime: this.el.currentTime | |
}); | |
case "durationchange": | |
return this.model.set({ | |
duration: this.el.duration | |
}); | |
case "playing": | |
return this.model.set({ | |
playing: !0, | |
connecting: !1 | |
}); | |
case "pause": | |
return this.model.set({ | |
ended: !1, | |
playing: !1, | |
connecting: !1 | |
}); | |
case "ended": | |
return this.model.set({ | |
ended: !0, | |
playing: !1, | |
currentTime: 0 | |
}), this.seek(0); | |
case "loadstart": | |
return this.model.set({ | |
src: this.el.src, | |
connecting: !0 | |
}); | |
case "volumechange": | |
return this.model.set({ | |
volume: this.el.volume, | |
muted: 0 === this.el.volume | |
}); | |
case "seeking": | |
return this.model.set({ | |
seeking: !0 | |
}); | |
case "seeked": | |
return this.model.set({ | |
seeking: !1, | |
connecting: !1 | |
}) | |
} | |
}, i | |
}(e.Base), s = ["canplay", "durationchange", "ended", "loadstart", "pause", "play", "playing", "progress", "seeking", "seeked", "timeupdate", "volumechange"] | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.OnDemandPlayer", function(e, t) { | |
return e.addInitializer(function(n) { | |
var i; | |
if (!n.legacy) { | |
try { | |
this.adapter = new e.Adapter.HTML5({ | |
model: t.WebplayerApp.model, | |
formats: ["mp3", "m4a"] | |
}) | |
} catch (r) { | |
i = r, console.warn(i.message), this.adapter = new e.Adapter.Flash({ | |
model: t.WebplayerApp.model, | |
swfUrl: t.options.webplayer.swfUrl | |
}) | |
} | |
return this.adapter.once("ready", function(e) { | |
return function() { | |
return t.vent.trigger("webplayer:adapter:ready", "OnDemandPlayer"), di.analytics.trackNonInteractiveEvent({ | |
category: "Webplayer.Adapter", | |
action: e.adapter.type | |
}) | |
} | |
}(this)) | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.OnDemandPlayer.Views", function(e, t, n, i) { | |
var r, o, a; | |
return a = "icon-play", o = "icon-pause", r = "icon-spinner3", e.PlayButton = i.ItemView.extend({ | |
template: "di/ui/webplayer/track/play_button", | |
modelEvents: { | |
"change:playing": "render" | |
}, | |
events: { | |
click: "onPlayPauseClick" | |
}, | |
behaviors: { | |
KeyCommands: { | |
" ": "onPlayPauseClick" | |
} | |
}, | |
onPlayPauseClick: function(e) { | |
return e.preventDefault(), this.model.get("hasPlayed") ? t.commands.execute(this.model.get("playing") ? "webplayer:pause" : "webplayer:play") : t.commands.execute("webplayer:play:track", this.model.get("track").get("id")) | |
}, | |
templateHelpers: function() { | |
return { | |
iconClass: function() { | |
return this.track ? this.connecting ? r : this.playing ? o : a : "" | |
}, | |
ariaLabel: function() { | |
return this.playing ? "pause" : "play" | |
}, | |
ariaAttr: function() { | |
return "" | |
} | |
} | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.OnDemandPlayer.Views", function(e, t, n, i, r, o) { | |
return e.ProgressBar = i.ItemView.extend({ | |
template: "di/ui/webplayer_ondemand/progress_bar", | |
className: "progress-wrap", | |
ui: { | |
playProgress: ".progress-play", | |
loadProgress: ".progress-load", | |
timecode: ".timecode" | |
}, | |
modelEvents: { | |
"change:duration": "render", | |
"change:loadProgress": "onLoadProgressChange", | |
"change:playing": "onPlayingChange", | |
"change:seeking": "onSeekingChange", | |
"change:ended": "onEndedChanged", | |
"change:connecting": "onConnectingChanged" | |
}, | |
events: { | |
click: "onScrubClick" | |
}, | |
onPlayingChange: function(e, t) { | |
return this.updateTimecode(), t ? this.timecodeRefreshID = setInterval(o.bind(this.updateTimecode, this), 1e3) : clearInterval(this.timecodeRefreshID) | |
}, | |
onConnectingChanged: function(e, t) { | |
return this.ui.playProgress.stop().toggleClass("animated", t) | |
}, | |
onLoadProgressChange: function(e, t) { | |
return null == t && (t = 100), this.ui.loadProgress.width("" + t + "%") | |
}, | |
onSeekingChange: function(e, t) { | |
return t ? void 0 : (this.updateProgressBar(), this.updateTimecode()) | |
}, | |
onEndedChanged: function(e, t) { | |
return t ? this.ui.playProgress.css("width", "0%") : void 0 | |
}, | |
updateTimecode: function() { | |
var e, t, n; | |
return e = Math.floor(this.model.get("duration") / 3600) > 0, t = di.date.format.secondsToTimecode(this.model.get("currentTime"), { | |
includeZeroHours: e | |
}), n = di.date.format.secondsToTimecode(this.model.get("duration")), this.ui.timecode.text("" + t + " / " + n), this.updateProgressBar() | |
}, | |
updateProgressBar: function() { | |
var e, t; | |
if (this.model.get("duration") > 0 && (e = this.model.get("currentTime") / this.model.get("duration"), e *= 100, !isNaN(e) && e !== this.prevProgressPct && (this.prevProgressPct = e, this.ui.playProgress.stop(), this.ui.playProgress.css("width", "" + e + "%"), this.model.get("playing")))) return Math.ceil(e) < 100 ? (t = this.model.get("duration") - this.model.get("currentTime"), this.ui.playProgress.animate({ | |
width: "100%" | |
}, { | |
duration: 1e3 * t, | |
easing: "linear", | |
queue: !1 | |
})) : void 0 | |
}, | |
onScrubClick: function(e) { | |
var n, i, o; | |
if (!this.model.get("seeking") && !this.model.get("connecting")) return o = e.offsetX || e.clientX - r(e.currentTarget).offset().left, n = o / this.$el.width(), i = this.model.get("duration") * n, t.commands.execute("webplayer:seek", i) | |
}, | |
onRender: function() { | |
return this.prevProgressPct = null, this.updateTimecode(), this.updateProgressBar() | |
}, | |
onBeforeDestroy: function() { | |
return clearInterval(this.timecodeRefreshID) | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.OnDemandPlayer.Views", function(e, t, n, i) { | |
return e.Settings = i.LayoutView.extend({ | |
template: "di/ui/webplayer/settings", | |
regions: { | |
volumeRegion: ".volume-region", | |
actionMenu: ".actions-menu" | |
}, | |
ui: { | |
settingsButton: ".preferences" | |
}, | |
events: { | |
"click @ui.settingsButton": "onSettingsButtonClick" | |
}, | |
onBeforeShow: function() { | |
return this.volumeRegion.show(new e.Volume({ | |
model: this.model | |
})) | |
}, | |
onSettingsButtonClick: function() { | |
return t.options.user.authenticated ? t.commands.execute("xhrpages:navigate", Routes.settings_path()) : t.commands.execute("modal:gatekeeper", { | |
prompt: "You must be logged in to change player preferences" | |
}) | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.OnDemandPlayer.Views", function(e, t, n, i) { | |
return e.TrackTitle = i.ItemView.extend({ | |
template: "di/ui/webplayer_ondemand/track_title", | |
modelEvents: { | |
"change:track": "render", | |
"change:playing": "render", | |
"change:volume": "onVolumeChanged" | |
}, | |
onVolumeChanged: function(e, t) { | |
return this.status = 0 === t ? "Volume: Muted" : "Volume: " + Math.floor(100 * t) + "%", clearTimeout(this.timeoutId), this.timeoutId = setTimeout(function(e) { | |
return function() { | |
return e.status = null, e.render() | |
} | |
}(this), 2e3), this.render() | |
}, | |
serializeData: function() { | |
var e; | |
return e = this.model.toJSON(), e.status = this.status, e | |
}, | |
templateHelpers: { | |
primaryText: function() { | |
return this.status ? this.status : this.track && this.track.artist ? this.track.artist.name + " - " : "" | |
}, | |
secondaryText: function() { | |
return this.status ? "" : this.track.title | |
} | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.OnDemandPlayer.Views", function(e, t) { | |
var n, i, r, o; | |
return i = 1, o = "icon-sound", r = "icon-mute", n = .05, e.Volume = t.WebplayerApp.IcecastPlayer.Views.Volume.extend({ | |
modelEvents: { | |
"change:volume": "invalidateView", | |
"change:muted": "invalidateView" | |
}, | |
behaviors: { | |
Popdown: {}, | |
KeyCommands: { | |
"+": "keyVolumeUp", | |
"=": "keyVolumeUp", | |
"-": "keyVolumeDown" | |
} | |
}, | |
keyVolumeUp: function() { | |
var e; | |
return e = Math.min(this.model.get("volume") + n, 1), t.commands.execute("webplayer:volume", e) | |
}, | |
keyVolumeDown: function() { | |
var e; | |
return e = Math.max(this.model.get("volume") - n, 0), t.commands.execute("webplayer:volume", e) | |
}, | |
onBeforeShow: function() { | |
return this.model.get("volume") > 1 ? this.model.set("volume", this.model.get("volume") / 100) : void 0 | |
}, | |
onRender: function() { | |
return this.invalidateView() | |
}, | |
onMousewheel: function(e, n) { | |
var r; | |
return e.preventDefault(), r = (100 * this.model.get("volume") + n * i) / 100, t.commands.execute("webplayer:volume", r) | |
}, | |
onMousemove: function(e) { | |
var n; | |
if (this.dragging) return n = (e.clientX - this.handleOffset) / 100, t.commands.execute("webplayer:volume", n) | |
}, | |
invalidateView: function() { | |
var e; | |
return this.model.get("muted") ? (this.ui.muteToggleButton.swapClass(o, r), e = 0) : (this.ui.muteToggleButton.swapClass(r, o), e = 100 * this.model.get("volume")), this.ui.sliderHandle.css("left", e + "%"), this.ui.sliderBar.width(e + "%") | |
}, | |
onVolumeSliderClick: function(e) { | |
return e.preventDefault(), this.startDrag(), e.offsetX = e.offsetX - 2 || e.clientX - this.ui.progressContainer.offset().left + 2, this.handleOffset = e.clientX - e.offsetX, t.commands.execute("webplayer:volume", e.offsetX / 100) | |
}, | |
onMuteToggleClick: function() { | |
return t.commands.execute("webplayer:mute:toggle") | |
}, | |
onMinVolumeClick: function() { | |
return t.commands.execute("webplayer:mute") | |
}, | |
onMaxVolumeClick: function() { | |
return t.commands.execute("webplayer:volume", 1) | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.OnDemandPlayer.Views", function(e, t, n, i) { | |
return e.WebplayerLayout = i.LayoutView.extend({ | |
template: "di/ui/webplayer/webplayer_layout", | |
className: "wrap", | |
regions: { | |
trackRegion: ".track-region", | |
settingsRegion: ".settings-region", | |
channelRegion: ".channel-region" | |
}, | |
ui: { | |
currentTime: ".current-time", | |
progressMeter: ".progress-meter", | |
progressPct: ".progress-pct", | |
scrubber: ".progress-outer" | |
}, | |
onBeforeShow: function() { | |
return this.trackRegion.show(new e.TrackLayout({ | |
model: this.model | |
})), this.settingsRegion.show(new e.Settings({ | |
model: this.model | |
})) | |
} | |
}), e.TrackLayout = i.LayoutView.extend({ | |
template: "di/ui/webplayer_ondemand/track_layout", | |
regions: { | |
controlsRegion: ".controls", | |
progressRegion: ".progress", | |
titleRegion: ".track-title" | |
}, | |
modelEvents: { | |
"change:playerType": "onPlayerTypeChanged" | |
}, | |
onPlayerTypeChanged: function(e, t) { | |
return "OnDemandPlayer" !== t ? this.destroy() : void 0 | |
}, | |
onBeforeShow: function() { | |
return this.progressRegion.show(new e.ProgressBar({ | |
model: this.model | |
})), this.controlsRegion.show(new e.PlayButton({ | |
model: this.model | |
})), this.titleRegion.show(new e.TrackTitle({ | |
model: this.model | |
})) | |
} | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp.OnDemandPlayer", function(e, t, n, i, r, o) { | |
var a; | |
return this.startWithParent = !1, a = { | |
getNormalizedVolume: function() { | |
var e; | |
return e = t.WebplayerApp.model.get("volume"), e > 1 && (e /= 100), e | |
}, | |
playTrack: function(e) { | |
return t.request("current_user:isPremium") ? (t.WebplayerApp.model.set({ | |
playerType: "OnDemandPlayer", | |
src: null, | |
duration: 0 / 0, | |
currentTime: 0 / 0, | |
playing: !1 | |
}), t.request("track:entity", e, function(e) { | |
var n; | |
return n = e.assets({ | |
purpose: "on-demand", | |
quality: "hd" | |
}), t.WebplayerApp.model.set({ | |
track: e, | |
volume: a.getNormalizedVolume(), | |
src: o.values(n.urls), | |
duration: n.length, | |
currentTime: 0, | |
ready: !0 | |
}) | |
}), o.delay(function() { | |
return t.commands.execute("webplayer:play") | |
}, 500)) : void 0 | |
} | |
}, e.addInitializer(function(e) { | |
if (e.legacy) return this.stop(); | |
if (!t.commands.getHandler("webplayer:play:track")) return t.commands.setHandler("webplayer:play:track", a.playTrack) | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.provide("di.application.module.webplayer.TransportManager"), di.app.module("webplayer.transportmanager", function(e, t) { | |
var n, i, r, o; | |
return n = !1, r = new di.log.Console("di.module.webplayer.TransportManager"), o = null, i = { | |
bindAdEvents_: function() { | |
return di.eventbus.once({ | |
"webplayer:ads:preroll-end": i.startPlayer_, | |
"webplayer:ad:none_available": i.startPlayer_ | |
}) | |
}, | |
unbindAdEvents_: function() { | |
return di.eventbus.off({ | |
"webplayer:ads:preroll-end": i.startPlayer_, | |
"webplayer:ad:none_available": i.startPlayer_ | |
}) | |
}, | |
startPlayer_: function() { | |
return function() { | |
return i.unbindAdEvents_(), t.commands.execute("webplayer:audio:start") | |
} | |
}(this), | |
playPublic_: function() { | |
var e, r; | |
return i.bindAdEvents_(), n ? "function" == typeof(r = t.module("webplayer.ads")).requestAds ? r.requestAds({ | |
position: "preroll" | |
}) : void 0 : "function" == typeof(e = t.module("webplayer.ads")).requestAd ? e.requestAd({ | |
position: "preroll" | |
}) : void 0 | |
}, | |
playPremium_: function() { | |
return this.startPlayer_() | |
} | |
}, e.playAudio = function(e) { | |
return null == e && (e = !1), e ? (r.log("Play received with skipPreroll flag, starting playback immediately."), i.startPlayer_()) : null == o ? void r.log("Play received, but no play strategy set. Aborting.") : (r.log("Play: using {" + o + "}"), i[o]()) | |
}, e.stopAudio = function() { | |
var e; | |
return i.unbindAdEvents_(), t.commands.execute("webplayer:audio:stop"), "function" == typeof(e = t.module("webplayer.ads")).stopAds ? e.stopAds() : void 0 | |
}, t.addInitializer(function(t) { | |
return o = t.user.hasPremium ? "playPremium_" : "playPublic_", this.commands.setHandlers({ | |
"transportmanager:play": e.playAudio, | |
"transportmanager:stop": e.stopAudio | |
}) | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("WebplayerApp", function(e, t, n, i, r) { | |
var o, a, s, l, u, c; | |
return this.startWithParent = !1, l = "#webplayer-region", u = "wp-visible", a = "IcecastPlayer", s = "OnDemandPlayer", this.flashError = !1, c = i.Region.extend({ | |
el: r(l), | |
onBeforeSwap: function(e) { | |
return e.$el.hide() | |
}, | |
onBeforeSwapOut: function(e) { | |
return e.$el.fadeOut() | |
}, | |
onShow: function(e) { | |
return e.$el.is(":hidden") ? e.$el.fadeIn() : void 0 | |
} | |
}), o = { | |
onFlashError: function(n) { | |
return e.options.legacy ? void 0 : e.flashError || (e.flashError = n, t.commands.setHandler("webplayer:play:channel", function() { | |
return t.commands.execute("modal:flash" + n) | |
}), "flash" !== e.OnDemandPlayer.adapter.type) ? void 0 : t.commands.setHandler("webplayer:play:track", function() { | |
return t.commands.execute("modal:flash" + n) | |
}) | |
}, | |
onPlayerTypeChange: function(e, t) { | |
return o.show(t) | |
}, | |
onShowingChanged: function(e, t) { | |
return r(document.body).toggleClass(u, t) | |
}, | |
show: function(n) { | |
if (n = n || e.model.get("playerType")) { | |
if (!e.model.get("ready")) return void t.vent.once("webplayer:ready", function() { | |
return o.show(n) | |
}); | |
switch (t.webplayerRegion.$el.attr("data-player-type", n), n) { | |
case a: | |
return o.showIcecastPlayer(); | |
case s: | |
return o.showOnDemandPlayer() | |
} | |
} | |
}, | |
showIcecastPlayer: function() { | |
var n; | |
return e.IcecastPlayer.startListening(), n = e.model.get("volume"), 1 > n && n > 0 && (n = Math.ceil(100 * n)), e.model.get("playing") && t.commands.execute("webplayer:stop"), t.webplayerRegion.show(new e.IcecastPlayer.Views.WebplayerLayout({ | |
model: e.model | |
})), e.model.set({ | |
playerType: a, | |
src: null, | |
volume: n, | |
showing: !0 | |
}) | |
}, | |
showOnDemandPlayer: function() { | |
var n; | |
return e.IcecastPlayer.stopListening(), n = e.model.get("volume"), n > 1 && (n /= 100), t.commands.execute("transportmanager:stop"), t.webplayerRegion.show(new e.OnDemandPlayer.Views.WebplayerLayout({ | |
model: e.model | |
})), e.model.set({ | |
playerType: s, | |
channel: null, | |
volume: n, | |
showing: !0 | |
}) | |
}, | |
autoResume: function() { | |
var e; | |
if (!t.request("webplayer:isLegacy")) { | |
if (!t.request("webplayer:isReady")) return t.vent.once("webplayer:ready", o.autoResume); | |
switch (t.request("webplayer:playerType")) { | |
case "IcecastPlayer": | |
return e = !0, t.commands.execute("transportmanager:play", e); | |
case "OnDemandPlayer": | |
return t.commands.execute("webplayer:play") | |
} | |
} | |
}, | |
attachRegion: function(e) { | |
return e.legacy ? void 0 : t.webplayerRegion = new c | |
}, | |
attachHandlers: function() { | |
return o.attachRequestHandlers(), o.attachModelEventHandlers(), o.attachCommandHandlers() | |
}, | |
attachModelEventHandlers: function() { | |
return e.model.on("change:playerType", o.onPlayerTypeChange), e.model.on("change:showing", o.onShowingChanged) | |
}, | |
attachRequestHandlers: function() { | |
return t.reqres.setHandlers({ | |
"webplayer:channel": function() { | |
return e.model.get("channel") | |
}, | |
"webplayer:track": function() { | |
return e.model.get("track") | |
}, | |
"webplayer:isPlaying": function() { | |
return e.model.get("playing") | |
}, | |
"webplayer:isShowingAd": function() { | |
return !!e.model.get("ad") | |
}, | |
"webplayer:volume": function() { | |
return e.model.get("volume") | |
}, | |
"webplayer:muted": function() { | |
return e.model.get("muted") | |
}, | |
"webplayer:isFirstTimeListener": function() { | |
return e.model.get("firstTimeListener") | |
}, | |
"webplayer:isReady": function() { | |
return e.model.get("ready") | |
}, | |
"webplayer:playerType": function() { | |
return e.model.get("playerType") | |
}, | |
"webplayer:isLegacy": function() { | |
return !!e.options.legacy | |
} | |
}) | |
}, | |
attachCommandHandlers: function() { | |
return t.commands.setHandlers({ | |
"flash:error": o.onFlashError, | |
"webplayer:autoresume": o.autoResume | |
}) | |
}, | |
startSubModules: function(e) { | |
return t.module("WebplayerApp.OnDemandPlayer").start(e), t.module("WebplayerApp.IcecastPlayer").start(e), t.module("webplayer.transportmanager").start(), t.options.user.hasPremium ? void 0 : (t.module("webplayer.ads", di.application.module.webplayer.Ads), t.module("webplayer.ads.liverail", di.application.module.webplayer.ads.provider.Liverail), t.module("webplayer.ads").start()) | |
} | |
}, e.addInitializer(function(e) { | |
return this.options = null != e ? e : {}, "http:" !== document.location.protocol ? this.stop() : (this.model = this.options.model = new di.model.Webplayer({}, { | |
autofetch: !0 | |
}), this.model.legacy = this.options.legacy, o.attachRegion(this.options), o.startSubModules(this.options), o.attachHandlers(this.options), this.model.get("firstTimeListener") ? void 0 : o.show()) | |
}) | |
}) | |
}.call(this), | |
function() { | |
di.app.module("AsyncContentModule", function(e) { | |
var t, n, i, r, o; | |
return this.startWithParent = !1, r = {}, o = new di.log.Console("AudioAddict.UI.AsyncModule"), t = function(e) { | |
var t; | |
return t = $(this), t.block(), $.get(e, function(n) { | |
return t.html($(n).html()), o.log("Updated async mod content from {" + e + "}") | |
}).always(function() { | |
return t.unblock() | |
}) | |
}, n = function() { | |
return $("[data-async-url]").not(".ready").each(function() { | |
var e, n, i, a; | |
return e = $(this).addClass("ready"), i = e.data(), i.asyncInterval > 0 ? (a = function() { | |
return t.call(e, i.asyncUrl) | |
}, n = setInterval(a, i.asyncInterval), r[n] = e, o.log("Starting recurring async mod updates from {" + i.asyncUrl + "} at interval of {" + i.asyncInterval + "ms} with id {" + n + "}")) : t.call(e, i.asyncUrl) | |
}) | |
}, i = function() { | |
return _.each(r, function(e, t) { | |
return e.removeClass("ready").off(), clearInterval(t), o.log("Stopped recurring async mod updates from {" + e.data("async-url") + "} for id {" + t + "}") | |
}), r = {} | |
}, e.addInitializer(n), e.addFinalizer(i) | |
}) | |
}.call(this), | |
function() { | |
di.app.addInitializer(function() { | |
return this.module("modals", di.application.module.Modals), this.module("timedAlerts", di.application.module.TimedAlerts), this.module("ChannelBrowserApp", di.ChannelBrowserApp), this.module("TermForm", di.app.TermForm), this.module("ComparisonPlayer", di.app.ComparisonPlayer), this.module("FAQ", di.app.FAQ), this.module("Billing", di.app.Billing), this.module("WebplayerApp").start({ | |
legacy: !1 | |
}) | |
}), window.onerror = function(e, t, n) { | |
var i; | |
return i = "error={" + e + "}, url={" + t + "}, line={" + n + "}", console.error(i), di.analytics.trackException(i) | |
} | |
}.call(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment