HusseyCoding_CmsMenuContent - Version 1.1.0

Version Notes

Major overhaul of both styling and functionality.

Download this release

Release Info

Developer Hussey Coding
Extension HusseyCoding_CmsMenuContent
Version 1.1.0
Comparing to
See all releases


Code changes from version 1.0.5 to 1.1.0

app/code/community/HusseyCoding/CmsMenuContent/Block/Cms/Page/Edit/Tab/Cmsselect.php CHANGED
@@ -13,14 +13,14 @@ class HusseyCoding_CmsMenuContent_Block_Cms_Page_Edit_Tab_Cmsselect
13
 
14
  $menufieldset = $form->addFieldset('cmsmenucontentpages_fieldset', array(
15
  'legend' => Mage::helper('cms')->__('Configure Menu Content'),
16
- 'comment' => Mage::helper('cms')->__('Configure this page to display a menu of static block content.')
17
  ));
18
 
19
  $menufieldset->addField('is_menu_page', 'select', array(
20
  'name' => 'is_menu_page',
21
  'label' => Mage::helper('cms')->__('Menu Page'),
22
  'title' => Mage::helper('cms')->__('Menu Page'),
23
- 'note' => Mage::helper('cms')->__('Use {{menucontent}} in content to set links position'),
24
  'values' => array(
25
  '1' => Mage::helper('cms')->__('Enabled'),
26
  '0' => Mage::helper('cms')->__('Disabled'),
13
 
14
  $menufieldset = $form->addFieldset('cmsmenucontentpages_fieldset', array(
15
  'legend' => Mage::helper('cms')->__('Configure Menu Content'),
16
+ 'comment' => Mage::helper('cms')->__('Configure this page to display at least one menu of static block content.')
17
  ));
18
 
19
  $menufieldset->addField('is_menu_page', 'select', array(
20
  'name' => 'is_menu_page',
21
  'label' => Mage::helper('cms')->__('Menu Page'),
22
  'title' => Mage::helper('cms')->__('Menu Page'),
23
+ 'note' => Mage::helper('cms')->__('Use {{menucontent}} in content to set position, once for each section created using breaks.'),
24
  'values' => array(
25
  '1' => Mage::helper('cms')->__('Enabled'),
26
  '0' => Mage::helper('cms')->__('Disabled'),
app/code/community/HusseyCoding/CmsMenuContent/Helper/Data.php CHANGED
@@ -6,58 +6,54 @@ class HusseyCoding_CmsMenuContent_Helper_Data extends Mage_Core_Helper_Abstract
6
 
7
  public function addBlocks($blocks, $content, $page)
8
  {
9
- $blocks = $this->getValidateBlocks($blocks, $page->getStoreId());
 
10
  $linkcolour = $this->validateHtmlColour($page->getLinkColour());
11
  $hovercolour = $this->validateHtmlColour($page->getHoverColour());
12
  $activecolour = $this->validateHtmlColour($page->getActiveColour());
13
  $ahovercolour = $this->validateHtmlColour($page->getAhoverColour());
14
 
15
- if ($blocks):
16
- $itemshtml = $this->getItemsHtml($blocks);
 
 
 
 
 
 
 
 
 
 
 
17
 
18
- $html = $this->getItemsCss($linkcolour, $hovercolour, $activecolour, $ahovercolour);
19
-
20
- $html .= '<div class="cmsmenucontent_container">';
21
-
22
- $html .= '<div class="cmsmenucontent_menu">';
23
- $html .= $itemshtml['linkshtml'];
24
- $html .= '</div>';
25
-
26
- $html .= '<div class="cmsmenucontent_content">';
27
- $html .= $itemshtml['contenthtml'];
28
- $html .= '</div>';
29
-
30
- $html .= '</div>';
31
-
32
- $html .= $this->getItemsJs($blocks);
33
-
34
- $html = str_replace('{{menucontent}}', $html, $content);
35
-
36
- return $html;
37
  endif;
38
 
39
  return str_replace('{{menucontent}}', '', $content);
40
  }
41
 
42
- private function getValidateBlocks($blocks, $pagescope)
43
  {
44
  $return = array();
45
  $cmsall = in_array('0', $pagescope);
46
- foreach ($blocks as $block):
47
- $block = Mage::getModel('cms/block')->load((int) $block);
48
- if ($block):
49
- if ($block->getIsActive() && $block->getUseInMenuPage()):
50
- if (!$cmsall):
51
- $blockscope = $block->getStoreId();
52
- $compare = array_diff($blockscope, $pagescope);
53
- if (count($blockscope) > count($compare) || in_array('0', $blockscope)):
54
- $return[] = $block;
 
 
 
 
55
  endif;
56
- else:
57
- $return[] = $block;
58
  endif;
59
  endif;
60
- endif;
61
  endforeach;
62
 
63
  return $return;
@@ -77,21 +73,22 @@ class HusseyCoding_CmsMenuContent_Helper_Data extends Mage_Core_Helper_Abstract
77
  return false;
78
  }
79
 
80
- private function getItemsHtml($blocks)
81
  {
82
- $menuhtml = array();
83
- $contenthtml = array();
84
- foreach ($blocks as $key => $block):
85
- $key++;
86
- $title = $this->getBlockMenuTitle($block);
87
- $menuhtml[] = '<a class="blocklink" id="blocklink_' . $key . '" href="javascript:void(0)">' . $title . '</a>';
88
- $contenthtml[] = '<div class="blockcontent" id="blockcontent_' . $key . '">' . $block->getContent() . '</div>';
 
 
 
 
89
  endforeach;
90
 
91
- $menuhtml = implode('', $menuhtml);
92
- $contenthtml = implode('', $contenthtml);
93
-
94
- return array('linkshtml' => $menuhtml, 'contenthtml' => $contenthtml);
95
  }
96
 
97
  public function getBlockMenuTitle($block)
@@ -99,14 +96,19 @@ class HusseyCoding_CmsMenuContent_Helper_Data extends Mage_Core_Helper_Abstract
99
  return $block->getLinkText() ? $block->getLinkText() : $block->getTitle();
100
  }
101
 
102
- private function getItemsCss($linkcolour, $hovercolour, $activecolour, $ahovercolour)
103
  {
104
  $css = '';
105
  if ($linkcolour || $hovercolour || $activecolour):
106
  $css .= '<style type="text/css">';
107
  if ($linkcolour) $css .= ' .cmsmenucontent_container .cmsmenucontent_menu a.blocklink { color:' . $linkcolour . '; }';
108
  if ($hovercolour) $css .= ' .cmsmenucontent_container .cmsmenucontent_menu a.blocklink:hover { color:' . $hovercolour . '; }';
109
- if ($activecolour) $css .= ' .cmsmenucontent_container .cmsmenucontent_menu a.blocklink_active { color:' . $activecolour . '; }';
 
 
 
 
 
110
  if ($ahovercolour) $css .= ' .cmsmenucontent_container .cmsmenucontent_menu a.blocklink_active:hover { color:' . $ahovercolour . '; }';
111
  $css .= ' </style>';
112
  endif;
@@ -114,17 +116,40 @@ class HusseyCoding_CmsMenuContent_Helper_Data extends Mage_Core_Helper_Abstract
114
  return $css;
115
  }
116
 
117
- private function getItemsJs($blocks)
118
  {
119
  $js = '<script type="text/javascript">';
120
  $js .= ' var thismenucontent = new menucontent();';
121
  $js .= ' thismenucontent.menuitems = {};';
122
- foreach ($blocks as $key => $blocks):
123
- $key++;
124
- $js .= ' thismenucontent.menuitems.blocklink_' . $key . ' = "blockcontent_' . $key . '";';
 
 
 
125
  endforeach;
126
  $js .= ' </script>';
127
 
128
  return $js;
129
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  }
6
 
7
  public function addBlocks($blocks, $content, $page)
8
  {
9
+ $blocks = $this->_separateBlocks($blocks);
10
+ $blocks = $this->_getValidateBlocks($blocks, $page->getStoreId());
11
  $linkcolour = $this->validateHtmlColour($page->getLinkColour());
12
  $hovercolour = $this->validateHtmlColour($page->getHoverColour());
13
  $activecolour = $this->validateHtmlColour($page->getActiveColour());
14
  $ahovercolour = $this->validateHtmlColour($page->getAhoverColour());
15
 
16
+ if (!empty($blocks)):
17
+ $itemshtml = $this->_getItemsHtml($blocks);
18
+ $html = $this->_getItemsCss($linkcolour, $hovercolour, $activecolour, $ahovercolour);
19
+ foreach ($blocks as $section => $block):
20
+ $html .= '<div class="cmsmenucontent_container">';
21
+ $html .= '<div class="cmsmenucontent_menu">';
22
+ $html .= $itemshtml[$section];
23
+ $html .= '</div>';
24
+ $html .= '</div>';
25
+ $content = preg_replace('/{{menucontent}}/', $html, $content, 1);
26
+ $html = '';
27
+ endforeach;
28
+ $content .= $this->_getItemsJs($blocks);
29
 
30
+ return $content;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  endif;
32
 
33
  return str_replace('{{menucontent}}', '', $content);
34
  }
35
 
36
+ private function _getValidateBlocks($blocks, $pagescope)
37
  {
38
  $return = array();
39
  $cmsall = in_array('0', $pagescope);
40
+ foreach ($blocks as $id => $section):
41
+ foreach ($section as $block):
42
+ $block = Mage::getModel('cms/block')->load((int) $block);
43
+ if ($block):
44
+ if ($block->getIsActive() && $block->getUseInMenuPage()):
45
+ if (!$cmsall):
46
+ $blockscope = $block->getStoreId();
47
+ $compare = array_diff($blockscope, $pagescope);
48
+ if (count($blockscope) > count($compare) || in_array('0', $blockscope)):
49
+ $return[$id][] = $block;
50
+ endif;
51
+ else:
52
+ $return[$id][] = $block;
53
  endif;
 
 
54
  endif;
55
  endif;
56
+ endforeach;
57
  endforeach;
58
 
59
  return $return;
73
  return false;
74
  }
75
 
76
+ private function _getItemsHtml($blocks)
77
  {
78
+ $html = array();
79
+ $key = 0;
80
+ foreach ($blocks as $k => $section):
81
+ foreach ($section as $block):
82
+ $key++;
83
+ $title = $this->getBlockMenuTitle($block);
84
+ $class = strpos($title, '?') !== false ? ' question-mark-indent' : ' information-indent';
85
+ $html[$k][] = '<a class="blocklink' . $class . '" id="blocklink_' . $key . '" href="javascript:void(0)">' . $title . '</a>';
86
+ $html[$k][] = '<div class="blockcontent" id="blockcontent_' . $key . '">' . $block->getContent() . '</div>';
87
+ endforeach;
88
+ $html[$k] = implode('', $html[$k]);
89
  endforeach;
90
 
91
+ return $html;
 
 
 
92
  }
93
 
94
  public function getBlockMenuTitle($block)
96
  return $block->getLinkText() ? $block->getLinkText() : $block->getTitle();
97
  }
98
 
99
+ private function _getItemsCss($linkcolour, $hovercolour, $activecolour, $ahovercolour)
100
  {
101
  $css = '';
102
  if ($linkcolour || $hovercolour || $activecolour):
103
  $css .= '<style type="text/css">';
104
  if ($linkcolour) $css .= ' .cmsmenucontent_container .cmsmenucontent_menu a.blocklink { color:' . $linkcolour . '; }';
105
  if ($hovercolour) $css .= ' .cmsmenucontent_container .cmsmenucontent_menu a.blocklink:hover { color:' . $hovercolour . '; }';
106
+ if ($activecolour):
107
+ $css .= ' .cmsmenucontent_container .cmsmenucontent_menu a.blocklink_active { color:' . $activecolour . '; }';
108
+ $css .= ' .cmsmenucontent_container .cmsmenucontent_menu .information-indent:before, .cmsmenucontent_container .cmsmenucontent_menu .question-mark-indent:before { background-color:' . $activecolour . '; }';
109
+ $css .= ' .cmsmenucontent_container .cmsmenucontent_menu a.blocklink_active:after { border-color:rgba(' . $activecolour . ', 0); border-top-color:' . $activecolour . '; }';
110
+ $css .= ' .cmsmenucontent_container .cmsmenucontent_menu a.blocklink:after { border-color:rgba(' . $activecolour . ', 0); border-right-color:' . $activecolour . '; }';
111
+ endif;
112
  if ($ahovercolour) $css .= ' .cmsmenucontent_container .cmsmenucontent_menu a.blocklink_active:hover { color:' . $ahovercolour . '; }';
113
  $css .= ' </style>';
114
  endif;
116
  return $css;
117
  }
118
 
119
+ private function _getItemsJs($blocks)
120
  {
121
  $js = '<script type="text/javascript">';
122
  $js .= ' var thismenucontent = new menucontent();';
123
  $js .= ' thismenucontent.menuitems = {};';
124
+ $key = 0;
125
+ foreach ($blocks as $block):
126
+ foreach ($block as $blocks):
127
+ $key++;
128
+ $js .= ' thismenucontent.menuitems.blocklink_' . $key . ' = "blockcontent_' . $key . '";';
129
+ endforeach;
130
  endforeach;
131
  $js .= ' </script>';
132
 
133
  return $js;
134
  }
135
+
136
+ private function _separateBlocks($blocks)
137
+ {
138
+ $return = array();
139
+ $section = array();
140
+ foreach ($blocks as $block):
141
+ if ($block == 'sb'):
142
+ if (!empty($section)):
143
+ $return[] = $section;
144
+ $section = array();
145
+ endif;
146
+ elseif (!empty($block)):
147
+ $section[] = $block;
148
+ endif;
149
+ endforeach;
150
+
151
+ if (!empty($section)) $return[] = $section;
152
+
153
+ return !empty($return) ? $return : $blocks;
154
+ }
155
  }
app/code/community/HusseyCoding/CmsMenuContent/Model/Observer.php CHANGED
@@ -4,7 +4,11 @@ class HusseyCoding_CmsMenuContent_Model_Observer
4
  public function adminhtmlCmsPageSaveBefore($observer)
5
  {
6
  $page = $observer->getObject();
7
- $page->setMenuItems(implode(',', $page->getMenuItems()));
 
 
 
 
8
  }
9
 
10
  public function adminhtmlCmsPageLoadAfter($observer)
4
  public function adminhtmlCmsPageSaveBefore($observer)
5
  {
6
  $page = $observer->getObject();
7
+ $items = $page->getBlockOrder();
8
+ $items = preg_replace('/^(sb,)+/', '', $items);
9
+ $items = preg_replace('/(,sb)+$/', '', $items);
10
+ $page->setMenuItems($items);
11
+ $page->setBlockOrder($items);
12
  }
13
 
14
  public function adminhtmlCmsPageLoadAfter($observer)
app/code/community/HusseyCoding/CmsMenuContent/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <HusseyCoding_CmsMenuContent>
5
- <version>1.0.5</version>
6
  </HusseyCoding_CmsMenuContent>
7
  </modules>
8
  <global>
@@ -86,4 +86,4 @@
86
  </cms_page_render>
87
  </events>
88
  </frontend>
89
- </config>
2
  <config>
3
  <modules>
4
  <HusseyCoding_CmsMenuContent>
5
+ <version>1.1.0</version>
6
  </HusseyCoding_CmsMenuContent>
7
  </modules>
8
  <global>
86
  </cms_page_render>
87
  </events>
88
  </frontend>
89
+ </config>
package.xml CHANGED
@@ -1,20 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>HusseyCoding_CmsMenuContent</name>
4
- <version>1.0.5</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
- <summary>Adds tab style content switching to Magento CMS pages.</summary>
10
- <description>This fully search engine optimised (SEO) extension allows you to greatly condense the number of CMS pages you need by quickly and easily including any number of static blocks on a CMS page with customisable links to switch between block content.&#xD;
11
- &#xD;
12
- This allows you to have a high volume of information on only a few pages while keeping content highly readable and accessible by the customer.</description>
13
- <notes>Fixed losing block order on cms edit page load</notes>
14
  <authors><author><name>Hussey Coding</name><user>husseycoding</user><email>info@husseycoding.co.uk</email></author></authors>
15
- <date>2015-08-16</date>
16
- <time>05:50:02</time>
17
- <contents><target name="magecommunity"><dir name="HusseyCoding"><dir name="CmsMenuContent"><dir name="Block"><dir name="Cms"><dir name="Block"><dir name="Edit"><file name="AdminhtmlForm.php" hash="8b3d9b9efc2fb0196170243f1d834ddc"/></dir></dir><dir name="Page"><dir name="Edit"><dir name="Tab"><file name="Cmsselect.php" hash="203884175c84b904d888d2fa01aeb02b"/></dir></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="e0b337d009017cd85850fa4f435908cf"/><file name="config.xml" hash="6ceb112dd2ad665ebdf02b261303b7b1"/><file name="system.xml" hash="a406ecf3c9587d5b01d8c1948ff2a226"/></dir><dir name="Helper"><file name="Data.php" hash="83dfe3a1035e6bdba0ce28341e5d8e9f"/></dir><dir name="Model"><file name="Observer.php" hash="1148fec36c6ee12c6e1fbd6b9c80b371"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Cmsmenucontent.php" hash="94a74f45a770f313061cdacd2befeef3"/></dir></dir></dir></dir><dir name="sql"><dir name="cmsmenucontent_setup"><file name="mysql4-install-1.0.0.php" hash="d0381661e97eaf679ea945bd7a602952"/></dir></dir></dir><dir name="Common"><dir name="etc"><file name="system.xml" hash="6c9ba9f227b9adfc9abf97f17b46fdbf"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="HusseyCoding_CmsMenuContent.xml" hash="83437e316b1a2960bed43874190e3643"/><file name="HusseyCoding_Common.xml" hash="31e82d3d9b3179c2fa9e002f9669da47"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="cmsmenucontent.xml" hash="526a2c79ead0c597b49381f001b9f973"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="cmsmenucontent.xml" hash="c97897fa5b2aed04a1322c2e993c2db6"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="cmsmenucontent"><dir name="js"><file name="cmsmenucontent.js" hash="e730f983de79909158b56e7fcab67bf6"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="js"><file name="cmsmenucontent.js" hash="e7170f638a49b44c8f3844fee890e90a"/></dir><dir name="css"><file name="cmsmenucontent.css" hash="dd1d4fe0a289497c765dded798b1186f"/></dir></dir></dir></dir></target></contents>
18
  <compatible/>
19
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
20
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>HusseyCoding_CmsMenuContent</name>
4
+ <version>1.1.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
+ <summary>Adds expanding blocks of content to CMS pages.</summary>
10
+ <description>This extension adds multiple sections of expanding static block content to CMS pages. Each CMS page can have multiple separate sections of static block content. Each static block starts contracted on page load with a styled title header with icon, and then expands on click. Ideal for things like FAQ pages where there needs to be several separate sections of FAQ block content.</description>
11
+ <notes>Major overhaul of both styling and functionality.</notes>
 
 
12
  <authors><author><name>Hussey Coding</name><user>husseycoding</user><email>info@husseycoding.co.uk</email></author></authors>
13
+ <date>2016-11-11</date>
14
+ <time>11:26:17</time>
15
+ <contents><target name="magecommunity"><dir name="HusseyCoding"><dir name="CmsMenuContent"><dir name="Block"><dir name="Cms"><dir name="Block"><dir name="Edit"><file name="AdminhtmlForm.php" hash="8b3d9b9efc2fb0196170243f1d834ddc"/></dir></dir><dir name="Page"><dir name="Edit"><dir name="Tab"><file name="Cmsselect.php" hash="2ef179fbe65df8e01f170654fa96a798"/></dir></dir></dir></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="e0b337d009017cd85850fa4f435908cf"/><file name="config.xml" hash="f85e0c445448c36dafad98273ff0fdf5"/><file name="system.xml" hash="a406ecf3c9587d5b01d8c1948ff2a226"/></dir><dir name="Helper"><file name="Data.php" hash="1e4e3a706145f78feba03e61076f0e36"/></dir><dir name="Model"><file name="Observer.php" hash="ec37348ede88822c22d39b2e52f2cdb7"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Cmsmenucontent.php" hash="94a74f45a770f313061cdacd2befeef3"/></dir></dir></dir></dir><dir name="sql"><dir name="cmsmenucontent_setup"><file name="mysql4-install-1.0.0.php" hash="d0381661e97eaf679ea945bd7a602952"/></dir></dir></dir><dir name="Common"><dir name="etc"><file name="system.xml" hash="6c9ba9f227b9adfc9abf97f17b46fdbf"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="HusseyCoding_CmsMenuContent.xml" hash="83437e316b1a2960bed43874190e3643"/><file name="HusseyCoding_Common.xml" hash="31e82d3d9b3179c2fa9e002f9669da47"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="cmsmenucontent.xml" hash="526a2c79ead0c597b49381f001b9f973"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="cmsmenucontent.xml" hash="c97897fa5b2aed04a1322c2e993c2db6"/></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="cmsmenucontent"><dir name="js"><file name="cmsmenucontent.js" hash="ece1a52c292d8bfd8c0a74514c5fe428"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="js"><file name="cmsmenucontent.js" hash="65b67baf0907423f5535067259269a9c"/></dir><dir name="css"><file name="cmsmenucontent.css" hash="e6fe5dac9cd484a484df8484592a39d4"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
skin/adminhtml/default/default/cmsmenucontent/js/cmsmenucontent.js CHANGED
@@ -1,10 +1,17 @@
1
  var selected = Class.create({
2
- initialize: function() {
3
- this.userselected = $F("menu_block_order").split(",");
 
 
 
 
4
  this.getText();
5
  Event.observe($("menu_menu_items"), "change", this.updateForm.bindAsEventListener(this));
6
  $("menu_menu_items").up("tr").insert({ after: '<tr><td class="label">Block Display Order</td><td id="displayblockorder" class="value"></td></tr>' });
7
  this.outputOrder();
 
 
 
8
  },
9
  addColumn: function(id) {
10
  if (this.userselected.indexOf(id) == -1) {
@@ -44,21 +51,49 @@ var selected = Class.create({
44
  for (var i = 0; i < $("menu_menu_items").options.length; i++) {
45
  this.valuetext[$("menu_menu_items").options[i].value] = $("menu_menu_items").options[i].text;
46
  }
 
47
  },
48
  outputOrder: function() {
49
  var html = new Array();
50
  var hidden = new Array();
51
  this.userselected.each(function(s) {
52
- html.push(this.valuetext[s]);
53
  hidden.push(s);
54
  }.bind(this));
55
  hidden = hidden.join(",");
56
- html = html.join("<br />");
57
  $("menu_block_order").value = hidden;
58
  $("displayblockorder").update(html);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  }
60
  });
61
 
 
 
62
  document.observe("dom:loaded", function() {
63
- var selecteditems = new selected();
64
  });
1
  var selected = Class.create({
2
+ afterInit: function() {
3
+ if ($F("menu_block_order")) {
4
+ this.userselected = $F("menu_block_order").split(",");
5
+ } else {
6
+ this.userselected = new Array();
7
+ }
8
  this.getText();
9
  Event.observe($("menu_menu_items"), "change", this.updateForm.bindAsEventListener(this));
10
  $("menu_menu_items").up("tr").insert({ after: '<tr><td class="label">Block Display Order</td><td id="displayblockorder" class="value"></td></tr>' });
11
  this.outputOrder();
12
+ this.initOrderSort();
13
+ this.addSectionButton();
14
+ Event.observe($("add_cmsmenucontent_break"), "click", this.addBreak.bind(this));
15
  },
16
  addColumn: function(id) {
17
  if (this.userselected.indexOf(id) == -1) {
51
  for (var i = 0; i < $("menu_menu_items").options.length; i++) {
52
  this.valuetext[$("menu_menu_items").options[i].value] = $("menu_menu_items").options[i].text;
53
  }
54
+ this.valuetext["sb"] = "Break";
55
  },
56
  outputOrder: function() {
57
  var html = new Array();
58
  var hidden = new Array();
59
  this.userselected.each(function(s) {
60
+ html.push("<div class=\"id_" + s + "\" style=\"cursor:pointer\">" + this.valuetext[s] + "</div>");
61
  hidden.push(s);
62
  }.bind(this));
63
  hidden = hidden.join(",");
64
+ html = html.join("");
65
  $("menu_block_order").value = hidden;
66
  $("displayblockorder").update(html);
67
+ this.initOrderSort();
68
+ },
69
+ initOrderSort: function() {
70
+ Sortable.create("displayblockorder", {
71
+ tag: "div",
72
+ onChange: function(evt) {
73
+ selecteditems.updateOrder();
74
+ }
75
+ });
76
+ },
77
+ updateOrder: function() {
78
+ var ids = [];
79
+ $("displayblockorder").childElements().each(function(e) {
80
+ var id = e.className.split("_");
81
+ ids.push(id.pop());
82
+ }.bind(this));
83
+ this.userselected = ids;
84
+ $("menu_block_order").value = ids.join(",");
85
+ },
86
+ addSectionButton: function() {
87
+ $("menu_menu_items").up("tr").insert({ after: '<tr><td class="label"></td><td class="value"><button type="button" id="add_cmsmenucontent_break"><span><span><span>Add Break</span></span></span></button><p class=\"note\"><span>Adding breaks creates sections. Drag breaks to the start or end of block order to remove on save.</span></p></td></tr>' });
88
+ },
89
+ addBreak: function() {
90
+ this.userselected.push("sb");
91
+ this.outputOrder();
92
  }
93
  });
94
 
95
+ var selecteditems = new selected();
96
+
97
  document.observe("dom:loaded", function() {
98
+ selecteditems.afterInit();
99
  });
skin/frontend/base/default/css/cmsmenucontent.css CHANGED
@@ -1,2 +1,12 @@
1
  .cmsmenucontent_container .cmsmenucontent_menu a { padding-bottom:4px; display:block; }
2
- .cmsmenucontent_container .cmsmenucontent_menu { margin-bottom:16px; }
 
 
 
 
 
 
 
 
 
 
1
  .cmsmenucontent_container .cmsmenucontent_menu a { padding-bottom:4px; display:block; }
2
+ .cmsmenucontent_container .cmsmenucontent_menu { margin-bottom:16px; }
3
+ .cmsmenucontent_container .cmsmenucontent_menu a.blocklink,
4
+ .cmsmenucontent_container .cmsmenucontent_menu a.blocklink_active { background-color:#f2f2f2; padding:7px 30px 7px 10px; margin-bottom:7px; position:relative; border:1px solid #ddd; text-decoration:none; -webkit-border-radius:5px; -moz-border-radius:5px; border-radius:5px; }
5
+ .cmsmenucontent_container .cmsmenucontent_menu .blockcontent a { display:inline; }
6
+ .cmsmenucontent_container .cmsmenucontent_menu .blockcontent { overflow:hidden; -webkit-transition:all 500ms cubic-bezier(0.670, 0.000, 0.330, 1.000); -moz-transition:all 500ms cubic-bezier(0.670, 0.000, 0.330, 1.000); -o-transition:all 500ms cubic-bezier(0.670, 0.000, 0.330, 1.000); transition:all 500ms cubic-bezier(0.670, 0.000, 0.330, 1.000); -webkit-transition-timing-function:cubic-bezier(0.670, 0.000, 0.330, 1.000); -moz-transition-timing-function:cubic-bezier(0.670, 0.000, 0.330, 1.000); -o-transition-timing-function:cubic-bezier(0.670, 0.000, 0.330, 1.000); transition-timing-function:cubic-bezier(0.670, 0.000, 0.330, 1.000); }
7
+ .cmsmenucontent_container .cmsmenucontent_menu a.blocklink_active:after { right:10px; top:45%; border:solid transparent; content:" "; height:0; width:0; position:absolute; pointer-events:none; border-color:rgba(#888, 0); border-top-color:#888; border-width:7px; margin-left:-7px; }
8
+ .cmsmenucontent_container .cmsmenucontent_menu a.blocklink:after { right:10px; top:50%; border:solid transparent; content:" "; height:0; width:0; position:absolute; pointer-events:none; border-color:rgba(#888, 0); border-right-color:#888; border-width:7px; margin-top:-7px; }
9
+ .cmsmenucontent_container .cmsmenucontent_menu .information-indent:before,
10
+ .cmsmenucontent_container .cmsmenucontent_menu .question-mark-indent:before { -webkit-border-radius:10px; -moz-border-radius:10px; border-radius:10px; width:20px; height:20px; background-color:#888; display:inline-block; line-height:20px; text-align:center; font-weight:bold; margin-right:10px; color:#f2f2f2; font-size:15px; }
11
+ .cmsmenucontent_container .cmsmenucontent_menu .question-mark-indent:before { content:"?"; }
12
+ .cmsmenucontent_container .cmsmenucontent_menu .information-indent:before { content:"!"; }
skin/frontend/base/default/js/cmsmenucontent.js CHANGED
@@ -5,16 +5,8 @@ var menucontent = Class.create({
5
  this.bookmarkSwitch();
6
  },
7
  initMenuItems: function() {
8
- var count = 0;
9
  $H(this.menuitems).each(function(item) {
10
- if (count == 0) {
11
- $(item.key).removeClassName("blocklink")
12
- $(item.key).addClassName("blocklink_active")
13
- $(item.value).show();
14
- } else {
15
- $(item.value).hide();
16
- }
17
- count++;
18
  });
19
  },
20
  addObservers: function() {
@@ -27,13 +19,16 @@ var menucontent = Class.create({
27
  displayContent: function(el) {
28
  $H(this.menuitems).each(function(item) {
29
  if (item.key == el) {
30
- $(item.key).removeClassName("blocklink")
31
- $(item.key).addClassName("blocklink_active")
32
- $(item.value).show();
33
- } else {
34
- $(item.key).removeClassName("blocklink_active")
35
- $(item.key).addClassName("blocklink")
36
- $(item.value).hide();
 
 
 
37
  }
38
  });
39
  },
@@ -44,6 +39,7 @@ var menucontent = Class.create({
44
  var el = $("blocklink_" + argument);
45
  if (el) {
46
  this.displayContent(el.id);
 
47
  }
48
  }
49
  }
5
  this.bookmarkSwitch();
6
  },
7
  initMenuItems: function() {
 
8
  $H(this.menuitems).each(function(item) {
9
+ $(item.value).setStyle({ height:"0" });
 
 
 
 
 
 
 
10
  });
11
  },
12
  addObservers: function() {
19
  displayContent: function(el) {
20
  $H(this.menuitems).each(function(item) {
21
  if (item.key == el) {
22
+ if ($(item.key).hasClassName("blocklink_active")) {
23
+ $(item.key).removeClassName("blocklink_active")
24
+ $(item.key).addClassName("blocklink")
25
+ $(item.value).setStyle({ height:"0" });
26
+ } else {
27
+ $(item.key).removeClassName("blocklink")
28
+ $(item.key).addClassName("blocklink_active")
29
+ var height = $(item.value).scrollHeight;
30
+ $(item.value).setStyle({ height:height + "px" });
31
+ }
32
  }
33
  });
34
  },
39
  var el = $("blocklink_" + argument);
40
  if (el) {
41
  this.displayContent(el.id);
42
+ Effect.ScrollTo(el, {duration:1.0, offset:-5});
43
  }
44
  }
45
  }