diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index f8436a9d6..6e81c4cf7 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -202,7 +202,8 @@ <Content Include="Scripts\2010.2.825\telerik.textbox.min.js" /> <Content Include="Scripts\2010.2.825\telerik.treeview.min.js" /> <Content Include="Scripts\2010.2.825\telerik.window.min.js" /> - <Content Include="Scripts\jquery.msg.js" /> + <Content Include="Scripts\jquery.notify.js" /> + <Content Include="Scripts\jquery.notify.min.js" /> <Content Include="Scripts\Notifications.js" /> <Content Include="Views\Series\Details.aspx" /> <Content Include="Views\Series\index.aspx" /> diff --git a/NzbDrone.Web/Scripts/Notifications.js b/NzbDrone.Web/Scripts/Notifications.js index 6da5a0f1d..64e2ac190 100644 --- a/NzbDrone.Web/Scripts/Notifications.js +++ b/NzbDrone.Web/Scripts/Notifications.js @@ -1,12 +1,5 @@ /// <reference path="jquery-1.4.1-vsdoc.js" /> $(function () { - alert("Notification"); - - var container = $("#container-bottom").notify({ stack: 'above' }); - container.notify("create", { - title: 'Look ma, two containers!', - text: 'This container is positioned on the bottom of the screen. Notifications will stack on top of each other with the <code>position</code> attribute set to <code>above</code>.' - }, { expires: false }); - + }); \ No newline at end of file diff --git a/NzbDrone.Web/Scripts/jquery.msg.js b/NzbDrone.Web/Scripts/jquery.msg.js deleted file mode 100644 index 419ca26c2..000000000 --- a/NzbDrone.Web/Scripts/jquery.msg.js +++ /dev/null @@ -1,97 +0,0 @@ -/* -Copyright (c) 2010 Diego Uría Martínez - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -/** - * Add a message to the body. - * - * Example: - * $('a').click(function() { - * $.fn.jQueryMsg({ - * msg: 'Hello world!!' - * }); - * }); - * - * TODO: - * - don't set 'speed' too high, it may loose some events - * - option: message tag - * - option: content tag - */ -(function($,undefined){ - var name = 'jQueryMsg'; - var timeout; - - $.fn.jQueryMsg = function(params) - { - var settings = $.extend( - {}, - { - msgClass : 'jquerymsgclass', //container class - speed : 0, //effects' speed - delay: 100, //delay between messages - timeout: 3000, //maximum time the message is shown on the screen. 0 for permanent - fx: 'none' //effect: set it to none, fade or slide - }, - params); - - if(typeof(settings.msg) === 'string') - { - var show = {width: 'show', height: 'show'}; - var hide = {width: 'hide', height: 'hide'}; - switch(settings.fx) { - case 'fade': - show = {opacity: 'show'}; - hide = {opacity: 'hide'}; - break; - case 'slide': - show = {height: 'show'}; - hide = {height: 'hide'}; - break; - } - - var msg; - if($('p.'+name).size() > 0) { - msg = $('p.'+name); - msg.click().delay(settings.delay); - } - else { - msg = $('<p class="'+name+'"></p>'); - msg.hide().appendTo('body'); - } - - clearTimeout(timeout); - - msg.one('click',function() { - msg.animate(hide, settings.speed, function() { - msg.removeClass().addClass(name); - }); - }).queue(function() { - msg.html(settings.msg).addClass(settings.msgClass).animate(show, settings.speed).dequeue(); - - if(settings.timeout > 0) { - timeout = setTimeout(function() { - msg.click(); - }, settings.timeout); - } - }); - } - } -})(jQuery); \ No newline at end of file diff --git a/NzbDrone.Web/Scripts/jquery.notify.js b/NzbDrone.Web/Scripts/jquery.notify.js new file mode 100644 index 000000000..c2c4657f4 --- /dev/null +++ b/NzbDrone.Web/Scripts/jquery.notify.js @@ -0,0 +1,140 @@ +/* + * jQuery Notify UI Widget 1.4 + * Copyright (c) 2010 Eric Hynds + * + * http://www.erichynds.com/jquery/a-jquery-ui-growl-ubuntu-notification-widget/ + * + * Depends: + * - jQuery 1.4 + * - jQuery UI 1.8 widget factory + * + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * +*/ +(function($){ + +$.widget("ech.notify", { + options: { + speed: 500, + expires: 5000, + stack: 'below', + custom: false + }, + _create: function(){ + var self = this; + this.templates = {}; + this.keys = []; + + // build and save templates + this.element.addClass("ui-notify").children().addClass("ui-notify-message ui-notify-message-style").each(function(i){ + var key = this.id || i; + self.keys.push(key); + self.templates[key] = $(this).removeAttr("id").wrap("<div></div>").parent().html(); // because $(this).andSelf().html() no workie + }).end().empty().show(); + }, + create: function(template, msg, opts){ + if(typeof template === "object"){ + opts = msg; + msg = template; + template = null; + } + + var tpl = this.templates[ template || this.keys[0]]; + + // remove default styling class if rolling w/ custom classes + if(opts && opts.custom){ + tpl = $(tpl).removeClass("ui-notify-message-style").wrap("<div></div>").parent().html(); + } + + // return a new notification instance + return new $.ech.notify.instance(this)._create(msg, $.extend({}, this.options, opts), tpl); + } +}); + +// instance constructor +$.extend($.ech.notify, { + instance: function(widget){ + this.parent = widget; + this.isOpen = false; + } +}); + +// instance methods +$.extend($.ech.notify.instance.prototype, { + _create: function(params, options, template){ + this.options = options; + + var self = this, + + // build html template + html = template.replace(/#(?:\{|%7B)(.*?)(?:\}|%7D)/g, function($1, $2){ + return ($2 in params) ? params[$2] : ''; + }), + + // the actual message + m = (this.element = $(html)), + + // close link + closelink = m.find(".ui-notify-close"); + + // clickable? + if(typeof this.options.click === "function"){ + m.addClass("ui-notify-click").bind("click", function(e){ + self._trigger("click", e, self); + }); + } + + // show close link? + if(closelink.length){ + closelink.bind("click", function(){ + self.close(); + return false; + }); + } + + this.open(); + + // auto expire? + if(typeof options.expires === "number"){ + window.setTimeout(function(){ + self.close(); + }, options.expires); + } + + return this; + }, + close: function(){ + var self = this, speed = this.options.speed; + + this.element.fadeTo(speed, 0).slideUp(speed, function(){ + self._trigger("close"); + self.isOpen = false; + }); + + return this; + }, + open: function(){ + if(this.isOpen || this._trigger("beforeopen") === false){ + return this; + } + + var self = this; + + this.element[this.options.stack === 'above' ? 'prependTo' : 'appendTo'](this.parent.element).css({ display:"none", opacity:"" }).fadeIn(this.options.speed, function(){ + self._trigger("open"); + self.isOpen = true; + }); + + return this; + }, + widget: function(){ + return this.element; + }, + _trigger: function(type, e, instance){ + return this.parent._trigger.call( this, type, e, instance ); + } +}); + +})(jQuery); diff --git a/NzbDrone.Web/Scripts/jquery.notify.min.js b/NzbDrone.Web/Scripts/jquery.notify.min.js new file mode 100644 index 000000000..402bf1e8b --- /dev/null +++ b/NzbDrone.Web/Scripts/jquery.notify.min.js @@ -0,0 +1,16 @@ +/* + * jQuery Notify UI Widget 1.4 + * Copyright (c) 2010 Eric Hynds + * + * http://www.erichynds.com/jquery/a-jquery-ui-growl-ubuntu-notification-widget/ + * + * Depends: + * - jQuery 1.4 + * - jQuery UI 1.8 widget factory + * + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * +*/ +(function(d){d.widget("ech.notify",{options:{speed:500,expires:5E3,stack:"below",custom:false},_create:function(){var a=this;this.templates={};this.keys=[];this.element.addClass("ui-notify").children().addClass("ui-notify-message ui-notify-message-style").each(function(b){b=this.id||b;a.keys.push(b);a.templates[b]=d(this).removeAttr("id").wrap("<div></div>").parent().html()}).end().empty().show()},create:function(a,b,c){if(typeof a==="object"){c=b;b=a;a=null}a=this.templates[a||this.keys[0]];if(c&&c.custom)a=d(a).removeClass("ui-notify-message-style").wrap("<div></div>").parent().html();return(new d.ech.notify.instance(this))._create(b,d.extend({},this.options,c),a)}});d.extend(d.ech.notify,{instance:function(a){this.parent=a;this.isOpen=false}});d.extend(d.ech.notify.instance.prototype,{_create:function(a,b,c){this.options=b;var e=this;c=c.replace(/#(?:\{|%7B)(.*?)(?:\}|%7D)/g,function(f,g){return g in a?a[g]:""});c=this.element=d(c);var h=c.find(".ui-notify-close");typeof this.options.click==="function"&&c.addClass("ui-notify-click").bind("click",function(f){e._trigger("click",f,e)});h.length&&h.bind("click",function(){e.close();return false});this.open();typeof b.expires==="number"&&window.setTimeout(function(){e.close()},b.expires);return this},close:function(){var a=this,b=this.options.speed;this.isOpen=false;this.element.fadeTo(b,0).slideUp(b,function(){a._trigger("close")});return this},open:function(){if(this.isOpen||this._trigger("beforeopen")===false)return this;var a=this;this.isOpen=true;this.element[this.options.stack==="above"?"prependTo":"appendTo"](this.parent.element).css({display:"none",opacity:""}).fadeIn(this.options.speed,function(){a._trigger("open")});return this},widget:function(){return this.element},_trigger:function(a,b,c){return this.parent._trigger.call(this,a,b,c)}})})(jQuery); diff --git a/NzbDrone.Web/Views/Series/index.aspx b/NzbDrone.Web/Views/Series/index.aspx index b027aa228..cfd4d86bd 100644 --- a/NzbDrone.Web/Views/Series/index.aspx +++ b/NzbDrone.Web/Views/Series/index.aspx @@ -2,45 +2,6 @@ <%@ Import Namespace="Telerik.Web.Mvc.UI" %> -<asp:Content ID="Content3" ContentPlaceHolderID="JavascriptContent" runat="server"> - $(document).ready(function () { - $("#Mediabox").bind("click", MediaBoxClick); - setTimeout('MediaDetect();', 5000); - }); - var Discovered = false; - - function MediaDetect() { - $.ajax({ - url: 'Series/MediaDetect', - success: MediaDetectCallback - }); - - } - function MediaDetectCallback(data) { - Discovered=data.Discovered; - if(!Discovered) - setTimeout('MediaDetect();', 10000); - else - LightUpMedia(data); - } - - function LightUpMedia(data) { - $.ajax({ - url: 'Series/LightUpMedia', - success: LightUpMediaSuccess - }); - } - function LightUpMediaSuccess(data) { - $("#Mediabox").html(data.HTML); - } - function MediaBoxClick(args) { - $.ajax({ - url: 'Series/ControlMedia', - data: "Action=" + args.target.className - }); - } -</asp:Content> - <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> Series diff --git a/NzbDrone.Web/Views/Shared/Site.Master b/NzbDrone.Web/Views/Shared/Site.Master index d86d6cb71..ea4050783 100644 --- a/NzbDrone.Web/Views/Shared/Site.Master +++ b/NzbDrone.Web/Views/Shared/Site.Master @@ -22,12 +22,46 @@ Released : 20100727 Html.Telerik().StyleSheetRegistrar().DefaultGroup(group => group.Add("telerik.common.css").Add("telerik.sitefinity.css")).Render(); %> <link href="../../Content/ui.notify.css" rel="stylesheet" type="text/css" /> - <script src="../../Scripts/jquery.msg.js" type="text/javascript"></script> <link href="../../Content/style.css" rel="stylesheet" type="text/css" media="screen" /> - <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> + <link type="text/css" rel="stylesheet" href="http://www.erichynds.com/examples/style.css" /> + <link type="text/css" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/redmond/jquery-ui.css" /> + <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js" type="text/javascript"></script> + <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.js" type="text/javascript"></script> + <script src="../../Scripts/jquery.notify.min.js" type="text/javascript"></script> <script src="../../Scripts/Notifications.js" type="text/javascript"></script> <script type="text/javascript"> - <asp:ContentPlaceHolder ID="JavascriptContent" runat="server" /> + + + function create(template, vars, opts) { + return $container.notify("create", template, vars, opts); + } + + + + $(function () { + + // initialize widget on a container, passing in all the defaults. + // the defaults will apply to any notification created within this + // container, but can be overwritten on notification-by-notification + // basis. + $container = $("#konfused").notify(); + + + // create two when the pg loads + var tttt = create("default", { title: '*********Default Notification', text: 'Example of a default notification. I will fade out after 5 seconds' }); + create("sticky", { title: 'Sticky Notification', text: 'Example of a "sticky" notification. Click on the X above to close me.' }, { expires: false }); + + // second + var container = $("#container-bottom").notify({ stack: 'above' }); + container.notify("create", { + title: 'Look ma, two containers!', + text: 'This container is positioned on the bottom of the screen. Notifications will stack on top of each other with the <code>position</code> attribute set to <code>above</code>.' + }, { expires: false }); + + container.notify("widget").find("input").bind("click", function () { + container.notify("create", 1, { title: 'Another Notification!', text: 'The quick brown fox jumped over the lazy dog.' }); + }); + }); </script> </head> <body> @@ -58,8 +92,55 @@ Released : 20100727 </div> </div> </div> - <div id="container-bottom" style="display: none; top: auto; right: 0; padding: 10px; - bottom: 0; margin: 0 0 10px 10px"> + <div id="konfused" style="display: none"> + <div id="default"> + <h1> + #{title}</h1> + <h2> + <div class="defText"> + #{text} + </div> + </h2> + </div> + <div id="sticky"> + <h1> + #{title}</h1> + <p> + #{text}</p> + </div> + <div id="themeroller" class="ui-state-error" style="padding: 10px; -moz-box-shadow: 0 0 6px #980000; + -webkit-box-shadow: 0 0 6px #980000; box-shadow: 0 0 6px #980000;"> + <a class="ui-notify-close" href="#"><span class="ui-icon ui-icon-close" style="float: right"> + </span></a><span style="float: left; margin: 0 5px 0 0;" class="ui-icon ui-icon-alert"> + </span> + <h1> + #{title}</h1> + <p> + #{text}</p> + <p style="text-align: center"> + <a class="ui-notify-close" href="#">Close Me</a></p> + </div> + <div id="withIcon"> + <a class="ui-notify-close ui-notify-cross" href="#">x</a> + <div style="float: left; margin: 0 10px 0 0"> + <img src="#{icon}" alt="warning" /></div> + <h1> + #{title}</h1> + <p> + #{text}</p> + </div> + <div id="buttons"> + <h1> + #{title}</h1> + <p> + #{text}</p> + <p style="margin-top: 10px; text-align: center"> + <input type="button" class="confirm" value="Close Dialog" /> + </p> + </div> + </div> + <div id="container-bottom" style="top: auto; right: 0; padding: 10px; bottom: 0; + margin: 0 0 10px 10px"> <div> <h1> #{title}</h1>