Sha256: a22090cc4c68be65bcc54adc245ab7b0120764e87556b485484d354dc7f67fbd

Contents?: true

Size: 1.89 KB

Versions: 38

Compression:

Stored size: 1.89 KB

Contents

$.widget("rbbt.hide_toggle", {
 options: {
 },

 _create: function() {
   var tool = this
   var element = this.element
   if (this.options.title === undefined){  this.options.title = element.attr('hide-title') }
   if (this.options.title === undefined){  this.options.title = "toggle" }

   var button = this.options.button = $('<a>').addClass('hide_toggle').html(this.options.title).attr('data-title', this.options.title)

   button.click(function(){ tool.toggle(); update_rbbt(); return false })
   if (this.options.container !== undefined){
     $(this.options.container).first().append(button)
   }
   //this.hide()
 },

 _swap: function(){
   this.options.saved = this.element.html()
   this.element.html(this.options.button)
 },

 _restore: function(){
   this.element.html(this.options.saved)
 },


 hide: function(){
   var tool = this;
   this.element.addClass('hidden').removeClass('shown').removeClass('show')
   this.options.button.addClass('hidden').removeClass('shown').removeClass('show')

   if (this.options.container === undefined){ this._swap(); }
 },

 show: function(){
   if (this.options.container === undefined){ 
     this._restore(); 
   }else{
     $(this.options.container).find('.hide_toggle.shown').trigger('click')
   }
   this.element.addClass('shown').addClass('show').removeClass('hidden')
   this.options.button.addClass('shown').addClass('show').removeClass('hidden')
 },

 toggle: function(){
   if (this.element.hasClass('shown')){
     this.hide();
   }else{
     this.show();
   }
 }

})

$('#top_menu .hide').hide_toggle({container: '#top_menu .container'})

$('.sidebar').hide_toggle({container: '#top_menu .container', title: 'Side'})

$('.actions.togglable_hide .action_controller').parents('.togglable_hide').first().hide_toggle({container: '#top_menu .container'}) 

register_dom_update('.fixable', function(elem){ elem.hide_toggle({container: '#top_menu .container', title: "Fixed"}) })

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
rbbt-rest-1.7.5 share/views/public/js/rbbt/hide.js
rbbt-rest-1.7.4 share/views/public/js/rbbt/hide.js
rbbt-rest-1.7.3 share/views/public/js/rbbt/hide.js
rbbt-rest-1.7.2 share/views/public/js/rbbt/hide.js
rbbt-rest-1.7.1 share/views/public/js/rbbt/hide.js
rbbt-rest-1.7.0 share/views/public/js/rbbt/hide.js
rbbt-rest-1.6.28 share/views/public/js/rbbt/hide.js
rbbt-rest-1.6.26 share/views/public/js/rbbt/hide.js
rbbt-rest-1.6.25 share/views/public/js/rbbt/hide.js
rbbt-rest-1.6.24 share/views/public/js/rbbt/hide.js
rbbt-rest-1.6.23 share/views/public/js/rbbt/hide.js
rbbt-rest-1.6.22 share/views/public/js/rbbt/hide.js
rbbt-rest-1.6.21 share/views/public/js/rbbt/hide.js
rbbt-rest-1.6.20 share/views/public/js/rbbt/hide.js
rbbt-rest-1.6.19 share/views/public/js/rbbt/hide.js
rbbt-rest-1.6.18 share/views/public/js/rbbt/hide.js
rbbt-rest-1.6.17 share/views/public/js/rbbt/hide.js
rbbt-rest-1.6.16 share/views/public/js/rbbt/hide.js
rbbt-rest-1.6.15 share/views/public/js/rbbt/hide.js
rbbt-rest-1.6.14 share/views/public/js/rbbt/hide.js