1var tplmod_aside_width = 0;
2var tplmod_content_width = 0;
3var tplmod_toggle_open = 0;
4var tplmod_content_padding = {'b':0,'t':0};
5jQuery(document).ready(function() {
6
7 // get default values
8
9if(JSINFO['tmplft_template'] == 'bootstrap3') {
10	tplmod_aside_width = parseInt(jQuery("aside#dokuwiki__aside").css('width'));
11	tplmod_content_width = parseInt(jQuery("article#dokuwiki__content").css('width'));
12}
13else {
14	tplmod_aside_width = parseInt(jQuery("div#dokuwiki__aside").css('width'));
15	tplmod_content_width = parseInt(jQuery("div#dokuwiki__content").css('width'));
16}
17tplmod_toggle_open = tplmod_aside_width + tplmod_content_width;
18tplmod_content_padding.t =jQuery("div.wrapper").css('padding-top');
19tplmod_content_padding.b =jQuery("div.wrapper").css('padding-bottom');
20
21
22
23if(isNaN(JSINFO['tmplftacl']))  {
24    JSINFO['tmplftacl'] = 0;
25}
26
27if(JSINFO['tmplftacl'] < 255) {
28    jQuery("#dokuwiki__usertools > ul > li.admin").hide();
29}
30if(JSINFO['tmplft_template'] == 'monochrome' && JSINFO['tmplft_bgcolor']) {
31    jQuery("html").css('background-color',JSINFO['tmplft_bgcolor'] );
32    jQuery("body").css('background-color',JSINFO['tmplft_bgcolor'] );
33    jQuery("div#dw__toc").css('background-color',JSINFO['tmplft_bgcolor'] );
34}
35
36var acl = ((JSINFO['tmplftacl'] >= 0)  && (JSINFO['tmplftacl'] <= JSINFO['tmplft_aclgen'])) ? true: false;
37
38if(JSINFO['tmplft_template'] == 'monochrome'  && !JSINFO['tmplft_logo'])   {
39     jQuery("div.pad div.headings img").first().css('padding-right','4px');
40 }
41
42if(JSINFO['tmplft_logo']) {
43 if(JSINFO['tmplft_template']    == 'monochrome')   {
44       jQuery("div.pad div.headings img").first().attr("src", function( i, val ) {
45       if(JSINFO['tmplft_logo_width']) {
46          this.width = JSINFO['tmplft_logo_width'] ;
47          }
48      var elems = val.split(/[\/\\]/);
49      this.style.padding = '4px';
50      var img = elems.pop();
51          return val.replace(img,JSINFO['tmplft_logo']);
52    });
53 }
54 else {
55jQuery("div.headings.group h1 img,div.navbar-header img").attr("src", function( i, val ) {
56      if(JSINFO['tmplft_logo_width']) {
57  this.width = JSINFO['tmplft_logo_width'] ;
58      }
59  var elems = val.split(/[\/\\]/);
60  var img = elems.pop();
61      return val.replace(img,JSINFO['tmplft_logo']);
62});
63}
64}
65
66
67if(JSINFO['tmplft_tag'] ) {
68jQuery("p.claim,span#dw__tagline").html(function(i,val) {
69
70       if(val.match(/<.*?>/)) {
71          val = val.replace(/^\s*(<.*?>)(.*?)(<\/)/,function(m,m1,m2,m3) {
72              return m1 + JSINFO['tmplft_tag']  +  m3;
73         } );
74     }
75     else val = JSINFO['tmplft_tag'] ;
76     if(JSINFO['tmplft_template'] == 'bootstrap3') {
77         jQuery("span#dw__tagline").css("padding-top", "2px");
78     }
79    return val;
80});
81}
82
83if(JSINFO['tmplft_title'] ) {
84     jQuery("div.headings.group h1 span").html(function(index,val) {
85         return  JSINFO['tmplft_title'] ;
86    });
87
88     jQuery("span#dw__title").html(function(index,val) {
89         var elems = val.split('<span');
90         return  JSINFO['tmplft_title']  + '<span' +elems[1] ;
91    });
92}
93
94
95if(acl && JSINFO['tmplft_template'] == 'bootstrap3') {    var regex;
96       if(JSINFO['tmplft_mobile'])
97          regex = new RegExp(JSINFO['tmplft_mobile']);
98      else regex = '/NONE/';
99     jQuery("ul.dropdown-menu.tools li").each (function( index ) {
100      var  _html =  jQuery( this ).html();
101       if( _html.match(regex))  {
102           jQuery(this). html("");
103       }
104    });
105}
106
107if(acl && JSINFO['tmplft_pagetools']) {
108     var regex = new RegExp(JSINFO['tmplft_pagetools'].replace(/,/g,"|"));
109     if(JSINFO['tmplft_ptools_xcl']) {
110         var xcludes = new RegExp(JSINFO['tmplft_ptools_xcl'].replace(/,/g,"|"));
111     }
112      if (typeof xcludes == 'undefined') {
113             xcludes = new RegExp("NONE");
114       }
115     /* nav#dw__pagetools => bootstrap3 */
116    jQuery( "#dokuwiki__pagetools a, nav#dw__pagetools li a" ).each(function( index ) {
117        var url  = jQuery( this ).attr('href');
118      var _class = jQuery(this).attr('class');
119
120      if(_class && _class.match(/show/)) {
121       return 1;  //  continue: keep show icon
122      }
123
124       if(url.match(regex)  && !url.match(xcludes)) {
125              jQuery( this ).hide();
126        }
127    });
128}
129
130jQuery("div.mobileTools option") .each(function(index, opt) {
131    var opts, regex, xcludes, optparent;
132    optparent = jQuery(this).parent("optgroup");
133    if(optparent.attr('label') && optparent.attr('label').match(/User\s+Tools/i)) return;
134
135    if(JSINFO['tmplft_ptools_xcl']) {
136         xcludes = new RegExp(JSINFO['tmplft_ptools_xcl'].replace(/,/g,"|"));
137         if (acl && typeof xcludes != 'undefined') {
138              if(opt.value.match(xcludes)) return;
139         }
140    }
141    var regex = new RegExp(JSINFO['tmplft_mobile']);
142    if(acl && regex) {
143        if(opt.value.match(regex))  jQuery(this).hide();
144    }
145});
146
147if(acl && JSINFO['tmplft_sitetools']) {
148    var regex = new RegExp(JSINFO['tmplft_sitetools'].replace(/,/g,"|"));
149    jQuery( "#dokuwiki__sitetools a,#sidebar-site-tools a,#dokuwiki__usertools > ul > li a").each(function( index ) {
150        var url  = jQuery( this ).attr('href');
151        if(url.match(regex)) {
152            jQuery( this ).hide();
153        }
154    });
155}
156
157
158if(JSINFO['tmplft_profile']) {
159   	if(JSINFO['tmplft_template'] == 'bootstrap3') {
160	     jQuery("li a.action.profile").parent().html("");
161	}
162    else {
163		jQuery("div#dokuwiki__usertools li.profile, div#dokuwiki__usertools a[href$='profile']").hide();
164	}
165}
166if(acl && JSINFO['tmplft_search'] ) jQuery("form#dw__search").hide();
167
168});
169
170function tplmod_toggle_aside() {
171	var display,content_width;
172
173   	if(JSINFO['tmplft_template'] == 'bootstrap3') {
174        content_width = parseInt(jQuery("article#dokuwiki__content").css('width'));
175	}
176	else {
177	    content_width = parseInt(jQuery("div#dokuwiki__content").css('width'))
178	}
179    if(content_width == tplmod_toggle_open) {
180        content_width = tplmod_content_width;
181        if(JSINFO['tmplft_template']    == 'monochrome')   {
182           jQuery("div#dokuwiki__content").css('padding-left','0px');
183           jQuery("div.wrapper").css('padding-top',tplmod_content_padding.t);
184           jQuery("div.wrapper").css('padding-bottom',tplmod_content_padding.b);
185        }
186        display = true;
187    }
188    else {
189        content_width = tplmod_toggle_open;
190        if(JSINFO['tmplft_template']    == 'monochrome')   {
191            jQuery("div.wrapper").css('padding-top','0px');
192            jQuery("div.wrapper").css('padding-bottom','0px');
193             jQuery("div#dokuwiki__content").css('padding-left','8px');
194             jQuery("div#dokuwiki__content").css('background-color','white');
195        }
196        display = false;
197    }
198	if(JSINFO['tmplft_template'] == 'bootstrap3') {
199		jQuery("aside#dokuwiki__aside").toggle(display);
200		jQuery("article#dokuwiki__content").css("width", content_width +'px' );
201	}
202    else {
203	    jQuery("div#dokuwiki__aside").toggle(display);
204        jQuery("div#dokuwiki__content").css("width", content_width +'px' );
205    }
206}
207 function tplmod_setui_lang(m,client,dw_val_obj) {
208
209        var params = "tplmod_val=" +  m;   params += '&call=tplmod_ui_lang';
210		params += "&tplmod_client=" + client;
211        jQuery.post( DOKU_BASE + 'lib/exe/ajax.php', params,
212                function (data) {
213                    if(data == 'done') {
214                         alert(LANG.plugins.tplmod.ui_updated + m);
215                    }
216                      else  {
217                         alert(LANG.plugins.tplmod.ui_save_err + data);
218                      }
219                    },
220                'html'
221            );
222 }
223
224
225