1mw.content = mw.content || { 2 3 deleteContent: function (id, callback) { 4 mw.tools.confirm(mw.msg.del, function () { 5 $.post(mw.settings.api_url + "content/delete", {id: id}, function (data) { 6 if (callback) { 7 callback.call(data, data); 8 } 9 mw.notification.success('Content deleted'); 10 }); 11 }); 12 }, 13 deleteCategory: function (id, callback) { 14 mw.tools.confirm('Are you sure you want to delete this?', function () { 15 $.post(mw.settings.api_url + "category/delete", {id: id}, function (data) { 16 mw.notification.success('Category deleted'); 17 if (callback) { 18 callback.call(data, data); 19 } 20 mw.reload_module_everywhere('content/manager'); 21 }); 22 }); 23 }, 24 publish: function ($id) { 25 var master = {}; 26 master.id = $id; 27 mw.$(mwd.body).addClass("loading"); 28 mw.drag.save(); 29 $.ajax({ 30 type: 'POST', 31 url: mw.settings.site_url + 'api/content/set_published', 32 data: master, 33 datatype: "json", 34 async: true, 35 beforeSend: function () { 36 37 }, 38 success: function (data) { 39 mw.$(mwd.body).removeClass("loading"); 40 $('.mw-set-content-publish').hide(); 41 mw.$('.mw-set-content-unpublish').fadeIn(); 42 mw.askusertostay = false; 43 mw.notification.success("Content is Published."); 44 }, 45 error: function () { 46 mw.$(mwd.body).removeClass("loading"); 47 }, 48 complete: function () { 49 mw.$(mwd.body).removeClass("loading"); 50 } 51 }); 52 }, 53 unpublish: function ($id) { 54 var master = {}; 55 master.id = $id; 56 mw.$(mwd.body).addClass("loading"); 57 58 mw.drag.save(); 59 $.ajax({ 60 type: 'POST', 61 url: mw.settings.site_url + 'api/content/set_unpublished', 62 data: master, 63 datatype: "json", 64 async: true, 65 beforeSend: function () { 66 67 }, 68 success: function (data) { 69 mw.$(mwd.body).removeClass("loading"); 70 mw.$('.mw-set-content-unpublish').hide(); 71 mw.$('.mw-set-content-publish').fadeIn(); 72 mw.askusertostay = false; 73 mw.notification.warning("Content is Unpublished."); 74 }, 75 error: function () { 76 mw.$(mwd.body).removeClass("loading"); 77 }, 78 complete: function () { 79 mw.$(mwd.body).removeClass("loading"); 80 } 81 }); 82 83 }, 84 save: function (data, e) { 85 var master = {}; 86 var calc = {}; 87 var e = e || {}; 88 // data.subtype === 'category' 89 if (data.content == "" || typeof data.content === 'undefined') { 90 // calc.content = false; 91 } 92 else { 93 var doc = mw.tools.parseHtml(data.content); 94 var all = doc.querySelectorAll('[contenteditable]'), l = all.length, i = 0; 95 for (; i < l; i++) { 96 all[i].removeAttribute('contenteditable'); 97 } 98 data.content = doc.body.innerHTML; 99 } 100 101 if (data.title == "" || typeof data.title === 'undefined') { 102 calc.title = false; 103 } 104 if (!mw.tools.isEmptyObject(calc)) { 105 if (typeof e.onError === 'function') { 106 e.onError.call(calc); 107 } 108 return false; 109 } 110 if (typeof data.content_type === "undefined" || data.content_type == "") { 111 data.content_type = "post"; 112 } 113 if (typeof data.id === "undefined" || data.id == "") { 114 data.id = 0; 115 } 116 master.title = data.title; 117 master.content = data.content; 118 mw.$(mwd.body).addClass("loading"); 119 mw.trigger('adminSaveStart'); 120 $.ajax({ 121 type: 'POST', 122 url: mw.settings.api_url + 'save_content_admin', 123 data: data, 124 datatype: "json", 125 async: true, 126 success: function (data) { 127 mw.$(mwd.body).removeClass("loading"); 128 if (typeof data === 'object' && typeof data.error != 'undefined') { 129 if (typeof e.onError === 'function') { 130 e.onError.call(data); 131 } 132 } 133 else { 134 if (typeof e.onSuccess === 'function') {
135 e.onSuccess.call(data); 136 } 137 } 138 }, 139 error: function (data) { 140 mw.$(mwd.body).removeClass("loading"); 141 if (typeof e.onError === 'function') { 142 e.onError.call(data); 143 } 144 }, 145 complete: function () { 146 mw.$(mwd.body).removeClass("loading"); 147 } 148 }); 149 } 150}; 151 152 153mw.post = mw.post || { 154 del: function (a, callback) { 155 var arr = $.isArray(a) ? a : [a]; 156 var obj = {ids: arr} 157 $.post(mw.settings.api_url + "content/delete", obj, function (data) { 158 typeof callback === 'function' ? callback.call(data) : ''; 159 }); 160 }, 161 publish: function (id, c) { 162 var obj = { 163 id: id 164 } 165 $.post(mw.settings.api_url + 'content/set_published', obj, function (data) { 166 if (typeof c === 'function') { 167 c.call(id, data); 168 } 169 }); 170 }, 171 unpublish: function (id, c) { 172 var obj = { 173 id: id 174 } 175 $.post(mw.settings.api_url + 'content/set_unpublished', obj, function (data) { 176 if (typeof c === 'function') { 177 c.call(id, data); 178 } 179 }); 180 }, 181 set: function (id, state, e) { 182 if (typeof e !== 'undefined') { 183 e.preventDefault(); 184 e.stopPropagation(); 185 } 186 if (state == 'unpublish') { 187 mw.post.unpublish(id, function (data) { 188 mw.notification.warning(mw.msg.contentunpublished); 189 }); 190 } 191 else if (state == 'publish') { 192 mw.post.publish(id, function (data) { 193 mw.notification.success(mw.msg.contentpublished); 194 mw.$(".manage-post-item-" + id).removeClass("content-unpublished").find(".post-un-publish").remove(); 195 if (typeof e !== 'undefined') { 196 mw.$(e.target.parentNode).removeClass("content-unpublished"); 197 mw.$(e.target).remove(); 198 } 199 }); 200 } 201 } 202}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.