-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update category list view - fix redundant title text - allow ordering from category list * Fix travis error
- Loading branch information
1 parent
8c647b1
commit cfaeacf
Showing
7 changed files
with
116 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** | ||
* Created by Dimas Ciputra <[email protected]> on 22/07/16. | ||
*/ | ||
|
||
var sortable_state = 'enabled'; | ||
|
||
$("#sortable").sortable({ | ||
stop: onStopSortable | ||
}); | ||
|
||
function onStopSortable(e, ui) { | ||
var categories = $.map($(this).find('li'), function(el, i){ | ||
var cat = String(el.id).split('-'); | ||
return { | ||
'sort_number' : i, | ||
'id': cat[0], | ||
'name': cat[1] | ||
} | ||
}); | ||
sortableDisable(); | ||
|
||
var data_url = $("#sortable").data("url"); | ||
|
||
if(data_url) { | ||
$.ajax({ | ||
url: data_url, | ||
type: "POST", | ||
data: JSON.stringify(categories), | ||
success: function (response) { | ||
sortableEnable(); | ||
if($('#order-saved').is(":visible")) | ||
{ | ||
$('#order-saved').hide(); | ||
showOrderSaved(); | ||
} else { | ||
showOrderSaved(); | ||
} | ||
}, | ||
error: function (response) { | ||
console.log(response); | ||
sortableEnable(); | ||
if($('#order-not-saved').is(":visible")) | ||
{ | ||
$('#order-not-saved').hide(); | ||
showOrderNotSaved(); | ||
} else { | ||
showOrderNotSaved(); | ||
} | ||
} | ||
|
||
}); | ||
} | ||
|
||
} | ||
|
||
function showOrderSaved() { | ||
$('#order-saved').fadeIn( "fast", function() { | ||
$('#order-saved').fadeOut(2000); | ||
}); | ||
} | ||
|
||
function showOrderNotSaved() { | ||
$('#order-not-saved').fadeIn( "fast", function() { | ||
$('#order-not-saved').fadeOut(2000); | ||
}); | ||
} | ||
|
||
function sortableEnable() { | ||
sortable_state = 'enabled'; | ||
$("#sortable").sortable({ | ||
stop: onStopSortable | ||
}); | ||
$("#sortable").sortable("option", "disabled", false ); | ||
$("#sortable").disableSelection(); | ||
return false; | ||
} | ||
function sortableDisable() { | ||
sortable_state = 'disabled'; | ||
$( "#sortable" ).sortable("disable"); | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters