Changeset 2545:63fc385ee997
- Timestamp:
- 11/14/13 12:14:36 (10 years ago)
- Branch:
- 2.6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/js/meta-editor.js
r1920 r2545 13 13 text_all: 'all', 14 14 text_separation: 'Separate each %s by comas', 15 15 16 16 target: null, 17 17 meta_type: null, … … 20 20 submit_button: null, 21 21 post_id: false, 22 22 23 23 service_uri: 'services.php', 24 24 25 25 displayMeta: function(type,post_id) { 26 26 this.meta_type = type; 27 27 this.post_id = post_id; 28 28 this.target.empty(); 29 29 30 30 this.meta_dialog = $('<input type="text" class="ib" />'); 31 31 this.meta_dialog.attr('title',this.text_add_meta.replace(/%s/,this.meta_type)); … … 39 39 return true; 40 40 }); 41 41 42 42 var This = this; 43 43 44 44 this.submit_button = $('<input type="button" value="ok" class="ib" />'); 45 45 this.submit_button.click(function() { … … 48 48 return false; 49 49 }); 50 50 51 51 this.addMetaDialog(); 52 52 53 53 if (this.post_id == false) { 54 54 this.target.append(this.meta_field); … … 56 56 this.displayMetaList(); 57 57 }, 58 58 59 59 displayMetaList: function() { 60 60 var li; … … 63 63 this.target.prepend(this.meta_list); 64 64 } 65 65 66 66 if (this.post_id == false) { 67 67 var meta = this.splitMetaValues(this.meta_field.val()); 68 68 69 69 this.meta_list.empty(); 70 70 for (var i=0; i<meta.length; i++) { … … 88 88 postId: this.post_id 89 89 }; 90 90 91 91 $.get(this.service_uri,params,function(data) { 92 92 data = $(data); 93 93 94 94 if (data.find('rsp').attr('status') != 'ok') { return; } 95 95 96 96 This.meta_list.empty(); 97 97 data.find('meta').each(function() { … … 111 111 } 112 112 }, 113 113 114 114 addMetaDialog: function() { 115 115 116 116 if (this.submit_button == null) { 117 117 this.target.append($('<p></p>').append(this.meta_dialog)); … … 119 119 this.target.append($('<p></p>').append(this.meta_dialog).append(' ').append(this.submit_button)); 120 120 } 121 121 122 122 if (this.text_separation != '') { 123 123 this.target.append($('<p></p>').addClass('form-note').append(this.text_separation.replace(/%s/,this.meta_type))); 124 124 } 125 125 126 126 this.showMetaList(metaEditor.prototype.meta_type,this.target); 127 128 }, 129 127 128 }, 129 130 130 showMetaList: function(type,target) { 131 131 132 132 var params = { 133 133 f: 'getMeta', … … 135 135 sortby: 'metaId,asc' 136 136 }; 137 137 138 138 if (type == 'more') { 139 139 params.limit = '30'; 140 140 } 141 141 142 142 var This = this; 143 143 144 144 $.get(this.service_uri,params,function(data) { 145 145 146 146 var pl = $('<p class="addMeta"></p>'); 147 147 148 148 $(target).find('.addMeta').remove(); 149 149 150 150 if ($(data).find('meta').length > 0) { 151 151 pl.empty(); 152 152 var meta_link; 153 153 154 154 $(data).find('meta').each(function(i) { 155 155 meta_link = $('<a href="#">' + $(this).text() + '</a>'); … … 160 160 return false; 161 161 }); 162 162 163 163 if (i>0) { 164 164 pl.append(', '); … … 166 166 pl.append(meta_link); 167 167 }); 168 168 169 169 if (type == 'more') { 170 170 var a_more = $('<a href="#" class="metaGetMore"></a>'); 171 171 a_more.append(This.text_all + String.fromCharCode(160)+String.fromCharCode(187)); 172 172 a_more.click(function() { 173 This.showMetaList(' all',target);173 This.showMetaList('more-all',target); 174 174 return false; 175 175 }); 176 176 pl.append(', ').append(a_more); 177 177 } 178 179 if (type != 'more-all') { 178 180 pl.addClass('hide'); 179 181 180 182 var pa = $('<p></p>'); 181 183 target.append(pa); 182 184 183 185 var a = $('<a href="#" class="metaGetList">' + This.text_choose + '</a>'); 184 186 a.click(function() { … … 187 189 return false; 188 190 }); 189 191 190 192 pa.append(a); 191 193 } 192 194 193 195 target.append(pl); 194 196 195 197 } else { 196 198 pl.empty(); … … 198 200 }); 199 201 }, 200 202 201 203 addMeta: function(str) { 202 204 str = this.splitMetaValues(str).join(','); … … 204 206 str = this.splitMetaValues(this.meta_field.val() + ',' + str); 205 207 this.meta_field.val(str); 206 208 207 209 this.meta_dialog.val(''); 208 210 this.displayMetaList(); … … 215 217 meta: str 216 218 }; 217 219 218 220 var This = this; 219 221 $.post(this.service_uri,params,function(data) { … … 227 229 } 228 230 }, 229 231 230 232 removeMeta: function(meta_id) { 231 233 if (this.post_id == false) { … … 241 243 } else { 242 244 var text_confirm_msg = this.text_confirm_remove.replace(/%s/,this.meta_type); 243 245 244 246 if (window.confirm(text_confirm_msg)) { 245 247 var This = this; … … 251 253 metaType: this.meta_type 252 254 }; 253 255 254 256 $.post(this.service_uri,params,function(data) { 255 257 if ($(data).find('rsp').attr('status') == 'ok') { … … 262 264 } 263 265 }, 264 266 265 267 splitMetaValues: function(str) { 266 268 function inArray(needle,stack) { … … 272 274 return false; 273 275 } 274 276 275 277 var res = new Array(); 276 278 var v = str.split(',');
Note: See TracChangeset
for help on using the changeset viewer.