Permalink
Browse files

Starting some Google+ modules

  • Loading branch information...
1 parent 73a9292 commit b35a5a972bb77bff109d1fb3a7a6d9f0eef2b6b0 @darkspotinthecorner committed Jan 16, 2012
Showing with 417 additions and 10 deletions.
  1. +0 −8 modules/github.user.js
  2. +177 −0 modules/google.css
  3. +41 −0 modules/google.js
  4. +30 −0 modules/google.plus.js
  5. +94 −0 modules/google.plus.user.js
  6. +2 −2 modules/youtube.video.js
  7. +73 −0 test.google.html
View
@@ -7,14 +7,6 @@ DarkTip.registerModule('github.user', {
'1': 'username'
}
}
- /*
- 'implicit': {
- 'match' : /^http:\/\/www\.youtube\.com\/(v\/|watch\?v=)([A-Za-z0-9\-_]+).*$/i,
- 'params': {
- '2': 'videoid'
- }
- },
- */
},
'queries': {
View
@@ -0,0 +1,177 @@
+/* **************************************************************************
+ * The DarkTip plugin is a javascript based tooltip framework that enables
+ * quick and easy development of modules that hook into specific aspects of a
+ * webpage and display context sensitive tooltips.
+ *
+ * Copyright (C) 2011 Martin Gelder
+ * (darkspotinthecorner {at} gmail {dot} com)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://www.gnu.org/licenses/gpl.html.
+ * ************************************************************************** */
+
+/* ==========================================================================
+ * --- DarkTip.google Styles ------------------------------------------------
+ * ========================================================================== */
+
+/* --- Override of 280 max-width -------------------------------------------- */
+
+.darktip-tooltip-google {
+ max-width: 750px;
+ min-width: 200px;
+}
+
+/* --------------------------------------------------------------------------
+ * Generic Tooltips
+ * -------------------------------------------------------------------------- */
+
+.ajaxloading,
+.darktip-tooltip-google {
+ font-family: Arial, Verdana, sans-serif;
+ font-size: 12px;
+ line-height: 15px;
+}
+
+.darktip-tooltip-google .ui-tooltip-titlebar,
+.darktip-tooltip-google .ui-tooltip-content {
+ border-color: #333;
+ color: #fff;
+}
+
+.darktip-tooltip-google .ui-tooltip-content {
+ background-color: #000;
+ background-color: rgba(0, 0, 0, 0.85);
+}
+
+.darktip-tooltip-google .tooltip-404 {
+ padding:3 px;
+}
+
+.darktip-tooltip-google .tooltip-404 .title {
+ font-size: 16px;
+ font-weight: bold;
+ border-bottom: 1px solid #444;
+ margin-bottom: 5px;
+ padding-bottom: 3px;
+ color: #FF3333;
+}
+
+.darktip-tooltip-google .tooltip-404 .title .sub {
+ font-size: 14px;
+ color: #808080;
+}
+
+.darktip-tooltip-google .tooltip-404 div .value {
+ color: #FFB100;
+}
+
+.darktip-tooltip-google .darktip-row {
+ padding-bottom: 1px;
+}
+
+.darktip-tooltip-google .darktip-row.padded {
+ padding: 2px 4px;
+}
+
+.darktip-tooltip-google div {
+ position: relative;
+}
+
+/* --------------------------------------------------------------------------
+ * Simple / Extended Rules
+ * -------------------------------------------------------------------------- */
+
+.darktip-tooltip-google div.darktip-only-s {
+ display: block;
+}
+
+.darktip-tooltip-google span.darktip-only-s {
+ display: inline;
+}
+
+body.darktip-extended-mode .darktip-tooltip-google .darktip-only-s {
+ display: none;
+}
+
+.darktip-tooltip-google .darktip-only-x {
+ display: none;
+}
+
+body.darktip-extended-mode .darktip-tooltip-google div.darktip-only-x {
+ display: block;
+}
+
+body.darktip-extended-mode .darktip-tooltip-google span.darktip-only-x {
+ display: inline;
+}
+
+.darktip-tooltip-google .info-meta {
+ color: #777;
+ padding-top: 6px;
+ padding-bottom: 3px;
+}
+
+/* --------------------------------------------------------------------------
+ * More Rules
+ * -------------------------------------------------------------------------- */
+
+.darktip-tooltip-google .avatar {
+ float: left;
+ border: 4px solid rgba(0, 0, 0, 0.33);
+}
+
+.darktip-tooltip-google .col-98 {
+ padding: 4px 4px 4px 98px;
+}
+
+.darktip-tooltip-google .pos-right {
+ position: absolute;
+ top: 0;
+ right: 0;
+}
+
+/* --------------------------------------------------------------------------
+ * Specific Elements Rules
+ * -------------------------------------------------------------------------- */
+
+.darktip-tooltip-google .headline {
+ font-size: 14px;
+ font-weight: bold;
+ border-bottom: 1px solid #444;
+ margin-bottom: 5px;
+ padding-bottom: 3px;
+}
+
+.darktip-tooltip-google .headline-right {
+ float: right;
+ font-size: 13px;
+ padding-left: 10px;
+}
+
+.darktip-tooltip-google .realname {
+ color: #999;
+}
+
+.darktip-tooltip-google .username {
+ color: #ddf;
+}
+
+.darktip-tooltip-google label {
+ color: #db9;
+}
+
+.darktip-tooltip-google .bio {
+ font-style: italic;
+ color: #999;
+}
+
View
@@ -0,0 +1,41 @@
+DarkTip.registerModule('google', {
+
+ 'apikey': '',
+
+ 'triggers': {
+ 'apiParams': {
+ 'callback': 'callback'
+ }
+ },
+
+ 'layout': {
+ 'css': {
+ 'class': 'darktip-tooltip-google'
+ }
+ },
+
+ 'prepareData': function(state) {
+ if(Object.keys(state['data']).length === 0) {
+ return false;
+ }
+ return state['data'];
+ },
+
+ 'enhanceData': function(module, params, data) {
+ var add = {
+ '_meta': {
+ 'module': module
+ }
+ };
+ DarkTip.jq.extend(true, data, add);
+ return data;
+ },
+
+ 'i18n': {
+ 'en_US': {
+ 'loading' : 'Loading data from Google...',
+ 'not-found': 'Google data not found',
+ }
+ }
+
+});
View
@@ -0,0 +1,30 @@
+DarkTip.registerModule('google.plus', {
+
+ 'prepareData': function(state) {
+ if(Object.keys(state['data']).length === 0) {
+ return false;
+ }
+ return state['data'];
+ },
+
+ 'enhanceData': function(module, params, data) {
+ var add = {
+ '_meta': {
+ 'module': module
+ }
+ };
+ DarkTip.jq.extend(true, data, add);
+ return data;
+ },
+
+ 'i18n': {
+ 'en_US': {
+ 'loading' : 'Loading data from Google+ ...',
+ 'not-found': 'Google+ data not found',
+ 'label' : {
+ 'userid': 'User ID:'
+ }
+ }
+ }
+
+});
@@ -0,0 +1,94 @@
+DarkTip.registerModule('google.plus.user', {
+
+ 'triggers': {
+ 'explicit': {
+ 'match' : /^g\+user:(.+)$/i,
+ 'params': {
+ '1': 'userid'
+ }
+ },
+ 'implicit': {
+ 'match' : /^(https:\/\/)?plus.google.com\/u\/[0-9]+\/([0-9]+)([^0-9]?.*)$/i,
+ 'params': {
+ '2': 'userid'
+ }
+ },
+ },
+
+ 'queries': {
+ 'user': {
+ 'required' : true,
+ 'condition': true,
+ 'call' : 'https://www.googleapis.com/plus/v1/people/<%= this["userid"] %>?key=<%= this["apikey"] %>'
+ }
+ },
+
+ 'getParams': {
+ 'explicit': function(result) {
+ var params = DarkTip.mapRegex(result, DarkTip._read(DarkTip.route('google.plus.user', 'triggers.explicit.params')));
+ params['apikey'] = DarkTip._read(DarkTip.route('google', 'apikey'));
+ return params;
+ },
+ 'implicit': function(result) {
+ var params = DarkTip.mapRegex(result, DarkTip._read(DarkTip.route('google.plus.user', 'triggers.implicit.params')));
+ params['apikey'] = DarkTip._read(DarkTip.route('google', 'apikey'));
+ return params;
+ }
+ },
+
+ 'prepareData': function(state) {
+ console.log(['prepareData'], state);
+ if(Object.keys(state['data']).length === 0)
+ {
+ return false;
+ }
+ if(typeof state['data']['user'] === 'undefined')
+ {
+ return false;
+ }
+ if(typeof state['data']['user']['error'] !== 'undefined')
+ {
+ return false;
+ }
+
+ return state['data'];
+ },
+
+ 'enhanceData': function(module, params, data) {
+ var add = {
+ '_meta': {
+ 'module': module
+ }
+ };
+ DarkTip.jq.extend(true, data, add);
+ return data;
+ },
+
+ 'layout': {
+ 'width': {
+ 'core': 350
+ }
+ },
+
+ 'templates': {
+ 'core':(
+ '<div class="tooltip-gplus-user">' +
+ 'G+ User found! :)' +
+ '</div>'
+ ),
+ '404':(
+ '<div class="tooltip-gplus-user tooltip-404">' +
+ '<div class="title">404<span class="sub"> / <%= this._loc("not-found") %></span></div>' +
+ '<div class="darktip-row"><span class="label"><%= this._loc("label.userid") %></span> <span class="value"><%= this["userid"] %></span></div>' +
+ '</div>'
+ )
+ },
+
+ 'i18n': {
+ 'en_US': {
+ 'loading' : 'Loading Google+ user ...',
+ 'not-found': 'Google+ user not found',
+ }
+ }
+
+});
View
@@ -8,9 +8,9 @@ DarkTip.registerModule('youtube.video', {
}
},
'implicit': {
- 'match' : /^http:\/\/www\.youtube\.com\/(v\/|watch\?v=)([A-Za-z0-9\-_]+).*$/i,
+ 'match' : /^(http:\/\/)?www\.youtube\.com\/(v\/|watch\?v=)([A-Za-z0-9\-_]+).*$/i,
'params': {
- '2': 'videoid'
+ '3': 'videoid'
}
}
},
Oops, something went wrong.

0 comments on commit b35a5a9

Please sign in to comment.