Browse Source

#1784 Updates Tab remote API syntax with changes in 1.x

pull/1785/head
jlukic 9 years ago
parent
commit
0b9edd1eda
1 changed files with 12 additions and 10 deletions
  1. 22
      src/definitions/modules/tab.js

22
src/definitions/modules/tab.js

@ -77,7 +77,7 @@ $.fn.tab = function(parameters) {
if(settings.auto) {
module.verbose('Setting up automatic tab retrieval from server');
settings.apiSettings = {
url: settings.path + '/{$tab}'
url: (settings.path || '') + '/{$tab}'
};
}
@ -270,10 +270,10 @@ $.fn.tab = function(parameters) {
;
module.verbose('Looking for tab', tab);
if(isTab) {
module.verbose('Tab was found', tab);
module.verbose('Tab was found', tab);
// scope up
activeTabPath = currentPath;
activeTabPath = currentPath;
parameterArray = module.utilities.filterArray(pathArray, currentPathArray);
if(isLastIndex) {
@ -341,11 +341,11 @@ $.fn.tab = function(parameters) {
fetch: function(tabPath, fullTabPath) {
var
$tab = module.get.tabElement(tabPath),
apiSettings = {
dataType : 'html',
stateContext : $tab,
onSuccess : function(response) {
$tab = module.get.tabElement(tabPath),
apiSettings = {
dataType : 'html',
on : 'now',
onSuccess : function(response) {
module.cache.add(fullTabPath, response);
module.content.update(tabPath, response);
if(tabPath == activeTabPath) {
@ -360,7 +360,7 @@ $.fn.tab = function(parameters) {
},
urlData: { tab: fullTabPath }
},
request = $tab.data(metadata.promise) || false,
request = $tab.api('get request') || false,
existingRequest = ( request && request.state() === 'pending' ),
requestSettings,
cachedContent
@ -369,6 +369,7 @@ $.fn.tab = function(parameters) {
fullTabPath = fullTabPath || tabPath;
cachedContent = module.cache.read(fullTabPath);
if(settings.cache && cachedContent) {
module.debug('Showing existing content', fullTabPath);
module.content.update(tabPath, cachedContent);
@ -384,7 +385,8 @@ $.fn.tab = function(parameters) {
else if($.api !== undefined) {
requestSettings = $.extend(true, { headers: { 'X-Remote': true } }, settings.apiSettings, apiSettings);
module.debug('Retrieving remote content', fullTabPath, requestSettings);
$.api( requestSettings );
console.log(existingRequest, requestSettings, cachedContent);
$tab.api( requestSettings );
}
else {
module.error(error.api);

Loading…
Cancel
Save