From: Jordan Augé <jordan.auge@lip6.fr> Date: Tue, 9 Jul 2013 23:17:44 +0000 (+0200) Subject: added messaging thanks to jquery-notify X-Git-Tag: myslice-0.2-1~99 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=07411e389a9d39ddccfd93cd53ac895393a8ae3a;p=unfold.git added messaging thanks to jquery-notify --- diff --git a/Makefile b/Makefile index 7752b109..74438a43 100644 --- a/Makefile +++ b/Makefile @@ -85,6 +85,10 @@ THIRD-PARTY-RESOURCES += $(shell ls third-party/syntaxhighlighter/styles/shTheme THIRD-PARTY-RESOURCES += $(shell ls third-party/smartwizard-1636c86/js/jquery.smartWizard-2.0.js) #THIRD-PARTY-RESOURCES += $(shell ls third-party/smartwizard-1636c86/js/jquery.smartWizard-2.0.min.js) THIRD-PARTY-RESOURCES += $(shell ls third-party/smartwizard-1636c86/styles/smart_wizard.css) +# jquery.notify +THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery-notify/jquery.notify.js) +THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery-notify/jquery.notify.min.js) +THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery-notify/ui.notify.css) thirdparty-js: diff --git a/manifold/js/manifold.js b/manifold/js/manifold.js index 221986df..c3aac9fb 100644 --- a/manifold/js/manifold.js +++ b/manifold/js/manifold.js @@ -29,9 +29,12 @@ var CLEAR_FIELDS = 6; var NEW_RECORD = 7; var CLEAR_RECORDS = 8; -var IN_PROGRESS = 101; +var IN_PROGRESS = 101; var DONE = 102; +var SET_ADD = 201; +var SET_REMOVED = 202; + /*! * This namespace holds functions for globally managing query objects * \Class Manifold @@ -122,7 +125,7 @@ var manifold = { } query.iter_subqueries(function (sq) { - $('.plugin').trigger(manifold.get_record_channel(sq.query_uuid), [IN_PROGRESS]); + manifold.raise_record_event(sq.query_uuid, IN_PROGRESS); }); // not quite sure what happens if we send a string directly, as POST data is named.. @@ -157,6 +160,34 @@ var manifold = { return true; }, + raise_event_handler: function(type, query_uuid, event_type, value) + { + if (type == 'query') { + var channels = [ manifold.get_query_channel(query_uuid), manifold.get_query_channel('*') ]; + } else if (type == 'record') { + var channels = [ manifold.get_record_channel(query_uuid), manifold.get_record_channel('*') ]; + + } else { + throw 'Incorrect type for manifold.raise_event()'; + } + $.each(channels, function(i, channel) { + if (value === undefined) + $('.plugin').trigger(channel, [event_type]); + else + $('.plugin').trigger(channel, [event_type, value]); + }); + }, + + raise_query_event: function(query_uuid, event_type, value) + { + manifold.raise_event_handler('query', query_uuid, event_type, value); + }, + + raise_record_event: function(query_uuid, event_type, value) + { + manifold.raise_event_handler('record', query_uuid, event_type, value); + }, + /*! * Publish result * \fn publish_result(query, results) @@ -169,12 +200,11 @@ var manifold = { result = []; // NEW PLUGIN API - var channel = manifold.get_record_channel(query.query_uuid); - $('.plugin').trigger(channel, [CLEAR_RECORDS]); + manifold.raise_record_event(query.query_uuid, CLEAR_RECORDS); $.each(result, function(i, record) { - $('.plugin').trigger(channel, [NEW_RECORD, record]); + manifold.raise_record_event(query.query_uuid, NEW_RECORD, record); }); - $('.plugin').trigger(channel, [DONE]); + manifold.raise_record_event(query.query_uuid, DONE); // OLD PLUGIN API BELOW /* Publish an update announce */ @@ -247,6 +277,18 @@ var manifold = { } }, + raise_event: function(uuid, event_type, value) + { + switch(event_type) { + case SET_ADD: + // Query uuid has been updated with the key of a new element + break; + case SET_REMOVED: + // Query uuid has been updated with the key of a removed element + break; + } + }, + /* Publish/subscribe channels for internal use */ get_query_channel: function(uuid) { return '/query/' + uuid }, get_record_channel: function(uuid) { return '/record/' + uuid }, diff --git a/manifold/manifoldapi.py b/manifold/manifoldapi.py index cc38ba74..d2a4a512 100644 --- a/manifold/manifoldapi.py +++ b/manifold/manifoldapi.py @@ -58,6 +58,7 @@ class ManifoldAPI: return ManifoldResult(code=result['code'], value=result['value']) else: if debug: print "KO (new API) - raising ManifoldException" + print "RESULT=", result raise ManifoldException(ManifoldResult(code=result['code'], output=result['description'])) else: if debug: print "taken as old API" diff --git a/manifold/manifoldproxy.py b/manifold/manifoldproxy.py index fd4c5ad9..a8bec589 100644 --- a/manifold/manifoldproxy.py +++ b/manifold/manifoldproxy.py @@ -87,6 +87,7 @@ with the query passed using POST""" try: answer=manifold_api.send_manifold_query (manifold_query) except ManifoldException, manifold_result: + print "MANIFOLD EXCEPTION" answer=manifold_result print "="*80 print "ANSWER IN PROXY", answer diff --git a/plugins/hazelnut/hazelnut.js b/plugins/hazelnut/hazelnut.js index e63baccd..84be66ed 100644 --- a/plugins/hazelnut/hazelnut.js +++ b/plugins/hazelnut/hazelnut.js @@ -178,78 +178,78 @@ /* methods */ - this.set_query = function(query) { - messages.info('hazelnut.set_query'); - var options = this.options; - /* Compare current and advertised query to get added and removed fields */ - previous_query = this.current_query; - /* Save the query as the current query */ - this.current_query = query; - if (debug) - messages.debug("hazelnut.set_query, current_query is now -> " + this.current_query); - - /* We check all necessary fields : in column editor I presume XXX */ - // XXX ID naming has no plugin_uuid - if (typeof(query.fields) != 'undefined') { - $.each (query.fields, function(index, value) { - if (!$('#hazelnut-checkbox-' + options.plugin_uuid + "-" + value).attr('checked')) - $('#hazelnut-checkbox-' + options.plugin_uuid + "-" + value).attr('checked', true); - }); - } - - /* Process updates in filters / current_query must be updated before this call for filtering ! */ - this.table.fnDraw(); - - /* - * Process updates in fields - */ - if (typeof(query.fields) != 'undefined') { - /* DataTable Settings */ - var oSettings = this.table.dataTable().fnSettings(); - var cols = oSettings.aoColumns; - var colnames = cols.map(function(x) {return x.sTitle}); - colnames = $.grep(colnames, function(value) {return value != "+/-";}); - - if (previous_query == null) { - var added_fields = query.fields; - var removed_fields = colnames; - removed_fields = $.grep(colnames, function(x) { return $.inArray(x, added_fields) == -1}); - } else { - var tmp = previous_query.diff_fields(query); - var added_fields = tmp.added; - var removed_fields = tmp.removed; - } - - /* Hide/unhide columns to match added/removed fields */ - var object = this; - $.each(added_fields, function (index, field) { - var index = object.getColIndex(field,cols); - if(index != -1) - object.table.fnSetColumnVis(index, true); - }); - $.each(removed_fields, function (index, field) { - var index = object.getColIndex(field,cols); - if(index != -1) - object.table.fnSetColumnVis(index, false); - }); - } - } - - this.set_resources = function(resources, instance) { - if (debug) - messages.debug("entering hazelnut.set_resources"); - var options = this.options; - var previous_resources = this.current_resources; - this.current_resources = resources; - - /* We uncheck all checkboxes ... */ - $('hazelnut-checkbox-' + options.plugin_uuid).attr('checked', false); - /* ... and check the ones specified in the resource list */ - $.each(this.current_resources, function(index, urn) { - $('#hazelnut-checkbox-' + options.plugin_uuid + "-" + urn).attr('checked', true) - }); - - } +// DEPRECATED // this.set_query = function(query) { +// DEPRECATED // messages.info('hazelnut.set_query'); +// DEPRECATED // var options = this.options; +// DEPRECATED // /* Compare current and advertised query to get added and removed fields */ +// DEPRECATED // previous_query = this.current_query; +// DEPRECATED // /* Save the query as the current query */ +// DEPRECATED // this.current_query = query; +// DEPRECATED // if (debug) +// DEPRECATED // messages.debug("hazelnut.set_query, current_query is now -> " + this.current_query); +// DEPRECATED // +// DEPRECATED // /* We check all necessary fields : in column editor I presume XXX */ +// DEPRECATED // // XXX ID naming has no plugin_uuid +// DEPRECATED // if (typeof(query.fields) != 'undefined') { +// DEPRECATED // $.each (query.fields, function(index, value) { +// DEPRECATED // if (!$('#hazelnut-checkbox-' + options.plugin_uuid + "-" + value).attr('checked')) +// DEPRECATED // $('#hazelnut-checkbox-' + options.plugin_uuid + "-" + value).attr('checked', true); +// DEPRECATED // }); +// DEPRECATED // } +// DEPRECATED // +// DEPRECATED // /* Process updates in filters / current_query must be updated before this call for filtering ! */ +// DEPRECATED // this.table.fnDraw(); +// DEPRECATED // +// DEPRECATED // /* +// DEPRECATED // * Process updates in fields +// DEPRECATED // */ +// DEPRECATED // if (typeof(query.fields) != 'undefined') { +// DEPRECATED // /* DataTable Settings */ +// DEPRECATED // var oSettings = this.table.dataTable().fnSettings(); +// DEPRECATED // var cols = oSettings.aoColumns; +// DEPRECATED // var colnames = cols.map(function(x) {return x.sTitle}); +// DEPRECATED // colnames = $.grep(colnames, function(value) {return value != "+/-";}); +// DEPRECATED // +// DEPRECATED // if (previous_query == null) { +// DEPRECATED // var added_fields = query.fields; +// DEPRECATED // var removed_fields = colnames; +// DEPRECATED // removed_fields = $.grep(colnames, function(x) { return $.inArray(x, added_fields) == -1}); +// DEPRECATED // } else { +// DEPRECATED // var tmp = previous_query.diff_fields(query); +// DEPRECATED // var added_fields = tmp.added; +// DEPRECATED // var removed_fields = tmp.removed; +// DEPRECATED // } +// DEPRECATED // +// DEPRECATED // /* Hide/unhide columns to match added/removed fields */ +// DEPRECATED // var object = this; +// DEPRECATED // $.each(added_fields, function (index, field) { +// DEPRECATED // var index = object.getColIndex(field,cols); +// DEPRECATED // if(index != -1) +// DEPRECATED // object.table.fnSetColumnVis(index, true); +// DEPRECATED // }); +// DEPRECATED // $.each(removed_fields, function (index, field) { +// DEPRECATED // var index = object.getColIndex(field,cols); +// DEPRECATED // if(index != -1) +// DEPRECATED // object.table.fnSetColumnVis(index, false); +// DEPRECATED // }); +// DEPRECATED // } +// DEPRECATED // } + +// DEPRECATED // this.set_resources = function(resources, instance) { +// DEPRECATED // if (debug) +// DEPRECATED // messages.debug("entering hazelnut.set_resources"); +// DEPRECATED // var options = this.options; +// DEPRECATED // var previous_resources = this.current_resources; +// DEPRECATED // this.current_resources = resources; +// DEPRECATED // +// DEPRECATED // /* We uncheck all checkboxes ... */ +// DEPRECATED // $('hazelnut-checkbox-' + options.plugin_uuid).attr('checked', false); +// DEPRECATED // /* ... and check the ones specified in the resource list */ +// DEPRECATED // $.each(this.current_resources, function(index, urn) { +// DEPRECATED // $('#hazelnut-checkbox-' + options.plugin_uuid + "-" + urn).attr('checked', true) +// DEPRECATED // }); +// DEPRECATED // +// DEPRECATED // } /** * @brief Determine index of key in the table columns @@ -261,30 +261,30 @@ return (tabIndex.length > 0) ? tabIndex[0] : -1; } - /** - * @brief - * XXX will be removed/replaced - */ - this.selected_changed = function(e, change) { - if (debug) messages.debug("entering hazelnut.selected_changed"); - var actions = change.split("/"); - if (actions.length > 1) { - var oNodes = this.table.fnGetNodes(); - var myNode = $.grep(oNodes, function(value) { - if (value.id == actions[1]) { return value; } - }); - if( myNode.length>0 ) { - if ((actions[2]=="add" && actions[0]=="cancel") || actions[0]=="del") - checked=''; - else - checked="checked='checked' "; - var newValue = this.checkbox(actions[1], 'node', checked, false); - var columnPos = this.table.fnSettings().aoColumns.length - 1; - this.table.fnUpdate(newValue, myNode[0], columnPos); - this.table.fnDraw(); - } - } - } +// DEPRECATED // /** +// DEPRECATED // * @brief +// DEPRECATED // * XXX will be removed/replaced +// DEPRECATED // */ +// DEPRECATED // this.selected_changed = function(e, change) { +// DEPRECATED // if (debug) messages.debug("entering hazelnut.selected_changed"); +// DEPRECATED // var actions = change.split("/"); +// DEPRECATED // if (actions.length > 1) { +// DEPRECATED // var oNodes = this.table.fnGetNodes(); +// DEPRECATED // var myNode = $.grep(oNodes, function(value) { +// DEPRECATED // if (value.id == actions[1]) { return value; } +// DEPRECATED // }); +// DEPRECATED // if( myNode.length>0 ) { +// DEPRECATED // if ((actions[2]=="add" && actions[0]=="cancel") || actions[0]=="del") +// DEPRECATED // checked=''; +// DEPRECATED // else +// DEPRECATED // checked="checked='checked' "; +// DEPRECATED // var newValue = this.checkbox(actions[1], 'node', checked, false); +// DEPRECATED // var columnPos = this.table.fnSettings().aoColumns.length - 1; +// DEPRECATED // this.table.fnUpdate(newValue, myNode[0], columnPos); +// DEPRECATED // this.table.fnDraw(); +// DEPRECATED // } +// DEPRECATED // } +// DEPRECATED // } this.update_plugin = function(e, rows) { // e.data is what we passed in second argument to subscribe @@ -604,8 +604,17 @@ } function check_click (e) { + var object = e.data.instance; - var value = this.value; + + /* The key of the object to be added */ + // XXX What about multiple keys ? + var value = this.value; + + // NEW PLUGIN API + manifold.raise_event(object.options.query_uuid, this.checked?SET_ADD:SET_REMOVED, value); + + // OLD PLUGIN API BELOW if (this.checked) { object.current_resources.push(value); diff --git a/portal/templates/dashboard.html b/portal/templates/dashboard.html new file mode 100644 index 00000000..14892f3b --- /dev/null +++ b/portal/templates/dashboard.html @@ -0,0 +1,43 @@ +{% extends "layout-unfold1.html" %} + +{% block head %} +<link rel="stylesheet" type="text/css" href="{{STATIC_URL}}/dashboard.css" /> +{% endblock %} + +{% block unfold1_main %} + +<div id='tophat_status'></div> +<div id='ms-dashboard'> + + <div class='ms-dashboard-panel' id="ms-dashboard-profile"> + <div class='ms-dashboard-caption'> + <h2>User profile</h2> + </div> + <div class='ms-dashboard-content'> + <ul> + <li><span id='username'>{{person.first_name}} {{person.last_name}}</span></li> + <li><b>Email: </b><a href='mailto:#'>{{person.email}}</a></li> + </ul> + </div> + </div> + + <div class='ms-dashboard-panel' id='ms-dashboard-testbeds'> + <div class='ms-dashboard-caption'> + <h2>Testbeds access</h2> + </div> + <div class='ms-dashboard-content' id='tophat__list__network_hrn__network_name'> + {{networks}} + </div> + </div> + + <div class='ms-dashboard-panel' id='ms-dashboard-slices'> + <div class='ms-dashboard-caption'> + <h2>Slices</h2> + </div> + <div class='ms-dashboard-content' id='tophat__list__slice_hrn__slice_hrn'> + {{slices}} + </div> + </div> +</div> + +{% endblock %} diff --git a/portal/views.py b/portal/views.py index f03befa9..815c16a1 100644 --- a/portal/views.py +++ b/portal/views.py @@ -22,6 +22,7 @@ from django.conf import settings from django.contrib.sites.models import Site, RequestSite +from django.contrib import messages from django.views.generic import View from django.views.generic.base import TemplateView from django.shortcuts import render @@ -40,6 +41,9 @@ class DashboardView(TemplateView): def get_context_data(self, **kwargs): user_hrn = 'ple.upmc.jordan_auge' + messages.info(self.request, 'You have logged in') + + page = Page(self.request) # Slow... diff --git a/third-party/jquery-notify/alert.png b/third-party/jquery-notify/alert.png new file mode 100644 index 00000000..d64c533f Binary files /dev/null and b/third-party/jquery-notify/alert.png differ diff --git a/third-party/jquery-notify/jquery.notify.js b/third-party/jquery-notify/jquery.notify.js new file mode 100644 index 00000000..dd1d7486 --- /dev/null +++ b/third-party/jquery-notify/jquery.notify.js @@ -0,0 +1,156 @@ +/* jQuery Notify UI Widget 1.5 by 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, + queue: 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(); + } + + this.openNotifications = this.openNotifications || 0; + + // 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.__super = 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.__super.element.queue("notify", function(){ + self.open(); + + // auto expire? + if(typeof options.expires === "number" && options.expires > 0){ + setTimeout($.proxy(self.close, self), options.expires); + } + }); + + if(!this.options.queue || this.__super.openNotifications <= this.options.queue - 1) { + this.__super.element.dequeue("notify"); + } + + return this; + }, + + close: function(){ + var speed = this.options.speed; + + this.element.fadeTo(speed, 0).slideUp(speed, $.proxy(function(){ + this._trigger("close"); + this.isOpen = false; + this.element.remove(); + this.__super.openNotifications -= 1; + this.__super.element.dequeue("notify"); + }, this)); + + return this; + }, + + open: function(){ + if(this.isOpen || this._trigger("beforeopen") === false){ + return this; + } + + var self = this; + + this.__super.openNotifications += 1; + + this.element[this.options.stack === "above" ? "prependTo" : "appendTo"](this.__super.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.__super._trigger.call( this, type, e, instance ); + } + }); + +})(jQuery); diff --git a/third-party/jquery-notify/jquery.notify.min.js b/third-party/jquery-notify/jquery.notify.min.js new file mode 100644 index 00000000..4a076e1b --- /dev/null +++ b/third-party/jquery-notify/jquery.notify.min.js @@ -0,0 +1,12 @@ +/* jQuery Notify UI Widget 1.5 by 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:!1,queue:!1},_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){"object"===typeof a&&(c=b,b=a,a=null);a=this.templates[a||this.keys[0]];c&&c.custom&&(a=d(a).removeClass("ui-notify-message-style").wrap("<div></div>").parent().html());this.openNotifications=this.openNotifications||0;return(new d.ech.notify.instance(this))._create(b,d.extend({},this.options,c),a)}});d.extend(d.ech.notify,{instance:function(a){this.__super=a;this.isOpen=!1}});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(b,c){return c in a?a[c]:""}),c=this.element=d(c),f=c.find(".ui-notify-close");"function"===typeof this.options.click&&c.addClass("ui-notify-click").bind("click",function(a){e._trigger("click",a,e)});f.length&&f.bind("click",function(){e.close();return!1});this.__super.element.queue("notify",function(){e.open();"number"===typeof b.expires&&0<b.expires&&setTimeout(d.proxy(e.close,e),b.expires)});(!this.options.queue||this.__super.openNotifications<=this.options.queue-1)&&this.__super.element.dequeue("notify");return this},close:function(){var a=this.options.speed;this.element.fadeTo(a,0).slideUp(a,d.proxy(function(){this._trigger("close");this.isOpen=!1;this.element.remove();this.__super.openNotifications-=1;this.__super.element.dequeue("notify")},this));return this},open:function(){if(this.isOpen||!1===this._trigger("beforeopen"))return this;var a=this;this.__super.openNotifications+=1;this.element["above"===this.options.stack?"prependTo":"appendTo"](this.__super.element).css({display:"none",opacity:""}).fadeIn(this.options.speed,function(){a._trigger("open");a.isOpen=!0});return this},widget:function(){return this.element},_trigger:function(a,b,c){return this.__super._trigger.call(this,a,b,c)}})})(jQuery); diff --git a/third-party/jquery-notify/style.css b/third-party/jquery-notify/style.css new file mode 100644 index 00000000..167ebb57 --- /dev/null +++ b/third-party/jquery-notify/style.css @@ -0,0 +1,21 @@ +html, body { margin:0; padding:0; font:12px Helvetica, Arial, sans-serif } +#content { padding:10px 30px; } +a { color:#477099; text-decoration:none } +a:hover { text-decoration:underline } + +#bar { background:#252823; padding:5px 10px; border-bottom:4px solid #C3D3DA } +#bar h1 { margin:0; padding:0; color:#fff; font-size:40px; letter-spacing:-1px; text-shadow:0 0 4px #000000 } +#bar h1 span { color:#C3D3DA } +#bar div { float:right; margin-top:-50px; padding:20px 20px 0 0 } +#bar a { color:#fff } + +.message { padding:10px; margin:15px 0; display:block; text-align:left; } +.message-title { font-weight:bold; font-size:1.25em; } +.message-body { margin-top:4px; } +.error, .notice, .success {padding:.8em;margin-bottom:1em;border:2px solid #ddd;} +.error {background:#FBE3E4;color:#8a1f11;border-color:#FBC2C4;} +.notice {background:#FFF6BF;color:#514721;border-color:#FFD324;} +.success {background:#E6EFC2;color:#264409;border-color:#C6D880;} +.error a {color:#8a1f11;} +.notice a {color:#514721;} +.success a {color:#264409;} diff --git a/third-party/jquery-notify/ui.notify.css b/third-party/jquery-notify/ui.notify.css new file mode 100644 index 00000000..845ab3e1 --- /dev/null +++ b/third-party/jquery-notify/ui.notify.css @@ -0,0 +1,14 @@ +.ui-notify { width:350px; position:fixed; top: 67px; right:10px; z-index: 999;} +/* .ui-notify { width:350px; position:fixed; top:10px; right:10px; } */ +.ui-notify-message { padding:10px; margin-bottom:15px; -moz-border-radius:8px; -webkit-border-radius:8px; border-radius:8px } +.ui-notify-message h1 { font-size:14px; margin:0; padding:0 } +.ui-notify-message p { margin:3px 0; padding:0; line-height:18px } +.ui-notify-message:last-child { margin-bottom:0 } +.ui-notify-message-style { background:#000; background:rgba(0,0,0,0.8); -moz-box-shadow: 0 0 6px #000; -webkit-box-shadow: 0 0 6px #000; box-shadow: 0 0 6px #000; } +.ui-notify-message-style h1 { color:#fff; font-weight:bold } +.ui-notify-message-style p { color:#fff } +.ui-notify-close { color:#fff; text-decoration:underline } +.ui-notify-click { cursor:pointer } +.ui-notify-cross { margin-top:-4px; float:right; cursor:pointer; text-decoration:none; font-size:12px; font-weight:bold; text-shadow:0 1px 1px #fff; padding:2px } +.ui-notify-cross:hover { color:#ffffab } +.ui-notify-cross:active { position:relative; top:1px } diff --git a/views/templates/layout-unfold1.html b/views/templates/layout-unfold1.html index 9633a298..ba1c01bd 100644 --- a/views/templates/layout-unfold1.html +++ b/views/templates/layout-unfold1.html @@ -3,6 +3,7 @@ <title> MySlice - {{ title }} </title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> {# This is where insert_str will end up #}{% media_container prelude %} +{% include 'messages-header.html' %} <script type="text/javascript"> {# raw js code - use {% insert prelude_js %} ... {% endinsert %} #} {% container prelude_js %}</script> <style type="text/css">{# In case we need to add raw css code #}{% container prelude_css %}</style> {{ header_prelude }} @@ -19,6 +20,7 @@ {% block topmenu %} {% include 'widget-topmenu.html' %} {% endblock topmenu %} +{% include 'messages.html' %} <div class="container-fluid"> <div class="row-fluid"> <div id="unfold1-main" class="span12 columns"> diff --git a/views/templates/messages-header.html b/views/templates/messages-header.html new file mode 100644 index 00000000..0c292e74 --- /dev/null +++ b/views/templates/messages-header.html @@ -0,0 +1,38 @@ +<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.js" type="text/javascript"></script> +<!-- <script type="text/javascript">{{ STATIC_URL }}js/ui.widget.js</script> --> +<script src="{{ STATIC_URL }}js/jquery.notify.js" type="text/javascript"></script> +<link rel='stylesheet' href='{{ STATIC_URL }}css/ui.notify.css' type='text/css' /> + +<script type="text/javascript"> +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 = $("#notifications").notify(); + + // create two when the pg loads + //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 }); + +{% if messages %} + $(document).ready(function(){ + {% for message in messages %} + $("#notifications").notify("create", { + title: 'Test Notification', + text: '{{ message }}' + },{ + expires: false, + speed: 1000 + }); + {% endfor %} + }); +{% endif %} + + +}); +</script> diff --git a/views/templates/messages.html b/views/templates/messages.html new file mode 100644 index 00000000..b6843361 --- /dev/null +++ b/views/templates/messages.html @@ -0,0 +1,38 @@ + <!--- container to hold notifications, and default templates ---> +<div id="notifications" style="display:none"> + + <div id="default"> + <h1>#{title}</h1> + <p>#{text}</p> + </div> + + <div id="sticky"> + <a class="ui-notify-close ui-notify-cross" href="#">x</a> + <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:2px 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>