diff --git a/app/assets/javascripts/app/controllers/notify.js.coffee b/app/assets/javascripts/app/controllers/notify.js.coffee index 4376ac0c8..95fb236c9 100644 --- a/app/assets/javascripts/app/controllers/notify.js.coffee +++ b/app/assets/javascripts/app/controllers/notify.js.coffee @@ -1,5 +1,4 @@ $ = jQuery.sub() -#Post = App.Post class App.Notify extends Spine.Controller events: @@ -11,7 +10,6 @@ class App.Notify extends Spine.Controller super Spine.bind 'notify', (data) => -# @log 'bind notify', data @[data.type] data.msg Spine.bind 'notify:removeall', => @@ -19,26 +17,42 @@ class App.Notify extends Spine.Controller @destroyAll() info: (data) -> - @render( text: arguments[0], type: 'alert-info' ) + @render( text: arguments[0], type: 'information' ) warning: (data) -> - @render( text: arguments[0], type: 'alert-warning' ) + @render( text: arguments[0], type: 'alert' ) error: (data) -> - @render( text: arguments[0], type: 'alert-error' ) + @render( text: arguments[0], type: 'error' ) success: (data) -> - @render( text: arguments[0], type: 'alert-success' ) + @render( text: arguments[0], type: 'success' ) render: (data) -> - notify = App.view('notify')(data: data) - @append( notify ) -# notify.html('') - +# notify = App.view('notify')(data: data) +# @append( notify ) + $.noty.closeAll() + $('#notify').noty( + { + text: data.text, + layout: 'top', + type: data.type, + theme: 'noty_theme_twitter', + animateOpen: { height: 'toggle' }, + animateClose: { height: 'toggle' }, + speed: 450, + timeout: 3600, + closeButton: false, + closeOnSelfClick: true, + closeOnSelfOver: false, + } + ) + destroy: (e) -> e.preventDefault() - $(e.target).parents('.alert').remove(); +# $(e.target).parents('.alert').remove(); destroyAll: -> - $(@el).find('.alert').remove(); + $.noty.closeAll() +# $(@el).find('.alert').remove(); diff --git a/app/assets/javascripts/app/index.js.coffee b/app/assets/javascripts/app/index.js.coffee index 6b70e08c4..097a701e4 100644 --- a/app/assets/javascripts/app/index.js.coffee +++ b/app/assets/javascripts/app/index.js.coffee @@ -15,6 +15,7 @@ #= require ./lib/underscore.coffee #= require ./lib/ba-linkify.js #= require ./lib/jquery.tagsinput.js +#= require ./lib/jquery.noty.js #= require ./lib/fileuploader.js #not_used= require_tree ./lib @@ -158,7 +159,6 @@ class App.Run extends Spine.Controller # start content new App.Content( el: @el.find('#content') ); - #class App.Content extends Spine.Stack class App.Content extends Spine.Controller className: 'container' diff --git a/app/assets/javascripts/app/lib/jquery.noty.js b/app/assets/javascripts/app/lib/jquery.noty.js new file mode 100644 index 000000000..05b7b4ba0 --- /dev/null +++ b/app/assets/javascripts/app/lib/jquery.noty.js @@ -0,0 +1,220 @@ +/** +* jQuery Noty Plugin v1.1.1 +* Authors: Nedim Arabacı (http://ned.im), Muhittin Özer (http://muhittinozer.com) +* +* Examples and Documentation - http://needim.github.com/noty/ +* +* Licensed under the MIT licenses: +* http://www.opensource.org/licenses/mit-license.php +* +**/ +(function($) { + $.noty = function(options, customContainer) { + + var base = this; + var $noty = null; + var isCustom = false; + + base.init = function(options) { + base.options = $.extend({}, $.noty.defaultOptions, options); + base.options.type = base.options.cssPrefix+base.options.type; + base.options.id = base.options.type+'_'+new Date().getTime(); + base.options.layout = base.options.cssPrefix+'layout_'+base.options.layout; + + if (base.options.custom.container) customContainer = base.options.custom.container; + isCustom = ($.type(customContainer) === 'object') ? true : false; + + return base.addQueue(); + }; + + // Push notification to queue + base.addQueue = function() { + var isGrowl = ($.inArray(base.options.layout, $.noty.growls) == -1) ? false : true; + if (!isGrowl) (base.options.force) ? $.noty.queue.unshift({options: base.options}) : $.noty.queue.push({options: base.options}); + return base.render(isGrowl); + }; + + // Render the noty + base.render = function(isGrowl) { + + // Layout spesific container settings + var container = (isCustom) ? customContainer.addClass(base.options.theme+' '+base.options.layout+' noty_custom_container') : $('body'); + if (isGrowl) { + if ($('ul.noty_cont.' + base.options.layout).length == 0) + container.prepend($('