-
-
-
+ sortDialog.init();
+ });
+
+
+
-
\ No newline at end of file
diff --git a/src/Umbraco.Web.UI/umbraco_client/Dialogs/SortDialog.css b/src/Umbraco.Web.UI/umbraco_client/Dialogs/SortDialog.css
new file mode 100644
index 0000000000..99345dc472
--- /dev/null
+++ b/src/Umbraco.Web.UI/umbraco_client/Dialogs/SortDialog.css
@@ -0,0 +1,59 @@
+#sortableFrame
+{
+ height: 270px;
+ overflow: auto;
+ border: 1px solid #ccc;
+}
+
+#sortableNodes
+{
+ padding: 4px;
+ display: block;
+ border-spacing:0;
+ border-collapse:collapse;
+}
+
+ #sortableNodes thead tr th
+ {
+ border-bottom: 1px solid #ccc;
+ padding: 4px;
+ padding-right: 25px;
+ background-image: url(../tableSorting/img/bg.gif);
+ cursor: pointer;
+ font-weight: bold;
+ background-repeat: no-repeat;
+ background-position: center right;
+ }
+
+ #sortableNodes thead tr th.headerSortDown
+ {
+ background-image: url(../tableSorting/img/desc.gif);
+ }
+
+ #sortableNodes thead tr th.headerSortUp
+ {
+ background-image: url(../tableSorting/img/asc.gif);
+ }
+
+ #sortableNodes tbody tr td
+ {
+ border-bottom: 1px solid #efefef;
+ }
+
+ #sortableNodes td
+ {
+ padding: 4px;
+ cursor: move;
+ }
+
+tr.tDnD_whileDrag, tr.tDnD_whileDrag td
+{
+ background: #dcecf3;
+ border-color: #a8d8eb !Important;
+ margin-top: 20px;
+}
+
+#sortableNodes .nowrap
+{
+ white-space: nowrap;
+}
diff --git a/src/Umbraco.Web.UI/umbraco_client/Dialogs/SortDialog.js b/src/Umbraco.Web.UI/umbraco_client/Dialogs/SortDialog.js
new file mode 100644
index 0000000000..75a84292c3
--- /dev/null
+++ b/src/Umbraco.Web.UI/umbraco_client/Dialogs/SortDialog.js
@@ -0,0 +1,121 @@
+Umbraco.Sys.registerNamespace("Umbraco.Dialogs");
+
+(function ($) {
+
+
+ Umbraco.Dialogs.SortDialog = base2.Base.extend({
+ //private methods/variables
+ _opts: null,
+
+ _setupTableSorter: function () {
+ //adds a custom sorter to the tablesorter based on the current cultures date/time format
+ $.tablesorter.addParser({
+ // use a unique id
+ id: 'cultureDateParser',
+ is: function(s, table, cell) {
+ //don't auto-detect this parser
+ return false;
+ },
+ format: function(s, table, cell, cellIndex) {
+ var c = table.config;
+
+ s = s.replace(/\-/g, "/");
+ //all of these basically transform the string into year-month-day since that
+ //is what JS understands when creating a Date object
+ if (c.dateFormat.indexOf("dd/MM/yyyy") == 0 || c.dateFormat.indexOf("dd-MM-yyyy") == 0) {
+ s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3-$2-$1");
+ }
+ else if (c.dateFormat.indexOf("dd/MM/yy") == 0 || c.dateFormat.indexOf("dd-MM-yy") == 0) {
+ s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/, "$3-$2-$1");
+ }
+ else if (c.dateFormat.indexOf("MM/dd/yyyy") == 0 || c.dateFormat.indexOf("MM-dd-yyyy") == 0) {
+ s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{4})/, "$3-$1-$2");
+ }
+ else if (c.dateFormat.indexOf("MM/dd/yy") == 0 || c.dateFormat.indexOf("MM-dd-yy") == 0) {
+ s = s.replace(/(\d{1,2})[\/\-](\d{1,2})[\/\-](\d{2})/, "$3-$1-$2");
+ }
+ return $.tablesorter.formatFloat(new Date(s).getTime());
+ },
+ // set the type to either numeric or text (text uses a natural sort function
+ // so it will work for everything, but numeric is faster for numbers
+ type: 'numeric'
+ });
+ },
+
+ _saveSort: function() {
+ var rows = jQuery('#sortableNodes tbody tr');
+ var sortOrder = "";
+
+ $.each(rows, function () {
+ sortOrder += $(this).attr("id").replace("node_", "") + ",";
+ });
+
+ document.getElementById("sortingDone").style.display = 'none';
+ document.getElementById("sortArea").style.display = 'none';
+
+ document.getElementById("loading").style.display = 'block';
+
+ var self = this;
+
+ $.ajax({
+ type: "POST",
+ url: self._opts.serviceUrl,
+ data: '{ "ParentId": ' + parseInt(self._opts.currentId) + ', "SortOrder": "' + sortOrder + '"}',
+ contentType: "application/json; charset=utf-8",
+ dataType: "json",
+ success: function(msg) {
+ self._showConfirm();
+ }
+ });
+ },
+
+ _showConfirm: function() {
+ document.getElementById("loading").style.display = 'none';
+ document.getElementById("sortingDone").style.display = 'block';
+ UmbClientMgr.mainTree().reloadActionNode();
+ },
+
+ // Constructor
+ constructor: function (opts) {
+ // Merge options with default
+ this._opts = $.extend({
+ // Default options go here
+ }, opts);
+
+ this._setupTableSorter();
+ },
+
+ //public methods/variables
+
+ init: function () {
+ var self = this;
+
+ //create the sorter
+ $("#sortableNodes").tablesorter({
+ dateFormat: self._opts.dateTimeFormat,
+ headers: {
+ 0: { sorter: "text" },
+ 1: { sorter: "cultureDateParser" }, //ensure to set our custom parser here
+ 2: { sorter: "numeric" }
+ }
+ });
+
+ //setup the drag/drop sorting
+ $("#sortableNodes").tableDnD({ containment: jQuery("#sortableFrame") });
+
+ //wire up the submit button
+ self._opts.submitButton.click(function() {
+ self._saveSort();
+ });
+
+ //wire up the close button
+ self._opts.closeWindowButton.click(function () {
+ UmbClientMgr.closeModalWindow();
+ });
+ },
+
+ });
+
+
+
+})(jQuery);
\ No newline at end of file
diff --git a/src/Umbraco.Web.UI/umbraco_client/tablesorting/jquery.tablesorter.min.js b/src/Umbraco.Web.UI/umbraco_client/tablesorting/jquery.tablesorter.min.js
new file mode 100644
index 0000000000..b8605df1e7
--- /dev/null
+++ b/src/Umbraco.Web.UI/umbraco_client/tablesorting/jquery.tablesorter.min.js
@@ -0,0 +1,4 @@
+
+(function($){$.extend({tablesorter:new
+function(){var parsers=[],widgets=[];this.defaults={cssHeader:"header",cssAsc:"headerSortUp",cssDesc:"headerSortDown",cssChildRow:"expand-child",sortInitialOrder:"asc",sortMultiSortKey:"shiftKey",sortForce:null,sortAppend:null,sortLocaleCompare:true,textExtraction:"simple",parsers:{},widgets:[],widgetZebra:{css:["even","odd"]},headers:{},widthFixed:false,cancelSelection:true,sortList:[],headerList:[],dateFormat:"us",decimal:'/\.|\,/g',onRenderHeader:null,selectorHeaders:'thead th',debug:false};function benchmark(s,d){log(s+","+(new Date().getTime()-d.getTime())+"ms");}this.benchmark=benchmark;function log(s){if(typeof console!="undefined"&&typeof console.debug!="undefined"){console.log(s);}else{alert(s);}}function buildParserCache(table,$headers){if(table.config.debug){var parsersDebug="";}if(table.tBodies.length==0)return;var rows=table.tBodies[0].rows;if(rows[0]){var list=[],cells=rows[0].cells,l=cells.length;for(var i=0;i