aboutsummaryrefslogtreecommitdiff
path: root/javascript
diff options
context:
space:
mode:
authorpete <pete@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-18 13:03:08 +0000
committerpete <pete@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-06-18 13:03:08 +0000
commit64876aa88b223a8f368a7669b7e129847248fab7 (patch)
tree22ad3c34ed5b8b0e4977778ab41a07703bc3725b /javascript
parent09fba458f79b8b1b1940405911915feade1989bf (diff)
downloadelgg-64876aa88b223a8f368a7669b7e129847248fab7.tar.gz
elgg-64876aa88b223a8f368a7669b7e129847248fab7.tar.bz2
widget drag n drop
git-svn-id: https://code.elgg.org/elgg/trunk@962 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'javascript')
-rw-r--r--javascript/initialise_elgg.js58
1 files changed, 47 insertions, 11 deletions
diff --git a/javascript/initialise_elgg.js b/javascript/initialise_elgg.js
index 15aa40396..a8905a162 100644
--- a/javascript/initialise_elgg.js
+++ b/javascript/initialise_elgg.js
@@ -27,13 +27,15 @@ $(document).ready(function () {
// click function for customise panel - remove widget
$('img.remove_me').click(function () {
- //$(this.parentNode.parentNode.parentNode.parentNode.parentNode).fadeOut("medium");
$(this.parentNode.parentNode.parentNode.parentNode.parentNode).fadeOut("medium", function () {
$(this).remove();
- var widgetNameMain = ($('#main_widgets').text()).replace(/[\n]/g, ',');
- var widgetNameRight = ($('#rightsidebar_widgets').text()).replace(/[\n]/g, ',');
+
+ var widgetNameMain = outputWidgetList('#main_widgets');
document.getElementById('debugField1').value = widgetNameMain;
+
+ var widgetNameRight = outputWidgetList('#rightsidebar_widgets');
document.getElementById('debugField2').value = widgetNameRight;
+
});
return false;
@@ -61,9 +63,8 @@ $(document).ready(function () {
stop: function(e,ui) {
$(this).sortable( "refresh" );
- var widgetNameMain = ($('#main_widgets').text()).replace(/[\n]/g, ',');
- var widgetNameRight = ($('#rightsidebar_widgets').text()).replace(/[\n]/g, ',');
- //alert('widgetName = ' +widgetName);
+ var widgetNameRight = outputWidgetList('#rightsidebar_widgets');
+ var widgetNameMain = outputWidgetList('#main_widgets');
document.getElementById('debugField1').value = widgetNameMain;
document.getElementById('debugField2').value = widgetNameRight;
}
@@ -89,13 +90,15 @@ $(document).ready(function () {
$('img.remove_me').click(function () {
$(this.parentNode.parentNode.parentNode.parentNode.parentNode).fadeOut("medium", function () {
$(this).remove();
- var widgetNameMain = ($('#rightsidebar_widgets').text()).replace(/[\n]/g, ',');
- document.getElementById('debugField2').value = widgetNameMain;
+
+ var widgetNameRight = outputWidgetList('#rightsidebar_widgets');
+ document.getElementById('debugField2').value = widgetNameRight;
});
return false;
});
$els.sortable( "refresh" );
- var widgetNameRight = ($('#rightsidebar_widgets').text()).replace(/[\n]/g, ',');
+
+ var widgetNameRight = outputWidgetList('#rightsidebar_widgets');
document.getElementById('debugField2').value = widgetNameRight;
}
});
@@ -108,14 +111,16 @@ $(document).ready(function () {
$('img.remove_me').click(function () {
$(this.parentNode.parentNode.parentNode.parentNode.parentNode).fadeOut("medium", function () {
$(this).remove();
- var widgetNameMain = ($('#main_widgets').text()).replace(/[\n]/g, ',');
+
+ var widgetNameMain = outputWidgetList('#main_widgets');
document.getElementById('debugField1').value = widgetNameMain;
});
return false;
});
$els.sortable( "refresh" );
- var widgetNameMain = ($('#main_widgets').text()).replace(/[\n]/g, ',');
+
+ var widgetNameMain = outputWidgetList('#main_widgets');
document.getElementById('debugField1').value = widgetNameMain;
}
});
@@ -123,6 +128,34 @@ $(document).ready(function () {
});
+
+jQuery.fn.makeDelimitedList = function(elementAttribute) {
+
+ var delimitedListArray = new Array();
+
+ var listDelimiter = "::";
+
+ // Loop over each element in the stack and add the elementAttribute to the array
+ this.each(function(e) {
+ var listElement = $(this);
+
+ // Add the attribute value to our values array
+ delimitedListArray[delimitedListArray.length] = listElement.attr(elementAttribute);
+ }
+ );
+
+ // Return value list by joining the array
+ return(delimitedListArray.join(listDelimiter));
+}
+
+
+function outputWidgetList(forElement) {
+ //return( $("input[@name='handler']", forElement ).makeDelimitedList("value") );
+ return( $("input[@name='handler'], input[@name='guid']", forElement ).makeDelimitedList("value") );
+
+}
+
+
// toggle box content
var toggleContent = function(e) {
var targetContent = $('div.collapsable_box_content', this.parentNode.parentNode);
@@ -140,3 +173,6 @@ var toggleContent = function(e) {
}
return false;
};
+
+
+