mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +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 {string} sQuery
|
||||||
* @param {Function} fCallback
|
* @param {Function} fCallback
|
||||||
*/
|
*/
|
||||||
RainLoopApp.prototype.getContactsTagsAutocomplete = function (sQuery, fCallback)
|
RainLoopApp.prototype.getContactTagsAutocomplete = function (sQuery, fCallback)
|
||||||
{
|
{
|
||||||
fCallback(_.filter(RL.data().contactTags(), function (oContactTag) {
|
fCallback(_.filter(RL.data().contactTags(), function (oContactTag) {
|
||||||
return oContactTag && oContactTag.filterHelper(sQuery);
|
return oContactTag && oContactTag.filterHelper(sQuery);
|
||||||
|
|
|
||||||
|
|
@ -572,25 +572,27 @@ ko.bindingHandlers.emailsTags = {
|
||||||
fValue(oEvent.target.value);
|
fValue(oEvent.target.value);
|
||||||
}, this)
|
}, 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)
|
if ($oEl.data('EmailsTagsValue') !== sValue)
|
||||||
{
|
{
|
||||||
$oEl.val(sValue);
|
$oEl.val(sValue);
|
||||||
$oEl.data('EmailsTagsValue', sValue);
|
$oEl.data('EmailsTagsValue', sValue);
|
||||||
$oEl.inputosaurus('refresh');
|
$oEl.inputosaurus('refresh');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if (fValue.focusTrigger)
|
if (fEmailsTagsFilter && ko.utils.unwrapObservable(fEmailsTagsFilter))
|
||||||
{
|
|
||||||
fValue.focusTrigger.subscribe(function (bValue) {
|
|
||||||
if (bValue)
|
|
||||||
{
|
{
|
||||||
$oEl.inputosaurus('focus');
|
$oEl.inputosaurus('focus');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -614,7 +616,7 @@ ko.bindingHandlers.contactTags = {
|
||||||
'inputDelimiters': [',', ';'],
|
'inputDelimiters': [',', ';'],
|
||||||
'outputDelimiter': ',',
|
'outputDelimiter': ',',
|
||||||
'autoCompleteSource': function (oData, fResponse) {
|
'autoCompleteSource': function (oData, fResponse) {
|
||||||
RL.getContactsTagsAutocomplete(oData.term, function (aData) {
|
RL.getContactTagsAutocomplete(oData.term, function (aData) {
|
||||||
fResponse(_.map(aData, function (oTagItem) {
|
fResponse(_.map(aData, function (oTagItem) {
|
||||||
return oTagItem.toLine(false);
|
return oTagItem.toLine(false);
|
||||||
}));
|
}));
|
||||||
|
|
@ -640,29 +642,31 @@ ko.bindingHandlers.contactTags = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
'change': _.bind(function (oEvent) {
|
'change': _.bind(function (oEvent) {
|
||||||
$oEl.data('ContactsTagsValue', oEvent.target.value);
|
$oEl.data('ContactTagsValue', oEvent.target.value);
|
||||||
fValue(oEvent.target.value);
|
fValue(oEvent.target.value);
|
||||||
}, this)
|
}, this)
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
'update': function (oElement, fValueAccessor, fAllBindingsAccessor) {
|
||||||
|
|
||||||
fValue.subscribe(function (sValue) {
|
var
|
||||||
if ($oEl.data('ContactsTagsValue') !== sValue)
|
$oEl = $(oElement),
|
||||||
|
fAllValueFunc = fAllBindingsAccessor(),
|
||||||
|
fContactTagsFilter = fAllValueFunc['contactTagsFilter'] || null,
|
||||||
|
sValue = ko.utils.unwrapObservable(fValueAccessor())
|
||||||
|
;
|
||||||
|
|
||||||
|
if ($oEl.data('ContactTagsValue') !== sValue)
|
||||||
{
|
{
|
||||||
$oEl.val(sValue);
|
$oEl.val(sValue);
|
||||||
$oEl.data('ContactsTagsValue', sValue);
|
$oEl.data('ContactTagsValue', sValue);
|
||||||
$oEl.inputosaurus('refresh');
|
$oEl.inputosaurus('refresh');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if (fValue.focusTrigger)
|
if (fContactTagsFilter && ko.utils.unwrapObservable(fContactTagsFilter))
|
||||||
{
|
|
||||||
fValue.focusTrigger.subscribe(function (bValue) {
|
|
||||||
if (bValue)
|
|
||||||
{
|
{
|
||||||
$oEl.inputosaurus('focus');
|
$oEl.inputosaurus('focus');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -687,8 +687,8 @@ PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePositio
|
||||||
self.contactsCount(iCount);
|
self.contactsCount(iCount);
|
||||||
|
|
||||||
self.contacts(aList);
|
self.contacts(aList);
|
||||||
self.contactTags(aTagsList);
|
|
||||||
self.contacts.loading(false);
|
self.contacts.loading(false);
|
||||||
|
self.contactTags(aTagsList);
|
||||||
|
|
||||||
self.viewClearSearch('' !== self.search());
|
self.viewClearSearch('' !== self.search());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="e-cell e-value">
|
<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="help-block error-desc" data-bind="visible: emptyToError">
|
||||||
<span class="i18n" data-i18n-text="COMPOSE/EMPTY_TO_ERROR_DESC"></span>
|
<span class="i18n" data-i18n-text="COMPOSE/EMPTY_TO_ERROR_DESC"></span>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
||||||
|
|
@ -270,7 +270,7 @@
|
||||||
<div class="controls fix-width">
|
<div class="controls fix-width">
|
||||||
<div class="property-line">
|
<div class="property-line">
|
||||||
<div class="tags-property-container">
|
<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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -3620,25 +3620,27 @@ ko.bindingHandlers.emailsTags = {
|
||||||
fValue(oEvent.target.value);
|
fValue(oEvent.target.value);
|
||||||
}, this)
|
}, 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)
|
if ($oEl.data('EmailsTagsValue') !== sValue)
|
||||||
{
|
{
|
||||||
$oEl.val(sValue);
|
$oEl.val(sValue);
|
||||||
$oEl.data('EmailsTagsValue', sValue);
|
$oEl.data('EmailsTagsValue', sValue);
|
||||||
$oEl.inputosaurus('refresh');
|
$oEl.inputosaurus('refresh');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if (fValue.focusTrigger)
|
if (fEmailsTagsFilter && ko.utils.unwrapObservable(fEmailsTagsFilter))
|
||||||
{
|
|
||||||
fValue.focusTrigger.subscribe(function (bValue) {
|
|
||||||
if (bValue)
|
|
||||||
{
|
{
|
||||||
$oEl.inputosaurus('focus');
|
$oEl.inputosaurus('focus');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -3662,7 +3664,7 @@ ko.bindingHandlers.contactTags = {
|
||||||
'inputDelimiters': [',', ';'],
|
'inputDelimiters': [',', ';'],
|
||||||
'outputDelimiter': ',',
|
'outputDelimiter': ',',
|
||||||
'autoCompleteSource': function (oData, fResponse) {
|
'autoCompleteSource': function (oData, fResponse) {
|
||||||
RL.getContactsTagsAutocomplete(oData.term, function (aData) {
|
RL.getContactTagsAutocomplete(oData.term, function (aData) {
|
||||||
fResponse(_.map(aData, function (oTagItem) {
|
fResponse(_.map(aData, function (oTagItem) {
|
||||||
return oTagItem.toLine(false);
|
return oTagItem.toLine(false);
|
||||||
}));
|
}));
|
||||||
|
|
@ -3688,29 +3690,31 @@ ko.bindingHandlers.contactTags = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
'change': _.bind(function (oEvent) {
|
'change': _.bind(function (oEvent) {
|
||||||
$oEl.data('ContactsTagsValue', oEvent.target.value);
|
$oEl.data('ContactTagsValue', oEvent.target.value);
|
||||||
fValue(oEvent.target.value);
|
fValue(oEvent.target.value);
|
||||||
}, this)
|
}, this)
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
'update': function (oElement, fValueAccessor, fAllBindingsAccessor) {
|
||||||
|
|
||||||
fValue.subscribe(function (sValue) {
|
var
|
||||||
if ($oEl.data('ContactsTagsValue') !== sValue)
|
$oEl = $(oElement),
|
||||||
|
fAllValueFunc = fAllBindingsAccessor(),
|
||||||
|
fContactTagsFilter = fAllValueFunc['contactTagsFilter'] || null,
|
||||||
|
sValue = ko.utils.unwrapObservable(fValueAccessor())
|
||||||
|
;
|
||||||
|
|
||||||
|
if ($oEl.data('ContactTagsValue') !== sValue)
|
||||||
{
|
{
|
||||||
$oEl.val(sValue);
|
$oEl.val(sValue);
|
||||||
$oEl.data('ContactsTagsValue', sValue);
|
$oEl.data('ContactTagsValue', sValue);
|
||||||
$oEl.inputosaurus('refresh');
|
$oEl.inputosaurus('refresh');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if (fValue.focusTrigger)
|
if (fContactTagsFilter && ko.utils.unwrapObservable(fContactTagsFilter))
|
||||||
{
|
|
||||||
fValue.focusTrigger.subscribe(function (bValue) {
|
|
||||||
if (bValue)
|
|
||||||
{
|
{
|
||||||
$oEl.inputosaurus('focus');
|
$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,25 +3623,27 @@ ko.bindingHandlers.emailsTags = {
|
||||||
fValue(oEvent.target.value);
|
fValue(oEvent.target.value);
|
||||||
}, this)
|
}, 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)
|
if ($oEl.data('EmailsTagsValue') !== sValue)
|
||||||
{
|
{
|
||||||
$oEl.val(sValue);
|
$oEl.val(sValue);
|
||||||
$oEl.data('EmailsTagsValue', sValue);
|
$oEl.data('EmailsTagsValue', sValue);
|
||||||
$oEl.inputosaurus('refresh');
|
$oEl.inputosaurus('refresh');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if (fValue.focusTrigger)
|
if (fEmailsTagsFilter && ko.utils.unwrapObservable(fEmailsTagsFilter))
|
||||||
{
|
|
||||||
fValue.focusTrigger.subscribe(function (bValue) {
|
|
||||||
if (bValue)
|
|
||||||
{
|
{
|
||||||
$oEl.inputosaurus('focus');
|
$oEl.inputosaurus('focus');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -3665,7 +3667,7 @@ ko.bindingHandlers.contactTags = {
|
||||||
'inputDelimiters': [',', ';'],
|
'inputDelimiters': [',', ';'],
|
||||||
'outputDelimiter': ',',
|
'outputDelimiter': ',',
|
||||||
'autoCompleteSource': function (oData, fResponse) {
|
'autoCompleteSource': function (oData, fResponse) {
|
||||||
RL.getContactsTagsAutocomplete(oData.term, function (aData) {
|
RL.getContactTagsAutocomplete(oData.term, function (aData) {
|
||||||
fResponse(_.map(aData, function (oTagItem) {
|
fResponse(_.map(aData, function (oTagItem) {
|
||||||
return oTagItem.toLine(false);
|
return oTagItem.toLine(false);
|
||||||
}));
|
}));
|
||||||
|
|
@ -3691,29 +3693,31 @@ ko.bindingHandlers.contactTags = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
'change': _.bind(function (oEvent) {
|
'change': _.bind(function (oEvent) {
|
||||||
$oEl.data('ContactsTagsValue', oEvent.target.value);
|
$oEl.data('ContactTagsValue', oEvent.target.value);
|
||||||
fValue(oEvent.target.value);
|
fValue(oEvent.target.value);
|
||||||
}, this)
|
}, this)
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
'update': function (oElement, fValueAccessor, fAllBindingsAccessor) {
|
||||||
|
|
||||||
fValue.subscribe(function (sValue) {
|
var
|
||||||
if ($oEl.data('ContactsTagsValue') !== sValue)
|
$oEl = $(oElement),
|
||||||
|
fAllValueFunc = fAllBindingsAccessor(),
|
||||||
|
fContactTagsFilter = fAllValueFunc['contactTagsFilter'] || null,
|
||||||
|
sValue = ko.utils.unwrapObservable(fValueAccessor())
|
||||||
|
;
|
||||||
|
|
||||||
|
if ($oEl.data('ContactTagsValue') !== sValue)
|
||||||
{
|
{
|
||||||
$oEl.val(sValue);
|
$oEl.val(sValue);
|
||||||
$oEl.data('ContactsTagsValue', sValue);
|
$oEl.data('ContactTagsValue', sValue);
|
||||||
$oEl.inputosaurus('refresh');
|
$oEl.inputosaurus('refresh');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
if (fValue.focusTrigger)
|
if (fContactTagsFilter && ko.utils.unwrapObservable(fContactTagsFilter))
|
||||||
{
|
|
||||||
fValue.focusTrigger.subscribe(function (bValue) {
|
|
||||||
if (bValue)
|
|
||||||
{
|
{
|
||||||
$oEl.inputosaurus('focus');
|
$oEl.inputosaurus('focus');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -11512,8 +11516,8 @@ PopupsContactsViewModel.prototype.reloadContactList = function (bDropPagePositio
|
||||||
self.contactsCount(iCount);
|
self.contactsCount(iCount);
|
||||||
|
|
||||||
self.contacts(aList);
|
self.contacts(aList);
|
||||||
self.contactTags(aTagsList);
|
|
||||||
self.contacts.loading(false);
|
self.contacts.loading(false);
|
||||||
|
self.contactTags(aTagsList);
|
||||||
|
|
||||||
self.viewClearSearch('' !== self.search());
|
self.viewClearSearch('' !== self.search());
|
||||||
|
|
||||||
|
|
@ -21040,7 +21044,7 @@ RainLoopApp.prototype.getAutocomplete = function (sQuery, fCallback)
|
||||||
* @param {string} sQuery
|
* @param {string} sQuery
|
||||||
* @param {Function} fCallback
|
* @param {Function} fCallback
|
||||||
*/
|
*/
|
||||||
RainLoopApp.prototype.getContactsTagsAutocomplete = function (sQuery, fCallback)
|
RainLoopApp.prototype.getContactTagsAutocomplete = function (sQuery, fCallback)
|
||||||
{
|
{
|
||||||
fCallback(_.filter(RL.data().contactTags(), function (oContactTag) {
|
fCallback(_.filter(RL.data().contactTags(), function (oContactTag) {
|
||||||
return oContactTag && oContactTag.filterHelper(sQuery);
|
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