PageSourceSearch

https://www.nguoicham.com/PF.Site/Apps/p-saved-items/assets/autoload.js?v=dcbfd3

js nguoicham.com collected 2026-10-02 12:57:44 UTC 12,978 bytes, 268 lines download raw bytes

1var appSavedItem = {
2    isDetailPage: null,
3    turnOnConfirmationWithUnsavedAction: null,
4    stopPropagation: function(event, obj) {
5        event.stopPropagation();
6        if($(obj).hasClass('dropdown')) {
7            let dropdown = $(obj);
8            if(dropdown.hasClass('open')) {
9                dropdown.removeClass('open');
10                dropdown.find('a:first').prop('aria-expanded', false);
11                dropdown.find('.js_create_collection_container').addClass('hide');
12            }
13            else {
14                dropdown.addClass('open');
15                dropdown.find('a:first').prop('aria-expanded', true);
16            }
17        }
18    },
19    processItem: function(params) {
20        if(!empty(params['type_id']) && parseInt(params['item_id']) > 0) {
21            let isSave = parseInt(params['is_save']) == 1;
22            let feed_id = !empty(params['feed_id']) && parseInt(params['feed_id']) > 0 ? parseInt(params['feed_id']) : 0;
23            if(!isSave && !isset(params['unsave_confirmation']) && feed_id > 0 && appSavedItem.isDetailPage && appSavedItem.turnOnConfirmationWithUnsavedAction) {
24                tb_show(oTranslations['saveditems_unsave_item'], $.ajaxBox('saveditems.openConfirmationPopup', 'feed_id=' + feed_id + '&type_id=' + params['type_id'] + '&item_id=' + params['item_id'] + '&is_save=' + parseInt(params['is_save']) + '&link=' + (!empty(params['link']) ? encodeURIComponent(params['link']) : '') + '&is_detail=1'));
25            }
26            else {
27                $.ajaxCall('saveditems.processItem', 'feed_id=' + feed_id + '&type_id=' + params['type_id'] + '&item_id=' + params['item_id'] + '&is_save=' + parseInt(params['is_save']) + '&link=' + (!empty(params['link']) ? encodeURIComponent(params['link']) : '') + '&is_detail=' + appSavedItem.isDetailPage);
28                if(isset(params['unsave_confirmation'])) {
29                    tb_remove();
30                }
31            }
32
33            return false;
34        }
35    },
36    unsave: function(obj) {
37        let _this = $(obj);
38
39        if(_this.closest('[data-target="saved_item"]').length) {
40            let parent = _this.closest('[data-target="saved_item"]');
41            let savedId = parseInt(parent.data('id'));
42
43            if(!empty(savedId) && savedId > 0) {
44                if(parent.data('added') && empty(_this.data('remove-from-collection'))) {
45                    $Core.jsConfirm({message: oTranslations['saveditems_unsave_from_collection_notice']}, function () {
46                        $.ajaxCall('saveditems.processItem', 'saved_id=' + savedId + '&is_save=0');
47                    });
48                }
49                else {
50                    let collectionId = parseInt(parent.data('collection'));
51                    $.ajaxCall('saveditems.processItem', 'saved_id=' + savedId + '&is_save=0' + (collectionId > 0 && !empty(_this.data('remove-from-collection')) ? ('&collection_id=' + collectionId + '&no_confirmation_with_collection=1') : ''));
52                }
53            }
54
55
56        }
57
58        return false;
59    },
60    appendSavedAlert: function(feedId, content) {
61        let actionBtn = $('.js_saved_item_' + feedId);
62        if(actionBtn.length) {
63            let parent = actionBtn.closest('.js_feed_view_more_entry_holder');
64            let contentObject = $(content);
65            if(parent.find('.js_saved_alert_item:first').length) {
66                parent.find('.js_saved_alert_item:first').remove();
67            }
68            contentObject.prependTo(parent);
69        }
70    },
71    appendCollectionList: function(savedId, content) {
72        if($('.js_saved_item_' + savedId).length) {
73            let targetEle = $('.js_saved_item_' + savedId).find('.js_collection_information');
74            if(targetEle.find('.js_collection_item').length) {
75                targetEle.find('.js_collection_item').remove();
76            }
77            if(!empty(content)) {
78                targetEle.append(content);
79            }
80        }
81    },
82    processFormAddCollection: function(event, obj) {
83        event.stopPropagation();
84        let parent = $(obj).closest('.js_saved_alert_item');
85        let form = parent.find('.js_create_collection_container');
86        if(form.hasClass('hide')) {
87            form.removeClass('hide');
88        } else {
89            form.addClass('hide');
90        }
91    },
92    createCollection: function(obj) {
93        let parent = $(obj).closest('.js_create_collection_container'),
94         collectionTitle = parent.find('.js_saveditems_collection_title_input').val(),
95         noReload = $(obj).closest('.js_add_to_collection_container').length,
96         id = parseInt($(obj).data('id')),
97         collectionId = parseInt($(obj).data('collection')),
98         detail = $(obj).data('detail'),
99         feedId = $(obj).data('feed'),
100         privacy = parent.find('input[name="val[privacy]"]').val(),
101         privacy_list = [];
102         parent.find('input[name="val[privacy_list][]"]').each(function() {
103            privacy_list.push($(this).val());
104         });
105
106
107        $.ajaxCall('saveditems.createCollection', 'title=' + encodeURIComponent(collectionTitle) + (noReload ? ('&no_reload=' + noReload) : '') + (id ? ('&id=' + id) : '') + (collectionId ? ('&collection_id=' + collectionId) : '') + (detail ? '&detail=1' : '') + (feedId ? '&feed_id='+ feedId : '') + (privacy ? '&privacy='+ privacy : '') + (privacy_list? '&privacy_list='+ privacy_list : '') + ($(obj).data('keeppopup') ? '&keep_popup=1' : ''));
108    },
109    cancelCreateCollection: function(id) {
110        let parent = $('[data-target="collection_form_'+ parseInt(id) +'"]');
111        parent.addClass('hide');
112        parent.find('.js_saveditems_collection_title_input').val('');
113        parent.find('.js_error').addClass('hide').html('');
114    },
115    addItemToCollection: function(obj) {
116        let savedId = $(obj).data('id');
117        let collectionId = $(obj).data('collection');
118        let feedId = $(obj).data('feed');
119        if(parseInt(savedId) > 0 && parseInt(collectionId) > 0) {
120            setTimeout(function() {
121                let inputCheckbox = $('[data-target="saved_alert_item_' + savedId + '"] [data-collection="' + collectionId + '"] input[type="checkbox"]'),
122                  isAdd = !inputCheckbox.prop('checked');
123                inputCheckbox.prop('checked', isAdd);
124                $.ajaxCall('saveditems.processAddItemToCollection', 'saved_id=' + parseInt(savedId) + '&collection_id=' + parseInt(collectionId) + '&is_add=' + (isAdd ? 1 : 0) + (parseInt(feedId) > 0 ? '&feed_id=' + feedId : ''));
125            },50);
126        }
127        else {
128            $(obj).find('input[type="checkbox"]:first').prop('checked', false)
129        }
130        return false;
131    },
132    deleteCollection: function(collectionId) {
133        if(parseInt(collectionId) > 0) {
134            $Core.jsConfirm({message: oTranslations['saveditems_are_you_sure_you_want_to_delete_this_collection']}, function(){
135                $.ajaxCall('saveditems.deleteCollection', 'collection_id=' + parseInt(collectionId));
136            });
137        }
138        return false;
139    },
140    processItemStatus: function(obj) {
141        let status = $(obj).data('status');
142        let savedId = parseInt($(obj).parent().data('id'));
143        if(savedId > 0) {
144            $.ajaxCall('saveditems.processItemStatus', 'id=' + savedId + '&status=' + parseInt(status));
145        }
146        return false;
147    },
148    showSuccessfulMessage: function(target_id, message) {
149        let objectThis = $('.js_saved_item_' + target_id);
150        if(appSavedItem.isDetailPage && !objectThis.closest('.js_feed_view_more_entry_holder').length) {
151            if ($('#public_message').length == 0) {
152                $('#main').prepend('<div class="public_message" id="public_message"></div>');
153            }
154            $('#public_message').html(message);
155            $Behavior.addModerationListener();
156        }
157    },
158    checkInDetailPage: function() {
159        if(isset(oTranslations['saveditemscheckdetail_1'])) {
160            appSavedItem.isDetailPage = 1;
161            oTranslations["saveditemscheckdetail_1"] = null;
162        }
163        else {
164            appSavedItem.isDetailPage = 0;
165            oTranslations["saveditemscheckdetail_0"] = null;
166        }
167    },
168    checkTurnOnConfirmationWithUnsavedAction: function() {
169        if(isset(oTranslations['saveditemscheckturnonconfirmationwithunsavedaction_1'])) {
170            appSavedItem.turnOnConfirmationWithUnsavedAction = 1;
171            oTranslations["saveditemscheckturnonconfirmationwithunsavedaction_1"] = null;
172        }
173        else {
174            appSavedItem.turnOnConfirmationWithUnsavedAction = 0;
175            oTranslations["saveditemscheckturnonconfirmationwithunsavedaction_0"] = null;
176        }
177    },
178    checkSetting: function() {
179      appSavedItem.checkInDetailPage();
180      appSavedItem.checkTurnOnConfirmationWithUnsavedAction();
181    },
182    changeCollectionTitleInDetail: function(url, title) {
183        $('a[href="' + url + '"]').each(function(){
184           if($(this).find('.item-name').length) {
185               $(this).find('.item-name').html(title);
186           }
187           else {
188               $(this).html(title);
189           }
190        });
191    },
192    toggleCollectionOnPopupSavedItem: function(){
193        if($('.js_p_saveditems_action_collection_toggle').length){
194            var btn = $('.js_p_saveditems_action_collection_toggle'),
195                parent = btn.closest('.p-saveditems-dropdown-addto-collection-
195popup-content'),
196                toggleContent = parent.find('.js_p_saveditems_wrapper_collection_toggle');
197            btn.on('click',function(){
198                btn.toggleClass('toggle');
199                toggleContent.toggleClass('hide');
200            });
201        }
202    },
203    addFriendToCollection: function (form){
204        var _form = $(form),
205          btn = _form.find('button');
206        btn.prop('disabled', true);
207
208        $.fn.ajaxCall('saveditems.addFriendToCollection', _form.serialize(), null, null, function() {
209            btn.prop('disabled', false);
210            js_box_remove();
211        });
212
213        return false;
214    },
215    unShowDeleteFriend: function (iFriendId, iCollectionId) {
216        if ($('#js_collection_' + iCollectionId + '_friend_' + iFriendId).length){
217            $('#js_collection_' + iCollectionId + '_friend_' + iFriendId).remove();
218        }
219    },
220
221    buildFriends: function($oObj) {
222        if (this.isBeingBuilt === false &&
223          !isset(this.aParams['is_mail']) && ((this.aParams['include_current_user'] !== $Core.searchFriendsInput.bIsIncludeCurrentUser) || empty($Cache.friends))) {
224            $($oObj).val('');
225            this.isBeingBuilt = true;
226            $Core.searchFriendsInput.bIsIncludeCurrentUser = this.aParams['include_current_user'];
227            $.ajaxCall('friend.buildCache',(this._get('include_current_user') ? 'include_current_user=1' : '') +
228              (this._get('allow_custom') ? '&allow_custom=1' : ''), 'GET');
229        }
230    },
231}
232
233$Behavior.savedItem = function() {
234    if($('.p-saveditems-status').length) {
235        $('.p-saveditems-status[data-toggle="tooltip"]').tooltip();
236    }
237    $(document).on('click', '.js_saved_alert_item .js_add_to_collection_container', function(event) {
238        event.stopPropagation();
239    }).on('click', '.js_saved_alert_item .js_add_to_collection_btn', function(event) {
240        $(this).closest('.js_saved_alert_item').find('.js_create_collection_container').addClass('hide');
241    }).on('focus', '.js_saveditems_collection_title_input', function() {
242        $(this).addClass('focus');
243    }).on('blur', '.js_saveditems_collection_title_input', function() {
244        $(this).removeClass('focus');
245    }).off('keyup', '.js_saveditems_collection_title_input').on('keyup', '.js_saveditems_collection_title_input', function(e) {
246        if(e.which == 13 && $(this).hasClass('focus')) {
247            e.stopPropagation();
248            appSavedItem.createCollection($(this).get(0));
249        }
250    });
251    if(appSavedItem.isDetailPage == null && appSavedItem.turnOnPopupWithSavedAction == null && appSavedItem.turnOnConfirmationWithUnsavedAction == null) {
252        appSavedItem.checkSetting();
253    }
254    //fix overlap layout
255    $('.p-saveditems-dropdown-addto-collection.js_add_to_collection_container').on('show.bs.dropdown', function () {
256        $(this).closest('.layout-middle').css('z-index','10');
257    }).on('hidden.bs.dropdown', function () {
258        $(this).closest('.layout-middle').css('z-index','');
259    });
260}
261
262PF.event.on('on_page_change_end', function() {
263    appSavedItem.checkSetting();
264    //
265    // if (typeof $Core.searchFriendsInput !== 'undefined') {
266    //     $Core.searchFriendsInput.buildFriends = appSavedItem.buildFriends;
267    // }
268});

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.