app/assets/javascripts/hooch.js in hooch-0.16.0 vs app/assets/javascripts/hooch.js in hooch-0.16.1

- old
+ new

@@ -232,10 +232,11 @@ this.getContentWrapper() this.attachDismisser() this.disableScroll() this.$modal_content.trigger('modalInitialized') this.$modal_mask.show() + hooch.current_modal = this this.$modal_content.trigger('modalVisible') }, getMask: function(){ this.$modal_mask = $('#hooch-mask') }, @@ -243,18 +244,16 @@ this.$modal_wrapper = this.$modal_mask.find('#hooch-modal') this.$modal_wrapper.html(this.$modal_content) this.$modal_content.show() }, getDismisser: function(){ - if(this.dismissable){ - this.$dismisser = this.$modal_mask.find('#hooch-dismiss') - } + this.$dismisser = this.$modal_mask.find('#hooch-dismiss') + this.dismisser = new hooch.ModalDismisser(this.$dismisser,this) }, attachDismisser: function(){ if(this.dismissable){ this.$modal_wrapper.append(this.$dismisser) - this.dismisser = new hooch.ModalDismisser(this.$dismisser,this) } }, close: function(){ this.$modal_mask.hide() this.$modal_content.hide() @@ -274,17 +273,39 @@ closeModal: function(){ if(hooch.dismisser){ hooch.dismisser.dismissModal() } }, + attachModalDismisser: function(){ + if(hooch.current_modal){ + hooch.current_modal.dismissable = true + hooch.current_modal.attachDismisser() + } + }, ModalNow: Class.extend({ init: function($modal_trigger){ this.$modal_content = $($modal_trigger.data('content-target')) + this.delay = $modal_trigger.data('delay') this.dismissable = $modal_trigger.data('dismissable') - new hooch.Modal(this.$modal_content, this.dismissable) + var modal_now = this + if(this.delay > 0){ + setTimeout(function(){new hooch.Modal(modal_now.$modal_content, modal_now.dismissable)}, delay) + } else { + new hooch.Modal(this.$modal_content, this.dismissable) + } } }), + ModalCloser: Class.extend({ + init: function($modal_closer){ + var milliseconds = $modal_closer.data('milliseconds') + if(milliseconds > 0){ + setTimeout(function(){hooch.closeModal()},milliseconds) + } else { + hooch.closeModal() + } + } + }), Expandable: Class.extend({ init: function($expandable){ var expandable = this; this.expand_class = $expandable.data('expand-class'); this.collapse_class = $expandable.data('collapse-class'); @@ -2284,10 +2305,10 @@ },'hooch'); window.any_time_manager.registerList( ['hover_overflow','hidey_button','hide-show','submit-proxy','click-proxy','field-filler','revealer', 'checkbox-hidden-proxy','prevent-double-submit','prevent-double-link-click', 'tab-group', 'hover-reveal', 'emptier', 'remover', 'checkbox-proxy', 'fake-checkbox', 'fake-select', 'select-action-changer', - 'sorter', 'sort-element', 'bind-key','modal-trigger','modal-now','history-pusher', 'history-replacer', 'link', 'atarget', + 'sorter', 'sort-element', 'bind-key','modal-trigger','modal-now','modal-closer','history-pusher', 'history-replacer', 'link', 'atarget', 'page-reloader'],'hooch'); window.any_time_manager.load(); }; hooch.pauseEvent = function(e){ if(e.stopPropagation) e.stopPropagation();