@ -6,10 +6,11 @@ define(function() {
function modified ( el ) {
function modified ( el ) {
var cid = $ ( el ) . parents ( 'li' ) . attr ( 'data-cid' ) ;
var cid = $ ( el ) . parents ( 'li' ) . attr ( 'data-cid' ) ;
if ( cid ) {
modified _categories [ cid ] = modified _categories [ cid ] || { } ;
modified _categories [ cid ] = modified _categories [ cid ] || { } ;
modified _categories [ cid ] [ $ ( el ) . attr ( 'data-name' ) ] = $ ( el ) . val ( ) ;
modified _categories [ cid ] [ $ ( el ) . attr ( 'data-name' ) ] = $ ( el ) . val ( ) ;
}
}
}
function save ( ) {
function save ( ) {
socket . emit ( 'api:admin.categories.update' , modified _categories ) ;
socket . emit ( 'api:admin.categories.update' , modified _categories ) ;
@ -28,6 +29,7 @@ define(function() {
var iconClass = jQuery ( '.bootbox .selected' ) . children ( ':first' ) . attr ( 'class' ) ;
var iconClass = jQuery ( '.bootbox .selected' ) . children ( ':first' ) . attr ( 'class' ) ;
el . attr ( 'class' , iconClass + ' icon-2x' ) ;
el . attr ( 'class' , iconClass + ' icon-2x' ) ;
el . val ( iconClass ) ;
el . val ( iconClass ) ;
el . attr ( 'value' , iconClass ) ;
modified ( el ) ;
modified ( el ) ;
}
}
@ -66,7 +68,6 @@ define(function() {
} ) ;
} ) ;
//DRY Failure. this needs to go into an ajaxify onready style fn. Currently is copy pasted into every single function so after ACP is off the ground fix asap
function showCreateCategoryModal ( ) {
function showCreateCategoryModal ( ) {
$ ( '#new-category-modal' ) . modal ( ) ;
$ ( '#new-category-modal' ) . modal ( ) ;
}
}
@ -75,7 +76,7 @@ define(function() {
var category = {
var category = {
name : $ ( '#inputName' ) . val ( ) ,
name : $ ( '#inputName' ) . val ( ) ,
description : $ ( '#inputDescription' ) . val ( ) ,
description : $ ( '#inputDescription' ) . val ( ) ,
icon : $ ( '#new-category-modal i' ) . attr( 'value' ) ,
icon : $ ( '#new-category-modal i' ) . val( ) ,
blockclass : $ ( '#inputBlockclass' ) . val ( )
blockclass : $ ( '#inputBlockclass' ) . val ( )
} ;
} ;
@ -120,6 +121,10 @@ define(function() {
select _icon ( $ ( this ) . find ( 'i' ) ) ;
select _icon ( $ ( this ) . find ( 'i' ) ) ;
} ) ;
} ) ;
jQuery ( '#new-category-modal' ) . on ( 'click' , '.icon' , function ( ev ) {
select _icon ( $ ( this ) . find ( 'i' ) ) ;
} ) ;
jQuery ( '.blockclass' ) . on ( 'change' , function ( ev ) {
jQuery ( '.blockclass' ) . on ( 'change' , function ( ev ) {
update _blockclass ( ev . target ) ;
update _blockclass ( ev . target ) ;
} ) ;
} ) ;
@ -137,7 +142,7 @@ define(function() {
} ) ;
} ) ;
jQuery ( ' .entry-row button ') . on ( 'click ', function ( ev ) {
jQuery ( ' #entry-container ') . on ( 'click ', '.disable-btn ', function ( ev ) {
var btn = jQuery ( this ) ;
var btn = jQuery ( this ) ;
var categoryRow = btn . parents ( 'li' ) ;
var categoryRow = btn . parents ( 'li' ) ;
var cid = categoryRow . attr ( 'data-cid' ) ;
var cid = categoryRow . attr ( 'data-cid' ) ;