mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-08 22:18:28 +03:00
knockout bind optimizations
This commit is contained in:
parent
eb11eaa096
commit
2fa2cd191e
9 changed files with 126 additions and 114 deletions
|
|
@ -978,7 +978,7 @@ RainLoopApp.prototype.getAutocomplete = function (sQuery, fCallback)
|
|||
* @param {string} sQuery
|
||||
* @param {Function} fCallback
|
||||
*/
|
||||
RainLoopApp.prototype.getContactsTagsAutocomplete = function (sQuery, fCallback)
|
||||
RainLoopApp.prototype.getContactTagsAutocomplete = function (sQuery, fCallback)
|
||||
{
|
||||
fCallback(_.filter(RL.data().contactTags(), function (oContactTag) {
|
||||
return oContactTag && oContactTag.filterHelper(sQuery);
|
||||
|
|
|
|||
|
|
@ -572,24 +572,26 @@ ko.bindingHandlers.emailsTags = {
|
|||
fValue(oEvent.target.value);
|
||||
}, this)
|
||||
});
|
||||
},
|
||||
'update': function (oElement, fValueAccessor, fAllBindingsAccessor) {
|
||||
|
||||
var
|
||||
$oEl = $(oElement),
|
||||
fAllValueFunc = fAllBindingsAccessor(),
|
||||
fEmailsTagsFilter = fAllValueFunc['emailsTagsFilter'] || null,
|
||||
sValue = ko.utils.unwrapObservable(fValueAccessor())
|
||||
;
|
||||
|
||||
fValue.subscribe(function (sValue) {
|
||||
if ($oEl.data('EmailsTagsValue') !== sValue)
|
||||
{
|
||||
$oEl.val(sValue);
|
||||
$oEl.data('EmailsTagsValue', sValue);
|
||||
$oEl.inputosaurus('refresh');
|
||||
}
|
||||
});
|
||||
|
||||
if (fValue.focusTrigger)
|
||||
if ($oEl.data('EmailsTagsValue') !== sValue)
|
||||
{
|
||||
fValue.focusTrigger.subscribe(function (bValue) {
|
||||
if (bValue)
|
||||
{
|
||||
$oEl.inputosaurus('focus');
|
||||
}
|
||||
});
|
||||
$oEl.val(sValue);
|
||||
$oEl.data('EmailsTagsValue', sValue);
|
||||
$oEl.inputosaurus('refresh');
|
||||
}
|
||||
|
||||
if (fEmailsTagsFilter && ko.utils.unwrapObservable(fEmailsTagsFilter))
|
||||
{
|
||||
$oEl.inputosaurus('focus');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -614,7 +616,7 @@ ko.bindingHandlers.contactTags = {
|
|||
'inputDelimiters': [',', ';'],
|
||||
'outputDelimiter': ',',
|
||||
'autoCompleteSource': function (oData, fResponse) {
|
||||
RL.getContactsTagsAutocomplete(oData.term, function (aData) {
|
||||
RL.getContactTagsAutocomplete(oData.term, function (aData) {
|
||||
fResponse(_.map(aData, function (oTagItem) {
|
||||
return oTagItem.toLine(false);
|
||||
}));
|
||||
|
|
@ -640,28 +642,30 @@ ko.bindingHandlers.contactTags = {
|
|||
});
|
||||
},
|
||||
'change': _.bind(function (oEvent) {
|
||||
$oEl.data('ContactsTagsValue', oEvent.target.value);
|
||||
$oEl.data('ContactTagsValue', oEvent.target.value);
|
||||
fValue(oEvent.target.value);
|
||||
}, this)
|
||||
});
|
||||
},
|
||||
'update': function (oElement, fValueAccessor, fAllBindingsAccessor) {
|
||||
|
||||
fValue.subscribe(function (sValue) {
|
||||
if ($oEl.data('ContactsTagsValue') !== sValue)
|
||||
{
|
||||
$oEl.val(sValue);
|
||||
$oEl.data('ContactsTagsValue', sValue);
|
||||
$oEl.inputosaurus('refresh');
|
||||
}
|
||||
});
|
||||
var
|
||||
$oEl = $(oElement),
|
||||
fAllValueFunc = fAllBindingsAccessor(),
|
||||
fContactTagsFilter = fAllValueFunc['contactTagsFilter'] || null,
|
||||
sValue = ko.utils.unwrapObservable(fValueAccessor())
|
||||
;
|
||||
|
||||
if (fValue.focusTrigger)
|
||||
if ($oEl.data('ContactTagsValue') !== sValue)
|
||||
{
|
||||
fValue.focusTrigger.subscribe(function (bValue) {
|
||||
if (bValue)
|
||||
{
|
||||
$oEl.inputosaurus('focus');
|
||||
}
|
||||
});
|
||||
$oEl.val(sValue);
|
||||
$oEl.data('ContactTagsValue', sValue);
|
||||
$oEl.inputosaurus('refresh');
|
||||
}
|
||||
|
||||
if (fContactTagsFilter && ko.utils.unwrapObservable(fContactTagsFilter))
|
||||
{
|
||||
$oEl.inputosaurus('focus');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -687,8 +687,8 @@ PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePositio
|
|||
self.contactsCount(iCount);
|
||||
|
||||
self.contacts(aList);
|
||||
self.contactTags(aTagsList);
|
||||
self.contacts.loading(false);
|
||||
self.contactTags(aTagsList);
|
||||
|
||||
self.viewClearSearch('' !== self.search());
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@
|
|||
</label>
|
||||
</div>
|
||||
<div class="e-cell e-value">
|
||||
<input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" data-bind="emailsTags: to" />
|
||||
<input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" data-bind="emailsTags: to, emailsTagsFilter: to.focusTrigger" />
|
||||
<span class="help-block error-desc" data-bind="visible: emptyToError">
|
||||
<span class="i18n" data-i18n-text="COMPOSE/EMPTY_TO_ERROR_DESC"></span>
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@
|
|||
<div class="controls fix-width">
|
||||
<div class="property-line">
|
||||
<div class="tags-property-container">
|
||||
<input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" data-bind="contactTags: viewTags" />
|
||||
<input type="text" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" data-bind="contactTags: viewTags, contactTagsFilter: viewTags.focusTrigger" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -3620,24 +3620,26 @@ ko.bindingHandlers.emailsTags = {
|
|||
fValue(oEvent.target.value);
|
||||
}, this)
|
||||
});
|
||||
},
|
||||
'update': function (oElement, fValueAccessor, fAllBindingsAccessor) {
|
||||
|
||||
var
|
||||
$oEl = $(oElement),
|
||||
fAllValueFunc = fAllBindingsAccessor(),
|
||||
fEmailsTagsFilter = fAllValueFunc['emailsTagsFilter'] || null,
|
||||
sValue = ko.utils.unwrapObservable(fValueAccessor())
|
||||
;
|
||||
|
||||
fValue.subscribe(function (sValue) {
|
||||
if ($oEl.data('EmailsTagsValue') !== sValue)
|
||||
{
|
||||
$oEl.val(sValue);
|
||||
$oEl.data('EmailsTagsValue', sValue);
|
||||
$oEl.inputosaurus('refresh');
|
||||
}
|
||||
});
|
||||
|
||||
if (fValue.focusTrigger)
|
||||
if ($oEl.data('EmailsTagsValue') !== sValue)
|
||||
{
|
||||
fValue.focusTrigger.subscribe(function (bValue) {
|
||||
if (bValue)
|
||||
{
|
||||
$oEl.inputosaurus('focus');
|
||||
}
|
||||
});
|
||||
$oEl.val(sValue);
|
||||
$oEl.data('EmailsTagsValue', sValue);
|
||||
$oEl.inputosaurus('refresh');
|
||||
}
|
||||
|
||||
if (fEmailsTagsFilter && ko.utils.unwrapObservable(fEmailsTagsFilter))
|
||||
{
|
||||
$oEl.inputosaurus('focus');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -3662,7 +3664,7 @@ ko.bindingHandlers.contactTags = {
|
|||
'inputDelimiters': [',', ';'],
|
||||
'outputDelimiter': ',',
|
||||
'autoCompleteSource': function (oData, fResponse) {
|
||||
RL.getContactsTagsAutocomplete(oData.term, function (aData) {
|
||||
RL.getContactTagsAutocomplete(oData.term, function (aData) {
|
||||
fResponse(_.map(aData, function (oTagItem) {
|
||||
return oTagItem.toLine(false);
|
||||
}));
|
||||
|
|
@ -3688,28 +3690,30 @@ ko.bindingHandlers.contactTags = {
|
|||
});
|
||||
},
|
||||
'change': _.bind(function (oEvent) {
|
||||
$oEl.data('ContactsTagsValue', oEvent.target.value);
|
||||
$oEl.data('ContactTagsValue', oEvent.target.value);
|
||||
fValue(oEvent.target.value);
|
||||
}, this)
|
||||
});
|
||||
},
|
||||
'update': function (oElement, fValueAccessor, fAllBindingsAccessor) {
|
||||
|
||||
fValue.subscribe(function (sValue) {
|
||||
if ($oEl.data('ContactsTagsValue') !== sValue)
|
||||
{
|
||||
$oEl.val(sValue);
|
||||
$oEl.data('ContactsTagsValue', sValue);
|
||||
$oEl.inputosaurus('refresh');
|
||||
}
|
||||
});
|
||||
var
|
||||
$oEl = $(oElement),
|
||||
fAllValueFunc = fAllBindingsAccessor(),
|
||||
fContactTagsFilter = fAllValueFunc['contactTagsFilter'] || null,
|
||||
sValue = ko.utils.unwrapObservable(fValueAccessor())
|
||||
;
|
||||
|
||||
if (fValue.focusTrigger)
|
||||
if ($oEl.data('ContactTagsValue') !== sValue)
|
||||
{
|
||||
fValue.focusTrigger.subscribe(function (bValue) {
|
||||
if (bValue)
|
||||
{
|
||||
$oEl.inputosaurus('focus');
|
||||
}
|
||||
});
|
||||
$oEl.val(sValue);
|
||||
$oEl.data('ContactTagsValue', sValue);
|
||||
$oEl.inputosaurus('refresh');
|
||||
}
|
||||
|
||||
if (fContactTagsFilter && ko.utils.unwrapObservable(fContactTagsFilter))
|
||||
{
|
||||
$oEl.inputosaurus('focus');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
8
rainloop/v/0.0.0/static/js/admin.min.js
vendored
8
rainloop/v/0.0.0/static/js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -3623,24 +3623,26 @@ ko.bindingHandlers.emailsTags = {
|
|||
fValue(oEvent.target.value);
|
||||
}, this)
|
||||
});
|
||||
},
|
||||
'update': function (oElement, fValueAccessor, fAllBindingsAccessor) {
|
||||
|
||||
var
|
||||
$oEl = $(oElement),
|
||||
fAllValueFunc = fAllBindingsAccessor(),
|
||||
fEmailsTagsFilter = fAllValueFunc['emailsTagsFilter'] || null,
|
||||
sValue = ko.utils.unwrapObservable(fValueAccessor())
|
||||
;
|
||||
|
||||
fValue.subscribe(function (sValue) {
|
||||
if ($oEl.data('EmailsTagsValue') !== sValue)
|
||||
{
|
||||
$oEl.val(sValue);
|
||||
$oEl.data('EmailsTagsValue', sValue);
|
||||
$oEl.inputosaurus('refresh');
|
||||
}
|
||||
});
|
||||
|
||||
if (fValue.focusTrigger)
|
||||
if ($oEl.data('EmailsTagsValue') !== sValue)
|
||||
{
|
||||
fValue.focusTrigger.subscribe(function (bValue) {
|
||||
if (bValue)
|
||||
{
|
||||
$oEl.inputosaurus('focus');
|
||||
}
|
||||
});
|
||||
$oEl.val(sValue);
|
||||
$oEl.data('EmailsTagsValue', sValue);
|
||||
$oEl.inputosaurus('refresh');
|
||||
}
|
||||
|
||||
if (fEmailsTagsFilter && ko.utils.unwrapObservable(fEmailsTagsFilter))
|
||||
{
|
||||
$oEl.inputosaurus('focus');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -3665,7 +3667,7 @@ ko.bindingHandlers.contactTags = {
|
|||
'inputDelimiters': [',', ';'],
|
||||
'outputDelimiter': ',',
|
||||
'autoCompleteSource': function (oData, fResponse) {
|
||||
RL.getContactsTagsAutocomplete(oData.term, function (aData) {
|
||||
RL.getContactTagsAutocomplete(oData.term, function (aData) {
|
||||
fResponse(_.map(aData, function (oTagItem) {
|
||||
return oTagItem.toLine(false);
|
||||
}));
|
||||
|
|
@ -3691,28 +3693,30 @@ ko.bindingHandlers.contactTags = {
|
|||
});
|
||||
},
|
||||
'change': _.bind(function (oEvent) {
|
||||
$oEl.data('ContactsTagsValue', oEvent.target.value);
|
||||
$oEl.data('ContactTagsValue', oEvent.target.value);
|
||||
fValue(oEvent.target.value);
|
||||
}, this)
|
||||
});
|
||||
},
|
||||
'update': function (oElement, fValueAccessor, fAllBindingsAccessor) {
|
||||
|
||||
fValue.subscribe(function (sValue) {
|
||||
if ($oEl.data('ContactsTagsValue') !== sValue)
|
||||
{
|
||||
$oEl.val(sValue);
|
||||
$oEl.data('ContactsTagsValue', sValue);
|
||||
$oEl.inputosaurus('refresh');
|
||||
}
|
||||
});
|
||||
var
|
||||
$oEl = $(oElement),
|
||||
fAllValueFunc = fAllBindingsAccessor(),
|
||||
fContactTagsFilter = fAllValueFunc['contactTagsFilter'] || null,
|
||||
sValue = ko.utils.unwrapObservable(fValueAccessor())
|
||||
;
|
||||
|
||||
if (fValue.focusTrigger)
|
||||
if ($oEl.data('ContactTagsValue') !== sValue)
|
||||
{
|
||||
fValue.focusTrigger.subscribe(function (bValue) {
|
||||
if (bValue)
|
||||
{
|
||||
$oEl.inputosaurus('focus');
|
||||
}
|
||||
});
|
||||
$oEl.val(sValue);
|
||||
$oEl.data('ContactTagsValue', sValue);
|
||||
$oEl.inputosaurus('refresh');
|
||||
}
|
||||
|
||||
if (fContactTagsFilter && ko.utils.unwrapObservable(fContactTagsFilter))
|
||||
{
|
||||
$oEl.inputosaurus('focus');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -11512,8 +11516,8 @@ PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePositio
|
|||
self.contactsCount(iCount);
|
||||
|
||||
self.contacts(aList);
|
||||
self.contactTags(aTagsList);
|
||||
self.contacts.loading(false);
|
||||
self.contactTags(aTagsList);
|
||||
|
||||
self.viewClearSearch('' !== self.search());
|
||||
|
||||
|
|
@ -21040,7 +21044,7 @@ RainLoopApp.prototype.getAutocomplete = function (sQuery, fCallback)
|
|||
* @param {string} sQuery
|
||||
* @param {Function} fCallback
|
||||
*/
|
||||
RainLoopApp.prototype.getContactsTagsAutocomplete = function (sQuery, fCallback)
|
||||
RainLoopApp.prototype.getContactTagsAutocomplete = function (sQuery, fCallback)
|
||||
{
|
||||
fCallback(_.filter(RL.data().contactTags(), function (oContactTag) {
|
||||
return oContactTag && oContactTag.filterHelper(sQuery);
|
||||
|
|
|
|||
10
rainloop/v/0.0.0/static/js/app.min.js
vendored
10
rainloop/v/0.0.0/static/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue