2 * headerMenu Plugin Js Controller
4 * Copyright 2012-2013, Franck Villaume - TrivialDev
5 * http://fusionforge.org
7 * This file is part of FusionForge. FusionForge is free software;
8 * you can redistribute it and/or modify it under the terms of the
9 * GNU General Public License as published by the Free Software
10 * Foundation; either version 2 of the Licence, or (at your option)
13 * FusionForge is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License along
19 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 EditHeaderMenuController = function(params) {
26 this.initializeView();
29 HeaderMenuController = function(params) {
32 this.initializeView();
35 GroupMenuController = function(params) {
38 this.initializeView();
41 HeaderMenuController.prototype =
43 bindControls: function() {
44 this.params.inputHtmlCode.click(jQuery.proxy(this, "htmlCodeView"));
45 this.params.inputURL.click(jQuery.proxy(this, "htmlUrlView"));
46 this.params.inputOuter.click(jQuery.proxy(this, "inputHtmlCodeView"));
47 this.params.inputHeader.click(jQuery.proxy(this, "initializeView"));
50 initializeView: function() {
51 this.params.inputHtmlCode.prop('disabled', true);
52 this.params.trHtmlCode.hide();
53 this.params.trUrlCode.show();
54 this.params.inputURL.attr('checked', 'checked');
55 if (typeof(this.params.tableTbodyLink) != 'undefined') {
56 this.params.tableTbodyLink.sortable({
57 update: function(event, ui) {
58 jQuery(ui.item).attr("id", jQuery(ui.item).index());
64 htmlCodeView: function() {
65 this.params.trHtmlCode.show();
66 this.params.trUrlCode.hide();
69 htmlUrlView: function() {
70 this.params.trHtmlCode.hide();
71 this.params.trUrlCode.show();
74 inputHtmlCodeView: function() {
75 this.params.inputHtmlCode.prop('disabled', false);
79 GroupMenuController.prototype =
81 bindControls: function() {
82 this.params.inputHtmlCode.click(jQuery.proxy(this, "htmlCodeView"));
83 this.params.inputURL.click(jQuery.proxy(this, "htmlUrlView"));
84 this.params.validateButton.click(jQuery.proxy(this, "validateLinkOrder"));
87 initializeView: function() {
88 this.params.trHtmlCode.hide();
89 this.params.trUrlCode.show();
90 this.params.inputURL.attr('checked', 'checked');
91 if (typeof(this.params.tableTbodyLink) != 'undefined') {
92 this.params.tableTbodyLink.sortable({
93 update: function(event, ui) {
94 jQuery("#sortable tbody").children().each(function() {
95 if (jQuery(this).index() % 2 === 0) {
96 jQuery(this).attr("class", "even");
98 jQuery(this).attr("class", "odd");
100 jQuery(this).children(":first").text(jQuery(this).index());
102 jQuery("#linkordervalidatebutton").show();
108 htmlCodeView: function() {
109 this.params.trHtmlCode.show();
110 this.params.trUrlCode.hide();
111 this.params.trIframeView.hide();
114 htmlUrlView: function() {
115 this.params.trHtmlCode.hide();
116 this.params.trUrlCode.show();
117 this.params.trIframeView.show();
120 inputHtmlCodeView: function() {
121 this.params.inputHtmlCode.prop('disabled', false);
124 validateLinkOrder: function() {
125 var linkOrder = jQuery("#sortable tbody").sortable('toArray').toString();
126 jQuery.get(this.params.headerMenuUrl, {
127 group_id: this.params.groupId,
128 action: 'validateOrder',
129 linkorder: linkOrder,
132 jQuery('#maindiv').prepend('<p class="feedback">Link Order successfully validated</p>');
133 this.params.validateButton.hide();
137 EditHeaderMenuController.prototype =
139 bindControls: function() {
140 this.params.inputHtmlCode.click(jQuery.proxy(this, "htmlCodeView"));
141 this.params.inputURL.click(jQuery.proxy(this, "htmlUrlView"));
142 if (typeof(this.params.inputOuter) != 'undefined') {
143 this.params.inputOuter.click(jQuery.proxy(this, "inputHtmlCodeView"));
145 if (typeof(this.params.inputHeader) != 'undefined') {
146 this.params.inputHeader.click(jQuery.proxy(this, "headerView"));
148 if (typeof(this.params.inputURLIframe) != 'undefined') {
149 this.params.inputURLIframe.click(jQuery.proxy(this, "htmlUrlView"));
153 initializeView: function() {
154 if (this.params.inputHeader.attr("checked")) {
155 this.params.inputHtmlCode.prop('disabled', true);
157 if (this.params.inputHtmlCode.attr("checked")) {
158 this.params.trHtmlCode.show();
159 this.params.trUrlCode.hide();
161 if (this.params.inputURL.attr("checked")) {
162 this.params.trHtmlCode.hide();
163 this.params.trUrlCode.show();
165 if (typeof(this.params.inputURLIframe) != 'undefined') {
166 if (this.params.inputURLIframe.attr("checked")) {
167 this.params.trHtmlCode.hide();
168 this.params.trUrlCode.show();
173 htmlUrlView: function() {
174 this.params.trHtmlCode.hide();
175 this.params.trUrlCode.show();
178 htmlCodeView: function() {
179 this.params.trHtmlCode.show();
180 this.params.trUrlCode.hide();
183 headerView: function() {
184 this.params.inputHtmlCode.prop('disabled', true);
185 this.params.trHtmlCode.hide();
186 this.params.trUrlCode.show();
187 this.params.inputURL.attr('checked', 'checked');
190 inputHtmlCodeView: function() {
191 this.params.inputHtmlCode.prop('disabled', false);