Open the file /exercises/portlets.html in
your browser. Use the file
/exercises/js/portlets.js. Your task is to create a
portlet creation function that uses the module pattern, such that the
following code will work:
var myPortlet = Portlet({
title : 'Curry',
source : 'data/html/curry.html',
initialState : 'open' // or 'closed'
});
myPortlet.$element.appendTo('body');
Each portlet should be a div with a title, a content area, a button to open/close the portlet, a button to remove the portlet, and a button to refresh the portlet. The portlet returned by the Portlet function should have the following public API:
myPortlet.open(); // force open state
myPortlet.close(); // force close state
myPortlet.toggle(); // toggle open/close state
myPortlet.refresh(); // refresh the content
myPortlet.destroy(); // remove the portlet from the page
myPortlet.setSource('data/html/onions.html');
// change the source
Copyright Rebecca Murphey, released under the Creative Commons Attribution-Share Alike 3.0 United States license.