app/assets/javascripts/hooch.js in hooch-0.15.28 vs app/assets/javascripts/hooch.js in hooch-0.16.0
- old
+ new
@@ -185,14 +185,15 @@
}),
ModalTrigger: Class.extend({
init: function($modal_trigger){
this.$modal_trigger = $modal_trigger
this.$modal_content = $($modal_trigger.data('content-target'))
+ this.dismissable = $modal_trigger.data('dismissable')
var modal_trigger = this
$modal_trigger.on('click', function(){
modal_trigger.instantiate('before')
- new hooch.Modal(modal_trigger.$modal_content)
+ new hooch.Modal(modal_trigger.$modal_content, this.dismissable)
modal_trigger.instantiate('after')
})
},
instantiate: function(timing){
var instantiate_class_name = 'instantiate-' + timing + '-class'
@@ -221,43 +222,40 @@
hooch.dismisser = null
this.modal_mask.close()
}
}),
Modal: Class.extend({
- init: function($modal_content){
+ init: function($modal_content,dismissable){
this.$modal_content = $modal_content
+ this.dismissable = dismissable
this.getMask()
this.getDismisser()
this.getContentWrapper()
this.attachDismisser()
this.disableScroll()
this.$modal_content.trigger('modalInitialized')
this.$modal_mask.show()
this.$modal_content.trigger('modalVisible')
},
getMask: function(){
- this.mask_top = $(window).scrollTop()
- this.mask_height = $(window).height()
this.$modal_mask = $('#hooch-mask')
- this.$modal_mask.css({height: this.mask_height + 'px', top: this.mask_top + 'px',
- position: 'absolute', 'z-index': 100000,
- left: 0, right: 0, bottom: 0
- })
},
getContentWrapper: function(){
this.$modal_wrapper = this.$modal_mask.find('#hooch-modal')
- this.$modal_element = $('<div/>', {id: 'hooch_content', style: 'position: relative; float: left; height: ' + (this.mask_height - 100) + 'px;'})
- this.$modal_wrapper.html(this.$modal_element)
- this.$modal_element.html(this.$modal_content)
+ this.$modal_wrapper.html(this.$modal_content)
this.$modal_content.show()
},
getDismisser: function(){
- this.$dismisser = this.$modal_mask.find('#hooch-dismiss')
+ if(this.dismissable){
+ this.$dismisser = this.$modal_mask.find('#hooch-dismiss')
+ }
},
attachDismisser: function(){
- this.$modal_wrapper.append(this.$dismisser)
- this.dismisser = new hooch.ModalDismisser(this.$dismisser,this)
+ 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()
this.enableScroll()
@@ -276,10 +274,17 @@
closeModal: function(){
if(hooch.dismisser){
hooch.dismisser.dismissModal()
}
},
+ ModalNow: Class.extend({
+ init: function($modal_trigger){
+ this.$modal_content = $($modal_trigger.data('content-target'))
+ this.dismissable = $modal_trigger.data('dismissable')
+ new hooch.Modal(this.$modal_content, this.dismissable)
+ }
+ }),
Expandable: Class.extend({
init: function($expandable){
var expandable = this;
this.expand_class = $expandable.data('expand-class');
this.collapse_class = $expandable.data('collapse-class');
@@ -928,11 +933,11 @@
});
}
}),
ReloadPage: Class.extend({
init: function(reload_page){
- window.location.href = reload_page;
+ window.location.assign(reload_page);
}
}),
PageReloader: Class.extend({
init: function($reloader){
$reloader.on('click', function(){
@@ -2279,10 +2284,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','history-pusher', 'history-replacer', 'link', 'atarget',
+ 'sorter', 'sort-element', 'bind-key','modal-trigger','modal-now','history-pusher', 'history-replacer', 'link', 'atarget',
'page-reloader'],'hooch');
window.any_time_manager.load();
};
hooch.pauseEvent = function(e){
if(e.stopPropagation) e.stopPropagation();