Skip to content

Commit

Permalink
Work on the UI to show what episodes have been requested #254
Browse files Browse the repository at this point in the history
  • Loading branch information
tidusjar committed Aug 2, 2016
1 parent a5cbd5d commit 0657264
Show file tree
Hide file tree
Showing 26 changed files with 8,438 additions and 15 deletions.
3 changes: 3 additions & 0 deletions PlexRequests.UI/Content/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -333,3 +333,6 @@ label {
margin-top: 0 !important;
margin-bottom: 0 !important; }

.tooltip_templates {
display: none; }

2 changes: 1 addition & 1 deletion PlexRequests.UI/Content/base.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion PlexRequests.UI/Content/base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -419,4 +419,5 @@ $border-radius: 10px;
.checkbox-custom{
margin-top:0 $i;
margin-bottom:0 $i;
}
}
.tooltip_templates { display: none; }
20 changes: 19 additions & 1 deletion PlexRequests.UI/Content/requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -574,10 +574,29 @@ function tvLoad() {
var url = createBaseUrl(base, '/requests/tvshows');
$.ajax(url).success(function (results) {
if (results.length > 0) {
var tvObject = new Array();
results.forEach(function (result) {
var ep = result.episodes;
ep.forEach(function (episode, index) {
if (!tvObject.find(x => x.seasonNumber === episode.seasonNumber)) {
var obj = { seasonNumber: episode.seasonNumber, episodes: [] }
tvObject.push(obj);
tvObject[index].episodes.push(episode.episodeNumber);
} else {
var selectedObj =tvObject.find(x => x.seasonNumber === episode.seasonNumber);
selectedObj.episodes.push(episode.episodeNumber);
}
});

var context = buildRequestContext(result, "tv");
context.episodes = tvObject;
var html = searchTemplate(context);
$tvl.append(html);

});

$('.customTooltip').tooltipster({
contentCloning: true
});
}
else {
Expand Down Expand Up @@ -638,7 +657,6 @@ function buildRequestContext(result, type) {
hasQualities: result.qualities && result.qualities.length > 0,
artist: result.artistName,
musicBrainzId: result.musicBrainzId,
episodes : result.episodes
};

return context;
Expand Down
4 changes: 4 additions & 0 deletions PlexRequests.UI/Content/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
return s;
}

$(function() {
$('[data-toggle="tooltip"]').tooltip();
});

var mainBaseUrl = $('#baseUrl').text();

function Humanize(date) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module unless amdModuleId is set
define(["tooltipster"], function (a0) {
return (factory(a0));
});
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory(require("tooltipster"));
} else {
factory(jQuery);
}
}(this, function ($) {

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module unless amdModuleId is set
define(["jquery"], function (a0) {
return (factory(a0));
});
} else if (typeof exports === 'object') {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = factory(require("jquery"));
} else {
factory(jQuery);
}
}(this, function ($) {

var pluginName = 'tooltipster.SVG';

$.tooltipster._plugin({
name: pluginName,
core: {
__init: function() {

$.tooltipster._on('init', function(event) {

var win = $.tooltipster._env.window;

if ( win.SVGElement
&& event.origin instanceof win.SVGElement
) {

// auto-activation of the plugin on the instance
event.instance._plug(pluginName);
}
});
}
},
instance: {
__init: function(instance) {

var self = this;

//list of instance variables
self.__hadTitleTag = false;
self.__instance = instance;

// jQuery < v3.0's addClass and hasClass do not work on SVG elements.
// However, $('.tooltipstered') does find elements having the class.
if (!self.__instance._$origin.hasClass('tooltipstered')) {

var c = self.__instance._$origin.attr('class') || '';

if (c.indexOf('tooltipstered') == -1) {
self.__instance._$origin.attr('class', c + ' tooltipstered');
}
}

// if there is no content yet, let's look for a <title> child element
if (self.__instance.content() === null) {

// TODO: when there are several <title> tags (not supported in
// today's browsers yet though, still an RFC draft), pick the right
// one based on its "lang" attribute
var $title = self.__instance._$origin.find('>title');

if ($title[0]) {

var title = $title.text();

self.__hadTitleTag = true;
self.__instance._$origin.data('tooltipster-initialTitle', title);
self.__instance.content(title);

$title.remove();
}
}

// rectify the geometry if SVG.js and its screenBBox plugin have been included
self.__instance
._on('geometry.'+ self.namespace, function(event) {

var win = $.tooltipster._env.window;

// SVG coordinates may need fixing but we need svg.screenbox.js
// to provide it. SVGElement is IE8+
if (win.SVG.svgjs) {

if (!win.SVG.parser) {
win.SVG.prepare();
}

var svgEl = win.SVG.adopt(event.origin);

// not all figures need (and have) screenBBox
if (svgEl && svgEl.screenBBox) {

var bbox = svgEl.screenBBox();

event.edit({
height: bbox.height,
left: bbox.x,
top: bbox.y,
width: bbox.width
});
}
}
})
// if jQuery < v3.0, we have to remove the class ourselves
._on('destroy.'+ self.namespace, function() {
self.__destroy();
});
},

__destroy: function() {

var self = this;

if (!self.__instance._$origin.hasClass('tooltipstered')) {
var c = self.__instance._$origin.attr('class').replace('tooltipstered', '');
self.__instance._$origin.attr('class', c);
}

self.__instance._off('.'+ self.namespace);

// if the content was provided as a title tag, we may need to restore it
if (self.__hadTitleTag) {

// this must happen after Tooltipster restored (or not) the title attr
self.__instance.one('destroyed', function() {

// if a title attribute was restored, we just need to replace it with a tag
var title = self.__instance._$origin.attr('title');

if (title) {

// must be namespaced to work
$(document.createElementNS('http://www.w3.org/2000/svg', 'title'))
.text(title)
.appendTo(self.__instance._$origin);

self.__instance._$origin.removeAttr('title');
}
});
}
}
}
});

/* a build task will add "return $;" here */
return $;

}));


}));
Loading

0 comments on commit 0657264

Please sign in to comment.