template redesign

This commit is contained in:
Jana Deutschländer 2017-01-02 08:58:59 +01:00
commit f414dd9577
31 changed files with 1156 additions and 80 deletions

79
js/base/helper.js Normal file
View file

@ -0,0 +1,79 @@
/**
* @file helper funcs
*
*/
// + + + + + + + + + + + + + + + + + + + + + + + + + + + +
// shuffle func for random values
// + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Array.prototype.shuffle = function(){
var tmp, rand;
for(var i =0; i < this.length; i++){
rand = Math.floor(Math.random() * this.length);
tmp = this[i];
this[i] = this[rand];
this[rand] =tmp;
}
};
// + + + + + + + + + + + + + + + + + + + + + + + + + + + +
// js trim func for ie
// + + + + + + + + + + + + + + + + + + + + + + + + + + + +
if(typeof String.prototype.trim !== 'function') {
String.prototype.trim = function() {
return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
};
}
var linkTo_UnCryptMailto = function(s){
location.href=decryptString(s,-2);
};
var decryptCharcode = function(n, start, end, offset) {
n = n + offset;
if (offset > 0 && n > end) {
n = start + (n - end - 1);
} else if (offset < 0 && n < start) {
n = end - (start - n - 1);
}
return String.fromCharCode(n);
};
var decryptString = function(enc, offset) {
var dec = '';
var len = enc.length;
for (var i = 0; i < len; i++) {
var n = enc.charCodeAt(i);
if (n >= 43 && n <= 58) {
dec += decryptCharcode(n, 43, 58, offset);
} else if (n >= 64 && n <= 90) {
dec += decryptCharcode(n, 64, 90, offset);
} else if (n >= 97 && n <= 122) {
dec += decryptCharcode(n, 97, 122, offset);
} else {
dec += enc.charAt(i);
}
}
return dec;
};
/**
* simplify setting and getting state out of a node
* $("#my_id").data("my_data_attr") equals $$("#my_id").my_data_attr and
* $("#my_id").data("my_data_attr", "my_data_val") equals $$("#my_id").my_data_attr = my_data_val
* you can also do
* $$("#my_id").my_data_val = $$("#my_id").my_data_val + 1.
*/
var $$ = function(param) {
var node = $(param)[0];
var id = $.data(node);
$.cache[id] = $.cache[id] || {};
$.cache[id].node = node;
return $.cache[id];
};
var alertFB = false;
if (typeof console === "undefined" || typeof console.log === "undefined") {
console = {};
if (alertFB) {
console.log = function(msg) {
alert(msg);
};
} else {
console.log = function() {};
}
}

169
js/base/spc.js Normal file
View file

@ -0,0 +1,169 @@
/**
* @file utility funcs for jQuery projects
*
*/
// + + + + + + + + + + + + + + + + + + + + + + + + + + + +
// object literal with funcs for jquery plug-ins
// + + + + + + + + + + + + + + + + + + + + + + + + + + + +
var spc = {
/*general options */
config: {
debug: false,
dev: true
},
isDef: function(val){
return (val===undefined) ? false : true;
},
/* get options of object */
get_options: function(key, options){
var result = null;
if ('object' == typeof(options)) {
result = options[key];
}
if (!result) { return ""; }
return result;
},
/* set wai aria roles to list of containern */
set_wa: function(contlist, ariaattr,ariaval){
$(contlist).attr(ariaattr, ariaval);
},
/* Encode/decode htmlentities */
encode_entities: function(s){
return $("<acronym/>").text(s).html();
},
decode_entities: function(s){
return $("<acronym/>").html(s).text();
},
/* add func to load event */
add_loadEvent: function(func_name){
var lastonload = window.onload;
if (typeof window.onload != 'function') { window.onload = func_name; }
else { window.onload = function() { lastonload(); func_name(); }; }
},
/* logging for debug */
_debug: function(msg){
if(this.config.debug) {
try{
if(console){
console.log(msg);
} else{
alert(msg);
}
}catch(err){
alert(msg);
}
}
},
/* return obj values for debug */
_get_objVs: function(objl){
try{
var p = typeof JSON != "undefined" ? JSON.stringify : function(objl){
var arr = [];
$.each(objl,function(key,val){
var next = key + ": ";
next += $.isPlainObject(val) ? printObj(val) : val;
arr.push( next );
});
return "{ " + arr.join(", ") + " }";
};
return p(objl);
}catch(err){
this._debug(err);
return '';
}
},
aria_live: function(setobj){
if(typeof(setobj)=='object'){
setobj.attr('aria-live',"polite");
}
},
aria_role: function(setobj, role){
if(typeof(setobj)=='object'){
setobj.attr('role',role);
}
},
change_tabindex: function(remobj,setobj,i){
if(typeof(remobj)=='object'){
remobj.removeAttr('tabindex');
}
if(typeof(setobj)=='object'){
setobj.attr('tabindex',i);
}
},
/* set focus to dom object: param obj */
set_newfocusObj: function(focusobj){
try{
if(focusobj) focusobj.focus();
}catch(err){
this._debug('exception: '+err);
}
},
/* set focus to dom object: param id */
set_newfocusId: function(fid){
try{
var focusobj = document.getElementById(fid);
if(focusobj) focusobj.focus();
if(focusobj) console.log(focusobj);
}catch(err){
this._debug('exception: '+err);
}
},
/* set focus to nonfocussable dom object: */
set_newfocusBox: function(remobj,setobj){
this.change_tabindex(remobj,setobj,0);
try{
if(setobj) setobj.focus();
}catch(err){
this._debug('exception: '+err);
}
},
/* set title(s) and remove other title(s) if set */
set_title: function(remobj,setobj,ctitle){
if(typeof(remobj)=='object'){
remobj.removeAttr('title');
}
if(typeof(setobj)=='object'){
setobj.attr('title',ctitle);
}
},
/* count appearances of dom elems with certain markup */
count: function(jqdom){
var num = 0;
$(jqdom).each(function() {
num++;
});
return num;
},
countOV: function(objlit){
var i = 0;
for (var elem in objlit){
i++;
}
return i;
},
/*merge object literals (do not overwrite default, not recursively) */
merge: function(objl1,objl2,objl3,objl4){
return $.extend({},objl1,objl2,objl3,objl4);
},
/*merge object literals (do not overwrite default, recursively) */
mergeR: function(objl1,objl2,objl3,objl4){
return $.extend(true,{},objl1,objl2,objl3,objl4);
},
loadImage: function(isrc, func, errfunc){
try{
var img = new Image();
img.onload = func;
img.onerror = errfunc;
img.src = isrc;
}catch(err){
errfunc();
}
},
tb_getPageSize: function(){
var de=document.documentElement;
var w=window.innerWidth||self.innerWidth||(de&&de.clientWidth)||document.body.clientWidth;
var h=window.innerHeight||self.innerHeight||(de&&de.clientHeight)||document.body.clientHeight;
arrayPageSize=[w,h];
return arrayPageSize;
}
};

37
js/plugins/do_tasks.js Normal file
View file

@ -0,0 +1,37 @@
( function( $, spc ) {
var togglePageAnalysis = function(){
var $this = $('.page-attributes').find('.plugin__qc');
try{
var $link = $this.find('#plugin__qc__link'),
$container = $this.find('#plugin__qc__wrapper');
if($container.length < 1){
$this.remove();
}else{
$container.attr('aria-hidden','true');
var $icon = $container.find('#plugin__qc__icon');
$container.find('#plugin__qc__out').removeAttr('style');
$link.on( 'click', function(e){
e.preventDefault();
$icon.trigger('click');
var oldState = ($link.attr('aria-expanded')=== "true" );
$container.attr('aria-hidden',oldState);
$(this).attr('aria-expanded',!oldState);
});
}
}catch(err){
$this.remove();
}
};
$(function(){
togglePageAnalysis();
});
} )( jQuery, spc );