Changeset 28555 for trunk/admin/themes/default/js/addAlbum.js
- Timestamp:
- May 28, 2014, 9:04:40 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/themes/default/js/addAlbum.js
r28552 r28555 5 5 6 6 var $popup = jQuery('#addAlbumForm'); 7 if (!$popup.data('init')) { 8 $popup.find('[name="category_parent"]').selectize({ 9 valueField: 'id', 10 labelField: 'fullname', 11 sortField: 'global_rank', 12 searchField: ['fullname'], 13 plugins: ['remove_button'], 14 onInitialize: function() { 15 this.on('dropdown_close', function() { 16 if (this.getValue() == '') { 17 this.setValue(0); 18 } 7 8 function init() { 9 if ($popup.data('init')) { 10 return; 11 } 12 $popup.data('init', true); 13 14 options.cache.selectize($popup.find('[name="category_parent"]'), { 15 'default': 0, 16 'filter': function(categories) { 17 categories.push({ 18 id: 0, 19 fullname: '------------', 20 global_rank: 0 19 21 }); 22 23 return categories; 20 24 } 21 25 }); … … 48 52 49 53 var newAlbum = data.result.id, 50 newAlbum_name = ''; 54 newAlbum_name = '', 55 newAlbum_rank = '0'; 51 56 52 57 if (parent_id != 0) { 53 58 newAlbum_name = albumParent[0].selectize.options[parent_id].fullname +' / '; 59 newAlbum_rank = albumParent[0].selectize.options[parent_id].global_rank +'.1'; 54 60 } 55 61 newAlbum_name+= name; … … 75 81 // target is selectize 76 82 else { 77 $albumSelect[0].selectize.addOption({ 78 id: newAlbum, 79 fullname: newAlbum_name 80 }); 83 var selectize = $albumSelect[0].selectize; 81 84 82 $albumSelect[0].selectize.setValue(newAlbum); 85 if (jQuery.isEmptyObject(selectize.options)) { 86 options.cache.clear(); 87 options.cache.selectize($albumSelect, { 88 'default': newAlbum, 89 'value': newAlbum 90 }); 91 } 92 else { 93 $albumSelect[0].selectize.addOption({ 94 id: newAlbum, 95 fullname: newAlbum_name, 96 global_rank: newAlbum_rank 97 }); 98 99 $albumSelect[0].selectize.setValue(newAlbum); 100 } 83 101 } 84 102 … … 99 117 width: 350, height: 300, 100 118 onComplete: function() { 101 var albumParent = $popup.find('[name="category_parent"]')[0]; 102 119 init(); 103 120 $popup.data('target', jQuery(this).data('addAlbum')); 104 105 albumParent.selectize.clearOptions(); 106 107 options.cache.get(function(categories) { 108 categories.push({ 109 id: 0, 110 fullname: '------------', 111 global_rank: 0 112 }); 113 114 albumParent.selectize.load(function(callback) { 115 callback(categories); 116 }); 117 118 albumParent.selectize.setValue(0); 119 }); 121 $popup.find('[name=category_name]').focus(); 120 122 } 121 123 });
Note: See TracChangeset
for help on using the changeset viewer.