Dotclear

source: plugins/widgets/dragdrop.js @ 2980:aef1340d89e3

Revision 2980:aef1340d89e3, 2.2 KB checked in by Nicolas <nikrou77@…>, 10 years ago (diff)

Usual oops. Incorrect javascript comment

Line 
1/*
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2015 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12*/
13
14$(function() {
15
16     // clean
17     $('.remove-if-drag').remove();
18     $('.hidden-if-drag').hide();
19     $('.widgets, .sortable-delete').addClass('if-drag');
20
21     // move
22     $( ".connected, .sortable-delete" ).sortable({
23          tolerance: "move",
24          cursor: "move",
25          axis: "y",
26          dropOnEmpty: true,
27          handle: ".widget-name",
28          placeholder: "ui-sortable-placeholder",
29          items: "li:not(.sortable-delete-placeholder,.empty-widgets)",
30          connectWith: ".connected, .sortable-delete",
31          start: function( event, ui ) {
32               // petit décalage esthétique
33               ui.item.css('left', ui.item.position().left + 20);
34          },
35          update: function(event, ui) {
36               ul = $(this);
37               widget = ui.item;
38               field = ul.parents('.widgets');
39
40               // met a zéro le décalage
41               ui.item.css('left', 'auto');
42               // Fixes issue #2080
43               ui.item.css('width', 'auto');
44               ui.item.css('height', 'auto');
45
46               // signale les zones vides
47               if( ul.find('li:not(.empty-widgets)').length == 0 ) {
48                    ul.find('li.empty-widgets').show();
49                    field.find('ul.sortable-delete').hide();
50               } else {
51                    ul.find('li.empty-widgets').hide();
52                    field.find('ul.sortable-delete').show();
53               }
54
55               // remove
56               if( widget.parents('ul').is('.sortable-delete') ) {
57                    widget.hide('slow', function() {
58                         $(this).remove();
59                    });
60               }
61
62               // réordonne
63               reorder(ul);
64
65               // expand
66               if(widget.find('img.expand').length == 0) {
67                    dotclear.postExpander(widget);
68                    dotclear.viewPostContent(widget, 'close');
69               }
70          }
71     });
72
73     // add
74     $( "#widgets-ref > li" ).draggable({
75          tolerance: "move",
76          cursor: "move",
77          connectToSortable: ".connected",
78          helper: "clone",
79          revert: "invalid",
80          start: function( event, ui ) {
81               ui.helper.css({'width': $('#widgets-ref > li').css('width')});
82          }
83     });
84
85     $("li.ui-draggable, ul.ui-sortable li")
86          .not('ul.sortable-delete li, li.empty-widgets')
87          .css({'cursor':'move'});
88});
Note: See TracBrowser for help on using the repository browser.

Sites map