Revision 7e6e43e1 snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/common.js
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/common.js | ||
---|---|---|
302 | 302 |
|
303 | 303 |
ui.tabs = function(tabsEl, sectionEl) { |
304 | 304 |
var tabLink = tabsEl.find('a'); |
305 |
ui.replaceClass(tabLink.find('.active'), 'outline', 'full'); |
|
305 |
ui.replaceClass(tabLink.find('.active'), 'outline', 'full', 'snf-');
|
|
306 | 306 |
function href(a) { |
307 | 307 |
return a.attr('href'); |
308 | 308 |
} |
... | ... | |
312 | 312 |
return false; |
313 | 313 |
} else { |
314 | 314 |
window.location.hash = $(this).attr('href'); |
315 |
ui.replaceClass($(this).parents(tabsEl).find('.active'), 'full', 'outline'); |
|
315 |
ui.replaceClass($(this).parents(tabsEl).find('.active'), 'full', 'outline', 'snf-');
|
|
316 | 316 |
$(this).parents(tabsEl).find('a').removeClass('active'); |
317 | 317 |
$(this).addClass('active'); |
318 |
ui.replaceClass($(this), 'outline', 'full'); |
|
318 |
ui.replaceClass($(this), 'outline', 'full', 'snf-');
|
|
319 | 319 |
ui.tabsSection( $(this), sectionEl); |
320 | 320 |
} |
321 | 321 |
}) |
322 | 322 |
} |
323 | 323 |
|
324 | 324 |
// the function replaces part of the class of a span that is placed inside an a element |
325 |
ui.replaceClass = function(elements, str1, str2) { |
|
325 |
// the class is a word with the form : firstSubStr+*+str1 and it will be converted to: firstSubStr+*+str2 |
|
326 |
// it must be uniquely recognized by the firstSubStr and the str1. |
|
327 |
|
|
328 |
ui.replaceClass = function(elements, str1, str2, firstSubStr) { |
|
326 | 329 |
$.each($(elements), function() { |
327 |
classOld = $(this).find('span').attr('class'); |
|
330 |
var classOld = $(this).find('span').attr('class'); |
|
331 |
var classNew; |
|
328 | 332 |
if(classOld != undefined && classOld.indexOf(str1) != -1) { |
329 |
var classNew =classOld.replace(str1, str2); |
|
330 | 333 |
if(classOld.indexOf(' ') == -1) { |
334 |
classNew = classOld.replace(str1, str2); |
|
331 | 335 |
$(this).find('.'+classOld).removeClass(classOld).addClass(classNew); |
332 | 336 |
} |
333 | 337 |
else { |
334 |
var classToReplace; |
|
335 |
if(classOld.indexOf(' ') > classOld.indexOf(str1)) { |
|
336 |
classToReplace = classOld.substring(0,classOld.indexOf(' ')); |
|
338 |
// the string starts with the firstSubStr and after the end of the word there's a space |
|
339 |
var expr1 = new RegExp('^'+firstSubStr+'+(\\S*)+'+str1+'+(\\s+)', 'g'); |
|
337 | 340 |
|
338 |
}
|
|
339 |
else {
|
|
341 |
// the word is between spaces
|
|
342 |
var expr2 = new RegExp('(\\s+)'+firstSubStr+'+(\\S*)+'+str1+'+(\\s+)', 'g');
|
|
340 | 343 |
|
341 |
classToReplace = classOld.substring(classOld.indexOf(' ')+1, classOld.indexOf(str1)+str1.length);
|
|
342 |
}
|
|
344 |
// before the word there's at least one space and the string ends with this word
|
|
345 |
var expr3 = new RegExp('(\\s+)'+firstSubStr+'+(\\S*)+'+str1+'$', 'g');
|
|
343 | 346 |
|
344 |
if($(this).find('.'+classToReplace).hasClass(classOld)) { |
|
345 |
console.log('classToReplace ', classToReplace) |
|
346 |
$(this).find('.'+classToReplace).removeClass(classToReplace).addClass(classNew); |
|
347 |
// spaces all over the string |
|
348 |
var spacesExp = new RegExp('\\s+', 'g'); |
|
349 |
|
|
350 |
if(classOld.match(expr1) != null) { |
|
351 |
classToReplace = classOld.match(expr1); |
|
352 |
} |
|
353 |
else if(classOld.match(expr2) != null) { |
|
354 |
classToReplace = classOld.match(expr2); |
|
355 |
} |
|
356 |
else if (classOld.match(expr3) != null) { |
|
357 |
classToReplace = classOld.match(expr3); |
|
347 | 358 |
} |
359 |
classToReplace = classToReplace.toString().replace(spacesExp,""); |
|
360 |
classNew = classToReplace.replace(str1, str2); |
|
361 |
$(this).find('.'+classToReplace).removeClass(classToReplace).addClass(classNew); |
|
348 | 362 |
} |
349 | 363 |
} |
350 | 364 |
}); |
... | ... | |
391 | 405 |
} |
392 | 406 |
else { |
393 | 407 |
$(this).addClass('fix-position'); |
394 |
var marg = parseInt($(self).css('marginLeft')) + cmarg; |
|
408 |
var scrollBarWidth = 14; |
|
409 |
var marg = parseInt($(self).css('marginLeft')) + cmarg - scrollBarWidth; |
|
410 |
tt = marg; |
|
395 | 411 |
setTimeout(function(){ |
396 | 412 |
$(self).animate({ |
397 | 413 |
'margin-left': marg, |
... | ... | |
756 | 772 |
}); |
757 | 773 |
// end of connected details js |
758 | 774 |
|
759 |
ui.replaceClass($('a.current, a.active'), 'outline', 'full'); |
|
775 |
ui.replaceClass($('a.current, a.active'), 'outline', 'full', 'snf-');
|
|
760 | 776 |
|
761 | 777 |
// with the function below the sidebar in detailed views |
762 | 778 |
// will not hide if we click something in a wizard |
Also available in: Unified diff