Permalink
Browse files

5.0.0

- big code cleaning
- majority of properties, methods and event handlers are renamed
(camelCase syntax is used)
- added option to set delete confirmation question (for deleting DIV
element and row)
  • Loading branch information...
1 parent 6f18a72 commit a7952290bf9384afa6d1611af0447fd2b6164913 @dbunic committed Oct 30, 2012
View
@@ -1,5 +1,10 @@
Changes for REDIPS.drag library
+5.0.0
+- big code cleaning
+- majority of properties, methods and event handlers are renamed (camelCase syntax is used)
+- added option to set delete confirmation question (for deleting DIV element and row)
+
4.7.6
- added event handler myhandler_relocated() - event can be triggered after single call of relocate() method or after all DIV elements are shifted in "shift" mode
View
@@ -130,14 +130,14 @@
</table>
<div><input type="button" value="Save1" class="button" onclick="save('plain')" title="Send content to the server (it will only show accepted parameters)"/><span class="message_line">Save content of the first table (plain query string)</span></div>
<div><input type="button" value="Save2" class="button" onclick="save('json')" title="Send content to the server (it will only show accepted parameters)"/><span class="message_line">Save content of the first table (JSON format)</span></div>
- <div><input type="radio" name="drop_option" class="checkbox" onclick="set_drop_option(this)" value="multiple" title="Enabled dropping to already taken table cells" checked="true"/><span class="message_line">Enable dropping to already taken table cells</span></div>
- <div><input type="radio" name="drop_option" class="checkbox" onclick="set_drop_option(this)" value="single" title="Disabled dropping to already taken table cells"/><span class="message_line">Disable dropping to already taken table cells</span></div>
- <div><input type="radio" name="drop_option" class="checkbox" onclick="set_drop_option(this)" value="switch" title="Switch content"/><span class="message_line">Switch content</span></div>
- <div><input type="radio" name="drop_option" class="checkbox" onclick="set_drop_option(this)" value="switching" title="Switching content continuously"/><span class="message_line">Switching content continuously</span></div>
- <div><input type="radio" name="drop_option" class="checkbox" onclick="set_drop_option(this)" value="overwrite" title="Overwrite content"/><span class="message_line">Overwrite content</span></div>
- <div><input type="checkbox" class="checkbox" onclick="toggle_delete_cloned(this)" title="Remove cloned object if dragged outside of any table" checked="true"/><span class="message_line">Remove cloned element if dragged outside of any table</span></div>
- <div><input type="checkbox" class="checkbox" onclick="toggle_confirm(this)" title="Confirm delete" checked="true"/><span class="message_line">Confirm delete</span></div>
- <div><input type="checkbox" class="checkbox" onclick="toggle_dragging(this)" title="Enable dragging" checked="true"/><span class="message_line">Enable dragging</span></div>
+ <div><input type="radio" name="drop_option" class="checkbox" onclick="setMode(this)" value="multiple" title="Enabled dropping to already taken table cells" checked="true"/><span class="message_line">Enable dropping to already taken table cells</span></div>
+ <div><input type="radio" name="drop_option" class="checkbox" onclick="setMode(this)" value="single" title="Disabled dropping to already taken table cells"/><span class="message_line">Disable dropping to already taken table cells</span></div>
+ <div><input type="radio" name="drop_option" class="checkbox" onclick="setMode(this)" value="switch" title="Switch content"/><span class="message_line">Switch content</span></div>
+ <div><input type="radio" name="drop_option" class="checkbox" onclick="setMode(this)" value="switching" title="Switching content continuously"/><span class="message_line">Switching content continuously</span></div>
+ <div><input type="radio" name="drop_option" class="checkbox" onclick="setMode(this)" value="overwrite" title="Overwrite content"/><span class="message_line">Overwrite content</span></div>
+ <div><input type="checkbox" class="checkbox" onclick="toggleDeleteCloned(this)" title="Remove cloned object if dragged outside of any table" checked="true"/><span class="message_line">Remove cloned element if dragged outside of any table</span></div>
+ <div><input type="checkbox" class="checkbox" onclick="toggleConfirm(this)" title="Confirm delete"/><span class="message_line">Confirm delete</span></div>
+ <div><input type="checkbox" class="checkbox" onclick="toggleDragging(this)" title="Enable dragging" checked="true"/><span class="message_line">Enable dragging</span></div>
</div>
</body>
</html>
View
@@ -5,50 +5,50 @@
"use strict";
// define redips_init variable
-var redips_init;
+var redipsInit;
// redips initialization
-redips_init = function () {
+redipsInit = function () {
// reference to the REDIPS.drag library and message line
var rd = REDIPS.drag,
msg = document.getElementById('message');
// how to display disabled elements
- rd.border_disabled = 'solid'; // border style for disabled element will not be changed (default is dotted)
- rd.opacity_disabled = 60; // disabled elements will have opacity effect
+ rd.style.borderDisabled = 'solid'; // border style for disabled element will not be changed (default is dotted)
+ rd.style.opacityDisabled = 60; // disabled elements will have opacity effect
// initialization
rd.init();
// only "smile" can be placed to the marked cell
rd.mark.exception.d8 = 'smile';
// prepare handlers
- rd.myhandler_clicked = function () {
+ rd.event.clicked = function () {
msg.innerHTML = 'Clicked';
};
- rd.myhandler_dblclicked = function () {
+ rd.event.dblClicked = function () {
msg.innerHTML = 'Dblclicked';
};
- rd.myhandler_moved = function () {
+ rd.event.moved = function () {
msg.innerHTML = 'Moved';
};
- rd.myhandler_notmoved = function () {
+ rd.event.notMoved = function () {
msg.innerHTML = 'Not moved';
};
- rd.myhandler_dropped = function () {
+ rd.event.dropped = function () {
msg.innerHTML = 'Dropped';
};
- rd.myhandler_switched = function () {
+ rd.event.switched = function () {
msg.innerHTML = 'Switched';
};
- rd.myhandler_clonedend1 = function () {
+ rd.event.clonedEnd1 = function () {
msg.innerHTML = 'Cloned end1';
};
- rd.myhandler_clonedend2 = function () {
+ rd.event.clonedEnd2 = function () {
msg.innerHTML = 'Cloned end2';
};
- rd.myhandler_notcloned = function () {
+ rd.event.notCloned = function () {
msg.innerHTML = 'Not cloned';
};
- rd.myhandler_deleted = function (cloned) {
+ rd.event.deleted = function (cloned) {
// if cloned element is directly moved to the trash
if (cloned) {
// set id of original element (read from redips property)
@@ -59,45 +59,50 @@ redips_init = function () {
msg.innerHTML = 'Deleted';
}
};
- rd.myhandler_undeleted = function () {
+ rd.event.undeleted = function () {
msg.innerHTML = 'Undeleted';
};
- rd.myhandler_cloned = function () {
+ rd.event.cloned = function () {
// display message
msg.innerHTML = 'Cloned';
// append 'd' to the element text (Clone -> Cloned)
rd.obj.innerHTML += 'd';
};
- rd.myhandler_changed = function () {
+ rd.event.changed = function () {
// get target and source position (method returns positions as array)
- var pos = rd.get_position();
+ var pos = rd.getPosition();
// display current row and current cell
msg.innerHTML = 'Changed: ' + pos[1] + ' ' + pos[2];
};
};
// toggles trash_ask parameter defined at the top
-function toggle_confirm(chk) {
- REDIPS.drag.trash_ask = chk.checked;
+function toggleConfirm(chk) {
+ if (chk.checked === true) {
+ REDIPS.drag.trash.question = 'Are you sure you want to delete DIV element?';
+ }
+ else {
+ REDIPS.drag.trash.question = null;
+ }
}
// toggles delete_cloned parameter defined at the top
-function toggle_delete_cloned(chk) {
- REDIPS.drag.delete_cloned = chk.checked;
+function toggleDeleteCloned(chk) {
+ REDIPS.drag.deleteCloned = chk.checked;
}
// enables / disables dragging
-function toggle_dragging(chk) {
- REDIPS.drag.enable_drag(chk.checked);
+function toggleDragging(chk) {
+ REDIPS.drag.enableDrag(chk.checked);
}
// function sets drop_option parameter defined at the top
-function set_drop_option(radio_button) {
- REDIPS.drag.drop_option = radio_button.value;
+function setMode(radioButton) {
+ REDIPS.drag.dropMode = radioButton.value;
}
@@ -106,7 +111,7 @@ function save(type) {
// define table_content variable
var table_content;
// prepare table content of first table in JSON format or as plain query string (depends on value of "type" variable)
- table_content = REDIPS.drag.save_content('table1', type);
+ table_content = REDIPS.drag.saveContent('table1', type);
// if content doesn't exist
if (!table_content) {
alert('Table is empty!');
@@ -125,8 +130,8 @@ function save(type) {
// add onload event listener
if (window.addEventListener) {
- window.addEventListener('load', redips_init, false);
+ window.addEventListener('load', redipsInit, false);
}
else if (window.attachEvent) {
- window.attachEvent('onload', redips_init);
+ window.attachEvent('onload', redipsInit);
}
View
@@ -4,17 +4,17 @@
/* enable strict mode */
"use strict";
-// define redips_init variable
-var redips_init;
+// define redipsInit variable
+var redipsInit;
// redips initialization
-redips_init = function () {
+redipsInit = function () {
var num = 0, // number of successfully placed elements
rd = REDIPS.drag; // reference to the REDIPS.drag lib
// initialization
rd.init();
// set hover color
- rd.hover.color_td = '#9BB3DA';
+ rd.hover.colorTd = '#9BB3DA';
// define green elements for green cells
rd.mark.exception.green = 'green_cell';
rd.mark.exception.greenc0 = 'green_cell';
@@ -24,12 +24,13 @@ redips_init = function () {
rd.mark.exception.orangec0 = 'orange_cell';
rd.mark.exception.orangec1 = 'orange_cell';
// this function (event handler) is called after element is dropped
- rd.myhandler_dropped = function () {
- var msg; // message text
+ rd.event.dropped = function () {
+ // message text
+ var msg;
// if the DIV element was placed on allowed cell then
- if (rd.target_cell.className.indexOf(rd.mark.exception[rd.obj.id]) !== -1) {
+ if (rd.td.target.className.indexOf(rd.mark.exception[rd.obj.id]) !== -1) {
// make it a unmovable
- rd.enable_drag(false, rd.obj.id);
+ rd.enableDrag(false, rd.obj.id);
// increase counter
num++;
// prepare and display message
@@ -46,8 +47,8 @@ redips_init = function () {
// add onload event listener
if (window.addEventListener) {
- window.addEventListener('load', redips_init, false);
+ window.addEventListener('load', redipsInit, false);
}
else if (window.attachEvent) {
- window.attachEvent('onload', redips_init);
-}
+ window.attachEvent('onload', redipsInit);
+}
View
@@ -37,6 +37,8 @@ body{
/* without width, IE6/7 will not apply filter/opacity to the element ?! */
/* IE needs element layout */
width: 82px;
+ height: 25px;
+ line-height: 25px;
/* round corners */
border-radius: 4px; /* Opera, Chrome */
-moz-border-radius: 4px; /* FF */
View
@@ -5,42 +5,41 @@
"use strict";
// functions
-var redips_init, // define redips_init variable
+var redipsInit, // define redipsInit variable
initXMLHttpClient, // create XMLHttp request object in a cross-browser manner
- send_request, // send AJAX request
+ sendRequest, // send AJAX request
request, // XMLHttp request object
- print_message; // print message
+ printMessage; // print message
// redips initialization
-redips_init = function () {
+redipsInit = function () {
// reference to the REDIPS.drag object
var rd = REDIPS.drag;
// create XMLHttp request object
request = initXMLHttpClient();
// REDIPS.drag initialization
rd.init();
- rd.drop_option = 'single'; // dragged elements can be placed to the empty cells only
- rd.hover.color_td = '#9BB3DA'; // set hover color
- rd.trash_ask = false; // do not ask on delete
+ rd.dropMode = 'single'; // dragged elements can be placed to the empty cells only
+ rd.hover.colorTd = '#9BB3DA'; // set hover color
// save - after element is dropped
- rd.myhandler_dropped = function () {
+ rd.event.dropped = function () {
// get element position (method returns array with current and source positions - tableIndex, rowIndex and cellIndex)
- var pos = rd.get_position();
+ var pos = rd.getPosition();
// save table content
- send_request('ajax/db_save.php?p=' + rd.obj.id + '_' + pos.join('_'));
+ sendRequest('ajax/db_save.php?p=' + rd.obj.id + '_' + pos.join('_'));
};
// delete - after element is deleted
- rd.myhandler_deleted = function () {
+ rd.event.deleted = function () {
// get element position
- var pos = rd.get_position(),
+ var pos = rd.getPosition(),
row = pos[4],
col = pos[5];
// delete element
- send_request('ajax/db_delete.php?p=' + rd.obj.id + '_' + row + '_' + col);
+ sendRequest('ajax/db_delete.php?p=' + rd.obj.id + '_' + row + '_' + col);
};
// print message to the message line
- print_message('AJAX version');
+ printMessage('AJAX version');
};
@@ -75,7 +74,7 @@ initXMLHttpClient = function () {
// function sends AJAX request to the server (save or delete)
// input parameter is complete URL of service with query string
-send_request = function (url) {
+sendRequest = function (url) {
// open asynchronus request
request.open('GET', url, true);
// the onreadystatechange event is triggered every time the readyState changes
@@ -95,15 +94,15 @@ send_request = function (url) {
// print message
-print_message = function (message) {
+printMessage = function (message) {
document.getElementById('message').innerHTML = message;
};
// add onload event listener
if (window.addEventListener) {
- window.addEventListener('load', redips_init, false);
+ window.addEventListener('load', redipsInit, false);
}
else if (window.attachEvent) {
- window.attachEvent('onload', redips_init);
+ window.attachEvent('onload', redipsInit);
}
View
@@ -8,7 +8,6 @@
$db_user = 'enter_user_name';
$db_pwd = 'enter_user_password';
-
// reset record set to null ($rs is used in timetable function)
$rs = null;
Oops, something went wrong.

0 comments on commit a795229

Please sign in to comment.