From 09852e9b9b8e64f003bed5aa57630d8b42c8ac95 Mon Sep 17 00:00:00 2001
From: François Frisch
Date: Sat, 17 Mar 2012 19:28:30 -0700
Subject: Integrating picasa carousel and youtube channel
---
.../ui/youtube-channel.reel/youtube-channel.html | 34 +++++++
.../ui/youtube-channel.reel/youtube-channel.js | 101 +++++++++++++++++++++
2 files changed, 135 insertions(+)
create mode 100644 node_modules/montage/ui/youtube-channel.reel/youtube-channel.html
create mode 100644 node_modules/montage/ui/youtube-channel.reel/youtube-channel.js
(limited to 'node_modules/montage/ui/youtube-channel.reel')
diff --git a/node_modules/montage/ui/youtube-channel.reel/youtube-channel.html b/node_modules/montage/ui/youtube-channel.reel/youtube-channel.html
new file mode 100644
index 00000000..b3858ec9
--- /dev/null
+++ b/node_modules/montage/ui/youtube-channel.reel/youtube-channel.html
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/node_modules/montage/ui/youtube-channel.reel/youtube-channel.js b/node_modules/montage/ui/youtube-channel.reel/youtube-channel.js
new file mode 100644
index 00000000..fd642290
--- /dev/null
+++ b/node_modules/montage/ui/youtube-channel.reel/youtube-channel.js
@@ -0,0 +1,101 @@
+/*
+ This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
+ */
+/*global require,exports*/
+var Montage = require("montage").Montage,
+ Component = require("ui/component").Component,
+ Uuid = require("core/uuid").Uuid;
+
+
+var YoutubeChannel = exports.YoutubeChannel = Montage.create(Component, {
+
+ _userRe: {
+ enumerable: false,
+ value: /youtube.com\/(user\/)?([a-z0-9]+)/i
+ },
+
+ _channelUrl: {
+ enumerable: false,
+ value: null
+ },
+ channelUrl: {
+ depends: ["channel"],
+ get: function() {
+ return this._channelUrl;
+ },
+ set: function(value, fromChannel) {
+ if (this._channelUrl !== value) {
+ this._channelUrl = value;
+
+ // prevent infinite loop
+ if (!fromChannel) {
+ var match = this._userRe.exec(value);
+ if (match && match[2]) {
+ Object.getPropertyDescriptor(this, "channel").set.call(this, match[2], true);
+ }
+ }
+ }
+ }
+ },
+
+ _channel: {
+ enumerable: false,
+ value: null
+ },
+ channel: {
+ get: function() {
+ return this._channel;
+ },
+ set: function(value, fromUrl) {
+ if (this._channel !== value) {
+ this._channel = value;
+
+ // prevent infinite loop
+ if (!fromUrl) {
+ Object.getPropertyDescriptor(this, "channelUrl").set.call(this, "http://www.youtube.com/user/" + value, true);
+ }
+
+ this._loadChannel();
+ }
+ }
+ },
+
+ _loadChannel: {
+ enumerable: false,
+ value: function() {
+ var self = this;
+
+ var callbackName = "scriptCallback" + Uuid.generate().replace(/-/g, "_");
+
+ window[callbackName] = function(data) {
+ self.handleData(data);
+ delete window[callbackName];
+ };
+
+ // create url
+ var url = "http://gdata.youtube.com/feeds/api/users/" + this._channel + "/uploads?v=2&alt=json-in-script&callback=" + callbackName;
+
+ var script = document.createElement("script");
+ script.src = url;
+ this._element.appendChild(script);
+ }
+ },
+
+ handleData: {
+ value: function(data) {
+ var entries = data.feed.entry || [];
+
+ var playlist = [];
+
+ for (var i = 0, len = entries.length; i < len; i++) {
+ var id = entries[i]["media$group"]["yt$videoid"]["$t"];
+ playlist.push(id);
+ }
+
+ this.player.playlist = playlist;
+ }
+ }
+
+});
\ No newline at end of file
--
cgit v1.2.3