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,
107 action: 'validateOrder',
108 linkorder: linkOrder,
111 jQuery.proxy(function(data) {
112 jQuery('.feedback').remove();
113 jQuery('.error').remove();
115 jQuery('#maindiv').prepend('<div class="actionresult"><p id="validateLinkMessage" class="feedback">'+this.params.validMessOut+'</p></div>');
117 jQuery('#maindiv').prepend('<p id="validateLinkMessage" class="error">'+this.params.errMessOut+'</p>');
119 jQuery("#linkorderoutervalidatebutton").hide();
124 validateHeaLinkOrder: function() {
125 var linkOrder = jQuery(".sortable_headermenu_listlinks tbody").sortable('toArray').toString();
126 jQuery.get(this.params.headerMenuUrl,
128 action: 'validateOrder',
129 linkorder: linkOrder,
132 jQuery.proxy(function(data) {
133 jQuery('.feedback').remove();
134 jQuery('.error').remove();
136 jQuery('#maindiv').prepend('<div class="actionresult"><p id="validateLinkMessage" class="feedback">'+this.params.validMessHea+'</p></div>');
138 jQuery('#maindiv').prepend('<p id="validateLinkMessage" class="error">'+this.params.errMessHea+'</p>');
140 jQuery("#linkorderheadervalidatebutton").hide();
146 GroupMenuController.prototype =
148 bindControls: function() {
149 this.params.inputHtmlCode.click(jQuery.proxy(this, "htmlCodeView"));
150 this.params.inputURL.click(jQuery.proxy(this, "htmlUrlView"));
151 this.params.validateButton.click(jQuery.proxy(this, "validateProjectLinkOrder"));
154 initializeView: function() {
155 this.params.trHtmlCode.hide();
156 this.params.trUrlCode.show();
157 this.params.inputURL.attr('checked', 'checked');
158 if (typeof(this.params.tableTbodyLink) != 'undefined') {
159 this.params.tableTbodyLink.sortable({
160 update: function(event, ui) {
161 jQuery("#sortable").find("tbody").children().each(function() {
162 if (jQuery(this).index() % 2 === 0) {
163 jQuery(this).attr("class", "even");
165 jQuery(this).attr("class", "odd");
167 jQuery(this).children(":first").text(jQuery(this).index());
169 jQuery("#linkordervalidatebutton").show();
175 htmlCodeView: function() {
176 this.params.trHtmlCode.show();
177 this.params.trUrlCode.hide();
178 this.params.trIframeView.hide();
181 htmlUrlView: function() {
182 this.params.trHtmlCode.hide();
183 this.params.trUrlCode.show();
184 this.params.trIframeView.show();
187 inputHtmlCodeView: function() {
188 this.params.inputHtmlCode.prop('disabled', false);
191 validateProjectLinkOrder: function() {
192 var linkOrder = jQuery("#sortable").find("tbody").sortable('toArray').toString();
193 jQuery.get(this.params.headerMenuUrl,
195 group_id: this.params.groupId,
196 action: 'validateOrder',
197 linkorder: linkOrder,
200 jQuery.proxy(function(data) {
201 jQuery('.feedback').remove();
202 jQuery('.error').remove();
204 jQuery('#maindiv').prepend('<div class="actionresult"><p id="validateLinkMessage" class="feedback">'+this.params.validMessage+'</p></div>');
206 jQuery('#maindiv').prepend('<p id="validateLinkMessage" class="error">'+this.params.errorMessage+'</p>');
208 this.params.validateButton.hide();
215 EditHeaderMenuController.prototype =
217 bindControls: function() {
218 this.params.inputHtmlCode.click(jQuery.proxy(this, "htmlCodeView"));
219 this.params.inputURL.click(jQuery.proxy(this, "htmlUrlView"));
220 if (typeof(this.params.inputOuter) != 'undefined') {
221 this.params.inputOuter.click(jQuery.proxy(this, "inputHtmlCodeView"));
223 if (typeof(this.params.inputHeader) != 'undefined') {
224 this.params.inputHeader.click(jQuery.proxy(this, "headerView"));
226 if (typeof(this.params.inputURLIframe) != 'undefined') {
227 this.params.inputURLIframe.click(jQuery.proxy(this, "htmlUrlView"));
231 initializeView: function() {
232 if (this.params.inputHeader.attr("checked")) {
233 this.params.inputHtmlCode.prop('disabled', true);
235 if (this.params.inputHtmlCode.attr("checked")) {
236 this.params.trHtmlCode.show();
237 this.params.trUrlCode.hide();
239 if (this.params.inputURL.attr("checked")) {
240 this.params.trHtmlCode.hide();
241 this.params.trUrlCode.show();
243 if (typeof(this.params.inputURLIframe) != 'undefined') {
244 if (this.params.inputURLIframe.attr("checked")) {
245 this.params.trHtmlCode.hide();
246 this.params.trUrlCode.show();
251 htmlUrlView: function() {
252 this.params.trHtmlCode.hide();
253 this.params.trUrlCode.show();
256 htmlCodeView: function() {
257 this.params.trHtmlCode.show();
258 this.params.trUrlCode.hide();
261 headerView: function() {
262 this.params.inputHtmlCode.prop('disabled', true);
263 this.params.trHtmlCode.hide();
264 this.params.trUrlCode.show();
265 this.params.inputURL.attr('checked', 'checked');
268 inputHtmlCodeView: function() {
269 this.params.inputHtmlCode.prop('disabled', false);