Commit 08eec11a authored by Floréal Cabanettes's avatar Floréal Cabanettes

Add button new recipe with notification to QRecipeWriter

parent 23f56e74
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-11-12 21:59+0100\n"
"PO-Revision-Date: 2017-11-12 21:59+0100\n"
"POT-Creation-Date: 2017-11-12 22:26+0100\n"
"PO-Revision-Date: 2017-11-12 22:27+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: fr\n"
......@@ -351,6 +351,10 @@ msgstr "logiciel QRecipeWriter"
msgid "(available for Windows and Linux)"
msgstr "(disponible pour Windows et Linux)"
#: templates/panel/recipes.html:16
msgid "Add new"
msgstr "Ajouter une nouvelle"
#: templates/panel/recipes.html:26
msgctxt "filter-recipes"
msgid "All"
......
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-11-11 18:37+0100\n"
"PO-Revision-Date: 2017-11-11 18:37+0100\n"
"POT-Creation-Date: 2017-11-12 22:25+0100\n"
"PO-Revision-Date: 2017-11-12 22:26+0100\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: fr\n"
......@@ -22,10 +22,19 @@ msgstr ""
msgid "'"
msgstr ""
#: panel/static/js/panel.recipes.js:40
#: panel/static/js/panel.recipes.js:43
msgid ""
"To add a new recipe, please use the <b>QRecipeWriter software</b>!<br/"
">Available for Windows and Linux (click here to install)"
msgstr ""
"Pour ajouter une nouvelle recette, veuillez utiliser le <b>logiciel "
"QRecipeWriter</b> !<br/>Disponible pour Windows et Linux (cliquez ici "
"pour l'installer)"
#: panel/static/js/panel.recipes.js:60
msgid "Please select an action to do!"
msgstr "Veuillez sélectionner une action à effectuer !"
#: panel/static/js/panel.recipes.js:49
#: panel/static/js/panel.recipes.js:70
msgid "recipes"
msgstr "recettes"
This diff is collapsed.
......@@ -218,4 +218,10 @@ h2.subtitle-recipe {
div.subtitle-recipe {
margin-bottom: 30px;
}
input[type=button].add-new-recipe {
margin-left: 20px;
font-size: 15pt;
line-height: 30px;
}
\ No newline at end of file
/* Project: Bootstrap Growl = v3.1.3 | Description: Turns standard Bootstrap alerts into "Growl-like" notifications. | Author: Mouse0270 aka Robert McIntosh | License: MIT License | Website: https://github.com/mouse0270/bootstrap-growl */
!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t("object"==typeof exports?require("jquery"):jQuery)}(function(t){function e(e,i,n){var i={content:{message:"object"==typeof i?i.message:i,title:i.title?i.title:"",icon:i.icon?i.icon:"",url:i.url?i.url:"#",target:i.target?i.target:"-"}};n=t.extend(!0,{},i,n),this.settings=t.extend(!0,{},s,n),this._defaults=s,"-"==this.settings.content.target&&(this.settings.content.target=this.settings.url_target),this.animations={start:"webkitAnimationStart oanimationstart MSAnimationStart animationstart",end:"webkitAnimationEnd oanimationend MSAnimationEnd animationend"},"number"==typeof this.settings.offset&&(this.settings.offset={x:this.settings.offset,y:this.settings.offset}),this.init()}var s={element:"body",position:null,type:"info",allow_dismiss:!0,newest_on_top:!1,showProgressbar:!1,placement:{from:"top",align:"right"},offset:20,spacing:10,z_index:1031,delay:5e3,timer:1e3,url_target:"_blank",mouse_over:null,animate:{enter:"animated fadeInDown",exit:"animated fadeOutUp"},onShow:null,onShown:null,onClose:null,onClosed:null,icon_type:"class",template:'<div data-notify="container" class="col-xs-11 col-sm-4 alert alert-{0}" role="alert"><button type="button" aria-hidden="true" class="close" data-notify="dismiss">&times;</button><span data-notify="icon"></span> <span data-notify="title">{1}</span> <span data-notify="message">{2}</span><div class="progress" data-notify="progressbar"><div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div></div><a href="{3}" target="{4}" data-notify="url"></a></div>'};String.format=function(){for(var t=arguments[0],e=1;e<arguments.length;e++)t=t.replace(RegExp("\\{"+(e-1)+"\\}","gm"),arguments[e]);return t},t.extend(e.prototype,{init:function(){var t=this;this.buildNotify(),this.settings.content.icon&&this.setIcon(),"#"!=this.settings.content.url&&this.styleURL(),this.placement(),this.bind(),this.notify={$ele:this.$ele,update:function(e,s){var i={};"string"==typeof e?i[e]=s:i=e;for(var e in i)switch(e){case"type":this.$ele.removeClass("alert-"+t.settings.type),this.$ele.find('[data-notify="progressbar"] > .progress-bar').removeClass("progress-bar-"+t.settings.type),t.settings.type=i[e],this.$ele.addClass("alert-"+i[e]).find('[data-notify="progressbar"] > .progress-bar').addClass("progress-bar-"+i[e]);break;case"icon":var n=this.$ele.find('[data-notify="icon"]');"class"==t.settings.icon_type.toLowerCase()?n.removeClass(t.settings.content.icon).addClass(i[e]):(n.is("img")||n.find("img"),n.attr("src",i[e]));break;case"progress":var a=t.settings.delay-t.settings.delay*(i[e]/100);this.$ele.data("notify-delay",a),this.$ele.find('[data-notify="progressbar"] > div').attr("aria-valuenow",i[e]).css("width",i[e]+"%");break;case"url":this.$ele.find('[data-notify="url"]').attr("href",i[e]);break;case"target":this.$ele.find('[data-notify="url"]').attr("target",i[e]);break;default:this.$ele.find('[data-notify="'+e+'"]').html(i[e])}var o=this.$ele.outerHeight()+parseInt(t.settings.spacing)+parseInt(t.settings.offset.y);t.reposition(o)},close:function(){t.close()}}},buildNotify:function(){var e=this.settings.content;this.$ele=t(String.format(this.settings.template,this.settings.type,e.title,e.message,e.url,e.target)),this.$ele.attr("data-notify-position",this.settings.placement.from+"-"+this.settings.placement.align),this.settings.allow_dismiss||this.$ele.find('[data-notify="dismiss"]').css("display","none"),(this.settings.delay<=0&&!this.settings.showProgressbar||!this.settings.showProgressbar)&&this.$ele.find('[data-notify="progressbar"]').remove()},setIcon:function(){"class"==this.settings.icon_type.toLowerCase()?this.$ele.find('[data-notify="icon"]').addClass(this.settings.content.icon):this.$ele.find('[data-notify="icon"]').is("img")?this.$ele.find('[data-notify="icon"]').attr("src",this.settings.content.icon):this.$ele.find('[data-notify="icon"]').append('<img src="'+this.settings.content.icon+'" alt="Notify Icon" />')},styleURL:function(){this.$ele.find('[data-notify="url"]').css({backgroundImage:"url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)",height:"100%",left:"0px",position:"absolute",top:"0px",width:"100%",zIndex:this.settings.z_index+1}),this.$ele.find('[data-notify="dismiss"]').css({position:"absolute",right:"10px",top:"5px",zIndex:this.settings.z_index+2})},placement:function(){var e=this,s=this.settings.offset.y,i={display:"inline-block",margin:"0px auto",position:this.settings.position?this.settings.position:"body"===this.settings.element?"fixed":"absolute",transition:"all .5s ease-in-out",zIndex:this.settings.z_index},n=!1,a=this.settings;switch(t('[data-notify-position="'+this.settings.placement.from+"-"+this.settings.placement.align+'"]:not([data-closing="true"])').each(function(){return s=Math.max(s,parseInt(t(this).css(a.placement.from))+parseInt(t(this).outerHeight())+parseInt(a.spacing))}),1==this.settings.newest_on_top&&(s=this.settings.offset.y),i[this.settings.placement.from]=s+"px",this.settings.placement.align){case"left":case"right":i[this.settings.placement.align]=this.settings.offset.x+"px";break;case"center":i.left=0,i.right=0}this.$ele.css(i).addClass(this.settings.animate.enter),t.each(Array("webkit","moz","o","ms",""),function(t,s){e.$ele[0].style[s+"AnimationIterationCount"]=1}),t(this.settings.element).append(this.$ele),1==this.settings.newest_on_top&&(s=parseInt(s)+parseInt(this.settings.spacing)+this.$ele.outerHeight(),this.reposition(s)),t.isFunction(e.settings.onShow)&&e.settings.onShow.call(this.$ele),this.$ele.one(this.animations.start,function(){n=!0}).one(this.animations.end,function(){t.isFunction(e.settings.onShown)&&e.settings.onShown.call(this)}),setTimeout(function(){n||t.isFunction(e.settings.onShown)&&e.settings.onShown.call(this)},600)},bind:function(){var e=this;if(this.$ele.find('[data-notify="dismiss"]').on("click",function(){e.close()}),this.$ele.mouseover(function(){t(this).data("data-hover","true")}).mouseout(function(){t(this).data("data-hover","false")}),this.$ele.data("data-hover","false"),this.settings.delay>0){e.$ele.data("notify-delay",e.settings.delay);var s=setInterval(function(){var t=parseInt(e.$ele.data("notify-delay"))-e.settings.timer;if("false"===e.$ele.data("data-hover")&&"pause"==e.settings.mouse_over||"pause"!=e.settings.mouse_over){var i=(e.settings.delay-t)/e.settings.delay*100;e.$ele.data("notify-delay",t),e.$ele.find('[data-notify="progressbar"] > div').attr("aria-valuenow",i).css("width",i+"%")}t<=-e.settings.timer&&(clearInterval(s),e.close())},e.settings.timer)}},close:function(){var e=this,s=parseInt(this.$ele.css(this.settings.placement.from)),i=!1;this.$ele.data("closing","true").addClass(this.settings.animate.exit),e.reposition(s),t.isFunction(e.settings.onClose)&&e.settings.onClose.call(this.$ele),this.$ele.one(this.animations.start,function(){i=!0}).one(this.animations.end,function(){t(this).remove(),t.isFunction(e.settings.onClosed)&&e.settings.onClosed.call(this)}),setTimeout(function(){i||(e.$ele.remove(),e.settings.onClosed&&e.settings.onClosed(e.$ele))},600)},reposition:function(e){var s=this,i='[data-notify-position="'+this.settings.placement.from+"-"+this.settings.placement.align+'"]:not([data-closing="true"])',n=this.$ele.nextAll(i);1==this.settings.newest_on_top&&(n=this.$ele.prevAll(i)),n.each(function(){t(this).css(s.settings.placement.from,e),e=parseInt(e)+parseInt(s.settings.spacing)+t(this).outerHeight()})}}),t.notify=function(t,s){var i=new e(this,t,s);return i.notify},t.notifyDefaults=function(e){return s=t.extend(!0,{},s,e)},t.notifyClose=function(e){"undefined"==typeof e||"all"==e?t("[data-notify]").find('[data-notify="dismiss"]').trigger("click"):t('[data-notify-position="'+e+'"]').find('[data-notify="dismiss"]').trigger("click")}});
\ No newline at end of file
......@@ -2,4 +2,23 @@ panel = {};
panel.init = function(csrftoken) {
panel.csrftoken = csrftoken;
};
panel.notify = function(message, delay=5000, type="info", url=null) {
$.notify({
message: message,
url: url,
target: "notify-target"
},{
type: type,
placement: {
from: "top",
align: "center"
},
delay: delay,
animate: {
enter: 'animated fadeInDown',
exit: 'animated fadeOutUp'
},
})
};
\ No newline at end of file
......@@ -38,6 +38,10 @@ panel.recipes.init_events = function () {
}
}
panel.recipes.apply_action_to_recipe(this, action);
});
$("input.add-new-recipe").click(function() {
panel.notify(django.gettext("To add a new recipe, please use the <b>QRecipeWriter software</b>!<br/>Available for Windows and Linux (click here to install)"),
0, "info", "https://gite.flo-art.fr/cooking/qrecipewriter");
})
};
......
......@@ -13,6 +13,8 @@
<link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap.min.css' %}">
<!-- Font Awesome -->
<link rel="stylesheet" type="text/css" href="{% static 'css/font-awesome.min.css' %}">
<!-- Animate -->
<link rel="stylesheet" type="text/css" href="{% static 'css/animate.css' %}">
<!-- Ionicons -->
<link rel="stylesheet" type="text/css" href="{% static 'css/ionicons.min.css' %}">
<!-- Theme style -->
......@@ -49,6 +51,8 @@
<script src="{% static 'js/jquery-ui.min.js' %}" type="text/javascript"></script>
<!-- Bootstrap 3.3.7 -->
<script src="{% static 'js/bootstrap.min.js' %}" type="text/javascript"></script>
<!-- Bootstrap notify -->
<script src="{% static 'js/bootstrap-notify.min.js' %}" type="text/javascript"></script>
<!-- datepicker -->
<script src="{% static 'js/moment-with-locales.min.js' %}" type="text/javascript"></script>
<script src="{% static 'js/bootstrap-datetimepicker.min.js' %}" type="text/javascript"></script>
......
......@@ -13,7 +13,7 @@
{% block content %}
<section class="content-header">
<h1>
{% trans "Recipes" %}
{% trans "Recipes" %} <input type="button" class="add-new-recipe" value="{% trans "Add new" %}" />
</h1>
<ol class="breadcrumb">
<li><a href="{% url "panel_index" %}"><i class="fa fa-dashboard"></i> {% trans "Home" %}</a></li>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment