forked from saurabh/orbit4-5
site structure now functional with create delete and edit page
This commit is contained in:
parent
30ab17eb82
commit
ec27f3f0e3
1
Gemfile
1
Gemfile
|
@ -8,6 +8,7 @@ gem 'sass-rails', '~> 4.0.2'
|
||||||
gem 'uglifier', '>= 1.3.0'
|
gem 'uglifier', '>= 1.3.0'
|
||||||
gem 'coffee-rails', '~> 4.0.0'
|
gem 'coffee-rails', '~> 4.0.0'
|
||||||
gem 'jquery-rails'
|
gem 'jquery-rails'
|
||||||
|
gem 'jquery-ui-rails', "4.0.5"
|
||||||
gem 'turbolinks'
|
gem 'turbolinks'
|
||||||
|
|
||||||
#password
|
#password
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
//= require jquery
|
||||||
|
//= require jquery_ujs
|
||||||
|
|
||||||
|
//= require basic/bootstrap
|
||||||
|
//= require jquery.ui.tooltip
|
||||||
|
//= require basic/iscroll
|
||||||
|
//= require basic/orbit_js_1.0.1.js
|
||||||
|
//= require basic/jquery.nanoscroller.js
|
||||||
|
//= require basic/jquery.easing.1.3.js
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,205 @@
|
||||||
|
/*
|
||||||
|
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
|
||||||
|
*
|
||||||
|
* Uses the built in easing capabilities added In jQuery 1.1
|
||||||
|
* to offer multiple easing options
|
||||||
|
*
|
||||||
|
* TERMS OF USE - jQuery Easing
|
||||||
|
*
|
||||||
|
* Open source under the BSD License.
|
||||||
|
*
|
||||||
|
* Copyright © 2008 George McGinley Smith
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name of the author nor the names of contributors may be used to endorse
|
||||||
|
* or promote products derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||||
|
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
// t: current time, b: begInnIng value, c: change In value, d: duration
|
||||||
|
jQuery.easing['jswing'] = jQuery.easing['swing'];
|
||||||
|
|
||||||
|
jQuery.extend( jQuery.easing,
|
||||||
|
{
|
||||||
|
def: 'easeOutQuad',
|
||||||
|
swing: function (x, t, b, c, d) {
|
||||||
|
//alert(jQuery.easing.default);
|
||||||
|
return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
|
||||||
|
},
|
||||||
|
easeInQuad: function (x, t, b, c, d) {
|
||||||
|
return c*(t/=d)*t + b;
|
||||||
|
},
|
||||||
|
easeOutQuad: function (x, t, b, c, d) {
|
||||||
|
return -c *(t/=d)*(t-2) + b;
|
||||||
|
},
|
||||||
|
easeInOutQuad: function (x, t, b, c, d) {
|
||||||
|
if ((t/=d/2) < 1) return c/2*t*t + b;
|
||||||
|
return -c/2 * ((--t)*(t-2) - 1) + b;
|
||||||
|
},
|
||||||
|
easeInCubic: function (x, t, b, c, d) {
|
||||||
|
return c*(t/=d)*t*t + b;
|
||||||
|
},
|
||||||
|
easeOutCubic: function (x, t, b, c, d) {
|
||||||
|
return c*((t=t/d-1)*t*t + 1) + b;
|
||||||
|
},
|
||||||
|
easeInOutCubic: function (x, t, b, c, d) {
|
||||||
|
if ((t/=d/2) < 1) return c/2*t*t*t + b;
|
||||||
|
return c/2*((t-=2)*t*t + 2) + b;
|
||||||
|
},
|
||||||
|
easeInQuart: function (x, t, b, c, d) {
|
||||||
|
return c*(t/=d)*t*t*t + b;
|
||||||
|
},
|
||||||
|
easeOutQuart: function (x, t, b, c, d) {
|
||||||
|
return -c * ((t=t/d-1)*t*t*t - 1) + b;
|
||||||
|
},
|
||||||
|
easeInOutQuart: function (x, t, b, c, d) {
|
||||||
|
if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
|
||||||
|
return -c/2 * ((t-=2)*t*t*t - 2) + b;
|
||||||
|
},
|
||||||
|
easeInQuint: function (x, t, b, c, d) {
|
||||||
|
return c*(t/=d)*t*t*t*t + b;
|
||||||
|
},
|
||||||
|
easeOutQuint: function (x, t, b, c, d) {
|
||||||
|
return c*((t=t/d-1)*t*t*t*t + 1) + b;
|
||||||
|
},
|
||||||
|
easeInOutQuint: function (x, t, b, c, d) {
|
||||||
|
if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
|
||||||
|
return c/2*((t-=2)*t*t*t*t + 2) + b;
|
||||||
|
},
|
||||||
|
easeInSine: function (x, t, b, c, d) {
|
||||||
|
return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
|
||||||
|
},
|
||||||
|
easeOutSine: function (x, t, b, c, d) {
|
||||||
|
return c * Math.sin(t/d * (Math.PI/2)) + b;
|
||||||
|
},
|
||||||
|
easeInOutSine: function (x, t, b, c, d) {
|
||||||
|
return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
|
||||||
|
},
|
||||||
|
easeInExpo: function (x, t, b, c, d) {
|
||||||
|
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
|
||||||
|
},
|
||||||
|
easeOutExpo: function (x, t, b, c, d) {
|
||||||
|
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
|
||||||
|
},
|
||||||
|
easeInOutExpo: function (x, t, b, c, d) {
|
||||||
|
if (t==0) return b;
|
||||||
|
if (t==d) return b+c;
|
||||||
|
if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
|
||||||
|
return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
|
||||||
|
},
|
||||||
|
easeInCirc: function (x, t, b, c, d) {
|
||||||
|
return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
|
||||||
|
},
|
||||||
|
easeOutCirc: function (x, t, b, c, d) {
|
||||||
|
return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
|
||||||
|
},
|
||||||
|
easeInOutCirc: function (x, t, b, c, d) {
|
||||||
|
if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
|
||||||
|
return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
|
||||||
|
},
|
||||||
|
easeInElastic: function (x, t, b, c, d) {
|
||||||
|
var s=1.70158;var p=0;var a=c;
|
||||||
|
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
||||||
|
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
||||||
|
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
||||||
|
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
||||||
|
},
|
||||||
|
easeOutElastic: function (x, t, b, c, d) {
|
||||||
|
var s=1.70158;var p=0;var a=c;
|
||||||
|
if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
|
||||||
|
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
||||||
|
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
||||||
|
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
|
||||||
|
},
|
||||||
|
easeInOutElastic: function (x, t, b, c, d) {
|
||||||
|
var s=1.70158;var p=0;var a=c;
|
||||||
|
if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
|
||||||
|
if (a < Math.abs(c)) { a=c; var s=p/4; }
|
||||||
|
else var s = p/(2*Math.PI) * Math.asin (c/a);
|
||||||
|
if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
||||||
|
return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
|
||||||
|
},
|
||||||
|
easeInBack: function (x, t, b, c, d, s) {
|
||||||
|
if (s == undefined) s = 1.70158;
|
||||||
|
return c*(t/=d)*t*((s+1)*t - s) + b;
|
||||||
|
},
|
||||||
|
easeOutBack: function (x, t, b, c, d, s) {
|
||||||
|
if (s == undefined) s = 1.70158;
|
||||||
|
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
|
||||||
|
},
|
||||||
|
easeInOutBack: function (x, t, b, c, d, s) {
|
||||||
|
if (s == undefined) s = 1.70158;
|
||||||
|
if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
|
||||||
|
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
|
||||||
|
},
|
||||||
|
easeInBounce: function (x, t, b, c, d) {
|
||||||
|
return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
|
||||||
|
},
|
||||||
|
easeOutBounce: function (x, t, b, c, d) {
|
||||||
|
if ((t/=d) < (1/2.75)) {
|
||||||
|
return c*(7.5625*t*t) + b;
|
||||||
|
} else if (t < (2/2.75)) {
|
||||||
|
return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
|
||||||
|
} else if (t < (2.5/2.75)) {
|
||||||
|
return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
|
||||||
|
} else {
|
||||||
|
return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
easeInOutBounce: function (x, t, b, c, d) {
|
||||||
|
if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
|
||||||
|
return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* TERMS OF USE - EASING EQUATIONS
|
||||||
|
*
|
||||||
|
* Open source under the BSD License.
|
||||||
|
*
|
||||||
|
* Copyright © 2001 Robert Penner
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* Neither the name of the author nor the names of contributors may be used to endorse
|
||||||
|
* or promote products derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||||
|
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||||
|
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||||
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
*/
|
|
@ -0,0 +1,752 @@
|
||||||
|
/*! nanoScrollerJS - v0.7.2
|
||||||
|
* http://jamesflorentino.github.com/nanoScrollerJS/
|
||||||
|
* Copyright (c) 2013 James Florentino; Licensed MIT */
|
||||||
|
|
||||||
|
|
||||||
|
(function($, window, document) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var BROWSER_IS_IE7, BROWSER_SCROLLBAR_WIDTH, DOMSCROLL, DOWN, DRAG, KEYDOWN, KEYUP, MOUSEDOWN, MOUSEMOVE, MOUSEUP, MOUSEWHEEL, NanoScroll, PANEDOWN, RESIZE, SCROLL, SCROLLBAR, TOUCHMOVE, UP, WHEEL, defaults, getBrowserScrollbarWidth;
|
||||||
|
defaults = {
|
||||||
|
/**
|
||||||
|
a classname for the pane element.
|
||||||
|
@property paneClass
|
||||||
|
@type String
|
||||||
|
@default 'pane'
|
||||||
|
*/
|
||||||
|
|
||||||
|
paneClass: 'pane',
|
||||||
|
/**
|
||||||
|
a classname for the slider element.
|
||||||
|
@property sliderClass
|
||||||
|
@type String
|
||||||
|
@default 'slider'
|
||||||
|
*/
|
||||||
|
|
||||||
|
sliderClass: 'slider',
|
||||||
|
/**
|
||||||
|
a classname for the content element.
|
||||||
|
@property contentClass
|
||||||
|
@type String
|
||||||
|
@default 'content'
|
||||||
|
*/
|
||||||
|
|
||||||
|
contentClass: 'content',
|
||||||
|
/**
|
||||||
|
a setting to enable native scrolling in iOS devices.
|
||||||
|
@property iOSNativeScrolling
|
||||||
|
@type Boolean
|
||||||
|
@default false
|
||||||
|
*/
|
||||||
|
|
||||||
|
iOSNativeScrolling: false,
|
||||||
|
/**
|
||||||
|
a setting to prevent the rest of the page being
|
||||||
|
scrolled when user scrolls the `.content` element.
|
||||||
|
@property preventPageScrolling
|
||||||
|
@type Boolean
|
||||||
|
@default false
|
||||||
|
*/
|
||||||
|
|
||||||
|
preventPageScrolling: false,
|
||||||
|
/**
|
||||||
|
a setting to disable binding to the resize event.
|
||||||
|
@property disableResize
|
||||||
|
@type Boolean
|
||||||
|
@default false
|
||||||
|
*/
|
||||||
|
|
||||||
|
disableResize: false,
|
||||||
|
/**
|
||||||
|
a setting to make the scrollbar always visible.
|
||||||
|
@property alwaysVisible
|
||||||
|
@type Boolean
|
||||||
|
@default false
|
||||||
|
*/
|
||||||
|
|
||||||
|
alwaysVisible: false,
|
||||||
|
/**
|
||||||
|
a default timeout for the `flash()` method.
|
||||||
|
@property flashDelay
|
||||||
|
@type Number
|
||||||
|
@default 1500
|
||||||
|
*/
|
||||||
|
|
||||||
|
flashDelay: 1500,
|
||||||
|
/**
|
||||||
|
a minimum height for the `.slider` element.
|
||||||
|
@property sliderMinHeight
|
||||||
|
@type Number
|
||||||
|
@default 20
|
||||||
|
*/
|
||||||
|
|
||||||
|
sliderMinHeight: 20,
|
||||||
|
/**
|
||||||
|
a maximum height for the `.slider` element.
|
||||||
|
@property sliderMaxHeight
|
||||||
|
@type Number
|
||||||
|
@default null
|
||||||
|
*/
|
||||||
|
|
||||||
|
sliderMaxHeight: null
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
@property SCROLLBAR
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
SCROLLBAR = 'scrollbar';
|
||||||
|
/**
|
||||||
|
@property SCROLL
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
SCROLL = 'scroll';
|
||||||
|
/**
|
||||||
|
@property MOUSEDOWN
|
||||||
|
@type String
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
MOUSEDOWN = 'mousedown';
|
||||||
|
/**
|
||||||
|
@property MOUSEMOVE
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
MOUSEMOVE = 'mousemove';
|
||||||
|
/**
|
||||||
|
@property MOUSEWHEEL
|
||||||
|
@type String
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
MOUSEWHEEL = 'mousewheel';
|
||||||
|
/**
|
||||||
|
@property MOUSEUP
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
MOUSEUP = 'mouseup';
|
||||||
|
/**
|
||||||
|
@property RESIZE
|
||||||
|
@type String
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
RESIZE = 'resize';
|
||||||
|
/**
|
||||||
|
@property DRAG
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
DRAG = 'drag';
|
||||||
|
/**
|
||||||
|
@property UP
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
UP = 'up';
|
||||||
|
/**
|
||||||
|
@property PANEDOWN
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
PANEDOWN = 'panedown';
|
||||||
|
/**
|
||||||
|
@property DOMSCROLL
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
DOMSCROLL = 'DOMMouseScroll';
|
||||||
|
/**
|
||||||
|
@property DOWN
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
DOWN = 'down';
|
||||||
|
/**
|
||||||
|
@property WHEEL
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
WHEEL = 'wheel';
|
||||||
|
/**
|
||||||
|
@property KEYDOWN
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
KEYDOWN = 'keydown';
|
||||||
|
/**
|
||||||
|
@property KEYUP
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
KEYUP = 'keyup';
|
||||||
|
/**
|
||||||
|
@property TOUCHMOVE
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
TOUCHMOVE = 'touchmove';
|
||||||
|
/**
|
||||||
|
@property BROWSER_IS_IE7
|
||||||
|
@type Boolean
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
BROWSER_IS_IE7 = window.navigator.appName === 'Microsoft Internet Explorer' && /msie 7./i.test(window.navigator.appVersion) && window.ActiveXObject;
|
||||||
|
/**
|
||||||
|
@property BROWSER_SCROLLBAR_WIDTH
|
||||||
|
@type Number
|
||||||
|
@static
|
||||||
|
@default null
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
BROWSER_SCROLLBAR_WIDTH = null;
|
||||||
|
/**
|
||||||
|
Returns browser's native scrollbar width
|
||||||
|
@method getBrowserScrollbarWidth
|
||||||
|
@return {Number} the scrollbar width in pixels
|
||||||
|
@static
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
getBrowserScrollbarWidth = function() {
|
||||||
|
var outer, outerStyle, scrollbarWidth;
|
||||||
|
outer = document.createElement('div');
|
||||||
|
outerStyle = outer.style;
|
||||||
|
outerStyle.position = 'absolute';
|
||||||
|
outerStyle.width = '100px';
|
||||||
|
outerStyle.height = '100px';
|
||||||
|
outerStyle.overflow = SCROLL;
|
||||||
|
outerStyle.top = '-9999px';
|
||||||
|
document.body.appendChild(outer);
|
||||||
|
scrollbarWidth = outer.offsetWidth - outer.clientWidth;
|
||||||
|
document.body.removeChild(outer);
|
||||||
|
return scrollbarWidth;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
@class NanoScroll
|
||||||
|
@param element {HTMLElement|Node} the main element
|
||||||
|
@param options {Object} nanoScroller's options
|
||||||
|
@constructor
|
||||||
|
*/
|
||||||
|
|
||||||
|
NanoScroll = (function() {
|
||||||
|
|
||||||
|
function NanoScroll(el, options) {
|
||||||
|
this.el = el;
|
||||||
|
this.options = options;
|
||||||
|
BROWSER_SCROLLBAR_WIDTH || (BROWSER_SCROLLBAR_WIDTH = getBrowserScrollbarWidth());
|
||||||
|
this.$el = $(this.el);
|
||||||
|
this.doc = $(document);
|
||||||
|
this.win = $(window);
|
||||||
|
this.$content = this.$el.children("." + options.contentClass);
|
||||||
|
this.$content.attr('tabindex', 0);
|
||||||
|
this.content = this.$content[0];
|
||||||
|
if (this.options.iOSNativeScrolling && (this.el.style.WebkitOverflowScrolling != null)) {
|
||||||
|
this.nativeScrolling();
|
||||||
|
} else {
|
||||||
|
this.generate();
|
||||||
|
}
|
||||||
|
this.createEvents();
|
||||||
|
this.addEvents();
|
||||||
|
this.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Prevents the rest of the page being scrolled
|
||||||
|
when user scrolls the `.content` element.
|
||||||
|
@method preventScrolling
|
||||||
|
@param event {Event}
|
||||||
|
@param direction {String} Scroll direction (up or down)
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.preventScrolling = function(e, direction) {
|
||||||
|
if (!this.isActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (e.type === DOMSCROLL) {
|
||||||
|
if (direction === DOWN && e.originalEvent.detail > 0 || direction === UP && e.originalEvent.detail < 0) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
} else if (e.type === MOUSEWHEEL) {
|
||||||
|
if (!e.originalEvent || !e.originalEvent.wheelDelta) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (direction === DOWN && e.originalEvent.wheelDelta < 0 || direction === UP && e.originalEvent.wheelDelta > 0) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Enable iOS native scrolling
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.nativeScrolling = function() {
|
||||||
|
this.$content.css({
|
||||||
|
WebkitOverflowScrolling: 'touch'
|
||||||
|
});
|
||||||
|
this.iOSNativeScrolling = true;
|
||||||
|
this.isActive = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Updates those nanoScroller properties that
|
||||||
|
are related to current scrollbar position.
|
||||||
|
@method updateScrollValues
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.updateScrollValues = function() {
|
||||||
|
var content;
|
||||||
|
content = this.content;
|
||||||
|
this.maxScrollTop = content.scrollHeight - content.clientHeight;
|
||||||
|
this.contentScrollTop = content.scrollTop;
|
||||||
|
if (!this.iOSNativeScrolling) {
|
||||||
|
this.maxSliderTop = this.paneHeight - this.sliderHeight;
|
||||||
|
this.sliderTop = this.contentScrollTop * this.maxSliderTop / this.maxScrollTop;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates event related methods
|
||||||
|
@method createEvents
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.createEvents = function() {
|
||||||
|
var _this = this;
|
||||||
|
this.events = {
|
||||||
|
down: function(e) {
|
||||||
|
_this.isBeingDragged = true;
|
||||||
|
_this.offsetY = e.pageY - _this.slider.offset().top;
|
||||||
|
_this.pane.addClass('active');
|
||||||
|
_this.doc.bind(MOUSEMOVE, _this.events[DRAG]).bind(MOUSEUP, _this.events[UP]);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
drag: function(e) {
|
||||||
|
_this.sliderY = e.pageY - _this.$el.offset().top - _this.offsetY;
|
||||||
|
_this.scroll();
|
||||||
|
_this.updateScrollValues();
|
||||||
|
if (_this.contentScrollTop >= _this.maxScrollTop) {
|
||||||
|
_this.$el.trigger('scrollend');
|
||||||
|
} else if (_this.contentScrollTop === 0) {
|
||||||
|
_this.$el.trigger('scrolltop');
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
up: function(e) {
|
||||||
|
_this.isBeingDragged = false;
|
||||||
|
_this.pane.removeClass('active');
|
||||||
|
_this.doc.unbind(MOUSEMOVE, _this.events[DRAG]).unbind(MOUSEUP, _this.events[UP]);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
resize: function(e) {
|
||||||
|
_this.reset();
|
||||||
|
},
|
||||||
|
panedown: function(e) {
|
||||||
|
_this.sliderY = (e.offsetY || e.originalEvent.layerY) - (_this.sliderHeight * 0.5);
|
||||||
|
_this.scroll();
|
||||||
|
_this.events.down(e);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
scroll: function(e) {
|
||||||
|
if (_this.isBeingDragged) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_this.updateScrollValues();
|
||||||
|
if (!_this.iOSNativeScrolling) {
|
||||||
|
_this.sliderY = _this.sliderTop;
|
||||||
|
_this.slider.css({
|
||||||
|
top: _this.sliderTop
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (e == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_this.contentScrollTop >= _this.maxScrollTop) {
|
||||||
|
if (_this.options.preventPageScrolling) {
|
||||||
|
_this.preventScrolling(e, DOWN);
|
||||||
|
}
|
||||||
|
_this.$el.trigger('scrollend');
|
||||||
|
} else if (_this.contentScrollTop === 0) {
|
||||||
|
if (_this.options.preventPageScrolling) {
|
||||||
|
_this.preventScrolling(e, UP);
|
||||||
|
}
|
||||||
|
_this.$el.trigger('scrolltop');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
wheel: function(e) {
|
||||||
|
if (e == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_this.sliderY += -e.wheelDeltaY || -e.delta;
|
||||||
|
_this.scroll();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Adds event listeners with jQuery.
|
||||||
|
@method addEvents
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.addEvents = function() {
|
||||||
|
var events;
|
||||||
|
this.removeEvents();
|
||||||
|
events = this.events;
|
||||||
|
if (!this.options.disableResize) {
|
||||||
|
this.win.bind(RESIZE, events[RESIZE]);
|
||||||
|
}
|
||||||
|
if (!this.iOSNativeScrolling) {
|
||||||
|
this.slider.bind(MOUSEDOWN, events[DOWN]);
|
||||||
|
this.pane.bind(MOUSEDOWN, events[PANEDOWN]).bind("" + MOUSEWHEEL + " " + DOMSCROLL, events[WHEEL]);
|
||||||
|
}
|
||||||
|
this.$content.bind("" + SCROLL + " " + MOUSEWHEEL + " " + DOMSCROLL + " " + TOUCHMOVE, events[SCROLL]);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Removes event listeners with jQuery.
|
||||||
|
@method removeEvents
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.removeEvents = function() {
|
||||||
|
var events;
|
||||||
|
events = this.events;
|
||||||
|
this.win.unbind(RESIZE, events[RESIZE]);
|
||||||
|
if (!this.iOSNativeScrolling) {
|
||||||
|
this.slider.unbind();
|
||||||
|
this.pane.unbind();
|
||||||
|
}
|
||||||
|
this.$content.unbind("" + SCROLL + " " + MOUSEWHEEL + " " + DOMSCROLL + " " + TOUCHMOVE, events[SCROLL]);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Generates nanoScroller's scrollbar and elements for it.
|
||||||
|
@method generate
|
||||||
|
@chainable
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.generate = function() {
|
||||||
|
var contentClass, cssRule, options, paneClass, sliderClass;
|
||||||
|
options = this.options;
|
||||||
|
paneClass = options.paneClass, sliderClass = options.sliderClass, contentClass = options.contentClass;
|
||||||
|
if (!this.$el.find("" + paneClass).length && !this.$el.find("" + sliderClass).length) {
|
||||||
|
this.$el.append("<div class=\"" + paneClass + "\"><div class=\"" + sliderClass + "\" /></div>");
|
||||||
|
}
|
||||||
|
this.pane = this.$el.children("." + paneClass);
|
||||||
|
this.slider = this.pane.find("." + sliderClass);
|
||||||
|
if (BROWSER_SCROLLBAR_WIDTH) {
|
||||||
|
cssRule = this.$el.css('direction') === 'rtl' ? {
|
||||||
|
left: -BROWSER_SCROLLBAR_WIDTH
|
||||||
|
} : {
|
||||||
|
right: -BROWSER_SCROLLBAR_WIDTH
|
||||||
|
};
|
||||||
|
this.$el.addClass('has-scrollbar');
|
||||||
|
}
|
||||||
|
if (cssRule != null) {
|
||||||
|
this.$content.css(cssRule);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@method restore
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.restore = function() {
|
||||||
|
this.stopped = false;
|
||||||
|
this.pane.show();
|
||||||
|
this.addEvents();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Resets nanoScroller's scrollbar.
|
||||||
|
@method reset
|
||||||
|
@chainable
|
||||||
|
@example
|
||||||
|
$(".nano").nanoScroller();
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.reset = function() {
|
||||||
|
var content, contentHeight, contentStyle, contentStyleOverflowY, paneBottom, paneHeight, paneOuterHeight, paneTop, sliderHeight;
|
||||||
|
if (this.iOSNativeScrolling) {
|
||||||
|
this.contentHeight = this.content.scrollHeight;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!this.$el.find("." + this.options.paneClass).length) {
|
||||||
|
this.generate().stop();
|
||||||
|
}
|
||||||
|
if (this.stopped) {
|
||||||
|
this.restore();
|
||||||
|
}
|
||||||
|
content = this.content;
|
||||||
|
contentStyle = content.style;
|
||||||
|
contentStyleOverflowY = contentStyle.overflowY;
|
||||||
|
if (BROWSER_IS_IE7) {
|
||||||
|
this.$content.css({
|
||||||
|
height: this.$content.height()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
contentHeight = content.scrollHeight + BROWSER_SCROLLBAR_WIDTH;
|
||||||
|
paneHeight = this.pane.outerHeight();
|
||||||
|
paneTop = parseInt(this.pane.css('top'), 10);
|
||||||
|
paneBottom = parseInt(this.pane.css('bottom'), 10);
|
||||||
|
paneOuterHeight = paneHeight + paneTop + paneBottom;
|
||||||
|
sliderHeight = Math.round(paneOuterHeight / contentHeight * paneOuterHeight);
|
||||||
|
if (sliderHeight < this.options.sliderMinHeight) {
|
||||||
|
sliderHeight = this.options.sliderMinHeight;
|
||||||
|
} else if ((this.options.sliderMaxHeight != null) && sliderHeight > this.options.sliderMaxHeight) {
|
||||||
|
sliderHeight = this.options.sliderMaxHeight;
|
||||||
|
}
|
||||||
|
if (contentStyleOverflowY === SCROLL && contentStyle.overflowX !== SCROLL) {
|
||||||
|
sliderHeight += BROWSER_SCROLLBAR_WIDTH;
|
||||||
|
}
|
||||||
|
this.maxSliderTop = paneOuterHeight - sliderHeight;
|
||||||
|
this.contentHeight = contentHeight;
|
||||||
|
this.paneHeight = paneHeight;
|
||||||
|
this.paneOuterHeight = paneOuterHeight;
|
||||||
|
this.sliderHeight = sliderHeight;
|
||||||
|
this.slider.height(sliderHeight);
|
||||||
|
this.events.scroll();
|
||||||
|
this.pane.show();
|
||||||
|
this.isActive = true;
|
||||||
|
if ((content.scrollHeight === content.clientHeight) || (this.pane.outerHeight(true) >= content.scrollHeight && contentStyleOverflowY !== SCROLL)) {
|
||||||
|
this.pane.hide();
|
||||||
|
this.isActive = false;
|
||||||
|
} else if (this.el.clientHeight === content.scrollHeight && contentStyleOverflowY === SCROLL) {
|
||||||
|
this.slider.hide();
|
||||||
|
} else {
|
||||||
|
this.slider.show();
|
||||||
|
}
|
||||||
|
this.pane.css({
|
||||||
|
opacity: (this.options.alwaysVisible ? 1 : ''),
|
||||||
|
visibility: (this.options.alwaysVisible ? 'visible' : '')
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@method scroll
|
||||||
|
@private
|
||||||
|
@example
|
||||||
|
$(".nano").nanoScroller({ scroll: 'top' });
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.scroll = function() {
|
||||||
|
if (!this.isActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.sliderY = Math.max(0, this.sliderY);
|
||||||
|
this.sliderY = Math.min(this.maxSliderTop, this.sliderY);
|
||||||
|
this.$content.scrollTop((this.paneHeight - this.contentHeight + BROWSER_SCROLLBAR_WIDTH) * this.sliderY / this.maxSliderTop * -1);
|
||||||
|
if (!this.iOSNativeScrolling) {
|
||||||
|
this.slider.css({
|
||||||
|
top: this.sliderY
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Scroll at the bottom with an offset value
|
||||||
|
@method scrollBottom
|
||||||
|
@param offsetY {Number}
|
||||||
|
@chainable
|
||||||
|
@example
|
||||||
|
$(".nano").nanoScroller({ scrollBottom: value });
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.scrollBottom = function(offsetY) {
|
||||||
|
if (!this.isActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.reset();
|
||||||
|
this.$content.scrollTop(this.contentHeight - this.$content.height() - offsetY).trigger(MOUSEWHEEL);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Scroll at the top with an offset value
|
||||||
|
@method scrollTop
|
||||||
|
@param offsetY {Number}
|
||||||
|
@chainable
|
||||||
|
@example
|
||||||
|
$(".nano").nanoScroller({ scrollTop: value });
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.scrollTop = function(offsetY) {
|
||||||
|
if (!this.isActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.reset();
|
||||||
|
this.$content.scrollTop(+offsetY).trigger(MOUSEWHEEL);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Scroll to an element
|
||||||
|
@method scrollTo
|
||||||
|
@param node {Node} A node to scroll to.
|
||||||
|
@chainable
|
||||||
|
@example
|
||||||
|
$(".nano").nanoScroller({ scrollTo: $('#a_node') });
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.scrollTo = function(node) {
|
||||||
|
if (!this.isActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.reset();
|
||||||
|
this.scrollTop($(node).get(0).offsetTop);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
To stop the operation.
|
||||||
|
This option will tell the plugin to disable all event bindings and hide the gadget scrollbar from the UI.
|
||||||
|
@method stop
|
||||||
|
@chainable
|
||||||
|
@example
|
||||||
|
$(".nano").nanoScroller({ stop: true });
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.stop = function() {
|
||||||
|
this.stopped = true;
|
||||||
|
this.removeEvents();
|
||||||
|
this.pane.hide();
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
To flash the scrollbar gadget for an amount of time defined in plugin settings (defaults to 1,5s).
|
||||||
|
Useful if you want to show the user (e.g. on pageload) that there is more content waiting for him.
|
||||||
|
@method flash
|
||||||
|
@chainable
|
||||||
|
@example
|
||||||
|
$(".nano").nanoScroller({ flash: true });
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.flash = function() {
|
||||||
|
var _this = this;
|
||||||
|
if (!this.isActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.reset();
|
||||||
|
this.pane.addClass('flashed');
|
||||||
|
setTimeout(function() {
|
||||||
|
_this.pane.removeClass('flashed');
|
||||||
|
}, this.options.flashDelay);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
return NanoScroll;
|
||||||
|
|
||||||
|
})();
|
||||||
|
$.fn.nanoScroller = function(settings) {
|
||||||
|
return this.each(function() {
|
||||||
|
var options, scrollbar;
|
||||||
|
if (!(scrollbar = this.nanoscroller)) {
|
||||||
|
options = $.extend({}, defaults, settings);
|
||||||
|
this.nanoscroller = scrollbar = new NanoScroll(this, options);
|
||||||
|
}
|
||||||
|
if (settings && typeof settings === "object") {
|
||||||
|
$.extend(scrollbar.options, settings);
|
||||||
|
if (settings.scrollBottom) {
|
||||||
|
return scrollbar.scrollBottom(settings.scrollBottom);
|
||||||
|
}
|
||||||
|
if (settings.scrollTop) {
|
||||||
|
return scrollbar.scrollTop(settings.scrollTop);
|
||||||
|
}
|
||||||
|
if (settings.scrollTo) {
|
||||||
|
return scrollbar.scrollTo(settings.scrollTo);
|
||||||
|
}
|
||||||
|
if (settings.scroll === 'bottom') {
|
||||||
|
return scrollbar.scrollBottom(0);
|
||||||
|
}
|
||||||
|
if (settings.scroll === 'top') {
|
||||||
|
return scrollbar.scrollTop(0);
|
||||||
|
}
|
||||||
|
if (settings.scroll && settings.scroll instanceof $) {
|
||||||
|
return scrollbar.scrollTo(settings.scroll);
|
||||||
|
}
|
||||||
|
if (settings.stop) {
|
||||||
|
return scrollbar.stop();
|
||||||
|
}
|
||||||
|
if (settings.flash) {
|
||||||
|
return scrollbar.flash();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return scrollbar.reset();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
})(jQuery, window, document);
|
|
@ -0,0 +1,624 @@
|
||||||
|
//Global Variables
|
||||||
|
$sidebarState = window.localStorage.getItem('sidebarState');
|
||||||
|
$ua = navigator.userAgent;
|
||||||
|
$.extend($.support, {
|
||||||
|
touch: "ontouchend" in document
|
||||||
|
});
|
||||||
|
if($.support.touch) {
|
||||||
|
mouseenterEvent = clickEvent = "touchstart";
|
||||||
|
} else {
|
||||||
|
clickEvent = "click";
|
||||||
|
mouseenterEvent = "mouseenter";
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
!function ($) {
|
||||||
|
// Set sidebarState
|
||||||
|
sidebarState = function (v) {
|
||||||
|
if(v) {
|
||||||
|
window.localStorage.setItem('sidebarState', 1);
|
||||||
|
} else {
|
||||||
|
window.localStorage.removeItem('sidebarState');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Focus first element
|
||||||
|
$.fn.focusFirstField = function(){
|
||||||
|
$this = this;
|
||||||
|
$this.find(":text:visible:enabled").filter(function(){
|
||||||
|
return $(this).parents(":hidden").size() == 0;
|
||||||
|
}).slice(0,1).focus();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Checked Toggle
|
||||||
|
$.fn.togglebox = function () {
|
||||||
|
var $checked = this;
|
||||||
|
$checked.each(function() {
|
||||||
|
if(!$(this).closest('div').hasClass('togglebox')) {
|
||||||
|
$(this).wrap('<div class="toggle-control"/>');
|
||||||
|
if($(this).attr('type') == "hidden" && $(this).attr('value') == 'true') {
|
||||||
|
$(this).wrap('<div class="togglebox disable" />');
|
||||||
|
} else {
|
||||||
|
$(this).wrap('<div class="togglebox" />');
|
||||||
|
}
|
||||||
|
$('<label><b></b></label>').insertAfter($(this));
|
||||||
|
if($(this).data().deploy) {
|
||||||
|
switch($(this).data().deploy) {
|
||||||
|
case "left":
|
||||||
|
$(this).closest('.toggle-control').css('float','left');
|
||||||
|
break;
|
||||||
|
case "right":
|
||||||
|
$(this).closest('.toggle-control').css('float','right');
|
||||||
|
break;
|
||||||
|
case "inline":
|
||||||
|
$(this).closest('.toggle-control').css('display','inline-block');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($(this).data().title) {
|
||||||
|
$(this).closest('.toggle-control').append('<p>'+$(this).data().title+'</p>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
$checked.each(function(i) {
|
||||||
|
if($(this).attr('type') == "checkbox") {
|
||||||
|
if($(this).data().disabled) {
|
||||||
|
console.log("d")
|
||||||
|
$(this).parent('.togglebox').addClass('disable').closest('li').addClass('disabled');
|
||||||
|
if($(this).prop('checked')) {
|
||||||
|
$(this).parent('.togglebox').removeClass('disable').closest('li').removeClass('disabled');
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
if($(this).prop('checked')) {
|
||||||
|
$(this).parent('.togglebox').addClass('disable').closest('li').addClass('disabled');
|
||||||
|
};
|
||||||
|
}
|
||||||
|
$(this).on({
|
||||||
|
change: function() {
|
||||||
|
$(this).parent('.togglebox').toggleClass('disable');
|
||||||
|
$(this).closest('tr').toggleClass('disable');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
if($(this).attr('type') == "radio") {
|
||||||
|
if(!$(this).prop('checked')) {
|
||||||
|
$(this).parent('.togglebox').addClass('disable').closest('li').addClass('disabled');
|
||||||
|
$(this).closest('tr').addClass('disable');
|
||||||
|
};
|
||||||
|
$(this).on({
|
||||||
|
change: function() {
|
||||||
|
$checked.not($(".toggle-check[type='checkbox']")).each(function(i) {
|
||||||
|
if(!$(this).parent('.togglebox').hasClass('disable')) {
|
||||||
|
$(this).parent('.togglebox').toggleClass('disable');
|
||||||
|
$(this).closest('tr').toggleClass('disable');
|
||||||
|
};
|
||||||
|
});
|
||||||
|
$(this).parent('.togglebox').toggleClass('disable')
|
||||||
|
$(this).closest('tr').toggleClass('disable');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
if($('#sitemap').length) {
|
||||||
|
$(this).on({
|
||||||
|
change: function() {
|
||||||
|
$(this).closest('li').toggleClass('disabled');
|
||||||
|
if($(this).prop('checked')) {
|
||||||
|
$(this).attr('checked', 'checked');
|
||||||
|
$(this).parents('h6')
|
||||||
|
.siblings('ul')
|
||||||
|
.find('li')
|
||||||
|
.addClass('disabled')
|
||||||
|
.find('h6 .togglebox')
|
||||||
|
.addClass('disable')
|
||||||
|
.find('input[type="checkbox"]')
|
||||||
|
.prop('checked', true)
|
||||||
|
.attr('checked', 'checked');
|
||||||
|
} else {
|
||||||
|
$(this).removeAttr('checked');
|
||||||
|
$(this).parents('h6')
|
||||||
|
.siblings('ul')
|
||||||
|
.find('li')
|
||||||
|
.removeClass('disabled')
|
||||||
|
.find('h6 .togglebox')
|
||||||
|
.removeClass('disable')
|
||||||
|
.find('input[type="checkbox"]')
|
||||||
|
.prop('checked', false)
|
||||||
|
.removeAttr('checked');
|
||||||
|
};
|
||||||
|
// $('.toggle-check').each(function(i) {
|
||||||
|
// var len = $(this).closest('ul').children('li').length,
|
||||||
|
// checLen = $(this).closest('ul').children('li').find('input[checked]').length,
|
||||||
|
// checLen = checLen - $(this).closest('ul').children('li').find('ul').find('input[checked]').length;
|
||||||
|
// if(len == checLen) {
|
||||||
|
// $(this).closest('ul')
|
||||||
|
// .parent('li')
|
||||||
|
// .addClass('disabled')
|
||||||
|
// .children('h6')
|
||||||
|
// .find('.togglebox')
|
||||||
|
// .addClass('disable')
|
||||||
|
// .find('input[type="checkbox"]')
|
||||||
|
// .prop('checked', true)
|
||||||
|
// .attr('checked', 'checked');
|
||||||
|
// } else {
|
||||||
|
// $(this).closest('ul')
|
||||||
|
// .parent('li')
|
||||||
|
// .removeClass('disabled')
|
||||||
|
// .children('h6')
|
||||||
|
// .find('.togglebox')
|
||||||
|
// .removeClass('disable')
|
||||||
|
// .find('input[type="checkbox"]')
|
||||||
|
// .prop('checked', false)
|
||||||
|
// .removeAttr('checked');
|
||||||
|
// };
|
||||||
|
// });
|
||||||
|
},
|
||||||
|
});
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Search Clear
|
||||||
|
$.fn.searchClear = function (param){
|
||||||
|
_defaultSettings = {
|
||||||
|
inputName: ':input',
|
||||||
|
inputIcon: 'inputIcon',
|
||||||
|
clearBtnIcon: 'clearBtnIcon',
|
||||||
|
liveFilter: false,
|
||||||
|
};
|
||||||
|
_set = $.extend(_defaultSettings, param);
|
||||||
|
$this = this;
|
||||||
|
$input = this.find(_set.inputName);
|
||||||
|
$tmp = '<i class="'+_set.inputIcon+'"></i><i class="'+_set.clearBtnIcon+' search-clear"></i>';
|
||||||
|
$input.wrap('<div class="sc-field" />');
|
||||||
|
$this.find('.sc-field').prepend($tmp);
|
||||||
|
$searchClear = $this.find(".search-clear");
|
||||||
|
function run(e) {
|
||||||
|
$searchClear.hide();
|
||||||
|
$($input).each(function() {
|
||||||
|
if($(this).val().length > 0) {
|
||||||
|
$(this).prev($searchClear).show();
|
||||||
|
}else {
|
||||||
|
$(this).prev($searchClear).hide();
|
||||||
|
}
|
||||||
|
$(this).on("blur keyup", function(){
|
||||||
|
if($(this).val().length > 0) {
|
||||||
|
$(this).prev($searchClear).show();
|
||||||
|
}else {
|
||||||
|
$(this).prev($searchClear).hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if(_set.liveFilter) {
|
||||||
|
$(this).prevAll($searchClear).on({
|
||||||
|
click: function(){
|
||||||
|
$(this).hide();
|
||||||
|
$(this).next($input).val("");
|
||||||
|
$('.checkbox-card .mark').removeClass('mark')
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$(this).prevAll($searchClear).on({
|
||||||
|
click: function(){
|
||||||
|
$(this).hide();
|
||||||
|
$(this).next($input).val("");
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checking IE10
|
||||||
|
// if Windows 8 and IE is ture. remove search clear buttom and fix text input padding-right
|
||||||
|
if(/Windows NT 6.2/g.test(navigator.userAgent)){
|
||||||
|
if(/MSIE/g.test(navigator.userAgent)){
|
||||||
|
$searchClear.remove();
|
||||||
|
$input.css({
|
||||||
|
'padding-right': '5px',
|
||||||
|
});
|
||||||
|
}else{run()}
|
||||||
|
}else{run()}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Fixed Nav
|
||||||
|
fixedNav = function () {
|
||||||
|
if($('.fixed-nav').length){
|
||||||
|
var $fixedNav = $('.fixed-nav');
|
||||||
|
if($sidebarState){
|
||||||
|
$fixedNav.addClass('open');
|
||||||
|
}
|
||||||
|
$fixedNav.on(clickEvent, function() {
|
||||||
|
if($sidebarState) {
|
||||||
|
window.localStorage.removeItem('sidebarState');
|
||||||
|
$fixedNav.removeClass('open');
|
||||||
|
}else{
|
||||||
|
window.localStorage.setItem('sidebarState', 1);
|
||||||
|
$fixedNav.addClass('open');
|
||||||
|
}
|
||||||
|
$sidebarState = window.localStorage.getItem('sidebarState')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Sidebar
|
||||||
|
sidebarNav = function () {
|
||||||
|
var $sidebar = $('#sidebar'),
|
||||||
|
$sidebarMenu = $('#sidebar-menu'),
|
||||||
|
$scroller = $('.scroller'),
|
||||||
|
$sidebarNav = $('.sidebar-nav'),
|
||||||
|
$el = $('.sidebar-nav').children('li'),
|
||||||
|
$elIndex = null,
|
||||||
|
$blockList = $('.sub-nav-block-list'),
|
||||||
|
$block = $('.sub-nav-block'),
|
||||||
|
$blockIndex = 0,
|
||||||
|
$arrow = $('.sub-nav-arrow'),
|
||||||
|
$wrap = $('#main-wrap'),
|
||||||
|
$wrapLeft = $wrap.css('margin-left'),
|
||||||
|
$position = $arrow.outerHeight(true)*-1,
|
||||||
|
$arrowHeightFormat = $arrow.outerHeight(true)/2;
|
||||||
|
if($('#sidebar').length>0) {
|
||||||
|
$wrap.css({'margin-left': 61});
|
||||||
|
$wrapLeft = 61;
|
||||||
|
}
|
||||||
|
if($el.hasClass('active')) {
|
||||||
|
// Menu defaults active
|
||||||
|
$elIndex = $el.filter('.active').index();
|
||||||
|
if($sidebarState && !$sidebarNav.hasClass('no-sub-nav')) {
|
||||||
|
$block.eq($elIndex).addClass('show');
|
||||||
|
$blockList.css({'width': 180});
|
||||||
|
$wrap.css({
|
||||||
|
'margin-left': 241,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Arrow defaults position
|
||||||
|
$position = $el.eq($elIndex).position().top+$el.eq($elIndex).height()/2-$arrowHeightFormat+$('.scroller').position().top;
|
||||||
|
$arrow.css({
|
||||||
|
'top': $position,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if($.support.touch && !$sidebarNav.hasClass('no-sub-nav')) {
|
||||||
|
$el.find('a').removeAttr('href');
|
||||||
|
};
|
||||||
|
$el.on(mouseenterEvent, function(e) {
|
||||||
|
$block.siblings().removeClass('show').eq($(this).index()).addClass('show');
|
||||||
|
$arrow.stop(true, false).animate({
|
||||||
|
top: ($(this).position().top+$(this).height()/2)-$arrowHeightFormat+$('.scroller').position().top,
|
||||||
|
},{
|
||||||
|
duration: 500,
|
||||||
|
easing: 'easeInOutBack',
|
||||||
|
});
|
||||||
|
if(!$sidebarState || !$el.hasClass('active')) {
|
||||||
|
$blockList.css({'width': 180});
|
||||||
|
if($('#pageslide').length) {
|
||||||
|
if($('#pageslide').is(":hidden")) {
|
||||||
|
$wrap.css({
|
||||||
|
'margin-left': $blockList.width()+$sidebarNav.width(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
$wrap.css({
|
||||||
|
'margin-left': $blockList.width()+$sidebarNav.width(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// if($('.topnav').length) {
|
||||||
|
// $('.topnav').css({
|
||||||
|
// 'left': $blockList.width()+$sidebarNav.width()+20,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
if($('.bottomnav').length) {
|
||||||
|
$('.bottomnav').css({
|
||||||
|
'left': $blockList.width()+$sidebarNav.width()+20,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$sidebar.css({
|
||||||
|
'width': $blockList.width()+$sidebarNav.width(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if ($sidebarNav.hasClass('no-sub-nav')) {
|
||||||
|
$sidebar.on('mouseleave', function() {
|
||||||
|
$arrow.stop(true, false).animate({
|
||||||
|
'top': $position,
|
||||||
|
},{
|
||||||
|
duration: 500,
|
||||||
|
easing: 'easeInOutBack',
|
||||||
|
});
|
||||||
|
})
|
||||||
|
};
|
||||||
|
// $el.on('mouseleave', function() {
|
||||||
|
// $el.hasClass('active') ? $position = $el.eq($elIndex).position().top+$el.eq($elIndex).height()/2-$arrowHeightFormat+$('.scroller').position().top;
|
||||||
|
// $(this).hasClass('active') ? '':$(this).children('span').removeClass('hover');
|
||||||
|
// });
|
||||||
|
$block.on({
|
||||||
|
mouseenter: function() {
|
||||||
|
$blockIndex = $block.filter('.sub-nav-block show').index();
|
||||||
|
$el.eq($blockIndex).hasClass('active') ? '':$el.eq($blockIndex).children('span').addClass('hover');
|
||||||
|
},
|
||||||
|
mouseleave: function() {
|
||||||
|
$block.removeClass('show');
|
||||||
|
if(!$sidebarState || !$el.hasClass('active')) {
|
||||||
|
$blockList.css({'width': 0});
|
||||||
|
if($('#pageslide').length) {
|
||||||
|
if($('#pageslide').is(":hidden")) {
|
||||||
|
$wrap.css({
|
||||||
|
'margin-left': $wrapLeft,
|
||||||
|
});
|
||||||
|
// if($('.topnav').length) {
|
||||||
|
// if($sidebarState) {
|
||||||
|
// $('.topnav').css({
|
||||||
|
// 'left': 261,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$wrap.css({
|
||||||
|
'margin-left': $blockList.width()+$sidebarNav.width(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// if($('.topnav').length) {
|
||||||
|
// $('.topnav').css({
|
||||||
|
// 'left': $blockList.width()+$sidebarNav.width()+20,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
if($('.bottomnav').length) {
|
||||||
|
$('.bottomnav').css({
|
||||||
|
'left': $blockList.width()+$sidebarNav.width()+20,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$sidebar.css({'width': 61});
|
||||||
|
}else{
|
||||||
|
$block.eq($elIndex).addClass('show');
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
if($elIndex === null) {
|
||||||
|
$position = $arrow.outerHeight(true)*-1;
|
||||||
|
} else {
|
||||||
|
$position = $el.eq($elIndex).position().top+$el.eq($elIndex).height()/2-$arrowHeightFormat+$('.scroller').position().top;
|
||||||
|
}
|
||||||
|
$arrow.stop(true, false).animate({
|
||||||
|
top: $position,
|
||||||
|
},{
|
||||||
|
duration: 500,
|
||||||
|
easing: 'easeInOutBack',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Touch Start
|
||||||
|
$wrap.on({
|
||||||
|
touchstart: function() {
|
||||||
|
if(!$sidebarState || !$el.hasClass('active')) {
|
||||||
|
if($block.hasClass('show')) {
|
||||||
|
$blockIndex = $block.filter('.sub-nav-block show').index();
|
||||||
|
$block.removeClass('show');
|
||||||
|
$blockList.css({'width': 0});
|
||||||
|
$wrap.css({
|
||||||
|
'margin-left': $wrapLeft,
|
||||||
|
});
|
||||||
|
$sidebar.css({'width': 61});
|
||||||
|
$arrow.stop().animate({
|
||||||
|
top: $position,
|
||||||
|
},{
|
||||||
|
duration: 500,
|
||||||
|
easing: 'easeInOutBack',
|
||||||
|
});
|
||||||
|
$el.eq($blockIndex).hasClass('active') ? '':$el.eq($blockIndex).children('span').removeClass('hover');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Sidebar Nav Drag
|
||||||
|
if(/MSIE 8.0/g.test($ua)){
|
||||||
|
$arrow.remove();
|
||||||
|
$sidebarMenu.addClass('nano')
|
||||||
|
.children('.scroller')
|
||||||
|
.addClass('content')
|
||||||
|
.removeClass('scroller');
|
||||||
|
$sidebarMenu.nanoScroller({ scrollTop: 0 });
|
||||||
|
} else {
|
||||||
|
if($('#sidebar').length) {
|
||||||
|
var sidebarMenu = new iScroll('sidebar-menu', {
|
||||||
|
vScrollbar: true,
|
||||||
|
scrollbarClass: 'myScrollbar',
|
||||||
|
onBeforeScrollStart: function (e) {
|
||||||
|
var target = e.target;
|
||||||
|
clearTimeout(this.hoverTimeout);
|
||||||
|
while (target.nodeName != "SPAN") target = target.parentNode;
|
||||||
|
$target = $(target.parentNode).index();
|
||||||
|
},
|
||||||
|
touch: function () {
|
||||||
|
if (this.hoverTarget) {
|
||||||
|
clearTimeout(this.hoverTimeout);
|
||||||
|
$('.sub-nav-block').removeClass('show')
|
||||||
|
$('.sub-nav-block').eq($target).addClass('show')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Initial State
|
||||||
|
initialState = function () {
|
||||||
|
if($('.bottomnav').length) {
|
||||||
|
var $bottomnavHeight = $('.bottomnav').outerHeight();
|
||||||
|
$('.wrap-inner').css({
|
||||||
|
'padding-bottom': $bottomnavHeight,
|
||||||
|
})
|
||||||
|
if($sidebarState) {
|
||||||
|
if(!$('.sidebar-nav').hasClass('no-sub-nav')) {
|
||||||
|
if($('#basic-info').length) {
|
||||||
|
$('.bottomnav').css({
|
||||||
|
'left': 631,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$('.bottomnav').css({
|
||||||
|
'left': 261,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if($('.topnav').length) {
|
||||||
|
// if($sidebarState) {
|
||||||
|
// $('.topnav').css({
|
||||||
|
// 'left': 261,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
};
|
||||||
|
$.fn.delayKeyup = function(callback, ms){
|
||||||
|
var timer = 0;
|
||||||
|
$(this).keyup(function(){
|
||||||
|
clearTimeout (timer);
|
||||||
|
timer = setTimeout(callback, ms);
|
||||||
|
});
|
||||||
|
return $(this);
|
||||||
|
};
|
||||||
|
}(window.jQuery);
|
||||||
|
|
||||||
|
|
||||||
|
var ini = function() {
|
||||||
|
api = this
|
||||||
|
api.modal = function(e) {
|
||||||
|
$('#dialog a.delete-item').attr("href", e);
|
||||||
|
$('#dialog').modal('show');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
var ini = function() {
|
||||||
|
api = this
|
||||||
|
api.modal = function(e) {
|
||||||
|
$('#dialog a.delete-item').attr("href", e);
|
||||||
|
$('#dialog').modal('show');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Open Slide
|
||||||
|
function openSlide() {
|
||||||
|
var $openSlide = $('.open-slide');
|
||||||
|
typeof customOpenSlide === 'function' ? customOpenSlide($openSlide) : $openSlide.pageslide();
|
||||||
|
}
|
||||||
|
|
||||||
|
function formTip() {
|
||||||
|
if($('.main-forms').length && $('.add-on').length || $('.phtot-action').length) {
|
||||||
|
$('.main-forms .add-on, .main-forms .file-link, .phtot-action li').tooltip({
|
||||||
|
position: {
|
||||||
|
my: "center bottom-4",
|
||||||
|
at: "center top"
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if($('.no-sub-nav').length) {
|
||||||
|
$('.no-sub-nav li').tooltip({
|
||||||
|
position: {
|
||||||
|
my: "left+20 center",
|
||||||
|
at: "right center"
|
||||||
|
},
|
||||||
|
track: true,
|
||||||
|
tooltipClass: "sidebar-tooltip",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function changeStatusHidden() {
|
||||||
|
$('#status').find('label.checkbox').each(function() {
|
||||||
|
$(this).find('input[type="hidden"]').clone().appendTo($(this));
|
||||||
|
$(this).find('input[type="hidden"]').eq(0).remove();
|
||||||
|
$(this).find('input[type="checkbox"]').after
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Document Ready
|
||||||
|
$(function() {
|
||||||
|
showFiltersOnPageRefresh();
|
||||||
|
|
||||||
|
new ini();
|
||||||
|
$('#main-wrap').on('click', '.delete', function() {
|
||||||
|
api.modal($(this).attr('rel'));
|
||||||
|
})
|
||||||
|
initialState();
|
||||||
|
$('#login').on('shown', function () {
|
||||||
|
$(document.body).addClass('modalBlur');
|
||||||
|
$('#login').focusFirstField();
|
||||||
|
}).on("hide", function() {
|
||||||
|
$(document.body).removeClass('modalBlur');
|
||||||
|
});
|
||||||
|
$('#orbit-bar .searchClear').searchClear({
|
||||||
|
inputName: '.search-query',
|
||||||
|
inputIcon: 'icon-search',
|
||||||
|
clearBtnIcon: 'icons-cross-3',
|
||||||
|
|
||||||
|
});
|
||||||
|
$('#filter .searchClear').searchClear({
|
||||||
|
inputName: '.search-query',
|
||||||
|
inputIcon: 'icon-search',
|
||||||
|
clearBtnIcon: 'icons-cross-3',
|
||||||
|
liveFilter: true,
|
||||||
|
});
|
||||||
|
$('#member-filter').on('shown', function() {
|
||||||
|
$(this).find('.nano').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true });
|
||||||
|
});
|
||||||
|
if($('#sidebar').length) {
|
||||||
|
if(!/MSIE 8.0/g.test(navigator.userAgent)){
|
||||||
|
document.getElementById('sidebar').addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($('#pageslide').length) {
|
||||||
|
openSlide();
|
||||||
|
}
|
||||||
|
if($('.tags').length) {
|
||||||
|
$('#filter-input').fastLiveFilter('#tags-list', '.filter-item', '.tag');
|
||||||
|
}
|
||||||
|
if($('#card-list').length) {
|
||||||
|
$('#filter-input').fastLiveFilter('#card-list', '.filter-item', '.user-name');
|
||||||
|
}
|
||||||
|
if($('.toggle-check').length) {
|
||||||
|
$('.toggle-check').togglebox();
|
||||||
|
}
|
||||||
|
if($('#status').length) {
|
||||||
|
changeStatusHidden();
|
||||||
|
}
|
||||||
|
formTip()
|
||||||
|
sidebarNav();
|
||||||
|
});
|
||||||
|
|
||||||
|
var showFiltersOnPageRefresh = function(){
|
||||||
|
var params = getUrlVars(),
|
||||||
|
paramfilter = params['new_filter[type]'];
|
||||||
|
|
||||||
|
// switch (paramfilter){
|
||||||
|
// case "role":
|
||||||
|
// paramfilter = "status";
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
|
||||||
|
if( paramfilter ){
|
||||||
|
$( "#filter" ).addClass('open');
|
||||||
|
$( '#filter a[href="#collapse-' + paramfilter + '"]').parent().parent().addClass('active');
|
||||||
|
$( '#filter #collapse-' + paramfilter ).addClass('in');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var getUrlVars = function(){
|
||||||
|
var vars = [], hash;
|
||||||
|
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
|
||||||
|
for(var i = 0; i < hashes.length; i++){
|
||||||
|
hash = hashes[i].split('=');
|
||||||
|
vars.push(decodeURIComponent(hash[0]));
|
||||||
|
vars[decodeURIComponent(hash[0])] = decodeURIComponent(hash[1]);
|
||||||
|
}
|
||||||
|
if(vars[0] == window.location.href){
|
||||||
|
vars =[];
|
||||||
|
}
|
||||||
|
return vars;
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
function slideshow (element, bannerEffect, bannerTime, bannerSpeed) {
|
||||||
|
element.cycle('destroy');
|
||||||
|
element.children('img').removeAttr('class');;
|
||||||
|
element.cycle({
|
||||||
|
fx: bannerEffect,
|
||||||
|
timeout: bannerTime,
|
||||||
|
speed: bannerSpeed,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
function setSlideshow(element, data) {
|
||||||
|
$("#pageslide .ad_banner_ad_fx").children('option:selected').each(function(index, el) {
|
||||||
|
$(this).val() == 'flipHorz' || $(this).val() == 'flipVert' ? $('.suckIE').show() : $('.suckIE').hide();
|
||||||
|
});
|
||||||
|
slideshow(element, data['fx'], 2000, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function preview() {
|
||||||
|
$('.open-modal').on('click', function() {
|
||||||
|
var _data = $(this).data();
|
||||||
|
bannerName = _data.name;
|
||||||
|
bannerEffect = _data.fx;
|
||||||
|
bannerTime = _data.time;
|
||||||
|
bannerSpeed = _data.speed;
|
||||||
|
bannerW = _data.w;
|
||||||
|
bannerH = _data.h;
|
||||||
|
$('#preview').modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#preview').on('shown', function() {
|
||||||
|
$(this).attr('aria-labelledby', bannerName.toString()).find('h3').text(bannerName.toString())
|
||||||
|
if(bannerW > 500) {
|
||||||
|
var resize = 500/bannerW
|
||||||
|
bannerW = Math.floor(bannerW*resize);
|
||||||
|
bannerH = Math.floor(bannerH*resize);
|
||||||
|
console.log(bannerW)
|
||||||
|
};
|
||||||
|
if(bannerH > 300) {
|
||||||
|
var resize = 300/bannerH
|
||||||
|
bannerW = Math.floor(bannerW*resize);
|
||||||
|
bannerH = Math.floor(bannerH*resize);
|
||||||
|
}
|
||||||
|
slideshow($(this).find('.preview'), bannerEffect, bannerTime, bannerSpeed);
|
||||||
|
$(this).find('.preview').css({
|
||||||
|
'width': bannerW,
|
||||||
|
'height': bannerH
|
||||||
|
});
|
||||||
|
$(this).find('.preview img').css({
|
||||||
|
'width': '100%',
|
||||||
|
'height': '100%'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$('#preview').on('hidden', function() {
|
||||||
|
$(this).attr('aria-labelledby', '').find('h3').text('')
|
||||||
|
$(this).find('.preview').cycle('destroy');
|
||||||
|
$(this).find('.preview img').removeAttr('style');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
var bannerName = null,
|
||||||
|
bannerEffect = null,
|
||||||
|
bannerTime = null,
|
||||||
|
bannerSpeed = null,
|
||||||
|
bannerW = null,
|
||||||
|
bannerH = null,
|
||||||
|
$preview = $('#pageslide .preview');
|
||||||
|
|
||||||
|
$(".ad_banner_ad_fx").change(function () {
|
||||||
|
var suckIE = false;
|
||||||
|
// bannerTime = $("#pageslide #timeout").val()*1000;
|
||||||
|
// bannerSpeed = $("#pageslide #speed").val()*1000;
|
||||||
|
|
||||||
|
bannerTime = parseInt(bannerTime) || 300;
|
||||||
|
bannerSpeed = parseInt(bannerSpeed) || 300;
|
||||||
|
$(this).children('option:selected').each(function(index, el) {
|
||||||
|
$(this).val() == 'flipHorz' || $(this).val() == 'flipVert' ? $('.suckIE').show() : $('.suckIE').hide();
|
||||||
|
});
|
||||||
|
slideshow($preview, $(this).val(), 2000, 1000);
|
||||||
|
});
|
||||||
|
preview();
|
||||||
|
});
|
|
@ -0,0 +1,3 @@
|
||||||
|
$(function(){
|
||||||
|
$('.main-list').footable();
|
||||||
|
});
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,170 @@
|
||||||
|
/* ===========================================================
|
||||||
|
* bootstrap-fileupload.js j2
|
||||||
|
* http://jasny.github.com/bootstrap/javascript.html#fileupload
|
||||||
|
* ===========================================================
|
||||||
|
* Copyright 2012 Jasny BV, Netherlands.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License")
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
* ========================================================== */
|
||||||
|
|
||||||
|
!function ($) {
|
||||||
|
|
||||||
|
"use strict"; // jshint ;_
|
||||||
|
|
||||||
|
/* FILEUPLOAD PUBLIC CLASS DEFINITION
|
||||||
|
* ================================= */
|
||||||
|
|
||||||
|
var Fileupload = function (element, options) {
|
||||||
|
this.$element = $(element)
|
||||||
|
this.type = this.$element.data('uploadtype') || (this.$element.find('.thumbnail').length > 0 ? "image" : "file")
|
||||||
|
|
||||||
|
this.$input = this.$element.find(':file')
|
||||||
|
if (this.$input.length === 0) return
|
||||||
|
|
||||||
|
this.name = this.$input.attr('name') || options.name
|
||||||
|
|
||||||
|
this.$hidden = this.$element.find('input[type=hidden][name="'+this.name+'"]')
|
||||||
|
if (this.$hidden.length === 0) {
|
||||||
|
this.$hidden = $('<input type="hidden" />')
|
||||||
|
this.$element.prepend(this.$hidden)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$preview = this.$element.find('.fileupload-preview')
|
||||||
|
var height = this.$preview.css('height')
|
||||||
|
if (this.$preview.css('display') != 'inline' && height != '0px' && height != 'none') this.$preview.css('line-height', height)
|
||||||
|
|
||||||
|
this.original = {
|
||||||
|
'exists': this.$element.hasClass('fileupload-exists'),
|
||||||
|
'preview': this.$preview.html(),
|
||||||
|
'hiddenVal': this.$hidden.val()
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$remove = this.$element.find('[data-dismiss="fileupload"]')
|
||||||
|
|
||||||
|
this.$element.find('[data-trigger="fileupload"]').on('click.fileupload', $.proxy(this.trigger, this))
|
||||||
|
|
||||||
|
this.listen()
|
||||||
|
}
|
||||||
|
|
||||||
|
Fileupload.prototype = {
|
||||||
|
|
||||||
|
listen: function() {
|
||||||
|
this.$input.on('change.fileupload', $.proxy(this.change, this))
|
||||||
|
$(this.$input[0].form).on('reset.fileupload', $.proxy(this.reset, this))
|
||||||
|
if (this.$remove) this.$remove.on('click.fileupload', $.proxy(this.clear, this))
|
||||||
|
},
|
||||||
|
|
||||||
|
change: function(e, invoked) {
|
||||||
|
if (invoked === 'clear') return
|
||||||
|
|
||||||
|
var file = e.target.files !== undefined ? e.target.files[0] : (e.target.value ? { name: e.target.value.replace(/^.+\\/, '') } : null)
|
||||||
|
|
||||||
|
if (!file) {
|
||||||
|
this.clear()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$hidden.val('')
|
||||||
|
this.$hidden.attr('name', '')
|
||||||
|
this.$input.attr('name', this.name)
|
||||||
|
|
||||||
|
if (this.type === "image" && this.$preview.length > 0 && (typeof file.type !== "undefined" ? file.type.match('image.*') : file.name.match('\\.(gif|png|jpe?g)$')) && typeof FileReader !== "undefined") {
|
||||||
|
var reader = new FileReader()
|
||||||
|
var preview = this.$preview
|
||||||
|
var element = this.$element
|
||||||
|
|
||||||
|
reader.onload = function(e) {
|
||||||
|
preview.html('<img src="' + e.target.result + '" ' + (preview.css('max-height') != 'none' ? 'style="max-height: ' + preview.css('max-height') + ';"' : '') + ' />')
|
||||||
|
element.addClass('fileupload-exists').removeClass('fileupload-new');
|
||||||
|
$('.fileupload-remove').removeClass('active').find('input[type="checkbox"]').prop('checked', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
reader.readAsDataURL(file)
|
||||||
|
} else {
|
||||||
|
this.$preview.text(file.name)
|
||||||
|
this.$element.addClass('fileupload-exists').removeClass('fileupload-new')
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
clear: function(e) {
|
||||||
|
this.$hidden.val('')
|
||||||
|
this.$hidden.attr('name', this.name)
|
||||||
|
this.$input.attr('name', '')
|
||||||
|
|
||||||
|
//ie8+ doesn't support changing the value of input with type=file so clone instead
|
||||||
|
if (navigator.userAgent.match(/msie/i)){
|
||||||
|
var inputClone = this.$input.clone(true);
|
||||||
|
this.$input.after(inputClone);
|
||||||
|
this.$input.remove();
|
||||||
|
this.$input = inputClone;
|
||||||
|
}else{
|
||||||
|
this.$input.val('')
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$preview.html('')
|
||||||
|
this.$element.addClass('fileupload-new').removeClass('fileupload-exists')
|
||||||
|
|
||||||
|
if (e) {
|
||||||
|
this.$input.trigger('change', [ 'clear' ])
|
||||||
|
e.preventDefault()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
reset: function(e) {
|
||||||
|
this.clear()
|
||||||
|
|
||||||
|
this.$hidden.val(this.original.hiddenVal)
|
||||||
|
this.$preview.html(this.original.preview)
|
||||||
|
|
||||||
|
if (this.original.exists) this.$element.addClass('fileupload-exists').removeClass('fileupload-new')
|
||||||
|
else this.$element.addClass('fileupload-new').removeClass('fileupload-exists')
|
||||||
|
},
|
||||||
|
|
||||||
|
trigger: function(e) {
|
||||||
|
this.$input.trigger('click')
|
||||||
|
e.preventDefault()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* FILEUPLOAD PLUGIN DEFINITION
|
||||||
|
* =========================== */
|
||||||
|
|
||||||
|
$.fn.fileupload = function (options) {
|
||||||
|
return this.each(function () {
|
||||||
|
var $this = $(this)
|
||||||
|
, data = $this.data('fileupload')
|
||||||
|
if (!data) $this.data('fileupload', (data = new Fileupload(this, options)))
|
||||||
|
if (typeof options == 'string') data[options]()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
$.fn.fileupload.Constructor = Fileupload
|
||||||
|
|
||||||
|
|
||||||
|
/* FILEUPLOAD DATA-API
|
||||||
|
* ================== */
|
||||||
|
|
||||||
|
$(document).on('click.fileupload.data-api', '[data-provides="fileupload"]', function (e) {
|
||||||
|
var $this = $(this)
|
||||||
|
if ($this.data('fileupload')) return
|
||||||
|
$this.fileupload($this.data())
|
||||||
|
|
||||||
|
var $target = $(e.target).closest('[data-dismiss="fileupload"],[data-trigger="fileupload"]');
|
||||||
|
if ($target.length > 0) {
|
||||||
|
$target.trigger('click.fileupload')
|
||||||
|
e.preventDefault()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}(window.jQuery);
|
|
@ -0,0 +1,63 @@
|
||||||
|
// function cardCheck() {
|
||||||
|
// if($('.tags').length) {
|
||||||
|
// var $card = $('.checkbox-card .card'),
|
||||||
|
// $check = $card.children($('input[type="checkbox"]'));
|
||||||
|
// $check.each(function(){
|
||||||
|
// if($(this).attr('checked')) {
|
||||||
|
// $(this).parent(".check").addClass("active");
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// } else {
|
||||||
|
// var $card = $('.checkbox-card>li'),
|
||||||
|
// $check = $('input[type="checkbox"]');
|
||||||
|
// $check.each(function(){
|
||||||
|
// if($(this).attr('checked')) {
|
||||||
|
// $(this).parent("li").addClass("active");
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// $card.on('click', function() {
|
||||||
|
// $(this).toggleClass('active')
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// $(function(){
|
||||||
|
// cardCheck();
|
||||||
|
// });
|
||||||
|
!function ($) {
|
||||||
|
$.fn.cardCheck = function(param) {
|
||||||
|
_defaultSettings = {
|
||||||
|
item: '.check-item',
|
||||||
|
};
|
||||||
|
_set = $.extend(_defaultSettings, param);
|
||||||
|
$main = $(this);
|
||||||
|
$check = $main.find('input[type="checkbox"]');
|
||||||
|
$check.each(function(){
|
||||||
|
if($(this).prop('checked')) {
|
||||||
|
$(this).parent(_set.item).addClass("active");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$main.delegate(_set.item, 'click', function(e) {
|
||||||
|
$(this).toggleClass('active')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}(window.jQuery);
|
||||||
|
optionHeight = function() {
|
||||||
|
var $H = $(window).height()-parseInt($('.wrap-inner').css('padding-top'))-$('.bottomnav').innerHeight()-$('#orbit-bar').innerHeight()-2;
|
||||||
|
$('.mini-layout-sidebar .nano').height($H);
|
||||||
|
}
|
||||||
|
$(function(){
|
||||||
|
if($('.mini-layout-sidebar .nano').length) {
|
||||||
|
optionHeight();
|
||||||
|
$(window).resize(function() {
|
||||||
|
optionHeight();
|
||||||
|
});
|
||||||
|
$('.mini-layout-sidebar .nano').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true });
|
||||||
|
}
|
||||||
|
if($('.tags').length) {
|
||||||
|
$('.tags-groups').cardCheck({
|
||||||
|
item: '.card',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$('.checkbox-card').cardCheck();
|
||||||
|
};
|
||||||
|
});
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,2 @@
|
||||||
|
/* Plugin for Cycle2; Copyright (c) 2012 M. Alsup; v20130909 */
|
||||||
|
(function(e){"use strict";function t(t){return{preInit:function(e){e.slides.css(n)},transition:function(i,n,s,o,r){var l=i,c=e(n),a=e(s),d=l.speed/2;t.call(a,-90),a.css({display:"block","background-position":"-90px",opacity:1}),c.css("background-position","0px"),c.animate({backgroundPosition:90},{step:t,duration:d,easing:l.easeOut||l.easing,complete:function(){i.API.updateView(!1,!0),a.animate({backgroundPosition:0},{step:t,duration:d,easing:l.easeIn||l.easing,complete:r})}})}}}function i(t){return function(i){var n=e(this);n.css({"-webkit-transform":"rotate"+t+"("+i+"deg)","-moz-transform":"rotate"+t+"("+i+"deg)","-ms-transform":"rotate"+t+"("+i+"deg)","-o-transform":"rotate"+t+"("+i+"deg)",transform:"rotate"+t+"("+i+"deg)"})}}var n,s=document.createElement("div").style,o=e.fn.cycle.transitions,r=void 0!==s.transform||void 0!==s.MozTransform||void 0!==s.webkitTransform||void 0!==s.oTransform||void 0!==s.msTransform;r&&void 0!==s.msTransform&&(s.msTransform="rotateY(0deg)",s.msTransform||(r=!1)),r?(o.flipHorz=t(i("Y")),o.flipVert=t(i("X")),n={"-webkit-backface-visibility":"hidden","-moz-backface-visibility":"hidden","-o-backface-visibility":"hidden","backface-visibility":"hidden"}):(o.flipHorz=o.scrollHorz,o.flipVert=o.scrollVert||o.scrollHorz)})(jQuery);
|
2
app/assets/javascripts/lib/cycle2/transition/jquery.cycle2.ie-fade.min.js
vendored
Executable file
2
app/assets/javascripts/lib/cycle2/transition/jquery.cycle2.ie-fade.min.js
vendored
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
/*! Plugin for Cycle2; Copyright (c) 2012 M. Alsup; ver: 20121120 */
|
||||||
|
(function(a){function b(a,b,c){if(a&&c.style.filter){b._filter=c.style.filter;try{c.style.removeAttribute("filter")}catch(d){}}else!a&&b._filter&&(c.style.filter=b._filter)}"use strict",a.extend(a.fn.cycle.transitions,{fade:{before:function(c,d,e,f){var g=c.API.getSlideOpts(c.nextSlide).slideCss||{};c.API.stackSlides(d,e,f),c.cssBefore=a.extend(g,{opacity:0,display:"block"}),c.animIn={opacity:1},c.animOut={opacity:0},b(!0,c,e)},after:function(a,c,d){b(!1,a,d)}},fadeout:{before:function(c,d,e,f){var g=c.API.getSlideOpts(c.nextSlide).slideCss||{};c.API.stackSlides(d,e,f),c.cssBefore=a.extend(g,{opacity:1,display:"block"}),c.animOut={opacity:0},b(!0,c,e)},after:function(a,c,d){b(!1,a,d)}}})})(jQuery);
|
2
app/assets/javascripts/lib/cycle2/transition/jquery.cycle2.scrollVert.min.js
vendored
Executable file
2
app/assets/javascripts/lib/cycle2/transition/jquery.cycle2.scrollVert.min.js
vendored
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
/*! Plugin for Cycle2; Copyright (c) 2012 M. Alsup; ver: 20121120 */
|
||||||
|
(function(a){"use strict",a.fn.cycle.transitions.scrollVert={before:function(a,b,c,d){a.API.stackSlides(a,b,c,d);var e=a.container.css("overflow","hidden").height();a.cssBefore={top:d?-e:e,left:0,opacity:1,display:"block"},a.animIn={top:0},a.animOut={top:d?e:-e}}}})(jQuery);
|
|
@ -0,0 +1,2 @@
|
||||||
|
/* Plugin for Cycle2; Copyright (c) 2012 M. Alsup; v20130721 */
|
||||||
|
(function(e){"use strict";e.fn.cycle.transitions.tileSlide=e.fn.cycle.transitions.tileBlind={before:function(t,i,n,s){t.API.stackSlides(i,n,s),e(i).show(),t.container.css("overflow","hidden"),t.tileDelay=t.tileDelay||"tileSlide"==t.fx?100:125,t.tileCount=t.tileCount||7,t.tileVertical=t.tileVertical!==!1,t.container.data("cycleTileInitialized")||(t.container.on("cycle-destroyed",e.proxy(this.onDestroy,t.API)),t.container.data("cycleTileInitialized",!0))},transition:function(t,i,n,s,o){function r(e){p.eq(e).animate(I,{duration:t.speed,easing:t.easing,complete:function(){(s?v-1===e:0===e)&&t._tileAniCallback()}}),setTimeout(function(){(s?v-1!==e:0!==e)&&r(s?e+1:e-1)},t.tileDelay)}t.slides.not(i).not(n).hide();var c,l,a,d,u,p=e(),f=e(i),y=e(n),v=t.tileCount,h=t.tileVertical,g=t.container.height(),m=t.container.width();h?(l=Math.floor(m/v),d=m-l*(v-1),a=u=g):(l=d=m,a=Math.floor(g/v),u=g-a*(v-1)),t.container.find(".cycle-tiles-container").remove();var I,A={left:0,top:0,overflow:"hidden",position:"absolute",margin:0,padding:0};I=h?"tileSlide"==t.fx?{top:g}:{width:0}:"tileSlide"==t.fx?{left:m}:{height:0};var S=e('<div class="cycle-tiles-container"></div>');S.css({zIndex:f.css("z-index"),overflow:"visible",position:"absolute",top:0,left:0,direction:"ltr"}),S.insertBefore(n);for(var x=0;v>x;x++)c=e("<div></div>").css(A).css({width:v-1===x?d:l,height:v-1===x?u:a,marginLeft:h?x*l:0,marginTop:h?0:x*a}).append(f.clone().css({position:"relative",maxWidth:"none",width:f.width(),margin:0,padding:0,marginLeft:h?-(x*l):0,marginTop:h?0:-(x*a)})),p=p.add(c);S.append(p),f.hide(),y.show().css("opacity",1),r(s?0:v-1),t._tileAniCallback=function(){y.show(),f.hide(),S.remove(),o()}},stopTransition:function(e){e.container.find("*").stop(!0,!0),e._tileAniCallback&&e._tileAniCallback()},onDestroy:function(){var e=this.opts();e.container.find(".cycle-tiles-container").remove()}}})(jQuery);
|
|
@ -0,0 +1,17 @@
|
||||||
|
!function ($) {
|
||||||
|
$.fn.datetimepick = function() {
|
||||||
|
var $this = this,
|
||||||
|
$data = $this.data();
|
||||||
|
$this.datetimepicker({
|
||||||
|
format: $data.dateFormat,
|
||||||
|
pickTime: $data.picktime,
|
||||||
|
language: $data.language,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}(window.jQuery);
|
||||||
|
|
||||||
|
$(function(){
|
||||||
|
$('.datetimepick').each(function() {
|
||||||
|
$(this).datetimepick();
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,33 @@
|
||||||
|
$(document).ready(function(){
|
||||||
|
|
||||||
|
$('.date_picker').datetimepicker({
|
||||||
|
pickTime: false
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.default_picker').datetimepicker();
|
||||||
|
|
||||||
|
$('.time_picker').datetimepicker({
|
||||||
|
pickDate: false
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.separated_picker div').on("changeDate",function(){
|
||||||
|
if ($(this).hasClass('date_picker'))
|
||||||
|
{
|
||||||
|
if ($(this).find('input').val() && $(this).siblings('div').css('pointer-events'))
|
||||||
|
{
|
||||||
|
$(this).siblings('div').css('pointer-events', '');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$(this).siblings('div').find('input').val(null);
|
||||||
|
$(this).siblings('div').css('pointer-events', 'none');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$(this).siblings('input').val($(this).find('input').val() + ' ' + $(this).siblings('div').find('input').val());
|
||||||
|
});
|
||||||
|
|
||||||
|
// $('.date_picker').on("changeDate",function(){
|
||||||
|
// $(this).find('input').val('');
|
||||||
|
// });
|
||||||
|
|
||||||
|
});
|
|
@ -0,0 +1,32 @@
|
||||||
|
$(function () {
|
||||||
|
var $fileType = $('.file-type'),
|
||||||
|
$type = ['pdf', 'psd', 'ai', 'fla', 'swf', 'in', 'acc', 'do', 'xl', 'pp', 'zip', 'rar', '7z', 'txt', 'jp', 'gif', 'png', 'mp3', 'wav'];
|
||||||
|
|
||||||
|
$fileType.each(function (i) {
|
||||||
|
var $fileTypeHref = null;
|
||||||
|
if($(this).children('a').length) {
|
||||||
|
$fileTypeHref = $(this).children('a').attr('href');
|
||||||
|
} else {
|
||||||
|
$fileTypeHref = $(this).attr('href');
|
||||||
|
};
|
||||||
|
|
||||||
|
$fileTypeHref = $fileTypeHref.split("/");
|
||||||
|
$fileTypeHref = $fileTypeHref[$fileTypeHref.length-1];
|
||||||
|
$fileTypeHref = $fileTypeHref.split(".");
|
||||||
|
$fileTypeHref = $fileTypeHref[$fileTypeHref.length-1];
|
||||||
|
|
||||||
|
$.map($type, function(type, index) {
|
||||||
|
if($fileTypeHref.indexOf(type)!=-1) {
|
||||||
|
if(type == "swf") {
|
||||||
|
$fileType.eq(i).addClass('type-fla');
|
||||||
|
} else if(type == "zip" || type == "rar" || type == "7z") {
|
||||||
|
$fileType.eq(i).addClass('type-zip');
|
||||||
|
} else if(type == "mp3" || type == "wav") {
|
||||||
|
$fileType.eq(i).addClass('type-audio');
|
||||||
|
} else {
|
||||||
|
$fileType.eq(i).addClass('type-'+type);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,415 @@
|
||||||
|
/*!
|
||||||
|
* FooTable - Awesome Responsive Tables
|
||||||
|
* http://themergency.com/footable
|
||||||
|
*
|
||||||
|
* Requires jQuery - http://jquery.com/
|
||||||
|
*
|
||||||
|
* Copyright 2012 Steven Usher & Brad Vincent
|
||||||
|
* Released under the MIT license
|
||||||
|
* You are free to use FooTable in commercial projects as long as this copyright header is left intact.
|
||||||
|
*
|
||||||
|
* Date: 18 Nov 2012
|
||||||
|
*/
|
||||||
|
(function ($, w, undefined) {
|
||||||
|
w.footable = {
|
||||||
|
options: {
|
||||||
|
delay: 100, // The number of millseconds to wait before triggering the react event
|
||||||
|
breakpoints: { // The different screen resolution breakpoints
|
||||||
|
phone: 480,
|
||||||
|
tablet: 1024
|
||||||
|
},
|
||||||
|
parsers: { // The default parser to parse the value out of a cell (values are used in building up row detail)
|
||||||
|
alpha: function (cell) {
|
||||||
|
return $(cell).data('value') || $.trim($(cell).text());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
toggleSelector: '.detail-row', //the selector to show/hide the detail row
|
||||||
|
createDetail: function (element, data) { //creates the contents of the detail row
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
element.append('<div><strong>' + data[i].name + '</strong> : ' + data[i].display + '</div>');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
classes: {
|
||||||
|
loading : 'footable-loading',
|
||||||
|
loaded : 'footable-loaded',
|
||||||
|
sorted : 'footable-sorted',
|
||||||
|
descending : 'footable-sorted-desc',
|
||||||
|
indicator : 'footable-sort-indicator'
|
||||||
|
},
|
||||||
|
debug: false // Whether or not to log information to the console.
|
||||||
|
},
|
||||||
|
|
||||||
|
version: {
|
||||||
|
major: 0, minor: 1,
|
||||||
|
toString: function () {
|
||||||
|
return w.footable.version.major + '.' + w.footable.version.minor;
|
||||||
|
},
|
||||||
|
parse: function (str) {
|
||||||
|
version = /(\d+)\.?(\d+)?\.?(\d+)?/.exec(str);
|
||||||
|
return {
|
||||||
|
major: parseInt(version[1]) || 0,
|
||||||
|
minor: parseInt(version[2]) || 0,
|
||||||
|
patch: parseInt(version[3]) || 0
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
plugins: {
|
||||||
|
_validate: function (plugin) {
|
||||||
|
///<summary>Simple validation of the <paramref name="plugin"/> to make sure any members called by Foobox actually exist.</summary>
|
||||||
|
///<param name="plugin">The object defining the plugin, this should implement a string property called "name" and a function called "init".</param>
|
||||||
|
|
||||||
|
if (typeof plugin['name'] !== 'string') {
|
||||||
|
if (w.footable.options.debug == true) console.error('Validation failed, plugin does not implement a string property called "name".', plugin);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!$.isFunction(plugin['init'])) {
|
||||||
|
if (w.footable.options.debug == true) console.error('Validation failed, plugin "' + plugin['name'] + '" does not implement a function called "init".', plugin);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (w.footable.options.debug == true) console.log('Validation succeeded for plugin "' + plugin['name'] + '".', plugin);
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
registered: [], // An array containing all registered plugins.
|
||||||
|
register: function (plugin, options) {
|
||||||
|
///<summary>Registers a <paramref name="plugin"/> and its default <paramref name="options"/> with Foobox.</summary>
|
||||||
|
///<param name="plugin">The plugin that should implement a string property called "name" and a function called "init".</param>
|
||||||
|
///<param name="options">The default options to merge with the Foobox's base options.</param>
|
||||||
|
|
||||||
|
if (w.footable.plugins._validate(plugin)) {
|
||||||
|
w.footable.plugins.registered.push(plugin);
|
||||||
|
if (options != undefined && typeof options === 'object') $.extend(true, w.footable.options, options);
|
||||||
|
if (w.footable.options.debug == true) console.log('Plugin "' + plugin['name'] + '" has been registered with the Foobox.', plugin);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
init: function (instance) {
|
||||||
|
///<summary>Loops through all registered plugins and calls the "init" method supplying the current <paramref name="instance"/> of the Foobox as the first parameter.</summary>
|
||||||
|
///<param name="instance">The current instance of the Foobox that the plugin is being initialized for.</param>
|
||||||
|
|
||||||
|
for(var i = 0; i < w.footable.plugins.registered.length; i++){
|
||||||
|
try {
|
||||||
|
w.footable.plugins.registered[i]['init'](instance);
|
||||||
|
} catch(err) {
|
||||||
|
if (w.footable.options.debug == true) console.error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var instanceCount = 0;
|
||||||
|
|
||||||
|
$.fn.footable = function(options) {
|
||||||
|
///<summary>The main constructor call to initialize the plugin using the supplied <paramref name="options"/>.</summary>
|
||||||
|
///<param name="options">
|
||||||
|
///<para>A JSON object containing user defined options for the plugin to use. Any options not supplied will have a default value assigned.</para>
|
||||||
|
///<para>Check the documentation or the default options object above for more information on available options.</para>
|
||||||
|
///</param>
|
||||||
|
|
||||||
|
options=options||{};
|
||||||
|
var o=$.extend(true,{},w.footable.options,options); //merge user and default options
|
||||||
|
return this.each(function () {
|
||||||
|
instanceCount++;
|
||||||
|
this.footable = new Footable(this, o, instanceCount);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
//helper for using timeouts
|
||||||
|
function Timer() {
|
||||||
|
///<summary>Simple timer object created around a timeout.</summary>
|
||||||
|
var t=this;
|
||||||
|
t.id=null;
|
||||||
|
t.busy=false;
|
||||||
|
t.start=function (code,milliseconds) {
|
||||||
|
///<summary>Starts the timer and waits the specified amount of <paramref name="milliseconds"/> before executing the supplied <paramref name="code"/>.</summary>
|
||||||
|
///<param name="code">The code to execute once the timer runs out.</param>
|
||||||
|
///<param name="milliseconds">The time in milliseconds to wait before executing the supplied <paramref name="code"/>.</param>
|
||||||
|
|
||||||
|
if (t.busy) {return;}
|
||||||
|
t.stop();
|
||||||
|
t.id=setTimeout(function () {
|
||||||
|
code();
|
||||||
|
t.id=null;
|
||||||
|
t.busy=false;
|
||||||
|
},milliseconds);
|
||||||
|
t.busy=true;
|
||||||
|
};
|
||||||
|
t.stop=function () {
|
||||||
|
///<summary>Stops the timer if its runnning and resets it back to its starting state.</summary>
|
||||||
|
|
||||||
|
if(t.id!=null) {
|
||||||
|
clearTimeout(t.id);
|
||||||
|
t.id=null;
|
||||||
|
t.busy=false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
function Footable(t, o, id) {
|
||||||
|
///<summary>Inits a new instance of the plugin.</summary>
|
||||||
|
///<param name="t">The main table element to apply this plugin to.</param>
|
||||||
|
///<param name="o">The options supplied to the plugin. Check the defaults object to see all available options.</param>
|
||||||
|
///<param name="id">The id to assign to this instance of the plugin.</param>
|
||||||
|
|
||||||
|
var ft = this;
|
||||||
|
ft.id = id;
|
||||||
|
ft.table = t;
|
||||||
|
ft.options = o;
|
||||||
|
ft.breakpoints = [];
|
||||||
|
ft.breakpointNames = '';
|
||||||
|
ft.columns = { };
|
||||||
|
|
||||||
|
var opt = ft.options;
|
||||||
|
var cls = opt.classes;
|
||||||
|
|
||||||
|
// This object simply houses all the timers used in the footable.
|
||||||
|
ft.timers = {
|
||||||
|
resize: new Timer(),
|
||||||
|
register: function (name) {
|
||||||
|
ft.timers[name] = new Timer();
|
||||||
|
return ft.timers[name];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
w.footable.plugins.init(ft);
|
||||||
|
|
||||||
|
ft.init = function() {
|
||||||
|
var $window = $(w), $table = $(ft.table);
|
||||||
|
|
||||||
|
if ($table.hasClass(cls.loaded)) {
|
||||||
|
//already loaded FooTable for the table, so don't init again
|
||||||
|
ft.raise('footable_already_initialized');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$table.addClass(cls.loading);
|
||||||
|
|
||||||
|
// Get the column data once for the life time of the plugin
|
||||||
|
$table.find('> thead > tr > th, > thead > tr > td').each(function() {
|
||||||
|
var data = ft.getColumnData(this);
|
||||||
|
ft.columns[data.index] = data;
|
||||||
|
|
||||||
|
var count = data.index + 1;
|
||||||
|
//get all the cells in the column
|
||||||
|
var $column = $table.find('> tbody > tr > td:nth-child(' + count + ')');
|
||||||
|
//add the className to the cells specified by data-class="blah"
|
||||||
|
if (data.className != null) $column.not('.footable-cell-detail').addClass(data.className);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Create a nice friendly array to work with out of the breakpoints object.
|
||||||
|
for(var name in opt.breakpoints) {
|
||||||
|
ft.breakpoints.push({ 'name': name, 'width': opt.breakpoints[name] });
|
||||||
|
ft.breakpointNames += (name + ' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort the breakpoints so the smallest is checked first
|
||||||
|
ft.breakpoints.sort(function(a, b) { return a['width'] - b['width']; });
|
||||||
|
|
||||||
|
//bind the toggle selector click events
|
||||||
|
ft.bindToggleSelectors();
|
||||||
|
|
||||||
|
ft.raise('footable_initializing');
|
||||||
|
|
||||||
|
$table.bind('footable_initialized', function (e) {
|
||||||
|
//resize the footable onload
|
||||||
|
ft.resize();
|
||||||
|
|
||||||
|
//remove the loading class
|
||||||
|
$table.removeClass(cls.loading);
|
||||||
|
|
||||||
|
//hides all elements within the table that have the attribute data-hide="init"
|
||||||
|
$table.find('[data-init="hide"]').hide();
|
||||||
|
$table.find('[data-init="show"]').show();
|
||||||
|
|
||||||
|
//add the loaded class
|
||||||
|
$table.addClass(cls.loaded);
|
||||||
|
});
|
||||||
|
|
||||||
|
$window
|
||||||
|
.bind('resize.footable', function () {
|
||||||
|
ft.timers.resize.stop();
|
||||||
|
ft.timers.resize.start(function() {
|
||||||
|
ft.raise('footable_resizing');
|
||||||
|
ft.resize();
|
||||||
|
ft.raise('footable_resized');
|
||||||
|
}, opt.delay);
|
||||||
|
});
|
||||||
|
|
||||||
|
ft.raise('footable_initialized');
|
||||||
|
};
|
||||||
|
|
||||||
|
//moved this out into it's own function so that it can be called from other add-ons
|
||||||
|
ft.bindToggleSelectors = function() {
|
||||||
|
var $table = $(ft.table);
|
||||||
|
$table.find(opt.toggleSelector).unbind('click.footable').bind('click.footable', function (e) {
|
||||||
|
if ($table.is('.breakpoint')) {
|
||||||
|
var $row = $(this).is('tr') ? $(this) : $(this).parents('tr:first');
|
||||||
|
ft.toggleDetail($row.get(0));
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
ft.parse = function(cell, column) {
|
||||||
|
var parser = opt.parsers[column.type] || opt.parsers.alpha;
|
||||||
|
return parser(cell);
|
||||||
|
};
|
||||||
|
|
||||||
|
ft.getColumnData = function(th) {
|
||||||
|
var $th = $(th), hide = $th.data('hide');
|
||||||
|
hide = hide || '';
|
||||||
|
hide = hide.split(',');
|
||||||
|
var data = {
|
||||||
|
'index': $th.index(),
|
||||||
|
'hide': { },
|
||||||
|
'type': $th.data('type') || 'alpha',
|
||||||
|
'name': $th.data('name') || $.trim($th.text()),
|
||||||
|
'ignore': $th.data('ignore') || false,
|
||||||
|
'className': $th.data('class') || null
|
||||||
|
};
|
||||||
|
data.hide['default'] = ($th.data('hide')==="all") || ($.inArray('default', hide) >= 0);
|
||||||
|
|
||||||
|
for(var name in opt.breakpoints) {
|
||||||
|
data.hide[name] = ($th.data('hide')==="all") || ($.inArray(name, hide) >= 0);
|
||||||
|
}
|
||||||
|
var e = ft.raise('footable_column_data', { 'column': { 'data': data, 'th': th } });
|
||||||
|
return e.column.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
ft.getViewportWidth = function() {
|
||||||
|
return window.innerWidth || (document.body ? document.body.offsetWidth : 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
ft.getViewportHeight = function() {
|
||||||
|
return window.innerHeight || (document.body ? document.body.offsetHeight : 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
ft.hasBreakpointColumn = function(breakpoint) {
|
||||||
|
for(var c in ft.columns) {
|
||||||
|
if (ft.columns[c].hide[breakpoint]) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
ft.resize = function() {
|
||||||
|
var $table = $(ft.table);
|
||||||
|
var info = {
|
||||||
|
'width': $table.width(), //the table width
|
||||||
|
'height': $table.height(), //the table height
|
||||||
|
'viewportWidth': ft.getViewportWidth(), //the width of the viewport
|
||||||
|
'viewportHeight': ft.getViewportHeight(), //the width of the viewport
|
||||||
|
'orientation': null
|
||||||
|
};
|
||||||
|
info.orientation = info.viewportWidth > info.viewportHeight ? 'landscape' : 'portrait';
|
||||||
|
|
||||||
|
if (info.viewportWidth < info.width) info.width = info.viewportWidth;
|
||||||
|
if (info.viewportHeight < info.height) info.height = info.viewportHeight;
|
||||||
|
|
||||||
|
var pinfo = $table.data('footable_info');
|
||||||
|
$table.data('footable_info', info);
|
||||||
|
|
||||||
|
// This (if) statement is here purely to make sure events aren't raised twice as mobile safari seems to do
|
||||||
|
if (!pinfo || ((pinfo && pinfo.width && pinfo.width != info.width) || (pinfo && pinfo.height && pinfo.height != info.height))) {
|
||||||
|
var current = null, breakpoint;
|
||||||
|
for (var i = 0; i < ft.breakpoints.length; i++) {
|
||||||
|
breakpoint = ft.breakpoints[i];
|
||||||
|
if (breakpoint && breakpoint.width && info.width <= breakpoint.width) {
|
||||||
|
current = breakpoint;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var breakpointName = (current == null ? 'default' : current['name']);
|
||||||
|
|
||||||
|
var hasBreakpointFired = ft.hasBreakpointColumn(breakpointName);
|
||||||
|
|
||||||
|
$table
|
||||||
|
.removeClass('default breakpoint').removeClass(ft.breakpointNames)
|
||||||
|
.addClass(breakpointName + (hasBreakpointFired ? ' breakpoint' : ''))
|
||||||
|
.find('> thead > tr > th').each(function() {
|
||||||
|
var data = ft.columns[$(this).index()];
|
||||||
|
var count = data.index + 1;
|
||||||
|
//get all the cells in the column
|
||||||
|
var $column = $table.find('> tbody > tr > td:nth-child(' + count + '), > tfoot > tr > td:nth-child(' + count + '), > colgroup > col:nth-child(' + count + ')').add(this);
|
||||||
|
|
||||||
|
if (data.hide[breakpointName] == false) $column.show();
|
||||||
|
else $column.hide();
|
||||||
|
})
|
||||||
|
.end()
|
||||||
|
.find('> tbody > tr.footable-detail-show').each(function() {
|
||||||
|
ft.createOrUpdateDetailRow(this);
|
||||||
|
});
|
||||||
|
|
||||||
|
$table.find('> tbody > tr.footable-detail-show:visible').each(function() {
|
||||||
|
var $next = $(this).next();
|
||||||
|
if ($next.hasClass('footable-row-detail')) {
|
||||||
|
if (breakpointName == 'default' && !hasBreakpointFired) $next.hide();
|
||||||
|
else $next.show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// adding .footable-last-column to the last th and td in order to allow for styling if the last column is hidden (which won't work using :last-child)
|
||||||
|
$table.find('> thead > tr > th.footable-last-column,> tbody > tr > td.footable-last-column').removeClass('footable-last-column');
|
||||||
|
$table.find('> thead > tr > th:visible:last,> tbody > tr > td:visible:last').addClass('footable-last-column');
|
||||||
|
|
||||||
|
ft.raise('footable_breakpoint_' + breakpointName, { 'info': info });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ft.toggleDetail = function(actualRow) {
|
||||||
|
var $row = $(actualRow),
|
||||||
|
created = ft.createOrUpdateDetailRow($row.get(0)),
|
||||||
|
$next = $row.next();
|
||||||
|
|
||||||
|
if (!created && $next.is(':visible')) {
|
||||||
|
$row.removeClass('footable-detail-show');
|
||||||
|
//only hide the next row if it's a detail row
|
||||||
|
if($next.hasClass('footable-row-detail'))
|
||||||
|
$next.find('.footable-row-detail-inner').slideUp(300, function() {
|
||||||
|
$next.hide();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$row.addClass('footable-detail-show');
|
||||||
|
$next.show();
|
||||||
|
$next.find('.footable-row-detail-inner').slideDown(300);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ft.createOrUpdateDetailRow = function (actualRow) {
|
||||||
|
var $row = $(actualRow), $next = $row.next(), $detail, values = [];
|
||||||
|
if ($row.is(':hidden')) return; //if the row is hidden for some readon (perhaps filtered) then get out of here
|
||||||
|
$row.find('> td:hidden').each(function () {
|
||||||
|
var column = ft.columns[$(this).index()];
|
||||||
|
if (column.ignore == true) return true;
|
||||||
|
values.push({ 'name': column.name, 'value': ft.parse(this, column), 'display': $.trim($(this).html()) });
|
||||||
|
});
|
||||||
|
if(values.length == 0) //return if we don't have any data to show
|
||||||
|
return;
|
||||||
|
var colspan = $row.find('> td:visible').length;
|
||||||
|
var exists = $next.hasClass('footable-row-detail');
|
||||||
|
if (!exists) { // Create
|
||||||
|
$next = $('<tr class="footable-row-detail"><td class="footable-cell-detail"><div class="footable-row-detail-inner"></div></td></tr>');
|
||||||
|
$row.after($next);
|
||||||
|
}
|
||||||
|
$next.find('> td:first').attr('colspan', colspan);
|
||||||
|
$detail = $next.find('.footable-row-detail-inner').empty();
|
||||||
|
opt.createDetail($detail, values);
|
||||||
|
return !exists;
|
||||||
|
};
|
||||||
|
|
||||||
|
ft.raise = function(eventName, args) {
|
||||||
|
args = args || { };
|
||||||
|
var def = { 'ft': ft };
|
||||||
|
$.extend(true, def, args);
|
||||||
|
var e = $.Event(eventName, def);
|
||||||
|
if (!e.ft) { $.extend(true, e, def); } //pre jQuery 1.6 which did not allow data to be passed to event object constructor
|
||||||
|
$(ft.table).trigger(e);
|
||||||
|
return e;
|
||||||
|
};
|
||||||
|
|
||||||
|
ft.init();
|
||||||
|
return ft;
|
||||||
|
};
|
||||||
|
})(jQuery, window);
|
|
@ -0,0 +1,59 @@
|
||||||
|
$(function() {
|
||||||
|
var $container = $('.gallery'),
|
||||||
|
$containerData = $container.data();
|
||||||
|
|
||||||
|
$container.imagesLoaded( function(){
|
||||||
|
$container.masonry({
|
||||||
|
itemSelector : '.rgalbum',
|
||||||
|
isAnimated: true,
|
||||||
|
});
|
||||||
|
if($containerData.galleryId == 'gallery') {
|
||||||
|
var $albumname = $('.albumname'),
|
||||||
|
$img = $('.rgalbum img');
|
||||||
|
$albumname.each(function(i) {
|
||||||
|
var $imgH = $(this).prevAll($img).height(),
|
||||||
|
$H = $(this).height()+20,
|
||||||
|
$fontSize = parseInt($(this).css('font-size'));
|
||||||
|
$lineHeight = parseInt($(this).css('line-height'));
|
||||||
|
if($H > $imgH) {
|
||||||
|
$(this).css({
|
||||||
|
'bottom': "auto",
|
||||||
|
'top': 0,
|
||||||
|
});
|
||||||
|
$(this).hover(function() {
|
||||||
|
$(this).stop(true, true).delay(500).animate({
|
||||||
|
'top': '-='+($H-$imgH),
|
||||||
|
},($H-$imgH)*10)
|
||||||
|
},function() {
|
||||||
|
$(this).stop(true, true);
|
||||||
|
$(this).css({
|
||||||
|
'bottom': "auto",
|
||||||
|
'top': 0,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#orbit_gallery').delegate('.icons-tag','click',function(){
|
||||||
|
$(this).parents('.gallery_info').nextAll('.albumtag').slideToggle(300, function() {
|
||||||
|
$container.masonry({
|
||||||
|
itemSelector : '.rgalbum',
|
||||||
|
isAnimated: true,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.add-imgs').on({
|
||||||
|
click: function() {
|
||||||
|
$('#fileupload').slideToggle(300, function() {
|
||||||
|
if(!$(this).is(':hidden')) {
|
||||||
|
$('.add-imgs').html('<i class="icons-cross-2"></i> Close panel');
|
||||||
|
} else {
|
||||||
|
$('.add-imgs').html('<i class="icons-plus"></i> Add Image');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,11 @@
|
||||||
|
var $openSlide = $('.open-slide'),
|
||||||
|
$pageslideW;
|
||||||
|
$(window).width() > 1440 ? $pageslideW = 1024 : $pageslideW = 954;
|
||||||
|
$(window).resize(function() {
|
||||||
|
$(this).width() > 1440 ? $pageslideW = 1024 : $pageslideW = 954;
|
||||||
|
});
|
||||||
|
$iFrame = $openSlide.filter('.view-page.open-slide');
|
||||||
|
$iFrame.pageslide({
|
||||||
|
W: $pageslideW,
|
||||||
|
iframe: true
|
||||||
|
});
|
|
@ -0,0 +1,158 @@
|
||||||
|
function getPageData() {
|
||||||
|
$.getJSON("<%= Rails.application.routes.url_helpers.get_page_module_json_admin_page_parts_path %>").done(function(data) {
|
||||||
|
_pageData = data;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function getView(module_id, id) {
|
||||||
|
var _data = {};
|
||||||
|
_data.val = $('#module_widget #page_part_widget_path option:selected').val();
|
||||||
|
_data.id = id;
|
||||||
|
_data.module_id = module_id
|
||||||
|
$.ajax({
|
||||||
|
url: "<%= Rails.application.routes.url_helpers.get_display_style_admin_page_parts_path %>",
|
||||||
|
dataType: "script",
|
||||||
|
data: _data,
|
||||||
|
contentType: "application/html; charset=utf-8",
|
||||||
|
cache: false,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
$pageModule = $('#module_widget #page_part_module_app'),
|
||||||
|
$pageF2E = $('#module_widget #page_part_widget_path'),
|
||||||
|
$pageCategory = $('#module_widget #page-category'),
|
||||||
|
$pageCategoryGroup = $('#module_widget #page-category-groups'),
|
||||||
|
$pageTags = $('#module_widget #page-tags'),
|
||||||
|
$pageTagsGroup = $('#module_widget #page-tags-groups'),
|
||||||
|
$pageCount = $('#module_widget #page_count'),
|
||||||
|
_boolean = null,
|
||||||
|
_ID = null,
|
||||||
|
_type = null,
|
||||||
|
_status = null,
|
||||||
|
_pageData = null,
|
||||||
|
_selectData = null;
|
||||||
|
|
||||||
|
$('#module_widget').on('change', '.change', function(event) {
|
||||||
|
var _data, _select, $subSelete;
|
||||||
|
if(event.target.id !== 'page_part_widget_path') {
|
||||||
|
_data = _pageData.module;
|
||||||
|
_select = _boolean ? _selectData.module : null;
|
||||||
|
$subSelete = $('#module_widget #page_part_widget_path');
|
||||||
|
$(this).children("option:selected").each(function () {
|
||||||
|
var _val = $(this).val();
|
||||||
|
$subSelete.empty();
|
||||||
|
$pageCount.empty();
|
||||||
|
if(_val) {
|
||||||
|
$.each(_data, function(index, val) {
|
||||||
|
if(_val == val.main[1]) {
|
||||||
|
$.each(val.sub, function(index, val) {
|
||||||
|
var _selected = _select && $(this)[1] == _select.sub ? 'selected="selected"' : '';
|
||||||
|
$subSelete.append('<option value="' + $(this)[1] + '" ' + _selected.sub + '>' + $(this)[0] + '</option>');
|
||||||
|
});
|
||||||
|
$.each(val.count, function(index, val) {
|
||||||
|
$pageCount.append('<option value="' + val + '" ' + (_select && _select.main == _val && val == _selectData.module.count ? 'selected="selected"' : '') + '>' + val+ '</option>');
|
||||||
|
});
|
||||||
|
getView(val.main[1]);
|
||||||
|
|
||||||
|
if(event.target.id == 'page_part_module_app') {
|
||||||
|
$pageCategory.empty();
|
||||||
|
if(val.category.length > 0) {
|
||||||
|
$.each(val.category, function(index, val) {
|
||||||
|
if(val !== 0) {
|
||||||
|
var _arr = _select ? $.inArray($(this)[1], _select.category[1]) : '';
|
||||||
|
$pageCategory.append('<label class="checkbox"><input type="checkbox" name="page[category][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
|
||||||
|
if(_select && !_select.category[0] && _arr !== -1) {
|
||||||
|
$pageCategory.find('input[type="checkbox"]').eq(index).prop('checked', true);
|
||||||
|
}
|
||||||
|
_select && _val == _select.main && _select.category[0] ? $pageCategory.siblings('.checkbox').children('.select_all').prop('checked', true) : '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$pageCategoryGroup.show();
|
||||||
|
} else {
|
||||||
|
$pageCategoryGroup.hide();
|
||||||
|
}
|
||||||
|
if(val.tags.length > 0) {
|
||||||
|
$pageTags.empty();
|
||||||
|
$.each(val.tags, function(index, val) {
|
||||||
|
if(val !== 0) {
|
||||||
|
var _arr = _select ? $.inArray($(this)[1], _select.tags[1]) : '';
|
||||||
|
$pageTags.append('<label class="checkbox"><input type="checkbox" name="page[tag][]" value="'+ $(this)[1] + '">'+ $(this)[0] +'</label>');
|
||||||
|
if(_select && !_select.tags[0] && _arr !== -1) {
|
||||||
|
$pageTags.find('input[type="checkbox"]').eq(index).prop('checked', true);
|
||||||
|
}
|
||||||
|
_select && _val == _select.main && _select.tags[0] ? $pageTags.siblings('.checkbox').children('.select_all').prop('checked', true) : '';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$pageTagsGroup.show();
|
||||||
|
} else {
|
||||||
|
$pageTagsGroup.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$pageCategory.empty();
|
||||||
|
$pageCategoryGroup.hide();
|
||||||
|
$pageTags.empty();
|
||||||
|
$pageTagsGroup.hide();
|
||||||
|
$pageF2E.empty();
|
||||||
|
$pageCount.empty();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
getView($pageModule.val());
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
$('#module_widget').on('change', '.checkbox-groups input', function(event) {
|
||||||
|
var $checked = $(this);
|
||||||
|
if($checked.attr('type') == 'checkbox') {
|
||||||
|
if($checked.hasClass('select_all')) {
|
||||||
|
if($checked.prop('checked')){
|
||||||
|
$checked.closest('.checkbox').siblings('.groups').find('input[type="checkbox"]').prop('checked', true);
|
||||||
|
$checked.closest('.checkbox').siblings('.groups').find("input[type=hidden]").removeAttr('name');
|
||||||
|
}else{
|
||||||
|
$checked.closest('.checkbox').siblings('.groups').find('input[type="checkbox"]').prop('checked', false);
|
||||||
|
$checked.closest('.checkbox').siblings('.groups').find("input[type=hidden]").attr('name', 'page_part['+$checked.closest('.checkbox-groups').data('for')+'][]');
|
||||||
|
}
|
||||||
|
} else if($checked.hasClass('lang-enable')) {
|
||||||
|
if($checked.prop('checked')) {
|
||||||
|
$checked.closest('.active-link').addClass('active').siblings('active-link').removeClass('active').end().find('.active-mune').slideDown(300);
|
||||||
|
if(_status) {
|
||||||
|
var _index = $checked.closest('.link-options').find('.active').index() - 1,
|
||||||
|
_index = _type == 'page' ? _selectData.module.link[_index][1] : _linkData.link[_index][1] ;
|
||||||
|
$checked.closest('.active-link').find('.active-mune input').eq(_index).prop('checked', true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$('.active-link').removeClass('active');
|
||||||
|
$checked.closest('.active-link').find('.active-mune').slideUp(300, function() {
|
||||||
|
$(this).find('input:eq(0)').prop('checked', true);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
var checkboxes_size = $checked.closest('.groups').find("input[type=checkbox]").length,
|
||||||
|
checked_size = $checked.closest('.groups').find("input:checked").length;
|
||||||
|
if(checkboxes_size == checked_size)
|
||||||
|
$checked.closest('.groups').siblings('.checkbox').find('.select_all').prop('checked', true);
|
||||||
|
else
|
||||||
|
$checked.closest('.groups').siblings('.checkbox').find('.select_all').prop('checked', false);
|
||||||
|
|
||||||
|
if(checked_size == 0)
|
||||||
|
$checked.closest('.groups').find("input[type=hidden]").attr('name', 'page['+$checked.closest('.checkbox-groups').data('for')+'][]');
|
||||||
|
else
|
||||||
|
$checked.closest('.groups').find("input[type=hidden]").removeAttr('name');
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} else if($checked.attr('type') == 'radio' && !$(this).closest('div').hasClass('active-mune')) {
|
||||||
|
$('#module_widget #page_is_published_true').prop('checked') || $('#module_widget #link_is_published_true').prop('checked') ? $('.link-options').slideDown(300) : $('.link-options').slideUp(300);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
|
getPageData();
|
||||||
|
});
|
|
@ -0,0 +1,35 @@
|
||||||
|
function append_id(){
|
||||||
|
if ($("#object_id").length == 1) {
|
||||||
|
return "&id="+$("#object_id").val();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return '';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).on('change', 'select', function(e) {
|
||||||
|
if(!e.target.className == 'widget_field_select') {
|
||||||
|
switch(e.target.id) {
|
||||||
|
case 'page_module_app_id':
|
||||||
|
$.getScript($(this).attr('rel') + '?module_app_id='+$(this).val() + append_id());
|
||||||
|
break;
|
||||||
|
case 'page_app_frontend_url':
|
||||||
|
case 'page_part_widget_path':
|
||||||
|
$.getScript($(this).attr('rel') +'?frontend=' + $(this).val() + '&module_app_id=' + $("#module_app_list select").val() + append_id() );
|
||||||
|
break;
|
||||||
|
case 'page_design':
|
||||||
|
$.getScript($(this).attr('rel') + '?design_id=' + $(this).val() + append_id());
|
||||||
|
break;
|
||||||
|
case 'page_part_public_r_tag':
|
||||||
|
$.getScript($(this).attr('rel') + '?type=' + $(this).val() + append_id());
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
$.getScript($(this).attr('rel') + '?widget_field_value='+ $(this).val()+'&dom_id=' + $(this).attr("id") + '&field_seri=' +$(this).attr('field_seri')+ '&module_app_id=' +$("#page_module_app_id,page_part_module_app_id").val() + append_id() );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '.part_kind', function(event) {
|
||||||
|
$('.part_kind_partial').hide();
|
||||||
|
$('#part_' + $(this).attr('value')).show();
|
||||||
|
});
|
|
@ -0,0 +1,21 @@
|
||||||
|
function update_cates_and_tags()
|
||||||
|
{
|
||||||
|
$('.select_option,.select_all').removeAttr('disabled');
|
||||||
|
$(".select_all:checked").each(function( obj ) {
|
||||||
|
// $(this).parent().siblings('label').find('.select_option').attr('disabled',"disabled");
|
||||||
|
$(this).parent().siblings('label').find('.select_option').removeAttr('checked');
|
||||||
|
});
|
||||||
|
$(".select_option:checked").each(function( obj ) {
|
||||||
|
// $(this).parent().siblings('label').find('.select_all').attr('disabled',"disabled");
|
||||||
|
$(this).parent().siblings('label').find('.select_all').removeAttr('checked');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function rebind(){
|
||||||
|
$("#widget_data_source_category,#widget_data_source_tag,#app_page_category,#app_page_tag").find('input').change(function(){update_cates_and_tags()});
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
update_cates_and_tags();
|
||||||
|
rebind();
|
||||||
|
});
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,84 @@
|
||||||
|
/**
|
||||||
|
* fastLiveFilter jQuery plugin 1.0.3
|
||||||
|
*
|
||||||
|
* Copyright (c) 2011, Anthony Bush
|
||||||
|
* License: <http://www.opensource.org/licenses/bsd-license.php>
|
||||||
|
* Project Website: http://anthonybush.com/projects/jquery_fast_live_filter/
|
||||||
|
**/
|
||||||
|
!function ($) {
|
||||||
|
$.fn.fastLiveFilter = function(list, item, tar, options) {
|
||||||
|
// Options: input, list, timeout, callback
|
||||||
|
options = options || {};
|
||||||
|
list = $(list);
|
||||||
|
var input = this;
|
||||||
|
var target = $(tar);
|
||||||
|
var timeout = options.timeout || 0;
|
||||||
|
var callback = options.callback || function() {};
|
||||||
|
|
||||||
|
var keyTimeout;
|
||||||
|
|
||||||
|
// NOTE: because we cache lis & len here, users would need to re-init the plugin
|
||||||
|
// if they modify the list in the DOM later. This doesn't give us that much speed
|
||||||
|
// boost, so perhaps it's not worth putting it here.
|
||||||
|
var lis = list.find(item);
|
||||||
|
var len = lis.length;
|
||||||
|
var oldDisplay = len > 0 ? lis[0].style.display : "block";
|
||||||
|
callback(len); // do a one-time callback on initialization to make sure everything's in sync
|
||||||
|
|
||||||
|
input.change(function() {
|
||||||
|
// var startTime = new Date().getTime();
|
||||||
|
var filter = input.val().toLowerCase();
|
||||||
|
var li;
|
||||||
|
var numShown = 0;
|
||||||
|
for (var i = 0; i < len; i++) {
|
||||||
|
li = lis.eq(i);
|
||||||
|
if ((li.find(target).text()).toLowerCase().indexOf(filter) >= 0) {
|
||||||
|
if (li.hasClass("mark")) {
|
||||||
|
li.removeClass('mark');
|
||||||
|
|
||||||
|
// for Orbit
|
||||||
|
// var showTags = lis.not('.mark').find('input[type="checkbox"]:checked').length;
|
||||||
|
// if(lis.showTags) {
|
||||||
|
// $('#deselect, #deleteTags').removeClass('hide')
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
numShown++;
|
||||||
|
} else {
|
||||||
|
if (!li.hasClass("mark")) {
|
||||||
|
li.addClass('mark');
|
||||||
|
|
||||||
|
// for Orbit
|
||||||
|
// var showTags = lis.not('.mark').find('input[type="checkbox"]:checked').length;
|
||||||
|
// if(showTags == 0) {
|
||||||
|
// $('#deselect, #deleteTags').addClass('hide')
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// li.children('.card').removeClass('active').children('input').attr('checked', false);
|
||||||
|
// if($('.tags input[type="checkbox"]:checked').length == 0) {
|
||||||
|
// $('#deselect, #deleteTags, #addDefault').addClass('hide')
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
callback(numShown);
|
||||||
|
// var endTime = new Date().getTime();
|
||||||
|
// console.log('Search for ' + filter + ' took: ' + (endTime - startTime) + ' (' + numShown + ' results)');
|
||||||
|
return false;
|
||||||
|
}).keydown(function(e) {
|
||||||
|
// TODO: one point of improvement could be in here: currently the change event is
|
||||||
|
// invoked even if a change does not occur (e.g. by pressing a modifier key or
|
||||||
|
// something)
|
||||||
|
clearTimeout(keyTimeout);
|
||||||
|
keyTimeout = setTimeout(function() { input.change(); }, timeout);
|
||||||
|
if(e.which == '13') {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
// } else if(e.which == '8') {
|
||||||
|
// clearTimeout(keyTimeout);
|
||||||
|
// keyTimeout = setTimeout(function() { input.change(); }, timeout);
|
||||||
|
// }
|
||||||
|
});
|
||||||
|
return this; // maintain jQuery chainability
|
||||||
|
}
|
||||||
|
}(window.jQuery);
|
|
@ -0,0 +1,980 @@
|
||||||
|
/*!
|
||||||
|
* jQuery Form Plugin
|
||||||
|
* version: 2.94 (13-DEC-2011)
|
||||||
|
* @requires jQuery v1.3.2 or later
|
||||||
|
*
|
||||||
|
* Examples and documentation at: http://malsup.com/jquery/form/
|
||||||
|
* Dual licensed under the MIT and GPL licenses:
|
||||||
|
* http://www.opensource.org/licenses/mit-license.php
|
||||||
|
* http://www.gnu.org/licenses/gpl.html
|
||||||
|
*/
|
||||||
|
;(function($) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
Usage Note:
|
||||||
|
-----------
|
||||||
|
Do not use both ajaxSubmit and ajaxForm on the same form. These
|
||||||
|
functions are intended to be exclusive. Use ajaxSubmit if you want
|
||||||
|
to bind your own submit handler to the form. For example,
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#myForm').bind('submit', function(e) {
|
||||||
|
e.preventDefault(); // <-- important
|
||||||
|
$(this).ajaxSubmit({
|
||||||
|
target: '#output'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
Use ajaxForm when you want the plugin to manage all the event binding
|
||||||
|
for you. For example,
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#myForm').ajaxForm({
|
||||||
|
target: '#output'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
When using ajaxForm, the ajaxSubmit function will be invoked for you
|
||||||
|
at the appropriate time.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ajaxSubmit() provides a mechanism for immediately submitting
|
||||||
|
* an HTML form using AJAX.
|
||||||
|
*/
|
||||||
|
$.fn.ajaxSubmit = function(options) {
|
||||||
|
// fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
|
||||||
|
if (!this.length) {
|
||||||
|
log('ajaxSubmit: skipping submit process - no element selected');
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
var method, action, url, $form = this;
|
||||||
|
|
||||||
|
if (typeof options == 'function') {
|
||||||
|
options = { success: options };
|
||||||
|
}
|
||||||
|
|
||||||
|
method = this.attr('method');
|
||||||
|
action = this.attr('action');
|
||||||
|
url = (typeof action === 'string') ? $.trim(action) : '';
|
||||||
|
url = url || window.location.href || '';
|
||||||
|
if (url) {
|
||||||
|
// clean url (don't include hash vaue)
|
||||||
|
url = (url.match(/^([^#]+)/)||[])[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
options = $.extend(true, {
|
||||||
|
url: url,
|
||||||
|
success: $.ajaxSettings.success,
|
||||||
|
type: method || 'GET',
|
||||||
|
iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
|
||||||
|
}, options);
|
||||||
|
|
||||||
|
// hook for manipulating the form data before it is extracted;
|
||||||
|
// convenient for use with rich editors like tinyMCE or FCKEditor
|
||||||
|
var veto = {};
|
||||||
|
this.trigger('form-pre-serialize', [this, options, veto]);
|
||||||
|
if (veto.veto) {
|
||||||
|
log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// provide opportunity to alter form data before it is serialized
|
||||||
|
if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
|
||||||
|
log('ajaxSubmit: submit aborted via beforeSerialize callback');
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
var traditional = options.traditional;
|
||||||
|
if ( traditional === undefined ) {
|
||||||
|
traditional = $.ajaxSettings.traditional;
|
||||||
|
}
|
||||||
|
|
||||||
|
var qx,n,v,a = this.formToArray(options.semantic);
|
||||||
|
if (options.data) {
|
||||||
|
options.extraData = options.data;
|
||||||
|
qx = $.param(options.data, traditional);
|
||||||
|
}
|
||||||
|
|
||||||
|
// give pre-submit callback an opportunity to abort the submit
|
||||||
|
if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
|
||||||
|
log('ajaxSubmit: submit aborted via beforeSubmit callback');
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// fire vetoable 'validate' event
|
||||||
|
this.trigger('form-submit-validate', [a, this, options, veto]);
|
||||||
|
if (veto.veto) {
|
||||||
|
log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
var q = $.param(a, traditional);
|
||||||
|
if (qx) {
|
||||||
|
q = ( q ? (q + '&' + qx) : qx );
|
||||||
|
}
|
||||||
|
if (options.type.toUpperCase() == 'GET') {
|
||||||
|
options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
|
||||||
|
options.data = null; // data is null for 'get'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
options.data = q; // data is the query string for 'post'
|
||||||
|
}
|
||||||
|
|
||||||
|
var callbacks = [];
|
||||||
|
if (options.resetForm) {
|
||||||
|
callbacks.push(function() { $form.resetForm(); });
|
||||||
|
}
|
||||||
|
if (options.clearForm) {
|
||||||
|
callbacks.push(function() { $form.clearForm(options.includeHidden); });
|
||||||
|
}
|
||||||
|
|
||||||
|
// perform a load on the target only if dataType is not provided
|
||||||
|
if (!options.dataType && options.target) {
|
||||||
|
var oldSuccess = options.success || function(){};
|
||||||
|
callbacks.push(function(data) {
|
||||||
|
var fn = options.replaceTarget ? 'replaceWith' : 'html';
|
||||||
|
$(options.target)[fn](data).each(oldSuccess, arguments);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (options.success) {
|
||||||
|
callbacks.push(options.success);
|
||||||
|
}
|
||||||
|
|
||||||
|
options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
|
||||||
|
var context = options.context || options; // jQuery 1.4+ supports scope context
|
||||||
|
for (var i=0, max=callbacks.length; i < max; i++) {
|
||||||
|
callbacks[i].apply(context, [data, status, xhr || $form, $form]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// are there files to upload?
|
||||||
|
var fileInputs = $('input:file:enabled[value]', this); // [value] (issue #113)
|
||||||
|
var hasFileInputs = fileInputs.length > 0;
|
||||||
|
var mp = 'multipart/form-data';
|
||||||
|
var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
|
||||||
|
|
||||||
|
var fileAPI = !!(hasFileInputs && fileInputs.get(0).files && window.FormData);
|
||||||
|
log("fileAPI :" + fileAPI);
|
||||||
|
var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI;
|
||||||
|
|
||||||
|
// options.iframe allows user to force iframe mode
|
||||||
|
// 06-NOV-09: now defaulting to iframe mode if file input is detected
|
||||||
|
if (options.iframe !== false && (options.iframe || shouldUseFrame)) {
|
||||||
|
// hack to fix Safari hang (thanks to Tim Molendijk for this)
|
||||||
|
// see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
|
||||||
|
if (options.closeKeepAlive) {
|
||||||
|
$.get(options.closeKeepAlive, function() {
|
||||||
|
fileUploadIframe(a);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fileUploadIframe(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ((hasFileInputs || multipart) && fileAPI) {
|
||||||
|
options.progress = options.progress || $.noop;
|
||||||
|
fileUploadXhr(a);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$.ajax(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
// fire 'notify' event
|
||||||
|
this.trigger('form-submit-notify', [this, options]);
|
||||||
|
return this;
|
||||||
|
|
||||||
|
// XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz)
|
||||||
|
function fileUploadXhr(a) {
|
||||||
|
var formdata = new FormData();
|
||||||
|
|
||||||
|
for (var i=0; i < a.length; i++) {
|
||||||
|
if (a[i].type == 'file')
|
||||||
|
continue;
|
||||||
|
formdata.append(a[i].name, a[i].value);
|
||||||
|
}
|
||||||
|
|
||||||
|
$form.find('input:file:enabled').each(function(){
|
||||||
|
var name = $(this).attr('name'), files = this.files;
|
||||||
|
if (name) {
|
||||||
|
for (var i=0; i < files.length; i++)
|
||||||
|
formdata.append(name, files[i]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (options.extraData) {
|
||||||
|
for (var k in options.extraData)
|
||||||
|
formdata.append(k, options.extraData[k])
|
||||||
|
}
|
||||||
|
|
||||||
|
options.data = null;
|
||||||
|
|
||||||
|
var s = $.extend(true, {}, $.ajaxSettings, options, {
|
||||||
|
contentType: false,
|
||||||
|
processData: false,
|
||||||
|
cache: false,
|
||||||
|
type: 'POST'
|
||||||
|
});
|
||||||
|
|
||||||
|
s.context = s.context || s;
|
||||||
|
|
||||||
|
s.data = null;
|
||||||
|
var beforeSend = s.beforeSend;
|
||||||
|
s.beforeSend = function(xhr, o) {
|
||||||
|
o.data = formdata;
|
||||||
|
if(xhr.upload) { // unfortunately, jQuery doesn't expose this prop (http://bugs.jquery.com/ticket/10190)
|
||||||
|
xhr.upload.onprogress = function(event) {
|
||||||
|
o.progress(event.position, event.total);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if(beforeSend)
|
||||||
|
beforeSend.call(o, xhr, options);
|
||||||
|
};
|
||||||
|
$.ajax(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
// private function for handling file uploads (hat tip to YAHOO!)
|
||||||
|
function fileUploadIframe(a) {
|
||||||
|
var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle;
|
||||||
|
var useProp = !!$.fn.prop;
|
||||||
|
|
||||||
|
if (a) {
|
||||||
|
if ( useProp ) {
|
||||||
|
// ensure that every serialized input is still enabled
|
||||||
|
for (i=0; i < a.length; i++) {
|
||||||
|
el = $(form[a[i].name]);
|
||||||
|
el.prop('disabled', false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (i=0; i < a.length; i++) {
|
||||||
|
el = $(form[a[i].name]);
|
||||||
|
el.removeAttr('disabled');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($(':input[name=submit],:input[id=submit]', form).length) {
|
||||||
|
// if there is an input with a name or id of 'submit' then we won't be
|
||||||
|
// able to invoke the submit fn on the form (at least not x-browser)
|
||||||
|
alert('Error: Form elements must not have name or id of "submit".');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
s = $.extend(true, {}, $.ajaxSettings, options);
|
||||||
|
s.context = s.context || s;
|
||||||
|
id = 'jqFormIO' + (new Date().getTime());
|
||||||
|
if (s.iframeTarget) {
|
||||||
|
$io = $(s.iframeTarget);
|
||||||
|
n = $io.attr('name');
|
||||||
|
if (n == null)
|
||||||
|
$io.attr('name', id);
|
||||||
|
else
|
||||||
|
id = n;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$io = $('<iframe name="' + id + '" src="'+ s.iframeSrc +'" />');
|
||||||
|
$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
|
||||||
|
}
|
||||||
|
io = $io[0];
|
||||||
|
|
||||||
|
|
||||||
|
xhr = { // mock object
|
||||||
|
aborted: 0,
|
||||||
|
responseText: null,
|
||||||
|
responseXML: null,
|
||||||
|
status: 0,
|
||||||
|
statusText: 'n/a',
|
||||||
|
getAllResponseHeaders: function() {},
|
||||||
|
getResponseHeader: function() {},
|
||||||
|
setRequestHeader: function() {},
|
||||||
|
abort: function(status) {
|
||||||
|
var e = (status === 'timeout' ? 'timeout' : 'aborted');
|
||||||
|
log('aborting upload... ' + e);
|
||||||
|
this.aborted = 1;
|
||||||
|
$io.attr('src', s.iframeSrc); // abort op in progress
|
||||||
|
xhr.error = e;
|
||||||
|
s.error && s.error.call(s.context, xhr, e, status);
|
||||||
|
g && $.event.trigger("ajaxError", [xhr, s, e]);
|
||||||
|
s.complete && s.complete.call(s.context, xhr, e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
g = s.global;
|
||||||
|
// trigger ajax global events so that activity/block indicators work like normal
|
||||||
|
if (g && ! $.active++) {
|
||||||
|
$.event.trigger("ajaxStart");
|
||||||
|
}
|
||||||
|
if (g) {
|
||||||
|
$.event.trigger("ajaxSend", [xhr, s]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
|
||||||
|
if (s.global) {
|
||||||
|
$.active--;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (xhr.aborted) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add submitting element to data if we know it
|
||||||
|
sub = form.clk;
|
||||||
|
if (sub) {
|
||||||
|
n = sub.name;
|
||||||
|
if (n && !sub.disabled) {
|
||||||
|
s.extraData = s.extraData || {};
|
||||||
|
s.extraData[n] = sub.value;
|
||||||
|
if (sub.type == "image") {
|
||||||
|
s.extraData[n+'.x'] = form.clk_x;
|
||||||
|
s.extraData[n+'.y'] = form.clk_y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var CLIENT_TIMEOUT_ABORT = 1;
|
||||||
|
var SERVER_ABORT = 2;
|
||||||
|
|
||||||
|
function getDoc(frame) {
|
||||||
|
var doc = frame.contentWindow ? frame.contentWindow.document : frame.contentDocument ? frame.contentDocument : frame.document;
|
||||||
|
return doc;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rails CSRF hack (thanks to Yvan Barthelemy)
|
||||||
|
var csrf_token = $('meta[name=csrf-token]').attr('content');
|
||||||
|
var csrf_param = $('meta[name=csrf-param]').attr('content');
|
||||||
|
if (csrf_param && csrf_token) {
|
||||||
|
s.extraData = s.extraData || {};
|
||||||
|
s.extraData[csrf_param] = csrf_token;
|
||||||
|
}
|
||||||
|
|
||||||
|
// take a breath so that pending repaints get some cpu time before the upload starts
|
||||||
|
function doSubmit() {
|
||||||
|
// make sure form attrs are set
|
||||||
|
var t = $form.attr('target'), a = $form.attr('action');
|
||||||
|
|
||||||
|
// update form attrs in IE friendly way
|
||||||
|
form.setAttribute('target',id);
|
||||||
|
if (!method) {
|
||||||
|
form.setAttribute('method', 'POST');
|
||||||
|
}
|
||||||
|
if (a != s.url) {
|
||||||
|
form.setAttribute('action', s.url);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ie borks in some cases when setting encoding
|
||||||
|
if (! s.skipEncodingOverride && (!method || /post/i.test(method))) {
|
||||||
|
$form.attr({
|
||||||
|
encoding: 'multipart/form-data',
|
||||||
|
enctype: 'multipart/form-data'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// support timout
|
||||||
|
if (s.timeout) {
|
||||||
|
timeoutHandle = setTimeout(function() { timedOut = true; cb(CLIENT_TIMEOUT_ABORT); }, s.timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
// look for server aborts
|
||||||
|
function checkState() {
|
||||||
|
try {
|
||||||
|
var state = getDoc(io).readyState;
|
||||||
|
log('state = ' + state);
|
||||||
|
if (state.toLowerCase() == 'uninitialized')
|
||||||
|
setTimeout(checkState,50);
|
||||||
|
}
|
||||||
|
catch(e) {
|
||||||
|
log('Server abort: ' , e, ' (', e.name, ')');
|
||||||
|
cb(SERVER_ABORT);
|
||||||
|
timeoutHandle && clearTimeout(timeoutHandle);
|
||||||
|
timeoutHandle = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// add "extra" data to form if provided in options
|
||||||
|
var extraInputs = [];
|
||||||
|
try {
|
||||||
|
if (s.extraData) {
|
||||||
|
for (var n in s.extraData) {
|
||||||
|
extraInputs.push(
|
||||||
|
$('<input type="hidden" name="'+n+'">').attr('value',s.extraData[n])
|
||||||
|
.appendTo(form)[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!s.iframeTarget) {
|
||||||
|
// add iframe to doc and submit the form
|
||||||
|
$io.appendTo('body');
|
||||||
|
io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
|
||||||
|
}
|
||||||
|
setTimeout(checkState,15);
|
||||||
|
form.submit();
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
// reset attrs and remove "extra" input elements
|
||||||
|
form.setAttribute('action',a);
|
||||||
|
if(t) {
|
||||||
|
form.setAttribute('target', t);
|
||||||
|
} else {
|
||||||
|
$form.removeAttr('target');
|
||||||
|
}
|
||||||
|
$(extraInputs).remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s.forceSync) {
|
||||||
|
doSubmit();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setTimeout(doSubmit, 10); // this lets dom updates render
|
||||||
|
}
|
||||||
|
|
||||||
|
var data, doc, domCheckCount = 50, callbackProcessed;
|
||||||
|
|
||||||
|
function cb(e) {
|
||||||
|
if (xhr.aborted || callbackProcessed) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
doc = getDoc(io);
|
||||||
|
}
|
||||||
|
catch(ex) {
|
||||||
|
log('cannot access response document: ', ex);
|
||||||
|
e = SERVER_ABORT;
|
||||||
|
}
|
||||||
|
if (e === CLIENT_TIMEOUT_ABORT && xhr) {
|
||||||
|
xhr.abort('timeout');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (e == SERVER_ABORT && xhr) {
|
||||||
|
xhr.abort('server abort');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!doc || doc.location.href == s.iframeSrc) {
|
||||||
|
// response not received yet
|
||||||
|
if (!timedOut)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);
|
||||||
|
|
||||||
|
var status = 'success', errMsg;
|
||||||
|
try {
|
||||||
|
if (timedOut) {
|
||||||
|
throw 'timeout';
|
||||||
|
}
|
||||||
|
|
||||||
|
var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
|
||||||
|
log('isXml='+isXml);
|
||||||
|
if (!isXml && window.opera && (doc.body == null || doc.body.innerHTML == '')) {
|
||||||
|
if (--domCheckCount) {
|
||||||
|
// in some browsers (Opera) the iframe DOM is not always traversable when
|
||||||
|
// the onload callback fires, so we loop a bit to accommodate
|
||||||
|
log('requeing onLoad callback, DOM not available');
|
||||||
|
setTimeout(cb, 250);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// let this fall through because server response could be an empty document
|
||||||
|
//log('Could not access iframe DOM after mutiple tries.');
|
||||||
|
//throw 'DOMException: not available';
|
||||||
|
}
|
||||||
|
|
||||||
|
//log('response detected');
|
||||||
|
var docRoot = doc.body ? doc.body : doc.documentElement;
|
||||||
|
xhr.responseText = docRoot ? docRoot.innerHTML : null;
|
||||||
|
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
|
||||||
|
if (isXml)
|
||||||
|
s.dataType = 'xml';
|
||||||
|
xhr.getResponseHeader = function(header){
|
||||||
|
var headers = {'content-type': s.dataType};
|
||||||
|
return headers[header];
|
||||||
|
};
|
||||||
|
// support for XHR 'status' & 'statusText' emulation :
|
||||||
|
if (docRoot) {
|
||||||
|
xhr.status = Number( docRoot.getAttribute('status') ) || xhr.status;
|
||||||
|
xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText;
|
||||||
|
}
|
||||||
|
|
||||||
|
var dt = (s.dataType || '').toLowerCase();
|
||||||
|
var scr = /(json|script|text)/.test(dt);
|
||||||
|
if (scr || s.textarea) {
|
||||||
|
// see if user embedded response in textarea
|
||||||
|
var ta = doc.getElementsByTagName('textarea')[0];
|
||||||
|
if (ta) {
|
||||||
|
xhr.responseText = ta.value;
|
||||||
|
// support for XHR 'status' & 'statusText' emulation :
|
||||||
|
xhr.status = Number( ta.getAttribute('status') ) || xhr.status;
|
||||||
|
xhr.statusText = ta.getAttribute('statusText') || xhr.statusText;
|
||||||
|
}
|
||||||
|
else if (scr) {
|
||||||
|
// account for browsers injecting pre around json response
|
||||||
|
var pre = doc.getElementsByTagName('pre')[0];
|
||||||
|
var b = doc.getElementsByTagName('body')[0];
|
||||||
|
if (pre) {
|
||||||
|
xhr.responseText = pre.textContent ? pre.textContent : pre.innerText;
|
||||||
|
}
|
||||||
|
else if (b) {
|
||||||
|
xhr.responseText = b.textContent ? b.textContent : b.innerText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (dt == 'xml' && !xhr.responseXML && xhr.responseText != null) {
|
||||||
|
xhr.responseXML = toXml(xhr.responseText);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
data = httpData(xhr, dt, s);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
status = 'parsererror';
|
||||||
|
xhr.error = errMsg = (e || status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
log('error caught: ',e);
|
||||||
|
status = 'error';
|
||||||
|
xhr.error = errMsg = (e || status);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xhr.aborted) {
|
||||||
|
log('upload aborted');
|
||||||
|
status = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xhr.status) { // we've set xhr.status
|
||||||
|
status = (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) ? 'success' : 'error';
|
||||||
|
}
|
||||||
|
|
||||||
|
// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
|
||||||
|
if (status === 'success') {
|
||||||
|
s.success && s.success.call(s.context, data, 'success', xhr);
|
||||||
|
g && $.event.trigger("ajaxSuccess", [xhr, s]);
|
||||||
|
}
|
||||||
|
else if (status) {
|
||||||
|
if (errMsg == undefined)
|
||||||
|
errMsg = xhr.statusText;
|
||||||
|
s.error && s.error.call(s.context, xhr, status, errMsg);
|
||||||
|
g && $.event.trigger("ajaxError", [xhr, s, errMsg]);
|
||||||
|
}
|
||||||
|
|
||||||
|
g && $.event.trigger("ajaxComplete", [xhr, s]);
|
||||||
|
|
||||||
|
if (g && ! --$.active) {
|
||||||
|
$.event.trigger("ajaxStop");
|
||||||
|
}
|
||||||
|
|
||||||
|
s.complete && s.complete.call(s.context, xhr, status);
|
||||||
|
|
||||||
|
callbackProcessed = true;
|
||||||
|
if (s.timeout)
|
||||||
|
clearTimeout(timeoutHandle);
|
||||||
|
|
||||||
|
// clean up
|
||||||
|
setTimeout(function() {
|
||||||
|
if (!s.iframeTarget)
|
||||||
|
$io.remove();
|
||||||
|
xhr.responseXML = null;
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
var toXml = $.parseXML || function(s, doc) { // use parseXML if available (jQuery 1.5+)
|
||||||
|
if (window.ActiveXObject) {
|
||||||
|
doc = new ActiveXObject('Microsoft.XMLDOM');
|
||||||
|
doc.async = 'false';
|
||||||
|
doc.loadXML(s);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
doc = (new DOMParser()).parseFromString(s, 'text/xml');
|
||||||
|
}
|
||||||
|
return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null;
|
||||||
|
};
|
||||||
|
var parseJSON = $.parseJSON || function(s) {
|
||||||
|
return window['eval']('(' + s + ')');
|
||||||
|
};
|
||||||
|
|
||||||
|
var httpData = function( xhr, type, s ) { // mostly lifted from jq1.4.4
|
||||||
|
|
||||||
|
var ct = xhr.getResponseHeader('content-type') || '',
|
||||||
|
xml = type === 'xml' || !type && ct.indexOf('xml') >= 0,
|
||||||
|
data = xml ? xhr.responseXML : xhr.responseText;
|
||||||
|
|
||||||
|
if (xml && data.documentElement.nodeName === 'parsererror') {
|
||||||
|
$.error && $.error('parsererror');
|
||||||
|
}
|
||||||
|
if (s && s.dataFilter) {
|
||||||
|
data = s.dataFilter(data, type);
|
||||||
|
}
|
||||||
|
if (typeof data === 'string') {
|
||||||
|
if (type === 'json' || !type && ct.indexOf('json') >= 0) {
|
||||||
|
data = parseJSON(data);
|
||||||
|
} else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
|
||||||
|
$.globalEval(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ajaxForm() provides a mechanism for fully automating form submission.
|
||||||
|
*
|
||||||
|
* The advantages of using this method instead of ajaxSubmit() are:
|
||||||
|
*
|
||||||
|
* 1: This method will include coordinates for <input type="image" /> elements (if the element
|
||||||
|
* is used to submit the form).
|
||||||
|
* 2. This method will include the submit element's name/value data (for the element that was
|
||||||
|
* used to submit the form).
|
||||||
|
* 3. This method binds the submit() method to the form for you.
|
||||||
|
*
|
||||||
|
* The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
|
||||||
|
* passes the options argument along after properly binding events for submit elements and
|
||||||
|
* the form itself.
|
||||||
|
*/
|
||||||
|
$.fn.ajaxForm = function(options) {
|
||||||
|
// in jQuery 1.3+ we can fix mistakes with the ready state
|
||||||
|
if (this.length === 0) {
|
||||||
|
var o = { s: this.selector, c: this.context };
|
||||||
|
if (!$.isReady && o.s) {
|
||||||
|
log('DOM not ready, queuing ajaxForm');
|
||||||
|
$(function() {
|
||||||
|
$(o.s,o.c).ajaxForm(options);
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
// is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
|
||||||
|
log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.ajaxFormUnbind().bind('submit.form-plugin', function(e) {
|
||||||
|
if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
|
||||||
|
e.preventDefault();
|
||||||
|
$(this).ajaxSubmit(options);
|
||||||
|
}
|
||||||
|
}).bind('click.form-plugin', function(e) {
|
||||||
|
var target = e.target;
|
||||||
|
var $el = $(target);
|
||||||
|
if (!($el.is(":submit,input:image"))) {
|
||||||
|
// is this a child element of the submit el? (ex: a span within a button)
|
||||||
|
var t = $el.closest(':submit');
|
||||||
|
if (t.length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
target = t[0];
|
||||||
|
}
|
||||||
|
var form = this;
|
||||||
|
form.clk = target;
|
||||||
|
if (target.type == 'image') {
|
||||||
|
if (e.offsetX != undefined) {
|
||||||
|
form.clk_x = e.offsetX;
|
||||||
|
form.clk_y = e.offsetY;
|
||||||
|
} else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
|
||||||
|
var offset = $el.offset();
|
||||||
|
form.clk_x = e.pageX - offset.left;
|
||||||
|
form.clk_y = e.pageY - offset.top;
|
||||||
|
} else {
|
||||||
|
form.clk_x = e.pageX - target.offsetLeft;
|
||||||
|
form.clk_y = e.pageY - target.offsetTop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// clear form vars
|
||||||
|
setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
|
||||||
|
$.fn.ajaxFormUnbind = function() {
|
||||||
|
return this.unbind('submit.form-plugin click.form-plugin');
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* formToArray() gathers form element data into an array of objects that can
|
||||||
|
* be passed to any of the following ajax functions: $.get, $.post, or load.
|
||||||
|
* Each object in the array has both a 'name' and 'value' property. An example of
|
||||||
|
* an array for a simple login form might be:
|
||||||
|
*
|
||||||
|
* [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
|
||||||
|
*
|
||||||
|
* It is this array that is passed to pre-submit callback functions provided to the
|
||||||
|
* ajaxSubmit() and ajaxForm() methods.
|
||||||
|
*/
|
||||||
|
$.fn.formToArray = function(semantic) {
|
||||||
|
var a = [];
|
||||||
|
if (this.length === 0) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
var form = this[0];
|
||||||
|
var els = semantic ? form.getElementsByTagName('*') : form.elements;
|
||||||
|
if (!els) {
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
var i,j,n,v,el,max,jmax;
|
||||||
|
for(i=0, max=els.length; i < max; i++) {
|
||||||
|
el = els[i];
|
||||||
|
n = el.name;
|
||||||
|
if (!n) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (semantic && form.clk && el.type == "image") {
|
||||||
|
// handle image inputs on the fly when semantic == true
|
||||||
|
if(!el.disabled && form.clk == el) {
|
||||||
|
a.push({name: n, value: $(el).val(), type: el.type });
|
||||||
|
a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
v = $.fieldValue(el, true);
|
||||||
|
if (v && v.constructor == Array) {
|
||||||
|
for(j=0, jmax=v.length; j < jmax; j++) {
|
||||||
|
a.push({name: n, value: v[j]});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (v !== null && typeof v != 'undefined') {
|
||||||
|
a.push({name: n, value: v, type: el.type});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!semantic && form.clk) {
|
||||||
|
// input type=='image' are not found in elements array! handle it here
|
||||||
|
var $input = $(form.clk), input = $input[0];
|
||||||
|
n = input.name;
|
||||||
|
if (n && !input.disabled && input.type == 'image') {
|
||||||
|
a.push({name: n, value: $input.val()});
|
||||||
|
a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serializes form data into a 'submittable' string. This method will return a string
|
||||||
|
* in the format: name1=value1&name2=value2
|
||||||
|
*/
|
||||||
|
$.fn.formSerialize = function(semantic) {
|
||||||
|
//hand off to jQuery.param for proper encoding
|
||||||
|
return $.param(this.formToArray(semantic));
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serializes all field elements in the jQuery object into a query string.
|
||||||
|
* This method will return a string in the format: name1=value1&name2=value2
|
||||||
|
*/
|
||||||
|
$.fn.fieldSerialize = function(successful) {
|
||||||
|
var a = [];
|
||||||
|
this.each(function() {
|
||||||
|
var n = this.name;
|
||||||
|
if (!n) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var v = $.fieldValue(this, successful);
|
||||||
|
if (v && v.constructor == Array) {
|
||||||
|
for (var i=0,max=v.length; i < max; i++) {
|
||||||
|
a.push({name: n, value: v[i]});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (v !== null && typeof v != 'undefined') {
|
||||||
|
a.push({name: this.name, value: v});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//hand off to jQuery.param for proper encoding
|
||||||
|
return $.param(a);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value(s) of the element in the matched set. For example, consider the following form:
|
||||||
|
*
|
||||||
|
* <form><fieldset>
|
||||||
|
* <input name="A" type="text" />
|
||||||
|
* <input name="A" type="text" />
|
||||||
|
* <input name="B" type="checkbox" value="B1" />
|
||||||
|
* <input name="B" type="checkbox" value="B2"/>
|
||||||
|
* <input name="C" type="radio" value="C1" />
|
||||||
|
* <input name="C" type="radio" value="C2" />
|
||||||
|
* </fieldset></form>
|
||||||
|
*
|
||||||
|
* var v = $(':text').fieldValue();
|
||||||
|
* // if no values are entered into the text inputs
|
||||||
|
* v == ['','']
|
||||||
|
* // if values entered into the text inputs are 'foo' and 'bar'
|
||||||
|
* v == ['foo','bar']
|
||||||
|
*
|
||||||
|
* var v = $(':checkbox').fieldValue();
|
||||||
|
* // if neither checkbox is checked
|
||||||
|
* v === undefined
|
||||||
|
* // if both checkboxes are checked
|
||||||
|
* v == ['B1', 'B2']
|
||||||
|
*
|
||||||
|
* var v = $(':radio').fieldValue();
|
||||||
|
* // if neither radio is checked
|
||||||
|
* v === undefined
|
||||||
|
* // if first radio is checked
|
||||||
|
* v == ['C1']
|
||||||
|
*
|
||||||
|
* The successful argument controls whether or not the field element must be 'successful'
|
||||||
|
* (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
|
||||||
|
* The default value of the successful argument is true. If this value is false the value(s)
|
||||||
|
* for each element is returned.
|
||||||
|
*
|
||||||
|
* Note: This method *always* returns an array. If no valid value can be determined the
|
||||||
|
* array will be empty, otherwise it will contain one or more values.
|
||||||
|
*/
|
||||||
|
$.fn.fieldValue = function(successful) {
|
||||||
|
for (var val=[], i=0, max=this.length; i < max; i++) {
|
||||||
|
var el = this[i];
|
||||||
|
var v = $.fieldValue(el, successful);
|
||||||
|
if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
v.constructor == Array ? $.merge(val, v) : val.push(v);
|
||||||
|
}
|
||||||
|
return val;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the field element.
|
||||||
|
*/
|
||||||
|
$.fieldValue = function(el, successful) {
|
||||||
|
var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
|
||||||
|
if (successful === undefined) {
|
||||||
|
successful = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
|
||||||
|
(t == 'checkbox' || t == 'radio') && !el.checked ||
|
||||||
|
(t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
|
||||||
|
tag == 'select' && el.selectedIndex == -1)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tag == 'select') {
|
||||||
|
var index = el.selectedIndex;
|
||||||
|
if (index < 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
var a = [], ops = el.options;
|
||||||
|
var one = (t == 'select-one');
|
||||||
|
var max = (one ? index+1 : ops.length);
|
||||||
|
for(var i=(one ? index : 0); i < max; i++) {
|
||||||
|
var op = ops[i];
|
||||||
|
if (op.selected) {
|
||||||
|
var v = op.value;
|
||||||
|
if (!v) { // extra pain for IE...
|
||||||
|
v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
|
||||||
|
}
|
||||||
|
if (one) {
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
a.push(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
return $(el).val();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the form data. Takes the following actions on the form's input fields:
|
||||||
|
* - input text fields will have their 'value' property set to the empty string
|
||||||
|
* - select elements will have their 'selectedIndex' property set to -1
|
||||||
|
* - checkbox and radio inputs will have their 'checked' property set to false
|
||||||
|
* - inputs of type submit, button, reset, and hidden will *not* be effected
|
||||||
|
* - button elements will *not* be effected
|
||||||
|
*/
|
||||||
|
$.fn.clearForm = function(includeHidden) {
|
||||||
|
return this.each(function() {
|
||||||
|
$('input,select,textarea', this).clearFields(includeHidden);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the selected form elements.
|
||||||
|
*/
|
||||||
|
$.fn.clearFields = $.fn.clearInputs = function(includeHidden) {
|
||||||
|
var re = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i; // 'hidden' is not in this list
|
||||||
|
return this.each(function() {
|
||||||
|
var t = this.type, tag = this.tagName.toLowerCase();
|
||||||
|
if (re.test(t) || tag == 'textarea' || (includeHidden && /hidden/.test(t)) ) {
|
||||||
|
this.value = '';
|
||||||
|
}
|
||||||
|
else if (t == 'checkbox' || t == 'radio') {
|
||||||
|
this.checked = false;
|
||||||
|
}
|
||||||
|
else if (tag == 'select') {
|
||||||
|
this.selectedIndex = -1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the form data. Causes all form elements to be reset to their original value.
|
||||||
|
*/
|
||||||
|
$.fn.resetForm = function() {
|
||||||
|
return this.each(function() {
|
||||||
|
// guard against an input with the name of 'reset'
|
||||||
|
// note that IE reports the reset function as an 'object'
|
||||||
|
if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
|
||||||
|
this.reset();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables or disables any matching elements.
|
||||||
|
*/
|
||||||
|
$.fn.enable = function(b) {
|
||||||
|
if (b === undefined) {
|
||||||
|
b = true;
|
||||||
|
}
|
||||||
|
return this.each(function() {
|
||||||
|
this.disabled = !b;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks/unchecks any matching checkboxes or radio buttons and
|
||||||
|
* selects/deselects and matching option elements.
|
||||||
|
*/
|
||||||
|
$.fn.selected = function(select) {
|
||||||
|
if (select === undefined) {
|
||||||
|
select = true;
|
||||||
|
}
|
||||||
|
return this.each(function() {
|
||||||
|
var t = this.type;
|
||||||
|
if (t == 'checkbox' || t == 'radio') {
|
||||||
|
this.checked = select;
|
||||||
|
}
|
||||||
|
else if (this.tagName.toLowerCase() == 'option') {
|
||||||
|
var $sel = $(this).parent('select');
|
||||||
|
if (select && $sel[0] && $sel[0].type == 'select-one') {
|
||||||
|
// deselect all other options
|
||||||
|
$sel.find('option').selected(false);
|
||||||
|
}
|
||||||
|
this.selected = select;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// expose debug var
|
||||||
|
$.fn.ajaxSubmit.debug = false;
|
||||||
|
|
||||||
|
// helper fn for console logging
|
||||||
|
function log() {
|
||||||
|
if (!$.fn.ajaxSubmit.debug)
|
||||||
|
return;
|
||||||
|
var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
|
||||||
|
if (window.console && window.console.log) {
|
||||||
|
window.console.log(msg);
|
||||||
|
}
|
||||||
|
else if (window.opera && window.opera.postError) {
|
||||||
|
window.opera.postError(msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
})(jQuery);
|
|
@ -0,0 +1,124 @@
|
||||||
|
/* ===================================================
|
||||||
|
* jquery-lite-image-resize v.1.0.1
|
||||||
|
* https://github.com/RayChang/jquery-lite-image-resize
|
||||||
|
* ===================================================
|
||||||
|
* How to use ?
|
||||||
|
*
|
||||||
|
* HTML element closest to the image to add class "resizeimg".
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* <div class="resizeimg">
|
||||||
|
* <img src="images url" />
|
||||||
|
* </div>
|
||||||
|
*
|
||||||
|
* Or you can use:
|
||||||
|
* $('your class').rsImg();
|
||||||
|
*
|
||||||
|
* Note : HTML structure must be a structure like the example above.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
!function ($) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var ResizeImg = function(element) {
|
||||||
|
this.element = $(element);
|
||||||
|
this.element.data('exists', true);
|
||||||
|
};
|
||||||
|
ResizeImg.prototype.resize = function() {
|
||||||
|
var $img = this.element.children('img').eq(0),
|
||||||
|
elW = this.element.innerWidth(),
|
||||||
|
elH = this.element.innerHeight(),
|
||||||
|
elScale = elW/elH,
|
||||||
|
image = document.createElement("img");
|
||||||
|
image.src = $img.attr('src');
|
||||||
|
this.element.css({
|
||||||
|
'position': 'relative',
|
||||||
|
'overflow': 'hidden',
|
||||||
|
});
|
||||||
|
function imageLoadComplete() {
|
||||||
|
var imgW = image.width,
|
||||||
|
imgH = image.height,
|
||||||
|
imgScale = imgW/imgH,
|
||||||
|
portrait = {
|
||||||
|
'position': 'absolute',
|
||||||
|
'height': '100%',
|
||||||
|
'width': 'auto',
|
||||||
|
'max-width': 'none',
|
||||||
|
'left': '50%',
|
||||||
|
'top': 0,
|
||||||
|
'margin-left': imgW*(elH/imgH)/-2
|
||||||
|
},
|
||||||
|
landscape = {
|
||||||
|
'position': 'absolute',
|
||||||
|
'height': 'auto',
|
||||||
|
'max-height': 'none',
|
||||||
|
'width': '100%',
|
||||||
|
'left': 0,
|
||||||
|
'top': '50%',
|
||||||
|
'margin-top': imgH*(elW/imgW)/-2
|
||||||
|
},
|
||||||
|
center = {
|
||||||
|
'position': 'absolute',
|
||||||
|
'height': '100%',
|
||||||
|
'width': '100%',
|
||||||
|
'top': 0,
|
||||||
|
'left': 0
|
||||||
|
};
|
||||||
|
if(imgScale < 1) {
|
||||||
|
if(elScale < 1) {
|
||||||
|
if(elScale > imgScale) {
|
||||||
|
$img.css(landscape);
|
||||||
|
} else {
|
||||||
|
$img.css(portrait);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
$img.css(landscape);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
if(imgScale > 1) {
|
||||||
|
if(elScale > 1) {
|
||||||
|
if(elScale > imgScale) {
|
||||||
|
$img.css(landscape);
|
||||||
|
} else {
|
||||||
|
$img.css(portrait);
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
$img.css(portrait);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
if(imgScale == 1) {
|
||||||
|
if(elScale < 1) {
|
||||||
|
$img.css(portrait);
|
||||||
|
} else if(elScale > 1) {
|
||||||
|
$img.css(landscape);
|
||||||
|
} else {
|
||||||
|
$img.css(center);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
$img.fadeTo(500, 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
if(/MSIE 8.0/g.test($ua)) {
|
||||||
|
imageLoadComplete();
|
||||||
|
} else {
|
||||||
|
image.onload = imageLoadComplete;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$.fn.rsImg = function () {
|
||||||
|
this.each(function () {
|
||||||
|
if(!$(this).data('exists')) {
|
||||||
|
$(this).children("img").fadeTo(0,0);
|
||||||
|
new ResizeImg(this).resize();
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
$('.resizeimg').rsImg();
|
||||||
|
});
|
||||||
|
}(window.jQuery);
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,451 @@
|
||||||
|
/*
|
||||||
|
* jQuery UI Nested Sortable
|
||||||
|
* v 1.3.5 / 21 jun 2012
|
||||||
|
* http://mjsarfatti.com/code/nestedSortable
|
||||||
|
*
|
||||||
|
* Depends on:
|
||||||
|
* jquery.ui.sortable.js 1.8+
|
||||||
|
*
|
||||||
|
* Copyright (c) 2010-2012 Manuele J Sarfatti
|
||||||
|
* Licensed under the MIT License
|
||||||
|
* http://www.opensource.org/licenses/mit-license.php
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function($) {
|
||||||
|
|
||||||
|
$.widget("mjs.nestedSortable", $.extend({}, $.ui.sortable.prototype, {
|
||||||
|
|
||||||
|
options: {
|
||||||
|
tabSize: 20,
|
||||||
|
disableNesting: 'mjs-nestedSortable-no-nesting',
|
||||||
|
errorClass: 'mjs-nestedSortable-error',
|
||||||
|
doNotClear: false,
|
||||||
|
listType: 'ol',
|
||||||
|
maxLevels: 0,
|
||||||
|
protectRoot: false,
|
||||||
|
rootID: null,
|
||||||
|
rtl: false,
|
||||||
|
isAllowed: function(item, parent) { return true; }
|
||||||
|
},
|
||||||
|
|
||||||
|
_create: function() {
|
||||||
|
this.element.data('sortable', this.element.data('nestedSortable'));
|
||||||
|
|
||||||
|
if (!this.element.is(this.options.listType))
|
||||||
|
throw new Error('nestedSortable: Please check the listType option is set to your actual list type');
|
||||||
|
|
||||||
|
return $.ui.sortable.prototype._create.apply(this, arguments);
|
||||||
|
},
|
||||||
|
|
||||||
|
destroy: function() {
|
||||||
|
this.element
|
||||||
|
.removeData("nestedSortable")
|
||||||
|
.unbind(".nestedSortable");
|
||||||
|
return $.ui.sortable.prototype.destroy.apply(this, arguments);
|
||||||
|
},
|
||||||
|
|
||||||
|
_mouseDrag: function(event) {
|
||||||
|
|
||||||
|
//Compute the helpers position
|
||||||
|
this.position = this._generatePosition(event);
|
||||||
|
this.positionAbs = this._convertPositionTo("absolute");
|
||||||
|
|
||||||
|
if (!this.lastPositionAbs) {
|
||||||
|
this.lastPositionAbs = this.positionAbs;
|
||||||
|
}
|
||||||
|
|
||||||
|
var o = this.options;
|
||||||
|
|
||||||
|
//Do scrolling
|
||||||
|
if(this.options.scroll) {
|
||||||
|
var scrolled = false;
|
||||||
|
if(this.scrollParent[0] != document && this.scrollParent[0].tagName != 'HTML') {
|
||||||
|
|
||||||
|
if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity)
|
||||||
|
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
|
||||||
|
else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity)
|
||||||
|
this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
|
||||||
|
|
||||||
|
if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity)
|
||||||
|
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
|
||||||
|
else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity)
|
||||||
|
this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
if(event.pageY - $(document).scrollTop() < o.scrollSensitivity)
|
||||||
|
scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
|
||||||
|
else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity)
|
||||||
|
scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
|
||||||
|
|
||||||
|
if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity)
|
||||||
|
scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
|
||||||
|
else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity)
|
||||||
|
scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour)
|
||||||
|
$.ui.ddmanager.prepareOffsets(this, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Regenerate the absolute position used for position checks
|
||||||
|
this.positionAbs = this._convertPositionTo("absolute");
|
||||||
|
|
||||||
|
// Find the top offset before rearrangement,
|
||||||
|
var previousTopOffset = this.placeholder.offset().top;
|
||||||
|
|
||||||
|
//Set the helper position
|
||||||
|
if(!this.options.axis || this.options.axis != "y") this.helper[0].style.left = this.position.left+'px';
|
||||||
|
if(!this.options.axis || this.options.axis != "x") this.helper[0].style.top = this.position.top+'px';
|
||||||
|
|
||||||
|
//Rearrange
|
||||||
|
for (var i = this.items.length - 1; i >= 0; i--) {
|
||||||
|
|
||||||
|
//Cache variables and intersection, continue if no intersection
|
||||||
|
var item = this.items[i], itemElement = item.item[0], intersection = this._intersectsWithPointer(item);
|
||||||
|
if (!intersection) continue;
|
||||||
|
|
||||||
|
if(itemElement != this.currentItem[0] //cannot intersect with itself
|
||||||
|
&& this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
|
||||||
|
&& !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
|
||||||
|
&& (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true)
|
||||||
|
//&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
|
||||||
|
) {
|
||||||
|
|
||||||
|
$(itemElement).mouseenter();
|
||||||
|
|
||||||
|
this.direction = intersection == 1 ? "down" : "up";
|
||||||
|
|
||||||
|
if (this.options.tolerance == "pointer" || this._intersectsWithSides(item)) {
|
||||||
|
$(itemElement).mouseleave();
|
||||||
|
this._rearrange(event, item);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear emtpy ul's/ol's
|
||||||
|
this._clearEmpty(itemElement);
|
||||||
|
|
||||||
|
this._trigger("change", event, this._uiHash());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var parentItem = (this.placeholder[0].parentNode.parentNode &&
|
||||||
|
$(this.placeholder[0].parentNode.parentNode).closest('.ui-sortable').length)
|
||||||
|
? $(this.placeholder[0].parentNode.parentNode)
|
||||||
|
: null,
|
||||||
|
level = this._getLevel(this.placeholder),
|
||||||
|
childLevels = this._getChildLevels(this.helper);
|
||||||
|
|
||||||
|
// To find the previous sibling in the list, keep backtracking until we hit a valid list item.
|
||||||
|
var previousItem = this.placeholder[0].previousSibling ? $(this.placeholder[0].previousSibling) : null;
|
||||||
|
if (previousItem != null) {
|
||||||
|
while (previousItem[0].nodeName.toLowerCase() != 'li' || previousItem[0] == this.currentItem[0] || previousItem[0] == this.helper[0]) {
|
||||||
|
if (previousItem[0].previousSibling) {
|
||||||
|
previousItem = $(previousItem[0].previousSibling);
|
||||||
|
} else {
|
||||||
|
previousItem = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// To find the next sibling in the list, keep stepping forward until we hit a valid list item.
|
||||||
|
var nextItem = this.placeholder[0].nextSibling ? $(this.placeholder[0].nextSibling) : null;
|
||||||
|
if (nextItem != null) {
|
||||||
|
while (nextItem[0].nodeName.toLowerCase() != 'li' || nextItem[0] == this.currentItem[0] || nextItem[0] == this.helper[0]) {
|
||||||
|
if (nextItem[0].nextSibling) {
|
||||||
|
nextItem = $(nextItem[0].nextSibling);
|
||||||
|
} else {
|
||||||
|
nextItem = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var newList = document.createElement(o.listType);
|
||||||
|
|
||||||
|
this.beyondMaxLevels = 0;
|
||||||
|
|
||||||
|
// If the item is moved to the left, send it to its parent's level unless there are siblings below it.
|
||||||
|
if (parentItem != null && nextItem == null &&
|
||||||
|
(o.rtl && (this.positionAbs.left + this.helper.outerWidth() > parentItem.offset().left + parentItem.outerWidth()) ||
|
||||||
|
!o.rtl && (this.positionAbs.left < parentItem.offset().left))) {
|
||||||
|
parentItem.after(this.placeholder[0]);
|
||||||
|
this._clearEmpty(parentItem[0]);
|
||||||
|
this._trigger("change", event, this._uiHash());
|
||||||
|
}
|
||||||
|
// If the item is below a sibling and is moved to the right, make it a child of that sibling.
|
||||||
|
else if (previousItem != null &&
|
||||||
|
(o.rtl && (this.positionAbs.left + this.helper.outerWidth() < previousItem.offset().left + previousItem.outerWidth() - o.tabSize) ||
|
||||||
|
!o.rtl && (this.positionAbs.left > previousItem.offset().left + o.tabSize))) {
|
||||||
|
this._isAllowed(previousItem, level, level+childLevels+1);
|
||||||
|
if (!previousItem.children(o.listType).length) {
|
||||||
|
previousItem[0].appendChild(newList);
|
||||||
|
}
|
||||||
|
// If this item is being moved from the top, add it to the top of the list.
|
||||||
|
if (previousTopOffset && (previousTopOffset <= previousItem.offset().top)) {
|
||||||
|
previousItem.children(o.listType).prepend(this.placeholder);
|
||||||
|
}
|
||||||
|
// Otherwise, add it to the bottom of the list.
|
||||||
|
else {
|
||||||
|
previousItem.children(o.listType)[0].appendChild(this.placeholder[0]);
|
||||||
|
}
|
||||||
|
this._trigger("change", event, this._uiHash());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this._isAllowed(parentItem, level, level+childLevels);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Post events to containers
|
||||||
|
this._contactContainers(event);
|
||||||
|
|
||||||
|
//Interconnect with droppables
|
||||||
|
if($.ui.ddmanager) $.ui.ddmanager.drag(this, event);
|
||||||
|
|
||||||
|
//Call callbacks
|
||||||
|
this._trigger('sort', event, this._uiHash());
|
||||||
|
|
||||||
|
this.lastPositionAbs = this.positionAbs;
|
||||||
|
return false;
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
_mouseStop: function(event, noPropagation) {
|
||||||
|
|
||||||
|
// If the item is in a position not allowed, send it back
|
||||||
|
if (this.beyondMaxLevels) {
|
||||||
|
|
||||||
|
this.placeholder.removeClass(this.options.errorClass);
|
||||||
|
|
||||||
|
if (this.domPosition.prev) {
|
||||||
|
$(this.domPosition.prev).after(this.placeholder);
|
||||||
|
} else {
|
||||||
|
$(this.domPosition.parent).prepend(this.placeholder);
|
||||||
|
}
|
||||||
|
|
||||||
|
this._trigger("revert", event, this._uiHash());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clean last empty ul/ol
|
||||||
|
for (var i = this.items.length - 1; i >= 0; i--) {
|
||||||
|
var item = this.items[i].item[0];
|
||||||
|
this._clearEmpty(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ui.sortable.prototype._mouseStop.apply(this, arguments);
|
||||||
|
|
||||||
|
|
||||||
|
// for Orbit ----> Check the number of pages in each page
|
||||||
|
if($('.item-groups').length) {
|
||||||
|
var $sortable = $('.sortable'),
|
||||||
|
$host = $sortable.children('.navbar').eq(0),
|
||||||
|
$navbar = $('.sortable li').children('.navbar'),
|
||||||
|
$quantity = $sortable.find('li').length;
|
||||||
|
$host.find('.badge').text($quantity);
|
||||||
|
$navbar.each(function(i) {
|
||||||
|
if($navbar.eq(i).next('ol').length>0) {
|
||||||
|
var $amount = $navbar.eq(i).next('ol').find('li').length;
|
||||||
|
$navbar.eq(i).find('.badge').text($amount);
|
||||||
|
}else{
|
||||||
|
$navbar.eq(i).find('.badge').text('0');
|
||||||
|
}
|
||||||
|
if($navbar.eq(i).next('ol').length==1 && $navbar.eq(i).next('ol').children('li').length==0){
|
||||||
|
$navbar.eq(i).next('ol').remove();
|
||||||
|
}
|
||||||
|
$navbar.eq(i).find('.badge').text()>0 ? $navbar.eq(i).find('.badge').addClass('badge-info'):$navbar.eq(i).find('.badge').removeClass('badge-info');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
//
|
||||||
|
},
|
||||||
|
|
||||||
|
serialize: function(options) {
|
||||||
|
|
||||||
|
var o = $.extend({}, this.options, options),
|
||||||
|
items = this._getItemsAsjQuery(o && o.connected),
|
||||||
|
str = [];
|
||||||
|
|
||||||
|
$(items).each(function() {
|
||||||
|
var res = ($(o.item || this).attr(o.attribute || 'id') || '')
|
||||||
|
.match(o.expression || (/(.+)[-=_](.+)/)),
|
||||||
|
pid = ($(o.item || this).parent(o.listType)
|
||||||
|
.parent(o.items)
|
||||||
|
.attr(o.attribute || 'id') || '')
|
||||||
|
.match(o.expression || (/(.+)[-=_](.+)/));
|
||||||
|
|
||||||
|
if (res) {
|
||||||
|
str.push(((o.key || res[1]) + '[' + (o.key && o.expression ? res[1] : res[2]) + ']')
|
||||||
|
+ '='
|
||||||
|
+ (pid ? (o.key && o.expression ? pid[1] : pid[2]) : o.rootID));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if(!str.length && o.key) {
|
||||||
|
str.push(o.key + '=');
|
||||||
|
}
|
||||||
|
|
||||||
|
return str.join('&');
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
toHierarchy: function(options) {
|
||||||
|
|
||||||
|
var o = $.extend({}, this.options, options),
|
||||||
|
sDepth = o.startDepthCount || 0,
|
||||||
|
ret = [];
|
||||||
|
|
||||||
|
$(this.element).children(o.items).each(function () {
|
||||||
|
var level = _recursiveItems(this);
|
||||||
|
ret.push(level);
|
||||||
|
});
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
function _recursiveItems(item) {
|
||||||
|
var id = ($(item).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
|
||||||
|
if (id) {
|
||||||
|
var currentItem = {"id" : id[2]};
|
||||||
|
if ($(item).children(o.listType).children(o.items).length > 0) {
|
||||||
|
currentItem.children = [];
|
||||||
|
$(item).children(o.listType).children(o.items).each(function() {
|
||||||
|
var level = _recursiveItems(this);
|
||||||
|
currentItem.children.push(level);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return currentItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
toArray: function(options) {
|
||||||
|
|
||||||
|
var o = $.extend({}, this.options, options),
|
||||||
|
sDepth = o.startDepthCount || 0,
|
||||||
|
ret = [],
|
||||||
|
left = 2;
|
||||||
|
|
||||||
|
ret.push({
|
||||||
|
"item_id": o.rootID,
|
||||||
|
"parent_id": 'none',
|
||||||
|
"depth": sDepth,
|
||||||
|
"left": '1',
|
||||||
|
"right": ($(o.items, this.element).length + 1) * 2
|
||||||
|
});
|
||||||
|
|
||||||
|
$(this.element).children(o.items).each(function () {
|
||||||
|
left = _recursiveArray(this, sDepth + 1, left);
|
||||||
|
});
|
||||||
|
|
||||||
|
ret = ret.sort(function(a,b){ return (a.left - b.left); });
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
function _recursiveArray(item, depth, left) {
|
||||||
|
|
||||||
|
var right = left + 1,
|
||||||
|
id,
|
||||||
|
pid;
|
||||||
|
|
||||||
|
if ($(item).children(o.listType).children(o.items).length > 0) {
|
||||||
|
depth ++;
|
||||||
|
$(item).children(o.listType).children(o.items).each(function () {
|
||||||
|
right = _recursiveArray($(this), depth, right);
|
||||||
|
});
|
||||||
|
depth --;
|
||||||
|
}
|
||||||
|
|
||||||
|
id = ($(item).attr(o.attribute || 'id')).match(o.expression || (/(.+)[-=_](.+)/));
|
||||||
|
|
||||||
|
if (depth === sDepth + 1) {
|
||||||
|
pid = o.rootID;
|
||||||
|
} else {
|
||||||
|
var parentItem = ($(item).parent(o.listType)
|
||||||
|
.parent(o.items)
|
||||||
|
.attr(o.attribute || 'id'))
|
||||||
|
.match(o.expression || (/(.+)[-=_](.+)/));
|
||||||
|
pid = parentItem[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (id) {
|
||||||
|
ret.push({"item_id": id[2], "parent_id": pid, "depth": depth, "left": left, "right": right});
|
||||||
|
}
|
||||||
|
|
||||||
|
left = right + 1;
|
||||||
|
return left;
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
_clearEmpty: function(item) {
|
||||||
|
|
||||||
|
var emptyList = $(item).children(this.options.listType);
|
||||||
|
if (emptyList.length && !emptyList.children().length && !this.options.doNotClear) {
|
||||||
|
emptyList.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
_getLevel: function(item) {
|
||||||
|
|
||||||
|
var level = 1;
|
||||||
|
|
||||||
|
if (this.options.listType) {
|
||||||
|
var list = item.closest(this.options.listType);
|
||||||
|
while (list && list.length > 0 &&
|
||||||
|
!list.is('.ui-sortable')) {
|
||||||
|
level++;
|
||||||
|
list = list.parent().closest(this.options.listType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return level;
|
||||||
|
},
|
||||||
|
|
||||||
|
_getChildLevels: function(parent, depth) {
|
||||||
|
var self = this,
|
||||||
|
o = this.options,
|
||||||
|
result = 0;
|
||||||
|
depth = depth || 0;
|
||||||
|
|
||||||
|
$(parent).children(o.listType).children(o.items).each(function (index, child) {
|
||||||
|
result = Math.max(self._getChildLevels(child, depth + 1), result);
|
||||||
|
});
|
||||||
|
|
||||||
|
return depth ? result + 1 : result;
|
||||||
|
},
|
||||||
|
|
||||||
|
_isAllowed: function(parentItem, level, levels) {
|
||||||
|
var o = this.options,
|
||||||
|
isRoot = $(this.domPosition.parent).hasClass('ui-sortable') ? true : false,
|
||||||
|
maxLevels = this.placeholder.closest('.ui-sortable').nestedSortable('option', 'maxLevels'); // this takes into account the maxLevels set to the recipient list
|
||||||
|
|
||||||
|
// Is the root protected?
|
||||||
|
// Are we trying to nest under a no-nest?
|
||||||
|
// Are we nesting too deep?
|
||||||
|
if (!o.isAllowed(this.currentItem, parentItem) ||
|
||||||
|
parentItem && parentItem.hasClass(o.disableNesting) ||
|
||||||
|
o.protectRoot && (parentItem == null && !isRoot || isRoot && level > 1)) {
|
||||||
|
this.placeholder.addClass(o.errorClass);
|
||||||
|
if (maxLevels < levels && maxLevels != 0) {
|
||||||
|
this.beyondMaxLevels = levels - maxLevels;
|
||||||
|
} else {
|
||||||
|
this.beyondMaxLevels = 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (maxLevels < levels && maxLevels != 0) {
|
||||||
|
this.placeholder.addClass(o.errorClass);
|
||||||
|
this.beyondMaxLevels = levels - maxLevels;
|
||||||
|
} else {
|
||||||
|
this.placeholder.removeClass(o.errorClass);
|
||||||
|
this.beyondMaxLevels = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}));
|
||||||
|
|
||||||
|
$.mjs.nestedSortable.prototype.options = $.extend({}, $.ui.sortable.prototype.options, $.mjs.nestedSortable.prototype.options);
|
||||||
|
})(jQuery);
|
|
@ -0,0 +1,147 @@
|
||||||
|
(function( $ ) {
|
||||||
|
$.fn.muImageResize = function( params ) {
|
||||||
|
var _defaultSettings = {
|
||||||
|
width:300,
|
||||||
|
height:300,
|
||||||
|
wrap_fix:true // Let image display like in-line.
|
||||||
|
};
|
||||||
|
var _set = $.extend(_defaultSettings, params);
|
||||||
|
// var isIE7 = $.browser.msie && (7 == ~~ $.browser.version);
|
||||||
|
|
||||||
|
//var anyDynamicSource = $(this).attr("src");
|
||||||
|
//$(this).attr("src",anyDynamicSource+ "?" + new Date().getTime());
|
||||||
|
|
||||||
|
// Just bind load event once per element.
|
||||||
|
return this.one('load', function() {
|
||||||
|
// Remove all attributes and CSS rules.
|
||||||
|
this.removeAttribute( "width" );
|
||||||
|
this.removeAttribute( "height" );
|
||||||
|
this.style.width = this.style.height = "";
|
||||||
|
|
||||||
|
var ow, oh;
|
||||||
|
|
||||||
|
//[workaround] - msie need get width early
|
||||||
|
if (/MSIE/g.test($ua))
|
||||||
|
{
|
||||||
|
// Get original size for calcutation.
|
||||||
|
ow = this.width;
|
||||||
|
oh = this.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_set.wrap_fix) {
|
||||||
|
$(this).wrap(function(){
|
||||||
|
return '<div style="width:'+_set.width+'px; height:'+_set.height+'px; display:inline-block;" />';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!/MSIE/g.test($ua))
|
||||||
|
{
|
||||||
|
// Get original size for calcutation.
|
||||||
|
ow = this.width;
|
||||||
|
oh = this.height;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if cannot get width or height.
|
||||||
|
if (0==ow || 0==oh){
|
||||||
|
$(this).width(_set.width);
|
||||||
|
$(this).height(_set.height);
|
||||||
|
}else{
|
||||||
|
|
||||||
|
// Merge position settings
|
||||||
|
var sh_margin_type='';
|
||||||
|
|
||||||
|
// if original image's width > height.
|
||||||
|
if (ow > oh) {
|
||||||
|
p = oh / _set.height;
|
||||||
|
oh = _set.height;
|
||||||
|
ow = ow / p;
|
||||||
|
|
||||||
|
// original image width smaller than settings.
|
||||||
|
if (ow < _set.width){
|
||||||
|
// need to resize again,
|
||||||
|
// because new image size range must can cover settings' range, than we can crop it correctly.
|
||||||
|
p = ow / _set.width;
|
||||||
|
ow = _set.width;
|
||||||
|
oh = oh / p;
|
||||||
|
|
||||||
|
// the crop range would be in the center of new image size.
|
||||||
|
sh = (oh-_set.height)/2;
|
||||||
|
t=sh+'px';
|
||||||
|
r=_set.width+'px';
|
||||||
|
b=(_set.height+sh)+'px';
|
||||||
|
l='0px';
|
||||||
|
|
||||||
|
// need to be adjust top position latter.
|
||||||
|
sh_margin_type = 'margin-top';
|
||||||
|
|
||||||
|
// original image width bigger than settings.
|
||||||
|
}else{
|
||||||
|
// new image range can cover settings' range.
|
||||||
|
sh = (ow-_set.width)/2;
|
||||||
|
t='0px';
|
||||||
|
r=(_set.width+sh)+'px';
|
||||||
|
b=_set.height+'px';
|
||||||
|
l=sh+'px';
|
||||||
|
// need to be adjust left position latter.
|
||||||
|
sh_margin_type = 'margin-left';
|
||||||
|
}
|
||||||
|
// ref above, change width to height then do same things.
|
||||||
|
}else{
|
||||||
|
p = ow / _set.width;
|
||||||
|
ow = _set.width;
|
||||||
|
oh = oh / p;
|
||||||
|
|
||||||
|
if (oh < _set.height) {
|
||||||
|
p = oh / _set.height;
|
||||||
|
oh = _set.height;
|
||||||
|
ow = ow / p;
|
||||||
|
|
||||||
|
sh = (ow-_set.width)/2;
|
||||||
|
t='0px';
|
||||||
|
r=(_set.width+sh)+'px';
|
||||||
|
b=_set.height+'px';
|
||||||
|
l=sh+'px';
|
||||||
|
sh_margin_type = 'margin-left';
|
||||||
|
}else{
|
||||||
|
sh = (oh-_set.height)/2;
|
||||||
|
t=sh+'px';
|
||||||
|
r=_set.width+'px';
|
||||||
|
b=(_set.height+sh)+'px';
|
||||||
|
l='0px';
|
||||||
|
sh_margin_type = 'margin-top';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resize img.
|
||||||
|
$(this).width(ow);
|
||||||
|
$(this).height(oh);
|
||||||
|
|
||||||
|
// Crop img by set clip style.
|
||||||
|
$(this).css('clip','rect('+t+' '+r+' '+b+' '+l+')');
|
||||||
|
|
||||||
|
var osh = 0;
|
||||||
|
if('auto' != $(this).css(sh_margin_type)){
|
||||||
|
osh = parseInt($(this).css(sh_margin_type));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (0 < sh) {sh*=-1;}
|
||||||
|
sh += osh;
|
||||||
|
|
||||||
|
$(this).css(sh_margin_type, sh+'px');
|
||||||
|
// $(this).css('position','absolute');
|
||||||
|
}
|
||||||
|
$(this).fadeIn('slow');
|
||||||
|
})
|
||||||
|
.one( "error", function() {
|
||||||
|
//$(this).hide();
|
||||||
|
})
|
||||||
|
.each(function() {
|
||||||
|
$(this).hide();
|
||||||
|
// Trigger load event (for Gecko and MSIE)
|
||||||
|
if ( this.complete || /MSIE/g.test($ua) ) {
|
||||||
|
$( this ).trigger( "load" ).trigger( "error" );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
})( jQuery );
|
|
@ -0,0 +1,752 @@
|
||||||
|
/*! nanoScrollerJS - v0.7.2
|
||||||
|
* http://jamesflorentino.github.com/nanoScrollerJS/
|
||||||
|
* Copyright (c) 2013 James Florentino; Licensed MIT */
|
||||||
|
|
||||||
|
|
||||||
|
(function($, window, document) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var BROWSER_IS_IE7, BROWSER_SCROLLBAR_WIDTH, DOMSCROLL, DOWN, DRAG, KEYDOWN, KEYUP, MOUSEDOWN, MOUSEMOVE, MOUSEUP, MOUSEWHEEL, NanoScroll, PANEDOWN, RESIZE, SCROLL, SCROLLBAR, TOUCHMOVE, UP, WHEEL, defaults, getBrowserScrollbarWidth;
|
||||||
|
defaults = {
|
||||||
|
/**
|
||||||
|
a classname for the pane element.
|
||||||
|
@property paneClass
|
||||||
|
@type String
|
||||||
|
@default 'pane'
|
||||||
|
*/
|
||||||
|
|
||||||
|
paneClass: 'pane',
|
||||||
|
/**
|
||||||
|
a classname for the slider element.
|
||||||
|
@property sliderClass
|
||||||
|
@type String
|
||||||
|
@default 'slider'
|
||||||
|
*/
|
||||||
|
|
||||||
|
sliderClass: 'slider',
|
||||||
|
/**
|
||||||
|
a classname for the content element.
|
||||||
|
@property contentClass
|
||||||
|
@type String
|
||||||
|
@default 'content'
|
||||||
|
*/
|
||||||
|
|
||||||
|
contentClass: 'content',
|
||||||
|
/**
|
||||||
|
a setting to enable native scrolling in iOS devices.
|
||||||
|
@property iOSNativeScrolling
|
||||||
|
@type Boolean
|
||||||
|
@default false
|
||||||
|
*/
|
||||||
|
|
||||||
|
iOSNativeScrolling: false,
|
||||||
|
/**
|
||||||
|
a setting to prevent the rest of the page being
|
||||||
|
scrolled when user scrolls the `.content` element.
|
||||||
|
@property preventPageScrolling
|
||||||
|
@type Boolean
|
||||||
|
@default false
|
||||||
|
*/
|
||||||
|
|
||||||
|
preventPageScrolling: false,
|
||||||
|
/**
|
||||||
|
a setting to disable binding to the resize event.
|
||||||
|
@property disableResize
|
||||||
|
@type Boolean
|
||||||
|
@default false
|
||||||
|
*/
|
||||||
|
|
||||||
|
disableResize: false,
|
||||||
|
/**
|
||||||
|
a setting to make the scrollbar always visible.
|
||||||
|
@property alwaysVisible
|
||||||
|
@type Boolean
|
||||||
|
@default false
|
||||||
|
*/
|
||||||
|
|
||||||
|
alwaysVisible: false,
|
||||||
|
/**
|
||||||
|
a default timeout for the `flash()` method.
|
||||||
|
@property flashDelay
|
||||||
|
@type Number
|
||||||
|
@default 1500
|
||||||
|
*/
|
||||||
|
|
||||||
|
flashDelay: 1500,
|
||||||
|
/**
|
||||||
|
a minimum height for the `.slider` element.
|
||||||
|
@property sliderMinHeight
|
||||||
|
@type Number
|
||||||
|
@default 20
|
||||||
|
*/
|
||||||
|
|
||||||
|
sliderMinHeight: 20,
|
||||||
|
/**
|
||||||
|
a maximum height for the `.slider` element.
|
||||||
|
@property sliderMaxHeight
|
||||||
|
@type Number
|
||||||
|
@default null
|
||||||
|
*/
|
||||||
|
|
||||||
|
sliderMaxHeight: null
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
@property SCROLLBAR
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
SCROLLBAR = 'scrollbar';
|
||||||
|
/**
|
||||||
|
@property SCROLL
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
SCROLL = 'scroll';
|
||||||
|
/**
|
||||||
|
@property MOUSEDOWN
|
||||||
|
@type String
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
MOUSEDOWN = 'mousedown';
|
||||||
|
/**
|
||||||
|
@property MOUSEMOVE
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
MOUSEMOVE = 'mousemove';
|
||||||
|
/**
|
||||||
|
@property MOUSEWHEEL
|
||||||
|
@type String
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
MOUSEWHEEL = 'mousewheel';
|
||||||
|
/**
|
||||||
|
@property MOUSEUP
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
MOUSEUP = 'mouseup';
|
||||||
|
/**
|
||||||
|
@property RESIZE
|
||||||
|
@type String
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
RESIZE = 'resize';
|
||||||
|
/**
|
||||||
|
@property DRAG
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
DRAG = 'drag';
|
||||||
|
/**
|
||||||
|
@property UP
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
UP = 'up';
|
||||||
|
/**
|
||||||
|
@property PANEDOWN
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
PANEDOWN = 'panedown';
|
||||||
|
/**
|
||||||
|
@property DOMSCROLL
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
DOMSCROLL = 'DOMMouseScroll';
|
||||||
|
/**
|
||||||
|
@property DOWN
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
DOWN = 'down';
|
||||||
|
/**
|
||||||
|
@property WHEEL
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
WHEEL = 'wheel';
|
||||||
|
/**
|
||||||
|
@property KEYDOWN
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
KEYDOWN = 'keydown';
|
||||||
|
/**
|
||||||
|
@property KEYUP
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
KEYUP = 'keyup';
|
||||||
|
/**
|
||||||
|
@property TOUCHMOVE
|
||||||
|
@type String
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
TOUCHMOVE = 'touchmove';
|
||||||
|
/**
|
||||||
|
@property BROWSER_IS_IE7
|
||||||
|
@type Boolean
|
||||||
|
@static
|
||||||
|
@final
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
BROWSER_IS_IE7 = window.navigator.appName === 'Microsoft Internet Explorer' && /msie 7./i.test(window.navigator.appVersion) && window.ActiveXObject;
|
||||||
|
/**
|
||||||
|
@property BROWSER_SCROLLBAR_WIDTH
|
||||||
|
@type Number
|
||||||
|
@static
|
||||||
|
@default null
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
BROWSER_SCROLLBAR_WIDTH = null;
|
||||||
|
/**
|
||||||
|
Returns browser's native scrollbar width
|
||||||
|
@method getBrowserScrollbarWidth
|
||||||
|
@return {Number} the scrollbar width in pixels
|
||||||
|
@static
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
getBrowserScrollbarWidth = function() {
|
||||||
|
var outer, outerStyle, scrollbarWidth;
|
||||||
|
outer = document.createElement('div');
|
||||||
|
outerStyle = outer.style;
|
||||||
|
outerStyle.position = 'absolute';
|
||||||
|
outerStyle.width = '100px';
|
||||||
|
outerStyle.height = '100px';
|
||||||
|
outerStyle.overflow = SCROLL;
|
||||||
|
outerStyle.top = '-9999px';
|
||||||
|
document.body.appendChild(outer);
|
||||||
|
scrollbarWidth = outer.offsetWidth - outer.clientWidth;
|
||||||
|
document.body.removeChild(outer);
|
||||||
|
return scrollbarWidth;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
@class NanoScroll
|
||||||
|
@param element {HTMLElement|Node} the main element
|
||||||
|
@param options {Object} nanoScroller's options
|
||||||
|
@constructor
|
||||||
|
*/
|
||||||
|
|
||||||
|
NanoScroll = (function() {
|
||||||
|
|
||||||
|
function NanoScroll(el, options) {
|
||||||
|
this.el = el;
|
||||||
|
this.options = options;
|
||||||
|
BROWSER_SCROLLBAR_WIDTH || (BROWSER_SCROLLBAR_WIDTH = getBrowserScrollbarWidth());
|
||||||
|
this.$el = $(this.el);
|
||||||
|
this.doc = $(document);
|
||||||
|
this.win = $(window);
|
||||||
|
this.$content = this.$el.children("." + options.contentClass);
|
||||||
|
this.$content.attr('tabindex', 0);
|
||||||
|
this.content = this.$content[0];
|
||||||
|
if (this.options.iOSNativeScrolling && (this.el.style.WebkitOverflowScrolling != null)) {
|
||||||
|
this.nativeScrolling();
|
||||||
|
} else {
|
||||||
|
this.generate();
|
||||||
|
}
|
||||||
|
this.createEvents();
|
||||||
|
this.addEvents();
|
||||||
|
this.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Prevents the rest of the page being scrolled
|
||||||
|
when user scrolls the `.content` element.
|
||||||
|
@method preventScrolling
|
||||||
|
@param event {Event}
|
||||||
|
@param direction {String} Scroll direction (up or down)
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.preventScrolling = function(e, direction) {
|
||||||
|
if (!this.isActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (e.type === DOMSCROLL) {
|
||||||
|
if (direction === DOWN && e.originalEvent.detail > 0 || direction === UP && e.originalEvent.detail < 0) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
} else if (e.type === MOUSEWHEEL) {
|
||||||
|
if (!e.originalEvent || !e.originalEvent.wheelDelta) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (direction === DOWN && e.originalEvent.wheelDelta < 0 || direction === UP && e.originalEvent.wheelDelta > 0) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Enable iOS native scrolling
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.nativeScrolling = function() {
|
||||||
|
this.$content.css({
|
||||||
|
WebkitOverflowScrolling: 'touch'
|
||||||
|
});
|
||||||
|
this.iOSNativeScrolling = true;
|
||||||
|
this.isActive = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Updates those nanoScroller properties that
|
||||||
|
are related to current scrollbar position.
|
||||||
|
@method updateScrollValues
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.updateScrollValues = function() {
|
||||||
|
var content;
|
||||||
|
content = this.content;
|
||||||
|
this.maxScrollTop = content.scrollHeight - content.clientHeight;
|
||||||
|
this.contentScrollTop = content.scrollTop;
|
||||||
|
if (!this.iOSNativeScrolling) {
|
||||||
|
this.maxSliderTop = this.paneHeight - this.sliderHeight;
|
||||||
|
this.sliderTop = this.contentScrollTop * this.maxSliderTop / this.maxScrollTop;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Creates event related methods
|
||||||
|
@method createEvents
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.createEvents = function() {
|
||||||
|
var _this = this;
|
||||||
|
this.events = {
|
||||||
|
down: function(e) {
|
||||||
|
_this.isBeingDragged = true;
|
||||||
|
_this.offsetY = e.pageY - _this.slider.offset().top;
|
||||||
|
_this.pane.addClass('active');
|
||||||
|
_this.doc.bind(MOUSEMOVE, _this.events[DRAG]).bind(MOUSEUP, _this.events[UP]);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
drag: function(e) {
|
||||||
|
_this.sliderY = e.pageY - _this.$el.offset().top - _this.offsetY;
|
||||||
|
_this.scroll();
|
||||||
|
_this.updateScrollValues();
|
||||||
|
if (_this.contentScrollTop >= _this.maxScrollTop) {
|
||||||
|
_this.$el.trigger('scrollend');
|
||||||
|
} else if (_this.contentScrollTop === 0) {
|
||||||
|
_this.$el.trigger('scrolltop');
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
up: function(e) {
|
||||||
|
_this.isBeingDragged = false;
|
||||||
|
_this.pane.removeClass('active');
|
||||||
|
_this.doc.unbind(MOUSEMOVE, _this.events[DRAG]).unbind(MOUSEUP, _this.events[UP]);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
resize: function(e) {
|
||||||
|
_this.reset();
|
||||||
|
},
|
||||||
|
panedown: function(e) {
|
||||||
|
_this.sliderY = (e.offsetY || e.originalEvent.layerY) - (_this.sliderHeight * 0.5);
|
||||||
|
_this.scroll();
|
||||||
|
_this.events.down(e);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
scroll: function(e) {
|
||||||
|
if (_this.isBeingDragged) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_this.updateScrollValues();
|
||||||
|
if (!_this.iOSNativeScrolling) {
|
||||||
|
_this.sliderY = _this.sliderTop;
|
||||||
|
_this.slider.css({
|
||||||
|
top: _this.sliderTop
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (e == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_this.contentScrollTop >= _this.maxScrollTop) {
|
||||||
|
if (_this.options.preventPageScrolling) {
|
||||||
|
_this.preventScrolling(e, DOWN);
|
||||||
|
}
|
||||||
|
_this.$el.trigger('scrollend');
|
||||||
|
} else if (_this.contentScrollTop === 0) {
|
||||||
|
if (_this.options.preventPageScrolling) {
|
||||||
|
_this.preventScrolling(e, UP);
|
||||||
|
}
|
||||||
|
_this.$el.trigger('scrolltop');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
wheel: function(e) {
|
||||||
|
if (e == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_this.sliderY += -e.wheelDeltaY || -e.delta;
|
||||||
|
_this.scroll();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Adds event listeners with jQuery.
|
||||||
|
@method addEvents
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.addEvents = function() {
|
||||||
|
var events;
|
||||||
|
this.removeEvents();
|
||||||
|
events = this.events;
|
||||||
|
if (!this.options.disableResize) {
|
||||||
|
this.win.bind(RESIZE, events[RESIZE]);
|
||||||
|
}
|
||||||
|
if (!this.iOSNativeScrolling) {
|
||||||
|
this.slider.bind(MOUSEDOWN, events[DOWN]);
|
||||||
|
this.pane.bind(MOUSEDOWN, events[PANEDOWN]).bind("" + MOUSEWHEEL + " " + DOMSCROLL, events[WHEEL]);
|
||||||
|
}
|
||||||
|
this.$content.bind("" + SCROLL + " " + MOUSEWHEEL + " " + DOMSCROLL + " " + TOUCHMOVE, events[SCROLL]);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Removes event listeners with jQuery.
|
||||||
|
@method removeEvents
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.removeEvents = function() {
|
||||||
|
var events;
|
||||||
|
events = this.events;
|
||||||
|
this.win.unbind(RESIZE, events[RESIZE]);
|
||||||
|
if (!this.iOSNativeScrolling) {
|
||||||
|
this.slider.unbind();
|
||||||
|
this.pane.unbind();
|
||||||
|
}
|
||||||
|
this.$content.unbind("" + SCROLL + " " + MOUSEWHEEL + " " + DOMSCROLL + " " + TOUCHMOVE, events[SCROLL]);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Generates nanoScroller's scrollbar and elements for it.
|
||||||
|
@method generate
|
||||||
|
@chainable
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.generate = function() {
|
||||||
|
var contentClass, cssRule, options, paneClass, sliderClass;
|
||||||
|
options = this.options;
|
||||||
|
paneClass = options.paneClass, sliderClass = options.sliderClass, contentClass = options.contentClass;
|
||||||
|
if (!this.$el.find("" + paneClass).length && !this.$el.find("" + sliderClass).length) {
|
||||||
|
this.$el.append("<div class=\"" + paneClass + "\"><div class=\"" + sliderClass + "\" /></div>");
|
||||||
|
}
|
||||||
|
this.pane = this.$el.children("." + paneClass);
|
||||||
|
this.slider = this.pane.find("." + sliderClass);
|
||||||
|
if (BROWSER_SCROLLBAR_WIDTH) {
|
||||||
|
cssRule = this.$el.css('direction') === 'rtl' ? {
|
||||||
|
left: -BROWSER_SCROLLBAR_WIDTH
|
||||||
|
} : {
|
||||||
|
right: -BROWSER_SCROLLBAR_WIDTH
|
||||||
|
};
|
||||||
|
this.$el.addClass('has-scrollbar');
|
||||||
|
}
|
||||||
|
if (cssRule != null) {
|
||||||
|
this.$content.css(cssRule);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@method restore
|
||||||
|
@private
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.restore = function() {
|
||||||
|
this.stopped = false;
|
||||||
|
this.pane.show();
|
||||||
|
this.addEvents();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Resets nanoScroller's scrollbar.
|
||||||
|
@method reset
|
||||||
|
@chainable
|
||||||
|
@example
|
||||||
|
$(".nano").nanoScroller();
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.reset = function() {
|
||||||
|
var content, contentHeight, contentStyle, contentStyleOverflowY, paneBottom, paneHeight, paneOuterHeight, paneTop, sliderHeight;
|
||||||
|
if (this.iOSNativeScrolling) {
|
||||||
|
this.contentHeight = this.content.scrollHeight;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!this.$el.find("." + this.options.paneClass).length) {
|
||||||
|
this.generate().stop();
|
||||||
|
}
|
||||||
|
if (this.stopped) {
|
||||||
|
this.restore();
|
||||||
|
}
|
||||||
|
content = this.content;
|
||||||
|
contentStyle = content.style;
|
||||||
|
contentStyleOverflowY = contentStyle.overflowY;
|
||||||
|
if (BROWSER_IS_IE7) {
|
||||||
|
this.$content.css({
|
||||||
|
height: this.$content.height()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
contentHeight = content.scrollHeight + BROWSER_SCROLLBAR_WIDTH;
|
||||||
|
paneHeight = this.pane.outerHeight();
|
||||||
|
paneTop = parseInt(this.pane.css('top'), 10);
|
||||||
|
paneBottom = parseInt(this.pane.css('bottom'), 10);
|
||||||
|
paneOuterHeight = paneHeight + paneTop + paneBottom;
|
||||||
|
sliderHeight = Math.round(paneOuterHeight / contentHeight * paneOuterHeight);
|
||||||
|
if (sliderHeight < this.options.sliderMinHeight) {
|
||||||
|
sliderHeight = this.options.sliderMinHeight;
|
||||||
|
} else if ((this.options.sliderMaxHeight != null) && sliderHeight > this.options.sliderMaxHeight) {
|
||||||
|
sliderHeight = this.options.sliderMaxHeight;
|
||||||
|
}
|
||||||
|
if (contentStyleOverflowY === SCROLL && contentStyle.overflowX !== SCROLL) {
|
||||||
|
sliderHeight += BROWSER_SCROLLBAR_WIDTH;
|
||||||
|
}
|
||||||
|
this.maxSliderTop = paneOuterHeight - sliderHeight;
|
||||||
|
this.contentHeight = contentHeight;
|
||||||
|
this.paneHeight = paneHeight;
|
||||||
|
this.paneOuterHeight = paneOuterHeight;
|
||||||
|
this.sliderHeight = sliderHeight;
|
||||||
|
this.slider.height(sliderHeight);
|
||||||
|
this.events.scroll();
|
||||||
|
this.pane.show();
|
||||||
|
this.isActive = true;
|
||||||
|
if ((content.scrollHeight === content.clientHeight) || (this.pane.outerHeight(true) >= content.scrollHeight && contentStyleOverflowY !== SCROLL)) {
|
||||||
|
this.pane.hide();
|
||||||
|
this.isActive = false;
|
||||||
|
} else if (this.el.clientHeight === content.scrollHeight && contentStyleOverflowY === SCROLL) {
|
||||||
|
this.slider.hide();
|
||||||
|
} else {
|
||||||
|
this.slider.show();
|
||||||
|
}
|
||||||
|
this.pane.css({
|
||||||
|
opacity: (this.options.alwaysVisible ? 1 : ''),
|
||||||
|
visibility: (this.options.alwaysVisible ? 'visible' : '')
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
@method scroll
|
||||||
|
@private
|
||||||
|
@example
|
||||||
|
$(".nano").nanoScroller({ scroll: 'top' });
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.scroll = function() {
|
||||||
|
if (!this.isActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.sliderY = Math.max(0, this.sliderY);
|
||||||
|
this.sliderY = Math.min(this.maxSliderTop, this.sliderY);
|
||||||
|
this.$content.scrollTop((this.paneHeight - this.contentHeight + BROWSER_SCROLLBAR_WIDTH) * this.sliderY / this.maxSliderTop * -1);
|
||||||
|
if (!this.iOSNativeScrolling) {
|
||||||
|
this.slider.css({
|
||||||
|
top: this.sliderY
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Scroll at the bottom with an offset value
|
||||||
|
@method scrollBottom
|
||||||
|
@param offsetY {Number}
|
||||||
|
@chainable
|
||||||
|
@example
|
||||||
|
$(".nano").nanoScroller({ scrollBottom: value });
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.scrollBottom = function(offsetY) {
|
||||||
|
if (!this.isActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.reset();
|
||||||
|
this.$content.scrollTop(this.contentHeight - this.$content.height() - offsetY).trigger(MOUSEWHEEL);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Scroll at the top with an offset value
|
||||||
|
@method scrollTop
|
||||||
|
@param offsetY {Number}
|
||||||
|
@chainable
|
||||||
|
@example
|
||||||
|
$(".nano").nanoScroller({ scrollTop: value });
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.scrollTop = function(offsetY) {
|
||||||
|
if (!this.isActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.reset();
|
||||||
|
this.$content.scrollTop(+offsetY).trigger(MOUSEWHEEL);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
Scroll to an element
|
||||||
|
@method scrollTo
|
||||||
|
@param node {Node} A node to scroll to.
|
||||||
|
@chainable
|
||||||
|
@example
|
||||||
|
$(".nano").nanoScroller({ scrollTo: $('#a_node') });
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.scrollTo = function(node) {
|
||||||
|
if (!this.isActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.reset();
|
||||||
|
this.scrollTop($(node).get(0).offsetTop);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
To stop the operation.
|
||||||
|
This option will tell the plugin to disable all event bindings and hide the gadget scrollbar from the UI.
|
||||||
|
@method stop
|
||||||
|
@chainable
|
||||||
|
@example
|
||||||
|
$(".nano").nanoScroller({ stop: true });
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.stop = function() {
|
||||||
|
this.stopped = true;
|
||||||
|
this.removeEvents();
|
||||||
|
this.pane.hide();
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
To flash the scrollbar gadget for an amount of time defined in plugin settings (defaults to 1,5s).
|
||||||
|
Useful if you want to show the user (e.g. on pageload) that there is more content waiting for him.
|
||||||
|
@method flash
|
||||||
|
@chainable
|
||||||
|
@example
|
||||||
|
$(".nano").nanoScroller({ flash: true });
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
NanoScroll.prototype.flash = function() {
|
||||||
|
var _this = this;
|
||||||
|
if (!this.isActive) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.reset();
|
||||||
|
this.pane.addClass('flashed');
|
||||||
|
setTimeout(function() {
|
||||||
|
_this.pane.removeClass('flashed');
|
||||||
|
}, this.options.flashDelay);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
return NanoScroll;
|
||||||
|
|
||||||
|
})();
|
||||||
|
$.fn.nanoScroller = function(settings) {
|
||||||
|
return this.each(function() {
|
||||||
|
var options, scrollbar;
|
||||||
|
if (!(scrollbar = this.nanoscroller)) {
|
||||||
|
options = $.extend({}, defaults, settings);
|
||||||
|
this.nanoscroller = scrollbar = new NanoScroll(this, options);
|
||||||
|
}
|
||||||
|
if (settings && typeof settings === "object") {
|
||||||
|
$.extend(scrollbar.options, settings);
|
||||||
|
if (settings.scrollBottom) {
|
||||||
|
return scrollbar.scrollBottom(settings.scrollBottom);
|
||||||
|
}
|
||||||
|
if (settings.scrollTop) {
|
||||||
|
return scrollbar.scrollTop(settings.scrollTop);
|
||||||
|
}
|
||||||
|
if (settings.scrollTo) {
|
||||||
|
return scrollbar.scrollTo(settings.scrollTo);
|
||||||
|
}
|
||||||
|
if (settings.scroll === 'bottom') {
|
||||||
|
return scrollbar.scrollBottom(0);
|
||||||
|
}
|
||||||
|
if (settings.scroll === 'top') {
|
||||||
|
return scrollbar.scrollTop(0);
|
||||||
|
}
|
||||||
|
if (settings.scroll && settings.scroll instanceof $) {
|
||||||
|
return scrollbar.scrollTo(settings.scroll);
|
||||||
|
}
|
||||||
|
if (settings.stop) {
|
||||||
|
return scrollbar.stop();
|
||||||
|
}
|
||||||
|
if (settings.flash) {
|
||||||
|
return scrollbar.flash();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return scrollbar.reset();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
})(jQuery, window, document);
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,349 @@
|
||||||
|
/*
|
||||||
|
* jQuery pageSlide
|
||||||
|
* Version 2.0
|
||||||
|
* http://srobbin.com/jquery-pageslide/
|
||||||
|
*
|
||||||
|
* jQuery Javascript plugin which slides a webpage over to reveal an additional interaction pane.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2011 Scott Robbin (srobbin.com)
|
||||||
|
* Dual licensed under the MIT and GPL licenses.
|
||||||
|
*/
|
||||||
|
|
||||||
|
!(function($){
|
||||||
|
// Convenience vars for accessing elements
|
||||||
|
var $body = $('#main-wrap'),
|
||||||
|
$bottomNav = $('.bottomnav'),
|
||||||
|
$pageslide = $('#pageslide'),
|
||||||
|
$viewPage = $('#view-page');
|
||||||
|
|
||||||
|
var _sliding = false, // Mutex to assist closing only once
|
||||||
|
_lastCaller; // Used to keep track of last element to trigger pageslide
|
||||||
|
|
||||||
|
// If the pageslide element doesn't exist, create it
|
||||||
|
if( $pageslide.length == 0 ) {
|
||||||
|
$pageslide = $('<div />').attr( 'id', 'pageslide' )
|
||||||
|
.css( 'display', 'none' )
|
||||||
|
.appendTo( $body );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Private methods
|
||||||
|
*/
|
||||||
|
function _load( url, useIframe, callback,element ) {
|
||||||
|
// Are we loading an element from the page or a URL?
|
||||||
|
if ( url.indexOf("#") === 0 ) {
|
||||||
|
// Load a page element
|
||||||
|
$(url).clone(true).appendTo( $pageslide.empty() ).show();
|
||||||
|
if(callback)callback.call(this,$pageslide,element);
|
||||||
|
} else {
|
||||||
|
// Load a URL. Into an iframe?
|
||||||
|
if( useIframe ) {
|
||||||
|
var iframe = $("<iframe />").attr({
|
||||||
|
src: url,
|
||||||
|
frameborder: 0,
|
||||||
|
hspace: 0
|
||||||
|
})
|
||||||
|
.css({
|
||||||
|
width: "100%",
|
||||||
|
height: "100%"
|
||||||
|
});
|
||||||
|
|
||||||
|
$viewPage.find('.content').html( iframe );
|
||||||
|
$viewPage.clone(true).appendTo( $pageslide.empty() ).show();
|
||||||
|
$viewPage.find('.content').empty();
|
||||||
|
if(callback)callback.call(this,$viewPage,element);
|
||||||
|
} else {
|
||||||
|
$viewPage.find('.content').load(url, function(){
|
||||||
|
$viewPage.clone(true).appendTo( $pageslide.empty() ).show();
|
||||||
|
if($('#filter-default-tag').length) {
|
||||||
|
$('#filter-default-tag').fastLiveFilter('.add-default-tags-list', '.filter-item', '.tag');
|
||||||
|
addTagsTab();
|
||||||
|
$('#view-page .card').cardCheck({
|
||||||
|
item: $('#view-page input[type="checkbox"]'),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
if(callback)callback.call(this,$viewPage,element);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$pageslide.data( 'localEl', false );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function that controls opening of the pageslide
|
||||||
|
function _start( direction, speed ) {
|
||||||
|
var slideWidth = $pageslide.outerWidth( true ),
|
||||||
|
bodyAnimateIn = {},
|
||||||
|
bottomnavAnimateIn = {},
|
||||||
|
slideAnimateIn = {};
|
||||||
|
|
||||||
|
// If the slide is open or opening, just ignore the call
|
||||||
|
if( $pageslide.is(':visible') || _sliding ) return;
|
||||||
|
_sliding = true;
|
||||||
|
|
||||||
|
switch( direction ) {
|
||||||
|
case 'left':
|
||||||
|
$pageslide.css({ left: 'auto', right: '-' + slideWidth + 'px' });
|
||||||
|
bodyAnimateIn['width'] = '-=' + slideWidth;
|
||||||
|
slideAnimateIn['right'] = '+=' + slideWidth;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
if($sidebarState && !$('.item-groups').length) {
|
||||||
|
$pageslide.css({ left: '-' + (slideWidth-241) + 'px', right: 'auto' });
|
||||||
|
}else{
|
||||||
|
$pageslide.css({ left: '-' + (slideWidth-61) + 'px', right: 'auto' });
|
||||||
|
};
|
||||||
|
bodyAnimateIn['margin-left'] = '+=' + slideWidth;
|
||||||
|
bottomnavAnimateIn['left'] = '+=' + slideWidth;
|
||||||
|
if($(window).width() <= 1440 && slideWidth > 963 ) {
|
||||||
|
bodyAnimateIn['width'] = $body.width();
|
||||||
|
}
|
||||||
|
slideAnimateIn['left'] = '+=' + slideWidth;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Animate the slide, and attach this slide's settings to the element
|
||||||
|
$body.animate(bodyAnimateIn, speed);
|
||||||
|
$bottomNav.animate(bottomnavAnimateIn, speed);
|
||||||
|
$pageslide.show().animate(slideAnimateIn, speed, function() {
|
||||||
|
_sliding = false;
|
||||||
|
$pageslide.children('.nano').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true });
|
||||||
|
if(typeof $.fn.pageslide.defaults.openFn === "function") {
|
||||||
|
var returnValue = ($.fn.pageslide.defaults.iframe ? $viewPage : $pageslide);
|
||||||
|
$.fn.pageslide.defaults.openFn.call(this,returnValue);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Declaration
|
||||||
|
*/
|
||||||
|
$.fn.pageslide = function(options) {
|
||||||
|
var $elements = this;
|
||||||
|
// On click
|
||||||
|
$elements.bind(clickEvent, function(e) {
|
||||||
|
var $self = $(this),
|
||||||
|
settings = $.extend({ href: $self.attr('href') }, options);
|
||||||
|
|
||||||
|
// Prevent the default behavior and stop propagation
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
if ( $pageslide.is(':visible') && $self[0] == _lastCaller ) {
|
||||||
|
// If we clicked the same element twice, toggle closed
|
||||||
|
$.pageslide.close();
|
||||||
|
} else {
|
||||||
|
// Open
|
||||||
|
$.pageslide( settings,$self );
|
||||||
|
|
||||||
|
if($('.item-groups').length) {
|
||||||
|
$('.item-menu > a, .navbar-inner').removeClass("active");
|
||||||
|
$(this).parents('.navbar-inner').addClass('active').end().addClass('active');
|
||||||
|
if(!$.support.touch) {
|
||||||
|
if($('.item-menu > a').hasClass('active')) {
|
||||||
|
$('.item-menu').css({
|
||||||
|
'display': 'none',
|
||||||
|
});
|
||||||
|
$(this).parents('.item-menu').css({
|
||||||
|
'display': 'inline-block',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$pageName = $self.parents('.item-title').children('a').text();
|
||||||
|
$('.page-name').text($pageName);
|
||||||
|
} else if($('.tags-groups').length) {
|
||||||
|
if($('.gallery').length) {
|
||||||
|
$(this).closest('.rgalbum').addClass('active-single').siblings().removeClass('active-single');
|
||||||
|
if($(this).closest('ul').hasClass('photo-action')) {
|
||||||
|
$('.checkbox').prop('checked', false);
|
||||||
|
$('.rgalbum').removeClass('active');
|
||||||
|
$('.deletephoto, .deselect, .addtags').addClass('hide');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$(this).closest('li').addClass("active").siblings().removeClass("active").parent('ul').siblings().children('li').removeClass("active");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$(this).parents("tr").addClass("active").siblings().removeClass("active");;
|
||||||
|
}
|
||||||
|
$pageslide.focusFirstField(); // focus first form
|
||||||
|
setTimeout(setScroll, 300);
|
||||||
|
// Record the last element to trigger pageslide
|
||||||
|
_lastCaller = $self[0];
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Default settings
|
||||||
|
*/
|
||||||
|
$.fn.pageslide.defaults = {
|
||||||
|
speed: 300, // Accepts standard jQuery effects speeds (i.e. fast, normal or milliseconds)
|
||||||
|
direction: 'right', // Accepts 'left' or 'right'
|
||||||
|
modal: false, // If set to true, you must explicitly close pageslide using $.pageslide.close();
|
||||||
|
iframe: false, // By default, linked pages are loaded into an iframe. Set this to false if you don't want an iframe.
|
||||||
|
href: null, // Override the source of the content. Optional in most cases, but required when opening pageslide programmatically.
|
||||||
|
W: 264,
|
||||||
|
closeFn : null,
|
||||||
|
openFn : null,
|
||||||
|
loadComplete : null
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Public methods
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Open the pageslide
|
||||||
|
$.pageslide = function( options,element ) {
|
||||||
|
// Extend the settings with those the user has provided
|
||||||
|
var settings = $.extend({}, $.fn.pageslide.defaults, options);
|
||||||
|
var convertToFunction = function(fn){
|
||||||
|
var x = new Function();
|
||||||
|
x = fn;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Change Object to Function
|
||||||
|
if(settings.openFn) {
|
||||||
|
$.fn.pageslide.defaults.openFn = convertToFunction(settings.openFn);
|
||||||
|
};
|
||||||
|
|
||||||
|
if(settings.closeFn) {
|
||||||
|
$.fn.pageslide.defaults.closeFn = convertToFunction(settings.closeFn);
|
||||||
|
}
|
||||||
|
if(settings.loadComplete) {
|
||||||
|
$.fn.pageslide.defaults.loadComplete = convertToFunction(settings.loadComplete);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Are we trying to open in different direction?
|
||||||
|
if( ($pageslide.is(':visible') && $pageslide.data( 'W' ) != settings.W) || ($pageslide.is(':visible') && $pageslide.data( 'direction' ) != settings.direction) ) {
|
||||||
|
$.pageslide.close(function(){
|
||||||
|
$pageslide.css({'width': settings.W});
|
||||||
|
_load( settings.href, settings.iframe, settings.loadComplete, element );
|
||||||
|
_start( settings.direction, settings.speed );
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
_load( settings.href, settings.iframe, settings.loadComplete,element );
|
||||||
|
if( $pageslide.is(':hidden') ) {
|
||||||
|
$pageslide.css({'width': settings.W});
|
||||||
|
_start( settings.direction, settings.speed );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$pageslide.data( settings );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if($('#add-tags').length) {
|
||||||
|
$('.set_new').addClass('active in').siblings().removeClass('active in');
|
||||||
|
$('#pageslide .selete_defat .search-query').attr('id','filter-default-tag');
|
||||||
|
$('#filter-default-tag').fastLiveFilter('.add-defalt-tags-list', '.filter-item', '.tag');
|
||||||
|
$('.add-defalt-tags-list .filter-item').removeClass('mark');
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
// Close the pageslide
|
||||||
|
$.pageslide.close = function( callback ) {
|
||||||
|
var $pageslide = $('#pageslide'),
|
||||||
|
slideWidth = $pageslide.outerWidth( true ),
|
||||||
|
speed = $pageslide.data( 'speed' ),
|
||||||
|
bodyAnimateIn = {},
|
||||||
|
bottomnavAnimateIn = {};
|
||||||
|
slideAnimateIn = {}
|
||||||
|
|
||||||
|
// If the slide isn't open, just ignore the call
|
||||||
|
if( $pageslide.is(':hidden') || _sliding ) return;
|
||||||
|
_sliding = true;
|
||||||
|
|
||||||
|
switch( $pageslide.data( 'direction' ) ) {
|
||||||
|
case 'left':
|
||||||
|
bodyAnimateIn['width'] = '+=' + slideWidth;
|
||||||
|
slideAnimateIn['right'] = '-=' + slideWidth;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
bodyAnimateIn['margin-left'] = '-=' + slideWidth;
|
||||||
|
bottomnavAnimateIn['left'] = '-=' + slideWidth;
|
||||||
|
slideAnimateIn['left'] = '-=' + slideWidth;
|
||||||
|
if($pageslide.find('.preview').length) {
|
||||||
|
$pageslide.find('.preview').cycle('destroy');
|
||||||
|
$pageslide.find('.preview img').removeAttr('style');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($('.item-groups').length) {
|
||||||
|
$(".navbar-inner").removeClass("active");
|
||||||
|
$('.item-menu > a, .navbar-inner').removeClass("active");
|
||||||
|
if(!$.support.touch) {
|
||||||
|
$('.item-menu').css({
|
||||||
|
'display': 'none',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if($('.tags-groups').length) {
|
||||||
|
$('.tags-groups').children('li').removeClass("active");
|
||||||
|
$('.rgalbum').removeClass("active-single");
|
||||||
|
} else {
|
||||||
|
$("tr").removeClass("active");
|
||||||
|
};
|
||||||
|
|
||||||
|
$pageslide.animate(slideAnimateIn, speed);
|
||||||
|
$bottomNav.animate(bottomnavAnimateIn, speed);
|
||||||
|
$body.animate(bodyAnimateIn, speed, function() {
|
||||||
|
$pageslide.hide();
|
||||||
|
_sliding = false;
|
||||||
|
if( typeof callback != 'undefined' ) callback();
|
||||||
|
$body.css({'width': 'auto'});
|
||||||
|
if(typeof $.fn.pageslide.defaults.closeFn === "function") {
|
||||||
|
var returnValue = ($.fn.pageslide.defaults.iframe ? $viewPage : $pageslide);
|
||||||
|
$.fn.pageslide.defaults.closeFn.call(this,returnValue);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close Callback
|
||||||
|
$.pageslide.closeCallback = function(callback) {
|
||||||
|
if(typeof callback === "function"){
|
||||||
|
$.fn.pageslide.defaults.closeFn = callback;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Open Callback
|
||||||
|
$.pageslide.openCallback = function(callback) {
|
||||||
|
if(typeof callback === "function"){
|
||||||
|
$.fn.pageslide.defaults.openFn = callback;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
//data load complete callback
|
||||||
|
$.pageslide.loadComplete = function(callback) {
|
||||||
|
if(typeof callback === "function"){
|
||||||
|
$.fn.pageslide.defaults.loadComplete = callback;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Events */
|
||||||
|
|
||||||
|
// Don't let clicks to the pageslide close the window
|
||||||
|
$pageslide.click(function(e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Close the pageslide if the document is clicked or the users presses the ESC key, unless the pageslide is modal
|
||||||
|
$(document).bind('click keyup', function(e) {
|
||||||
|
// If this is a keyup event, let's see if it's an ESC key
|
||||||
|
if( e.type == "keyup" && e.keyCode != 27) return;
|
||||||
|
|
||||||
|
// Make sure it's visible, and we're not modal
|
||||||
|
if( $pageslide.is( ':visible' ) && !$pageslide.data( 'modal' ) ) {
|
||||||
|
$.pageslide.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
function setScroll(){
|
||||||
|
$pageslide.children('.nano').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true }); // set nano scroll
|
||||||
|
};
|
||||||
|
|
||||||
|
})(jQuery);
|
|
@ -0,0 +1,347 @@
|
||||||
|
/*
|
||||||
|
* jQuery pageSlide
|
||||||
|
* Version 2.0
|
||||||
|
* http://srobbin.com/jquery-pageslide/
|
||||||
|
*
|
||||||
|
* jQuery Javascript plugin which slides a webpage over to reveal an additional interaction pane.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2011 Scott Robbin (srobbin.com)
|
||||||
|
* Dual licensed under the MIT and GPL licenses.
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function($){
|
||||||
|
// Convenience vars for accessing elements
|
||||||
|
var $body = $('#main-wrap'),
|
||||||
|
$pageslide = $('#pageslide'),
|
||||||
|
$viewPage = $('#view-page');
|
||||||
|
|
||||||
|
var _sliding = false, // Mutex to assist closing only once
|
||||||
|
_lastCaller; // Used to keep track of last element to trigger pageslide
|
||||||
|
|
||||||
|
// If the pageslide element doesn't exist, create it
|
||||||
|
if( $pageslide.length == 0 ) {
|
||||||
|
$pageslide = $('<div />').attr( 'id', 'pageslide' )
|
||||||
|
.css( 'display', 'none' )
|
||||||
|
.appendTo( $('#main-wrap') );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Private methods
|
||||||
|
*/
|
||||||
|
function _load( url, useIframe ) {
|
||||||
|
// Are we loading an element from the page or a URL?
|
||||||
|
|
||||||
|
if ( url.indexOf("#") === 0 ) {
|
||||||
|
// Load a page element
|
||||||
|
$(url).clone(true).appendTo( $pageslide.empty() ).show();
|
||||||
|
if($('#items').length) {
|
||||||
|
$pageslide.css({'width': '324px'});
|
||||||
|
} else {
|
||||||
|
$pageslide.css({'width': '264px'});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Load a URL. Into an iframe?
|
||||||
|
if( useIframe ) {
|
||||||
|
var iframe = $("<iframe />").attr({
|
||||||
|
src: url,
|
||||||
|
frameborder: 0,
|
||||||
|
hspace: 0
|
||||||
|
})
|
||||||
|
.css({
|
||||||
|
width: "100%",
|
||||||
|
height: "100%"
|
||||||
|
});
|
||||||
|
|
||||||
|
$pageslide.html( iframe );
|
||||||
|
} else {
|
||||||
|
$viewPage.find('.content').load(url, function(){
|
||||||
|
$viewPage.clone(true).appendTo( $pageslide.empty() ).show();
|
||||||
|
});
|
||||||
|
$(window).width() > 1600 ? $pageslide.css({'width': '1024px'}) : $pageslide.css({'width': '953px'});
|
||||||
|
// $pageslide.load( url );
|
||||||
|
}
|
||||||
|
|
||||||
|
$pageslide.data( 'localEl', false );
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Function that controls opening of the pageslide
|
||||||
|
function _start( direction, speed ) {
|
||||||
|
var slideWidth,
|
||||||
|
bodyAnimateIn = {},
|
||||||
|
slideAnimateIn = {};
|
||||||
|
// If the slide is open or opening, just ignore the call
|
||||||
|
if( $pageslide.is(':visible') || _sliding ) return;
|
||||||
|
_sliding = true;
|
||||||
|
|
||||||
|
switch( direction ) {
|
||||||
|
case 'left':
|
||||||
|
if($(window).width() > 1600) {
|
||||||
|
$pageslide.css({'width': '1024px'});
|
||||||
|
slideWidth = $pageslide.outerWidth( true );
|
||||||
|
bodyAnimateIn['width'] = '-=' + slideWidth;
|
||||||
|
} else {
|
||||||
|
$pageslide.css({'width': '953px'});
|
||||||
|
slideWidth = $pageslide.outerWidth( true );
|
||||||
|
}
|
||||||
|
|
||||||
|
$pageslide.css({ left: 'auto', right: '-' + slideWidth + 'px' });
|
||||||
|
slideAnimateIn['right'] = '+=' + slideWidth;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// bodyAnimateIn['margin-left'] = '-=' + slideWidth;
|
||||||
|
|
||||||
|
// for Orbit ---> Fixed page does not move to the left
|
||||||
|
if($('#items').length) {
|
||||||
|
// bodyAnimateIn['padding-left'] = '+=' + slideWidth;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Original
|
||||||
|
// $pageslide.css({ left: '-' + slideWidth + 'px', right: 'auto' });
|
||||||
|
// bodyAnimateIn['margin-left'] = '+=' + slideWidth;
|
||||||
|
|
||||||
|
// for Orbit
|
||||||
|
// if($('#items').length) {
|
||||||
|
// $pageslide.css({'width': '324px'});
|
||||||
|
// slideWidth = $pageslide.outerWidth( true );
|
||||||
|
// } else {
|
||||||
|
// $pageslide.css({'width': '264px'});
|
||||||
|
// }
|
||||||
|
slideWidth = $pageslide.outerWidth( true );
|
||||||
|
if($sidebarState && !$('#items').length) {
|
||||||
|
$pageslide.css({ left: '-' + (slideWidth-241) + 'px', right: 'auto' });
|
||||||
|
}else{
|
||||||
|
$pageslide.css({ left: '-' + (slideWidth-61) + 'px', right: 'auto' });
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
bodyAnimateIn['margin-left'] = '+=' + slideWidth;
|
||||||
|
// bodyAnimateIn['width'] = '-=' + slideWidth;
|
||||||
|
//
|
||||||
|
|
||||||
|
slideAnimateIn['left'] = '+=' + slideWidth;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Animate the slide, and attach this slide's settings to the element
|
||||||
|
console.log("d")
|
||||||
|
$body.animate(bodyAnimateIn, speed);
|
||||||
|
$pageslide.show()
|
||||||
|
.animate(slideAnimateIn, speed, function() {
|
||||||
|
_sliding = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Declaration
|
||||||
|
*/
|
||||||
|
$.fn.pageslide = function(options) {
|
||||||
|
var $elements = this,
|
||||||
|
$ua = navigator.userAgent,
|
||||||
|
event = ($ua.match(/iPad/i)||$ua.match(/iPhone/i)||$ua.match(/iPod/i)||$ua.match(/Android/)) ? "touchstart" : "click";
|
||||||
|
// On click
|
||||||
|
$elements.on(event, function(e) {
|
||||||
|
var $self = $(this),
|
||||||
|
settings = $.extend({ href: $self.attr('href') }, options);
|
||||||
|
|
||||||
|
// Prevent the default behavior and stop propagation
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
if ( $pageslide.is(':visible') && $self[0] == _lastCaller ) {
|
||||||
|
// If we clicked the same element twice, toggle closed
|
||||||
|
$.pageslide.close();
|
||||||
|
} else {
|
||||||
|
// Open
|
||||||
|
$.pageslide( settings );
|
||||||
|
|
||||||
|
// for Orbit
|
||||||
|
|
||||||
|
if($('#items').length) {
|
||||||
|
$('.item-menu > a, .navbar-inner').removeClass("active");
|
||||||
|
$(this).parents('.navbar-inner').addClass('active').end().addClass('active');
|
||||||
|
if(!$.support.touch) {
|
||||||
|
if($('.item-menu > a').hasClass('active')) {
|
||||||
|
$('.item-menu').css({
|
||||||
|
'display': 'none',
|
||||||
|
});
|
||||||
|
$(this).parents('.item-menu').css({
|
||||||
|
'display': 'inline-block',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if($(this).hasClass('view-page')) {
|
||||||
|
pageID = $(this).data('pageId');
|
||||||
|
}
|
||||||
|
} else if($('.tags-groups').length) {
|
||||||
|
$(this).parents('li').addClass("active").siblings().removeClass("active").parent('ul').siblings().children('li').removeClass("active");
|
||||||
|
} else {
|
||||||
|
$(this).parents("tr").addClass("active").siblings().removeClass("active");;
|
||||||
|
}
|
||||||
|
$pageslide.focusFirstField(); // focus first form
|
||||||
|
|
||||||
|
setTimeout(setScroll, 300);
|
||||||
|
//
|
||||||
|
|
||||||
|
// Record the last element to trigger pageslide
|
||||||
|
_lastCaller = $self[0];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Default settings
|
||||||
|
*/
|
||||||
|
$.fn.pageslide.defaults = {
|
||||||
|
speed: 300, // Accepts standard jQuery effects speeds (i.e. fast, normal or milliseconds)
|
||||||
|
direction: 'right', // Accepts 'left' or 'right'
|
||||||
|
modal: false, // If set to true, you must explicitly close pageslide using $.pageslide.close();
|
||||||
|
iframe: false, // By default, linked pages are loaded into an iframe. Set this to false if you don't want an iframe.
|
||||||
|
href: null // Override the source of the content. Optional in most cases, but required when opening pageslide programmatically.
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Public methods
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Open the pageslide
|
||||||
|
$.pageslide = function( options ) {
|
||||||
|
// Extend the settings with those the user has provided
|
||||||
|
var settings = $.extend({}, $.fn.pageslide.defaults, options);
|
||||||
|
|
||||||
|
// Are we trying to open in different direction?
|
||||||
|
// if( $pageslide.is(':visible') && $pageslide.data( 'direction' ) != settings.direction) {
|
||||||
|
if( $pageslide.is(':visible')) {
|
||||||
|
$.pageslide.close(function(){
|
||||||
|
_load( settings.href, settings.iframe );
|
||||||
|
_start( settings.direction, settings.speed );
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
_load( settings.href, settings.iframe );
|
||||||
|
if( $pageslide.is(':hidden') ) {
|
||||||
|
_start( settings.direction, settings.speed );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$pageslide.data( settings );
|
||||||
|
|
||||||
|
|
||||||
|
// for Orbit
|
||||||
|
if($('#add-tags').length) {
|
||||||
|
$('.set_new').addClass('active in').siblings().removeClass('active in');
|
||||||
|
$('#pageslide .select_default .search-query').attr('id','filter-default-tag')
|
||||||
|
$('#filter-default-tag').fastLiveFilter('.add-default-tags-list', '.filter-item', '.tag');
|
||||||
|
$('.add-default-tags-list .filter-item').removeClass('mark');
|
||||||
|
}
|
||||||
|
//
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the pageslide
|
||||||
|
$.pageslide.close = function( callback ) {
|
||||||
|
var $pageslide = $('#pageslide'),
|
||||||
|
slideWidth,
|
||||||
|
speed = $pageslide.data( 'speed' ),
|
||||||
|
bodyAnimateIn = {},
|
||||||
|
slideAnimateIn = {}
|
||||||
|
|
||||||
|
// If the slide isn't open, just ignore the call
|
||||||
|
if( $pageslide.is(':hidden') || _sliding ) return;
|
||||||
|
_sliding = true;
|
||||||
|
|
||||||
|
switch( $pageslide.data( 'direction' ) ) {
|
||||||
|
case 'left':
|
||||||
|
if($(window).width() > 1600) {
|
||||||
|
$pageslide.css({'width': '1024px'});
|
||||||
|
} else {
|
||||||
|
$pageslide.css({'width': '953px'});
|
||||||
|
}
|
||||||
|
slideWidth = $pageslide.outerWidth( true );
|
||||||
|
// bodyAnimateIn['margin-left'] = '+=' + slideWidth;
|
||||||
|
if($(window).width() > 1600) {
|
||||||
|
bodyAnimateIn['width'] = '+=' + slideWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for Orbit ---> Fixed page does not move to the left
|
||||||
|
if($('#items').length) {
|
||||||
|
bodyAnimateIn['padding-left'] = '-=' + slideWidth;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
|
||||||
|
slideAnimateIn['right'] = '-=' + slideWidth;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// Original
|
||||||
|
// bodyAnimateIn['margin-left'] = '-=' + slideWidth;
|
||||||
|
// bodyAnimateIn['width'] = '+=' + slideWidth;
|
||||||
|
|
||||||
|
// for Orbit
|
||||||
|
// if($('#items').length) {
|
||||||
|
// $pageslide.css({'width': '324px'});
|
||||||
|
// slideWidth = $pageslide.outerWidth( true );
|
||||||
|
// } else {
|
||||||
|
// $pageslide.css({'width': '264px'});
|
||||||
|
// }
|
||||||
|
slideWidth = $pageslide.outerWidth( true );
|
||||||
|
bodyAnimateIn['margin-left'] = '-=' + slideWidth;
|
||||||
|
// bodyAnimateIn['width'] = '+=' + slideWidth;
|
||||||
|
if($pageslide.find('.preview').length) {
|
||||||
|
$pageslide.find('.preview').cycle('destroy');
|
||||||
|
$pageslide.find('.preview img').removeAttr('style');
|
||||||
|
}
|
||||||
|
//
|
||||||
|
|
||||||
|
slideAnimateIn['left'] = '-=' + slideWidth;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for Orbit
|
||||||
|
if($('#items').length) {
|
||||||
|
$(".navbar-inner").removeClass("active");
|
||||||
|
$('.item-menu > a, .navbar-inner').removeClass("active");
|
||||||
|
if(!$.support.touch) {
|
||||||
|
$('.item-menu').css({
|
||||||
|
'display': 'none',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if($('.tags-groups').length) {
|
||||||
|
$('.tags-groups').children('li').removeClass("active");
|
||||||
|
} else {
|
||||||
|
$("tr").removeClass("active");
|
||||||
|
};
|
||||||
|
//
|
||||||
|
|
||||||
|
$pageslide.animate(slideAnimateIn, speed);
|
||||||
|
$body.animate(bodyAnimateIn, speed, function() {
|
||||||
|
$pageslide.hide();
|
||||||
|
_sliding = false;
|
||||||
|
if( typeof callback != 'undefined' ) callback();
|
||||||
|
$body.css({'width': 'auto'});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Events */
|
||||||
|
|
||||||
|
// Don't let clicks to the pageslide close the window
|
||||||
|
$pageslide.click(function(e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Close the pageslide if the document is clicked or the users presses the ESC key, unless the pageslide is modal
|
||||||
|
$(document).bind('click keyup', function(e) {
|
||||||
|
// If this is a keyup event, let's see if it's an ESC key
|
||||||
|
if( e.type == "keyup" && e.keyCode != 27) return;
|
||||||
|
|
||||||
|
// Make sure it's visible, and we're not modal
|
||||||
|
if( $pageslide.is( ':visible' ) && !$pageslide.data( 'modal' ) ) {
|
||||||
|
$.pageslide.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
function setScroll(){
|
||||||
|
$pageslide.children('.nano').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true }); // set nano scroll
|
||||||
|
};
|
||||||
|
|
||||||
|
})(jQuery);
|
|
@ -0,0 +1,13 @@
|
||||||
|
/**
|
||||||
|
* jQuery.Preload
|
||||||
|
* https://github.com/htmlhero/jQuery.preload
|
||||||
|
*
|
||||||
|
* Created by Andrew Motoshin
|
||||||
|
* http://htmlhero.ru
|
||||||
|
*
|
||||||
|
* Version: 1.5.0
|
||||||
|
* Requires: jQuery 1.6+
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
!function(a){a.preload=function(){var b=[],c=function(a){for(var c=0;c<b.length;c++)if(b[c].src===a.src)return b[c];return b.push(a),a},d=function(a,b,c){"function"==typeof b&&b.call(a,c)};return function(b,e,f){if("undefined"!=typeof b){"string"==typeof b&&(b=[b]),2===arguments.length&&"function"==typeof e&&(f=e,e=0);var g,h=b.length;if(e>0&&h>e&&(g=b.slice(e,h),b=b.slice(0,e),h=b.length),!h)return d(b,f,!0),void 0;for(var i,j=arguments.callee,k=0,l=function(){k++,k===h&&(d(b,f,!g),j(g,e,f))},m=0;m<b.length;m++)i=new Image,i.src=b[m],i=c(i),i.complete?l():a(i).on("load error",l)}}}();var b=function(b,c){var d,e,f,g,h,i=[],j=new RegExp("url\\(['\"]?([^\"')]*)['\"]?\\)","i");return c.recursive&&(b=b.find("*").add(b)),b.each(function(){for(d=a(this),e=d.css("background-image")+","+d.css("border-image-source"),e=e.split(","),h=0;h<e.length;h++)f=e[h],-1===f.indexOf("about:blank")&&-1===f.indexOf("data:image")&&(g=j.exec(f),g&&i.push(g[1]));"IMG"===this.nodeName&&i.push(this.src)}),i};a.fn.preload=function(){var c,d;1===arguments.length?"object"==typeof arguments[0]?c=arguments[0]:d=arguments[0]:arguments.length>1&&(c=arguments[0],d=arguments[1]),c=a.extend({recursive:!0,part:0},c);var e=this,f=b(e,c);return a.preload(f,c.part,function(a){a&&"function"==typeof d&&d.call(e.get())}),this}}(jQuery);
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,11 @@
|
||||||
|
/*
|
||||||
|
* jQuery UI Touch Punch 0.2.2
|
||||||
|
*
|
||||||
|
* Copyright 2011, Dave Furfero
|
||||||
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||||
|
*
|
||||||
|
* Depends:
|
||||||
|
* jquery.ui.widget.js
|
||||||
|
* jquery.ui.mouse.js
|
||||||
|
*/
|
||||||
|
(function(b){b.support.touch="ontouchend" in document;if(!b.support.touch){return;}var c=b.ui.mouse.prototype,e=c._mouseInit,a;function d(g,h){if(g.originalEvent.touches.length>1){return;}g.preventDefault();var i=g.originalEvent.changedTouches[0],f=document.createEvent("MouseEvents");f.initMouseEvent(h,true,true,window,1,i.screenX,i.screenY,i.clientX,i.clientY,false,false,false,false,0,null);g.target.dispatchEvent(f);}c._touchStart=function(g){var f=this;if(a||!f._mouseCapture(g.originalEvent.changedTouches[0])){return;}a=true;f._touchMoved=false;d(g,"mouseover");d(g,"mousemove");d(g,"mousedown");};c._touchMove=function(f){if(!a){return;}this._touchMoved=true;d(f,"mousemove");};c._touchEnd=function(f){if(!a){return;}d(f,"mouseup");d(f,"mouseout");if(!this._touchMoved){d(f,"click");}a=false;};c._mouseInit=function(){var f=this;f.element.bind("touchstart",b.proxy(f,"_touchStart")).bind("touchmove",b.proxy(f,"_touchMove")).bind("touchend",b.proxy(f,"_touchEnd"));e.call(f);};})(jQuery);
|
|
@ -0,0 +1,111 @@
|
||||||
|
$(function() {
|
||||||
|
var ListCheckData = {},
|
||||||
|
ListCheck = function(element) {
|
||||||
|
this.element = $(element);
|
||||||
|
this.element.data('exists', true);
|
||||||
|
if(this.element.context.parentNode.tagName == "TD") {
|
||||||
|
this.elementWrap = $(this.element.context.parentNode);
|
||||||
|
this.elementWrap.addClass('listCheck');
|
||||||
|
} else if(this.element.context.parentNode.tagName == "TH") {
|
||||||
|
this.elementWrap = $(this.element.context.parentNode);
|
||||||
|
this.elementWrap.addClass('listCheckHead');
|
||||||
|
}
|
||||||
|
this.element.before('<i class="icon-check-empty" />');
|
||||||
|
};
|
||||||
|
|
||||||
|
$.fn.listCheck = function () {
|
||||||
|
$(this).each(function() {
|
||||||
|
var $this = $(this),
|
||||||
|
$el = $this.find('input[type="checkbox"]');
|
||||||
|
$el.each(function (i) {
|
||||||
|
if(!$(this).data('exists')) {
|
||||||
|
new ListCheck(this);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
$this.on(clickEvent, $el, function(e) {
|
||||||
|
if($(e.target).prop('checked')) {
|
||||||
|
$(e.target).siblings('i').addClass('icon-check').removeClass('icon-check-empty').closest('tr').addClass('checkHit');
|
||||||
|
} else {
|
||||||
|
$(e.target).siblings('i').addClass('icon-check-empty').removeClass('icon-check').closest('tr').removeClass('checkHit');
|
||||||
|
};
|
||||||
|
if($(e.target).closest('th').hasClass('listCheckHead')) {
|
||||||
|
$this.find('.listCheck input[type="checkbox"]').prop('checked', $(e.target).prop('checked'));
|
||||||
|
if($(e.target).prop('checked')) {
|
||||||
|
$this.find('.listCheck i').addClass('icon-check').removeClass('icon-check-empty').closest('tr').addClass('checkHit');
|
||||||
|
} else {
|
||||||
|
$this.find('.listCheck i').addClass('icon-check-empty').removeClass('icon-check').closest('tr').removeClass('checkHit');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var _isCheck = $this.find('tbody').find($el).filter(':checked').length,
|
||||||
|
_defaultLength = $this.find('tbody').find($el).length;
|
||||||
|
|
||||||
|
if(_isCheck > 0 && _isCheck < _defaultLength) {
|
||||||
|
$this.find('.listCheckHead i').removeClass('icon-check-empty icon-check').addClass('icon-minus');
|
||||||
|
} else if(!_isCheck) {
|
||||||
|
$this.find('.listCheckHead i').removeClass('icon-minus icon-check').addClass('icon-check-empty');
|
||||||
|
} else {
|
||||||
|
$this.find('.listCheckHead i').removeClass('icon-check-empty icon-minus').addClass('icon-check');
|
||||||
|
}
|
||||||
|
_isCheck ? $this.find('.list-active-btn').removeClass('disabled').data('actionable', true) : $this.find('.list-active-btn').addClass('disabled').data('actionable', false);
|
||||||
|
});
|
||||||
|
$this.on(clickEvent, '.list-active-btn', function(e) {
|
||||||
|
if(!$(this).hasClass('disabled')) {
|
||||||
|
ListCheckData.url = $(this).attr('rel');
|
||||||
|
ListCheckData.name = $this.find('tbody').find('input[type="checkbox"]').attr('name');
|
||||||
|
ListCheckData.action = $(this).data('checkAction');
|
||||||
|
ListCheckData.values = [];
|
||||||
|
ListCheckData.element = $this
|
||||||
|
$this.find('tbody').find('input[type="checkbox"]').each(function (i) {
|
||||||
|
this.checked && ListCheckData.values.push("ids[]=" + this.value);
|
||||||
|
});
|
||||||
|
console.log(ListCheckData.values.join("&"));
|
||||||
|
$('#dialog').modal('show');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
clearCheck($(this));
|
||||||
|
};
|
||||||
|
|
||||||
|
function clearCheck(element) {
|
||||||
|
element.find('input[type="checkbox"]').each(function() {
|
||||||
|
$(this).prop('checked', false).siblings('i').addClass('icon-check-empty').removeClass('icon-check').closest('tr').removeClass('checkHit');
|
||||||
|
});
|
||||||
|
element.find('.list-active-btn').addClass('disabled');
|
||||||
|
};
|
||||||
|
|
||||||
|
function actionSuccess(e) {
|
||||||
|
ListCheckData.element.find('tbody').find('input[type="checkbox"]').each(function() {
|
||||||
|
switch(e) {
|
||||||
|
case 'list-be-hide':
|
||||||
|
$(this).filter(':checked').closest('tr').addClass('checkHide');
|
||||||
|
break;
|
||||||
|
case 'list-be-show':
|
||||||
|
$(this).filter(':checked').closest('tr').removeClass('checkHide');
|
||||||
|
break;
|
||||||
|
case 'list-be-remove':
|
||||||
|
$(this).filter(':checked').closest('tr').fadeOut(300, function() {
|
||||||
|
$(this).remove();
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
$('.list-check').siblings('i').removeAttr('class').addClass('icon-check-empty').closest('tr').removeClass('checkHit');
|
||||||
|
});
|
||||||
|
clearCheck(ListCheckData.element);
|
||||||
|
}
|
||||||
|
$('.list-check').listCheck();
|
||||||
|
$('.delete-item').on(clickEvent, function() {
|
||||||
|
if(ListCheckData.url.indexOf("?") > -1) {
|
||||||
|
$.ajax(ListCheckData.url + "&" + ListCheckData.values.join("&")).done(function() {
|
||||||
|
actionSuccess(ListCheckData.action);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$.ajax(ListCheckData.url + "?" + ListCheckData.values.join("&")).done(function() {
|
||||||
|
actionSuccess(ListCheckData.action);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$('#dialog').modal('hide');
|
||||||
|
$('.list-active-btn').addClass('disabled').data('actionable', false);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,24 @@
|
||||||
|
function loadViewPage(url) {
|
||||||
|
var $listView = $('#list-view');
|
||||||
|
|
||||||
|
$listView.empty().removeClass('in active');
|
||||||
|
$listView.load(url, function(response, status, xhr) {
|
||||||
|
$(this).addClass('in active');
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
$viewType = window.localStorage.getItem('viewType') || '#member-list';
|
||||||
|
$viewSwitchNo = window.localStorage.getItem('viewSwitchNo') || 0;
|
||||||
|
loadViewPage('member-list.html ' + $viewType);
|
||||||
|
$('.view-switch').children('.btn').eq($viewSwitchNo).addClass('active');
|
||||||
|
$('.view-switch').delegate(".btn", clickEvent, function(e){
|
||||||
|
var url = $(this).attr('href'),
|
||||||
|
ID = url.split("#"),
|
||||||
|
ID = '#' + ID[ID.length-1];
|
||||||
|
window.localStorage.setItem('viewType', ID);
|
||||||
|
window.localStorage.setItem('viewSwitchNo', $(this).index());
|
||||||
|
loadViewPage(url);
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
})
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,3 @@
|
||||||
|
$(function() {
|
||||||
|
$('.member-avatar').rsImg();
|
||||||
|
})
|
|
@ -0,0 +1,18 @@
|
||||||
|
$(function() {
|
||||||
|
// for toggle-check
|
||||||
|
$('.role_filter_checked').on({
|
||||||
|
change: function() {
|
||||||
|
var _path = $(this).data('path');
|
||||||
|
// var path = <%= @path %>
|
||||||
|
$.ajax({
|
||||||
|
url: _path,
|
||||||
|
type: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
data: {remote: true},
|
||||||
|
})
|
||||||
|
.done(function() {})
|
||||||
|
.fail(function() {})
|
||||||
|
.always(function() {});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,58 @@
|
||||||
|
var H,P = [];
|
||||||
|
// Go to
|
||||||
|
!function ($) {
|
||||||
|
$.fn.goTo = function (){
|
||||||
|
var $this = this,
|
||||||
|
$destination = $this.attr('href'),
|
||||||
|
$offset = $($destination).offset();
|
||||||
|
$this.on(clickEvent, function() {
|
||||||
|
$("html, body").animate({
|
||||||
|
scrollTop: $offset.top,
|
||||||
|
}, 500);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}(window.jQuery);
|
||||||
|
function checkHeight() {
|
||||||
|
// if($('#member-module').height() > $(window).height()) {
|
||||||
|
// H = $(window).height()-
|
||||||
|
// parseInt($('.wrap-inner').css('padding-top'))+
|
||||||
|
// parseInt($('.wrap-inner').css('padding-bottom'))-
|
||||||
|
// $('#orbit-bar').outerHeight(true);
|
||||||
|
// }else{
|
||||||
|
// H = $(window).height()-
|
||||||
|
// parseInt($('.wrap-inner').css('padding-top'))+
|
||||||
|
// parseInt($('.wrap-inner').css('padding-bottom'))-
|
||||||
|
// $('#filter').outerHeight()+
|
||||||
|
// parseInt($('#filter').css('margin-bottom'))-
|
||||||
|
// $('#orbit-bar').outerHeight(true);
|
||||||
|
// };
|
||||||
|
H = $(window).height()-
|
||||||
|
parseInt($('.wrap-inner').css('padding-top'))-
|
||||||
|
$('#orbit-bar').outerHeight(true);
|
||||||
|
$('#basic-info').height(H);
|
||||||
|
$('#member-roles').height(H-$('.member-avatar').outerHeight(true)-parseInt($('#member-roles').css('margin-top'))+20);
|
||||||
|
$('#module-content').height(H-$('#module-navbar .navbar').outerHeight(true)-$('.bottomnav').innerHeight());
|
||||||
|
};
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
checkHeight();
|
||||||
|
$('.wrap-inner').css('padding-bottom', 0);
|
||||||
|
$(window).resize(checkHeight);
|
||||||
|
$('#member-roles h4 > span').each(function() {
|
||||||
|
$(this).css('margin-left',function() {
|
||||||
|
return $(this).innerWidth()/2*-1;
|
||||||
|
})
|
||||||
|
})
|
||||||
|
// $('#basic-info').scrollToFixed({
|
||||||
|
// marginTop: $('#orbit-bar').outerHeight(true)+20,
|
||||||
|
// });
|
||||||
|
// $('#module-navbar').scrollToFixed({
|
||||||
|
// marginTop: $('#orbit-bar').outerHeight(true),
|
||||||
|
// });
|
||||||
|
// $('.member-avatar').imagesLoaded(function() {
|
||||||
|
// $('#basic-info .member-avatar img').muImageResize({width: 100, height:100});
|
||||||
|
// });
|
||||||
|
$('.member-avatar').rsImg();
|
||||||
|
$('#member-roles, #module-content .nano').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true });
|
||||||
|
});
|
|
@ -0,0 +1,55 @@
|
||||||
|
jQuery(document).ready(function($) {
|
||||||
|
|
||||||
|
var selectAll = $( "#select_all_registration" ),
|
||||||
|
checkboxes = $( "input.select-this" ),
|
||||||
|
selectedBtns = $( "a.selected-actions" );
|
||||||
|
|
||||||
|
selectAll.bind(clickEvent,function(){
|
||||||
|
|
||||||
|
if( $( this ).is( ":checked" ) ){
|
||||||
|
checkboxes.prop( "checked", true );
|
||||||
|
selectedBtns.removeClass('hide');
|
||||||
|
}else{
|
||||||
|
checkboxes.prop( "checked", false );
|
||||||
|
selectedBtns.addClass('hide');
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
checkboxes.bind(clickEvent,function(){
|
||||||
|
var checkedCheckboxes = $( "input.select-this:checked" );
|
||||||
|
if( checkboxes.length == checkedCheckboxes.length ){
|
||||||
|
selectAll.prop( "checked", true );
|
||||||
|
}else{
|
||||||
|
selectAll.prop( "checked", false );
|
||||||
|
}
|
||||||
|
|
||||||
|
(checkedCheckboxes.length > 0 ? selectedBtns.removeClass('hide') : selectedBtns.addClass('hide'));
|
||||||
|
});
|
||||||
|
|
||||||
|
selectedBtns.bind(clickEvent,function(){
|
||||||
|
if( confirm("Are you sure?") ){
|
||||||
|
var userids = [],
|
||||||
|
_this = $( this ),
|
||||||
|
checkedCheckboxes = $( "input.select-this:checked" );
|
||||||
|
|
||||||
|
checkedCheckboxes.each(function(){
|
||||||
|
userids.push( $( this ).val() );
|
||||||
|
})
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url : _this.attr("href"),
|
||||||
|
type : "post",
|
||||||
|
dataType : "json",
|
||||||
|
data : {"userids" : userids},
|
||||||
|
success : function(data){
|
||||||
|
if( data.success == true){
|
||||||
|
window.location.href = data.url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
|
||||||
|
});
|
|
@ -0,0 +1,491 @@
|
||||||
|
// Retrieve the initial data
|
||||||
|
function temporary() {
|
||||||
|
attributesArray.length = 0;
|
||||||
|
$('.attributes').each(function() {
|
||||||
|
var attributesData = {},
|
||||||
|
$selectType = $('.dataType').data().type;
|
||||||
|
|
||||||
|
// Capture "attributes-body" within the input[type = "text"] val
|
||||||
|
$(this).find('.attributes-body').find('input[type="text"]').each(function(i) {
|
||||||
|
var $type = $(this).data().type;
|
||||||
|
attributesData[$type] = $(this).val();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Capture "attributes-body" within the input[type = "radio"] checked
|
||||||
|
$(this).find('.attributes-body').find('input[type="radio"]').each(function(i) {
|
||||||
|
var $type = $(this).data().type;
|
||||||
|
attributesData[$type] = $(this).prop("checked");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Capture "attributes-body" within the dataType selected
|
||||||
|
$(this).find('.attributes-body').find('.dataType').children("option:selected").each(function () {
|
||||||
|
attributesData[$selectType] = {};
|
||||||
|
attributesData[$selectType].index = $(this).index();
|
||||||
|
attributesData[$selectType].name = $(this).attr('ref');
|
||||||
|
if($(this).attr('ref') == 'typeB' || $(this).attr('ref') == 'typeE' || $(this).attr('ref') == 'typeF') {
|
||||||
|
attributesData[$selectType].option = [];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Capture "field-type" within the input[type = "text"] val
|
||||||
|
$(this).find('.field-type').find('input[type="text"]').each(function(i) {
|
||||||
|
var $type = $(this).data().type;
|
||||||
|
if(!$type.match('option_lang')) {
|
||||||
|
attributesData[$selectType][$type] = $(this).val();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(this).find('.field-type .add-target').find('.input-append').each(function() {
|
||||||
|
var append = []
|
||||||
|
$(this).children('input[type="text"]').each(function() {
|
||||||
|
var val = $(this).val();
|
||||||
|
append.push(val);
|
||||||
|
});
|
||||||
|
attributesData[$selectType].option.push(append);
|
||||||
|
})
|
||||||
|
|
||||||
|
// Capture "field-type" within the input[type = "checkbox"] checked
|
||||||
|
$(this).find('.field-type').find('input[type="checkbox"]').each(function() {
|
||||||
|
var $type = $(this).data().type;
|
||||||
|
attributesData[$selectType][$type] = $(this).prop("checked");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Capture "field-type" within the input[type = "radio"] checked
|
||||||
|
$(this).find('.field-type').find('input[type="radio"]').each(function() {
|
||||||
|
var $type = $(this).data().type;
|
||||||
|
attributesData[$selectType][$type] = $(this).prop("checked");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Capture "field-type" within the dataType selected
|
||||||
|
$(this).find('.field-type').find('select').children("option:selected").each(function () {
|
||||||
|
attributesData[$selectType].dateFormat = $(this).index();
|
||||||
|
});
|
||||||
|
|
||||||
|
attributesArray.push(attributesData);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Determine the Append input length
|
||||||
|
function inputAppendLength() {
|
||||||
|
$('.add-target').each(function(i) {
|
||||||
|
if($(this).children('.input-append:not(:hidden)').length == 1 || $(this).children('.input-append').length == 1) {
|
||||||
|
$(this).children('.input-append').each(function() {
|
||||||
|
if($(this).children('div').hasClass('tab-content')) {
|
||||||
|
var btnLength = $(this).children('.btn').length;
|
||||||
|
$(this).find('.btn').eq(btnLength-2).addClass('last');
|
||||||
|
$(this).find('.remove-input').addClass('hide');
|
||||||
|
} else {
|
||||||
|
var mediumLength = $(this).children('.input-medium').length;
|
||||||
|
$(this).children('.input-medium').eq(mediumLength-1).addClass('last');
|
||||||
|
$(this).children('.remove-input').addClass('hide');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$(this).children('.input-append').each(function() {
|
||||||
|
if($(this).children('div').hasClass('tab-content')) {
|
||||||
|
$(this).find('.btn').removeClass('last');
|
||||||
|
$(this).find('.remove-input').removeClass('hide');
|
||||||
|
} else {
|
||||||
|
$(this).children('.input-medium').removeClass('last');
|
||||||
|
$(this).children('.remove-input').removeClass('hide');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Role Attribute Template Data
|
||||||
|
function setData(l, type, ol) {
|
||||||
|
var fields = $('#info').length ? "info[attribute_fields]" : $('#sub_role').length ? "sub_role[attribute_fields]" : "role[attribute_fields]",
|
||||||
|
data = {
|
||||||
|
_add_more: ["add_more_" +l, fields+"["+l+"]["+type+"][add_more]"],
|
||||||
|
_calendar: ["calendar_" +l, fields+"["+l+"]["+type+"][calendar]"],
|
||||||
|
_cross_lang: ["cross_lang_" +l, fields+"["+l+"]["+type+"][cross_lang]"],
|
||||||
|
_disabled: ["disabled_" +l, fields+"["+l+"][disabled]"],
|
||||||
|
_format: ["format_" +l, fields+"["+l+"]["+type+"][format]"],
|
||||||
|
_initial: ["initial_" +l, fields+"["+l+"]["+type+"][initial]"],
|
||||||
|
_is_range: ["is_range_" +l, fields+"["+l+"]["+type+"][is_range]"],
|
||||||
|
_key: ["key_" +l, fields+"["+l+"][key]"],
|
||||||
|
_markup: fields+"["+l+"][markup]",
|
||||||
|
_option_list: ["option_list_"+l+"_"+ol, fields+"["+l+"]["+type+"][option_list]["+ol+"]", "option_list_"+ol],
|
||||||
|
_placeholder: ["placeholder_" +l, fields+"["+l+"]["+type+"][placeholder]"],
|
||||||
|
_title_translations: ["title_translations_" +l, fields+"["+l+"][title_translations]"],
|
||||||
|
_to_delete: ["to_delete_" +l, fields+"["+l+"][to_delete]"],
|
||||||
|
_to_search: ["to_search_" +l, fields+"["+l+"][to_search]"],
|
||||||
|
_to_show: ["to_show_" +l, fields+"["+l+"][to_show]"],
|
||||||
|
};
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get Default Address Form
|
||||||
|
function getAddressForm(trigger, element, decide) {
|
||||||
|
if(decide) {
|
||||||
|
addressVal.length = addressArray.length = 0;
|
||||||
|
var addressAllVal = [];
|
||||||
|
var inputNameArray = [];
|
||||||
|
trigger.closest('.input-append').find('.tab-pane').each(function() {
|
||||||
|
var adderssText = $(this).children('input[type="text"]').val(),
|
||||||
|
addersshidden = '',
|
||||||
|
addressData = {},
|
||||||
|
inputName = [];
|
||||||
|
$(this).children('input:not(:first)').each(function(j) {
|
||||||
|
var name = $(this).attr('name'),
|
||||||
|
val = $(this).val();
|
||||||
|
addersshidden += val;
|
||||||
|
addressData[name] = val;
|
||||||
|
inputName.push(name);
|
||||||
|
});
|
||||||
|
addressArray.push(addressData);
|
||||||
|
addressAllVal.push(adderssText);
|
||||||
|
inputNameArray.push(inputName);
|
||||||
|
if(adderssText != addersshidden) {
|
||||||
|
addressVal.push(false);
|
||||||
|
} else {
|
||||||
|
addressVal.push(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
element.find('.tab-pane').each(function(i) {
|
||||||
|
$(this).find('textarea, input[type="text"]').each(function(j) {
|
||||||
|
$(this).attr('name',inputNameArray[i][j]);
|
||||||
|
});
|
||||||
|
if(addressVal[i]) {
|
||||||
|
$(this).find('textarea, input[type="text"]').each(function(j) {
|
||||||
|
$(this).val(addressArray[i][$(this).attr('name')]);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$(this).find('textarea').val(addressAllVal[i]);
|
||||||
|
$(this).find('input[type="text"]').each(function(j) {
|
||||||
|
$(this).val('');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
element.off('show');
|
||||||
|
};
|
||||||
|
|
||||||
|
// Return Address Form
|
||||||
|
function returnAddressForm(element, decide) {
|
||||||
|
if(decide) {
|
||||||
|
addressArray.length = 0;
|
||||||
|
element.find('.tab-pane').each(function(i) {
|
||||||
|
var addressData = {};
|
||||||
|
$(this).find('textarea, input[type="text"]').each(function(j) {
|
||||||
|
var name = $(this).attr('name'),
|
||||||
|
val = $(this).val();
|
||||||
|
addressData[name] = val;
|
||||||
|
});
|
||||||
|
addressArray.push(addressData);
|
||||||
|
});
|
||||||
|
$.map(addressInputId, function(n, i) {
|
||||||
|
var v = '';
|
||||||
|
$('#'+n).find('input[type="hidden"]').each(function() {
|
||||||
|
$(this).val(addressArray[i][$(this).attr('name')]);
|
||||||
|
v += addressArray[i][$(this).attr('name')]
|
||||||
|
});
|
||||||
|
$('#'+n).find('input[type="text"]').each(function() {
|
||||||
|
$(this).val(v);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
returnDecide = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
appendIndex = null;
|
||||||
|
if($('#user-forms').length) {
|
||||||
|
addressVal = [];
|
||||||
|
addressArray = [];
|
||||||
|
addressInputId = [];
|
||||||
|
roleType = null;
|
||||||
|
returnDecide = false;
|
||||||
|
$('.attributes').each(function() {
|
||||||
|
if($(this).find('.toggle-check').attr('value') == "true") {
|
||||||
|
$(this).addClass('disabled').children('.attributes-body').hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('.returnDecide').on(clickEvent, function() {
|
||||||
|
returnDecide = true;
|
||||||
|
})
|
||||||
|
$('#address-field').on('hidden', function () {
|
||||||
|
$('.btn[data-toggle="modal"]').removeClass('active').blur();
|
||||||
|
$(this).find('.nav-tabs > li').removeClass('active').eq(0).addClass('active');
|
||||||
|
$(this).find('.tab-content > .tab-pane').removeClass('active in').eq(0).addClass('active in');
|
||||||
|
$(this).on('show', getAddressForm(null, $(this), false));
|
||||||
|
returnAddressForm($(this), returnDecide)
|
||||||
|
});
|
||||||
|
$('.control-group').delegate('.btn[data-toggle="modal"]', 'click', function() {
|
||||||
|
var $trigger = $(this);
|
||||||
|
addressInputId.length = 0;
|
||||||
|
$(this).closest('.input-append').find('.tab-pane').each(function() {
|
||||||
|
addressInputId.push($(this).attr('id'));
|
||||||
|
});
|
||||||
|
$('#address-field').on('show', getAddressForm($trigger, $('#address-field'), true));
|
||||||
|
});
|
||||||
|
$('#user-forms').delegate('.togglebox, .delete, .trigger, .remove-input', clickEvent, function(event) {
|
||||||
|
if($(this).hasClass('togglebox')) {
|
||||||
|
if($(this).hasClass('disable')) {
|
||||||
|
$(this).find('.toggle-check')
|
||||||
|
.attr('value', 'false')
|
||||||
|
.closest('.attributes')
|
||||||
|
.removeClass('disabled')
|
||||||
|
.children('.attributes-body')
|
||||||
|
.fadeIn(300);
|
||||||
|
} else {
|
||||||
|
$(this).find('.toggle-check')
|
||||||
|
.attr('value', 'true')
|
||||||
|
.closest('.attributes')
|
||||||
|
.addClass('disabled')
|
||||||
|
.children('.attributes-body')
|
||||||
|
.fadeOut(300);
|
||||||
|
}
|
||||||
|
$(this).toggleClass('disable');
|
||||||
|
};
|
||||||
|
if($(this).hasClass('remove-input')) {
|
||||||
|
$(this).closest('.input-append').fadeOut(300, function() {
|
||||||
|
$(this).remove();
|
||||||
|
inputAppendLength();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
if($(this).hasClass('trigger')) {
|
||||||
|
appendIndex = $(this).closest('.controls').find('.input-append').length;
|
||||||
|
nameNumber = $(this).closest('.controls').find('.input-append:eq(0)').find('input').eq(0).attr('name');
|
||||||
|
nameNumber = nameNumber.match(/[^[\D\]]+(?=])/g)[0];
|
||||||
|
roleType = $(this).data('roles')
|
||||||
|
if($(this).hasClass('textInput')) {
|
||||||
|
$("#template-text").tmpl().appendTo($(this).closest('.controls').find('.add-target'));
|
||||||
|
} else if ($(this).hasClass('textLengInput')) {
|
||||||
|
$("#template-text-language").tmpl().appendTo($(this).closest('.controls').find('.add-target'));
|
||||||
|
} else if ($(this).hasClass('address')) {
|
||||||
|
$("#template-address").tmpl().appendTo($(this).closest('.controls').find('.add-target'));
|
||||||
|
}
|
||||||
|
inputAppendLength();
|
||||||
|
};
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
inputAppendLength();
|
||||||
|
} else {
|
||||||
|
attributesArray = [];
|
||||||
|
attributesHeaderLength = null;
|
||||||
|
templateType = null;
|
||||||
|
attributeIndex = null;
|
||||||
|
if($('.add-target').length) {
|
||||||
|
inputAppendLength();
|
||||||
|
}
|
||||||
|
if(!$('.attributes').length) {
|
||||||
|
$('#attributes-area').addClass('clickHere');
|
||||||
|
} else {
|
||||||
|
temporary();
|
||||||
|
};
|
||||||
|
|
||||||
|
$('.add-attributes').on(clickEvent, function() {
|
||||||
|
if($('#attributes-area').hasClass('clickHere')) {
|
||||||
|
$('#attributes-area').removeClass('clickHere');
|
||||||
|
};
|
||||||
|
attributesHeaderLength = $('.attributes:not(:hidden)').length+1;
|
||||||
|
attributesLength = $('#attributes-area .attributes').length;
|
||||||
|
$("#template-attributes").tmpl(setData(attributesLength, templateType, appendIndex)).appendTo( "#attributes-area" );
|
||||||
|
$('.toggle-check').togglebox();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$('.attributes.default').each(function(i) {
|
||||||
|
$(this).children('.field-type').not('.default').hide();
|
||||||
|
$(this).find('input[type="text"]').on('keyup', function() {
|
||||||
|
$(this).trigger("checking");
|
||||||
|
});
|
||||||
|
$(this).find('input[type="radio"], input[type="checkbox"], select').change(function() {
|
||||||
|
$(this).trigger("checking");
|
||||||
|
});
|
||||||
|
$(this).delegate('input[type="text"], input[type="radio"], input[type="checkbox"], select', 'checking', function(e) {
|
||||||
|
var e = e.target.type,
|
||||||
|
$data = $(this).data().type;
|
||||||
|
switch(e) {
|
||||||
|
case 'text':
|
||||||
|
var val = $(this).val();
|
||||||
|
if(!$(this).closest('.field-type').length) {
|
||||||
|
$data = attributesArray[i][$data];
|
||||||
|
} else if(!$(this).closest('.add-target').length) {
|
||||||
|
$data = attributesArray[i].select[$data];
|
||||||
|
} else {
|
||||||
|
appendIndex = $(this).parent('.input-append').index()
|
||||||
|
optionIndex = $(this).index()
|
||||||
|
$data = attributesArray[i].select.option[appendIndex][optionIndex];
|
||||||
|
}
|
||||||
|
if(val != $data) {
|
||||||
|
$(this).closest('.attributes').find('.reply').removeClass('hide');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'radio':
|
||||||
|
var checked = $(this).prop("checked");
|
||||||
|
$data = attributesArray[i][$data];
|
||||||
|
if(checked != $data) {
|
||||||
|
$(this).closest('.attributes').find('.reply').removeClass('hide');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'checkbox':
|
||||||
|
var checked = $(this).prop("checked");
|
||||||
|
$data = attributesArray[i].select[$data];
|
||||||
|
if(checked != $data) {
|
||||||
|
$(this).closest('.attributes').find('.reply').removeClass('hide');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'select-one':
|
||||||
|
var ref,
|
||||||
|
$data = attributesArray[i].select.name;
|
||||||
|
$(this).children("option:selected").each(function() {
|
||||||
|
ref = $(this).attr('ref');
|
||||||
|
});
|
||||||
|
if(ref != $data) {
|
||||||
|
$(this).closest('.attributes').find('.reply').removeClass('hide');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
$(this).delegate('.reply', clickEvent, function() {
|
||||||
|
var $bodyText = $(this).parent('.attributes-header').siblings('.attributes-body').find('input[type="text"]'),
|
||||||
|
$bodyRadio = $(this).parent('.attributes-header').siblings('.attributes-body').find('input[type="radio"]'),
|
||||||
|
$bodySelected = $(this).parent('.attributes-header').siblings('.attributes-body').find('.dataType').children("option"),
|
||||||
|
$fieldTypeO = $(this).parent('.attributes-header').siblings('.field-type.default'),
|
||||||
|
$fieldTypeN = $(this).parent('.attributes-header').siblings('.field-type').not('.default');
|
||||||
|
$bodyText.each(function() {
|
||||||
|
var $type = $(this).data().type;
|
||||||
|
$(this).val(attributesArray[i][$type]);
|
||||||
|
});
|
||||||
|
$bodyRadio.each(function() {
|
||||||
|
var $type = $(this).data().type;
|
||||||
|
$(this).prop("checked", attributesArray[i][$type])
|
||||||
|
});
|
||||||
|
$fieldTypeO.find('input[type="text"]').each(function() {
|
||||||
|
var $type = $(this).data().type;
|
||||||
|
if(!$type.match('option_lang')) {
|
||||||
|
$(this).val(attributesArray[i].select[$type]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$fieldTypeO.find('.add-target').find('.input-append').each(function(k) {
|
||||||
|
$(this).children('input[type="text"]').each(function(j) {
|
||||||
|
$(this).val(attributesArray[i].select.option[k][j]);
|
||||||
|
// var val = $(this).val();
|
||||||
|
// append.push(val);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
$fieldTypeO.find('input[type="checkbox"], input[type="radio"]').each(function() {
|
||||||
|
var $type = $(this).data().type;
|
||||||
|
$(this).prop("checked", attributesArray[i].select[$type]);
|
||||||
|
});
|
||||||
|
$fieldTypeO.find('select').children("option").eq(attributesArray[i].select.dateFormat).prop('selected',true);
|
||||||
|
$bodySelected.eq(attributesArray[i].select.index).prop('selected',true);
|
||||||
|
$fieldTypeO.show();
|
||||||
|
$fieldTypeN.empty().hide();
|
||||||
|
$(this).addClass('hide')
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
});
|
||||||
|
$('#attributes-area').delegate('.togglebox, .delete, .trigger, .remove-input', clickEvent, function(event) {
|
||||||
|
if($(this).hasClass('togglebox')) {
|
||||||
|
if($(this).hasClass('disable')) {
|
||||||
|
$(this).find('.toggle-check')
|
||||||
|
.attr('value', 'false')
|
||||||
|
.closest('.attributes')
|
||||||
|
.removeClass('disabled')
|
||||||
|
.find('input, select')
|
||||||
|
.removeAttr('disabled')
|
||||||
|
.end('.attributes')
|
||||||
|
.find('.btn-group .btn')
|
||||||
|
.removeClass('disabled')
|
||||||
|
.end().find('.attribute_field_disabled').attr('value', 'false');
|
||||||
|
if($(this).closest('.attributes').find('.dataType').children("option:selected").attr('ref')) {
|
||||||
|
$(this).closest('.attributes').find('.field-type').addClass('in').find('.control-group').delay(150).fadeIn(300);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$(this).find('.toggle-check')
|
||||||
|
.attr('value', 'true')
|
||||||
|
.closest('.attributes')
|
||||||
|
.addClass('disabled')
|
||||||
|
.find('.attributes-body input, .attributes-body select')
|
||||||
|
.attr({'disabled': 'disabled'})
|
||||||
|
.end('.attributes')
|
||||||
|
.find('.btn-group .btn')
|
||||||
|
.addClass('disabled')
|
||||||
|
.end().find('.attribute_field_disabled').attr('value', 'true')
|
||||||
|
.end().find('.field-type .control-group').fadeOut(300, function() {
|
||||||
|
$(this).parent('.field-type').removeClass('in');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$(this).toggleClass('disable');
|
||||||
|
};
|
||||||
|
if($(this).hasClass('delete')) {
|
||||||
|
$(this).closest('.attributes').fadeOut(300, function() {
|
||||||
|
$('.attributes:not(:hidden)').each(function(i) {
|
||||||
|
$(this).find('.attributes-header h4 span').text(i+1);
|
||||||
|
});
|
||||||
|
attributesHeaderLength = $('.attributes:not(:hidden)').length+1;
|
||||||
|
if(!$('.attributes:not(:hidden)').length) {
|
||||||
|
$('#attributes-area').addClass('clickHere');
|
||||||
|
};
|
||||||
|
}).find('.attribute_field_to_delete').attr('value', 'true');;
|
||||||
|
};
|
||||||
|
if($(this).hasClass('trigger')) {
|
||||||
|
// appendIndex = $(this).closest('.controls').find('.input-append').length;
|
||||||
|
appendIndex = $(this).closest('.controls').find('.input-append:last-child').children('input:first-child').attr('name');
|
||||||
|
// appendIndex = appendIndex.split("][");
|
||||||
|
// appendIndex = parseInt(appendIndex[appendIndex.length-2])+1;
|
||||||
|
appendIndex = parseInt(appendIndex.match(/[^[\D\]]+(?=])/g)[1])+1;
|
||||||
|
console.log(appendIndex)
|
||||||
|
attributeIndex = $(this).closest('.attributes').index();
|
||||||
|
templateType = $(this).closest('.attributes').find('.dataType').children("option:selected").attr('ref');
|
||||||
|
$("#template-input-append").tmpl(setData(attributeIndex, templateType, appendIndex)).appendTo($(this).closest('.controls').find('.add-target'));
|
||||||
|
inputAppendLength();
|
||||||
|
};
|
||||||
|
if($(this).hasClass('remove-input')) {
|
||||||
|
$(this).parent('.input-append').fadeOut(300, function() {
|
||||||
|
$(this).remove()
|
||||||
|
inputAppendLength();
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
});
|
||||||
|
$('#attributes-area').delegate('.dataType', 'change', function() {
|
||||||
|
$(this).children("option:selected").each(function () {
|
||||||
|
var target = $(this).closest('.attributes').find('.field-type').not('.default');
|
||||||
|
attributeIndex = $(this).closest('.attributes').index();
|
||||||
|
appendIndex = 0
|
||||||
|
// $(this).closest('.attributes').find('.add-target').find('.input-append').length;
|
||||||
|
if($(this).closest('.attributes').hasClass('default')){
|
||||||
|
var i = $(this).closest('.attributes').index()
|
||||||
|
if($(this).attr('ref') == attributesArray[i].select.name) {
|
||||||
|
$(this).closest('.attributes').find('.field-type.default').show()
|
||||||
|
target.empty().hide();
|
||||||
|
} else {
|
||||||
|
$(this).closest('.attributes').find('.field-type.default').hide()
|
||||||
|
if($(this).attr('ref')) {
|
||||||
|
templateType = $(this).attr('ref');
|
||||||
|
target.removeAttr('class').addClass('field-type fade in ' + templateType).empty();
|
||||||
|
$("#template-type").tmpl(setData(attributeIndex, templateType, appendIndex)).appendTo(target);
|
||||||
|
if(templateType == 'typeB' || templateType == 'typeE' || templateType == 'typeF') {
|
||||||
|
inputAppendLength();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
target.removeAttr('class').addClass('field-type fade')
|
||||||
|
target.empty();
|
||||||
|
};
|
||||||
|
target.show();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if($(this).attr('ref')) {
|
||||||
|
templateType = $(this).attr('ref');
|
||||||
|
target.removeAttr('class').addClass('field-type fade in ' + templateType).empty();
|
||||||
|
$("#template-type").tmpl(setData(attributeIndex, templateType, appendIndex)).appendTo(target);
|
||||||
|
if(templateType == 'typeB' || templateType == 'typeE' || templateType == 'typeF') {
|
||||||
|
inputAppendLength();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
target.removeAttr('class').addClass('field-type fade')
|
||||||
|
target.empty();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,56 @@
|
||||||
|
function dragMode() {
|
||||||
|
$('#card-list').sortable({
|
||||||
|
placeholder: "highlight",
|
||||||
|
update: function( event, ui ) {
|
||||||
|
var _userPosition = {};
|
||||||
|
_userPosition.position = $(ui.item).index();
|
||||||
|
_userPosition.id = $(ui.item).data('user-id');
|
||||||
|
$.ajax({
|
||||||
|
url: "<%= Rails.application.routes.url_helpers.update_order_card_admin_users_new_interface_index_path %>",
|
||||||
|
type: 'POST',
|
||||||
|
dataType: 'script',
|
||||||
|
data: {users: _userPosition}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#card-list').disableSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
function typeMode() {
|
||||||
|
var _userPosition = [];
|
||||||
|
$('#list-view tbody tr').each(function(i) {
|
||||||
|
$(this).data('user-index', i);
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#member-list').on(clickEvent, '.edit_position', function(e){
|
||||||
|
var $input = $('<input type="text">'),
|
||||||
|
$cross = $('<a class="btn btn-mini"><i class="icons-cross"/></a>');
|
||||||
|
if($(this).siblings('input').length) {
|
||||||
|
$(this).siblings('input').attr('type', 'text').after($cross);
|
||||||
|
} else {
|
||||||
|
$(this).after($cross);
|
||||||
|
$(this).after($input);
|
||||||
|
}
|
||||||
|
$(this).hide();
|
||||||
|
$input.val($(this).text());
|
||||||
|
e.preventDefault();
|
||||||
|
$cross.click(function(event) {
|
||||||
|
$input.remove();
|
||||||
|
$(this).siblings('a').show().end().remove();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.bottomnav').on(clickEvent, '.btn', function(e) {
|
||||||
|
_userPosition = [];
|
||||||
|
$('#member-list tbody input').each(function(i) {
|
||||||
|
_userPosition.push([$(this).val(), $(this).siblings('a').data('user-id')]);
|
||||||
|
});
|
||||||
|
$.ajax({
|
||||||
|
url: "<%= Rails.application.routes.url_helpers.update_order_list_admin_users_new_interface_index_path %>",
|
||||||
|
type: 'POST',
|
||||||
|
dataType: 'script',
|
||||||
|
data: {users: _userPosition}
|
||||||
|
});
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
};
|
|
@ -0,0 +1,32 @@
|
||||||
|
function textareaResizable() {
|
||||||
|
var $btnW = null,
|
||||||
|
$textareaLangBtnGroup = $('.textarea-lang > .btn-group'),
|
||||||
|
$textareaLang = $('.textarea-lang'),
|
||||||
|
$textareaTab = $('.textarea-lang > .tab-pane'),
|
||||||
|
$textarea = $('.textarea-lang > .tab-pane > .resizable');
|
||||||
|
$textareaLangBtnGroup.each(function() {
|
||||||
|
$btnW = 4
|
||||||
|
$(this).find('.btn').each(function() {
|
||||||
|
$btnW += $(this).outerWidth(true);
|
||||||
|
$(this).on(clickEvent, function() {
|
||||||
|
var $id = $($(this).attr('href'));
|
||||||
|
if($id.find('.ui-wrapper').height() < 96) {
|
||||||
|
$id.find('.ui-wrapper').height(96)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$textarea.each(function() {
|
||||||
|
$(this).width($btnW+100);
|
||||||
|
});
|
||||||
|
$textarea.resizable({
|
||||||
|
maxHeight: 250,
|
||||||
|
maxWidth: 500,
|
||||||
|
minHeight: 100,
|
||||||
|
minWidth: $btnW+114,
|
||||||
|
handles: "se",
|
||||||
|
});
|
||||||
|
};
|
||||||
|
$(function() {
|
||||||
|
textareaResizable();
|
||||||
|
});
|
|
@ -0,0 +1,73 @@
|
||||||
|
$(function() {
|
||||||
|
$(".post_preview").click(function(){
|
||||||
|
$("#main-wrap").after("<span id='show_preview'></span>");
|
||||||
|
|
||||||
|
var preview_url = $(this).attr('url');
|
||||||
|
|
||||||
|
$("form.previewable").ajaxSubmit({
|
||||||
|
beforeSubmit: function(a,f,o){
|
||||||
|
o.dataType = 'script';
|
||||||
|
o.url = preview_url;
|
||||||
|
o.type = 'post';
|
||||||
|
},success: function(msg) {
|
||||||
|
$('#show_preview .modal').modal()
|
||||||
|
$('#show_preview .modal').height(function() {
|
||||||
|
return $(window).height() * 0.7;
|
||||||
|
});
|
||||||
|
}});
|
||||||
|
});
|
||||||
|
$(".preview_trigger").click(function(){
|
||||||
|
$("#main-wrap").after("<span id='show_preview'></span>");
|
||||||
|
$.ajax({
|
||||||
|
type: 'PUT',
|
||||||
|
url: $(this).attr("href"),
|
||||||
|
data: $(this).parents("form").serialize(),
|
||||||
|
success: function (msg) {
|
||||||
|
$('#show_preview .modal').modal();
|
||||||
|
$('#show_preview .modal').height(function() {
|
||||||
|
return $(window).height() * 0.7;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error: function(){
|
||||||
|
alert("ERROR");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
// $('#main-wrap').on(clickEvent, '.post_preview, .preview_trigger', function(e) {
|
||||||
|
// $("#main-wrap").after("<span id='show_preview'></span>");
|
||||||
|
// if($(this).hasClass('post_preview')) {
|
||||||
|
// var attrs = e.target.attributes;
|
||||||
|
// var url = attrs['url'];
|
||||||
|
// $("form.previewable").ajaxSubmit({
|
||||||
|
// beforeSubmit: function(a,f,o){
|
||||||
|
// o.dataType = 'script';
|
||||||
|
// o.url = url.nodeValue;
|
||||||
|
// o.type = 'post';
|
||||||
|
// },success: function(msg) {
|
||||||
|
// $('#show_preview .modal').modal()
|
||||||
|
// $('#show_preview .modal').height(function() {
|
||||||
|
// return $(window).height() * 0.7;
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// });
|
||||||
|
// } else if($(this).hasClass('preview_trigger')) {
|
||||||
|
// $.ajax({
|
||||||
|
// type: 'PUT',
|
||||||
|
// url: $(this).attr("href"),
|
||||||
|
// data: $(this).parents("form").serialize(),
|
||||||
|
// success: function (msg) {
|
||||||
|
// $('#show_preview .modal').modal();
|
||||||
|
// $('#show_preview .modal').height(function() {
|
||||||
|
// return $(window).height() * 0.7;
|
||||||
|
// });
|
||||||
|
// },
|
||||||
|
// error: function(){
|
||||||
|
// alert("ERROR");
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
});
|
|
@ -0,0 +1,8 @@
|
||||||
|
$(function() {
|
||||||
|
$('.module-area [data-toggle=buttons-checkbox]').find('input[type="checkbox"]').each(function() {
|
||||||
|
$(this).prop('checked') ? $(this).siblings('input[type="hidden"]').val(1) : $(this).siblings('input[type="hidden"]').val(0);
|
||||||
|
});
|
||||||
|
$('.module-area').delegate('input[type="checkbox"]', clickEvent, function(event) {
|
||||||
|
$(this).prop('checked') ? $(this).siblings('input[type="hidden"]').val(1) : $(this).siblings('input[type="hidden"]').val(0);
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,60 @@
|
||||||
|
// Search Clear
|
||||||
|
!function ($) {
|
||||||
|
$.fn.searchClear = function (param){
|
||||||
|
_defaultSettings = {
|
||||||
|
inputName: ':input',
|
||||||
|
inputIcon: 'inputIcon',
|
||||||
|
clearBtnIcon: 'clearBtnIcon',
|
||||||
|
};
|
||||||
|
_set = $.extend(_defaultSettings, param);
|
||||||
|
$this = this;
|
||||||
|
$input = this.find(_set.inputName);
|
||||||
|
$tmp = '<i class="'+_set.inputIcon+'"></i><i class="'+_set.clearBtnIcon+' search-clear"></i>';
|
||||||
|
$input.wrap('<div class="sc-field" />');
|
||||||
|
$this.find('.sc-field').prepend($tmp);
|
||||||
|
$searchClear = $this.find(".search-clear");
|
||||||
|
function run(e) {
|
||||||
|
$searchClear.hide();
|
||||||
|
if($input.val().length > 0) {
|
||||||
|
$searchClear.show();
|
||||||
|
}else {
|
||||||
|
$searchClear.hide();
|
||||||
|
}
|
||||||
|
$input.on("blur keyup", function(){
|
||||||
|
if($(this).val().length > 0) {
|
||||||
|
$searchClear.show();
|
||||||
|
}else {
|
||||||
|
$searchClear.hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$searchClear.on({
|
||||||
|
click: function(){
|
||||||
|
$(this).hide();
|
||||||
|
$input.val("")
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checking IE10
|
||||||
|
// if Windows 8 and IE is ture. remove search clear buttom and fix text input padding-right
|
||||||
|
if(/Windows NT 6.2/g.test(navigator.userAgent)){
|
||||||
|
if(/MSIE/g.test(navigator.userAgent)){
|
||||||
|
$searchClear.remove();
|
||||||
|
$input.css({
|
||||||
|
'padding-right': '5px',
|
||||||
|
});
|
||||||
|
}else{run()}
|
||||||
|
}else{run()}
|
||||||
|
}
|
||||||
|
}(window.jQuery);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var $moduleWidth = 0,
|
||||||
|
$moduleNav = $('.module-nav');
|
||||||
|
|
||||||
|
var navMenu = new iScroll(document.getElementsByClassName('nav-scroll')[0], {
|
||||||
|
snap: true,
|
||||||
|
momentum: false,
|
||||||
|
hScrollbar: false,
|
||||||
|
});
|
|
@ -0,0 +1,347 @@
|
||||||
|
!function ($) {
|
||||||
|
// Convenience vars for accessing elements
|
||||||
|
var $pageslide = $('#pageslide'),
|
||||||
|
$body = $('#main-wrap'),
|
||||||
|
$bottomNav = $('.bottomnav'),
|
||||||
|
$element;
|
||||||
|
if($pageslide.length == 0) {
|
||||||
|
var _html = '<div id="pageslide"><div class="page-title clearfix"><a class="pull-right" href="javascript:$.pageslide.close()"><i class="icons-arrow-left-2"/></a><span/></div><div class="view-page"><div class="nano"><div class="content"/></div></div></div>';
|
||||||
|
$pageslide = $(_html).css('display', 'none').appendTo( $body );
|
||||||
|
} else {
|
||||||
|
$pageslide.css('display', 'none')
|
||||||
|
}
|
||||||
|
|
||||||
|
var _sliding = false, // Mutex to assist closing only once
|
||||||
|
_lastCaller; // Used to keep track of last element to trigger pageslide
|
||||||
|
// $(window).resize(function(event) {
|
||||||
|
// if($pageslide.is(':visible')) {
|
||||||
|
// console.log("ddd")
|
||||||
|
// $pageslide.find('.nano').height($('body').height() - $('#orbit-bar').height() - $pageslide.find('.page-title').outerHeight(true));
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
function _checkTitle(settings) {
|
||||||
|
if(settings.pageTitle) {
|
||||||
|
$pageslide.find('.page-title').show().children('span').text(settings.pageTitle);
|
||||||
|
$pageslide.find('.view-page').css('top', 48);
|
||||||
|
} else {
|
||||||
|
$pageslide.find('.page-title').hide();
|
||||||
|
$pageslide.find('.view-page').css('top', 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function _load(settings) {
|
||||||
|
// Are we loading an element from the page or a URL?
|
||||||
|
if ( settings.href.indexOf("#") === 0 ) {
|
||||||
|
// Load a page element
|
||||||
|
window.console.log("in HTML");
|
||||||
|
var _contentHtml = $(settings.href).html();
|
||||||
|
var dtd = $.Deferred();
|
||||||
|
function appendHtml(dtd) {
|
||||||
|
$pageslide.find('.content').html(_contentHtml);
|
||||||
|
if($pageslide.find('.content').find('*').length !== 0) {
|
||||||
|
dtd.resolve();
|
||||||
|
} else {
|
||||||
|
dtd.reject();
|
||||||
|
}
|
||||||
|
return dtd;
|
||||||
|
}
|
||||||
|
$.when(appendHtml(dtd))
|
||||||
|
.done(function() {
|
||||||
|
$pageslide.find('.nano').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true });
|
||||||
|
if(settings.loadComplete)settings.loadComplete.call(this, $pageslide, $element);
|
||||||
|
})
|
||||||
|
.fail(function() {});
|
||||||
|
} else {
|
||||||
|
// Load a URL. Into an iframe?
|
||||||
|
if(settings.iframe) {
|
||||||
|
window.console.log("iFrame");
|
||||||
|
var iframe = $('<iframe id="pageslide_iframe" />').attr({
|
||||||
|
src: settings.href,
|
||||||
|
frameborder: 0,
|
||||||
|
hspace: 0
|
||||||
|
})
|
||||||
|
.css({
|
||||||
|
width: "100%",
|
||||||
|
height: "100%"
|
||||||
|
});
|
||||||
|
$pageslide.find('.content').css('overflow', 'hidden').html(iframe).show();
|
||||||
|
if(settings.loadComplete)settings.loadComplete.call(this, $pageslide, $element);
|
||||||
|
} else {
|
||||||
|
window.console.log("Load");
|
||||||
|
$pageslide.find('.content').load(settings.href, function(response, status, xhr){
|
||||||
|
if(status == 'success') {
|
||||||
|
$pageslide.show();
|
||||||
|
if(settings.loadComplete)settings.loadComplete.call(this, $pageslide, $element);
|
||||||
|
$pageslide.find('.nano').nanoScroller({ scrollTop: 0, iOSNativeScrolling: true });
|
||||||
|
} else {
|
||||||
|
var msg = '<div style="text-align: center;"><i class="icons-warning" style="font-size: 5em;"></i><h4>Oops!</h4>System may be wrong<br/> or please try again later</div>'
|
||||||
|
$pageslide.find('.content').html(msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$pageslide.data( 'localEl', false );
|
||||||
|
}
|
||||||
|
if($pageslide.find('.error-cover').length) $pageslide.find('.error-cover').remove();
|
||||||
|
_checkTitle(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Function that controls opening of the pageslide
|
||||||
|
function _start(settings) {
|
||||||
|
var slideWidth = $pageslide.outerWidth(true),
|
||||||
|
bodyMove = $sidebarState && !$('.item-groups').length ? slideWidth - 241 : settings.direction == 'right' ? slideWidth - 61 : slideWidth,
|
||||||
|
bodyAnimateIn = {},
|
||||||
|
bottomnavAnimateIn = {},
|
||||||
|
slideAnimateIn = {};
|
||||||
|
|
||||||
|
// If the slide is open or opening, just ignore the call
|
||||||
|
if($pageslide.is(':visible') || _sliding) return;
|
||||||
|
_sliding = true;
|
||||||
|
|
||||||
|
switch(settings.direction) {
|
||||||
|
case 'left':
|
||||||
|
$pageslide.css({left: 'auto', right: '-' + slideWidth + 'px'});
|
||||||
|
bodyAnimateIn['padding-right'] = '+=' + bodyMove;
|
||||||
|
slideAnimateIn['right'] = '+=' + slideWidth;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$pageslide.css({left: '-' + slideWidth + 'px', right: 'auto'});
|
||||||
|
bodyAnimateIn['margin-left'] = '+=' + bodyMove;
|
||||||
|
bottomnavAnimateIn['left'] = '+=' + bodyMove;
|
||||||
|
if($(window).width() <= 1440 && slideWidth > 963 ) {
|
||||||
|
bodyAnimateIn['width'] = $body.width();
|
||||||
|
}
|
||||||
|
slideAnimateIn['left'] = '+=' + slideWidth;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Animate the slide, and attach this slide's settings to the element
|
||||||
|
$body.animate(bodyAnimateIn, settings.speed);
|
||||||
|
$bottomNav.animate(bottomnavAnimateIn, settings.speed);
|
||||||
|
$pageslide.show().animate(slideAnimateIn, settings.speed, function() {
|
||||||
|
_sliding = false;
|
||||||
|
if(typeof settings.openFn === "function") {
|
||||||
|
settings.openFn.call(this, $pageslide, $element);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$.fn.pageslide = function(options) {
|
||||||
|
var $elements = this;
|
||||||
|
|
||||||
|
// On click
|
||||||
|
$elements.click( function(e) {
|
||||||
|
var $self = $(this),
|
||||||
|
settings = $.extend({href: $self.attr('href'), pageTitle: $self.data('title')}, options);
|
||||||
|
|
||||||
|
$element = $self;
|
||||||
|
// Prevent the default behavior and stop propagation
|
||||||
|
e.preventDefault();
|
||||||
|
e.stopPropagation();
|
||||||
|
|
||||||
|
if ($pageslide.is(':visible') && $self[0] == _lastCaller) {
|
||||||
|
// If we clicked the same element twice, toggle closed
|
||||||
|
$.pageslide.close();
|
||||||
|
} else {
|
||||||
|
// Open
|
||||||
|
$.pageslide(settings);
|
||||||
|
// Record the last element to trigger pageslide
|
||||||
|
_lastCaller = $self[0];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Default settings
|
||||||
|
*/
|
||||||
|
$.fn.pageslide.defaults = {
|
||||||
|
speed: 300, // Accepts standard jQuery effects speeds (i.e. fast, normal or milliseconds)
|
||||||
|
direction: 'right', // Accepts 'left' or 'right'
|
||||||
|
modal: false, // If set to true, you must explicitly close pageslide using $.pageslide.close();
|
||||||
|
iframe: false, // By default, linked pages are loaded into an iframe. Set this to false if you don't want an iframe.
|
||||||
|
href: null, // Override the source of the content. Optional in most cases, but required when opening pageslide programmatically.
|
||||||
|
W: 264,
|
||||||
|
closeFn : null,
|
||||||
|
openFn : null,
|
||||||
|
loadComplete : null,
|
||||||
|
pageTitle: '',
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Public methods
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Open the pageslide
|
||||||
|
$.pageslide = function(options) {
|
||||||
|
// Extend the settings with those the user has provided
|
||||||
|
var settings = $.extend({}, $.fn.pageslide.defaults, options),
|
||||||
|
pageCss = {},
|
||||||
|
convertToFunction = function(fn){
|
||||||
|
var x = new Function();
|
||||||
|
x = fn;
|
||||||
|
return x;
|
||||||
|
};
|
||||||
|
|
||||||
|
pageCss['width'] = settings.W;
|
||||||
|
pageCss['margin-left'] = $sidebarState && !$('.item-groups').length ? 241 : settings.direction == 'right' ? 61 : 0;
|
||||||
|
|
||||||
|
// Change Object to Function
|
||||||
|
if(settings.openFn) {
|
||||||
|
$.fn.pageslide.defaults.openFn = convertToFunction(settings.openFn);
|
||||||
|
};
|
||||||
|
if(settings.closeFn) {
|
||||||
|
$.fn.pageslide.defaults.closeFn = convertToFunction(settings.closeFn);
|
||||||
|
};
|
||||||
|
if(settings.loadComplete) {
|
||||||
|
$.fn.pageslide.defaults.loadComplete = convertToFunction(settings.loadComplete);
|
||||||
|
};
|
||||||
|
// Are we trying to open in different direction?
|
||||||
|
if(($pageslide.is(':visible') && $pageslide.data('W') != settings.W) || ($pageslide.is(':visible') && $pageslide.data('direction') != settings.direction)) {
|
||||||
|
$.pageslide.close(function(){
|
||||||
|
$pageslide.css(pageCss);
|
||||||
|
_checkTitle(settings)
|
||||||
|
_load(settings);
|
||||||
|
_start(settings);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
_checkTitle(settings)
|
||||||
|
_load(settings);
|
||||||
|
if($pageslide.is(':hidden')) {
|
||||||
|
$pageslide.css(pageCss);
|
||||||
|
_start(settings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$pageslide.data(settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close the pageslide
|
||||||
|
$.pageslide.close = function(callback) {
|
||||||
|
var $pageslide = $('#pageslide'),
|
||||||
|
slideWidth = $pageslide.outerWidth(true),
|
||||||
|
bodyMove = $sidebarState && !$('.item-groups').length ? slideWidth - 241 : $.fn.pageslide.defaults.direction == 'right' ? slideWidth - 61 : slideWidth
|
||||||
|
speed = $pageslide.data('speed'),
|
||||||
|
bodyAnimateIn = {},
|
||||||
|
bottomnavAnimateIn = {},
|
||||||
|
slideAnimateIn = {};
|
||||||
|
// If the slide isn't open, just ignore the call
|
||||||
|
if( $pageslide.is(':hidden') || _sliding ) return;
|
||||||
|
_sliding = true;
|
||||||
|
|
||||||
|
switch($pageslide.data('direction')) {
|
||||||
|
case 'left':
|
||||||
|
bodyAnimateIn['padding-right'] = '-=' + bodyMove;
|
||||||
|
slideAnimateIn['right'] = '-=' + slideWidth;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
bodyAnimateIn['margin-left'] = '-=' + bodyMove;
|
||||||
|
bottomnavAnimateIn['left'] = '-=' + bodyMove;
|
||||||
|
slideAnimateIn['left'] = '-=' + slideWidth;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$pageslide.animate(slideAnimateIn, speed);
|
||||||
|
$bottomNav.animate(bottomnavAnimateIn, speed);
|
||||||
|
$body.animate(bodyAnimateIn, speed, function() {
|
||||||
|
if($pageslide.data('href') == '#') {
|
||||||
|
$pageslide.attr('style', '')
|
||||||
|
.hide()
|
||||||
|
.find('.content')
|
||||||
|
.attr('style', '')
|
||||||
|
.end()
|
||||||
|
.find('.view-page')
|
||||||
|
.attr('style', '')
|
||||||
|
.end()
|
||||||
|
.find('.pane')
|
||||||
|
.remove()
|
||||||
|
.end()
|
||||||
|
.find('.page-title')
|
||||||
|
.attr('style', '')
|
||||||
|
.children('span');
|
||||||
|
} else {
|
||||||
|
$pageslide.attr('style', '')
|
||||||
|
.hide()
|
||||||
|
.find('.content')
|
||||||
|
.attr('style', '')
|
||||||
|
.empty()
|
||||||
|
.end()
|
||||||
|
.find('.view-page')
|
||||||
|
.attr('style', '')
|
||||||
|
.end()
|
||||||
|
.find('.pane')
|
||||||
|
.remove()
|
||||||
|
.end()
|
||||||
|
.find('.page-title')
|
||||||
|
.attr('style', '')
|
||||||
|
.children('span')
|
||||||
|
.empty();
|
||||||
|
}
|
||||||
|
_sliding = false;
|
||||||
|
if($pageslide.find('.error-cover').length) $pageslide.find('.error-cover').remove();
|
||||||
|
if(typeof callback != 'undefined') callback();
|
||||||
|
if(typeof $.fn.pageslide.defaults.closeFn === "function") {
|
||||||
|
$.fn.pageslide.defaults.closeFn.call(this, $pageslide, $element);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close Callback
|
||||||
|
$.pageslide.closeCallback = function( callback ) {
|
||||||
|
if(typeof callback === "function"){
|
||||||
|
$.fn.pageslide.defaults.closeFn = callback;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
// Open Callback
|
||||||
|
$.pageslide.openCallback = function( callback ) {
|
||||||
|
if(typeof callback === "function"){
|
||||||
|
$.fn.pageslide.defaults.openFn = callback;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
//data load complete callback
|
||||||
|
$.pageslide.loadComplete = function( callback ) {
|
||||||
|
if(typeof callback === "function"){
|
||||||
|
$.fn.pageslide.defaults.loadComplete = callback;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Events */
|
||||||
|
|
||||||
|
// Don't let clicks to the pageslide close the window
|
||||||
|
$pageslide.click(function(e) {
|
||||||
|
e.stopPropagation();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Close the pageslide if the document is clicked or the users presses the ESC key, unless the pageslide is modal
|
||||||
|
$(document).bind('click keyup', function(e) {
|
||||||
|
// If this is a keyup event, let's see if it's an ESC key
|
||||||
|
if( e.type == "keyup" && e.keyCode != 27) return;
|
||||||
|
|
||||||
|
// Make sure it's visible, and we're not modal
|
||||||
|
if( $pageslide.is( ':visible' ) && !$pageslide.data( 'modal' ) ) {
|
||||||
|
$.pageslide.close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}(window.jQuery);
|
||||||
|
|
||||||
|
function setForm(data) {
|
||||||
|
$.each(data, function(key, value) {
|
||||||
|
$("#pageslide form #" + key).val(value);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetForm() {
|
||||||
|
$("#pageslide form").find("input[type=text], input[type=number], textarea")
|
||||||
|
.val("")
|
||||||
|
.end()
|
||||||
|
.find("select")
|
||||||
|
.prop('selectedIndex', 0)
|
||||||
|
.end()
|
||||||
|
.find("input[type=checkbox]")
|
||||||
|
.prop('checked', false)
|
||||||
|
.end()
|
||||||
|
.find("input[type=radio]")
|
||||||
|
.prop('checked', false);
|
||||||
|
}
|
|
@ -0,0 +1,143 @@
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
var root = (typeof exports == 'undefined' ? window : exports);
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
// Ensure Content-Type is an image before trying to load @2x image
|
||||||
|
// https://github.com/imulus/retinajs/pull/45)
|
||||||
|
check_mime_type: true
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
root.Retina = Retina;
|
||||||
|
|
||||||
|
function Retina() {}
|
||||||
|
|
||||||
|
Retina.configure = function(options) {
|
||||||
|
if (options == null) options = {};
|
||||||
|
for (var prop in options) config[prop] = options[prop];
|
||||||
|
};
|
||||||
|
|
||||||
|
Retina.init = function(context) {
|
||||||
|
if (context == null) context = root;
|
||||||
|
|
||||||
|
var existing_onload = context.onload || new Function;
|
||||||
|
|
||||||
|
context.onload = function() {
|
||||||
|
var images = document.getElementsByTagName("img"), retinaImages = [], i, image;
|
||||||
|
for (i = 0; i < images.length; i++) {
|
||||||
|
image = images[i];
|
||||||
|
retinaImages.push(new RetinaImage(image));
|
||||||
|
}
|
||||||
|
existing_onload();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Retina.isRetina = function(){
|
||||||
|
var mediaQuery = "(-webkit-min-device-pixel-ratio: 1.5),\
|
||||||
|
(min--moz-device-pixel-ratio: 1.5),\
|
||||||
|
(-o-min-device-pixel-ratio: 3/2),\
|
||||||
|
(min-resolution: 1.5dppx)";
|
||||||
|
|
||||||
|
if (root.devicePixelRatio > 1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (root.matchMedia && root.matchMedia(mediaQuery).matches)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
root.RetinaImagePath = RetinaImagePath;
|
||||||
|
|
||||||
|
function RetinaImagePath(path, at_2x_path) {
|
||||||
|
this.path = path;
|
||||||
|
if (typeof at_2x_path !== "undefined" && at_2x_path !== null) {
|
||||||
|
this.at_2x_path = at_2x_path;
|
||||||
|
this.perform_check = false;
|
||||||
|
} else {
|
||||||
|
this.at_2x_path = path.replace(/\.\w+$/, function(match) { return "@2x" + match; });
|
||||||
|
this.perform_check = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RetinaImagePath.confirmed_paths = [];
|
||||||
|
|
||||||
|
RetinaImagePath.prototype.is_external = function() {
|
||||||
|
return !!(this.path.match(/^https?\:/i) && !this.path.match('//' + document.domain) )
|
||||||
|
}
|
||||||
|
|
||||||
|
RetinaImagePath.prototype.check_2x_variant = function(callback) {
|
||||||
|
var http, that = this;
|
||||||
|
if (this.is_external()) {
|
||||||
|
return callback(false);
|
||||||
|
} else if (!this.perform_check && typeof this.at_2x_path !== "undefined" && this.at_2x_path !== null) {
|
||||||
|
return callback(true);
|
||||||
|
} else if (this.at_2x_path in RetinaImagePath.confirmed_paths) {
|
||||||
|
return callback(true);
|
||||||
|
} else {
|
||||||
|
http = new XMLHttpRequest;
|
||||||
|
http.open('HEAD', this.at_2x_path);
|
||||||
|
http.onreadystatechange = function() {
|
||||||
|
if (http.readyState != 4) {
|
||||||
|
return callback(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (http.status >= 200 && http.status <= 399) {
|
||||||
|
if (config.check_mime_type) {
|
||||||
|
var type = http.getResponseHeader('Content-Type');
|
||||||
|
if (type == null || !type.match(/^image/i)) {
|
||||||
|
return callback(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RetinaImagePath.confirmed_paths.push(that.at_2x_path);
|
||||||
|
return callback(true);
|
||||||
|
} else {
|
||||||
|
return callback(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
http.send();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function RetinaImage(el) {
|
||||||
|
this.el = el;
|
||||||
|
this.path = new RetinaImagePath(this.el.getAttribute('src'), this.el.getAttribute('data-at2x'));
|
||||||
|
var that = this;
|
||||||
|
this.path.check_2x_variant(function(hasVariant) {
|
||||||
|
if (hasVariant) that.swap();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
root.RetinaImage = RetinaImage;
|
||||||
|
|
||||||
|
RetinaImage.prototype.swap = function(path) {
|
||||||
|
if (typeof path == 'undefined') path = this.path.at_2x_path;
|
||||||
|
|
||||||
|
var that = this;
|
||||||
|
function load() {
|
||||||
|
if (! that.el.complete) {
|
||||||
|
setTimeout(load, 5);
|
||||||
|
} else {
|
||||||
|
that.el.setAttribute('width', that.el.offsetWidth);
|
||||||
|
that.el.setAttribute('height', that.el.offsetHeight);
|
||||||
|
that.el.setAttribute('src', path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (Retina.isRetina()) {
|
||||||
|
Retina.init(root);
|
||||||
|
}
|
||||||
|
|
||||||
|
})();
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
$(function() {
|
||||||
|
$('#filter-input').fastLiveFilter('#tags-list', '.tags');
|
||||||
|
});
|
|
@ -0,0 +1,66 @@
|
||||||
|
mSet = function() {
|
||||||
|
if($('.m_set_swich').prop('checked')) {
|
||||||
|
$('.m_set').fadeTo(300, 1).find('input').removeAttr('disabled');
|
||||||
|
} else {
|
||||||
|
$('.m_set').fadeTo(300, .33).find('input').attr('disabled','disabled');
|
||||||
|
};
|
||||||
|
};
|
||||||
|
$(function() {
|
||||||
|
if($('.terms').length) {
|
||||||
|
$('.terms').each(function() {
|
||||||
|
if($(this).prop('checked')) {
|
||||||
|
$(this).closest('.control-group').next('.control-group').show();
|
||||||
|
};
|
||||||
|
$(this).on({
|
||||||
|
change: function() {
|
||||||
|
$(this).closest('.control-group').next('.control-group').slideToggle();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
if($('.m_set_swich').length) {
|
||||||
|
mSet();
|
||||||
|
$('.m_set_swich').on({
|
||||||
|
change: function() {
|
||||||
|
mSet();
|
||||||
|
},
|
||||||
|
});
|
||||||
|
$('.m-theme').each(function() {
|
||||||
|
if($(this).prop('checked')) {
|
||||||
|
$(this).closest('li').addClass('active');
|
||||||
|
};
|
||||||
|
$(this).on({
|
||||||
|
change: function() {
|
||||||
|
$(this).closest('li').addClass('active').siblings('li').removeClass('active');
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if($('.ob-theme').length) {
|
||||||
|
$('.ob-theme').each(function() {
|
||||||
|
if($(this).prop('checked')) {
|
||||||
|
$(this).closest('li').addClass('active');
|
||||||
|
};
|
||||||
|
$(this).on({
|
||||||
|
change: function() {
|
||||||
|
$(this).closest('li').addClass('active').siblings('li').removeClass('active');
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if($('.set-sidebar-state').length) {
|
||||||
|
if(window.localStorage.getItem('sidebarState') == 1) {
|
||||||
|
$('.set-sidebar-state').prop('checked',true).parent('.togglebox').removeClass('disable');
|
||||||
|
}
|
||||||
|
$('.set-sidebar-state').on({
|
||||||
|
change: function() {
|
||||||
|
if($(this).prop('checked')) {
|
||||||
|
sidebarState(1);
|
||||||
|
} else {
|
||||||
|
sidebarState(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
|
@ -0,0 +1,106 @@
|
||||||
|
!function ($) {
|
||||||
|
$.fn.h6Size = function () {
|
||||||
|
$h6 = this;
|
||||||
|
$h6.each(function(i) {
|
||||||
|
var W = $(this).width()-$(this).find('.toggle-control').width()-$(this).children('b').outerWidth(true)-5;
|
||||||
|
$(this).children('span').width(W);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}(window.jQuery);
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
// $('.toggle-check').togglebox();
|
||||||
|
var $mapTree = $('.map-tree'),
|
||||||
|
$mapTreeItem = $mapTree.children('li'),
|
||||||
|
$mapItemH6 = $mapTree.find('h6');
|
||||||
|
var mapItem = function(w) {
|
||||||
|
var WinW = $(window).width(),
|
||||||
|
W = null;
|
||||||
|
if(WinW < 767) {
|
||||||
|
W = w;
|
||||||
|
} else {
|
||||||
|
W = (w-64)/2;
|
||||||
|
};
|
||||||
|
return W;
|
||||||
|
};
|
||||||
|
$('#map-tree-language').css('margin-left',ml = function() {
|
||||||
|
var W = null;
|
||||||
|
$(this).children('li').map(function(i, v) {
|
||||||
|
W -= $(v).width()/2;
|
||||||
|
});
|
||||||
|
return W;
|
||||||
|
});
|
||||||
|
$mapTree.each(function(i) {
|
||||||
|
$('.line').append("<ul class='line"+(i+1)+" fade'/>");
|
||||||
|
if(i < 1) {
|
||||||
|
$('.line'+(i+1)).addClass("in active");
|
||||||
|
};
|
||||||
|
$(this).children('li').each(function(j) {
|
||||||
|
$('.line').children('.line'+(i+1)).append("<li/>");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$mapTreeItem.children('h6').find('span').before(function() {
|
||||||
|
var I = ($(this).parents('li').index()+1);
|
||||||
|
if (I < 10) {
|
||||||
|
I = "0"+I;
|
||||||
|
}
|
||||||
|
return "<b>" + I + "</b>";
|
||||||
|
});
|
||||||
|
$mapTreeItem.width(mapItem($mapTree.width()))
|
||||||
|
$mapItemH6.h6Size();
|
||||||
|
|
||||||
|
$mapTree.each(function() {
|
||||||
|
$(this).masonry({
|
||||||
|
itemSelector: '.map-tree > li',
|
||||||
|
gutter: 60,
|
||||||
|
});
|
||||||
|
$(this).masonry('on', 'layoutComplete', function(msnryInstance, laidOutItems) {
|
||||||
|
// console.log(msnryInstance.element)
|
||||||
|
var element = msnryInstance.element;
|
||||||
|
$(element).children('li').children('h6').each(function(i) {
|
||||||
|
$('ul.line'+$(element).index()).children('li').eq(i).css('top', ($(this).offset().top-$('ul.line'+$(element).index()).offset().top)+15);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$mapTree.each(function(j) {
|
||||||
|
$(this).children('li').children('h6').each(function(i) {
|
||||||
|
$('ul.line'+(j+1)).children('li').eq(i).css('top',($(this).offset().top-$('ul.line'+(j+1)).offset().top)+15);
|
||||||
|
});
|
||||||
|
$(this).children('li').on('mouseenter', function() {
|
||||||
|
$('ul.line'+(j+1)).children('li').eq($(this).index()).css({
|
||||||
|
'background-color': '#0088cc',
|
||||||
|
'z-index': 1,
|
||||||
|
})
|
||||||
|
});
|
||||||
|
$(this).children('li').on('mouseleave', function() {
|
||||||
|
$('ul.line'+(j+1)).children('li').eq($(this).index()).css({
|
||||||
|
'background-color': '#DBDBDB',
|
||||||
|
'z-index': 0,
|
||||||
|
})
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$('#map-tree-language a[data-toggle="tab"]').on('shown', function (e) {
|
||||||
|
var target = $(e.target).attr('href');
|
||||||
|
// console.log($(target).index())
|
||||||
|
$('ul.line'+$(target).index()).addClass("in active").siblings().removeClass("in active");
|
||||||
|
$mapTreeItem.width(mapItem($(target).width()))
|
||||||
|
// $mapTree.map(function(i,v){
|
||||||
|
// console.log(v.id +" : " +$(v).width() )
|
||||||
|
// })
|
||||||
|
$mapItemH6.h6Size();
|
||||||
|
$(target).masonry({
|
||||||
|
itemSelector: '.map-tree > li',
|
||||||
|
gutter: 60,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$(window).resize(function() {
|
||||||
|
var W = null;
|
||||||
|
$mapTree.map(function(i,v){
|
||||||
|
if($(v).width() > 0) {
|
||||||
|
W = $(v).width();
|
||||||
|
};
|
||||||
|
});
|
||||||
|
$mapTreeItem.width(mapItem(W));
|
||||||
|
$mapItemH6.h6Size();
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1,207 @@
|
||||||
|
function checkTagsQuantity() {
|
||||||
|
var $tagLead = $('.tag-lead'),
|
||||||
|
$tagsGroups = $('.tags-groups');
|
||||||
|
|
||||||
|
$tagsGroups.each(function(i) {
|
||||||
|
var $children = $(this).children().length;
|
||||||
|
$tagLead.eq(i).children('.badge').text($children);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkedLength() {
|
||||||
|
var $tagsList = $('#tags-list'),
|
||||||
|
$moduleTags,
|
||||||
|
$defaultTags,
|
||||||
|
$toDefault;
|
||||||
|
function reload_links() {
|
||||||
|
if($('.default-tags').length) {
|
||||||
|
$moduleTags = $('.module-tags input[type="checkbox"]:checked');
|
||||||
|
$defaultTags = $('.default-tags input[type="checkbox"]:checked');
|
||||||
|
|
||||||
|
if($moduleTags.length > 1 || $moduleTags.length+$defaultTags.length > 1) {
|
||||||
|
$('#mergerTags').removeClass('hide');
|
||||||
|
} else {
|
||||||
|
$('#mergerTags').addClass('hide');
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($moduleTags.length > 0 || $defaultTags.length > 0) {
|
||||||
|
$('#deselect').removeClass('hide');
|
||||||
|
var ids = new Array();
|
||||||
|
$defaultTags.each(function(i) {
|
||||||
|
ids.push($defaultTags.eq(i).parent().siblings('.tag_id').val());
|
||||||
|
});
|
||||||
|
$moduleTags.each(function(i) {
|
||||||
|
ids.push($moduleTags.eq(i).parent().siblings('.tag_id').val());
|
||||||
|
});
|
||||||
|
$('#deleteTags').attr('rel', "<%= Rails.application.routes.url_helpers.delete_tags_admin_tags_path %>" + "?ids=" + ids);
|
||||||
|
$('#deleteTags').removeClass('hide');
|
||||||
|
$('#deselect').on('click', deselect);
|
||||||
|
} else {
|
||||||
|
$('#deselect').addClass('hide');
|
||||||
|
$('#deleteTags').attr('rel', "");
|
||||||
|
$('#deleteTags').addClass('hide');
|
||||||
|
$('#deselect').off('click', deselect);
|
||||||
|
};
|
||||||
|
|
||||||
|
if ($moduleTags.length > 0 && $defaultTags.length == 0) {
|
||||||
|
var ids = new Array();
|
||||||
|
$moduleTags.each(function(i) {
|
||||||
|
ids.push($moduleTags.eq(i).parent().siblings('.tag_id').val());
|
||||||
|
});
|
||||||
|
$('#addDefault').attr('href', "<%= Rails.application.routes.url_helpers.add_to_default_admin_tags_path %>" + "?ids=" + ids);
|
||||||
|
$('#addDefault').removeClass('hide');
|
||||||
|
} else {
|
||||||
|
$('#addDefault').attr('href', "");
|
||||||
|
$('#addDefault').addClass('hide');
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
$moduleTags = $('.module-tags li.module input[type="checkbox"]:checked');
|
||||||
|
$defaultTags = $('.module-tags li.default input[type="checkbox"]:checked');
|
||||||
|
if($defaultTags.length > 0 || $moduleTags.length > 0) {
|
||||||
|
$('#deselect').removeClass('hide');
|
||||||
|
$('#deselect').on('click', deselect);
|
||||||
|
if($defaultTags.length > 0 && $moduleTags.length > 0) {
|
||||||
|
$('#deleteTags').attr('rel', "");
|
||||||
|
$('#deleteTags').addClass('hide');
|
||||||
|
$('#removeDefaults').attr('rel', "");
|
||||||
|
$('#removeDefaults').addClass('hide');
|
||||||
|
$('#mergerTags').addClass('hide');
|
||||||
|
} else if ($defaultTags.length > 0) {
|
||||||
|
var ids = new Array();
|
||||||
|
$defaultTags.each(function(i) {
|
||||||
|
ids.push($defaultTags.eq(i).parent().siblings('.tag_id').val());
|
||||||
|
});
|
||||||
|
$('#removeDefaults').attr('rel', "<%= Rails.application.routes.url_helpers.remove_default_admin_module_tags_path %>" + "?module_app_id=" + $('#module_app_id').val() + "&ids=" + ids);
|
||||||
|
$('#removeDefaults').removeClass('hide');
|
||||||
|
} else {
|
||||||
|
var ids = new Array();
|
||||||
|
$moduleTags.each(function(i) {
|
||||||
|
ids.push($moduleTags.eq(i).parent().siblings('.tag_id').val());
|
||||||
|
});
|
||||||
|
$('#deleteTags').attr('rel', "<%= Rails.application.routes.url_helpers.delete_tags_admin_module_tags_path %>" + "?module_app_id=" + $('#module_app_id').val() + "&ids=" + ids);
|
||||||
|
$('#deleteTags').removeClass('hide');
|
||||||
|
if($moduleTags.length > 1) {
|
||||||
|
$('#mergerTags').removeClass('hide');
|
||||||
|
} else {
|
||||||
|
$('#mergerTags').addClass('hide');
|
||||||
|
};
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
$('#deselect').addClass('hide');
|
||||||
|
$('#deleteTags').attr('rel', "");
|
||||||
|
$('#deleteTags').addClass('hide');
|
||||||
|
$('#removeDefaults').attr('rel', "");
|
||||||
|
$('#removeDefaults').addClass('hide');
|
||||||
|
$('#mergerTags').addClass('hide');
|
||||||
|
$('#deselect').off('click', deselect);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
$tagsList.delegate('.card', 'click', function() {
|
||||||
|
reload_links();
|
||||||
|
});
|
||||||
|
$('#selectAllTags').on('click', function() {
|
||||||
|
$('.filter-item:not(".mark") input[type="checkbox"]').attr('checked', true);
|
||||||
|
$('.filter-item:not(".mark") .card').addClass('active');
|
||||||
|
reload_links();
|
||||||
|
});
|
||||||
|
$('#deleteTags').on('click', function() {
|
||||||
|
$('#delete_tags .tags-groups').empty();
|
||||||
|
$('#delete_tags a.delete-tags').attr("href", $(this).attr("rel"));
|
||||||
|
if($defaultTags) {
|
||||||
|
$defaultTags.each(function(i) {
|
||||||
|
$defaultTags.eq(i).parents('.filter-item').clone().appendTo('#delete_tags .tags-groups');
|
||||||
|
$('#delete_tags .tags-groups .filter-item').addClass('def');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$moduleTags.each(function(i) {
|
||||||
|
$moduleTags.eq(i).parents('.filter-item').clone().appendTo('#delete_tags .tags-groups');
|
||||||
|
});
|
||||||
|
$('#delete_tags').modal('show', cleanTagInputs());
|
||||||
|
function cleanTagInputs(){
|
||||||
|
var $tagsDelete = $('#delete_tags'),
|
||||||
|
$filterItem = $tagsDelete.find('.filter-item');
|
||||||
|
$filterItem.find('.card, .amount').remove();
|
||||||
|
$filterItem.find('a').removeAttr('class');
|
||||||
|
$filterItem.find('a').removeAttr('href');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#mergerTags').on('click', function() {
|
||||||
|
if($moduleTags || $defaultTags) {
|
||||||
|
if($moduleTags.length > 1 || $moduleTags.length+$defaultTags.length > 1) {
|
||||||
|
$('#tags-merger form').attr("action", $(this).attr("rel"));
|
||||||
|
mergerTags()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#removeDefaults').on('click', function() {
|
||||||
|
$('#remove_defaults .tags-groups').empty();
|
||||||
|
$('#remove_defaults a.remove-defaults').attr("href", $(this).attr("rel"));
|
||||||
|
$defaultTags.each(function(i) {
|
||||||
|
$defaultTags.eq(i).parents('.filter-item').clone().appendTo('#remove_defaults .tags-groups');
|
||||||
|
});
|
||||||
|
$('#remove_defaults').modal('show', cleanTagInputs());
|
||||||
|
function cleanTagInputs(){
|
||||||
|
var $removeDefaults = $('#remove_defaults'),
|
||||||
|
$filterItem = $removeDefaults.find('.filter-item');
|
||||||
|
$filterItem.find('.card, .amount').remove();
|
||||||
|
$filterItem.find('a').removeAttr('class');
|
||||||
|
$filterItem.find('a').removeAttr('href');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function deselect() {
|
||||||
|
$('.tags input[type="checkbox"]').attr('checked', false);
|
||||||
|
$('.card').removeClass('active');
|
||||||
|
$('.bottomnav .toggable').not('.open-slide').addClass('hide');
|
||||||
|
$('#deleteTags').attr('rel', "<%= Rails.application.routes.url_helpers.delete_tags_admin_tags_path %>");
|
||||||
|
$('#addDefault').attr('href', "<%= Rails.application.routes.url_helpers.add_to_default_admin_tags_path %>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function addTagsTab() {
|
||||||
|
$('a[data-toggle="tab"]').click(function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
$(this).tab('show');
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function mergerTags() {
|
||||||
|
var $moduleTags = $('.module-tags input[type="checkbox"]:checked'),
|
||||||
|
$defaultTags = $('.default-tags input[type="checkbox"]:checked');
|
||||||
|
|
||||||
|
$defaultTags.each(function(i) {
|
||||||
|
$defaultTags.eq(i).parents('.filter-item').clone().appendTo('#tags-merger .tags-groups');
|
||||||
|
$('#tags-merger .tags-groups .filter-item').addClass('def');
|
||||||
|
});
|
||||||
|
$moduleTags.each(function(i) {
|
||||||
|
$moduleTags.eq(i).parents('.filter-item').clone().appendTo('#tags-merger .tags-groups');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#tags-merger').modal('show', changeTagName());
|
||||||
|
function changeTagName() {
|
||||||
|
var $tagsMerger = $('#tags-merger'),
|
||||||
|
$newTagsName = $('.new-tags-name'),
|
||||||
|
$filterItem = $tagsMerger.find('.filter-item');
|
||||||
|
$filterItem.find('.card, .amount').remove();
|
||||||
|
$filterItem.find('a').removeAttr('class');
|
||||||
|
$filterItem.find('a').removeAttr('href');
|
||||||
|
$filterItem.on('click', function() {
|
||||||
|
$(this).find('.tag').each(function(i) {
|
||||||
|
$newTagsName.eq(i).val($(this).text())
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$(function() {
|
||||||
|
if($('.default-tags').length) {
|
||||||
|
checkedLength();
|
||||||
|
$('#tags-merger').on('hidden', function () {
|
||||||
|
$(this).find('.filter-item').remove();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
checkedLength();
|
||||||
|
};
|
||||||
|
});
|
|
@ -0,0 +1,84 @@
|
||||||
|
$(function() {
|
||||||
|
// var mixedMode = [{
|
||||||
|
// name: "htmlmixed"
|
||||||
|
// }, {
|
||||||
|
// name: "css"
|
||||||
|
// }, {
|
||||||
|
// name: "javascript"
|
||||||
|
// }];
|
||||||
|
if(/MSIE 8.0/g.test($ua) || /MSIE 9.0/g.test($ua)) {
|
||||||
|
$('#code-theme').closest('.btn-group').hide();
|
||||||
|
}
|
||||||
|
if(!window.localStorage.getItem('code-theme')) {
|
||||||
|
window.localStorage.setItem('code-theme', 'default')
|
||||||
|
};
|
||||||
|
$(window).resize(function() {
|
||||||
|
getH();
|
||||||
|
})
|
||||||
|
getH = function() {
|
||||||
|
H = $(window).height();
|
||||||
|
H = H-$('#orbit-bar').height();
|
||||||
|
H = H-parseInt($('.wrap-inner').css('padding-top'))-parseInt($('.wrap-inner').css('padding-bottom'));
|
||||||
|
H = H-$('.wrap-inner > h3').outerHeight()-$('#code-tab').outerHeight()-28;
|
||||||
|
setH();
|
||||||
|
};
|
||||||
|
setH = function() {
|
||||||
|
$('.CodeMirror').css('height',H);
|
||||||
|
};
|
||||||
|
codeEditor = [];
|
||||||
|
$(".code").each(function(i) {
|
||||||
|
var cE = "cE"+i;
|
||||||
|
var cE = $(this).codemirror({
|
||||||
|
mode: $(this).data('mode'),
|
||||||
|
styleActiveLine: true,
|
||||||
|
lineNumbers: true,
|
||||||
|
lineWrapping: true,
|
||||||
|
autoCloseBrackets: true,
|
||||||
|
autoCloseTags: true,
|
||||||
|
tabMode: "indent",
|
||||||
|
tabSize: 4,
|
||||||
|
indentUnit: 4,
|
||||||
|
indentWithTabs: true,
|
||||||
|
});
|
||||||
|
cE.setOption("theme", window.localStorage.getItem('code-theme'));
|
||||||
|
CodeMirror.commands["selectAll"](cE);
|
||||||
|
var range = { from: cE.getCursor(true), to: cE.getCursor(false) };
|
||||||
|
cE.autoFormatRange(range.from, range.to);
|
||||||
|
codeEditor.push(cE);
|
||||||
|
$('#code-theme > li').eq(window.localStorage.getItem('lidx')).addClass('active')
|
||||||
|
});
|
||||||
|
getH();
|
||||||
|
$('.CodeMirror-sizer').each(function(i) {
|
||||||
|
if($(this).height() < H ) {
|
||||||
|
$(this).siblings('.CodeMirror-gutters').css('height',H-30);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$('#code-theme').delegate('a', clickEvent, function(e) {
|
||||||
|
theme = $(this).attr('href');
|
||||||
|
lidx = $(this).parent('li').index();
|
||||||
|
window.localStorage.setItem('code-theme', theme);
|
||||||
|
window.localStorage.setItem('lidx', lidx);
|
||||||
|
var j = null;
|
||||||
|
$('.tab-pane').each(function() {
|
||||||
|
if($(this).hasClass('in')) {
|
||||||
|
j = $(this).index()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
codeEditor[j].setOption("theme", theme);
|
||||||
|
$(this).parent('li').addClass('active').siblings('li').removeClass('active')
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
$('a[data-toggle="tab"]').on('shown', function (e) {
|
||||||
|
var j = null;
|
||||||
|
$('.tab-pane').each(function() {
|
||||||
|
if($(this).hasClass('in')) {
|
||||||
|
j = $(this).index()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
codeEditor[j].setOption("theme", window.localStorage.getItem('code-theme'));
|
||||||
|
});
|
||||||
|
setTimeout(sethide, 1);
|
||||||
|
function sethide(){
|
||||||
|
$(".tab-pane:eq(0)").nextAll(".tab-pane").removeClass("active in");
|
||||||
|
};
|
||||||
|
});
|
|
@ -0,0 +1,4 @@
|
||||||
|
//= require basic
|
||||||
|
//= require jquery.ui.sortable
|
||||||
|
//= require lib/jquery.ui.touch-punch.min.js
|
||||||
|
//= require lib/jquery.mjs.nestedSortable.js
|
|
@ -62,6 +62,14 @@ class PagesController < ApplicationController
|
||||||
render render_final_page
|
render render_final_page
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
page = Page.find(params[:id])
|
||||||
|
page.destroy
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
@ -74,7 +82,9 @@ class PagesController < ApplicationController
|
||||||
def create
|
def create
|
||||||
@page = Page.new(page_params)
|
@page = Page.new(page_params)
|
||||||
@page.save!
|
@page.save!
|
||||||
redirect_to pages_path
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -15,7 +15,7 @@ module ApplicationHelper
|
||||||
def render_menu
|
def render_menu
|
||||||
# json_file = File.read(File.join(Rails.root, 'public', "menu.json"))
|
# json_file = File.read(File.join(Rails.root, 'public', "menu.json"))
|
||||||
# @items = JSON.parse(json_file)
|
# @items = JSON.parse(json_file)
|
||||||
@pages = Page.where(:parent_page_id.ne => "" , :parent_page_id.exists => false, :page_id.ne => "", :page_id.exists => true)
|
@pages = Page.where(:parent_page_id.ne => "" , :parent_page_id.exists => false).first.child_page
|
||||||
|
|
||||||
def create_json(pages)
|
def create_json(pages)
|
||||||
item = {}
|
item = {}
|
||||||
|
|
|
@ -35,4 +35,13 @@ module OrbitHelper
|
||||||
def self.set_current_widget_module(name)
|
def self.set_current_widget_module(name)
|
||||||
@controller_name = name
|
@controller_name = name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def get_item_module_infos(page)
|
||||||
|
if page.parent_page_id.nil?
|
||||||
|
["Home","icons-house"]
|
||||||
|
else
|
||||||
|
module_app = ModuleApp.where(:key => page.module).first
|
||||||
|
[module_app.title, module_app.get_registration.icon_class]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,10 +7,11 @@ class Page
|
||||||
field :module
|
field :module
|
||||||
field :url
|
field :url
|
||||||
field :page_id
|
field :page_id
|
||||||
|
field :is_published, type: Boolean, default: true
|
||||||
|
|
||||||
has_many :page_parts, :autosave => true, :dependent => :destroy
|
has_many :page_parts, :autosave => true, :dependent => :destroy
|
||||||
|
|
||||||
has_many :child_page, :class_name => 'Page', :inverse_of => :parent_page
|
has_many :child_page, :class_name => 'Page', :inverse_of => :parent_page, :dependent => :destroy
|
||||||
belongs_to :parent_page, :class_name => 'Page', :inverse_of => :child_page
|
belongs_to :parent_page, :class_name => 'Page', :inverse_of => :child_page
|
||||||
|
|
||||||
def to_param
|
def to_param
|
||||||
|
@ -20,4 +21,12 @@ class Page
|
||||||
def self.find_by_param(input)
|
def self.find_by_param(input)
|
||||||
self.find_by(page_id: input) rescue nil
|
self.find_by(page_id: input) rescue nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.root
|
||||||
|
self.where(:parent_page_id.ne => "" , :parent_page_id.exists => false).first
|
||||||
|
end
|
||||||
|
|
||||||
|
def root?
|
||||||
|
self.parent_page_id.nil?
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -0,0 +1,41 @@
|
||||||
|
<div class="navbar">
|
||||||
|
<div class="navbar-inner">
|
||||||
|
<span class="brand"><i class="<%= node.root? ? 'icons-house' : 'icons-list-2' %>"></i></span>
|
||||||
|
<% if node.class.to_s.eql?('Page') %>
|
||||||
|
<% unless node.root? %>
|
||||||
|
<% name, icon_name = get_item_module_infos(node) %>
|
||||||
|
<span title="<%= name %>" class="item-type page tip"><i class="<%= icon_name %>"></i></span>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<span title="<%= t(:link) %>" class="item-type link tip"><i class="icon-link"></i></span>
|
||||||
|
<% end %>
|
||||||
|
<div class="item-title">
|
||||||
|
<%= content_tag(:em, node.url, class: "muted") if node.class.to_s.eql?('Link') %>
|
||||||
|
<% if node.class.to_s.eql?('Page') %>
|
||||||
|
<%= link_to node.name, node.url %>
|
||||||
|
<% else %>
|
||||||
|
<%= link_to node.title, node.url %>
|
||||||
|
<% end %>
|
||||||
|
<div class="item-menu">
|
||||||
|
<%= link_to content_tag(:i, nil, class: "icon-eye-open"), pages_edit_view_path(:id => node.id.to_s), class: "view-page open-slide tip", title: "View", data: {title: node.name} if node.class.to_s.eql?('Page') %>
|
||||||
|
<%# if node.class.to_s.downcase.eql?("page") %>
|
||||||
|
<%#= link_to content_tag(:i, nil, class: "icon-edit"), "#page", class: "open-slide tip page edit", title: t('editing.page'), data: {title: t('editing.page'), id: node.id.to_s, parent: node.parent_id.to_s, form: {name: node.name}.merge(node.title_translations)} %>
|
||||||
|
<%# elsif node.class.to_s.downcase.eql?("link") %>
|
||||||
|
<%#= link_to content_tag(:i, nil, class: "icon-edit"), "#link", class: "open-slide tip link edit", title: t('editing.link'), data: {title: t('editing.link'), id: node.id.to_s, parent: node.parent_id.to_s, form: {name: node.name}.merge(node.title_translations).merge(node.urls)} %>
|
||||||
|
<%# end %>
|
||||||
|
<%= link_to content_tag(:i, nil, class: "icons-newspaper"), new_page_path(:parent_page => node.id.to_s), class: "open-slide tip page", title: "Add Page", data: {title: "Add Page", id: 'new', parent: node.id.to_s} if node.class.to_s.eql?('Page') && level < 3 %>
|
||||||
|
<%#= link_to content_tag(:i, nil, class: "icon-link"), "#link", class: "open-slide tip link", title: t(:add_link), data: {title: t(:add_link), id: 'new', parent: node.id.to_s} if node.class.to_s.eql?('Page') %>
|
||||||
|
<%= link_to content_tag(:i, nil, class: "icon-trash"), page_path(node.id),:method => :delete,:remote => true, "data-confirm" => "Are you sure ?", class: "delete tip", title: "Delete", data: {title: "Delete"} unless node.root? %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="item-info pull-right">
|
||||||
|
<%# @site_in_use_locales.each do |valid_locale| %>
|
||||||
|
<%# if node.enabled_for && node.enabled_for.include?(valid_locale) %>
|
||||||
|
<!-- <span class="label label-warning"><%#= I18nVariable.from_locale(valid_locale) %></span> -->
|
||||||
|
|
|
||||||
|
<%# end %>
|
||||||
|
<%# end %>
|
||||||
|
<span class="badge <%= 'badge-inverse' if node.root? %>"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -0,0 +1,19 @@
|
||||||
|
<% unless node.root? %>
|
||||||
|
<li id='<%= node.id %>' class="<%= 'disabled' unless node.is_published %> <%= 'no-nest' if node.class.to_s.eql?('Link') %>" >
|
||||||
|
<% end %>
|
||||||
|
<%= render 'node', {node: node, level: level} rescue render 'admin/items/node', {node: node, level: level} %>
|
||||||
|
<% unless node.child_page.blank? %>
|
||||||
|
<% unless node.root? %>
|
||||||
|
<ol>
|
||||||
|
<% end %>
|
||||||
|
<% node.child_page.each do |child| %>
|
||||||
|
<%= render 'node_and_children', {node: child, level: level + 1} rescue render 'admin/items/node_and_children', {node: child, level: level + 1} %>
|
||||||
|
<% end %>
|
||||||
|
<% unless node.root? %>
|
||||||
|
</ol>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% unless node.root? %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
|
@ -1,3 +1,12 @@
|
||||||
<% @items.each do |i|%>
|
|
||||||
<%= link_to i.name, page_url(i.url) %>
|
<% node = Page.root %>
|
||||||
|
<% unless node.nil? %>
|
||||||
|
<ol id='<%= node.id %>' class="sortable item-groups">
|
||||||
|
<%= render 'node_and_children', {node: node, level: 0} %>
|
||||||
|
</ol>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<%##= render 'layouts/delete_modal', delete_options: {remote: true} %>
|
||||||
|
<%#= render 'form_page' %>
|
||||||
|
<%#= render 'form_link' %>
|
||||||
|
<%= javascript_include_tag "lib/pageslide.js" %>
|
||||||
|
<%= javascript_include_tag "lib/items/items" %>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
<!-- Language -->
|
<!-- Language -->
|
||||||
<li id="orbit-language" class="dropdown">
|
<li id="orbit-language" class="dropdown">
|
||||||
<a href="#" role="button" class="dropdown-toggle" data-toggle="dropdown" title="<%= t('site.language')%>"><%= t(:_locale, :locale => I18n.locale) %></a>
|
<a href="#" role="button" class="dropdown-toggle" data-toggle="dropdown" title="<%#= t('site.language')%>"><%= t(:_locale, :locale => I18n.locale) %></a>
|
||||||
<ul class="dropdown-menu" role="menu" aria-labelledby="orbit-language">
|
<ul class="dropdown-menu" role="menu" aria-labelledby="orbit-language">
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -37,5 +37,39 @@
|
||||||
<i class="icons-login"></i> <span class="hide"><%= t(:login) %></span>
|
<i class="icons-login"></i> <span class="hide"><%= t(:login) %></span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<!-- Log in Modal -->
|
||||||
|
<div id="login" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="ModalLabel" aria-hidden="true">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
|
<h3 id="ModalLabel"><%= t(:login_orbit) %></h3>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<%= form_for :user, url: "", html: {class: 'container'} do |f| %>
|
||||||
|
<div class="input-prepend">
|
||||||
|
<span class="add-on">
|
||||||
|
<i class="icon-user"></i>
|
||||||
|
</span>
|
||||||
|
<%= f.text_field :user_id, class: "input-xlarge" , placeholder: t("users.user_id") %>
|
||||||
|
</div>
|
||||||
|
<div class="input-prepend">
|
||||||
|
<span class="add-on">
|
||||||
|
<i class="icon-lock"></i>
|
||||||
|
</span>
|
||||||
|
<%= f.password_field :password, class: "input-xlarge", placeholder: t(:password) %>
|
||||||
|
</div>
|
||||||
|
<div class="pull-left" style="width: 150px;">
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox" name="user[remember_me]" value="1" checked="checked" />
|
||||||
|
<small>Remember me</small>
|
||||||
|
</label>
|
||||||
|
<%= content_tag :button, t(:login), :type => :submit, :class => 'btn btn-primary' %>
|
||||||
|
</div>
|
||||||
|
<div class="pull-right">
|
||||||
|
<%= link_to content_tag(:small, t(:forgot_password)) %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</ul>
|
</ul>
|
|
@ -6,6 +6,8 @@
|
||||||
<%= render 'shared/google_font' %>
|
<%= render 'shared/google_font' %>
|
||||||
<%= stylesheet_link_tag "structure" %>
|
<%= stylesheet_link_tag "structure" %>
|
||||||
<%= render 'shared/ie_html5_fix' %>
|
<%= render 'shared/ie_html5_fix' %>
|
||||||
|
<%= javascript_include_tag "structure" %>
|
||||||
|
<%= yield :page_specific_javascript %>
|
||||||
<%= csrf_meta_tag %>
|
<%= csrf_meta_tag %>
|
||||||
</head>
|
</head>
|
||||||
<body id="sideset">
|
<body id="sideset">
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
$("#main-wrap ol.sortable").html("<%= j render 'admin/items/node_and_children', {node: Page.root, level: 0} %>");
|
||||||
|
$.pageslide.close();
|
|
@ -0,0 +1 @@
|
||||||
|
$("#main-wrap ol.sortable").html("<%= j render 'admin/items/node_and_children', {node: Page.root, level: 0} %>");
|
|
@ -1,4 +1,4 @@
|
||||||
<%= form_for @page, url: {action: "create"} do |f| %>
|
<%= form_for @page, url: {action: "create"}, remote: true do |f| %>
|
||||||
<% I18n.available_locales.each do |locale| %>
|
<% I18n.available_locales.each do |locale| %>
|
||||||
Page name <%= locale.to_s %>:
|
Page name <%= locale.to_s %>:
|
||||||
<%= f.fields_for :name_translations do |n| %>
|
<%= f.fields_for :name_translations do |n| %>
|
||||||
|
@ -9,9 +9,8 @@
|
||||||
<%= f.text_field :page_id %>
|
<%= f.text_field :page_id %>
|
||||||
Module :
|
Module :
|
||||||
<%= f.select(:module, @modules.map{|m| [m.title,m.key]},{:include_blank => true}) %>
|
<%= f.select(:module, @modules.map{|m| [m.title,m.key]},{:include_blank => true}) %>
|
||||||
Parent page :
|
<%#= f.select(:parent_page, @pages.map{|page| [page.name, page.id]},{:include_blank => true}) %>
|
||||||
<%= f.select(:parent_page, @pages.map{|page| [page.name, page.id]},{:include_blank => true}) %>
|
<%= f.hidden_field :parent_page, value: params[:parent_page] %>
|
||||||
Page number:
|
<%#= f.text_field :number %>
|
||||||
<%= f.text_field :number %>
|
|
||||||
<%= f.submit "Create Page" %>
|
<%= f.submit "Create Page" %>
|
||||||
<% end %>
|
<% end %>
|
|
@ -74,6 +74,13 @@ module OrbitApp
|
||||||
def side_bar(&block) #setter for side_bar from init
|
def side_bar(&block) #setter for side_bar from init
|
||||||
@side_bar = SideBarRegistration::SideBar.new(@name,@key,method(:get_module_app), &block)
|
@side_bar = SideBarRegistration::SideBar.new(@name,@key,method(:get_module_app), &block)
|
||||||
end
|
end
|
||||||
|
def get_side_bar
|
||||||
|
@side_bar
|
||||||
|
end
|
||||||
|
|
||||||
|
def icon_class
|
||||||
|
@side_bar.get_icon_class
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue