Update the layout with new resources, and add the files in.
This commit is contained in:
parent
70078746fa
commit
6b100291e0
|
@ -189,20 +189,19 @@
|
|||
itemscope itemtype="http://schema.org/Product"> <!--<![endif]}
|
||||
})
|
||||
|
||||
(define html-postamble
|
||||
(define (make-html-postamble resources)
|
||||
@list{
|
||||
@||
|
||||
@; Grab Google CDN's jQuery, with a protocol relative URL;
|
||||
@; fall back to local if offline
|
||||
@; ... TODO: distribute the JS stuffs ...
|
||||
@; @script[src: '("http://ajax.googleapis.com/"
|
||||
@; "ajax/libs/jquery/1.9.1/jquery.min.js")]
|
||||
@; @script/inline{
|
||||
@; window.jQuery || document.write(@;
|
||||
@; '<script src="/js/libs/jquery-1.9.1.min.js"><\/script>')}
|
||||
@; @script[src: "js/libs/gumby.min.js"]
|
||||
@; @script[src: "js/plugins.js"]
|
||||
@; @script[src: "js/main.js"]
|
||||
@script[src: '("http://ajax.googleapis.com/"
|
||||
"ajax/libs/jquery/1.9.1/jquery.min.js")]
|
||||
@script/inline{
|
||||
window.jQuery || document.write(@;
|
||||
'<script src="/js/libs/jquery-1.9.1.min.js"><\/script>')}
|
||||
@script[src: (resources "gumby.min.js")]
|
||||
@script[src: (resources "plugins.js")]
|
||||
@script[src: (resources "main.js")]
|
||||
@||
|
||||
})
|
||||
|
||||
|
@ -212,7 +211,8 @@
|
|||
@list{@link[rel: "icon" href: icon type: "image/ico"]
|
||||
@link[rel: "shortcut icon" href: icon type: "image/x-icon"]})
|
||||
|
||||
(define (html-headers style favicon)
|
||||
(define (html-headers resources favicon)
|
||||
(define style (resources 'style-path))
|
||||
@list{
|
||||
@meta[name: "generator" content: "Racket"]
|
||||
@meta[http-equiv: "Content-Type" content: "text/html; charset=utf-8"]
|
||||
|
@ -229,10 +229,9 @@
|
|||
@; @link[rel: "stylesheet" href="css/minified.css"]
|
||||
@; CSS imports non-minified for staging, minify before moving to
|
||||
@; production
|
||||
@; ... TODO: distribute the CSS stuffs ...
|
||||
@; @link[rel: "stylesheet" href: "css/gumby.css"]
|
||||
@link[rel: "stylesheet" href: (resources "gumby.css")]
|
||||
@; TODO: Modify `racket-style' definition (and what it depends on)
|
||||
@; in "resources.rkt"
|
||||
@; in "resources.rkt", possibly do something similar with the new files
|
||||
@link[rel: "stylesheet" type: "text/css" href: style title: "default"]
|
||||
@; TODO: Edit the `more.css' definition in www/index.rkt
|
||||
@; More ideas for your <head> here: h5bp.com/d/head-Tips
|
||||
|
@ -262,9 +261,10 @@
|
|||
;; delay the `url-of' until we're in the rendering context
|
||||
=> (λ(f) (λ() (url-of (cadr f))))]
|
||||
[else (error 'resource "unknown resource: ~e" what)])]))
|
||||
(define icon-headers (html-icon-headers (resources 'icon-path)))
|
||||
(define headers (html-headers (resources 'style-path) icon-headers))
|
||||
(define make-navbar (navbar-maker (resources 'logo-path)))
|
||||
(define icon-headers (html-icon-headers (resources 'icon-path)))
|
||||
(define headers (html-headers resources icon-headers))
|
||||
(define make-navbar (navbar-maker (resources 'logo-path)))
|
||||
(define html-postamble (make-html-postamble resources))
|
||||
resources)
|
||||
|
||||
;; `define+provide-context' should be used in each toplevel directory (= each
|
||||
|
|
1881
new-racket-web/web/common/resources/css/gumby.css
Normal file
1881
new-racket-web/web/common/resources/css/gumby.css
Normal file
File diff suppressed because it is too large
Load Diff
24
new-racket-web/web/common/resources/css/style.css
Normal file
24
new-racket-web/web/common/resources/css/style.css
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
We highly recommend you use SASS and write your custom styles in sass/_custom.scss.
|
||||
However, this blank file is available if you prefer
|
||||
*/
|
||||
|
||||
body { background: url(loud.png) center 60% no-repeat fixed; }
|
||||
|
||||
.modal h2, .modal .btn { margin: 10px 0 0px; }
|
||||
.navbar div ul li a:hover { background: #292929; }
|
||||
|
||||
#growboxes { margin-top: 10pt; }
|
||||
.panetitle { color: red; font-size: 120%; margin-bottom: 4pt }
|
||||
|
||||
pre.codesnip { font-size: 140%; }
|
||||
|
||||
.racketnav { display: none }
|
||||
|
||||
.wide_only { display: block; }
|
||||
.narrow_only { display: none; }
|
||||
|
||||
@media only screen and (max-width: 767px) {
|
||||
.wide_only { display: none; }
|
||||
.narrow_only { display: block; }
|
||||
}
|
BIN
new-racket-web/web/common/resources/fonts/icons/entypo.eot
Normal file
BIN
new-racket-web/web/common/resources/fonts/icons/entypo.eot
Normal file
Binary file not shown.
BIN
new-racket-web/web/common/resources/fonts/icons/entypo.ttf
Normal file
BIN
new-racket-web/web/common/resources/fonts/icons/entypo.ttf
Normal file
Binary file not shown.
BIN
new-racket-web/web/common/resources/fonts/icons/entypo.woff
Normal file
BIN
new-racket-web/web/common/resources/fonts/icons/entypo.woff
Normal file
Binary file not shown.
27
new-racket-web/web/common/resources/js/libs/gumby.init.js
Normal file
27
new-racket-web/web/common/resources/js/libs/gumby.init.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
/**
|
||||
* Gumby Init
|
||||
*/
|
||||
|
||||
// test for touch event support
|
||||
Modernizr.load({
|
||||
test: Modernizr.touch,
|
||||
|
||||
// if present load custom jQuery mobile build and update Gumby.click
|
||||
yep: Gumby.path+'/jquery.mobile.custom.min.js',
|
||||
callback: function(url, result, key) {
|
||||
// check jQuery mobile has successfully loaded before using tap events
|
||||
if($.mobile) {
|
||||
window.Gumby.click = 'tap';
|
||||
}
|
||||
},
|
||||
|
||||
// either way initialize Gumby
|
||||
complete: function() {
|
||||
window.Gumby.init();
|
||||
|
||||
// if AMD return Gumby object to define
|
||||
if(typeof define == "function" && define.amd) {
|
||||
define(window.Gumby);
|
||||
}
|
||||
}
|
||||
});
|
150
new-racket-web/web/common/resources/js/libs/gumby.js
Normal file
150
new-racket-web/web/common/resources/js/libs/gumby.js
Normal file
|
@ -0,0 +1,150 @@
|
|||
/**
|
||||
* Gumby Framework
|
||||
* ---------------
|
||||
*
|
||||
* Follow @gumbycss on twitter and spread the love.
|
||||
* We worked super hard on making this awesome and released it to the web.
|
||||
* All we ask is you leave this intact. #gumbyisawesome
|
||||
*
|
||||
* Gumby Framework
|
||||
* http://gumbyframework.com
|
||||
*
|
||||
* Built with love by your friends @digitalsurgeons
|
||||
* http://www.digitalsurgeons.com
|
||||
*
|
||||
* Free to use under the MIT license.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
!function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
function Gumby() {
|
||||
this.$dom = $(document);
|
||||
this.isOldie = !!this.$dom.find('html').hasClass('oldie');
|
||||
this.click = 'click';
|
||||
this.onReady = this.onOldie = this.onTouch = false;
|
||||
this.uiModules = {};
|
||||
this.inits = {};
|
||||
|
||||
// check and set path with js/libs default
|
||||
this.path = $('script[gumby-path]').attr('gumby-path') ||
|
||||
$('script[data-path]').attr('data-path') ||
|
||||
$('script[path]').attr('path') ||
|
||||
'js/libs';
|
||||
}
|
||||
|
||||
// initialize Gumby
|
||||
Gumby.prototype.init = function() {
|
||||
// init UI modules
|
||||
this.initUIModules();
|
||||
|
||||
var scope = this;
|
||||
|
||||
// call ready() code when dom is ready
|
||||
this.$dom.ready(function() {
|
||||
if(scope.onReady) {
|
||||
scope.onReady();
|
||||
}
|
||||
|
||||
// call oldie() callback if applicable
|
||||
if(scope.isOldie && scope.onOldie) {
|
||||
scope.onOldie();
|
||||
}
|
||||
|
||||
// call touch() callback if applicable
|
||||
if(Modernizr.touch && scope.onTouch) {
|
||||
scope.onTouch();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// public helper - set Gumby ready callback
|
||||
Gumby.prototype.ready = function(code) {
|
||||
if(code && typeof code === 'function') {
|
||||
this.onReady = code;
|
||||
}
|
||||
};
|
||||
|
||||
// public helper - set oldie callback
|
||||
Gumby.prototype.oldie = function(code) {
|
||||
if(code && typeof code === 'function') {
|
||||
this.onOldie = code;
|
||||
}
|
||||
};
|
||||
|
||||
// public helper - set touch callback
|
||||
Gumby.prototype.touch = function(code) {
|
||||
if(code && typeof code === 'function') {
|
||||
this.onTouch = code;
|
||||
}
|
||||
};
|
||||
|
||||
// public helper - return debuggin object including uiModules object
|
||||
Gumby.prototype.debug = function() {
|
||||
return {
|
||||
$dom: this.$dom,
|
||||
isOldie: this.isOldie,
|
||||
uiModules: this.uiModules,
|
||||
click: this.click
|
||||
};
|
||||
};
|
||||
|
||||
// grab attribute value, testing data- gumby- and no prefix
|
||||
Gumby.prototype.selectAttr = function() {
|
||||
var i = 0;
|
||||
|
||||
// any number of attributes can be passed
|
||||
for(; i < arguments.length; i++) {
|
||||
// various formats
|
||||
var attr = arguments[i],
|
||||
dataAttr = 'data-'+arguments[i],
|
||||
gumbyAttr = 'gumby-'+arguments[i];
|
||||
|
||||
// first test for data-attr
|
||||
if(this.attr(dataAttr)) {
|
||||
return this.attr(dataAttr);
|
||||
|
||||
// next test for gumby-attr
|
||||
} else if(this.attr(gumbyAttr)) {
|
||||
return this.attr(gumbyAttr);
|
||||
|
||||
// finally no prefix
|
||||
} else if(this.attr(attr)) {
|
||||
return this.attr(attr);
|
||||
}
|
||||
}
|
||||
|
||||
// none found
|
||||
return false;
|
||||
};
|
||||
|
||||
// add an initialisation method
|
||||
Gumby.prototype.addInitalisation = function(ref, code) {
|
||||
this.inits[ref] = code;
|
||||
};
|
||||
|
||||
// initialize a uiModule
|
||||
Gumby.prototype.initialize = function(ref) {
|
||||
if(this.inits[ref] && typeof this.inits[ref] === 'function') {
|
||||
this.inits[ref]();
|
||||
}
|
||||
};
|
||||
|
||||
// store a UI module
|
||||
Gumby.prototype.UIModule = function(data) {
|
||||
var module = data.module;
|
||||
this.uiModules[module] = data;
|
||||
};
|
||||
|
||||
// loop round and init all UI modules
|
||||
Gumby.prototype.initUIModules = function() {
|
||||
var x;
|
||||
for(x in this.uiModules) {
|
||||
this.uiModules[x].init();
|
||||
}
|
||||
};
|
||||
|
||||
window.Gumby = new Gumby();
|
||||
|
||||
}();
|
1
new-racket-web/web/common/resources/js/libs/gumby.min.js
vendored
Normal file
1
new-racket-web/web/common/resources/js/libs/gumby.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
5
new-racket-web/web/common/resources/js/libs/jquery-1.9.1.min.js
vendored
Normal file
5
new-racket-web/web/common/resources/js/libs/jquery-1.9.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
3
new-racket-web/web/common/resources/js/libs/jquery.mobile.custom.min.js
vendored
Normal file
3
new-racket-web/web/common/resources/js/libs/jquery.mobile.custom.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4
new-racket-web/web/common/resources/js/libs/modernizr-2.6.2.min.js
vendored
Normal file
4
new-racket-web/web/common/resources/js/libs/modernizr-2.6.2.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,93 @@
|
|||
/**
|
||||
* Gumby Checkbox
|
||||
*/
|
||||
!function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
function Checkbox($el) {
|
||||
|
||||
this.$el = $el;
|
||||
var scope = this;
|
||||
|
||||
// listen for click event and custom gumby check/uncheck events
|
||||
this.$el.on(Gumby.click, function(e) {
|
||||
scope.click(e);
|
||||
}).on('gumby.check', function() {
|
||||
scope.update(true);
|
||||
}).on('gumby.uncheck', function() {
|
||||
scope.update(false);
|
||||
});
|
||||
|
||||
// update any .checked checkboxes on load
|
||||
if(scope.$el.hasClass('checked')) {
|
||||
scope.update(true);
|
||||
}
|
||||
}
|
||||
|
||||
// handle checkbox click event
|
||||
Checkbox.prototype.click = function(e) {
|
||||
|
||||
// element responsible for event trigger
|
||||
var $target = $(e.target);
|
||||
|
||||
// prevent propagation
|
||||
e.stopPropagation();
|
||||
|
||||
// prevent checkbox checking, we'll do that manually
|
||||
e.preventDefault();
|
||||
|
||||
// check/uncheck
|
||||
if(this.$el.hasClass('checked')) {
|
||||
this.update(false);
|
||||
} else {
|
||||
this.update(true);
|
||||
}
|
||||
};
|
||||
|
||||
// update checkbox, check equals true/false to sepcify check/uncheck
|
||||
Checkbox.prototype.update = function(check) {
|
||||
|
||||
var $input = this.$el.find('input'),
|
||||
$span = this.$el.find('span');
|
||||
|
||||
// check checkbox - check input, add checked class, append <i>
|
||||
if(check) {
|
||||
|
||||
$span.append('<i class="icon-check" />');
|
||||
|
||||
$input.prop('checked', true).end()
|
||||
.addClass('checked')
|
||||
.trigger('gumby.onCheck').trigger('gumby.onChange');
|
||||
|
||||
// uncheck checkbox - uncheck input, remove checked class, remove <i>
|
||||
} else {
|
||||
$input.prop('checked', false).end()
|
||||
.find('i').remove().end()
|
||||
.removeClass('checked').trigger('gumby.onUncheck').trigger('gumby.onChange');
|
||||
}
|
||||
};
|
||||
|
||||
// add initialisation
|
||||
Gumby.addInitalisation('checkboxes', function() {
|
||||
$('.checkbox').each(function() {
|
||||
var $this = $(this);
|
||||
// this element has already been initialized
|
||||
if($this.data('isCheckbox')) {
|
||||
return true;
|
||||
}
|
||||
// mark element as initialized
|
||||
$this.data('isCheckbox', true);
|
||||
new Checkbox($this);
|
||||
});
|
||||
});
|
||||
|
||||
// register UI module
|
||||
Gumby.UIModule({
|
||||
module: 'checkbox',
|
||||
events: ['onCheck', 'onUncheck', 'onChange', 'check', 'uncheck'],
|
||||
init: function() {
|
||||
Gumby.initialize('checkboxes');
|
||||
}
|
||||
});
|
||||
}();
|
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
* Gumby FitText
|
||||
*
|
||||
* Adapted from the awesome FitText jQuery plugin
|
||||
* brought to you by Paravel - http://paravelinc.com/
|
||||
*/
|
||||
!function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
function FitText($el) {
|
||||
this.$el = $el;
|
||||
// optional compressor rate
|
||||
this.rate = Gumby.selectAttr.apply(this.$el, ['rate']) || 1;
|
||||
// optional font sizes (min|max)
|
||||
this.fontSizes = this.parseSizes(Gumby.selectAttr.apply(this.$el, ['sizes']));
|
||||
|
||||
var scope = this;
|
||||
|
||||
// lets go
|
||||
$(window).on('load resize orientationchange', function() {
|
||||
scope.resize();
|
||||
});
|
||||
}
|
||||
|
||||
// apply the resizing
|
||||
FitText.prototype.resize = function() {
|
||||
this.$el.css('font-size', this.calculateSize());
|
||||
};
|
||||
|
||||
// calculate the font size
|
||||
FitText.prototype.calculateSize = function() {
|
||||
return Math.max(Math.min(this.$el.width() / (this.rate*10), parseFloat(this.fontSizes.max)), parseFloat(this.fontSizes.min));
|
||||
};
|
||||
|
||||
// parse size attributes with min|max syntax
|
||||
FitText.prototype.parseSizes = function(attrStr) {
|
||||
var sizes = {
|
||||
min: Number.NEGATIVE_INFINITY,
|
||||
max: Number.POSITIVE_INFINITY
|
||||
};
|
||||
|
||||
// attribute is optional
|
||||
if(!attrStr) { return sizes; }
|
||||
|
||||
// min and/or max specified
|
||||
if(attrStr.indexOf('|') > -1) {
|
||||
attrStr = attrStr.split('|');
|
||||
|
||||
// both are optional
|
||||
sizes.min = Number(attrStr[0]) || sizes.min;
|
||||
sizes.max = Number(attrStr[1]) || sizes.max;
|
||||
}
|
||||
|
||||
// only one value specific without | so use as min
|
||||
sizes.min = Number(attrStr) || sizes.min;
|
||||
|
||||
return sizes;
|
||||
};
|
||||
|
||||
// add initialisation
|
||||
Gumby.addInitalisation('fittext', function() {
|
||||
$('.fittext').each(function() {
|
||||
var $this = $(this);
|
||||
// this element has already been initialized
|
||||
if($this.data('isFittext')) {
|
||||
return true;
|
||||
}
|
||||
// mark element as initialized
|
||||
$this.data('isFittext', true);
|
||||
new FitText($this);
|
||||
});
|
||||
});
|
||||
|
||||
// register UI module
|
||||
Gumby.UIModule({
|
||||
module: 'fittext',
|
||||
events: [],
|
||||
init: function() {
|
||||
Gumby.initialize('fittext');
|
||||
}
|
||||
});
|
||||
}();
|
111
new-racket-web/web/common/resources/js/libs/ui/gumby.fixed.js
Normal file
111
new-racket-web/web/common/resources/js/libs/ui/gumby.fixed.js
Normal file
|
@ -0,0 +1,111 @@
|
|||
/**
|
||||
* Gumby Fixed
|
||||
*/
|
||||
!function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
function Fixed($el) {
|
||||
this.$el = $el;
|
||||
this.$holder = Gumby.selectAttr.apply(this.$el, ['holder']);
|
||||
this.fixedPoint = Gumby.selectAttr.apply(this.$el, ['fixed']);
|
||||
this.unfixPoint = false;
|
||||
|
||||
// if holder attr set then create jQuery object
|
||||
// otherwise use window for scrolling cals
|
||||
if(this.$holder) {
|
||||
this.$holder = $(this.$holder);
|
||||
} else {
|
||||
this.$holder = $(window);
|
||||
}
|
||||
|
||||
// fix/unfix points specified
|
||||
if(this.fixedPoint.indexOf('|') > -1) {
|
||||
var points = this.fixedPoint.split('|');
|
||||
this.fixedPoint = points[0];
|
||||
this.unfixPoint = points[1];
|
||||
}
|
||||
|
||||
// parse possible parameters
|
||||
this.fixedPoint = this.parseAttrValue(this.fixedPoint);
|
||||
if(this.unfixPoint) {
|
||||
this.unfixPoint = this.parseAttrValue(this.unfixPoint);
|
||||
}
|
||||
|
||||
var scope = this;
|
||||
this.$holder.scroll(function() {
|
||||
scope.scroll();
|
||||
});
|
||||
}
|
||||
|
||||
// handle scroll event on window/specified holder
|
||||
Fixed.prototype.scroll = function() {
|
||||
var offset = this.$holder.scrollTop(),
|
||||
fixedPoint = this.fixedPoint,
|
||||
unfixPoint = this.unfixPoint,
|
||||
endPoint = this.endPoint;
|
||||
|
||||
// if fixed point, unfix point or end point are DOM fragements
|
||||
// then re-calculate values as could have been updated
|
||||
fixedPoint = fixedPoint instanceof jQuery ? this.fixedPoint.offset().top : this.fixedPoint;
|
||||
unfixPoint = unfixPoint instanceof jQuery ? this.unfixPoint.offset().top : this.unfixPoint;
|
||||
|
||||
// ensure unfix point is never reached if not set
|
||||
if(!unfixPoint) {
|
||||
unfixPoint = offset * 2;
|
||||
}
|
||||
|
||||
// scrolled past fixed point and no fixed class present
|
||||
if((offset >= fixedPoint) && (offset < unfixPoint) && !this.$el.hasClass('fixed')) {
|
||||
this.$el.addClass('fixed').trigger('gumby.onFixed');
|
||||
|
||||
// before fixed point, pass 0 to onUnfixed event
|
||||
} else if((offset <= fixedPoint) && this.$el.hasClass('fixed')) {
|
||||
this.$el.removeClass('fixed').trigger('gumby.onUnfixed', 0);
|
||||
}
|
||||
|
||||
// after unfix point, pass 1 to onUnfixed event
|
||||
// separate conditional as should override
|
||||
if(unfixPoint && (offset >= unfixPoint) && this.$el.hasClass('fixed')) {
|
||||
this.$el.removeClass('fixed').trigger('gumby.onUnfixed', 1);
|
||||
}
|
||||
};
|
||||
|
||||
// parse attribute values, could be px, top, selector
|
||||
Fixed.prototype.parseAttrValue = function(attr) {
|
||||
// px value fixed point
|
||||
if($.isNumeric(attr)) {
|
||||
return Number(attr);
|
||||
// 'top' string fixed point
|
||||
} else if(attr === 'top') {
|
||||
return this.$el.offset().top;
|
||||
// selector specified
|
||||
} else {
|
||||
var $el = $(attr);
|
||||
return $el.length ? $el : false;
|
||||
}
|
||||
};
|
||||
|
||||
// add initialisation
|
||||
Gumby.addInitalisation('fixed', function() {
|
||||
$('[data-fixed],[gumby-fixed],[fixed]').each(function() {
|
||||
var $this = $(this);
|
||||
// this element has already been initialized
|
||||
if($this.data('isFixed')) {
|
||||
return true;
|
||||
}
|
||||
// mark element as initialized
|
||||
$this.data('isFixed', true);
|
||||
new Fixed($this);
|
||||
});
|
||||
});
|
||||
|
||||
// register UI module
|
||||
Gumby.UIModule({
|
||||
module: 'fixed',
|
||||
events: ['onFixed', 'onUnfixed'],
|
||||
init: function() {
|
||||
Gumby.initialize('fixed');
|
||||
}
|
||||
});
|
||||
}();
|
|
@ -0,0 +1,69 @@
|
|||
/**
|
||||
* Gumby Navbar
|
||||
*/
|
||||
!function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
// define module class and init only if we're on touch devices
|
||||
if(!Modernizr.touch) {
|
||||
return;
|
||||
}
|
||||
|
||||
function Navbar($el) {
|
||||
this.$el = $el;
|
||||
var scope = this;
|
||||
|
||||
// when navbar items are tapped hide/show dropdowns
|
||||
this.$el.find('li').on(Gumby.click, function(e) {
|
||||
var $this = $(this);
|
||||
|
||||
e.stopPropagation();
|
||||
|
||||
// prevent jump to top of page
|
||||
if(this.href === '#') {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
scope.dropdown($this);
|
||||
});
|
||||
}
|
||||
|
||||
// hide/show dropdowns
|
||||
Navbar.prototype.dropdown = function($this) {
|
||||
// we have dropdowns so open/cose
|
||||
if($this.children('.dropdown').length) {
|
||||
if($this.hasClass('active')) {
|
||||
$this.removeClass('active');
|
||||
} else {
|
||||
$this.addClass('active');
|
||||
}
|
||||
// no dropdown so close others
|
||||
} else {
|
||||
this.$items.removeClass('active');
|
||||
}
|
||||
};
|
||||
|
||||
// add initialisation
|
||||
Gumby.addInitalisation('navbars', function() {
|
||||
$('.navbar').each(function() {
|
||||
var $this = $(this);
|
||||
// this element has already been initialized
|
||||
if($this.data('isNavbar')) {
|
||||
return true;
|
||||
}
|
||||
// mark element as initialized
|
||||
$this.data('isNavbar', true);
|
||||
new Navbar($this);
|
||||
});
|
||||
});
|
||||
|
||||
// register UI module
|
||||
Gumby.UIModule({
|
||||
module: 'navbar',
|
||||
events: [],
|
||||
init: function() {
|
||||
Gumby.initialize('navbars');
|
||||
}
|
||||
});
|
||||
}();
|
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
* Gumby RadioBtn
|
||||
*/
|
||||
!function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
function RadioBtn($el) {
|
||||
|
||||
this.$el = $el;
|
||||
var scope = this;
|
||||
|
||||
// listen for click event and custom gumby check event
|
||||
this.$el.on(Gumby.click, function(e) {
|
||||
scope.click(e);
|
||||
}).on('gumby.check', function() {
|
||||
scope.update();
|
||||
});
|
||||
|
||||
// update any .checked checkboxes on load
|
||||
if(scope.$el.hasClass('checked')) {
|
||||
scope.update();
|
||||
}
|
||||
}
|
||||
|
||||
// handle radio button click event
|
||||
RadioBtn.prototype.click = function(e) {
|
||||
|
||||
// element responsible for event trigger
|
||||
var $target = $(e.target);
|
||||
|
||||
// prevent propagation
|
||||
e.stopPropagation();
|
||||
|
||||
// prevent radio button checking, we'll do that manually
|
||||
e.preventDefault();
|
||||
|
||||
// check radio button
|
||||
this.update();
|
||||
};
|
||||
|
||||
// check radio button, uncheck all others in name group
|
||||
RadioBtn.prototype.update = function() {
|
||||
var // this specific radio button
|
||||
$input = this.$el.find('input[type=radio]'),
|
||||
$span = this.$el.find('span'),
|
||||
// the group of radio buttons
|
||||
group = 'input[name="'+$input.attr('name')+'"]';
|
||||
|
||||
// uncheck radio buttons in same group - uncheck input, remove checked class, remove <i>
|
||||
$('.radio').has(group).removeClass('checked')
|
||||
.find('input').prop('checked', false).end()
|
||||
.find('i').remove();
|
||||
|
||||
// check this radio button - check input, add checked class, append <i>
|
||||
$input.prop('checked', true);
|
||||
$span.append('<i class="icon-dot" />');
|
||||
this.$el.addClass('checked').trigger('gumby.onChange');
|
||||
};
|
||||
|
||||
// add initialisation
|
||||
Gumby.addInitalisation('radiobtns', function() {
|
||||
$('.radio').each(function() {
|
||||
var $this = $(this);
|
||||
// this element has already been initialized
|
||||
if($this.data('isRadioBtn')) {
|
||||
return true;
|
||||
}
|
||||
// mark element as initialized
|
||||
$this.data('isRadioBtn', true);
|
||||
new RadioBtn($this);
|
||||
});
|
||||
});
|
||||
|
||||
// register UI module
|
||||
Gumby.UIModule({
|
||||
module: 'radiobtn',
|
||||
events: ['onChange', 'check'],
|
||||
init: function() {
|
||||
Gumby.initialize('radiobtns');
|
||||
}
|
||||
});
|
||||
}();
|
|
@ -0,0 +1,74 @@
|
|||
/**
|
||||
* Gumby Retina
|
||||
*/
|
||||
!function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
function Retina($el) {
|
||||
this.$el = $el;
|
||||
this.imageSrc = this.$el.attr('src');
|
||||
this.retinaSrc = this.fetchRetinaImage();
|
||||
this.$retinaImg = $(new Image());
|
||||
|
||||
var scope = this
|
||||
|
||||
// image src not valid
|
||||
if(!this.retinaSrc) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// load retina image
|
||||
this.$retinaImg.attr('src', this.retinaSrc).load(function() {
|
||||
scope.retinaImageLoaded();
|
||||
});
|
||||
}
|
||||
|
||||
// fetch retina src by appending '@2x' to image string before extension
|
||||
Retina.prototype.fetchRetinaImage = function() {
|
||||
var imgSrc = this.imageSrc,
|
||||
index = this.imageSrc.search(/(\.|\/)(gif|jpe?g|png)$/i);
|
||||
|
||||
// image src is not valid
|
||||
if(index < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// return retina src
|
||||
return imgSrc.substr(0, index) + '@2x' + imgSrc.substr(index, imgSrc.length);
|
||||
};
|
||||
|
||||
// once retina image loaded swap original src
|
||||
Retina.prototype.retinaImageLoaded = function() {
|
||||
this.$el.attr('src', this.$retinaImg.attr('src')).trigger('gumby.onRetina');
|
||||
};
|
||||
|
||||
// add initialisation
|
||||
Gumby.addInitalisation('retina', function() {
|
||||
|
||||
// this module is for retina devices only
|
||||
if(!window.devicePixelRatio || window.devicePixelRatio <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('img[data-retina],img[gumby-retina],img[retina]').each(function() {
|
||||
var $this = $(this);
|
||||
// this element has already been initialized
|
||||
if($this.data('isRetina')) {
|
||||
return true;
|
||||
}
|
||||
// mark element as initialized
|
||||
$this.data('isRetina', true);
|
||||
new Retina($this);
|
||||
});
|
||||
});
|
||||
|
||||
// register UI module
|
||||
Gumby.UIModule({
|
||||
module: 'retina',
|
||||
events: ['onRetina'],
|
||||
init: function() {
|
||||
Gumby.initialize('retina');
|
||||
}
|
||||
});
|
||||
}();
|
112
new-racket-web/web/common/resources/js/libs/ui/gumby.skiplink.js
Normal file
112
new-racket-web/web/common/resources/js/libs/ui/gumby.skiplink.js
Normal file
|
@ -0,0 +1,112 @@
|
|||
/**
|
||||
* Gumby SkipLink
|
||||
*/
|
||||
!function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
function SkipLink($el) {
|
||||
|
||||
this.$el = $el;
|
||||
this.targetPos = 0;
|
||||
this.duration = Number(Gumby.selectAttr.apply(this.$el, ['duration'])) || 200;
|
||||
this.offset = Gumby.selectAttr.apply(this.$el, ['offset']) || false;
|
||||
this.easing = Gumby.selectAttr.apply(this.$el, ['easing']) || 'swing';
|
||||
|
||||
var scope = this;
|
||||
|
||||
// skip to target element on click or trigger of gumby.skipTo event
|
||||
this.$el.on(Gumby.click+' gumby.skip', function(e) {
|
||||
e.preventDefault();
|
||||
// calculate target on each click
|
||||
// other UI interactions could effect this
|
||||
scope.calculateTarget();
|
||||
});
|
||||
}
|
||||
|
||||
// calculate target px point to skip to
|
||||
SkipLink.prototype.calculateTarget = function() {
|
||||
|
||||
var scope = this,
|
||||
target = Gumby.selectAttr.apply(this.$el, ['goto']),
|
||||
$target;
|
||||
|
||||
// 'top' specified so target is 0px
|
||||
if(target == 'top') {
|
||||
this.targetPos = 0;
|
||||
|
||||
// px point specified
|
||||
} else if($.isNumeric(target)) {
|
||||
this.targetPos = Number(target);
|
||||
} else {
|
||||
|
||||
// check for element with target as selector
|
||||
$target = $(target);
|
||||
|
||||
// target does not exist, we need a target
|
||||
if(!$target) {
|
||||
return false;
|
||||
}
|
||||
|
||||
this.targetPos = $target.offset().top;
|
||||
}
|
||||
|
||||
// skip to target
|
||||
this.skipTo();
|
||||
};
|
||||
|
||||
// animate body, html scrollTop value to target px point
|
||||
SkipLink.prototype.skipTo = function() {
|
||||
var scope = this;
|
||||
|
||||
// slide to position of target
|
||||
$('html,body').animate({
|
||||
'scrollTop' : this.calculateOffset()
|
||||
}, this.duration, this.easing).promise().done(function() {
|
||||
scope.$el.trigger('gumby.onComplete');
|
||||
});
|
||||
};
|
||||
|
||||
// calculate offset with current target point
|
||||
SkipLink.prototype.calculateOffset = function() {
|
||||
// no offset so return target here
|
||||
if(!this.offset) {
|
||||
return this.targetPos;
|
||||
}
|
||||
|
||||
// negative / positive
|
||||
var op = this.offset.substr(0, 1),
|
||||
off = Number(this.offset.substr(1, this.offset.length));
|
||||
|
||||
// subtract offset from target position
|
||||
if(op === '-') {
|
||||
return this.targetPos - off;
|
||||
// add offset to target position
|
||||
} else if(op === '+') {
|
||||
return this.targetPos + off;
|
||||
}
|
||||
};
|
||||
|
||||
// add initialisation
|
||||
Gumby.addInitalisation('skiplinks', function() {
|
||||
$('.skiplink > a, .skip').each(function() {
|
||||
var $this = $(this);
|
||||
// this element has already been initialized
|
||||
if($this.data('isSkipLink')) {
|
||||
return true;
|
||||
}
|
||||
// mark element as initialized
|
||||
$this.data('isSkipLink', true);
|
||||
new SkipLink($this);
|
||||
});
|
||||
});
|
||||
|
||||
// register UI module
|
||||
Gumby.UIModule({
|
||||
module: 'skiplink',
|
||||
events: ['onComplete', 'skip'],
|
||||
init: function() {
|
||||
Gumby.initialize('skiplinks');
|
||||
}
|
||||
});
|
||||
}();
|
70
new-racket-web/web/common/resources/js/libs/ui/gumby.tabs.js
Normal file
70
new-racket-web/web/common/resources/js/libs/ui/gumby.tabs.js
Normal file
|
@ -0,0 +1,70 @@
|
|||
/**
|
||||
* Gumby Tabs
|
||||
*/
|
||||
!function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
function Tabs($el) {
|
||||
|
||||
this.$el = $el;
|
||||
this.$nav = this.$el.find('ul.tab-nav > li');
|
||||
this.$content = this.$el.find('.tab-content');
|
||||
|
||||
var scope = this;
|
||||
|
||||
// listen for click event on tab nav and custom gumby set event
|
||||
this.$nav.children('a').on(Gumby.click, function(e) {
|
||||
e.preventDefault();
|
||||
scope.click($(this));
|
||||
});
|
||||
|
||||
// listen for gumby.set value for dynamically set tabs
|
||||
this.$el.on('gumby.set', function(e, index) {
|
||||
scope.set(e, index);
|
||||
});
|
||||
}
|
||||
|
||||
// handle tab nav click event
|
||||
Tabs.prototype.click = function($this) {
|
||||
// index of item to activate
|
||||
var index = $this.parent().index();
|
||||
|
||||
// deactivate other tab navigation and content
|
||||
this.$nav.add(this.$content).removeClass('active');
|
||||
|
||||
// activate this tab nav link and content
|
||||
this.$nav.eq(index).add(this.$content.eq(index)).addClass('active');
|
||||
|
||||
// trigger gumby.change event and pass current active tab index
|
||||
this.$el.trigger('gumby.onChange', index);
|
||||
};
|
||||
|
||||
// set specific tab
|
||||
Tabs.prototype.set = function(e, index) {
|
||||
this.$nav.eq(index).find('a').trigger(Gumby.click);
|
||||
};
|
||||
|
||||
// add initialisation
|
||||
Gumby.addInitalisation('tabs', function() {
|
||||
$('.tabs').each(function() {
|
||||
var $this = $(this);
|
||||
// this element has already been initialized
|
||||
if($this.data('isTabs')) {
|
||||
return true;
|
||||
}
|
||||
// mark element as initialized
|
||||
$this.data('isTabs', true);
|
||||
new Tabs($this);
|
||||
});
|
||||
});
|
||||
|
||||
// register UI module
|
||||
Gumby.UIModule({
|
||||
module: 'tabs',
|
||||
events: ['onChange', 'set'],
|
||||
init: function() {
|
||||
Gumby.initialize('tabs');
|
||||
}
|
||||
});
|
||||
}();
|
|
@ -0,0 +1,176 @@
|
|||
/**
|
||||
* Gumby Toggles/Switches
|
||||
*/
|
||||
!function() {
|
||||
|
||||
'use strict';
|
||||
|
||||
// Toggle constructor
|
||||
function Toggle($el) {
|
||||
this.$el = $($el);
|
||||
this.targets = [];
|
||||
this.on = '';
|
||||
|
||||
if(this.$el.length) {
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
|
||||
// Switch constructor
|
||||
function Switch($el) {
|
||||
this.$el = $($el);
|
||||
this.targets = [];
|
||||
this.on = '';
|
||||
|
||||
if(this.$el.length) {
|
||||
this.init();
|
||||
}
|
||||
}
|
||||
|
||||
// intialise toggles, switches will inherit method
|
||||
Toggle.prototype.init = function() {
|
||||
this.targets = this.parseTargets();
|
||||
this.on = Gumby.selectAttr.apply(this.$el, ['on']) || Gumby.click;
|
||||
|
||||
var scope = this;
|
||||
|
||||
// bind to specified event and trigger
|
||||
this.$el.on(this.on, function(e) {
|
||||
// only disable default if <a>
|
||||
if($(this).prop('tagName') === 'A') {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
// stop propagation
|
||||
e.stopPropagation();
|
||||
|
||||
scope.trigger(scope.triggered);
|
||||
|
||||
// listen for gumby.trigger to dynamically trigger toggle/switch
|
||||
}).on('gumby.trigger', function() {
|
||||
scope.trigger(scope.triggered);
|
||||
});
|
||||
};
|
||||
|
||||
// parse data-for attribute, switches will inherit method
|
||||
Toggle.prototype.parseTargets = function() {
|
||||
var targetStr = Gumby.selectAttr.apply(this.$el, ['trigger']),
|
||||
secondaryTargets = 0,
|
||||
targets = [];
|
||||
|
||||
// no targets so return false
|
||||
if(!targetStr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
secondaryTargets = targetStr.indexOf('|');
|
||||
|
||||
// no secondary targets specified so return single target
|
||||
if(secondaryTargets === -1) {
|
||||
return [$(targetStr)];
|
||||
}
|
||||
|
||||
// return array of both targets, split and return 0, 1
|
||||
targets = targetStr.split('|');
|
||||
return targets.length > 1 ? [$(targets[0]), $(targets[1])] : [$(targets[0])];
|
||||
};
|
||||
|
||||
// call triggered event and pass target data
|
||||
Toggle.prototype.triggered = function() {
|
||||
// trigger gumby.onTrigger event and pass array of target status data
|
||||
this.$el.trigger('gumby.onTrigger', [this.$el.hasClass('active')]);
|
||||
};
|
||||
|
||||
// Switch object inherits from Toggle
|
||||
Switch.prototype = new Toggle();
|
||||
|
||||
// Toggle specific trigger method
|
||||
Toggle.prototype.trigger = function(cb) {
|
||||
// no targets just toggle active class on toggle
|
||||
if(!this.targets) {
|
||||
this.$el.toggleClass('active');
|
||||
|
||||
// combine single target with toggle and toggle active class
|
||||
} else if(this.targets.length == 1) {
|
||||
this.$el.add(this.targets[0]).toggleClass('active');
|
||||
|
||||
// if two targets check active state of first
|
||||
// always combine toggle and first target
|
||||
} else if(this.targets.length > 1) {
|
||||
if(this.targets[0].hasClass('active')) {
|
||||
this.$el.add(this.targets[0]).removeClass('active');
|
||||
this.targets[1].addClass('active');
|
||||
} else {
|
||||
this.targets[1].removeClass('active');
|
||||
this.$el.add(this.targets[0]).addClass('active');
|
||||
}
|
||||
}
|
||||
|
||||
// call event handler here, applying scope of object Switch/Toggle
|
||||
if(cb && typeof cb === 'function') {
|
||||
cb.apply(this);
|
||||
}
|
||||
};
|
||||
|
||||
// Switch specific trigger method
|
||||
Switch.prototype.trigger = function(cb) {
|
||||
// no targets just add active class to switch
|
||||
if(!this.targets) {
|
||||
this.$el.addClass('active');
|
||||
|
||||
// combine single target with switch and add active class
|
||||
} else if(this.targets.length == 1) {
|
||||
this.$el.add(this.targets[0]).addClass('active');
|
||||
|
||||
// if two targets check active state of first
|
||||
// always combine switch and first target
|
||||
} else if(this.targets.length > 1) {
|
||||
this.$el.add(this.targets[0]).addClass('active');
|
||||
this.targets[1].removeClass('active');
|
||||
}
|
||||
|
||||
// call event handler here, applying scope of object Switch/Toggle
|
||||
if(cb && typeof cb === 'function') {
|
||||
cb.apply(this);
|
||||
}
|
||||
};
|
||||
|
||||
// add toggle initialisation
|
||||
Gumby.addInitalisation('toggles', function() {
|
||||
$('.toggle').each(function() {
|
||||
var $this = $(this);
|
||||
// this element has already been initialized
|
||||
if($this.data('isToggle')) {
|
||||
return true;
|
||||
}
|
||||
// mark element as initialized
|
||||
$this.data('isToggle', true);
|
||||
new Toggle($this);
|
||||
});
|
||||
});
|
||||
|
||||
// add switches initialisation
|
||||
Gumby.addInitalisation('switches', function() {
|
||||
$('.switch').each(function() {
|
||||
var $this = $(this);
|
||||
// this element has already been initialized
|
||||
if($this.data('isSwitch')) {
|
||||
return true;
|
||||
}
|
||||
// mark element as initialized
|
||||
$this.data('isSwitch', true);
|
||||
new Switch($this);
|
||||
});
|
||||
});
|
||||
|
||||
// register UI module
|
||||
Gumby.UIModule({
|
||||
module: 'toggleswitch',
|
||||
events: ['trigger', 'onTrigger'],
|
||||
init: function() {
|
||||
// Run initialize methods
|
||||
Gumby.initialize('switches');
|
||||
Gumby.initialize('toggles');
|
||||
}
|
||||
});
|
||||
}();
|
|
@ -0,0 +1,138 @@
|
|||
/**
|
||||
* Gumby jQuery Validation Plugin
|
||||
*/
|
||||
!function($) {
|
||||
|
||||
'use strict';
|
||||
|
||||
function Validation($this, req) {
|
||||
|
||||
// input and holder .field
|
||||
this.$this = $this;
|
||||
this.$field = this.$this.parents('.field');
|
||||
|
||||
// supplied validation function with default length check
|
||||
this.req = req || function() {
|
||||
return !!this.$this.val().length;
|
||||
};
|
||||
|
||||
// reference to this class
|
||||
var scope = this;
|
||||
|
||||
// checkboxes and radio buttons use gumby.onChange event to validate
|
||||
if(this.$this.is('[type=checkbox], [type=radio]')) {
|
||||
this.$field = this.$this.parent('label');
|
||||
this.$field.on('gumby.onChange', function() {
|
||||
scope.validate();
|
||||
});
|
||||
|
||||
// selects validate on change
|
||||
} else if(this.$this.is('select')) {
|
||||
this.$field = this.$this.parents('.picker');
|
||||
this.$field.on('change', function() {
|
||||
scope.validate();
|
||||
});
|
||||
|
||||
// others (text input, textarea) use blur
|
||||
} else {
|
||||
this.$this.on('blur', function(e) {
|
||||
// ignore tab
|
||||
if(e.which !== 9) {
|
||||
scope.validate();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// validate field
|
||||
Validation.prototype.validate = function() {
|
||||
|
||||
var result = this.req(this.$this);
|
||||
|
||||
// failed
|
||||
if(!result) {
|
||||
this.$field.removeClass('success').addClass('danger');
|
||||
|
||||
// passed
|
||||
} else {
|
||||
//} else if(this.$field.hasClass('danger')) {
|
||||
this.$field.removeClass('danger').addClass('success');
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
// jQuery plugin definition
|
||||
$.fn.validation = function(options) {
|
||||
|
||||
var // extend params with defaults
|
||||
settings = $.extend({
|
||||
submit : false,
|
||||
fail: false,
|
||||
required : []
|
||||
}, options),
|
||||
// store validation objects
|
||||
validations = [];
|
||||
|
||||
// init each form plugin is called on
|
||||
return this.each(function() {
|
||||
|
||||
// no required fields so plugin is pointless
|
||||
if(!settings.required.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var $this = $(this),
|
||||
reqLength = settings.required.length,
|
||||
i;
|
||||
|
||||
// loop round each required field and instantiate new validation object
|
||||
for(i = 0; i < reqLength; i++) {
|
||||
validations.push(new Validation(
|
||||
$this.find('[name="'+settings.required[i].name+'"]'),
|
||||
settings.required[i].validate || false
|
||||
));
|
||||
}
|
||||
|
||||
// hijack submit event
|
||||
$this.on('submit', function(e) {
|
||||
|
||||
// reference to whole form pass/fail
|
||||
var failed = false;
|
||||
|
||||
// if no passed attribute found we should halt form submit
|
||||
if(!$this.data('passed')) {
|
||||
e.preventDefault();
|
||||
|
||||
// loop round validation objects and validate each
|
||||
var reqLength = validations.length, i;
|
||||
for(i = 0; i < reqLength; i++) {
|
||||
if(!validations[i].validate()) {
|
||||
failed = true;
|
||||
}
|
||||
}
|
||||
|
||||
// passed
|
||||
if(!failed) {
|
||||
// if submit method present call that otherwise submit form
|
||||
if(settings.submit && typeof settings.submit === 'function') {
|
||||
settings.submit($this.serializeArray());
|
||||
return;
|
||||
}
|
||||
|
||||
// store passed bool and re-submit
|
||||
$this.data('passed', true).submit();
|
||||
|
||||
// failed
|
||||
} else {
|
||||
// call fail method if present
|
||||
if(settings.fail && typeof settings.fail === 'function') {
|
||||
settings.fail();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
}(jQuery);
|
24
new-racket-web/web/common/resources/js/main.js
Normal file
24
new-racket-web/web/common/resources/js/main.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
// Gumby is ready to go
|
||||
Gumby.ready(function() {
|
||||
console.log('Gumby is ready to go...', Gumby.debug());
|
||||
|
||||
// placeholder polyfil
|
||||
if(Gumby.isOldie || Gumby.$dom.find('html').hasClass('ie9')) {
|
||||
$('input, textarea').placeholder();
|
||||
}
|
||||
});
|
||||
|
||||
// Oldie document loaded
|
||||
Gumby.oldie(function() {
|
||||
console.log("This is an oldie browser...");
|
||||
});
|
||||
|
||||
// Touch devices loaded
|
||||
Gumby.touch(function() {
|
||||
console.log("This is a touch enabled device...");
|
||||
});
|
||||
|
||||
// Document ready
|
||||
$(function() {
|
||||
|
||||
});
|
8
new-racket-web/web/common/resources/js/plugins.js
Normal file
8
new-racket-web/web/common/resources/js/plugins.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
window.log=function(){log.history=log.history||[];log.history.push(arguments);if(this.console){arguments.callee=arguments.callee.caller;var a=[].slice.call(arguments);(typeof console.log==="object"?log.apply.call(console.log,console,a):console.log.apply(console,a))}};
|
||||
(function(b){function c(){}for(var d="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,timeStamp,profile,profileEnd,time,timeEnd,trace,warn".split(","),a;a=d.pop();){b[a]=b[a]||c}})((function(){try
|
||||
{console.log();return window.console;}catch(err){return window.console={};}})());
|
||||
|
||||
/*! http://mths.be/placeholder v2.0.7 by @mathias */
|
||||
;(function(f,h,$){var a='placeholder' in h.createElement('input'),d='placeholder' in h.createElement('textarea'),i=$.fn,c=$.valHooks,k,j;if(a&&d){j=i.placeholder=function(){return this};j.input=j.textarea=true}else{j=i.placeholder=function(){var l=this;l.filter((a?'textarea':':input')+'[placeholder]').not('.placeholder').bind({'focus.placeholder':b,'blur.placeholder':e}).data('placeholder-enabled',true).trigger('blur.placeholder');return l};j.input=a;j.textarea=d;k={get:function(m){var l=$(m);return l.data('placeholder-enabled')&&l.hasClass('placeholder')?'':m.value},set:function(m,n){var l=$(m);if(!l.data('placeholder-enabled')){return m.value=n}if(n==''){m.value=n;if(m!=h.activeElement){e.call(m)}}else{if(l.hasClass('placeholder')){b.call(m,true,n)||(m.value=n)}else{m.value=n}}return l}};a||(c.input=k);d||(c.textarea=k);$(function(){$(h).delegate('form','submit.placeholder',function(){var l=$('.placeholder',this).each(b);setTimeout(function(){l.each(e)},10)})});$(f).bind('beforeunload.placeholder',function(){$('.placeholder').each(function(){this.value=''})})}function g(m){var l={},n=/^jQuery\d+$/;$.each(m.attributes,function(p,o){if(o.specified&&!n.test(o.name)){l[o.name]=o.value}});return l}function b(m,n){var l=this,o=$(l);if(l.value==o.attr('placeholder')&&o.hasClass('placeholder')){if(o.data('placeholder-password')){o=o.hide().next().show().attr('id',o.removeAttr('id').data('placeholder-id'));if(m===true){return o[0].value=n}o.focus()}else{l.value='';o.removeClass('placeholder');l==h.activeElement&&l.select()}}}function e(){var q,l=this,p=$(l),m=p,o=this.id;if(l.value==''){if(l.type=='password'){if(!p.data('placeholder-textinput')){try{q=p.clone().attr({type:'text'})}catch(n){q=$('<input>').attr($.extend(g(this),{type:'text'}))}q.removeAttr('name').data({'placeholder-password':true,'placeholder-id':o}).bind('focus.placeholder',b);p.data({'placeholder-textinput':q,'placeholder-id':o}).before(q)}p=p.removeAttr('id').hide().prev().attr('id',o).show()}p.addClass('placeholder');p[0].value=p.attr('placeholder')}else{p.removeClass('placeholder')}}}(this,document,jQuery));
|
||||
|
||||
// place any jQuery/helper plugins in here, instead of separate, slower script files.
|
Loading…
Reference in New Issue
Block a user