Sha256: a5af5da654081a0e4a3ce4cd5bbb8935eab0125cb5487f944ece2f0b96de39a1

Contents?: true

Size: 1.54 KB

Versions: 86

Compression:

Stored size: 1.54 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)

   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')
   this.options.button.addClass('hidden').removeClass('shown')

   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').removeClass('hidden')
   this.options.button.addClass('shown').removeClass('hidden')
 },

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

})

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

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

Version data entries

86 entries across 86 versions & 1 rubygems

Version Path
rbbt-rest-1.4.10 share/views/public/js/rbbt/hide.js
rbbt-rest-1.4.9 share/views/public/js/rbbt/hide.js
rbbt-rest-1.4.8 share/views/public/js/rbbt/hide.js
rbbt-rest-1.4.7 share/views/public/js/rbbt/hide.js
rbbt-rest-1.4.6 share/views/public/js/rbbt/hide.js
rbbt-rest-1.4.5 share/views/public/js/rbbt/hide.js
rbbt-rest-1.4.4 share/views/public/js/rbbt/hide.js
rbbt-rest-1.4.3 share/views/public/js/rbbt/hide.js
rbbt-rest-1.4.2 share/views/public/js/rbbt/hide.js
rbbt-rest-1.4.1 share/views/public/js/rbbt/hide.js
rbbt-rest-1.4.0 share/views/public/js/rbbt/hide.js
rbbt-rest-1.3.32 share/views/public/js/rbbt/hide.js
rbbt-rest-1.3.31 share/views/public/js/rbbt/hide.js
rbbt-rest-1.3.30 share/views/public/js/rbbt/hide.js
rbbt-rest-1.3.29 share/views/public/js/rbbt/hide.js
rbbt-rest-1.3.28 share/views/public/js/rbbt/hide.js
rbbt-rest-1.3.27 share/views/public/js/rbbt/hide.js
rbbt-rest-1.3.26 share/views/public/js/rbbt/hide.js
rbbt-rest-1.3.25 share/views/public/js/rbbt/hide.js
rbbt-rest-1.3.24 share/views/public/js/rbbt/hide.js