]>
git.agnieray.net Git - galette.git/blob - galette/webroot/js/common.js
759395e2af799674abf492cde5516299b5ff6dd4
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
26 * @link http://galette.tuxfamily.org
27 * @since Available since 0.7dev - 2007-10-06
30 //set up fieldsets spindowns
31 //the function will spin the element just after legend, and will update the icon
32 $.fn
.spinDown = function() {
34 return this.click(function() {
37 $this.parent('legend').next().slideToggle(100);
38 var __i
= $this.find('i');
39 __i
.toggleClass('fa-arrow-alt-circle-down').toggleClass('fa-arrow-alt-circle-right');
46 //make fieldsets collapsibles. This requires a legend and all the following elements to be grouped (for example in a div element)
47 //The function will 'hide'
48 var _collapsibleFieldsets = function(){
49 $('legend').each(function(){
50 var _collapse
= $('<a href="#" class="collapsible tooltip"><i class="fas fa-arrow-alt-circle-down"></i> <span class="sr-only">Collapse/Expand</span></a>');
51 $(this).prepend(_collapse
);
56 var _fieldsInSortable = function(){
57 //so our forms elements continue to work as expected
58 $('.fields_list input, .fields_list select').bind(
59 'click.sortable mousedown.sortable',
67 var _initSortable = function(){
68 $('.fields_list').sortable({
69 items
: 'li:not(.listing)'
70 }).disableSelection();
74 $('#members_tab').sortable({
80 -------------------------------------------------------- */
82 var _messagesEffects = function(){
86 $('#errorbox').backgroundFade({sColor
:'#ffffff',eColor
:'#ff9999',steps
:50},function() {
87 $(this).backgroundFade({sColor
:'#ff9999',eColor
:'#ffffff'});
89 $('#warningbox').backgroundFade({sColor
:'#ffffff',eColor
:'#FFB619',steps
:50},function() {
90 $(this).backgroundFade({sColor
:'#FFB619',eColor
:'#ffffff'});
92 $('#infobox, #successbox').backgroundFade({sColor
:'#ffffff',eColor
:'#99FF99',steps
:50},function() {
93 $(this).backgroundFade({sColor
:'#99FF99',eColor
:'#ffffff'});
97 var _bind_check = function(boxelt
){
98 if (typeof(boxelt
) == 'undefined') {
101 var _is_checked
= true;
102 $('.checkall').click(function(){
103 $('table.listing :checkbox[name="' + boxelt
+ '[]"]').each(function(){
104 this.checked
= _is_checked
;
106 _is_checked
= !_is_checked
;
109 $('.checkinvert').click(function(){
110 $('table.listing :checkbox[name="' + boxelt
+ '[]"]').each(function(){
111 this.checked
= !$(this).is(':checked');
117 var _bind_legend = function() {
118 $('#legende h1').remove();
119 $('#legende').dialog({
124 create: function (event
, ui
) {
125 if ($(window
).width() < 767) {
126 $(this).dialog('option', {
134 $('.show_legend').click(function(e
){
136 $('#legende').dialog('open');
141 var _initTooltips = function(selector
) {
142 if (typeof(selector
) == 'undefined') {
145 selector
= selector
+ ' ';
149 //first, we hide tooltips in the page
150 $(selector
+ '.tip').hide();
151 $(selector
+ ' label.tooltip, ' + selector
+ ' span.bline.tooltip').each(function() {
152 var __i
= $('<i class="fas fa-exclamation-circle"></i>')
155 //and then, we show them on rollover
156 $(document
).tooltip({
157 items
: selector
+ ".tooltip, a[title]",
158 content: function(event
, ui
) {
162 //first, value from @class=tip element
163 var _next
= _this
.nextAll('.tip');
164 if (_next
.length
> 0) {
165 _content
= _next
.html();
168 //and finally, value from @class=sr-only element
169 if (typeof _content
== 'undefined') {
170 var _sronly
= _this
.find('.sr-only');
171 if (_sronly
.length
> 0) {
172 _content
= _sronly
.html();
176 //second, value from @title
177 if (typeof _content
== 'undefined') {
178 var _title
= _this
.attr('title');
179 if (typeof _title
!= 'undefined') {
191 $('.debuginfos span').hide();
192 /** TODO: find a way to translate this message ==> ajax ? */
193 $('.debuginfos').attr('title', 'Click to get more details.');
194 $('.debuginfos').click(function(){
195 $('.debuginfos span').slideToggle('slow');
201 $('select:not(.nochosen)').selectize({
205 $('.nojs').removeClass('nojs');
206 $('#menu h1').each(function(){
207 $(this).html('<a href="#">' + $(this).text() + '</a>');
210 if( $('#menu').length
> 0 ) {
211 $('#menu').accordion({
212 header
: 'h1:not(#logo)',
213 heightStyle
: 'content',
214 active
: $('#menu ul li[class*="selected"]').parent('ul').prevAll('ul').length
218 $('input:submit, .button, input:reset, button:submit' ).button({
219 create: function(event
, ui
) {
220 if ( $(event
.target
).hasClass('disabled') ) {
221 $(event
.target
).button('disable');
226 if ( $('#back2top').length
> 0 ) {
227 if (!$('#wrapper').scrollTop() && !$('html').scrollTop() ) {
228 $('#back2top').fadeOut();
230 $(window
).scroll(function() {
231 if ($(this).scrollTop()) {
232 $('#back2top').fadeIn();
234 $('#back2top').fadeOut();
239 $('select#lang_selector').change(function() {
243 /* Language selector.
244 * Works per default with CSS only, use javascript to replace with a click event,
245 * which is required because of the current way the menu is hidden on mobile devices.
247 $('#plang_selector').removeClass('onhover');
248 var _langs
= $('#plang_selector ul');
251 $('#plang_selector > a').on('click', function(event
) {
252 event
.preventDefault();
254 var _open
= _this
.attr('aria-expanded');
255 _this
.attr('aria-expanded', !open
);