Monday, February 20, 2012

using options with jasmine-jquery widgets

setup: function (defaultStateIsOpen) {

   var self = this;

   self.options.stateIsOpen = defaultStateIsOpen;

   self.options.container = self.element;

   self.definePortletHeader(self.options.container.children(":nth-child(1)"));

   self.definePortletContent(self.options.container.children(":nth-child(2)"));

   self.alterAppearanceBasedOnOpenState();

   self.reveal();

},

alterAppearanceBasedOnOpenState: function () {

   var self = this;

   if (self.options.stateIsOpen) {

      self.options.portletHeader.children("span").removeClass('ui-icon-plusthick');

      self.options.portletHeader.children("span").addClass('ui-icon-minusthick');

      self.options.portletContent.removeClass('hide');

   } else {

      self.options.portletHeader.children("span").addClass('ui-icon-plusthick');

      self.options.portletHeader.children("span").removeClass('ui-icon-minusthick');

      self.options.portletContent.addClass('hide');

   }

},

options: {

   stateIsOpen: false, //REQUIRED

   stateIsPersisted: false

}

No comments:

Post a Comment