Commit a50e8fd4 authored by David Lawrence's avatar David Lawrence

Bug 1090727: support jquery in the global/header template, and update the header…

Bug 1090727: support jquery in the global/header template, and update the header and footer to use jquery r=glob,a=glob
parent 11c20938
...@@ -7,54 +7,35 @@ ...@@ -7,54 +7,35 @@
*/ */
function show_mini_login_form( suffix ) { function show_mini_login_form( suffix ) {
var login_link = document.getElementById('login_link' + suffix); $('#login_link' + suffix).addClass('bz_default_hidden');
var login_form = document.getElementById('mini_login' + suffix); $('#mini_login' + suffix).removeClass('bz_default_hidden');
var account_container = document.getElementById('new_account_container' $('#new_account_container' + suffix).addClass('bz_default_hidden');
+ suffix);
YAHOO.util.Dom.addClass(login_link, 'bz_default_hidden');
YAHOO.util.Dom.removeClass(login_form, 'bz_default_hidden');
YAHOO.util.Dom.addClass(account_container, 'bz_default_hidden');
return false; return false;
} }
function hide_mini_login_form( suffix ) { function hide_mini_login_form( suffix ) {
var login_link = document.getElementById('login_link' + suffix); $('#login_link' + suffix).removeClass('bz_default_hidden');
var login_form = document.getElementById('mini_login' + suffix); $('#mini_login' + suffix).addClass('bz_default_hidden');
var account_container = document.getElementById('new_account_container' $('#new_account_container' + suffix).removeClass('bz_default_hidden');
+ suffix);
YAHOO.util.Dom.removeClass(login_link, 'bz_default_hidden');
YAHOO.util.Dom.addClass(login_form, 'bz_default_hidden');
YAHOO.util.Dom.removeClass(account_container, 'bz_default_hidden');
return false; return false;
} }
function show_forgot_form( suffix ) { function show_forgot_form( suffix ) {
var forgot_link = document.getElementById('forgot_link' + suffix); $('#forgot_link' + suffix).addClass('bz_default_hidden');
var forgot_form = document.getElementById('forgot_form' + suffix); $('#forgot_form' + suffix).removeClass('bz_default_hidden');
var login_container = document.getElementById('mini_login_container' $('#login_container' + suffix).addClass('bz_default_hidden');
+ suffix);
YAHOO.util.Dom.addClass(forgot_link, 'bz_default_hidden');
YAHOO.util.Dom.removeClass(forgot_form, 'bz_default_hidden');
YAHOO.util.Dom.addClass(login_container, 'bz_default_hidden');
return false; return false;
} }
function hide_forgot_form( suffix ) { function hide_forgot_form( suffix ) {
var forgot_link = document.getElementById('forgot_link' + suffix); $('#forgot_link' + suffix).removeClass('bz_default_hidden');
var forgot_form = document.getElementById('forgot_form' + suffix); $('#forgot_form' + suffix).addClass('bz_default_hidden');
var login_container = document.getElementById('mini_login_container' $('#login_container' + suffix).removeClass('bz_default_hidden');
+ suffix);
YAHOO.util.Dom.removeClass(forgot_link, 'bz_default_hidden');
YAHOO.util.Dom.addClass(forgot_form, 'bz_default_hidden');
YAHOO.util.Dom.removeClass(login_container, 'bz_default_hidden');
return false; return false;
} }
function set_language( value ) { function set_language( value ) {
YAHOO.util.Cookie.set('LANG', value, $.cookie('LANG', value, {
{
expires: new Date('January 1, 2038'), expires: new Date('January 1, 2038'),
path: BUGZILLA.param.cookie_path path: BUGZILLA.param.cookie_path
}); });
......
/*!
* jQuery Cookie Plugin v1.4.1
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2013 Klaus Hartl
* Released under the MIT license
*/
(function(factory){if(typeof define==='function'&&define.amd){define(['jquery'],factory);}else if(typeof exports==='object'){factory(require('jquery'));}else{factory(jQuery);}}(function($){var pluses=/\+/g;function encode(s){return config.raw?s:encodeURIComponent(s);}
function decode(s){return config.raw?s:decodeURIComponent(s);}
function stringifyCookieValue(value){return encode(config.json?JSON.stringify(value):String(value));}
function parseCookieValue(s){if(s.indexOf('"')===0){s=s.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,'\\');}
try{s=decodeURIComponent(s.replace(pluses,' '));return config.json?JSON.parse(s):s;}catch(e){}}
function read(s,converter){var value=config.raw?s:parseCookieValue(s);return $.isFunction(converter)?converter(value):value;}
var config=$.cookie=function(key,value,options){if(value!==undefined&&!$.isFunction(value)){options=$.extend({},config.defaults,options);if(typeof options.expires==='number'){var days=options.expires,t=options.expires=new Date();t.setTime(+t+days*864e+5);}
return(document.cookie=[encode(key),'=',stringifyCookieValue(value),options.expires?'; expires='+options.expires.toUTCString():'',options.path?'; path='+options.path:'',options.domain?'; domain='+options.domain:'',options.secure?'; secure':''].join(''));}
var result=key?undefined:{};var cookies=document.cookie?document.cookie.split('; '):[];for(var i=0,l=cookies.length;i<l;i++){var parts=cookies[i].split('=');var name=decode(parts.shift());var cookie=parts.join('=');if(key&&key===name){result=read(cookie,value);break;}
if(!key&&(cookie=read(cookie))!==undefined){result[name]=cookie;}}
return result;};config.defaults={};$.removeCookie=function(key,options){if($.cookie(key)===undefined){return false;}
$.cookie(key,'',$.extend({},options,{expires:-1}));return!$.cookie(key);};}));
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -32,39 +32,60 @@ ...@@ -32,39 +32,60 @@
onload = "" onload = ""
style_urls = [] style_urls = []
yui = [] yui = []
yui_css = {}
yui_deps = {}
no_yui = 0
jquery = []
jquery_css = []
%] %]
[% SET yui_css = { [% IF NOT no_yui %]
autocomplete => 1, [% SET yui_css = {
calendar => 1, autocomplete => 1,
datatable => 1, calendar => 1,
button => 1, datatable => 1,
} %] button => 1,
} %]
[%# Note: This is simple dependency resolution--you can't have dependencies
# that depend on each other. You have to specify all of a module's deps, [%# Note: This is simple dependency resolution--you can't have dependencies
# if that module is going to be specified in "yui". # that depend on each other. You have to specify all of a module's deps,
#%] # if that module is going to be specified in "yui".
[% SET yui_deps = { #%]
autocomplete => ['json', 'connection', 'datasource'], [% SET yui_deps = {
datatable => ['json', 'connection', 'datasource', 'element'], autocomplete => ['json', 'connection', 'datasource'],
} %] datatable => ['json', 'connection', 'datasource', 'element'],
} %]
[%# When using certain YUI modules, we need to process certain
# extra JS templates. [%# When using certain YUI modules, we need to process certain
#%] # extra JS templates.
[% SET yui_templates = { #%]
datatable => ['global/value-descs.js.tmpl'], [% SET yui_templates = {
} %] datatable => ['global/value-descs.js.tmpl'],
} %]
[% END %]
[%# These are JS URLs that are *always* on the page and come before [%# These are JS URLs that are *always* on the page and come before
# every other JS URL. # every other JS URL.
#%] #%]
[% SET starting_js_urls = [ [% SET starting_js_urls = [
"js/yui/yahoo-dom-event/yahoo-dom-event.js", "js/jquery/jquery-min.js",
"js/yui/cookie/cookie-min.js", "js/jquery/ui/jquery-ui-min.js"
] %]
[% IF NOT no_yui %]
[% starting_js_urls.push("js/yui/yahoo-dom-event/yahoo-dom-event.js",
"js/yui/cookie/cookie-min.js") %]
[% END %]
[% SET jq_css_urls = [
"js/jquery/ui/jquery-ui-min.css",
"js/jquery/ui/jquery-ui-structure-min.css",
"js/jquery/ui/jquery-ui-theme-min.css",
] %] ] %]
[% undef = style_urls.import(jquery_css, jq_css_urls) %]
[%# Add jQuery cookie support %]
[% jquery.push("cookie") %]
[%# We should be able to set the default value of the header variable [%# We should be able to set the default value of the header variable
# to the value of the title variable using the DEFAULT directive, # to the value of the title variable using the DEFAULT directive,
...@@ -85,7 +106,9 @@ ...@@ -85,7 +106,9 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
[% END %] [% END %]
[% SET yui = yui_resolve_deps(yui, yui_deps) %] [% IF NOT no_yui %]
[% SET yui = yui_resolve_deps(yui, yui_deps) %]
[% END %]
[% SET css_sets = css_files(style_urls, yui, yui_css) %] [% SET css_sets = css_files(style_urls, yui, yui_css) %]
[% IF constants.CONCATENATE_ASSETS %] [% IF constants.CONCATENATE_ASSETS %]
...@@ -115,9 +138,16 @@ ...@@ -115,9 +138,16 @@
[% END %] [% END %]
[% END %] [% END %]
[%# YUI Scripts %] [% IF NOT no_yui %]
[% FOREACH yui_name = yui %] [%# YUI Scripts %]
[% starting_js_urls.push("js/yui/$yui_name/${yui_name}-min.js") %] [% FOREACH yui_name = yui %]
[% starting_js_urls.push("js/yui/$yui_name/${yui_name}-min.js") %]
[% END %]
[% END %]
[%# jQuery Plugins %]
[% FOREACH jq_name = jquery %]
[% starting_js_urls.push("js/jquery/plugins/$jq_name/${jq_name}-min.js") %]
[% END %] [% END %]
[% starting_js_urls.push('js/global.js') %] [% starting_js_urls.push('js/global.js') %]
...@@ -127,27 +157,28 @@ ...@@ -127,27 +157,28 @@
<script type="text/javascript"> <script type="text/javascript">
<!-- <!--
YAHOO.namespace('bugzilla'); [% IF NOT no_yui %]
YAHOO.util.Event.addListener = function (el, sType, fn, obj, overrideContext) { YAHOO.namespace('bugzilla');
if ( ("onpagehide" in window || YAHOO.env.ua.gecko) && sType === "unload") { sType = "pagehide"; }; YAHOO.util.Event.addListener = function (el, sType, fn, obj, overrideContext) {
var capture = ((sType == "focusin" || sType == "focusout") && !YAHOO.env.ua.ie) ? true : false; if ( ("onpagehide" in window || YAHOO.env.ua.gecko) && sType === "unload") { sType = "pagehide"; };
return this._addListener(el, this._getType(sType), fn, obj, overrideContext, capture); var capture = ((sType == "focusin" || sType == "focusout") && !YAHOO.env.ua.ie) ? true : false;
}; return this._addListener(el, this._getType(sType), fn, obj, overrideContext, capture);
if ( "onpagehide" in window || YAHOO.env.ua.gecko) { };
YAHOO.util.Event._simpleRemove(window, "unload", if ( "onpagehide" in window || YAHOO.env.ua.gecko) {
YAHOO.util.Event._unload); YAHOO.util.Event._simpleRemove(window, "unload",
} YAHOO.util.Event._unload);
}
[% END %]
[%# The language selector needs javascript to set its cookie, [%# The language selector needs javascript to set its cookie,
# so it is hidden in HTML/CSS by the "bz_default_hidden" class. # so it is hidden in HTML/CSS by the "bz_default_hidden" class.
# If the browser can run javascript, it will then "unhide" # If the browser can run javascript, it will then "unhide"
# the language selector using the following code. # the language selector using the following code.
#%] #%]
function unhide_language_selector() { function unhide_language_selector() {
YAHOO.util.Dom.removeClass( $('#lang_links_container').removeClass('bz_default_hidden');
'lang_links_container', 'bz_default_hidden'
);
} }
YAHOO.util.Event.onDOMReady(unhide_language_selector); $(document).ready(unhide_language_selector);
[%# Make some Bugzilla information available to all scripts. [%# Make some Bugzilla information available to all scripts.
# We don't import every parameter and constant because we # We don't import every parameter and constant because we
...@@ -180,11 +211,14 @@ ...@@ -180,11 +211,14 @@
[% END %] [% END %]
}; };
[% FOREACH yui_name = yui %] [% IF NOT no_yui %]
[% FOREACH yui_template = yui_templates.$yui_name %] [% FOREACH yui_name = yui %]
[% INCLUDE $yui_template %] [% FOREACH yui_template = yui_templates.$yui_name %]
[% INCLUDE $yui_template %]
[% END %]
[% END %] [% END %]
[% END %] [% END %]
[% IF javascript %] [% IF javascript %]
[% javascript %] [% javascript %]
[% END %] [% END %]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment