芝麻web文件管理V1.00
编辑当前文件:/home2/sdektunc/.trash/cepali/message/amd/build/message_drawer_view_search.min.js
define(["jquery","core/custom_interaction_events","core/notification","core/pubsub","core/str","core/templates","core_message/message_repository","core_message/message_drawer_events"],function(a,b,c,d,e,f,g,h){var i=50,j=50,k=3,l={BLOCK_ICON_CONTAINER:'[data-region="block-icon-container"]',CANCEL_SEARCH_BUTTON:'[data-action="cancel-search"]',CONTACTS_CONTAINER:'[data-region="contacts-container"]',CONTACTS_LIST:'[data-region="contacts-container"] [data-region="list"]',EMPTY_MESSAGE_CONTAINER:'[data-region="empty-message-container"]',LIST:'[data-region="list"]',LOADING_ICON_CONTAINER:'[data-region="loading-icon-container"]',LOADING_PLACEHOLDER:'[data-region="loading-placeholder"]',MESSAGES_LIST:'[data-region="messages-container"] [data-region="list"]',MESSAGES_CONTAINER:'[data-region="messages-container"]',NON_CONTACTS_CONTAINER:'[data-region="non-contacts-container"]',NON_CONTACTS_LIST:'[data-region="non-contacts-container"] [data-region="list"]',SEARCH_ICON_CONTAINER:'[data-region="search-icon-container"]',SEARCH_ACTION:'[data-action="search"]',SEARCH_INPUT:'[data-region="search-input"]',SEARCH_RESULTS_CONTAINER:'[data-region="search-results-container"]',LOAD_MORE_USERS:'[data-action="load-more-users"]',LOAD_MORE_MESSAGES:'[data-action="load-more-messages"]',BUTTON_TEXT:'[data-region="button-text"]',NO_RESULTS_CONTAINTER:'[data-region="no-results-container"]',ALL_CONTACTS_CONTAINER:'[data-region="all-contacts-container"]'},m={CONTACTS_LIST:"core_message/message_drawer_contacts_list",NON_CONTACTS_LIST:"core_message/message_drawer_non_contacts_list",MESSAGES_LIST:"core_message/message_drawer_messages_list"},n=function(a){return a.attr("data-user-id")},o=function(a){return a.find(l.EMPTY_MESSAGE_CONTAINER)},p=function(a){return a.find(l.LOADING_ICON_CONTAINER)},q=function(a){return a.find(l.LOADING_PLACEHOLDER)},r=function(a){return a.find(l.SEARCH_ICON_CONTAINER)},s=function(a){return a.find(l.SEARCH_INPUT)},t=function(a){return a.find(l.SEARCH_RESULTS_CONTAINER)},u=function(a){return a.find(l.CONTACTS_CONTAINER)},v=function(a){return a.find(l.NON_CONTACTS_CONTAINER)},w=function(a){return a.find(l.MESSAGES_CONTAINER)},x=function(a){o(a).removeClass("hidden")},y=function(a){o(a).addClass("hidden")},z=function(a){p(a).removeClass("hidden")},A=function(a){p(a).addClass("hidden")},B=function(a){q(a).removeClass("hidden")},C=function(a){q(a).addClass("hidden")},D=function(a){r(a).removeClass("hidden")},E=function(a){r(a).addClass("hidden")},F=function(a){t(a).removeClass("hidden")},G=function(a){t(a).addClass("hidden")},H=function(a){var b=t(a);b.find(l.ALL_CONTACTS_CONTAINER).addClass("hidden"),b.find(l.MESSAGES_CONTAINER).addClass("hidden"),b.find(l.NO_RESULTS_CONTAINTER).removeClass("hidden")},I=function(a){var b=t(a);b.find(l.ALL_CONTACTS_CONTAINER).removeClass("hidden"),b.find(l.MESSAGES_CONTAINER).removeClass("hidden"),b.find(l.NO_RESULTS_CONTAINTER).addClass("hidden")},J=function(a){var b=t(a);b.find(l.ALL_CONTACTS_CONTAINER).removeClass("hidden")},K=function(a){var b=t(a);b.find(l.ALL_CONTACTS_CONTAINER).addClass("hidden")},L=function(a){var b=t(a);b.find(l.CONTACTS_CONTAINER).removeClass("hidden")},M=function(a){var b=t(a);b.find(l.CONTACTS_CONTAINER).addClass("hidden")},N=function(a){var b=t(a);b.find(l.NON_CONTACTS_CONTAINER).removeClass("hidden")},O=function(a){var b=t(a);b.find(l.NON_CONTACTS_CONTAINER).addClass("hidden")},P=function(a){var b=t(a);b.find(l.MESSAGES_CONTAINER).removeClass("hidden")},Q=function(a){var b=t(a);b.find(l.MESSAGES_CONTAINER).addClass("hidden")},R=function(a){s(a).prop("disabled",!0)},S=function(a){s(a).prop("disabled",!1)},T=function(a){s(a).val("")},U=function(a){a.find(l.CONTACTS_LIST).empty(),a.find(l.NON_CONTACTS_LIST).empty(),a.find(l.MESSAGES_LIST).empty(),I(a),J(a),L(a),N(a),P(a),Z(a),ba(a)},V=function(a,b){E(a),y(b),G(b),z(a),B(b),R(a)},W=function(a,b){D(a),y(b),F(b),A(a),C(b),S(a)},X=function(a){var b=a.find(l.LOAD_MORE_USERS);b.prop("disabled",!0),b.find(l.BUTTON_TEXT).addClass("hidden"),b.find(l.LOADING_ICON_CONTAINER).removeClass("hidden")},Y=function(a){var b=a.find(l.LOAD_MORE_USERS);b.prop("disabled",!1),b.find(l.BUTTON_TEXT).removeClass("hidden"),b.find(l.LOADING_ICON_CONTAINER).addClass("hidden")},Z=function(a){a.find(l.LOAD_MORE_USERS).removeClass("hidden")},$=function(a){a.find(l.LOAD_MORE_USERS).addClass("hidden")},_=function(a){var b=a.find(l.LOAD_MORE_MESSAGES);b.prop("disabled",!0),b.find(l.BUTTON_TEXT).addClass("hidden"),b.find(l.LOADING_ICON_CONTAINER).removeClass("hidden")},aa=function(a){var b=a.find(l.LOAD_MORE_MESSAGES);b.prop("disabled",!1),b.find(l.BUTTON_TEXT).removeClass("hidden"),b.find(l.LOADING_ICON_CONTAINER).addClass("hidden")},ba=function(a){a.find(l.LOAD_MORE_MESSAGES).removeClass("hidden")},ca=function(a){a.find(l.LOAD_MORE_MESSAGES).addClass("hidden")},da=function(a,b){return a.find('[data-contact-user-id="'+b+'"]')},ea=function(a,b){var c=v(a),d=da(c,b.userid);if(d.length){d.remove();var e=u(a);e.removeClass("hidden"),e.find(l.LIST).append(d)}c.find(l.LIST).children().length||c.addClass("hidden")},fa=function(a,b){var c=u(a),d=da(c,b);if(d.length){d.remove();var e=v(a);e.removeClass("hidden"),e.find(l.LIST).append(d)}c.find(l.LIST).children().length||c.addClass("hidden")},ga=function(a,b){var c=da(a,b);c.length&&c.find(l.BLOCK_ICON_CONTAINER).removeClass("hidden")},ha=function(a,b){var c=da(a,b);c.length&&c.find(l.BLOCK_ICON_CONTAINER).addClass("hidden")},ia=function(a,b){if(!a)return"";var c=new RegExp("("+b+")","gi");return a.replace(c,'
$1
')},ja=function(a,b){var c=u(a),d=a.attr("data-in-panel"),e=c.find(l.LIST);return f.render(m.CONTACTS_LIST,{contacts:b,frompanel:d}).then(function(a){return e.append(a),a})},ka=function(a,b){var c=v(a),d=a.attr("data-in-panel"),e=c.find(l.LIST);return f.render(m.NON_CONTACTS_LIST,{noncontacts:b,frompanel:d}).then(function(a){return e.append(a),a})},la=function(a,b){var c=w(a),d=a.attr("data-in-panel"),e=c.find(l.LIST);return f.render(m.MESSAGES_LIST,{messages:b,frompanel:d}).then(function(a){return e.append(a),a})},ma=function(b,c,d,e,f){var h=!1;return X(b),g.searchUsers(c,d,e+1,f).then(function(a){var b=a.contacts,c=a.noncontacts;return b.length<=e&&c.length<=e?(h=!0,{contacts:b,noncontacts:c}):{contacts:b.slice(0,e),noncontacts:c.slice(0,e)}}).then(function(c){var e=c.contacts.length,f=c.noncontacts.length;return e&&c.contacts.forEach(function(a){a.highlight=ia(a.fullname,d)}),f&&c.noncontacts.forEach(function(a){a.highlight=ia(a.fullname,d)}),a.when(!e||ja(b,c.contacts),!f||ka(b,c.noncontacts)).then(function(){return{contactsCount:e,nonContactsCount:f}})}).then(function(a){return Y(b),h&&$(b),a})["catch"](function(a){throw Y(b),a})},na=function(a,b,c,d,e){var f=!1;return _(a),g.searchMessages(b,c,d+1,e).then(function(a){var b=a.contacts;return b.length<=d?(f=!0,b):b.slice(0,d)}).then(function(b){return b.length?(b.forEach(function(a){a.lastmessage=ia(a.lastmessage,c)}),la(a,b).then(function(){return b.length})):b.length}).then(function(b){return aa(a),f&&ca(a),b})["catch"](function(b){throw aa(a),b})},oa=function(b,c,d,e,f,g,h){var i=n(c);return V(b,c),U(c),a.when(ma(c,i,d,e,f),na(c,i,d,g,h)).then(function(a,d){var e=a.contactsCount,f=a.nonContactsCount;W(b,c),e||f||d?(e||f?(e||M(c),f||O(c)):K(c),d||Q(c)):H(c)})},pa=function(a,e){var f=n(e),g=s(a),m="",o=0,p=0,q=function(b,d){m=g.val().trim(),""!==m&&(o=0,p=0,oa(a,e,m,k,p,i,o).then(function(){g.focus(),p+=k,o+=i})["catch"](c.exception)),d.originalEvent.preventDefault()};b.define(g,[b.events.enter]),b.define(a,[b.events.activate]),b.define(e,[b.events.activate]),g.on(b.events.enter,q),a.on(b.events.activate,l.SEARCH_ACTION,q),e.on(b.events.activate,l.LOAD_MORE_MESSAGES,function(a,b){""!==m&&na(e,f,m,i,o).then(function(){o+=i})["catch"](c.exception),b.originalEvent.preventDefault()}),e.on(b.events.activate,l.LOAD_MORE_USERS,function(a,b){""!==m&&ma(e,f,m,j,p).then(function(){p+=j})["catch"](c.exception),b.originalEvent.preventDefault()}),a.on(b.events.activate,l.CANCEL_SEARCH_BUTTON,function(){T(a),x(e),D(a),G(e),A(a),C(e),p=0,o=0}),d.subscribe(h.CONTACT_ADDED,function(a){ea(e,a)}),d.subscribe(h.CONTACT_REMOVED,function(a){fa(e,a)}),d.subscribe(h.CONTACT_BLOCKED,function(a){ga(e,a)}),d.subscribe(h.CONTACT_UNBLOCKED,function(a){ha(e,a)})},qa=function(b,c,d){d.attr("data-init")||(pa(c,d),d.attr("data-init",!0));var e=s(c);return e.focus(),a.Deferred().resolve().promise()},ra=function(a,b){if("object"!=typeof b)return e.get_string("messagedrawerviewsearch","core_message");var c=s(b),d=c.val().trim();return e.get_string("messagedrawerviewsearch","core_message",d)};return{show:qa,description:ra}});