]>
git.agnieray.net Git - galette.git/blob - galette/webroot/js/common.js
2 * Copyright © 2007-2014 The Galette Team
4 * This file is part of Galette (http://galette.tuxfamily.org).
6 * Galette is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * Galette is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
19 * @category Javascript
22 * @author Johan Cwiklinski <johan@x-tnd.be>
23 * @copyright 2007-2014 The Galette Team
24 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
25 * @link http://galette.tuxfamily.org
26 * @since Available since 0.7dev - 2007-10-06
29 //set up fieldsets spindowns
30 //the function will spin the element just after legend, and will update the icon
31 $.fn
.spinDown = function() {
33 return this.click(function() {
36 $this.parent('legend').next().slideToggle(100);
37 var __i
= $this.find('i');
38 __i
.toggleClass('fa-arrow-alt-circle-down').toggleClass('fa-arrow-alt-circle-right');
45 //make fieldsets collapsibles. This requires a legend and all the following elements to be grouped (for example in a div element)
46 //The function will 'hide'
47 var _collapsibleFieldsets = function(){
48 $('legend').each(function(){
49 var _collapse
= $('<a href="#" class="collapsible tooltip"><i class="fas fa-arrow-alt-circle-down"></i> <span class="sr-only">Collapse/Expand</span></a>');
50 $(this).prepend(_collapse
);
55 var _fieldsInSortable = function(){
56 //so our forms elements continue to work as expected
57 $('.fields_list input, .fields_list select').bind(
58 'click.sortable mousedown.sortable',
66 var _initSortable = function(){
67 $('.fields_list').sortable({
68 items
: 'li:not(.listing)'
69 }).disableSelection();
73 $('#members_tab').sortable({
79 -------------------------------------------------------- */
81 var _messagesEffects = function(){
85 $('#errorbox').backgroundFade({sColor
:'#ffffff',eColor
:'#ff9999',steps
:50},function() {
86 $(this).backgroundFade({sColor
:'#ff9999',eColor
:'#ffffff'});
88 $('#warningbox').backgroundFade({sColor
:'#ffffff',eColor
:'#FFB619',steps
:50},function() {
89 $(this).backgroundFade({sColor
:'#FFB619',eColor
:'#ffffff'});
91 $('#infobox, #successbox').backgroundFade({sColor
:'#ffffff',eColor
:'#99FF99',steps
:50},function() {
92 $(this).backgroundFade({sColor
:'#99FF99',eColor
:'#ffffff'});
96 var _bind_check = function(boxelt
){
97 if (typeof(boxelt
) == 'undefined') {
100 var _is_checked
= true;
101 $('.checkall').click(function(){
102 $('table.listing :checkbox[name="' + boxelt
+ '[]"]').each(function(){
103 this.checked
= _is_checked
;
105 _is_checked
= !_is_checked
;
108 $('.checkinvert').click(function(){
109 $('table.listing :checkbox[name="' + boxelt
+ '[]"]').each(function(){
110 this.checked
= !$(this).is(':checked');
116 var _bind_legend = function() {
117 $('#legende h1').remove();
118 $('#legende').dialog({
123 create: function (event
, ui
) {
124 if ($(window
).width() < 767) {
125 $(this).dialog('option', {
133 $('.show_legend').click(function(e
){
135 $('#legende').dialog('open');
140 var _initTooltips = function(selector
) {
141 if (typeof(selector
) == 'undefined') {
144 selector
= selector
+ ' ';
148 //first, we hide tooltips in the page
149 $(selector
+ '.tip').hide();
150 $(selector
+ ' label.tooltip, ' + selector
+ ' span.bline.tooltip').each(function() {
151 var __i
= $('<i class="fas fa-exclamation-circle"></i>')
154 //and then, we show them on rollover
155 $(document
).tooltip({
156 items
: selector
+ ".tooltip, a[title]",
157 content: function(event
, ui
) {
161 //first, value from @class=tip element
162 var _next
= _this
.nextAll('.tip');
163 if (_next
.length
> 0) {
164 _content
= _next
.html();
167 //and finally, value from @class=sr-only element
168 if (typeof _content
== 'undefined') {
169 var _sronly
= _this
.find('.sr-only');
170 if (_sronly
.length
> 0) {
171 _content
= _sronly
.html();
175 //second, value from @title
176 if (typeof _content
== 'undefined') {
177 var _title
= _this
.attr('title');
178 if (typeof _title
!= 'undefined') {
190 $('.debuginfos span').hide();
191 /** TODO: find a way to translate this message ==> ajax ? */
192 $('.debuginfos').attr('title', 'Click to get more details.');
193 $('.debuginfos').click(function(){
194 $('.debuginfos span').slideToggle('slow');
200 $('select:not(.nochosen)').selectize({
204 $('.nojs').removeClass('nojs');
205 $('#menu h1').each(function(){
206 $(this).html('<a href="#">' + $(this).text() + '</a>');
209 if( $('#menu').length
> 0 ) {
210 $('#menu').accordion({
211 header
: 'h1:not(#logo)',
212 heightStyle
: 'content',
213 active
: $('#menu ul li[class*="selected"]').parent('ul').prevAll('ul').length
217 $('input:submit, .button, input:reset, button:submit' ).button({
218 create: function(event
, ui
) {
219 if ( $(event
.target
).hasClass('disabled') ) {
220 $(event
.target
).button('disable');
225 if ( $('#back2top').length
> 0 ) {
226 if (!$('#wrapper').scrollTop() && !$('html').scrollTop() ) {
227 $('#back2top').fadeOut();
229 $(window
).scroll(function() {
230 if ($(this).scrollTop()) {
231 $('#back2top').fadeIn();
233 $('#back2top').fadeOut();
238 $('select#lang_selector').change(function() {
242 /* Language selector.
243 * Works per default with CSS only, use javascript to replace with a click event,
244 * which is required because of the current way the menu is hidden on mobile devices.
246 $('#plang_selector').removeClass('onhover');
247 var _langs
= $('#plang_selector ul');
250 $('#plang_selector > a').on('click', function(event
) {
251 event
.preventDefault();
253 var _open
= _this
.attr('aria-expanded');
254 _this
.attr('aria-expanded', !open
);