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"));
48 this.params.validOutButton.click(jQuery.proxy(this, "validateOutLinkOrder"));
49 this.params.validHeaButton.click(jQuery.proxy(this, "validateHeaLinkOrder"));
52 initializeView: function() {
53 this.params.inputHtmlCode.prop('disabled', true);
54 this.params.trHtmlCode.hide();
55 this.params.trUrlCode.show();
56 this.params.inputURL.attr('checked', 'checked');
57 if (typeof(this.params.tableOutTbLink) != 'undefined') {
58 this.params.tableOutTbLink.sortable({
59 update: function(event, ui) {
60 jQuery(".sortable_outermenu_listlinks tbody").children().each(function() {
61 if (jQuery(this).index() % 2 === 0) {
62 jQuery(this).attr("class", "even");
64 jQuery(this).attr("class", "odd");
66 jQuery(this).children(":first").text(jQuery(this).index());
68 jQuery("#linkorderoutervalidatebutton").show();
72 if (typeof(this.params.tableHeaTbLink) != 'undefined') {
73 this.params.tableHeaTbLink.sortable({
74 update: function(event, ui) {
75 jQuery(".sortable_headermenu_listlinks tbody").children().each(function() {
76 if (jQuery(this).index() % 2 === 0) {
77 jQuery(this).attr("class", "even");
79 jQuery(this).attr("class", "odd");
81 jQuery(this).children(":first").text(jQuery(this).index());
83 jQuery("#linkorderheadervalidatebutton").show();
89 htmlCodeView: function() {
90 this.params.trHtmlCode.show();
91 this.params.trUrlCode.hide();
94 htmlUrlView: function() {
95 this.params.trHtmlCode.hide();
96 this.params.trUrlCode.show();
99 inputHtmlCodeView: function() {
100 this.params.inputHtmlCode.prop('disabled', false);
103 validateOutLinkOrder: function() {
104 var linkOrder = jQuery(".sortable_outermenu_listlinks tbody").sortable('toArray').toString();
105 jQuery.get(this.params.headerMenuUrl, {
106 action: 'validateOrder',
107 linkorder: linkOrder,
110 jQuery('#validateLinkFeedback').remove();
111 jQuery('#maindiv').prepend('<p id="validateLinkFeedback" class="feedback">Outermenu Link Order successfully validated</p>');
112 this.params.validOutButton.hide();
115 validateHeaLinkOrder: function() {
116 var linkOrder = jQuery(".sortable_headermenu_listlinks tbody").sortable('toArray').toString();
117 jQuery.get(this.params.headerMenuUrl, {
118 action: 'validateOrder',
119 linkorder: linkOrder,
122 jQuery('#validateLinkFeedback').remove();
123 jQuery('#maindiv').prepend('<p id="validateLinkFeedback" class="feedback">Headermenu Link Order successfully validated</p>');
124 this.params.validHeaButton.hide();
128 GroupMenuController.prototype =
130 bindControls: function() {
131 this.params.inputHtmlCode.click(jQuery.proxy(this, "htmlCodeView"));
132 this.params.inputURL.click(jQuery.proxy(this, "htmlUrlView"));
133 this.params.validateButton.click(jQuery.proxy(this, "validateProjectLinkOrder"));
136 initializeView: function() {
137 this.params.trHtmlCode.hide();
138 this.params.trUrlCode.show();
139 this.params.inputURL.attr('checked', 'checked');
140 if (typeof(this.params.tableTbodyLink) != 'undefined') {
141 this.params.tableTbodyLink.sortable({
142 update: function(event, ui) {
143 jQuery("#sortable tbody").children().each(function() {
144 if (jQuery(this).index() % 2 === 0) {
145 jQuery(this).attr("class", "even");
147 jQuery(this).attr("class", "odd");
149 jQuery(this).children(":first").text(jQuery(this).index());
151 jQuery("#linkordervalidatebutton").show();
157 htmlCodeView: function() {
158 this.params.trHtmlCode.show();
159 this.params.trUrlCode.hide();
160 this.params.trIframeView.hide();
163 htmlUrlView: function() {
164 this.params.trHtmlCode.hide();
165 this.params.trUrlCode.show();
166 this.params.trIframeView.show();
169 inputHtmlCodeView: function() {
170 this.params.inputHtmlCode.prop('disabled', false);
173 validateProjectLinkOrder: function() {
174 var linkOrder = jQuery("#sortable tbody").sortable('toArray').toString();
175 jQuery.get(this.params.headerMenuUrl, {
176 group_id: this.params.groupId,
177 action: 'validateOrder',
178 linkorder: linkOrder,
181 jQuery('#validateLinkFeedback').remove();
182 jQuery('#maindiv').prepend('<p id="validateLinkFeedback" class="feedback">Link Order successfully validated</p>');
183 this.params.validateButton.hide();
187 EditHeaderMenuController.prototype =
189 bindControls: function() {
190 this.params.inputHtmlCode.click(jQuery.proxy(this, "htmlCodeView"));
191 this.params.inputURL.click(jQuery.proxy(this, "htmlUrlView"));
192 if (typeof(this.params.inputOuter) != 'undefined') {
193 this.params.inputOuter.click(jQuery.proxy(this, "inputHtmlCodeView"));
195 if (typeof(this.params.inputHeader) != 'undefined') {
196 this.params.inputHeader.click(jQuery.proxy(this, "headerView"));
198 if (typeof(this.params.inputURLIframe) != 'undefined') {
199 this.params.inputURLIframe.click(jQuery.proxy(this, "htmlUrlView"));
203 initializeView: function() {
204 if (this.params.inputHeader.attr("checked")) {
205 this.params.inputHtmlCode.prop('disabled', true);
207 if (this.params.inputHtmlCode.attr("checked")) {
208 this.params.trHtmlCode.show();
209 this.params.trUrlCode.hide();
211 if (this.params.inputURL.attr("checked")) {
212 this.params.trHtmlCode.hide();
213 this.params.trUrlCode.show();
215 if (typeof(this.params.inputURLIframe) != 'undefined') {
216 if (this.params.inputURLIframe.attr("checked")) {
217 this.params.trHtmlCode.hide();
218 this.params.trUrlCode.show();
223 htmlUrlView: function() {
224 this.params.trHtmlCode.hide();
225 this.params.trUrlCode.show();
228 htmlCodeView: function() {
229 this.params.trHtmlCode.show();
230 this.params.trUrlCode.hide();
233 headerView: function() {
234 this.params.inputHtmlCode.prop('disabled', true);
235 this.params.trHtmlCode.hide();
236 this.params.trUrlCode.show();
237 this.params.inputURL.attr('checked', 'checked');
240 inputHtmlCodeView: function() {
241 this.params.inputHtmlCode.prop('disabled', false);