1 | //jQuery( function($) {
|
---|
2 | //$('div.blockWrapper').iNestedSortable(
|
---|
3 | // {
|
---|
4 | // accept: 'block',
|
---|
5 | // }
|
---|
6 | //);
|
---|
7 | //});
|
---|
8 |
|
---|
9 | console.log("Loading gui_div.js\n");
|
---|
10 |
|
---|
11 | $(document).ready(function(){
|
---|
12 |
|
---|
13 | console.log("Document ready function\n");
|
---|
14 |
|
---|
15 | $('a.minmax').bind('click', toggleContent);
|
---|
16 | $('a.remove').bind('click', removeContent);
|
---|
17 |
|
---|
18 | $(".elementType").draggable({
|
---|
19 | connectToSortable: '.gsf_template',
|
---|
20 | helper: 'clone',
|
---|
21 | revert: 'invalid',
|
---|
22 | //start: function(event, ui) { ui.item.addClass('replaceMe');},
|
---|
23 | stop: function(event, ui) {
|
---|
24 | console.log("Stopped dragging - do we want to create element?"+ui.helper);
|
---|
25 | ui.helper.addClass('replaceMe');
|
---|
26 | },
|
---|
27 | });
|
---|
28 |
|
---|
29 | /*
|
---|
30 | $('.elementType').sortable({
|
---|
31 | cursor: 'pointer',
|
---|
32 | tolerance: 'pointer',
|
---|
33 | //placeholder:'placeholder',
|
---|
34 | connectWith:'.gsf_template',
|
---|
35 | //cancel: '.elementType',
|
---|
36 |
|
---|
37 | start: function(event, ui) {
|
---|
38 | $(this).clone().insertAfter(this);;
|
---|
39 | },
|
---|
40 |
|
---|
41 | });
|
---|
42 | */
|
---|
43 |
|
---|
44 | function templateAdded() {
|
---|
45 | var item = $('.elementType');
|
---|
46 | // do something with "item" - its your new pretty cloned dropped item ;]
|
---|
47 | item.replaceWith('<h2>REPLACED</h2>');
|
---|
48 | //item.addClass( 'added' );
|
---|
49 | };
|
---|
50 |
|
---|
51 | $('#formatStatement').sortable({
|
---|
52 | cursor: 'pointer',
|
---|
53 | tolerance: 'pointer',
|
---|
54 | items: '.gsf_template',
|
---|
55 | placeholder:'placeholder'
|
---|
56 | //'nested':'div'
|
---|
57 | });
|
---|
58 |
|
---|
59 | $('.gsf_template').sortable({
|
---|
60 | 'cursor':'pointer',
|
---|
61 | 'tolerance': 'pointer',
|
---|
62 | 'items':'.table, .gsf_choose-metadata, .gsf_metadata',
|
---|
63 | 'placeholder':'placeholder',
|
---|
64 | //'nested':'.gsf:metadata'
|
---|
65 | stop: function(event, ui) {
|
---|
66 | if (ui.item.hasClass("elementType") && ui.item.hasClass('css_gsf_template')) {
|
---|
67 | ui.item.replaceWith(gsf_metadata_element); //'<div class="element element-txt">This text box has been added!</div>');
|
---|
68 | //ui.item.style.border =
|
---|
69 | }
|
---|
70 | }
|
---|
71 |
|
---|
72 | //receive: function(event, ui) {
|
---|
73 | // console.log("I have received an item");
|
---|
74 | //var item = $('.ui_sortable/.elementType');
|
---|
75 | // var item = $('.div/.elementType'); //css_gsf_template not(.gsf_template)');
|
---|
76 | // console.log(item);
|
---|
77 | //item.replaceWith('<h2>REPLACED</h2>');
|
---|
78 | //}
|
---|
79 |
|
---|
80 | });
|
---|
81 |
|
---|
82 | $('.td').sortable({
|
---|
83 | 'cursor':'pointer',
|
---|
84 | 'tolerance': 'pointer',
|
---|
85 | 'items':'.leaf .gsf_choose-metadata, .gsf_link, .gsf_switch',
|
---|
86 | 'placeholder':'placeholder'
|
---|
87 | //'nested':'.gsf:metadata'
|
---|
88 | });
|
---|
89 |
|
---|
90 | $('.gsf_choose-metadata').sortable({
|
---|
91 | 'cursor':'pointer',
|
---|
92 | 'tolerance': 'pointer',
|
---|
93 | 'items':'.gsf_metadata',
|
---|
94 | 'placeholder':'placeholder',
|
---|
95 | 'connectWith':'.gsf_choose-metadata'
|
---|
96 | //'nested':'.gsf:metadata'
|
---|
97 | });
|
---|
98 |
|
---|
99 | $('.gsf_link').sortable({
|
---|
100 | 'cursor':'pointer',
|
---|
101 | 'tolerance': 'pointer',
|
---|
102 | 'items':'.gsf_icon',
|
---|
103 | 'placeholder':'placeholder'
|
---|
104 | //'nested':'.gsf:metadata'
|
---|
105 | });
|
---|
106 |
|
---|
107 | $('.gsf_switch').sortable({
|
---|
108 | 'cursor':'pointer',
|
---|
109 | 'tolerance': 'pointer',
|
---|
110 | 'items':'.gsf_metadata, .gsf_when, .gsf_otherwise',
|
---|
111 | 'placeholder':'placeholder'
|
---|
112 | //'nested':'.gsf:metadata'
|
---|
113 | });
|
---|
114 |
|
---|
115 | $('.gsf_when').sortable({
|
---|
116 | 'cursor':'pointer',
|
---|
117 | 'tolerance': 'pointer',
|
---|
118 | 'items':'.leaf',
|
---|
119 | 'placeholder':'placeholder'
|
---|
120 | //'nested':'.gsf:metadata'
|
---|
121 | });
|
---|
122 |
|
---|
123 | $('.gsf_otherwise').sortable({
|
---|
124 | 'cursor':'pointer',
|
---|
125 | 'tolerance': 'pointer',
|
---|
126 | 'items':'.leaf',
|
---|
127 | 'placeholder':'placeholder'
|
---|
128 | //'nested':'.gsf:metadata'
|
---|
129 | });
|
---|
130 |
|
---|
131 | //$(".resizable").resizable({containment: 'parent', alsoResize:'parent'});
|
---|
132 |
|
---|
133 | $('.tr').equalHeights();
|
---|
134 |
|
---|
135 | $(".td").resizable({
|
---|
136 | alsoResize: 'parent',
|
---|
137 | //containment: 'parent',
|
---|
138 | handles: 'e,s',
|
---|
139 | stop: function(event, ui) {
|
---|
140 | $(this).parent().parent().equalHeights();
|
---|
141 | }, });
|
---|
142 |
|
---|
143 |
|
---|
144 | $(".block").mouseover(function()
|
---|
145 | {
|
---|
146 | //alert("Mouse over event");
|
---|
147 | $(this).parents().css("border", "");
|
---|
148 | $(this).css("border", "1px solid blue");
|
---|
149 | return false;
|
---|
150 | }).mouseout(function(){
|
---|
151 | $(this).css("border", "");
|
---|
152 | return false;
|
---|
153 | });
|
---|
154 |
|
---|
155 | });
|
---|
156 |
|
---|
157 | var removeContent = (function () {
|
---|
158 | //var parentTag = $(this).parent().get(0).titleName;
|
---|
159 | //alert("Removing div " + parentTag);
|
---|
160 | $(this).parent().remove();
|
---|
161 | });
|
---|
162 |
|
---|
163 |
|
---|
164 | var toggleContent = function(e)
|
---|
165 | {
|
---|
166 | var targetContent = $('div.block', this.parentNode);
|
---|
167 | if (targetContent.css('display') == 'none') {
|
---|
168 | targetContent.slideDown(300);
|
---|
169 | $(this).html('[-]');
|
---|
170 | } else {
|
---|
171 | targetContent.slideUp(300);
|
---|
172 | $(this).html('[+]');
|
---|
173 | }
|
---|
174 | return false;
|
---|
175 | };
|
---|
176 |
|
---|
177 | function serialize(s)
|
---|
178 | {
|
---|
179 | serial = $.SortSerialize(s);
|
---|
180 | alert(serial.hash);
|
---|
181 | };
|
---|
182 |
|
---|
183 | /*--------------------------------------------------------------------
|
---|
184 | * JQuery Plugin: "EqualHeights"
|
---|
185 | * by: Scott Jehl, Todd Parker, Maggie Costello Wachs (http://www.filamentgroup.com)
|
---|
186 | *
|
---|
187 | * Copyright (c) 2008 Filament Group
|
---|
188 | * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
|
---|
189 | *
|
---|
190 | * Description: Compares the heights or widths of the top-level children of a provided element
|
---|
191 | and sets their min-height to the tallest height (or width to widest width). Sets in em units
|
---|
192 | by default if pxToEm() method is available.
|
---|
193 | * Dependencies: jQuery library, pxToEm method (article:
|
---|
194 | http://www.filamentgroup.com/lab/retaining_scalable_interfaces_with_pixel_to_em_conversion/)
|
---|
195 | * Usage Example: $(element).equalHeights();
|
---|
196 | Optional: to set min-height in px, pass a true argument: $(element).equalHeights(true);
|
---|
197 | * Version: 2.0, 08.01.2008
|
---|
198 | --------------------------------------------------------------------*/
|
---|
199 |
|
---|
200 | // Modified to get children of children ie. tr -> td -> div
|
---|
201 |
|
---|
202 | $.fn.equalHeights = function(px) {
|
---|
203 | console.log("EQUAL HEIGHTS");
|
---|
204 | $(this).each(function(){
|
---|
205 | var currentTallest = 0;
|
---|
206 | console.log($(this).children());
|
---|
207 | console.log($(this).children().children());
|
---|
208 | //$(this).children().children().each(function(i){
|
---|
209 | // console.log($(this));
|
---|
210 | // console.log("THIS HEIGHT="+$(this).height()+ " CURRENT TALLEST="+ currentTallest);
|
---|
211 | //if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
|
---|
212 | //if ($(this).height() > currentTallest) { currentTallest = $(this).height(); }
|
---|
213 | //});
|
---|
214 | //if (!px || !Number.prototype.pxToEm) currentTallest = currentTallest.pxToEm(); //use ems unless px is specified
|
---|
215 | // for ie6, set height since min-height isn't supported
|
---|
216 | //if ($.browser.msie && $.browser.version == 6.0) { $(this).children().children().css({'height': $(this).currentTallest}); }
|
---|
217 | $(this).children().children().css({'height': $(this).height()}); //currentTallest});
|
---|
218 | });
|
---|
219 | return this;
|
---|
220 | };
|
---|
221 |
|
---|