New UI changes(tags, categories, authorisations, module index…)
To run: - ruby lib/remove_old_tags.rb DB_NAME - rake new_ui:migrate_tags - rake new_ui:migrate_categories['APP_KEY,''MODEL_NAME'] (check new_ui.rake for more details)
This commit is contained in:
1 parent
07b3857465
commit
856898016b
1495 files changed
+52132
-9876
No files matched your search
@@ -0,0 +1,18 @@
|
||||
$("button.multi_files").live("click", function(){
|
||||
$("#new_add_banner_file_holder").append("<li>" + $(this).val() +'Time:'+ $(this).siblings('.ad_time').val()+'Link:'+$(this).siblings('.ad_out_link').val()+ "</li>");
|
||||
new_node = $(this).parent().clone();
|
||||
$(this).parent().css("display","none");
|
||||
new_node.children('input.multi_files').val("");
|
||||
$(this).parent().before(new_node);
|
||||
return false;
|
||||
|
||||
});
|
||||
|
||||
$('a.remove_mark').live("click",function(){
|
||||
$(this).prev("input").val("true");
|
||||
$(this).parent().css("text-decoration","line-through")
|
||||
$(this).parent().removeClass("r_snapshot");
|
||||
$(this).next().remove();
|
||||
$(this).remove();
|
||||
return false;
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
// This is a manifest file that'll be compiled into including all the files listed below.
|
||||
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
||||
// be included in the compiled file accessible from http://example.com/assets/application.js
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// the compiled file.
|
||||
//
|
||||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
//= require jquery.form
|
||||
//= require rss
|
||||
//= require ajax_form
|
||||
@@ -0,0 +1,7 @@
|
||||
$('#ajaxForm').ajaxForm({
|
||||
beforeSubmit: function(a,f,o) {
|
||||
o.dataType = 'script';
|
||||
},
|
||||
success: function(data) {
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
// This is a manifest file that'll be compiled into including all the files listed below.
|
||||
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
||||
// be included in the compiled file accessible from http://example.com/assets/application.js
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// the compiled file.
|
||||
//
|
||||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
//= require_tree .
|
||||
//= social-share-button
|
||||
@@ -0,0 +1,9 @@
|
||||
$('.archive_file_multiples_block a.delete').live('click', function(){
|
||||
$(this).parents('.list_item').remove();
|
||||
});
|
||||
|
||||
$(document).on('click', '.action a.remove_existing_record', function(){
|
||||
$(this).next('.should_destroy').attr('value', 1);
|
||||
$("tr#archive_file_multiple_" + $(this).prev().attr('value')).hide();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
$('.plugin_files_block a.delete').live('click', function(){
|
||||
$(this).parents('.list_item').remove();
|
||||
});
|
||||
|
||||
$(document).on('click', '.action a.remove_existing_record', function(){
|
||||
$(this).next('.should_destroy').attr('value', 1);
|
||||
$("tr#plugin_file_" + $(this).prev().attr('value')).hide();
|
||||
});
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
$('.attributes_block a.delete').live('click', function(){
|
||||
$(this).parents('.list_item').remove();
|
||||
});
|
||||
|
||||
$('.action a.remove_existing_record').live('click', function(){
|
||||
$(this).next('.should_destroy').attr('value', 1);
|
||||
$("#attribute_" + $(this).prev().attr('value')).hide();
|
||||
});
|
||||
|
||||
$('.action a.switch').live('click', function(){
|
||||
$(this).parent().toggleClass('disable');
|
||||
var $am = $(this).next('.built_in_state')
|
||||
$am.attr('value', ($am.attr('value') == "false") ? "true" : "false");
|
||||
});
|
||||
|
||||
$('.select_type select').live('change', function(){
|
||||
if(this.value == 'select')
|
||||
{
|
||||
$(this).next().show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).next().hide();
|
||||
}
|
||||
});
|
||||
+2164
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,28 @@
|
||||
<%#= encoding: utf-8 %>
|
||||
$(document).ready(function(){
|
||||
//alert("Anc Loaded");
|
||||
$('.bulletin_links_block a.delete').live('click', function(){
|
||||
$(this).parents('.list_item').remove();
|
||||
});
|
||||
|
||||
$('.bulletin_files_block a.delete').live('click', function(){
|
||||
$(this).parents('.list_item').remove();
|
||||
});
|
||||
|
||||
$(document).on('click', '.action a.remove_existing_record', function(){
|
||||
if(confirm("<%= I18n.t(:sure?)%>")){
|
||||
$(this).next('.should_destroy').attr('value', 1);
|
||||
$("tr#" + $(this).prev().attr('value')).hide();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.quick_edit_cancel', function(){
|
||||
tr = $(this).attr('rel');
|
||||
$('#' + tr).hide();
|
||||
$("tr#bulletin_file_" + $(this).prev().attr('value')).hide();
|
||||
$("tr#bulletin_link_" + $(this).prev().attr('value')).hide();
|
||||
});
|
||||
$('.reject_info').tooltip({
|
||||
placement : 'bottom'
|
||||
});
|
||||
});
|
||||
@@ -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,71 @@
|
||||
function r_editor(tgetUrl,tpostUrl,tfilename,toption){
|
||||
if(!toption){ toption =new Array();}
|
||||
if(!toption['width']){toption['width']=400;}
|
||||
if(!toption['height']){toption['height']=300;}
|
||||
var editor = this;
|
||||
editor.filename = tfilename;
|
||||
editor.getUrl = tgetUrl;
|
||||
editor.postUrl = tpostUrl;
|
||||
editor.nodeToBeChanged=""
|
||||
editor.width = toption['width'];
|
||||
editor.height = toption['height'];
|
||||
var html='';
|
||||
editor.init = function(){
|
||||
code = "<span id='file_editor' style='border:solid; width:"+editor.width+"px;height:"+editor.height+"px; float:right;' ><textarea style='height:87%;width:97%;resize:none;border:none;' ></textarea><input type='button' class='send' value='Send' ><input type='button' class='discard' value='Discard' ></span>";
|
||||
html = $(code);
|
||||
html.children("textarea").load(editor.getUrl);
|
||||
html.children("input.discard").click(function(){
|
||||
editor.destroy();
|
||||
});
|
||||
html.children("input.send").click(function(){
|
||||
editor.send();
|
||||
});
|
||||
return html;
|
||||
};
|
||||
editor.reload = function(){
|
||||
$.get(editor.getUrl,function(data){
|
||||
html.children("textarea").text(data);
|
||||
});
|
||||
};
|
||||
editor.send = function(){
|
||||
$.post(editor.postUrl,{filename:editor.filename,context:html.children("textarea").val(),authenticity_token:$('meta[name=csrf-token]').attr('content')},null,"script");
|
||||
};
|
||||
editor.destroy = function(){
|
||||
html.remove();
|
||||
};
|
||||
}
|
||||
|
||||
$(".r_edit").live("click",function(){
|
||||
new_editor = new r_editor($(this).attr("path"),"edit_file",$(this).attr("filename"));
|
||||
$(this).after(new_editor.init());
|
||||
});
|
||||
|
||||
|
||||
$(".r_snapshot").live({
|
||||
mouseenter:
|
||||
function(){
|
||||
$(this).append($("<span></span>").html('<p class="z-preview"><img src="'+$(this).attr("path")+'"width="220" height="19" /></p>'));
|
||||
},
|
||||
mouseleave:
|
||||
function(){
|
||||
$(this).find("span:last").remove();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
$('input.multi_files').live("change", function(){
|
||||
$(this).parent().prev("ul").append("<li>" + $(this).val() + "</li>");
|
||||
new_node = $(this).parent().clone();
|
||||
$(this).parent().css("display","none");
|
||||
new_node.children('input.multi_files').val("");
|
||||
$(this).parent().before(new_node);
|
||||
});
|
||||
|
||||
$('a.remove_mark').live("click",function(){
|
||||
$(this).prev("input").val("true");
|
||||
$(this).parent().css("text-decoration","line-through")
|
||||
$(this).parent().removeClass("r_snapshot");
|
||||
$(this).next().remove();
|
||||
$(this).remove();
|
||||
return false;
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
// This is a manifest file that'll be compiled into including all the files listed below.
|
||||
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
||||
// be included in the compiled file accessible from http://example.com/assets/application.js
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// the compiled file.
|
||||
//
|
||||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
//= require jquery-ui
|
||||
//= require jquery.form
|
||||
//= require jquery.tinyscrollbar
|
||||
//= require jquery.miniColors.min
|
||||
//= require bootstrap
|
||||
//= require orbitdesktopAPI
|
||||
//= require orbitTimeline
|
||||
//= require orbitdesktop
|
||||
//= require jquery.gridster
|
||||
//= require desktop/books_pages
|
||||
//= require select2
|
||||
@@ -0,0 +1,33 @@
|
||||
orbitDesktop.prototype.initializeBooks = function(target,url,cache){
|
||||
this.initializeBooks.list = function(){
|
||||
var bindHandlers = function(){
|
||||
o.simple_drop_down();
|
||||
|
||||
o.tinyscrollbar_ext({
|
||||
main: '.tinycanvas',
|
||||
fill: '.list_t'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
bindHandlers();
|
||||
|
||||
}
|
||||
|
||||
this.initializeBooks.addbook = function(){
|
||||
var bindHandlers = function(){
|
||||
o.simple_drop_down();
|
||||
|
||||
o.tinyscrollbar_ext({
|
||||
main: '.tinycanvas',
|
||||
fill: '.s_grid_con'
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
bindHandlers();
|
||||
|
||||
}
|
||||
this.initializeBooks.list();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
orbitDesktop.prototype.themefolder = "desktop_themes";
|
||||
orbitDesktopAPI.prototype.notifyImgPath = "/assets/";
|
||||
// alert("<%= @desktop.inspect %>")
|
||||
var od = new orbitDesktop("#ajax_container");
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// This is a manifest file that'll be compiled into including all the files listed below.
|
||||
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
||||
// be included in the compiled file accessible from http://example.com/assets/application.js
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// the compiled file.
|
||||
//
|
||||
//= require back_end
|
||||
@@ -0,0 +1,66 @@
|
||||
$(document).ready(function(){
|
||||
var result = '',
|
||||
title_text = '',
|
||||
link_text = '',
|
||||
summary_text = '',
|
||||
startDate_text = '',
|
||||
startMon_text = '',
|
||||
startDay_text = '',
|
||||
endDate_text = '',
|
||||
time_text = '',
|
||||
selet = 0,
|
||||
xmlLength = '',
|
||||
indexA = '',
|
||||
indexB = '',
|
||||
indexC = '',
|
||||
month = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
|
||||
checking = 1,
|
||||
$events = $('.events'),
|
||||
$mon = $('.events .mon'),
|
||||
$day = $('.events .day'),
|
||||
$link_text = $('.events .event_name'),
|
||||
$time = $('.events .event_info'),
|
||||
$next = $('.events .links_next'),
|
||||
$prev = $('.events .links_prev'),
|
||||
objLength = $events.find('ul > li').length;
|
||||
$next.on("click", function(){
|
||||
if (checking&&selet < xmlLength) {
|
||||
$('.links_prev').removeClass('disabled')
|
||||
selet+=objLength;
|
||||
$events.find('ul').fadeOut("fast", function () {
|
||||
resetText()
|
||||
$events.find('ul').fadeIn("fast" ,getEvent(selet));
|
||||
});
|
||||
if ((xmlLength-selet) == objLength) {
|
||||
$('.links_next').addClass('disabled')
|
||||
checking = 0;
|
||||
} else if ((xmlLength-selet) < objLength) {
|
||||
$('.links_next').addClass('disabled')
|
||||
checking = 0;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
$prev.on("click", function(){
|
||||
if (selet > 0) {
|
||||
$('.links_next').removeClass('disabled')
|
||||
checking = 1;
|
||||
selet-=objLength;
|
||||
$events.find('ul').fadeOut("fast", function () {
|
||||
$events.find('ul').fadeIn("fast" ,getEvent(selet));
|
||||
});
|
||||
if ((xmlLength-selet) == xmlLength ) {
|
||||
$('.links_prev').addClass('disabled')
|
||||
}
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
function resetText() {
|
||||
$events.find('li').find($mon).html('');
|
||||
$events.find('li').find($day).html('');
|
||||
$events.find('li').find($link_text).html('');
|
||||
$events.find('li').find($link_text).attr('href', '');
|
||||
$events.find('li').find($time).html('');
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
/*! HTML5 Shiv pre3.5 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
|
||||
Uncompressed source: https://github.com/aFarkas/html5shiv */
|
||||
(function(a,b){function h(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function i(){var a=l.elements;return typeof a=="string"?a.split(" "):a}function j(a){var b={},c=a.createElement,f=a.createDocumentFragment,g=f();a.createElement=function(a){l.shivMethods||c(a);var f;return b[a]?f=b[a].cloneNode():e.test(a)?f=(b[a]=c(a)).cloneNode():f=c(a),f.canHaveChildren&&!d.test(a)?g.appendChild(f):f},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+i().join().replace(/\w+/g,function(a){return b[a]=c(a),g.createElement(a),'c("'+a+'")'})+");return n}")(l,g)}function k(a){var b;return a.documentShived?a:(l.shivCSS&&!f&&(b=!!h(a,"article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio{display:none}canvas,video{display:inline-block;*display:inline;*zoom:1}[hidden]{display:none}audio[controls]{display:inline-block;*display:inline;*zoom:1}mark{background:#FF0;color:#000}")),g||(b=!j(a)),b&&(a.documentShived=b),a)}function p(a){var b,c=a.getElementsByTagName("*"),d=c.length,e=RegExp("^(?:"+i().join("|")+")$","i"),f=[];while(d--)b=c[d],e.test(b.nodeName)&&f.push(b.applyElement(q(b)));return f}function q(a){var b,c=a.attributes,d=c.length,e=a.ownerDocument.createElement(n+":"+a.nodeName);while(d--)b=c[d],b.specified&&e.setAttribute(b.nodeName,b.nodeValue);return e.style.cssText=a.style.cssText,e}function r(a){var b,c=a.split("{"),d=c.length,e=RegExp("(^|[\\s,>+~])("+i().join("|")+")(?=[[\\s,>+~#.:]|$)","gi"),f="$1"+n+"\\:$2";while(d--)b=c[d]=c[d].split("}"),b[b.length-1]=b[b.length-1].replace(e,f),c[d]=b.join("}");return c.join("{")}function s(a){var b=a.length;while(b--)a[b].removeNode()}function t(a){var b,c,d=a.namespaces,e=a.parentWindow;return!o||a.printShived?a:(typeof d[n]=="undefined"&&d.add(n),e.attachEvent("onbeforeprint",function(){var d,e,f,g=a.styleSheets,i=[],j=g.length,k=Array(j);while(j--)k[j]=g[j];while(f=k.pop())if(!f.disabled&&m.test(f.media)){for(d=f.imports,j=0,e=d.length;j<e;j++)k.push(d[j]);try{i.push(f.cssText)}catch(l){}}i=r(i.reverse().join("")),c=p(a),b=h(a,i)}),e.attachEvent("onafterprint",function(){s(c),b.removeNode(!0)}),a.printShived=!0,a)}var c=a.html5||{},d=/^<|^(?:button|form|map|select|textarea|object|iframe)$/i,e=/^<|^(?:a|b|button|code|div|fieldset|form|h1|h2|h3|h4|h5|h6|i|iframe|img|input|label|li|link|ol|option|p|param|q|script|select|span|strong|style|table|tbody|td|textarea|tfoot|th|thead|tr|ul)$/i,f,g;(function(){var c=b.createElement("a");c.innerHTML="<xyz></xyz>",f="hidden"in c,f&&typeof injectElementWithStyles=="function"&&injectElementWithStyles("#modernizr{}",function(b){b.hidden=!0,f=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle).display=="none"}),g=c.childNodes.length==1||function(){try{b.createElement("a")}catch(a){return!0}var c=b.createDocumentFragment();return typeof c.cloneNode=="undefined"||typeof c.createDocumentFragment=="undefined"||typeof c.createElement=="undefined"}()})();var l={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:k};a.html5=l,k(b);var m=/^$|\b(?:all|print)\b/,n="html5shiv",o=!g&&function(){var c=b.documentElement;return typeof b.namespaces!="undefined"&&typeof b.parentWindow!="undefined"&&typeof c.applyElement!="undefined"&&typeof c.removeNode!="undefined"&&typeof a.attachEvent!="undefined"}();l.type+=" print",l.shivPrint=t,t(b)})(this,document)
|
||||
@@ -0,0 +1,7 @@
|
||||
// jQuery(document).ajaxStart(function(){
|
||||
// $('<div class="modal-backdrop fade in" id="sys_modal"><img src="/assets/ajax-loader.gif" style="margin-top: 25%;margin-left: 50%;"></div>').appendTo('body');
|
||||
// });
|
||||
|
||||
// jQuery(document).ajaxComplete(function(){
|
||||
// $("#sys_modal").hide().remove();
|
||||
// });
|
||||
@@ -0,0 +1,37 @@
|
||||
function checkSwitch() {
|
||||
// $(".groups").each(function() {
|
||||
// $(this).find('.form-horizontal > .hide').length < $(this).find('.form-horizontal > div').length ? $(this).removeClass("disabled") : $(this).addClass("disabled")
|
||||
// });
|
||||
// $(".groups").addClass('disabled').has('.groups > .form-horizontal > div:not(.hide)').removeClass('disabled');
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
// checkSwitch();
|
||||
$('.onoff').click(function () {
|
||||
if($(this).parent("h4").length==1) {
|
||||
$(this).parents(".map-block").toggleClass("disabled");
|
||||
$(this).parents(".map-block").find(".form-horizontal").toggleClass("hide");
|
||||
if($(this).parents(".map-block").hasClass("disabled")){
|
||||
$(this).text("OFF");
|
||||
$(this).siblings(".subrole_disable_field").val("true");
|
||||
}else{
|
||||
$(this).text("ON");
|
||||
$(this).siblings(".subrole_disable_field").val("false");
|
||||
}
|
||||
}
|
||||
if($(this).parent("legend").length==1) {
|
||||
$(this).toggleClass("disabled");
|
||||
$(this).parent("legend").next("div").toggleClass("hide");
|
||||
if($(this).parent("legend").next("div").hasClass("hide")){
|
||||
$(this).text("OFF");
|
||||
$(this).siblings(".subrole_disable_field").val("true");
|
||||
}else{
|
||||
$(this).text("ON");
|
||||
$(this).siblings(".subrole_disable_field").val("false");
|
||||
}
|
||||
// checkSwitch();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
$(document).ready(function(){
|
||||
$(".status select").each(function (i) {
|
||||
$(this).change(function () {
|
||||
$(".status option:selected").eq(i).each(function () {
|
||||
if($(this).attr("value")=="alumna") {
|
||||
$(this).parents(".status").nextAll(".graduated").removeClass("hide");
|
||||
$(this).parents(".status").nextAll(".graduated").find("select").removeAttr("disabled");
|
||||
}else{
|
||||
$(this).parents(".status").nextAll(".graduated").addClass("hide");
|
||||
$(this).parents(".status").nextAll(".graduated").find("select").attr({disabled:''});
|
||||
}
|
||||
});
|
||||
})
|
||||
})
|
||||
});
|
||||
@@ -0,0 +1,112 @@
|
||||
jQuery(document).ready(function($) {
|
||||
// Stuff to do as soon as the DOM is ready. Use $() w/o colliding with other libs;
|
||||
var current_textarea = {};
|
||||
var parent = null;
|
||||
var this_modal_window = null;
|
||||
var lang = <%= VALID_LOCALES.to_s %>;
|
||||
|
||||
$("textarea[func=input_unit]").each(function(){
|
||||
var id = $(this).attr("id");
|
||||
current_textarea[id] = $(this).val();
|
||||
})
|
||||
console.log(current_textarea);
|
||||
|
||||
// current_textarea['en'] = $("textarea[for=en]").val();
|
||||
// current_textarea['zh_tw'] = $("textarea[for=zh_tw]").val();
|
||||
|
||||
|
||||
|
||||
$("div.controls").on("click","a.edit-btn",function(){
|
||||
parent = $(this).parent();
|
||||
this_modal_window = $(this).parent().parent().parent().parent().find(".modal");
|
||||
|
||||
choosen_lang = $(this).parent().parent().find("ul li.active").attr("for");
|
||||
$(this).parents(".editMore").find(".modal_tab").removeClass("active in");
|
||||
$(this).parents(".editMore").find(".modal_tab[for="+choosen_lang+"]").addClass("active in");
|
||||
|
||||
$(this).parents(".editMore").find(".modal-body li").removeClass("active");
|
||||
$(this).parents(".editMore").find(".modal-body li[for="+choosen_lang+"]").addClass("active");
|
||||
// switch($(this).parent().parent().find("ul li.active a").attr("href")){
|
||||
// case ".tab1":
|
||||
|
||||
// $("#tab3").addClass("active in");
|
||||
// $(".modal-body li").eq(0).addClass("active");
|
||||
// break;
|
||||
// case ".tab2":
|
||||
// $("#tab4").addClass("active in");
|
||||
// $(".modal-body li").eq(1).addClass("active");
|
||||
// break;
|
||||
|
||||
|
||||
$.each(lang,function(i,value){
|
||||
// console.log(this_modal_window);
|
||||
var sa = parent.find("input.street_address_"+lang[i]).val();
|
||||
var city = parent.find("input.city_"+lang[i]).val();
|
||||
var county = parent.find("input.county_"+lang[i]).val();
|
||||
var zip = parent.find("input.zip_"+lang[i]).val();
|
||||
var country = parent.find("input.country_"+lang[i]).val();
|
||||
this_modal_window.find('.tab-content div[for='+lang[i]+'] textarea[func=street_address]').val(sa);
|
||||
this_modal_window.find('.tab-content div[for='+lang[i]+'] input[func=city]').val(city);
|
||||
this_modal_window.find('.tab-content div[for='+lang[i]+'] input[func=county]').val(county);
|
||||
this_modal_window.find('.tab-content div[for='+lang[i]+'] input[func=zip]').val(zip);
|
||||
this_modal_window.find('.tab-content div[for='+lang[i]+'] input[func=country]').val(country);
|
||||
var verify = sa + city + country +county + zip;
|
||||
|
||||
var combined = "";
|
||||
if(verify!="")
|
||||
combined = sa + "\n" + city + "\n" + county + "\n" + zip + "\n" + country+"\n";
|
||||
|
||||
var Text0 = parent.find("div."+lang[i]+" textarea[func=input_unit]").val();
|
||||
Text1 = Text0.replace(/(\r\n|\n|\r)/gm,"");
|
||||
var Text2 = combined;
|
||||
Text2 = Text2.replace(/(\r\n|\n|\r)/gm,"");
|
||||
|
||||
if(Text1 != Text2){
|
||||
this_modal_window.find('.tab-content div[for='+lang[i]+'] textarea[func=street_address]').val(Text0);
|
||||
this_modal_window.find("input").val("");
|
||||
}
|
||||
});
|
||||
});
|
||||
$("textarea[func=input_unit]").change(function(){
|
||||
var id = $(this).attr("id");
|
||||
var lang = $(this).attr("for");
|
||||
if(!parent)
|
||||
parent = $(this).parent().parent();
|
||||
console.log(current_textarea[id]);
|
||||
if(current_textarea[id] != $(this).val())
|
||||
parent.find("input.indicator_"+lang).val("true");
|
||||
else
|
||||
parent.find("input.indicator_"+lang).val("false");
|
||||
})
|
||||
|
||||
$(".address-edit").on("hidden",function(){
|
||||
$("#tab3").removeClass("active in");
|
||||
$("#tab4").removeClass("active in");
|
||||
$(".modal-body li").removeClass("active");
|
||||
$(".modal-body input, .modal-body textarea").val("");
|
||||
|
||||
})
|
||||
$(".bt-save").click(function(){
|
||||
for(i=0;i<2;i++){
|
||||
var sa = this_modal_window.find('.tab-content div[for='+lang[i]+'] textarea[func=street_address]').val();
|
||||
var city = this_modal_window.find('.tab-content div[for='+lang[i]+'] input[func=city]').val();
|
||||
var county = this_modal_window.find('.tab-content div[for='+lang[i]+'] input[func=county]').val();
|
||||
var zip = this_modal_window.find('.tab-content div[for='+lang[i]+'] input[func=zip]').val();
|
||||
var country = this_modal_window.find('.tab-content div[for='+lang[i]+'] input[func=country]').val();
|
||||
parent.find("input.street_address_"+lang[i]).val(sa);
|
||||
parent.find("input.city_"+lang[i]).val(city);
|
||||
parent.find("input.county_"+lang[i]).val(county);
|
||||
parent.find("input.zip_"+lang[i]).val(zip);
|
||||
parent.find("input.country_"+lang[i]).val(country);
|
||||
var verify = sa + city + country +county + zip;
|
||||
var combined = "";
|
||||
if(verify!="")
|
||||
combined = sa + "\n" + city + "\n" + county + "\n" + zip + "\n" + country;
|
||||
parent.find("textarea[for="+lang[i]+"]").val(combined);
|
||||
parent.find("input.indicator_"+lang[i]).val("false");
|
||||
current_textarea[parent.find("textarea[for="+lang[i]+"]").attr("id")] = combined;
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
});
|
||||
@@ -0,0 +1,137 @@
|
||||
/*!
|
||||
* jQuery imagesLoaded plugin v2.0.1
|
||||
* http://github.com/desandro/imagesloaded
|
||||
*
|
||||
* MIT License. by Paul Irish et al.
|
||||
*/
|
||||
|
||||
/*jshint curly: true, eqeqeq: true, noempty: true, strict: true, undef: true, browser: true */
|
||||
/*global jQuery: false */
|
||||
|
||||
;(function($, undefined) {
|
||||
'use strict';
|
||||
|
||||
// blank image data-uri bypasses webkit log warning (thx doug jones)
|
||||
var BLANK = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==';
|
||||
|
||||
$.fn.imagesLoaded = function( callback ) {
|
||||
var $this = this,
|
||||
deferred = $.isFunction($.Deferred) ? $.Deferred() : 0,
|
||||
hasNotify = $.isFunction(deferred.notify),
|
||||
$images = $this.find('img').add( $this.filter('img') ),
|
||||
loaded = [],
|
||||
proper = [],
|
||||
broken = [];
|
||||
|
||||
function doneLoading() {
|
||||
var $proper = $(proper),
|
||||
$broken = $(broken);
|
||||
|
||||
if ( deferred ) {
|
||||
if ( broken.length ) {
|
||||
deferred.reject( $images, $proper, $broken );
|
||||
} else {
|
||||
deferred.resolve( $images );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $.isFunction( callback ) ) {
|
||||
callback.call( $this, $images, $proper, $broken );
|
||||
}
|
||||
}
|
||||
|
||||
function imgLoaded( img, isBroken ) {
|
||||
// don't proceed if BLANK image, or image is already loaded
|
||||
if ( img.src === BLANK || $.inArray( img, loaded ) !== -1 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// store element in loaded images array
|
||||
loaded.push( img );
|
||||
|
||||
// keep track of broken and properly loaded images
|
||||
if ( isBroken ) {
|
||||
broken.push( img );
|
||||
} else {
|
||||
proper.push( img );
|
||||
}
|
||||
|
||||
// cache image and its state for future calls
|
||||
$.data( img, 'imagesLoaded', { isBroken: isBroken, src: img.src } );
|
||||
|
||||
// trigger deferred progress method if present
|
||||
if ( hasNotify ) {
|
||||
deferred.notifyWith( $(img), [ isBroken, $images, $(proper), $(broken) ] );
|
||||
}
|
||||
|
||||
// call doneLoading and clean listeners if all images are loaded
|
||||
if ( $images.length === loaded.length ){
|
||||
setTimeout( doneLoading );
|
||||
$images.unbind( '.imagesLoaded' );
|
||||
}
|
||||
}
|
||||
|
||||
// if no images, trigger immediately
|
||||
if ( !$images.length ) {
|
||||
doneLoading();
|
||||
} else {
|
||||
$images.bind( 'load.imagesLoaded error.imagesLoaded', function( event ){
|
||||
// trigger imgLoaded
|
||||
imgLoaded( event.target, event.type === 'error' );
|
||||
}).each( function( i, el ) {
|
||||
var src = el.src;
|
||||
|
||||
// find out if this image has been already checked for status
|
||||
// if it was, and src has not changed, call imgLoaded on it
|
||||
var cached = $.data( el, 'imagesLoaded' );
|
||||
if ( cached && cached.src === src ) {
|
||||
imgLoaded( el, cached.isBroken );
|
||||
return;
|
||||
}
|
||||
|
||||
// if complete is true and browser supports natural sizes, try
|
||||
// to check for image status manually
|
||||
if ( el.complete && el.naturalWidth !== undefined ) {
|
||||
imgLoaded( el, el.naturalWidth === 0 || el.naturalHeight === 0 );
|
||||
return;
|
||||
}
|
||||
|
||||
// cached images don't fire load sometimes, so we reset src, but only when
|
||||
// dealing with IE, or image is complete (loaded) and failed manual check
|
||||
// webkit hack from http://groups.google.com/group/jquery-dev/browse_thread/thread/eee6ab7b2da50e1f
|
||||
if ( el.readyState || el.complete ) {
|
||||
el.src = BLANK;
|
||||
el.src = src;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return deferred ? deferred.promise( $this ) : $this;
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.upload-picture').find('img').imagesLoaded(function(){
|
||||
var picH = $('.upload-picture').width()/$('.upload-picture').find('img').width()*$('.upload-picture').find('img').height();
|
||||
var imgMarginTop = ($('.upload-picture').height()-picH)/2;
|
||||
var d = $('.upload-picture').height();
|
||||
if(imgMarginTop>0){
|
||||
imgMarginTop = 0;
|
||||
d = picH;
|
||||
$('.upload-picture').css({height:d})
|
||||
}
|
||||
$('.upload-picture').find('img').css({marginTop:imgMarginTop})
|
||||
$('.upload-picture').each(function (i){
|
||||
$(this).mouseenter(function(){
|
||||
var h= picH;
|
||||
$(this).stop().animate({height:h}, 500);
|
||||
$(this).find('img').stop().animate({marginTop:0}, 500);
|
||||
});
|
||||
$(this).mouseleave(function(){
|
||||
$(this).stop().animate({height:d}, 500);
|
||||
$(this).find('img').stop().animate({marginTop:imgMarginTop}, 500);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,72 @@
|
||||
//Preview need a link in form as Ex and a corresponding PUT action in controller
|
||||
//Ex preview trigger:
|
||||
// <%= link_to "NewPreview", realtime_preview_admin_ad_banner_path(ad_banner_tab) , :class=>'preview_trigger'%>
|
||||
|
||||
$(document).ready(function() {
|
||||
// $(".post_preview").click(function(e){
|
||||
// $("#main-wrap").after("<span id='show_preview'></span>");
|
||||
// e.preventDefault();
|
||||
// var form = $(this).parents("form").first()
|
||||
// //var cont = form["content"].value;
|
||||
// // $.ajax({
|
||||
// // type: 'POST',
|
||||
// // url: $(this).attr("href")+'?preview=true',
|
||||
// // data: form.serialize(),
|
||||
// // dataType: "script",
|
||||
// // success: function (msg) {
|
||||
// // $("#"+start_modal_with_id).modal('show'); },
|
||||
// // error: function(){
|
||||
// // alert("ERROR");
|
||||
// // }
|
||||
// // });
|
||||
// url = "/panel/news/back_end/news_bulletins/preview?preview=true"
|
||||
// // alert(url)
|
||||
// form.attr("action",url);
|
||||
// form.submit();
|
||||
// //return false;
|
||||
// });
|
||||
$("button.post_preview").click(function(){
|
||||
var btn = document.getElementById("button_for_preview");
|
||||
var attrs = btn.attributes;
|
||||
var url = attrs['url'];
|
||||
// url = url.replace("url=","");
|
||||
$("form.nccu_ajax_form").ajaxSubmit({
|
||||
beforeSubmit: function(a,f,o){
|
||||
$("#main-wrap").after("<span id='show_preview'></span>");
|
||||
o.dataType = 'script';
|
||||
o.url = url.nodeValue;
|
||||
o.type = 'post';
|
||||
},success: function(msg) { }
|
||||
|
||||
});
|
||||
})
|
||||
// $("form.nccu_ajax_form").ajaxForm({
|
||||
// beforeSubmit: function(a,f,o) {
|
||||
// // if(clicked_what.hasClass("post_preview")){
|
||||
// // $("#main-wrap").after("<span id='show_preview'></span>");
|
||||
// // o.dataType = 'script';
|
||||
// // o.url = clicked_what.attr("url");
|
||||
// // }
|
||||
// },
|
||||
// success: function(data) {
|
||||
// // if(!clicked_what.hasClass("post_preview")){
|
||||
// // window.location = data.redirect_url;
|
||||
// // }
|
||||
// }
|
||||
// })
|
||||
|
||||
$("a.preview_trigger").live('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) {
|
||||
$("#"+start_modal_with_id).modal('show'); },
|
||||
error: function(){
|
||||
alert("ERROR");
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
function append_id(){
|
||||
if ($("#object_id").length == 1) {
|
||||
return "&id="+$("#object_id").val();
|
||||
}
|
||||
else{
|
||||
return '';
|
||||
};
|
||||
}
|
||||
|
||||
$("#page_design").live('change', function() {
|
||||
$.getScript($(this).attr('rel') + '?design_id=' + $(this).val() + append_id());
|
||||
});
|
||||
|
||||
|
||||
$("#module_app_list select").live('change', function() {
|
||||
$.getScript($(this).attr('rel') + '?module_app_id='+$(this).val() + append_id());
|
||||
});
|
||||
|
||||
$("#widget_list select,#frontend_list select").live('change', function() {
|
||||
$.getScript($(this).attr('rel') +'?frontend=' + $(this).val() + '&module_app_id=' + $("#module_app_list select").val() + append_id() );
|
||||
});
|
||||
|
||||
$("#tag_list select").live('change', function() {
|
||||
$.getScript($(this).attr('rel') + '?type=' + $(this).val() + append_id() );
|
||||
});
|
||||
|
||||
$("select.widget_field_select").live('change', function() {
|
||||
$.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() );
|
||||
});
|
||||
|
||||
$('.part_kind').live('click', function() {
|
||||
$('.part_kind_partial').hide();
|
||||
$('#part_' + $(this).attr('value')).show();
|
||||
});
|
||||
@@ -0,0 +1,22 @@
|
||||
$(document).ready(function() {
|
||||
permissionCheckbox();
|
||||
});
|
||||
function permissionCheckbox(){
|
||||
$('.check[checked="checked"]').parents(".checkbox").addClass("checked")
|
||||
$(".checkbox").click(function(){
|
||||
if($(this).children(".check").attr("checked")){
|
||||
// uncheck
|
||||
$(this).children(".check").attr('checked', false);
|
||||
$(this).removeClass("checked");
|
||||
}else{
|
||||
// check
|
||||
$(this).children(".check").attr({checked: "checked"});
|
||||
$(this).addClass("checked");
|
||||
}
|
||||
});
|
||||
$(".checkbox").popover({
|
||||
trigger: 'hover',
|
||||
placement: 'bottom',
|
||||
delay: { show: 100, hide: 300 },
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
// var $CloneTarget ;
|
||||
|
||||
function checkMultipleInput() {
|
||||
$(".multipleInput").each(function() {
|
||||
$(this).children('.controls').length==1 ? $(this).addClass("plural") : $(this).removeClass("plural")
|
||||
});
|
||||
}
|
||||
function removeInput(){
|
||||
$(".removeInput").click(function (){
|
||||
$(this).parents(".controls").remove();
|
||||
checkMultipleInput();
|
||||
return false;
|
||||
});
|
||||
}
|
||||
$(document).ready(function(){
|
||||
var $modalNumber = 0;
|
||||
checkMultipleInput();
|
||||
removeInput();
|
||||
$(".addinput").click(function (){
|
||||
$modalNumber+=1;
|
||||
var $CloneTarget = $(this).parents(".controls").prev(".multipleInput").children('.controls:last');
|
||||
$(this).parents(".controls").prev(".multipleInput").append($CloneTarget.clone());
|
||||
class_to_be_removed = $(this).parents(".controls").prev(".multipleInput").attr("ext_class")
|
||||
// $(this).parents(".controls").prev(".multipleInput").children('.controls:last input').val("");
|
||||
$(this).parents(".controls").prev(".multipleInput").children('.controls:last').find('input').val('')
|
||||
|
||||
$(this).parents(".controls").prev(".multipleInput").children('.controls:last').find('.tab-pane').removeClass(class_to_be_removed).addClass("NewInput_"+$modalNumber)
|
||||
btn = $(this).parents(".controls").prev(".multipleInput").children('.controls:last').find(".nav.nav-pills li")
|
||||
$.each(btn,function(i,value){
|
||||
old_link = $(this).children("a").attr("href");
|
||||
$(this).children("a").attr("href",".NewInput_"+$modalNumber);
|
||||
});
|
||||
removeInput();
|
||||
checkMultipleInput();
|
||||
return false;
|
||||
})
|
||||
});
|
||||
@@ -0,0 +1,48 @@
|
||||
// JavaScript Document
|
||||
|
||||
// can copy code to any of ur desired javascsript
|
||||
|
||||
//extended jquery to search fast.
|
||||
$.extend($.expr[':'], {
|
||||
'containsi': function (elem, i, match, array) {
|
||||
return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
|
||||
}
|
||||
});
|
||||
var interval,sval;
|
||||
$(document).ready(function(){
|
||||
$("#user_filter").keyup(function(e){
|
||||
if((e.which>96 && e.which<123) || (e.which>64 && e.which<92) || (e.which == 32) || (e.which == 8)){
|
||||
sval = $(this).val();
|
||||
$(".checkbox").popover("hide");
|
||||
$("div.checkblock").hide();
|
||||
clearInterval(interval);
|
||||
interval = setInterval(waitForSearch,1000);
|
||||
}
|
||||
})
|
||||
})
|
||||
var waitForSearch = function(){
|
||||
if(sval){
|
||||
var re1 = new RegExp("^[\u4E00-\uFA29]*$"); //Chinese character range
|
||||
var re2 = new RegExp("^[\uE7C7-\uE7F3]*$");
|
||||
if ((re1.test(sval) && (re2.test(sval)))){
|
||||
|
||||
var totalfoundbyname = $("div#users_checkbox_ary label.member-name:contains("+sval+")").length
|
||||
if(totalfoundbyname!=0){
|
||||
$("div#users_checkbox_ary label.member-name:contains("+sval+")").parent().parent().show();
|
||||
}else if(totalfoundbyname==0){
|
||||
$("div#users_checkbox_ary div.for_unit:contains("+sval+")").parent().show();
|
||||
}
|
||||
}else{
|
||||
var totalfoundbyname = $("div#users_checkbox_ary label.member-name:containsi("+sval+")").length
|
||||
if(totalfoundbyname!=0){
|
||||
$("div#users_checkbox_ary label.member-name:containsi("+sval+")").parent().parent().show();
|
||||
}else if(totalfoundbyname==0){
|
||||
$("div#users_checkbox_ary div.for_unit:containsi("+sval+")").parent().show();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
$(".checkbox").popover('hide');
|
||||
$("div.checkblock").show();
|
||||
}
|
||||
clearInterval(interval);
|
||||
}
|
||||
@@ -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 it is too large.
Load diff
@@ -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);
|
||||
+3234
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Isotope v1.5.11
|
||||
* An exquisite jQuery plugin for magical layouts
|
||||
* http://isotope.metafizzy.co
|
||||
*
|
||||
* Commercial use requires one-time license fee
|
||||
* http://metafizzy.co/#licenses
|
||||
*
|
||||
* Copyright 2012 David DeSandro / Metafizzy
|
||||
*/
|
||||
(function(a,b,c){var d=a.document,e=a.Modernizr,f=function(a){return a.charAt(0).toUpperCase()+a.slice(1)},g="Moz Webkit O Ms".split(" "),h=function(a){var b=d.documentElement.style,c;if(typeof b[a]=="string")return a;a=f(a);for(var e=0,h=g.length;e<h;e++){c=g[e]+a;if(typeof b[c]=="string")return c}},i=h("transform"),j=h("transitionProperty"),k={csstransforms:function(){return!!i},csstransforms3d:function(){var a=!!h("perspective");if(a){var c=" -o- -moz- -ms- -webkit- -khtml- ".split(" "),d="@media ("+c.join("transform-3d),(")+"modernizr)",e=b("<style>"+d+"{#modernizr{height:3px}}"+"</style>").appendTo("head"),f=b('<div id="modernizr" />').appendTo("html");a=f.height()===3,f.remove(),e.remove()}return a},csstransitions:function(){return!!j}},l;if(e)for(l in k)e.hasOwnProperty(l)||e.addTest(l,k[l]);else{e=a.Modernizr={_version:"1.6ish: miniModernizr for Isotope"};var m=" ",n;for(l in k)n=k[l](),e[l]=n,m+=" "+(n?"":"no-")+l;b("html").addClass(m)}if(e.csstransforms){var o=e.csstransforms3d?{translate:function(a){return"translate3d("+a[0]+"px, "+a[1]+"px, 0) "},scale:function(a){return"scale3d("+a+", "+a+", 1) "}}:{translate:function(a){return"translate("+a[0]+"px, "+a[1]+"px) "},scale:function(a){return"scale("+a+") "}},p=function(a,c,d){var e=b.data(a,"isoTransform")||{},f={},g,h={},j;f[c]=d,b.extend(e,f);for(g in e)j=e[g],h[g]=o[g](j);var k=h.translate||"",l=h.scale||"",m=k+l;b.data(a,"isoTransform",e),a.style[i]=m};b.cssNumber.scale=!0,b.cssHooks.scale={set:function(a,b){p(a,"scale",b)},get:function(a,c){var d=b.data(a,"isoTransform");return d&&d.scale?d.scale:1}},b.fx.step.scale=function(a){b.cssHooks.scale.set(a.elem,a.now+a.unit)},b.cssNumber.translate=!0,b.cssHooks.translate={set:function(a,b){p(a,"translate",b)},get:function(a,c){var d=b.data(a,"isoTransform");return d&&d.translate?d.translate:[0,0]}}}var q,r;e.csstransitions&&(q={WebkitTransitionProperty:"webkitTransitionEnd",MozTransitionProperty:"transitionend",OTransitionProperty:"oTransitionEnd",transitionProperty:"transitionEnd"}[j],r=h("transitionDuration"));var s=b.event,t;s.special.smartresize={setup:function(){b(this).bind("resize",s.special.smartresize.handler)},teardown:function(){b(this).unbind("resize",s.special.smartresize.handler)},handler:function(a,b){var c=this,d=arguments;a.type="smartresize",t&&clearTimeout(t),t=setTimeout(function(){jQuery.event.handle.apply(c,d)},b==="execAsap"?0:100)}},b.fn.smartresize=function(a){return a?this.bind("smartresize",a):this.trigger("smartresize",["execAsap"])},b.Isotope=function(a,c,d){this.element=b(c),this._create(a),this._init(d)};var u=["overflow","position","width","height"],v=b(a);b.Isotope.settings={resizable:!0,layoutMode:"masonry",containerClass:"isotope",itemClass:"isotope-item",hiddenClass:"isotope-hidden",hiddenStyle:{opacity:0,scale:.001},visibleStyle:{opacity:1,scale:1},animationEngine:"best-available",animationOptions:{queue:!1,duration:800},sortBy:"original-order",sortAscending:!0,resizesContainer:!0,transformsEnabled:!b.browser.opera,itemPositionDataEnabled:!1},b.Isotope.prototype={_create:function(a){this.options=b.extend({},b.Isotope.settings,a),this.styleQueue=[],this.elemCount=0;var c=this.element[0].style;this.originalStyle={};for(var d=0,e=u.length;d<e;d++){var f=u[d];this.originalStyle[f]=c[f]||""}this.element.css({overflow:"hidden",position:"relative"}),this._updateAnimationEngine(),this._updateUsingTransforms();var g={"original-order":function(a,b){b.elemCount++;return b.elemCount},random:function(){return Math.random()}};this.options.getSortData=b.extend(this.options.getSortData,g),this.reloadItems(),this.offset={left:parseInt(this.element.css("padding-left"),10),top:parseInt(this.element.css("padding-top"),10)};var h=this;setTimeout(function(){h.element.addClass(h.options.containerClass)},0),this.options.resizable&&v.bind("smartresize.isotope",function(){h.resize()}),this.element.delegate("."+this.options.hiddenClass,"click",function(){return!1})},_getAtoms:function(a){var b=this.options.itemSelector,c=b?a.filter(b).add(a.find(b)):a,d={position:"absolute"};this.usingTransforms&&(d.left=0,d.top=0),c.css(d).addClass(this.options.itemClass),this.updateSortData(c,!0);return c},_init:function(a){this.$filteredAtoms=this._filter(this.$allAtoms),this._sort(),this.reLayout(a)},option:function(a){if(b.isPlainObject(a)){this.options=b.extend(!0,this.options,a);var c;for(var d in a)c="_update"+f(d),this[c]&&this[c]()}},_updateAnimationEngine:function(){var a=this.options.animationEngine.toLowerCase().replace(/[ _\-]/g,""),b;switch(a){case"css":case"none":b=!1;break;case"jquery":b=!0;break;default:b=!e.csstransitions}this.isUsingJQueryAnimation=b,this._updateUsingTransforms()},_updateTransformsEnabled:function(){this._updateUsingTransforms()},_updateUsingTransforms:function(){var a=this.usingTransforms=this.options.transformsEnabled&&e.csstransforms&&e.csstransitions&&!this.isUsingJQueryAnimation;a||(delete this.options.hiddenStyle.scale,delete this.options.visibleStyle.scale),thiLine truncated
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* jQuery Masonry v2.1.05
|
||||
* A dynamic layout plugin for jQuery
|
||||
* The flip-side of CSS Floats
|
||||
* http://masonry.desandro.com
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* Copyright 2012 David DeSandro
|
||||
*/
|
||||
(function(a,b,c){"use strict";var d=b.event,e;d.special.smartresize={setup:function(){b(this).bind("resize",d.special.smartresize.handler)},teardown:function(){b(this).unbind("resize",d.special.smartresize.handler)},handler:function(a,c){var d=this,f=arguments;a.type="smartresize",e&&clearTimeout(e),e=setTimeout(function(){b.event.handle.apply(d,f)},c==="execAsap"?0:100)}},b.fn.smartresize=function(a){return a?this.bind("smartresize",a):this.trigger("smartresize",["execAsap"])},b.Mason=function(a,c){this.element=b(c),this._create(a),this._init()},b.Mason.settings={isResizable:!0,isAnimated:!1,animationOptions:{queue:!1,duration:500},gutterWidth:0,isRTL:!1,isFitWidth:!1,containerStyle:{position:"relative"}},b.Mason.prototype={_filterFindBricks:function(a){var b=this.options.itemSelector;return b?a.filter(b).add(a.find(b)):a},_getBricks:function(a){var b=this._filterFindBricks(a).css({position:"absolute"}).addClass("masonry-brick");return b},_create:function(c){this.options=b.extend(!0,{},b.Mason.settings,c),this.styleQueue=[];var d=this.element[0].style;this.originalStyle={height:d.height||""};var e=this.options.containerStyle;for(var f in e)this.originalStyle[f]=d[f]||"";this.element.css(e),this.horizontalDirection=this.options.isRTL?"right":"left",this.offset={x:parseInt(this.element.css("padding-"+this.horizontalDirection),10),y:parseInt(this.element.css("padding-top"),10)},this.isFluid=this.options.columnWidth&&typeof this.options.columnWidth=="function";var g=this;setTimeout(function(){g.element.addClass("masonry")},0),this.options.isResizable&&b(a).bind("smartresize.masonry",function(){g.resize()}),this.reloadItems()},_init:function(a){this._getColumns(),this._reLayout(a)},option:function(a,c){b.isPlainObject(a)&&(this.options=b.extend(!0,this.options,a))},layout:function(a,b){for(var c=0,d=a.length;c<d;c++)this._placeBrick(a[c]);var e={};e.height=Math.max.apply(Math,this.colYs);if(this.options.isFitWidth){var f=0;c=this.cols;while(--c){if(this.colYs[c]!==0)break;f++}e.width=(this.cols-f)*this.columnWidth-this.options.gutterWidth}this.styleQueue.push({$el:this.element,style:e});var g=this.isLaidOut?this.options.isAnimated?"animate":"css":"css",h=this.options.animationOptions,i;for(c=0,d=this.styleQueue.length;c<d;c++)i=this.styleQueue[c],i.$el[g](i.style,h);this.styleQueue=[],b&&b.call(a),this.isLaidOut=!0},_getColumns:function(){var a=this.options.isFitWidth?this.element.parent():this.element,b=a.width();this.columnWidth=this.isFluid?this.options.columnWidth(b):this.options.columnWidth||this.$bricks.outerWidth(!0)||b,this.columnWidth+=this.options.gutterWidth,this.cols=Math.floor((b+this.options.gutterWidth)/this.columnWidth),this.cols=Math.max(this.cols,1)},_placeBrick:function(a){var c=b(a),d,e,f,g,h;d=Math.ceil(c.outerWidth(!0)/this.columnWidth),d=Math.min(d,this.cols);if(d===1)f=this.colYs;else{e=this.cols+1-d,f=[];for(h=0;h<e;h++)g=this.colYs.slice(h,h+d),f[h]=Math.max.apply(Math,g)}var i=Math.min.apply(Math,f),j=0;for(var k=0,l=f.length;k<l;k++)if(f[k]===i){j=k;break}var m={top:i+this.offset.y};m[this.horizontalDirection]=this.columnWidth*j+this.offset.x,this.styleQueue.push({$el:c,style:m});var n=i+c.outerHeight(!0),o=this.cols+1-l;for(k=0;k<o;k++)this.colYs[j+k]=n},resize:function(){var a=this.cols;this._getColumns(),(this.isFluid||this.cols!==a)&&this._reLayout()},_reLayout:function(a){var b=this.cols;this.colYs=[];while(b--)this.colYs.push(0);this.layout(this.$bricks,a)},reloadItems:function(){this.$bricks=this._getBricks(this.element.children())},reload:function(a){this.reloadItems(),this._init(a)},appended:function(a,b,c){if(b){this._filterFindBricks(a).css({top:this.element.height()});var d=this;setTimeout(function(){d._appended(a,c)},1)}else this._appended(a,c)},_appended:function(a,b){var c=this._getBricks(a);this.$bricks=this.$bricks.add(c),this.layout(c,b)},remove:function(a){this.$bricks=this.$bricks.not(a),a.remove()},destroy:function(){this.$bricks.removeClass("masonry-brick").each(function(){this.style.position="",this.style.top="",this.style.left=""});var c=this.element[0].style;for(var d in this.originalStyle)c[d]=this.originalStyle[d];this.element.unbind(".masonry").removeClass("masonry").removeData("masonry"),b(a).unbind(".masonry")}},b.fn.imagesLoaded=function(a){function h(){a.call(c,d)}function i(a){var c=a.target;c.src!==f&&b.inArray(c,g)===-1&&(g.push(c),--e<=0&&(setTimeout(h),d.unbind(".imagesLoaded",i)))}var c=this,d=c.find("img").add(c.filter("img")),e=d.length,f="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==",g=[];return e||h(),d.bind("load.imagesLoaded error.imagesLoaded",i).each(function(){var a=this.src;this.src=f,this.src=a}),c};var f=function(b){a.console&&a.console.error(b)};b.fn.masonry=function(a){if(typeof a=="string"){var c=Array.prototype.slice.call(arguments,1);this.each(function(){var d=b.data(this,"masonry");if(!d){f("cannot call methods on masonry prior to initialization; attempted to call method '"+a+"'");return}if(!b.isFunctiLine truncated
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
* jQuery miniColors: A small color selector
|
||||
*
|
||||
* Copyright 2011 Cory LaViska for A Beautiful Site, LLC. (http://abeautifulsite.net/)
|
||||
*
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses
|
||||
*
|
||||
*/
|
||||
if(jQuery)(function($){$.extend($.fn,{miniColors:function(o,data){var create=function(input,o,data){var color=expandHex(input.val());if(!color)color='ffffff';var hsb=hex2hsb(color);var trigger=$('<a class="miniColors-trigger" style="background-color: #'+color+'" href="#"></a>');trigger.insertAfter(input);input.addClass('miniColors').data('original-maxlength',input.attr('maxlength')||null).data('original-autocomplete',input.attr('autocomplete')||null).data('letterCase','uppercase').data('trigger',trigger).data('hsb',hsb).data('change',o.change?o.change:null).attr('maxlength',7).attr('autocomplete','off').val('#'+convertCase(color,o.letterCase));if(o.readonly)input.prop('readonly',true);if(o.disabled)disable(input);trigger.bind('click.miniColors',function(event){event.preventDefault();if(input.val()==='')input.val('#');show(input)});input.bind('focus.miniColors',function(event){if(input.val()==='')input.val('#');show(input)});input.bind('blur.miniColors',function(event){var hex=expandHex(input.val());input.val(hex?'#'+convertCase(hex,input.data('letterCase')):'')});input.bind('keydown.miniColors',function(event){if(event.keyCode===9)hide(input)});input.bind('keyup.miniColors',function(event){setColorFromInput(input)});input.bind('paste.miniColors',function(event){setTimeout(function(){setColorFromInput(input)},5)})};var destroy=function(input){hide();input=$(input);input.data('trigger').remove();input.attr('autocomplete',input.data('original-autocomplete')).attr('maxlength',input.data('original-maxlength')).removeData().removeClass('miniColors').unbind('.miniColors');$(document).unbind('.miniColors')};var enable=function(input){input.prop('disabled',false).data('trigger').css('opacity',1)};var disable=function(input){hide(input);input.prop('disabled',true).data('trigger').css('opacity',0.5)};var show=function(input){if(input.prop('disabled'))return false;hide();var selector=$('<div class="miniColors-selector"></div>');selector.append('<div class="miniColors-colors" style="background-color: #FFF;"><div class="miniColors-colorPicker"></div></div>').append('<div class="miniColors-hues"><div class="miniColors-huePicker"></div></div>').css({top:input.is(':visible')?input.offset().top+input.outerHeight():input.data('trigger').offset().top+input.data('trigger').outerHeight(),left:input.is(':visible')?input.offset().left:input.data('trigger').offset().left,display:'none'}).addClass(input.attr('class'));var hsb=input.data('hsb');selector.find('.miniColors-colors').css('backgroundColor','#'+hsb2hex({h:hsb.h,s:100,b:100}));var colorPosition=input.data('colorPosition');if(!colorPosition)colorPosition=getColorPositionFromHSB(hsb);selector.find('.miniColors-colorPicker').css('top',colorPosition.y+'px').css('left',colorPosition.x+'px');var huePosition=input.data('huePosition');if(!huePosition)huePosition=getHuePositionFromHSB(hsb);selector.find('.miniColors-huePicker').css('top',huePosition.y+'px');input.data('selector',selector).data('huePicker',selector.find('.miniColors-huePicker')).data('colorPicker',selector.find('.miniColors-colorPicker')).data('mousebutton',0);$('BODY').append(selector);selector.fadeIn(100);selector.bind('selectstart',function(){return false});$(document).bind('mousedown.miniColors touchstart.miniColors',function(event){input.data('mousebutton',1);if($(event.target).parents().andSelf().hasClass('miniColors-colors')){event.preventDefault();input.data('moving','colors');moveColor(input,event)}if($(event.target).parents().andSelf().hasClass('miniColors-hues')){event.preventDefault();input.data('moving','hues');moveHue(input,event)}if($(event.target).parents().andSelf().hasClass('miniColors-selector')){event.preventDefault();return}if($(event.target).parents().andSelf().hasClass('miniColors'))return;hide(input)});$(document).bind('mouseup.miniColors touchend.miniColors',function(event){event.preventDefault();input.data('mousebutton',0).removeData('moving')}).bind('mousemove.miniColors touchmove.miniColors',function(event){event.preventDefault();if(input.data('mousebutton')===1){if(input.data('moving')==='colors')moveColor(input,event);if(input.data('moving')==='hues')moveHue(input,event)}})};var hide=function(input){if(!input)input='.miniColors';$(input).each(function(){var selector=$(this).data('selector');$(this).removeData('selector');$(selector).fadeOut(100,function(){$(this).remove()})});$(document).unbind('.miniColors')};var moveColor=function(input,event){var colorPicker=input.data('colorPicker');colorPicker.hide();var position={x:event.pageX,y:event.pageY};if(event.originalEvent.changedTouches){position.x=event.originalEvent.changedTouches[0].pageX;position.y=event.originalEvent.changedTouches[0].pageY}position.x=position.x-input.data('selector').find('.miniColors-colors').offset().left-5;position.y=position.y-input.data('selector').find('.miniColors-colors').offset().top-5;if(position.x<=-5)position.x=-5;if(position.x>=144)position.x=144;if(position.y<=-5)position.y=-5;if(position.y>=144)positiLine truncated
|
||||
@@ -0,0 +1,6 @@
|
||||
var pic = $(".app-pic").length,w,h;
|
||||
for(i=0; i<pic; i=i+1) {
|
||||
w = $(".app-pic").eq(i).width();
|
||||
h = $(".app-pic").eq(i).height();
|
||||
$(".app-pic").eq(i).find('img').muImageResize({width: w, height: h});
|
||||
}
|
||||
@@ -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 ($.browser.msie)
|
||||
{
|
||||
// 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 (!$.browser.msie)
|
||||
{
|
||||
// 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 || $.browser.msie ) {
|
||||
$( this ).trigger( "load" ).trigger( "error" );
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
})( jQuery );
|
||||
@@ -0,0 +1,240 @@
|
||||
/*
|
||||
* Tiny Scrollbar 1.8
|
||||
* http://www.baijs.nl/tinyscrollbar/
|
||||
*
|
||||
* Copyright 2012, Maarten Baijs
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.opensource.org/licenses/gpl-2.0.php
|
||||
*
|
||||
* Date: 26 / 07 / 2012
|
||||
* Depends on library: jQuery
|
||||
*
|
||||
*/
|
||||
;( function( $ )
|
||||
{
|
||||
$.tiny = $.tiny || { };
|
||||
|
||||
$.tiny.scrollbar = {
|
||||
options: {
|
||||
axis : 'y' // vertical or horizontal scrollbar? ( x || y ).
|
||||
, wheel : 40 // how many pixels must the mouswheel scroll at a time.
|
||||
, scroll : true // enable or disable the mousewheel.
|
||||
, lockscroll : true // return scrollwheel to browser if there is no more content.
|
||||
, size : 'auto' // set the size of the scrollbar to auto or a fixed number.
|
||||
, sizethumb : 'auto' // set the size of the thumb to auto or a fixed number.
|
||||
, invertscroll : false // Enable mobile invert style scrolling
|
||||
, onMove : function(){}
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.tinyscrollbar = function( params )
|
||||
{
|
||||
var options = $.extend( {}, $.tiny.scrollbar.options, params );
|
||||
this.each( function()
|
||||
{
|
||||
|
||||
$( this ).data('tsb', new Scrollbar( $( this ), options ) );
|
||||
});
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
$.fn.tinyscrollbar_update = function(sScroll)
|
||||
{
|
||||
|
||||
return $( this ).data( 'tsb' ).update( sScroll );
|
||||
};
|
||||
|
||||
function Scrollbar( root, options )
|
||||
{
|
||||
var oSelf = this
|
||||
, oWrapper = root
|
||||
, oViewport = { obj: $( '.viewport', root ) }
|
||||
, oContent = { obj: $( '.overview', root ) }
|
||||
, oScrollbar = { obj: $( '.scrollbar', root ) }
|
||||
, oTrack = { obj: $( '.track', oScrollbar.obj ) }
|
||||
, oThumb = { obj: $( '.thumb', oScrollbar.obj ) }
|
||||
, sAxis = options.axis === 'x'
|
||||
, sDirection = sAxis ? 'left' : 'top'
|
||||
, sSize = sAxis ? 'Width' : 'Height'
|
||||
, iScroll = 0
|
||||
, iPosition = { start: 0, now: 0 }
|
||||
, iMouse = {}
|
||||
, touchEvents = 'ontouchstart' in document.documentElement
|
||||
, UA = $.browser
|
||||
;
|
||||
|
||||
function initialize()
|
||||
{
|
||||
oSelf.update();
|
||||
setEvents();
|
||||
|
||||
return oSelf;
|
||||
}
|
||||
|
||||
this.update = function( sScroll )
|
||||
{
|
||||
oViewport[ options.axis ] = oViewport.obj[0][ 'offset'+ sSize ];
|
||||
oContent[ options.axis ] = oContent.obj[0][ 'scroll'+ sSize ];
|
||||
oContent.ratio = oViewport[ options.axis ] / oContent[ options.axis ];
|
||||
|
||||
oScrollbar.obj.toggleClass( 'disable', oContent.ratio >= 1 );
|
||||
|
||||
oTrack[ options.axis ] = options.size === 'auto' ? oViewport[ options.axis ] : options.size;
|
||||
oThumb[ options.axis ] = Math.min( oTrack[ options.axis ], Math.max( 0, ( options.sizethumb === 'auto' ? ( oTrack[ options.axis ] * oContent.ratio ) : options.sizethumb ) ) );
|
||||
|
||||
oScrollbar.ratio = options.sizethumb === 'auto' ? ( oContent[ options.axis ] / oTrack[ options.axis ] ) : ( oContent[ options.axis ] - oViewport[ options.axis ] ) / ( oTrack[ options.axis ] - oThumb[ options.axis ] );
|
||||
|
||||
iScroll = ( sScroll === 'relative' && oContent.ratio <= 1 ) ? Math.min( ( oContent[ options.axis ] - oViewport[ options.axis ] ), Math.max( 0, iScroll )) : 0;
|
||||
iScroll = ( sScroll === 'bottom' && oContent.ratio <= 1 ) ? ( oContent[ options.axis ] - oViewport[ options.axis ] ) : isNaN( parseInt( sScroll, 10 ) ) ? iScroll : parseInt( sScroll, 10 );
|
||||
|
||||
setSize();
|
||||
};
|
||||
|
||||
function setSize()
|
||||
{
|
||||
var sCssSize = sSize.toLowerCase();
|
||||
|
||||
oThumb.obj.css( sDirection, iScroll / oScrollbar.ratio );
|
||||
oContent.obj.css( sDirection, -iScroll );
|
||||
iMouse.start = oThumb.obj.offset()[ sDirection ];
|
||||
|
||||
oScrollbar.obj.css( sCssSize, oTrack[ options.axis ] );
|
||||
oTrack.obj.css( sCssSize, oTrack[ options.axis ] );
|
||||
oThumb.obj.css( sCssSize, oThumb[ options.axis ] );
|
||||
}
|
||||
|
||||
function setEvents()
|
||||
{
|
||||
if( ! touchEvents )
|
||||
{
|
||||
oThumb.obj.bind( 'mousedown', start );
|
||||
oTrack.obj.bind( 'mouseup', drag );
|
||||
}
|
||||
else
|
||||
{
|
||||
oViewport.obj[0].ontouchstart = function( event )
|
||||
{
|
||||
if( 1 === event.touches.length )
|
||||
{
|
||||
start( event.touches[ 0 ] );
|
||||
event.stopPropagation();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if( options.scroll && window.addEventListener )
|
||||
{
|
||||
oWrapper[0].addEventListener( 'DOMMouseScroll', wheel, false );
|
||||
oWrapper[0].addEventListener( 'mousewheel', wheel, false );
|
||||
oWrapper[0].addEventListener( 'MozMousePixelScroll', function( event ){
|
||||
event.preventDefault();
|
||||
}, false);
|
||||
}
|
||||
else if( options.scroll )
|
||||
{
|
||||
oWrapper[0].onmousewheel = wheel;
|
||||
}
|
||||
}
|
||||
|
||||
function start( event )
|
||||
{
|
||||
$( "body" ).addClass( "noSelect" );
|
||||
// Disable select text under IE10
|
||||
if ( UA.msie < 10 ){
|
||||
$( "body" ).attr({
|
||||
"onselectstart": "return false",
|
||||
"ondragstart": "return false"
|
||||
});
|
||||
}
|
||||
oScrollbar.obj.addClass( "dragging" );
|
||||
|
||||
var oThumbDir = parseInt( oThumb.obj.css( sDirection ), 10 );
|
||||
iMouse.start = sAxis ? event.pageX : event.pageY;
|
||||
iPosition.start = oThumbDir == 'auto' ? 0 : oThumbDir;
|
||||
|
||||
if( ! touchEvents )
|
||||
{
|
||||
$( document ).bind( 'mousemove', drag );
|
||||
$( document ).bind( 'mouseup', end );
|
||||
oThumb.obj.bind( 'mouseup', end );
|
||||
}
|
||||
else
|
||||
{
|
||||
document.ontouchmove = function( event )
|
||||
{
|
||||
event.preventDefault();
|
||||
drag( event.touches[ 0 ] );
|
||||
};
|
||||
document.ontouchend = end;
|
||||
}
|
||||
}
|
||||
|
||||
function wheel( event )
|
||||
{
|
||||
if( oContent.ratio < 1 )
|
||||
{
|
||||
var oEvent = event || window.event
|
||||
, iDelta = oEvent.wheelDelta ? oEvent.wheelDelta / 120 : -oEvent.detail / 3
|
||||
;
|
||||
|
||||
iScroll -= iDelta * options.wheel;
|
||||
iScroll = Math.min( ( oContent[ options.axis ] - oViewport[ options.axis ] ), Math.max( 0, iScroll ));
|
||||
|
||||
oThumb.obj.css( sDirection, iScroll / oScrollbar.ratio );
|
||||
oContent.obj.css( sDirection, -iScroll );
|
||||
|
||||
if( options.lockscroll || ( iScroll !== ( oContent[ options.axis ] - oViewport[ options.axis ] ) && iScroll !== 0 ) )
|
||||
{
|
||||
oEvent = $.event.fix( oEvent );
|
||||
oEvent.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
options.onMove.call(this,get_destance_from_end());
|
||||
}
|
||||
|
||||
function get_destance_from_end(){
|
||||
var distance_to_end = (oContent.obj.width() - oScrollbar.obj.width()) - iScroll;
|
||||
return distance_to_end;
|
||||
}
|
||||
|
||||
function drag( event )
|
||||
{
|
||||
if( oContent.ratio < 1 )
|
||||
{
|
||||
if( options.invertscroll && touchEvents )
|
||||
{
|
||||
iPosition.now = Math.min( ( oTrack[ options.axis ] - oThumb[ options.axis ] ), Math.max( 0, ( iPosition.start + ( iMouse.start - ( sAxis ? event.pageX : event.pageY ) ))));
|
||||
}
|
||||
else
|
||||
{
|
||||
iPosition.now = Math.min( ( oTrack[ options.axis ] - oThumb[ options.axis ] ), Math.max( 0, ( iPosition.start + ( ( sAxis ? event.pageX : event.pageY ) - iMouse.start))));
|
||||
}
|
||||
|
||||
iScroll = iPosition.now * oScrollbar.ratio;
|
||||
oContent.obj.css( sDirection, -iScroll );
|
||||
oThumb.obj.css( sDirection, iPosition.now );
|
||||
}
|
||||
options.onMove.call(this,get_destance_from_end());
|
||||
}
|
||||
|
||||
function end()
|
||||
{
|
||||
$( "body" ).removeClass( "noSelect" );
|
||||
// Enable select text under IE10
|
||||
if ( UA.msie < 10 ){
|
||||
$( "body" ).removeAttr( "onselectstart", "ondragstart" );
|
||||
}
|
||||
oScrollbar.obj.removeClass( "dragging" );
|
||||
$( document ).unbind( 'mousemove', drag );
|
||||
$( document ).unbind( 'mouseup', end );
|
||||
oThumb.obj.unbind( 'mouseup', end );
|
||||
document.ontouchmove = document.ontouchend = null;
|
||||
}
|
||||
|
||||
return initialize();
|
||||
}
|
||||
|
||||
}(jQuery));
|
||||
@@ -0,0 +1,126 @@
|
||||
(function(a){
|
||||
function b(b,c){
|
||||
function w(a){
|
||||
if(!(g.ratio>=1)){
|
||||
o.now=Math.min(i[c.axis]-j[c.axis],Math.max(0,o.start+((k?a.pageX:a.pageY)-p.start)));
|
||||
n=o.now*h.ratio;
|
||||
g.obj.css(l,-n);
|
||||
j.obj.css(l,o.now)
|
||||
}
|
||||
return false
|
||||
}
|
||||
function v(b){
|
||||
a(document).unbind("mousemove",w);
|
||||
a(document).unbind("mouseup",v);
|
||||
j.obj.unbind("mouseup",v);
|
||||
document.ontouchmove=j.obj[0].ontouchend=document.ontouchend=null;
|
||||
return false
|
||||
}
|
||||
function u(b){
|
||||
if(!(g.ratio>=1)){
|
||||
var b=b||window.event;
|
||||
var d=b.wheelDelta?b.wheelDelta/120:-b.detail/3;
|
||||
n-=d*c.wheel;
|
||||
n=Math.min(g[c.axis]-f[c.axis],Math.max(0,n));
|
||||
j.obj.css(l,n/h.ratio);
|
||||
g.obj.css(l,-n);
|
||||
b=a.event.fix(b);
|
||||
b.preventDefault()
|
||||
}
|
||||
}
|
||||
function t(b){
|
||||
p.start=k?b.pageX:b.pageY;
|
||||
var c=parseInt(j.obj.css(l));
|
||||
o.start=c=="auto"?0:c;
|
||||
a(document).bind("mousemove",w);
|
||||
document.ontouchmove=function(b){
|
||||
a(document).unbind("mousemove");
|
||||
w(b.touches[0])
|
||||
};
|
||||
a(document).bind("mouseup",v);
|
||||
j.obj.bind("mouseup",v);
|
||||
j.obj[0].ontouchend=document.ontouchend=function(b){
|
||||
a(document).unbind("mouseup");
|
||||
j.obj.unbind("mouseup");
|
||||
v(b.touches[0])};
|
||||
return false
|
||||
}
|
||||
function s(){
|
||||
j.obj.bind("mousedown",t);
|
||||
j.obj[0].ontouchstart=function(a){
|
||||
a.preventDefault();
|
||||
j.obj.unbind("mousedown");
|
||||
t(a.touches[0]);
|
||||
return false
|
||||
};
|
||||
i.obj.bind("mouseup",w);
|
||||
if(c.scroll&&this.addEventListener){
|
||||
e[0].addEventListener("DOMMouseScroll",u,false);
|
||||
e[0].addEventListener("mousewheel",u,false)
|
||||
}else if(c.scroll){
|
||||
e[0].onmousewheel=u
|
||||
}
|
||||
}
|
||||
function r(){
|
||||
j.obj.css(l,n/h.ratio);
|
||||
g.obj.css(l,-n);
|
||||
p["start"]=j.obj.offset()[l];
|
||||
var a=m.toLowerCase();
|
||||
h.obj.css(a,i[c.axis]);
|
||||
i.obj.css(a,i[c.axis]);
|
||||
j.obj.css(a,j[c.axis])
|
||||
}
|
||||
function q(){
|
||||
d.update();
|
||||
s();
|
||||
return d
|
||||
}
|
||||
var d=this;
|
||||
var e=b;
|
||||
var f={obj:a(".viewport",b)};
|
||||
var g={obj:a(".overview",b)};
|
||||
var h={obj:a(".scrollbar",b)};
|
||||
var i={obj:a(".track",h.obj)};
|
||||
var j={obj:a(".thumb",h.obj)};
|
||||
var k=c.axis=="x",
|
||||
l=k?"left":"top",
|
||||
m=k?"Width":"Height";
|
||||
var n,
|
||||
o={start:0,now:0},
|
||||
p={};
|
||||
this.update=function(a){
|
||||
f[c.axis]=f.obj[0]["offset"+m];
|
||||
g[c.axis]=g.obj[0]["scroll"+m];
|
||||
g.ratio=f[c.axis]/g[c.axis];
|
||||
h.obj.toggleClass("disable",g.ratio>=1);
|
||||
i[c.axis]=c.size=="auto"?f[c.axis]:c.size;
|
||||
j[c.axis]=Math.min(i[c.axis],Math.max(0,c.sizethumb=="auto"?i[c.axis]*g.ratio:c.sizethumb));
|
||||
h.ratio=c.sizethumb=="auto"?g[c.axis]/i[c.axis]:(g[c.axis]-f[c.axis])/(i[c.axis]-j[c.axis]);
|
||||
n=a=="relative"&&g.ratio<=1?Math.min(g[c.axis]-f[c.axis],Math.max(0,n)):0;
|
||||
n=a=="bottom"&&g.ratio<=1?g[c.axis]-f[c.axis]:isNaN(parseInt(a))?n:parseInt(a);
|
||||
r()
|
||||
};
|
||||
return q()
|
||||
}
|
||||
a.tiny=a.tiny||{};
|
||||
a.tiny.scrollbar={
|
||||
options:{
|
||||
axis:"y",
|
||||
wheel:40,
|
||||
scroll:true,
|
||||
size:"auto",
|
||||
sizethumb:"auto"
|
||||
}
|
||||
};
|
||||
a.fn.tinyscrollbar=function(c){
|
||||
var c=a.extend({},a.tiny.scrollbar.options,c);
|
||||
this.each(function(){
|
||||
a(this).data("tsb",new b(a(this),c))
|
||||
});
|
||||
return this
|
||||
};
|
||||
a.fn.tinyscrollbar_update=function(b){
|
||||
return a(this).data("tsb").update(b)
|
||||
};
|
||||
})
|
||||
(jQuery)
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,56 @@
|
||||
<%#= encoding: utf-8 %>
|
||||
$(function() {
|
||||
var content_holder, content;
|
||||
var selector = 'a[contenteditable="true"]';
|
||||
// prevent clicks inside editable area to fire
|
||||
// a click event on the body
|
||||
// and therefor saving our content before we even edit it
|
||||
|
||||
$(".nav-tabs").find(".icons-pencil").click(function(){
|
||||
$(this).css({
|
||||
"display" : "none"
|
||||
})
|
||||
$(this).next().attr("contenteditable",true).addClass("edit");
|
||||
// $(selector).click(function(e) {
|
||||
// e.stopPropagation();
|
||||
// });
|
||||
|
||||
// initialize the "save" function
|
||||
$(selector).focus(function(e) {
|
||||
content_holder = $(this);
|
||||
content = content_holder.html();
|
||||
// one click outside the editable area saves the content
|
||||
$(selector).keypress( function(e) {
|
||||
// but not if the content didn't change
|
||||
//alert('out!!');
|
||||
if(e.keyCode == 13){
|
||||
$(".nav-tabs>li>a").removeClass("edit");
|
||||
$(this).prev(".icons-pencil").css({
|
||||
"display" : "block"
|
||||
})
|
||||
e.preventDefault();
|
||||
// if ($(e.target).is(selector) || content == content_holder.html()) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
$.ajax({
|
||||
url: content_holder.data('edit-url'),
|
||||
type: 'POST',
|
||||
dataType: 'json',
|
||||
data: { body: content_holder.html() },
|
||||
success: function(json) {
|
||||
$(selector).attr("contenteditable",false)
|
||||
alert("<%= I18n.t('update.success_') %>");
|
||||
//content_holder.effect('highlight', {'color': '#0f0'}, 3000);
|
||||
},
|
||||
error: function() {
|
||||
alert("<%= I18n.t('update.fail') %>");
|
||||
//content_holder.effect('highlight', {'color': '#f00'}, 3000);
|
||||
content_holder.html(content);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,126 @@
|
||||
/*
|
||||
* Date Format 1.2.3
|
||||
* (c) 2007-2009 Steven Levithan <stevenlevithan.com>
|
||||
* MIT license
|
||||
*
|
||||
* Includes enhancements by Scott Trenda <scott.trenda.net>
|
||||
* and Kris Kowal <cixar.com/~kris.kowal/>
|
||||
*
|
||||
* Accepts a date, a mask, or a date and a mask.
|
||||
* Returns a formatted version of the given date.
|
||||
* The date defaults to the current date/time.
|
||||
* The mask defaults to dateFormat.masks.default.
|
||||
*/
|
||||
|
||||
var dateFormat = function () {
|
||||
var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
|
||||
timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
|
||||
timezoneClip = /[^-+\dA-Z]/g,
|
||||
pad = function (val, len) {
|
||||
val = String(val);
|
||||
len = len || 2;
|
||||
while (val.length < len) val = "0" + val;
|
||||
return val;
|
||||
};
|
||||
|
||||
// Regexes and supporting functions are cached through closure
|
||||
return function (date, mask, utc) {
|
||||
var dF = dateFormat;
|
||||
|
||||
// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
|
||||
if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
|
||||
mask = date;
|
||||
date = undefined;
|
||||
}
|
||||
|
||||
// Passing date through Date applies Date.parse, if necessary
|
||||
date = date ? new Date(date) : new Date;
|
||||
if (isNaN(date)) throw SyntaxError("invalid date");
|
||||
|
||||
mask = String(dF.masks[mask] || mask || dF.masks["default"]);
|
||||
|
||||
// Allow setting the utc argument via the mask
|
||||
if (mask.slice(0, 4) == "UTC:") {
|
||||
mask = mask.slice(4);
|
||||
utc = true;
|
||||
}
|
||||
|
||||
var _ = utc ? "getUTC" : "get",
|
||||
d = date[_ + "Date"](),
|
||||
D = date[_ + "Day"](),
|
||||
m = date[_ + "Month"](),
|
||||
y = date[_ + "FullYear"](),
|
||||
H = date[_ + "Hours"](),
|
||||
M = date[_ + "Minutes"](),
|
||||
s = date[_ + "Seconds"](),
|
||||
L = date[_ + "Milliseconds"](),
|
||||
o = utc ? 0 : date.getTimezoneOffset(),
|
||||
flags = {
|
||||
d: d,
|
||||
dd: pad(d),
|
||||
ddd: dF.i18n.dayNames[D],
|
||||
dddd: dF.i18n.dayNames[D + 7],
|
||||
m: m + 1,
|
||||
mm: pad(m + 1),
|
||||
mmm: dF.i18n.monthNames[m],
|
||||
mmmm: dF.i18n.monthNames[m + 12],
|
||||
yy: String(y).slice(2),
|
||||
yyyy: y,
|
||||
h: H % 12 || 12,
|
||||
hh: pad(H % 12 || 12),
|
||||
H: H,
|
||||
HH: pad(H),
|
||||
M: M,
|
||||
MM: pad(M),
|
||||
s: s,
|
||||
ss: pad(s),
|
||||
l: pad(L, 3),
|
||||
L: pad(L > 99 ? Math.round(L / 10) : L),
|
||||
t: H < 12 ? "a" : "p",
|
||||
tt: H < 12 ? "am" : "pm",
|
||||
T: H < 12 ? "A" : "P",
|
||||
TT: H < 12 ? "AM" : "PM",
|
||||
Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
|
||||
o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
|
||||
S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
|
||||
};
|
||||
|
||||
return mask.replace(token, function ($0) {
|
||||
return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
|
||||
});
|
||||
};
|
||||
}();
|
||||
|
||||
// Some common format strings
|
||||
dateFormat.masks = {
|
||||
"default": "ddd mmm dd yyyy HH:MM:ss",
|
||||
shortDate: "m/d/yy",
|
||||
mediumDate: "mmm d, yyyy",
|
||||
longDate: "mmmm d, yyyy",
|
||||
fullDate: "dddd, mmmm d, yyyy",
|
||||
shortTime: "h:MM TT",
|
||||
mediumTime: "h:MM:ss TT",
|
||||
longTime: "h:MM:ss TT Z",
|
||||
isoDate: "yyyy / mm / dd",
|
||||
isoTime: "HH:MM:ss",
|
||||
isoDateTime: "yyyy-mm-dd'T'HH:MM:ss",
|
||||
isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
|
||||
};
|
||||
|
||||
// Internationalization strings
|
||||
dateFormat.i18n = {
|
||||
dayNames: [
|
||||
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
|
||||
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
|
||||
],
|
||||
monthNames: [
|
||||
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
|
||||
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
|
||||
]
|
||||
};
|
||||
|
||||
// For convenience...
|
||||
Date.prototype.format = function (mask, utc) {
|
||||
return dateFormat(this, mask, utc);
|
||||
};
|
||||
|
||||
@@ -0,0 +1,891 @@
|
||||
/**
|
||||
*
|
||||
* Date picker
|
||||
* Author: Stefan Petre www.eyecon.ro
|
||||
*
|
||||
* Dual licensed under the MIT and GPL licenses
|
||||
*
|
||||
*/
|
||||
(function ($) {
|
||||
var DatePicker = function () {
|
||||
var ids = {},
|
||||
views = {
|
||||
years: 'datepickerViewYears',
|
||||
moths: 'datepickerViewMonths',
|
||||
days: 'datepickerViewDays'
|
||||
},
|
||||
tpl = {
|
||||
wrapper: '<div class="datepicker"><div class="datepickerContainer"><table cellspacing="0" cellpadding="0"><tbody><tr></tr></tbody></table></div></div>',
|
||||
head: [
|
||||
'<td>',
|
||||
'<table cellspacing="0" cellpadding="0">',
|
||||
'<thead>',
|
||||
'<tr>',
|
||||
'<th class="datepickerGoPrev"><a href="#"><span><%=prev%></span></a></th>',
|
||||
'<th colspan="6" class="datepickerMonth"><a href="#"><span></span></a></th>',
|
||||
'<th class="datepickerGoNext"><a href="#"><span><%=next%></span></a></th>',
|
||||
'</tr>',
|
||||
'<tr class="datepickerDoW">',
|
||||
'<th><span><%=week%></span></th>',
|
||||
'<th><span><%=day1%></span></th>',
|
||||
'<th><span><%=day2%></span></th>',
|
||||
'<th><span><%=day3%></span></th>',
|
||||
'<th><span><%=day4%></span></th>',
|
||||
'<th><span><%=day5%></span></th>',
|
||||
'<th><span><%=day6%></span></th>',
|
||||
'<th><span><%=day7%></span></th>',
|
||||
'</tr>',
|
||||
'</thead>',
|
||||
'</table></td>'
|
||||
],
|
||||
space : '<td class="datepickerSpace"><div></div></td>',
|
||||
days: [
|
||||
'<tbody class="datepickerDays">',
|
||||
'<tr>',
|
||||
'<th class="datepickerWeek"><a href="#"><span><%=weeks[0].week%></span></a></th>',
|
||||
'<td class="<%=weeks[0].days[0].classname%>"><a href="#"><span><%=weeks[0].days[0].text%></span></a></td>',
|
||||
'<td class="<%=weeks[0].days[1].classname%>"><a href="#"><span><%=weeks[0].days[1].text%></span></a></td>',
|
||||
'<td class="<%=weeks[0].days[2].classname%>"><a href="#"><span><%=weeks[0].days[2].text%></span></a></td>',
|
||||
'<td class="<%=weeks[0].days[3].classname%>"><a href="#"><span><%=weeks[0].days[3].text%></span></a></td>',
|
||||
'<td class="<%=weeks[0].days[4].classname%>"><a href="#"><span><%=weeks[0].days[4].text%></span></a></td>',
|
||||
'<td class="<%=weeks[0].days[5].classname%>"><a href="#"><span><%=weeks[0].days[5].text%></span></a></td>',
|
||||
'<td class="<%=weeks[0].days[6].classname%>"><a href="#"><span><%=weeks[0].days[6].text%></span></a></td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<th class="datepickerWeek"><a href="#"><span><%=weeks[1].week%></span></a></th>',
|
||||
'<td class="<%=weeks[1].days[0].classname%>"><a href="#"><span><%=weeks[1].days[0].text%></span></a></td>',
|
||||
'<td class="<%=weeks[1].days[1].classname%>"><a href="#"><span><%=weeks[1].days[1].text%></span></a></td>',
|
||||
'<td class="<%=weeks[1].days[2].classname%>"><a href="#"><span><%=weeks[1].days[2].text%></span></a></td>',
|
||||
'<td class="<%=weeks[1].days[3].classname%>"><a href="#"><span><%=weeks[1].days[3].text%></span></a></td>',
|
||||
'<td class="<%=weeks[1].days[4].classname%>"><a href="#"><span><%=weeks[1].days[4].text%></span></a></td>',
|
||||
'<td class="<%=weeks[1].days[5].classname%>"><a href="#"><span><%=weeks[1].days[5].text%></span></a></td>',
|
||||
'<td class="<%=weeks[1].days[6].classname%>"><a href="#"><span><%=weeks[1].days[6].text%></span></a></td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<th class="datepickerWeek"><a href="#"><span><%=weeks[2].week%></span></a></th>',
|
||||
'<td class="<%=weeks[2].days[0].classname%>"><a href="#"><span><%=weeks[2].days[0].text%></span></a></td>',
|
||||
'<td class="<%=weeks[2].days[1].classname%>"><a href="#"><span><%=weeks[2].days[1].text%></span></a></td>',
|
||||
'<td class="<%=weeks[2].days[2].classname%>"><a href="#"><span><%=weeks[2].days[2].text%></span></a></td>',
|
||||
'<td class="<%=weeks[2].days[3].classname%>"><a href="#"><span><%=weeks[2].days[3].text%></span></a></td>',
|
||||
'<td class="<%=weeks[2].days[4].classname%>"><a href="#"><span><%=weeks[2].days[4].text%></span></a></td>',
|
||||
'<td class="<%=weeks[2].days[5].classname%>"><a href="#"><span><%=weeks[2].days[5].text%></span></a></td>',
|
||||
'<td class="<%=weeks[2].days[6].classname%>"><a href="#"><span><%=weeks[2].days[6].text%></span></a></td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<th class="datepickerWeek"><a href="#"><span><%=weeks[3].week%></span></a></th>',
|
||||
'<td class="<%=weeks[3].days[0].classname%>"><a href="#"><span><%=weeks[3].days[0].text%></span></a></td>',
|
||||
'<td class="<%=weeks[3].days[1].classname%>"><a href="#"><span><%=weeks[3].days[1].text%></span></a></td>',
|
||||
'<td class="<%=weeks[3].days[2].classname%>"><a href="#"><span><%=weeks[3].days[2].text%></span></a></td>',
|
||||
'<td class="<%=weeks[3].days[3].classname%>"><a href="#"><span><%=weeks[3].days[3].text%></span></a></td>',
|
||||
'<td class="<%=weeks[3].days[4].classname%>"><a href="#"><span><%=weeks[3].days[4].text%></span></a></td>',
|
||||
'<td class="<%=weeks[3].days[5].classname%>"><a href="#"><span><%=weeks[3].days[5].text%></span></a></td>',
|
||||
'<td class="<%=weeks[3].days[6].classname%>"><a href="#"><span><%=weeks[3].days[6].text%></span></a></td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<th class="datepickerWeek"><a href="#"><span><%=weeks[4].week%></span></a></th>',
|
||||
'<td class="<%=weeks[4].days[0].classname%>"><a href="#"><span><%=weeks[4].days[0].text%></span></a></td>',
|
||||
'<td class="<%=weeks[4].days[1].classname%>"><a href="#"><span><%=weeks[4].days[1].text%></span></a></td>',
|
||||
'<td class="<%=weeks[4].days[2].classname%>"><a href="#"><span><%=weeks[4].days[2].text%></span></a></td>',
|
||||
'<td class="<%=weeks[4].days[3].classname%>"><a href="#"><span><%=weeks[4].days[3].text%></span></a></td>',
|
||||
'<td class="<%=weeks[4].days[4].classname%>"><a href="#"><span><%=weeks[4].days[4].text%></span></a></td>',
|
||||
'<td class="<%=weeks[4].days[5].classname%>"><a href="#"><span><%=weeks[4].days[5].text%></span></a></td>',
|
||||
'<td class="<%=weeks[4].days[6].classname%>"><a href="#"><span><%=weeks[4].days[6].text%></span></a></td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<th class="datepickerWeek"><a href="#"><span><%=weeks[5].week%></span></a></th>',
|
||||
'<td class="<%=weeks[5].days[0].classname%>"><a href="#"><span><%=weeks[5].days[0].text%></span></a></td>',
|
||||
'<td class="<%=weeks[5].days[1].classname%>"><a href="#"><span><%=weeks[5].days[1].text%></span></a></td>',
|
||||
'<td class="<%=weeks[5].days[2].classname%>"><a href="#"><span><%=weeks[5].days[2].text%></span></a></td>',
|
||||
'<td class="<%=weeks[5].days[3].classname%>"><a href="#"><span><%=weeks[5].days[3].text%></span></a></td>',
|
||||
'<td class="<%=weeks[5].days[4].classname%>"><a href="#"><span><%=weeks[5].days[4].text%></span></a></td>',
|
||||
'<td class="<%=weeks[5].days[5].classname%>"><a href="#"><span><%=weeks[5].days[5].text%></span></a></td>',
|
||||
'<td class="<%=weeks[5].days[6].classname%>"><a href="#"><span><%=weeks[5].days[6].text%></span></a></td>',
|
||||
'</tr>',
|
||||
'</tbody>'
|
||||
],
|
||||
months: [
|
||||
'<tbody class="<%=className%>">',
|
||||
'<tr>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[0]%></span></a></td>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[1]%></span></a></td>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[2]%></span></a></td>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[3]%></span></a></td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[4]%></span></a></td>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[5]%></span></a></td>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[6]%></span></a></td>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[7]%></span></a></td>',
|
||||
'</tr>',
|
||||
'<tr>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[8]%></span></a></td>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[9]%></span></a></td>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[10]%></span></a></td>',
|
||||
'<td colspan="2"><a href="#"><span><%=data[11]%></span></a></td>',
|
||||
'</tr>',
|
||||
'</tbody>'
|
||||
]
|
||||
},
|
||||
defaults = {
|
||||
flat: false,
|
||||
starts: 1,
|
||||
prev: '◀',
|
||||
next: '▶',
|
||||
lastSel: false,
|
||||
mode: 'single',
|
||||
view: 'days',
|
||||
calendars: 1,
|
||||
format: 'Y-m-d',
|
||||
position: 'bottom',
|
||||
eventName: 'click',
|
||||
onRender: function(){return {};},
|
||||
onChange: function(){return true;},
|
||||
onShow: function(){return true;},
|
||||
onBeforeShow: function(){return true;},
|
||||
onHide: function(){return true;},
|
||||
locale: {
|
||||
days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"],
|
||||
daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
|
||||
daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"],
|
||||
months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
||||
monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
||||
weekMin: 'wk'
|
||||
}
|
||||
},
|
||||
fill = function(el) {
|
||||
var options = $(el).data('datepicker');
|
||||
var cal = $(el);
|
||||
var currentCal = Math.floor(options.calendars/2), date, data, dow, month, cnt = 0, week, days, indic, indic2, html, tblCal;
|
||||
cal.find('td>table tbody').remove();
|
||||
for (var i = 0; i < options.calendars; i++) {
|
||||
date = new Date(options.current);
|
||||
date.addMonths(-currentCal + i);
|
||||
tblCal = cal.find('table').eq(i+1);
|
||||
switch (tblCal[0].className) {
|
||||
case 'datepickerViewDays':
|
||||
dow = formatDate(date, 'B, Y');
|
||||
break;
|
||||
case 'datepickerViewMonths':
|
||||
dow = date.getFullYear();
|
||||
break;
|
||||
case 'datepickerViewYears':
|
||||
dow = (date.getFullYear()-6) + ' - ' + (date.getFullYear()+5);
|
||||
break;
|
||||
}
|
||||
tblCal.find('thead tr:first th:eq(1) span').text(dow);
|
||||
dow = date.getFullYear()-6;
|
||||
data = {
|
||||
data: [],
|
||||
className: 'datepickerYears'
|
||||
}
|
||||
for ( var j = 0; j < 12; j++) {
|
||||
data.data.push(dow + j);
|
||||
}
|
||||
html = tmpl(tpl.months.join(''), data);
|
||||
date.setDate(1);
|
||||
data = {weeks:[], test: 10};
|
||||
month = date.getMonth();
|
||||
var dow = (date.getDay() - options.starts) % 7;
|
||||
date.addDays(-(dow + (dow < 0 ? 7 : 0)));
|
||||
week = -1;
|
||||
cnt = 0;
|
||||
while (cnt < 42) {
|
||||
indic = parseInt(cnt/7,10);
|
||||
indic2 = cnt%7;
|
||||
if (!data.weeks[indic]) {
|
||||
week = date.getWeekNumber();
|
||||
data.weeks[indic] = {
|
||||
week: week,
|
||||
days: []
|
||||
};
|
||||
}
|
||||
data.weeks[indic].days[indic2] = {
|
||||
text: date.getDate(),
|
||||
classname: []
|
||||
};
|
||||
if (month != date.getMonth()) {
|
||||
data.weeks[indic].days[indic2].classname.push('datepickerNotInMonth');
|
||||
}
|
||||
if (date.getDay() == 0) {
|
||||
data.weeks[indic].days[indic2].classname.push('datepickerSunday');
|
||||
}
|
||||
if (date.getDay() == 6) {
|
||||
data.weeks[indic].days[indic2].classname.push('datepickerSaturday');
|
||||
}
|
||||
var fromUser = options.onRender(date);
|
||||
var val = date.valueOf();
|
||||
if (fromUser.selected || options.date == val || $.inArray(val, options.date) > -1 || (options.mode == 'range' && val >= options.date[0] && val <= options.date[1])) {
|
||||
data.weeks[indic].days[indic2].classname.push('datepickerSelected');
|
||||
}
|
||||
if (fromUser.disabled) {
|
||||
data.weeks[indic].days[indic2].classname.push('datepickerDisabled');
|
||||
}
|
||||
if (fromUser.className) {
|
||||
data.weeks[indic].days[indic2].classname.push(fromUser.className);
|
||||
}
|
||||
data.weeks[indic].days[indic2].classname = data.weeks[indic].days[indic2].classname.join(' ');
|
||||
cnt++;
|
||||
date.addDays(1);
|
||||
}
|
||||
html = tmpl(tpl.days.join(''), data) + html;
|
||||
data = {
|
||||
data: options.locale.monthsShort,
|
||||
className: 'datepickerMonths'
|
||||
};
|
||||
html = tmpl(tpl.months.join(''), data) + html;
|
||||
tblCal.append(html);
|
||||
}
|
||||
},
|
||||
parseDate = function (date, format) {
|
||||
if (date.constructor == Date) {
|
||||
return new Date(date);
|
||||
}
|
||||
var parts = date.split(/\W+/);
|
||||
var against = format.split(/\W+/), d, m, y, h, min, now = new Date();
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
switch (against[i]) {
|
||||
case 'd':
|
||||
case 'e':
|
||||
d = parseInt(parts[i],10);
|
||||
break;
|
||||
case 'm':
|
||||
m = parseInt(parts[i], 10)-1;
|
||||
break;
|
||||
case 'Y':
|
||||
case 'y':
|
||||
y = parseInt(parts[i], 10);
|
||||
y += y > 100 ? 0 : (y < 29 ? 2000 : 1900);
|
||||
break;
|
||||
case 'H':
|
||||
case 'I':
|
||||
case 'k':
|
||||
case 'l':
|
||||
h = parseInt(parts[i], 10);
|
||||
break;
|
||||
case 'P':
|
||||
case 'p':
|
||||
if (/pm/i.test(parts[i]) && h < 12) {
|
||||
h += 12;
|
||||
} else if (/am/i.test(parts[i]) && h >= 12) {
|
||||
h -= 12;
|
||||
}
|
||||
break;
|
||||
case 'M':
|
||||
min = parseInt(parts[i], 10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return new Date(
|
||||
y === undefined ? now.getFullYear() : y,
|
||||
m === undefined ? now.getMonth() : m,
|
||||
d === undefined ? now.getDate() : d,
|
||||
h === undefined ? now.getHours() : h,
|
||||
min === undefined ? now.getMinutes() : min,
|
||||
0
|
||||
);
|
||||
},
|
||||
formatDate = function(date, format) {
|
||||
var m = date.getMonth();
|
||||
var d = date.getDate();
|
||||
var y = date.getFullYear();
|
||||
var wn = date.getWeekNumber();
|
||||
var w = date.getDay();
|
||||
var s = {};
|
||||
var hr = date.getHours();
|
||||
var pm = (hr >= 12);
|
||||
var ir = (pm) ? (hr - 12) : hr;
|
||||
var dy = date.getDayOfYear();
|
||||
if (ir == 0) {
|
||||
ir = 12;
|
||||
}
|
||||
var min = date.getMinutes();
|
||||
var sec = date.getSeconds();
|
||||
var parts = format.split(''), part;
|
||||
for ( var i = 0; i < parts.length; i++ ) {
|
||||
part = parts[i];
|
||||
switch (parts[i]) {
|
||||
case 'a':
|
||||
part = date.getDayName();
|
||||
break;
|
||||
case 'A':
|
||||
part = date.getDayName(true);
|
||||
break;
|
||||
case 'b':
|
||||
part = date.getMonthName();
|
||||
break;
|
||||
case 'B':
|
||||
part = date.getMonthName(true);
|
||||
break;
|
||||
case 'C':
|
||||
part = 1 + Math.floor(y / 100);
|
||||
break;
|
||||
case 'd':
|
||||
part = (d < 10) ? ("0" + d) : d;
|
||||
break;
|
||||
case 'e':
|
||||
part = d;
|
||||
break;
|
||||
case 'H':
|
||||
part = (hr < 10) ? ("0" + hr) : hr;
|
||||
break;
|
||||
case 'I':
|
||||
part = (ir < 10) ? ("0" + ir) : ir;
|
||||
break;
|
||||
case 'j':
|
||||
part = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy;
|
||||
break;
|
||||
case 'k':
|
||||
part = hr;
|
||||
break;
|
||||
case 'l':
|
||||
part = ir;
|
||||
break;
|
||||
case 'm':
|
||||
part = (m < 9) ? ("0" + (1+m)) : (1+m);
|
||||
break;
|
||||
case 'M':
|
||||
part = (min < 10) ? ("0" + min) : min;
|
||||
break;
|
||||
case 'p':
|
||||
case 'P':
|
||||
part = pm ? "PM" : "AM";
|
||||
break;
|
||||
case 's':
|
||||
part = Math.floor(date.getTime() / 1000);
|
||||
break;
|
||||
case 'S':
|
||||
part = (sec < 10) ? ("0" + sec) : sec;
|
||||
break;
|
||||
case 'u':
|
||||
part = w + 1;
|
||||
break;
|
||||
case 'w':
|
||||
part = w;
|
||||
break;
|
||||
case 'y':
|
||||
part = ('' + y).substr(2, 2);
|
||||
break;
|
||||
case 'Y':
|
||||
part = y;
|
||||
break;
|
||||
}
|
||||
parts[i] = part;
|
||||
}
|
||||
return parts.join('');
|
||||
},
|
||||
extendDate = function(options) {
|
||||
if (Date.prototype.tempDate) {
|
||||
return;
|
||||
}
|
||||
Date.prototype.tempDate = null;
|
||||
Date.prototype.months = options.months;
|
||||
Date.prototype.monthsShort = options.monthsShort;
|
||||
Date.prototype.days = options.days;
|
||||
Date.prototype.daysShort = options.daysShort;
|
||||
Date.prototype.getMonthName = function(fullName) {
|
||||
return this[fullName ? 'months' : 'monthsShort'][this.getMonth()];
|
||||
};
|
||||
Date.prototype.getDayName = function(fullName) {
|
||||
return this[fullName ? 'days' : 'daysShort'][this.getDay()];
|
||||
};
|
||||
Date.prototype.addDays = function (n) {
|
||||
this.setDate(this.getDate() + n);
|
||||
this.tempDate = this.getDate();
|
||||
};
|
||||
Date.prototype.addMonths = function (n) {
|
||||
if (this.tempDate == null) {
|
||||
this.tempDate = this.getDate();
|
||||
}
|
||||
this.setDate(1);
|
||||
this.setMonth(this.getMonth() + n);
|
||||
this.setDate(Math.min(this.tempDate, this.getMaxDays()));
|
||||
};
|
||||
Date.prototype.addYears = function (n) {
|
||||
if (this.tempDate == null) {
|
||||
this.tempDate = this.getDate();
|
||||
}
|
||||
this.setDate(1);
|
||||
this.setFullYear(this.getFullYear() + n);
|
||||
this.setDate(Math.min(this.tempDate, this.getMaxDays()));
|
||||
};
|
||||
Date.prototype.getMaxDays = function() {
|
||||
var tmpDate = new Date(Date.parse(this)),
|
||||
d = 28, m;
|
||||
m = tmpDate.getMonth();
|
||||
d = 28;
|
||||
while (tmpDate.getMonth() == m) {
|
||||
d ++;
|
||||
tmpDate.setDate(d);
|
||||
}
|
||||
return d - 1;
|
||||
};
|
||||
Date.prototype.getFirstDay = function() {
|
||||
var tmpDate = new Date(Date.parse(this));
|
||||
tmpDate.setDate(1);
|
||||
return tmpDate.getDay();
|
||||
};
|
||||
Date.prototype.getWeekNumber = function() {
|
||||
var tempDate = new Date(this);
|
||||
tempDate.setDate(tempDate.getDate() - (tempDate.getDay() + 6) % 7 + 3);
|
||||
var dms = tempDate.valueOf();
|
||||
tempDate.setMonth(0);
|
||||
tempDate.setDate(4);
|
||||
return Math.round((dms - tempDate.valueOf()) / (604800000)) + 1;
|
||||
};
|
||||
Date.prototype.getDayOfYear = function() {
|
||||
var now = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
|
||||
var then = new Date(this.getFullYear(), 0, 0, 0, 0, 0);
|
||||
var time = now - then;
|
||||
return Math.floor(time / 24*60*60*1000);
|
||||
};
|
||||
},
|
||||
layout = function (el) {
|
||||
var options = $(el).data('datepicker');
|
||||
var cal = $('#' + options.id);
|
||||
if (!options.extraHeight) {
|
||||
var divs = $(el).find('div');
|
||||
//options.extraHeight = divs.get(0).offsetHeight + divs.get(1).offsetHeight;
|
||||
//options.extraWidth = divs.get(2).offsetWidth + divs.get(3).offsetWidth;
|
||||
}
|
||||
var tbl = cal.find('table:first').get(0);
|
||||
var width = tbl.offsetWidth;
|
||||
var height = tbl.offsetHeight;
|
||||
cal.css({
|
||||
width: width + options.extraWidth + 'px',
|
||||
height: height + options.extraHeight + 'px'
|
||||
}).find('div.datepickerContainer').css({
|
||||
width: width + 'px',
|
||||
height: height + 'px'
|
||||
});
|
||||
},
|
||||
click = function(ev) {
|
||||
if ($(ev.target).is('span')) {
|
||||
ev.target = ev.target.parentNode;
|
||||
}
|
||||
var el = $(ev.target);
|
||||
if (el.is('a')) {
|
||||
ev.target.blur();
|
||||
if (el.hasClass('datepickerDisabled')) {
|
||||
return false;
|
||||
}
|
||||
var options = $(this).data('datepicker');
|
||||
var parentEl = el.parent();
|
||||
var tblEl = parentEl.parent().parent().parent();
|
||||
var tblIndex = $('table', this).index(tblEl.get(0)) - 1;
|
||||
var tmp = new Date(options.current);
|
||||
var changed = false;
|
||||
var fillIt = false;
|
||||
if (parentEl.is('th')) {
|
||||
if (parentEl.hasClass('datepickerWeek') && options.mode == 'range' && !parentEl.next().hasClass('datepickerDisabled')) {
|
||||
var val = parseInt(parentEl.next().text(), 10);
|
||||
tmp.addMonths(tblIndex - Math.floor(options.calendars/2));
|
||||
if (parentEl.next().hasClass('datepickerNotInMonth')) {
|
||||
tmp.addMonths(val > 15 ? -1 : 1);
|
||||
}
|
||||
tmp.setDate(val);
|
||||
options.date[0] = (tmp.setHours(0,0,0,0)).valueOf();
|
||||
tmp.setHours(23,59,59,0);
|
||||
tmp.addDays(6);
|
||||
options.date[1] = tmp.valueOf();
|
||||
fillIt = true;
|
||||
changed = true;
|
||||
options.lastSel = false;
|
||||
} else if (parentEl.hasClass('datepickerMonth')) {
|
||||
tmp.addMonths(tblIndex - Math.floor(options.calendars/2));
|
||||
switch (tblEl.get(0).className) {
|
||||
case 'datepickerViewDays':
|
||||
tblEl.get(0).className = 'datepickerViewMonths';
|
||||
el.find('span').text(tmp.getFullYear());
|
||||
break;
|
||||
case 'datepickerViewMonths':
|
||||
tblEl.get(0).className = 'datepickerViewYears';
|
||||
el.find('span').text((tmp.getFullYear()-6) + ' - ' + (tmp.getFullYear()+5));
|
||||
break;
|
||||
case 'datepickerViewYears':
|
||||
tblEl.get(0).className = 'datepickerViewDays';
|
||||
el.find('span').text(formatDate(tmp, 'B, Y'));
|
||||
break;
|
||||
}
|
||||
} else if (parentEl.parent().parent().is('thead')) {
|
||||
switch (tblEl.get(0).className) {
|
||||
case 'datepickerViewDays':
|
||||
options.current.addMonths(parentEl.hasClass('datepickerGoPrev') ? -1 : 1);
|
||||
break;
|
||||
case 'datepickerViewMonths':
|
||||
options.current.addYears(parentEl.hasClass('datepickerGoPrev') ? -1 : 1);
|
||||
break;
|
||||
case 'datepickerViewYears':
|
||||
options.current.addYears(parentEl.hasClass('datepickerGoPrev') ? -12 : 12);
|
||||
break;
|
||||
}
|
||||
fillIt = true;
|
||||
}
|
||||
} else if (parentEl.is('td') && !parentEl.hasClass('datepickerDisabled')) {
|
||||
switch (tblEl.get(0).className) {
|
||||
case 'datepickerViewMonths':
|
||||
options.current.setMonth(tblEl.find('tbody.datepickerMonths td').index(parentEl));
|
||||
options.current.setFullYear(parseInt(tblEl.find('thead th.datepickerMonth span').text(), 10));
|
||||
options.current.addMonths(Math.floor(options.calendars/2) - tblIndex);
|
||||
tblEl.get(0).className = 'datepickerViewDays';
|
||||
break;
|
||||
case 'datepickerViewYears':
|
||||
options.current.setFullYear(parseInt(el.text(), 10));
|
||||
tblEl.get(0).className = 'datepickerViewMonths';
|
||||
break;
|
||||
default:
|
||||
var val = parseInt(el.text(), 10);
|
||||
tmp.addMonths(tblIndex - Math.floor(options.calendars/2));
|
||||
if (parentEl.hasClass('datepickerNotInMonth')) {
|
||||
tmp.addMonths(val > 15 ? -1 : 1);
|
||||
}
|
||||
tmp.setDate(val);
|
||||
switch (options.mode) {
|
||||
case 'multiple':
|
||||
val = (tmp.setHours(0,0,0,0)).valueOf();
|
||||
if ($.inArray(val, options.date) > -1) {
|
||||
$.each(options.date, function(nr, dat){
|
||||
if (dat == val) {
|
||||
options.date.splice(nr,1);
|
||||
return false;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
options.date.push(val);
|
||||
}
|
||||
break;
|
||||
case 'range':
|
||||
if (!options.lastSel) {
|
||||
options.date[0] = (tmp.setHours(0,0,0,0)).valueOf();
|
||||
}
|
||||
val = (tmp.setHours(23,59,59,0)).valueOf();
|
||||
if (val < options.date[0]) {
|
||||
options.date[1] = options.date[0] + 86399000;
|
||||
options.date[0] = val - 86399000;
|
||||
} else {
|
||||
options.date[1] = val;
|
||||
}
|
||||
options.lastSel = !options.lastSel;
|
||||
break;
|
||||
default:
|
||||
options.date = tmp.valueOf();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
fillIt = true;
|
||||
changed = true;
|
||||
}
|
||||
if (fillIt) {
|
||||
fill(this);
|
||||
}
|
||||
if (changed) {
|
||||
options.onChange.apply(this, prepareDate(options));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
prepareDate = function (options) {
|
||||
var tmp;
|
||||
if (options.mode == 'single') {
|
||||
tmp = new Date(options.date);
|
||||
return [formatDate(tmp, options.format), tmp, options.el];
|
||||
} else {
|
||||
tmp = [[],[], options.el];
|
||||
$.each(options.date, function(nr, val){
|
||||
var date = new Date(val);
|
||||
tmp[0].push(formatDate(date, options.format));
|
||||
tmp[1].push(date);
|
||||
});
|
||||
return tmp;
|
||||
}
|
||||
},
|
||||
getViewport = function () {
|
||||
var m = document.compatMode == 'CSS1Compat';
|
||||
return {
|
||||
l : window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
|
||||
t : window.pageYOffset || (m ? document.documentElement.scrollTop : document.body.scrollTop),
|
||||
w : window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth),
|
||||
h : window.innerHeight || (m ? document.documentElement.clientHeight : document.body.clientHeight)
|
||||
};
|
||||
},
|
||||
isChildOf = function(parentEl, el, container) {
|
||||
if (parentEl == el) {
|
||||
return true;
|
||||
}
|
||||
if (parentEl.contains) {
|
||||
return parentEl.contains(el);
|
||||
}
|
||||
if ( parentEl.compareDocumentPosition ) {
|
||||
return !!(parentEl.compareDocumentPosition(el) & 16);
|
||||
}
|
||||
var prEl = el.parentNode;
|
||||
while(prEl && prEl != container) {
|
||||
if (prEl == parentEl)
|
||||
return true;
|
||||
prEl = prEl.parentNode;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
show = function (ev) {
|
||||
var cal = $('#' + $(this).data('datepickerId'));
|
||||
if (!cal.is(':visible')) {
|
||||
var calEl = cal.get(0);
|
||||
fill(calEl);
|
||||
var options = cal.data('datepicker');
|
||||
options.onBeforeShow.apply(this, [cal.get(0)]);
|
||||
var pos = $(this).offset();
|
||||
var viewPort = getViewport();
|
||||
var top = pos.top;
|
||||
var left = pos.left;
|
||||
var oldDisplay = $.curCSS(calEl, 'display');
|
||||
cal.css({
|
||||
visibility: 'hidden',
|
||||
display: 'block'
|
||||
});
|
||||
layout(calEl);
|
||||
switch (options.position){
|
||||
case 'top':
|
||||
top -= calEl.offsetHeight;
|
||||
break;
|
||||
case 'left':
|
||||
left -= calEl.offsetWidth;
|
||||
break;
|
||||
case 'right':
|
||||
left += this.offsetWidth;
|
||||
break;
|
||||
case 'bottom':
|
||||
top += this.offsetHeight;
|
||||
break;
|
||||
}
|
||||
if (top + calEl.offsetHeight > viewPort.t + viewPort.h) {
|
||||
top = pos.top - calEl.offsetHeight;
|
||||
}
|
||||
if (top < viewPort.t) {
|
||||
top = pos.top + this.offsetHeight + calEl.offsetHeight;
|
||||
}
|
||||
if (left + calEl.offsetWidth > viewPort.l + viewPort.w) {
|
||||
left = pos.left - calEl.offsetWidth;
|
||||
}
|
||||
if (left < viewPort.l) {
|
||||
left = pos.left + this.offsetWidth
|
||||
}
|
||||
cal.css({
|
||||
visibility: 'visible',
|
||||
display: 'block',
|
||||
top: top + 'px',
|
||||
left: left + 'px'
|
||||
});
|
||||
if (options.onShow.apply(this, [cal.get(0)]) != false) {
|
||||
cal.show();
|
||||
}
|
||||
$(document).bind('mousedown', {cal: cal, trigger: this}, hide);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
hide = function (ev) {
|
||||
if (ev.target != ev.data.trigger && !isChildOf(ev.data.cal.get(0), ev.target, ev.data.cal.get(0))) {
|
||||
if (ev.data.cal.data('datepicker').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
|
||||
ev.data.cal.hide();
|
||||
}
|
||||
$(document).unbind('mousedown', hide);
|
||||
}
|
||||
};
|
||||
return {
|
||||
init: function(options){
|
||||
options = $.extend({}, defaults, options||{});
|
||||
extendDate(options.locale);
|
||||
options.calendars = Math.max(1, parseInt(options.calendars,10)||1);
|
||||
options.mode = /single|multiple|range/.test(options.mode) ? options.mode : 'single';
|
||||
return this.each(function(){
|
||||
if (!$(this).data('datepicker')) {
|
||||
options.el = this;
|
||||
if (options.date.constructor == String) {
|
||||
options.date = parseDate(options.date, options.format);
|
||||
options.date.setHours(0,0,0,0);
|
||||
}
|
||||
if (options.mode != 'single') {
|
||||
if (options.date.constructor != Array) {
|
||||
options.date = [options.date.valueOf()];
|
||||
if (options.mode == 'range') {
|
||||
options.date.push(((new Date(options.date[0])).setHours(23,59,59,0)).valueOf());
|
||||
}
|
||||
} else {
|
||||
for (var i = 0; i < options.date.length; i++) {
|
||||
options.date[i] = (parseDate(options.date[i], options.format).setHours(0,0,0,0)).valueOf();
|
||||
}
|
||||
if (options.mode == 'range') {
|
||||
options.date[1] = ((new Date(options.date[1])).setHours(23,59,59,0)).valueOf();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
options.date = options.date.valueOf();
|
||||
}
|
||||
if (!options.current) {
|
||||
options.current = new Date();
|
||||
} else {
|
||||
options.current = parseDate(options.current, options.format);
|
||||
}
|
||||
options.current.setDate(1);
|
||||
options.current.setHours(0,0,0,0);
|
||||
var id = 'datepicker_' + parseInt(Math.random() * 1000), cnt;
|
||||
options.id = id;
|
||||
$(this).data('datepickerId', options.id);
|
||||
var cal = $(tpl.wrapper).attr('id', id).bind('click', click).data('datepicker', options);
|
||||
if (options.className) {
|
||||
cal.addClass(options.className);
|
||||
}
|
||||
var html = '';
|
||||
for (var i = 0; i < options.calendars; i++) {
|
||||
cnt = options.starts;
|
||||
if (i > 0) {
|
||||
html += tpl.space;
|
||||
}
|
||||
html += tmpl(tpl.head.join(''), {
|
||||
week: options.locale.weekMin,
|
||||
prev: options.prev,
|
||||
next: options.next,
|
||||
day1: options.locale.daysMin[(cnt++)%7],
|
||||
day2: options.locale.daysMin[(cnt++)%7],
|
||||
day3: options.locale.daysMin[(cnt++)%7],
|
||||
day4: options.locale.daysMin[(cnt++)%7],
|
||||
day5: options.locale.daysMin[(cnt++)%7],
|
||||
day6: options.locale.daysMin[(cnt++)%7],
|
||||
day7: options.locale.daysMin[(cnt++)%7]
|
||||
});
|
||||
}
|
||||
cal
|
||||
.find('tr:first').append(html)
|
||||
.find('table').addClass(views[options.view]);
|
||||
fill(cal.get(0));
|
||||
if (options.flat) {
|
||||
cal.appendTo(this).show().css('position', 'relative');
|
||||
layout(cal.get(0));
|
||||
} else {
|
||||
cal.appendTo(document.body);
|
||||
$(this).bind(options.eventName, show);
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
showPicker: function() {
|
||||
return this.each( function () {
|
||||
if ($(this).data('datepickerId')) {
|
||||
show.apply(this);
|
||||
}
|
||||
});
|
||||
},
|
||||
hidePicker: function() {
|
||||
return this.each( function () {
|
||||
if ($(this).data('datepickerId')) {
|
||||
$('#' + $(this).data('datepickerId')).hide();
|
||||
}
|
||||
});
|
||||
},
|
||||
setDate: function(date, shiftTo){
|
||||
return this.each(function(){
|
||||
if ($(this).data('datepickerId')) {
|
||||
var cal = $('#' + $(this).data('datepickerId'));
|
||||
var options = cal.data('datepicker');
|
||||
options.date = date;
|
||||
if (options.date.constructor == String) {
|
||||
options.date = parseDate(options.date, options.format);
|
||||
options.date.setHours(0,0,0,0);
|
||||
}
|
||||
if (options.mode != 'single') {
|
||||
if (options.date.constructor != Array) {
|
||||
options.date = [options.date.valueOf()];
|
||||
if (options.mode == 'range') {
|
||||
options.date.push(((new Date(options.date[0])).setHours(23,59,59,0)).valueOf());
|
||||
}
|
||||
} else {
|
||||
for (var i = 0; i < options.date.length; i++) {
|
||||
options.date[i] = (parseDate(options.date[i], options.format).setHours(0,0,0,0)).valueOf();
|
||||
}
|
||||
if (options.mode == 'range') {
|
||||
options.date[1] = ((new Date(options.date[1])).setHours(23,59,59,0)).valueOf();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
options.date = options.date.valueOf();
|
||||
}
|
||||
if (shiftTo) {
|
||||
options.current = new Date (options.mode != 'single' ? options.date[0] : options.date);
|
||||
}
|
||||
fill(cal.get(0));
|
||||
}
|
||||
});
|
||||
},
|
||||
getDate: function(formated) {
|
||||
if (this.size() > 0) {
|
||||
return prepareDate($('#' + $(this).data('datepickerId')).data('datepicker'))[formated ? 0 : 1];
|
||||
}
|
||||
},
|
||||
clear: function(){
|
||||
return this.each(function(){
|
||||
if ($(this).data('datepickerId')) {
|
||||
var cal = $('#' + $(this).data('datepickerId'));
|
||||
var options = cal.data('datepicker');
|
||||
if (options.mode != 'single') {
|
||||
options.date = [];
|
||||
fill(cal.get(0));
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
fixLayout: function(){
|
||||
return this.each(function(){
|
||||
if ($(this).data('datepickerId')) {
|
||||
var cal = $('#' + $(this).data('datepickerId'));
|
||||
var options = cal.data('datepicker');
|
||||
if (options.flat) {
|
||||
layout(cal.get(0));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
}();
|
||||
$.fn.extend({
|
||||
DatePicker: DatePicker.init,
|
||||
DatePickerHide: DatePicker.hidePicker,
|
||||
DatePickerShow: DatePicker.showPicker,
|
||||
DatePickerSetDate: DatePicker.setDate,
|
||||
DatePickerGetDate: DatePicker.getDate,
|
||||
DatePickerClear: DatePicker.clear,
|
||||
DatePickerLayout: DatePicker.fixLayout
|
||||
});
|
||||
})(jQuery);
|
||||
|
||||
(function(){
|
||||
var cache = {};
|
||||
|
||||
this.tmpl = function tmpl(str, data){
|
||||
// Figure out if we're getting a template, or if we need to
|
||||
// load the template - and be sure to cache the result.
|
||||
var fn = !/\W/.test(str) ?
|
||||
cache[str] = cache[str] ||
|
||||
tmpl(document.getElementById(str).innerHTML) :
|
||||
|
||||
// Generate a reusable function that will serve as a template
|
||||
// generator (and which will be cached).
|
||||
new Function("obj",
|
||||
"var p=[],print=function(){p.push.apply(p,arguments);};" +
|
||||
|
||||
// Introduce the data as local variables using with(){}
|
||||
"with(obj){p.push('" +
|
||||
|
||||
// Convert the template into pure JavaScript
|
||||
str
|
||||
.replace(/[\r\t\n]/g, " ")
|
||||
.split("<%").join("\t")
|
||||
.replace(/((^|%>)[^\t]*)'/g, "$1\r")
|
||||
.replace(/\t=(.*?)%>/g, "',$1,'")
|
||||
.split("\t").join("');")
|
||||
.split("%>").join("p.push('")
|
||||
.split("\r").join("\\'")
|
||||
+ "');}return p.join('');");
|
||||
|
||||
// Provide some basic currying to the user
|
||||
return data ? fn( data ) : fn;
|
||||
};
|
||||
})();
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* jQuery Masonry v2.1.05
|
||||
* A dynamic layout plugin for jQuery
|
||||
* The flip-side of CSS Floats
|
||||
* http://masonry.desandro.com
|
||||
*
|
||||
* Licensed under the MIT license.
|
||||
* Copyright 2012 David DeSandro
|
||||
*/
|
||||
(function(a,b,c){"use strict";var d=b.event,e;d.special.smartresize={setup:function(){b(this).bind("resize",d.special.smartresize.handler)},teardown:function(){b(this).unbind("resize",d.special.smartresize.handler)},handler:function(a,c){var d=this,f=arguments;a.type="smartresize",e&&clearTimeout(e),e=setTimeout(function(){b.event.handle.apply(d,f)},c==="execAsap"?0:100)}},b.fn.smartresize=function(a){return a?this.bind("smartresize",a):this.trigger("smartresize",["execAsap"])},b.Mason=function(a,c){this.element=b(c),this._create(a),this._init()},b.Mason.settings={isResizable:!0,isAnimated:!1,animationOptions:{queue:!1,duration:500},gutterWidth:0,isRTL:!1,isFitWidth:!1,containerStyle:{position:"relative"}},b.Mason.prototype={_filterFindBricks:function(a){var b=this.options.itemSelector;return b?a.filter(b).add(a.find(b)):a},_getBricks:function(a){var b=this._filterFindBricks(a).css({position:"absolute"}).addClass("masonry-brick");return b},_create:function(c){this.options=b.extend(!0,{},b.Mason.settings,c),this.styleQueue=[];var d=this.element[0].style;this.originalStyle={height:d.height||""};var e=this.options.containerStyle;for(var f in e)this.originalStyle[f]=d[f]||"";this.element.css(e),this.horizontalDirection=this.options.isRTL?"right":"left",this.offset={x:parseInt(this.element.css("padding-"+this.horizontalDirection),10),y:parseInt(this.element.css("padding-top"),10)},this.isFluid=this.options.columnWidth&&typeof this.options.columnWidth=="function";var g=this;setTimeout(function(){g.element.addClass("masonry")},0),this.options.isResizable&&b(a).bind("smartresize.masonry",function(){g.resize()}),this.reloadItems()},_init:function(a){this._getColumns(),this._reLayout(a)},option:function(a,c){b.isPlainObject(a)&&(this.options=b.extend(!0,this.options,a))},layout:function(a,b){for(var c=0,d=a.length;c<d;c++)this._placeBrick(a[c]);var e={};e.height=Math.max.apply(Math,this.colYs);if(this.options.isFitWidth){var f=0;c=this.cols;while(--c){if(this.colYs[c]!==0)break;f++}e.width=(this.cols-f)*this.columnWidth-this.options.gutterWidth}this.styleQueue.push({$el:this.element,style:e});var g=this.isLaidOut?this.options.isAnimated?"animate":"css":"css",h=this.options.animationOptions,i;for(c=0,d=this.styleQueue.length;c<d;c++)i=this.styleQueue[c],i.$el[g](i.style,h);this.styleQueue=[],b&&b.call(a),this.isLaidOut=!0},_getColumns:function(){var a=this.options.isFitWidth?this.element.parent():this.element,b=a.width();this.columnWidth=this.isFluid?this.options.columnWidth(b):this.options.columnWidth||this.$bricks.outerWidth(!0)||b,this.columnWidth+=this.options.gutterWidth,this.cols=Math.floor((b+this.options.gutterWidth)/this.columnWidth),this.cols=Math.max(this.cols,1)},_placeBrick:function(a){var c=b(a),d,e,f,g,h;d=Math.ceil(c.outerWidth(!0)/this.columnWidth),d=Math.min(d,this.cols);if(d===1)f=this.colYs;else{e=this.cols+1-d,f=[];for(h=0;h<e;h++)g=this.colYs.slice(h,h+d),f[h]=Math.max.apply(Math,g)}var i=Math.min.apply(Math,f),j=0;for(var k=0,l=f.length;k<l;k++)if(f[k]===i){j=k;break}var m={top:i+this.offset.y};m[this.horizontalDirection]=this.columnWidth*j+this.offset.x,this.styleQueue.push({$el:c,style:m});var n=i+c.outerHeight(!0),o=this.cols+1-l;for(k=0;k<o;k++)this.colYs[j+k]=n},resize:function(){var a=this.cols;this._getColumns(),(this.isFluid||this.cols!==a)&&this._reLayout()},_reLayout:function(a){var b=this.cols;this.colYs=[];while(b--)this.colYs.push(0);this.layout(this.$bricks,a)},reloadItems:function(){this.$bricks=this._getBricks(this.element.children())},reload:function(a){this.reloadItems(),this._init(a)},appended:function(a,b,c){if(b){this._filterFindBricks(a).css({top:this.element.height()});var d=this;setTimeout(function(){d._appended(a,c)},1)}else this._appended(a,c)},_appended:function(a,b){var c=this._getBricks(a);this.$bricks=this.$bricks.add(c),this.layout(c,b)},remove:function(a){this.$bricks=this.$bricks.not(a),a.remove()},destroy:function(){this.$bricks.removeClass("masonry-brick").each(function(){this.style.position="",this.style.top="",this.style.left=""});var c=this.element[0].style;for(var d in this.originalStyle)c[d]=this.originalStyle[d];this.element.unbind(".masonry").removeClass("masonry").removeData("masonry"),b(a).unbind(".masonry")}},b.fn.imagesLoaded=function(a){function h(){a.call(c,d)}function i(a){var c=a.target;c.src!==f&&b.inArray(c,g)===-1&&(g.push(c),--e<=0&&(setTimeout(h),d.unbind(".imagesLoaded",i)))}var c=this,d=c.find("img").add(c.filter("img")),e=d.length,f="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==",g=[];return e||h(),d.bind("load.imagesLoaded error.imagesLoaded",i).each(function(){var a=this.src;this.src=f,this.src=a}),c};var f=function(b){a.console&&a.console.error(b)};b.fn.masonry=function(a){if(typeof a=="string"){var c=Array.prototype.slice.call(arguments,1);this.each(function(){var d=b.data(this,"masonry");if(!d){f("cannot call methods on masonry prior to initialization; attempted to call method '"+a+"'");return}if(!b.isFunctiLine truncated
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* jQuery.Preload - Multifunctional preloader
|
||||
* Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com
|
||||
* Dual licensed under MIT and GPL.
|
||||
* Date: 3/25/2009
|
||||
* @author Ariel Flesler
|
||||
* @version 1.0.8
|
||||
*/
|
||||
;(function($){var h=$.preload=function(c,d){if(c.split)c=$(c);d=$.extend({},h.defaults,d);var f=$.map(c,function(a){if(!a)return;if(a.split)return d.base+a+d.ext;var b=a.src||a.href;if(typeof d.placeholder=='string'&&a.src)a.src=d.placeholder;if(b&&d.find)b=b.replace(d.find,d.replace);return b||null}),data={loaded:0,failed:0,next:0,done:0,total:f.length};if(!data.total)return finish();var g=$(Array(d.threshold+1).join('<img/>')).load(handler).error(handler).bind('abort',handler).each(fetch);function handler(e){data.element=this;data.found=e.type=='load';data.image=this.src;data.index=this.index;var a=data.original=c[this.index];data[data.found?'loaded':'failed']++;data.done++;if(d.enforceCache)h.cache.push($('<img/>').attr('src',data.image)[0]);if(d.placeholder&&a.src)a.src=data.found?data.image:d.notFound||a.src;if(d.onComplete)d.onComplete(data);if(data.done<data.total)fetch(0,this);else{if(g&&g.unbind)g.unbind('load').unbind('error').unbind('abort');g=null;finish()}};function fetch(i,a,b){if(a.attachEvent&&data.next&&data.next%h.gap==0&&!b){setTimeout(function(){fetch(i,a,1)},0);return!1}if(data.next==data.total)return!1;a.index=data.next;a.src=f[data.next++];if(d.onRequest){data.index=a.index;data.element=a;data.image=a.src;data.original=c[data.next-1];d.onRequest(data)}};function finish(){if(d.onFinish)d.onFinish(data)}};h.gap=14;h.cache=[];h.defaults={threshold:2,base:'',ext:'',replace:''};$.fn.preload=function(a){h(this,a);return this}})(jQuery);
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
// (function($) {
|
||||
// var cache = [];
|
||||
// // Arguments are image paths relative to the current page.
|
||||
// $.preLoadImages = function() {
|
||||
// var args_len = arguments.length;
|
||||
// for (var i = args_len; i--;) {
|
||||
// var cacheImage = document.createElement('img');
|
||||
// cacheImage.src = arguments[i];
|
||||
// cache.push(cacheImage);
|
||||
// }
|
||||
// }
|
||||
// })(jQuery)
|
||||
|
||||
|
||||
(function($) {
|
||||
$.preloadimages = function (arr){
|
||||
var newimages=[], loadedimages=0
|
||||
var postaction=function(){}
|
||||
var arr=(typeof arr!="object")? [arr] : arr
|
||||
function imageloadpost(){
|
||||
loadedimages++
|
||||
if (loadedimages==arr.length){
|
||||
postaction(newimages) //call postaction and pass in newimages array as parameter
|
||||
}
|
||||
}
|
||||
for (var i=0; i<arr.length; i++){
|
||||
newimages[i]=new Image()
|
||||
newimages[i].src=arr[i]
|
||||
newimages[i].onload=function(){
|
||||
imageloadpost()
|
||||
}
|
||||
newimages[i].onerror=function(){
|
||||
imageloadpost()
|
||||
}
|
||||
}
|
||||
return { //return blank object with done() method
|
||||
done:function(f){
|
||||
postaction=f || postaction //remember user defined callback functions to be called when images load
|
||||
}
|
||||
}
|
||||
}
|
||||
})(jQuery)
|
||||
+391
@@ -0,0 +1,391 @@
|
||||
/*
|
||||
* jQuery UI Nested Sortable
|
||||
* v 1.3.4 / 28 apr 2011
|
||||
* http://mjsarfatti.com/sandbox/nestedSortable
|
||||
*
|
||||
* Depends:
|
||||
* jquery.ui.sortable.js 1.8+
|
||||
*
|
||||
* License CC BY-SA 3.0
|
||||
* Copyright 2010-2011, Manuele J Sarfatti
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
|
||||
$.widget("ui.nestedSortable", $.extend({}, $.ui.sortable.prototype, {
|
||||
|
||||
options: {
|
||||
tabSize: 20,
|
||||
disableNesting: 'ui-nestedSortable-no-nesting',
|
||||
errorClass: 'ui-nestedSortable-error',
|
||||
listType: 'ol',
|
||||
maxLevels: 0,
|
||||
revertOnError: 1
|
||||
},
|
||||
|
||||
_create: function() {
|
||||
this.element.data('sortable', this.element.data('nestedSortable'));
|
||||
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;
|
||||
}
|
||||
|
||||
//Do scrolling
|
||||
if(this.options.scroll) {
|
||||
var o = this.options, 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");
|
||||
|
||||
//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),
|
||||
previousItem = this.placeholder[0].previousSibling ? $(this.placeholder[0].previousSibling) : null;
|
||||
|
||||
if (previousItem != null) {
|
||||
while (previousItem[0].nodeName.toLowerCase() != 'li' || previousItem[0] == this.currentItem[0]) {
|
||||
if (previousItem[0].previousSibling) {
|
||||
previousItem = $(previousItem[0].previousSibling);
|
||||
} else {
|
||||
previousItem = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newList = document.createElement(o.listType);
|
||||
|
||||
this.beyondMaxLevels = 0;
|
||||
|
||||
// If the item is moved to the left, send it to its parent level
|
||||
if (parentItem != null && 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 another one and is moved to the right, make it a children of it
|
||||
else if (previousItem != null && this.positionAbs.left > previousItem.offset().left + o.tabSize) {
|
||||
this._isAllowed(previousItem, level+childLevels+1);
|
||||
if (!previousItem.children(o.listType).length) {
|
||||
previousItem[0].appendChild(newList);
|
||||
}
|
||||
previousItem.children(o.listType)[0].appendChild(this.placeholder[0]);
|
||||
this._trigger("change", event, this._uiHash());
|
||||
}
|
||||
else {
|
||||
this._isAllowed(parentItem, 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.options.revertOnError) {
|
||||
if (this.domPosition.prev) {
|
||||
$(this.domPosition.prev).after(this.placeholder);
|
||||
} else {
|
||||
$(this.domPosition.parent).prepend(this.placeholder);
|
||||
}
|
||||
this._trigger("revert", event, this._uiHash());
|
||||
} else {
|
||||
var parent = this.placeholder.parent().closest(this.options.items);
|
||||
|
||||
for (var i = this.beyondMaxLevels - 1; i > 0; i--) {
|
||||
parent = parent.parent().closest(this.options.items);
|
||||
}
|
||||
|
||||
parent.after(this.placeholder);
|
||||
this._trigger("change", 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);
|
||||
|
||||
},
|
||||
|
||||
serialize: function(o) {
|
||||
|
||||
var items = this._getItemsAsjQuery(o && o.connected),
|
||||
str = []; o = o || {};
|
||||
|
||||
$(items).each(function() {
|
||||
var res = ($(o.item || this).attr(o.attribute || 'id') || '')
|
||||
.match(o.expression || (/(.+)[-=_](.+)/)),
|
||||
pid = ($(o.item || this).parent(o.listType)
|
||||
.parent('li')
|
||||
.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]) : 'root'));
|
||||
}
|
||||
});
|
||||
|
||||
if(!str.length && o.key) {
|
||||
str.push(o.key + '=');
|
||||
}
|
||||
|
||||
return str.join('&');
|
||||
|
||||
},
|
||||
|
||||
toHierarchy: function(o) {
|
||||
|
||||
o = o || {};
|
||||
var sDepth = o.startDepthCount || 0,
|
||||
ret = [];
|
||||
|
||||
$(this.element).children('li').each(function () {
|
||||
var level = _recursiveItems($(this));
|
||||
ret.push(level);
|
||||
});
|
||||
|
||||
return ret;
|
||||
|
||||
function _recursiveItems(li) {
|
||||
var id = ($(li).attr(o.attribute || 'id') || '').match(o.expression || (/(.+)[-=_](.+)/));
|
||||
if (id) {
|
||||
var item = {"id" : id[2]};
|
||||
if ($(li).children(o.listType).children('li').length > 0) {
|
||||
item.children = [];
|
||||
$(li).children(o.listType).children('li').each(function() {
|
||||
var level = _recursiveItems($(this));
|
||||
item.children.push(level);
|
||||
});
|
||||
}
|
||||
return item;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
toArray: function(o) {
|
||||
|
||||
o = o || {};
|
||||
var sDepth = o.startDepthCount || 0,
|
||||
ret = [],
|
||||
left = 2;
|
||||
|
||||
ret.push({
|
||||
"item_id": 'root',
|
||||
"parent_id": 'none',
|
||||
"depth": sDepth,
|
||||
"left": '1',
|
||||
"right": ($('li', this.element).length + 1) * 2
|
||||
});
|
||||
|
||||
$(this.element).children('li').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('li').length > 0) {
|
||||
depth ++;
|
||||
$(item).children(o.listType).children('li').each(function () {
|
||||
right = _recursiveArray($(this), depth, right);
|
||||
});
|
||||
depth --;
|
||||
}
|
||||
|
||||
id = ($(item).attr(o.attribute || 'id')).match(o.expression || (/(.+)[-=_](.+)/));
|
||||
|
||||
if (depth === sDepth + 1) {
|
||||
pid = 'root';
|
||||
} else {
|
||||
var parentItem = ($(item).parent(o.listType)
|
||||
.parent('li')
|
||||
.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) {
|
||||
emptyList.remove();
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
_getLevel: function(item) {
|
||||
|
||||
var level = 1;
|
||||
|
||||
if (this.options.listType) {
|
||||
var list = item.closest(this.options.listType);
|
||||
while (!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, levels) {
|
||||
var o = this.options;
|
||||
// Are we trying to nest under a no-nest or are we nesting too deep?
|
||||
if (parentItem == null || !(parentItem.hasClass(o.disableNesting))) {
|
||||
if (o.maxLevels < levels && o.maxLevels != 0) {
|
||||
this.placeholder.addClass(o.errorClass);
|
||||
this.beyondMaxLevels = levels - o.maxLevels;
|
||||
} else {
|
||||
this.placeholder.removeClass(o.errorClass);
|
||||
this.beyondMaxLevels = 0;
|
||||
}
|
||||
} else {
|
||||
this.placeholder.addClass(o.errorClass);
|
||||
if (o.maxLevels < levels && o.maxLevels != 0) {
|
||||
this.beyondMaxLevels = levels - o.maxLevels;
|
||||
} else {
|
||||
this.beyondMaxLevels = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
$.ui.nestedSortable.prototype.options = $.extend({}, $.ui.sortable.prototype.options, $.ui.nestedSortable.prototype.options);
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,33 @@
|
||||
window.SocialShareButton =
|
||||
openUrl : (url) ->
|
||||
window.open(url)
|
||||
false
|
||||
|
||||
share : (el) ->
|
||||
site = $(el).data('site')
|
||||
title = encodeURIComponent($(el).parent().data('title'))
|
||||
img = encodeURIComponent($(el).parent().data("img"))
|
||||
fb_url = encodeURIComponent($(el).parent().data("fb_url"))
|
||||
url = encodeURIComponent(location.href)
|
||||
switch site
|
||||
when "weibo"
|
||||
SocialShareButton.openUrl("http://v.t.sina.com.cn/share/share.php?url=#{url}&pic=#{img}&title=#{title}&content=utf-8")
|
||||
when "twitter"
|
||||
SocialShareButton.openUrl("https://twitter.com/home?status=#{title}: #{url}")
|
||||
when "douban"
|
||||
SocialShareButton.openUrl("http://www.douban.com/recommend/?url=#{url}&title=#{title}&image=#{img}")
|
||||
when "facebook"
|
||||
SocialShareButton.openUrl("http://www.facebook.com/sharer.php?t=#{title}&u=#{fb_url}")
|
||||
when "qq"
|
||||
SocialShareButton.openUrl("http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=#{url}&title=#{title}&pics=#{img}")
|
||||
when "tqq"
|
||||
SocialShareButton.openUrl("http://share.v.t.qq.com/index.php?c=share&a=index&url=#{url}&title=#{title}&pic=#{img}")
|
||||
when "baidu"
|
||||
SocialShareButton.openUrl("http://apps.hi.baidu.com/share/?url=#{url}&title=#{title}&content=")
|
||||
when "kaixin001"
|
||||
SocialShareButton.openUrl("http://www.kaixin001.com/rest/records.php?url=#{url}&content=#{title}&style=11&pic=#{img}")
|
||||
when "renren"
|
||||
SocialShareButton.openUrl("http://widget.renren.com/dialog/share?resourceUrl=#{url}&title=#{title}&description=")
|
||||
when "google_plus"
|
||||
SocialShareButton.openUrl("https://plus.google.com/share?url=#{url}&t=#{title}")
|
||||
false
|
||||
@@ -0,0 +1,15 @@
|
||||
// This is a manifest file that'll be compiled into including all the files listed below.
|
||||
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
||||
// be included in the compiled file accessible from http://example.com/assets/application.js
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// the compiled file.
|
||||
//
|
||||
//= require jquery
|
||||
//= require mobile/jquery.cycle.all
|
||||
//= require mobile/jquery.mu.image.resize
|
||||
//= require mobile/orbit.mobile
|
||||
//= require mobile/jquery.mobile-1.2.0.min
|
||||
//= require mobile/jquery.swipeplanes-1.2.min
|
||||
//= require mobile/add2home
|
||||
//= require mobile/gmAPI
|
||||
//= require mobile/jquery.ui.map
|
||||
@@ -0,0 +1,350 @@
|
||||
/*!
|
||||
* Add to Homescreen v2.0.4 ~ Copyright (c) 2012 Matteo Spinelli, http://cubiq.org
|
||||
* Released under MIT license, http://cubiq.org/license
|
||||
*/
|
||||
var addToHome = (function (w) {
|
||||
var nav = w.navigator,
|
||||
isIDevice = 'platform' in nav && (/iphone|ipod|ipad/gi).test(nav.platform),
|
||||
isIPad,
|
||||
isRetina,
|
||||
isSafari,
|
||||
isStandalone,
|
||||
OSVersion,
|
||||
startX = 0,
|
||||
startY = 0,
|
||||
lastVisit = 0,
|
||||
isExpired,
|
||||
isSessionActive,
|
||||
isReturningVisitor,
|
||||
balloon,
|
||||
overrideChecks,
|
||||
|
||||
positionInterval,
|
||||
closeTimeout,
|
||||
|
||||
options = {
|
||||
autostart: true, // Automatically open the balloon
|
||||
returningVisitor: false, // Show the balloon to returning visitors only (setting this to true is HIGHLY RECCOMENDED)
|
||||
animationIn: 'bubble', // drop || bubble || fade
|
||||
animationOut: 'drop', // drop || bubble || fade
|
||||
startDelay: 2000, // 2 seconds from page load before the balloon appears
|
||||
lifespan: 10000, // 15 seconds before it is automatically destroyed
|
||||
bottomOffset: 14, // Distance of the balloon from bottom
|
||||
expire: 0, // Minutes to wait before showing the popup again (0 = always displayed)
|
||||
message: '', // Customize your message or force a language ('' = automatic)
|
||||
touchIcon: true, // Display the touch icon
|
||||
arrow: true, // Display the balloon arrow
|
||||
hookOnLoad: true, // Should we hook to onload event? (really advanced usage)
|
||||
iterations: 100 // Internal/debug use
|
||||
},
|
||||
|
||||
intl = {
|
||||
ca_es: 'Per instal·lar aquesta aplicació al vostre %device premeu %icon i llavors <strong>Afegir a pantalla d\'inici</strong>.',
|
||||
cs_cz: 'Pro instalaci aplikace na Váš %device, stiskněte %icon a v nabídce <strong>Přidat na plochu</strong>.',
|
||||
da_dk: 'Tilføj denne side til din %device: tryk på %icon og derefter <strong>Føj til hjemmeskærm</strong>.',
|
||||
de_de: 'Installieren Sie diese App auf Ihrem %device: %icon antippen und dann <strong>Zum Home-Bildschirm</strong>.',
|
||||
el_gr: 'Εγκαταστήσετε αυτήν την Εφαρμογή στήν συσκευή σας %device: %icon μετά πατάτε <strong>Προσθήκη σε Αφετηρία</strong>.',
|
||||
en_us: 'Install this web app on your %device: tap %icon and then <strong>Add to Home Screen</strong>.',
|
||||
es_es: 'Para instalar esta app en su %device, pulse %icon y seleccione <strong>Añadir a pantalla de inicio</strong>.',
|
||||
fi_fi: 'Asenna tämä web-sovellus laitteeseesi %device: paina %icon ja sen jälkeen valitse <strong>Lisää Koti-valikkoon</strong>.',
|
||||
fr_fr: 'Ajoutez cette application sur votre %device en cliquant sur %icon, puis <strong>Ajouter à l\'écran d\'accueil</strong>.',
|
||||
he_il: '<span dir="rtl">התקן אפליקציה זו על ה-%device שלך: הקש %icon ואז <strong>הוסף למסך הבית</strong>.</span>',
|
||||
hr_hr: 'Instaliraj ovu aplikaciju na svoj %device: klikni na %icon i odaberi <strong>Dodaj u početni zaslon</strong>.',
|
||||
hu_hu: 'Telepítse ezt a web-alkalmazást az Ön %device-jára: nyomjon a %icon-ra majd a <strong>Főképernyőhöz adás</strong> gombra.',
|
||||
it_it: 'Installa questa applicazione sul tuo %device: premi su %icon e poi <strong>Aggiungi a Home</strong>.',
|
||||
ja_jp: 'このウェブアプリをあなたの%deviceにインストールするには%iconをタップして<strong>ホーム画面に追加</strong>を選んでください。',
|
||||
ko_kr: '%device에 웹앱을 설치하려면 %icon을 터치 후 "홈화면에 추가"를 선택하세요',
|
||||
nb_no: 'Installer denne appen på din %device: trykk på %icon og deretter <strong>Legg til på Hjem-skjerm</strong>',
|
||||
nl_nl: 'Installeer deze webapp op uw %device: tik %icon en dan <strong>Zet in beginscherm</strong>.',
|
||||
pl_pl: 'Aby zainstalować tę aplikacje na %device: naciśnij %icon a następnie <strong>Dodaj jako ikonę</strong>.',
|
||||
pt_br: 'Instale este web app em seu %device: aperte %icon e selecione <strong>Adicionar à Tela Inicio</strong>.',
|
||||
pt_pt: 'Para instalar esta aplicação no seu %device, prima o %icon e depois o <strong>Adicionar ao ecrã principal</strong>.',
|
||||
ru_ru: 'Установите это веб-приложение на ваш %device: нажмите %icon, затем <strong>Добавить в «Домой»</strong>.',
|
||||
sv_se: 'Lägg till denna webbapplikation på din %device: tryck på %icon och därefter <strong>Lägg till på hemskärmen</strong>.',
|
||||
th_th: 'ติดตั้งเว็บแอพฯ นี้บน %device ของคุณ: แตะ %icon และ <strong>เพิ่มที่หน้าจอโฮม</strong>',
|
||||
tr_tr: '%device için bu uygulamayı kurduktan sonra %icon simgesine dokunarak <strong>Ana Ekrana Ekle</strong>yin.',
|
||||
zh_cn: '您可以将此应用程式安装到您的 %device 上。请按 %icon 然后点选<strong>添加至主屏幕</strong>。',
|
||||
zh_tw: '您可以將此應用程式安裝到您的 %device 上。請按 %icon 然後點選<strong>加入主畫面螢幕</strong>。'
|
||||
};
|
||||
|
||||
function init () {
|
||||
// Preliminary check, all further checks are performed on iDevices only
|
||||
if ( !isIDevice ) return;
|
||||
|
||||
var now = Date.now(),
|
||||
i;
|
||||
|
||||
// Merge local with global options
|
||||
if ( w.addToHomeConfig ) {
|
||||
for ( i in w.addToHomeConfig ) {
|
||||
options[i] = w.addToHomeConfig[i];
|
||||
}
|
||||
}
|
||||
if ( !options.autostart ) options.hookOnLoad = false;
|
||||
|
||||
isIPad = (/ipad/gi).test(nav.platform);
|
||||
isRetina = w.devicePixelRatio && w.devicePixelRatio > 1;
|
||||
isSafari = (/Safari/i).test(nav.appVersion) && !(/CriOS/i).test(nav.appVersion);
|
||||
isStandalone = nav.standalone;
|
||||
OSVersion = nav.appVersion.match(/OS (\d+_\d+)/i);
|
||||
OSVersion = OSVersion[1] ? +OSVersion[1].replace('_', '.') : 0;
|
||||
|
||||
lastVisit = +w.localStorage.getItem('addToHome');
|
||||
|
||||
isSessionActive = w.sessionStorage.getItem('addToHomeSession');
|
||||
isReturningVisitor = options.returningVisitor ? lastVisit && lastVisit + 28*24*60*60*1000 > now : true;
|
||||
|
||||
if ( !lastVisit ) lastVisit = now;
|
||||
|
||||
// If it is expired we need to reissue a new balloon
|
||||
isExpired = isReturningVisitor && lastVisit <= now;
|
||||
|
||||
if ( options.hookOnLoad ) w.addEventListener('load', loaded, false);
|
||||
else if ( !options.hookOnLoad && options.autostart ) loaded();
|
||||
}
|
||||
|
||||
function loaded () {
|
||||
w.removeEventListener('load', loaded, false);
|
||||
|
||||
if ( !isReturningVisitor ) w.localStorage.setItem('addToHome', Date.now());
|
||||
else if ( options.expire && isExpired ) w.localStorage.setItem('addToHome', Date.now() + options.expire * 60000);
|
||||
|
||||
if ( !overrideChecks && ( !isSafari || !isExpired || isSessionActive || isStandalone || !isReturningVisitor ) ) return;
|
||||
|
||||
var icons = options.touchIcon ? document.querySelectorAll('head link[rel=apple-touch-icon],head link[rel=apple-touch-icon-precomposed]') : [],
|
||||
sizes,
|
||||
touchIcon = '',
|
||||
closeButton,
|
||||
platform = nav.platform.split(' ')[0],
|
||||
language = nav.language.replace('-', '_'),
|
||||
i, l;
|
||||
|
||||
balloon = document.createElement('div');
|
||||
balloon.id = 'addToHomeScreen';
|
||||
balloon.style.cssText += 'left:-9999px;-webkit-transition-property:-webkit-transform,opacity;-webkit-transition-duration:0;-webkit-transform:translate3d(0,0,0);position:' + (OSVersion < 5 ? 'absolute' : 'fixed');
|
||||
|
||||
// Localize message
|
||||
if ( options.message in intl ) { // You may force a language despite the user's locale
|
||||
language = options.message;
|
||||
options.message = '';
|
||||
}
|
||||
if ( options.message === '' ) { // We look for a suitable language (defaulted to en_us)
|
||||
options.message = language in intl ? intl[language] : intl['en_us'];
|
||||
}
|
||||
|
||||
// Search for the apple-touch-icon
|
||||
if ( icons.length ) {
|
||||
for ( i = 0, l = icons.length; i < l; i++ ) {
|
||||
sizes = icons[i].getAttribute('sizes');
|
||||
|
||||
if ( sizes ) {
|
||||
if ( isRetina && sizes == '114x114' ) {
|
||||
touchIcon = icons[i].href;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
touchIcon = icons[i].href;
|
||||
}
|
||||
}
|
||||
|
||||
touchIcon = '<span style="background-image:url(' + touchIcon + ')" class="addToHomeTouchIcon"></span>';
|
||||
}
|
||||
|
||||
balloon.className = (isIPad ? 'addToHomeIpad' : 'addToHomeIphone') + (touchIcon ? ' addToHomeWide' : '');
|
||||
balloon.innerHTML = touchIcon +
|
||||
options.message.replace('%device', platform).replace('%icon', OSVersion >= 4.2 ? '<span class="addToHomeShare"></span>' : '<span class="addToHomePlus">+</span>') +
|
||||
(options.arrow ? '<span class="addToHomeArrow"></span>' : '') +
|
||||
'<span class="addToHomeClose">\u00D7</span>';
|
||||
|
||||
document.body.appendChild(balloon);
|
||||
|
||||
// Add the close action
|
||||
closeButton = balloon.querySelector('.addToHomeClose');
|
||||
if ( closeButton ) closeButton.addEventListener('click', clicked, false);
|
||||
|
||||
if ( !isIPad && OSVersion >= 6 ) window.addEventListener('orientationchange', orientationCheck, false);
|
||||
|
||||
setTimeout(show, options.startDelay);
|
||||
}
|
||||
|
||||
function show () {
|
||||
var duration,
|
||||
iPadXShift = 208;
|
||||
|
||||
// Set the initial position
|
||||
if ( isIPad ) {
|
||||
if ( OSVersion < 5 ) {
|
||||
startY = w.scrollY;
|
||||
startX = w.scrollX;
|
||||
} else if ( OSVersion < 6 ) {
|
||||
iPadXShift = 160;
|
||||
}
|
||||
|
||||
balloon.style.top = startY + options.bottomOffset + 'px';
|
||||
balloon.style.left = startX + iPadXShift - Math.round(balloon.offsetWidth / 2) + 'px';
|
||||
|
||||
switch ( options.animationIn ) {
|
||||
case 'drop':
|
||||
duration = '0.6s';
|
||||
balloon.style.webkitTransform = 'translate3d(0,' + -(w.scrollY + options.bottomOffset + balloon.offsetHeight) + 'px,0)';
|
||||
break;
|
||||
case 'bubble':
|
||||
duration = '0.6s';
|
||||
balloon.style.opacity = '0';
|
||||
balloon.style.webkitTransform = 'translate3d(0,' + (startY + 50) + 'px,0)';
|
||||
break;
|
||||
default:
|
||||
duration = '1s';
|
||||
balloon.style.opacity = '0';
|
||||
}
|
||||
} else {
|
||||
startY = w.innerHeight + w.scrollY;
|
||||
|
||||
if ( OSVersion < 5 ) {
|
||||
startX = Math.round((w.innerWidth - balloon.offsetWidth) / 2) + w.scrollX;
|
||||
balloon.style.left = startX + 'px';
|
||||
balloon.style.top = startY - balloon.offsetHeight - options.bottomOffset + 'px';
|
||||
} else {
|
||||
balloon.style.left = '50%';
|
||||
balloon.style.marginLeft = -Math.round(balloon.offsetWidth / 2) - ( w.orientation%180 && OSVersion >= 6 ? 40 : 0 ) + 'px';
|
||||
balloon.style.bottom = options.bottomOffset + 'px';
|
||||
}
|
||||
|
||||
switch (options.animationIn) {
|
||||
case 'drop':
|
||||
duration = '1s';
|
||||
balloon.style.webkitTransform = 'translate3d(0,' + -(startY + options.bottomOffset) + 'px,0)';
|
||||
break;
|
||||
case 'bubble':
|
||||
duration = '0.6s';
|
||||
balloon.style.webkitTransform = 'translate3d(0,' + (balloon.offsetHeight + options.bottomOffset + 50) + 'px,0)';
|
||||
break;
|
||||
default:
|
||||
duration = '1s';
|
||||
balloon.style.opacity = '0';
|
||||
}
|
||||
}
|
||||
|
||||
balloon.offsetHeight; // repaint trick
|
||||
balloon.style.webkitTransitionDuration = duration;
|
||||
balloon.style.opacity = '1';
|
||||
balloon.style.webkitTransform = 'translate3d(0,0,0)';
|
||||
balloon.addEventListener('webkitTransitionEnd', transitionEnd, false);
|
||||
|
||||
closeTimeout = setTimeout(close, options.lifespan);
|
||||
}
|
||||
|
||||
function manualShow (override) {
|
||||
if ( !isIDevice || balloon ) return;
|
||||
|
||||
overrideChecks = override;
|
||||
loaded();
|
||||
}
|
||||
|
||||
function close () {
|
||||
clearInterval( positionInterval );
|
||||
clearTimeout( closeTimeout );
|
||||
closeTimeout = null;
|
||||
|
||||
var posY = 0,
|
||||
posX = 0,
|
||||
opacity = '1',
|
||||
duration = '0',
|
||||
closeButton = balloon.querySelector('.addToHomeClose');
|
||||
|
||||
if ( closeButton ) closeButton.removeEventListener('click', close, false);
|
||||
if ( !isIPad && OSVersion >= 6 ) window.removeEventListener('orientationchange', orientationCheck, false);
|
||||
|
||||
if ( OSVersion < 5 ) {
|
||||
posY = isIPad ? w.scrollY - startY : w.scrollY + w.innerHeight - startY;
|
||||
posX = isIPad ? w.scrollX - startX : w.scrollX + Math.round((w.innerWidth - balloon.offsetWidth)/2) - startX;
|
||||
}
|
||||
|
||||
balloon.style.webkitTransitionProperty = '-webkit-transform,opacity';
|
||||
|
||||
switch ( options.animationOut ) {
|
||||
case 'drop':
|
||||
if ( isIPad ) {
|
||||
duration = '0.4s';
|
||||
opacity = '0';
|
||||
posY = posY + 50;
|
||||
} else {
|
||||
duration = '0.6s';
|
||||
posY = posY + balloon.offsetHeight + options.bottomOffset + 50;
|
||||
}
|
||||
break;
|
||||
case 'bubble':
|
||||
if ( isIPad ) {
|
||||
duration = '0.8s';
|
||||
posY = posY - balloon.offsetHeight - options.bottomOffset - 50;
|
||||
} else {
|
||||
duration = '0.4s';
|
||||
opacity = '0';
|
||||
posY = posY - 50;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
duration = '0.8s';
|
||||
opacity = '0';
|
||||
}
|
||||
|
||||
balloon.addEventListener('webkitTransitionEnd', transitionEnd, false);
|
||||
balloon.style.opacity = opacity;
|
||||
balloon.style.webkitTransitionDuration = duration;
|
||||
balloon.style.webkitTransform = 'translate3d(' + posX + 'px,' + posY + 'px,0)';
|
||||
}
|
||||
|
||||
|
||||
function clicked () {
|
||||
w.sessionStorage.setItem('addToHomeSession', '1');
|
||||
isSessionActive = true;
|
||||
close();
|
||||
}
|
||||
|
||||
function transitionEnd () {
|
||||
balloon.removeEventListener('webkitTransitionEnd', transitionEnd, false);
|
||||
|
||||
balloon.style.webkitTransitionProperty = '-webkit-transform';
|
||||
balloon.style.webkitTransitionDuration = '0.2s';
|
||||
|
||||
// We reached the end!
|
||||
if ( !closeTimeout ) {
|
||||
balloon.parentNode.removeChild(balloon);
|
||||
balloon = null;
|
||||
return;
|
||||
}
|
||||
|
||||
// On iOS 4 we start checking the element position
|
||||
if ( OSVersion < 5 && closeTimeout ) positionInterval = setInterval(setPosition, options.iterations);
|
||||
}
|
||||
|
||||
function setPosition () {
|
||||
var matrix = new WebKitCSSMatrix(w.getComputedStyle(balloon, null).webkitTransform),
|
||||
posY = isIPad ? w.scrollY - startY : w.scrollY + w.innerHeight - startY,
|
||||
posX = isIPad ? w.scrollX - startX : w.scrollX + Math.round((w.innerWidth - balloon.offsetWidth) / 2) - startX;
|
||||
|
||||
// Screen didn't move
|
||||
if ( posY == matrix.m42 && posX == matrix.m41 ) return;
|
||||
|
||||
balloon.style.webkitTransform = 'translate3d(' + posX + 'px,' + posY + 'px,0)';
|
||||
}
|
||||
|
||||
// Clear local and session storages (this is useful primarily in development)
|
||||
function reset () {
|
||||
w.localStorage.removeItem('addToHome');
|
||||
w.sessionStorage.removeItem('addToHomeSession');
|
||||
}
|
||||
|
||||
function orientationCheck () {
|
||||
balloon.style.marginLeft = -Math.round(balloon.offsetWidth / 2) - ( w.orientation%180 && OSVersion >= 6 ? 40 : 0 ) + 'px';
|
||||
}
|
||||
|
||||
// Bootstrap!
|
||||
init();
|
||||
|
||||
return {
|
||||
show: manualShow,
|
||||
close: close,
|
||||
reset: reset
|
||||
};
|
||||
})(window);
|
||||
@@ -0,0 +1,34 @@
|
||||
String.prototype.format = function() { a = this; for ( k in arguments ) { a = a.replace("{" + k + "}", arguments[k]); } return a; };
|
||||
window.gmAPI = {
|
||||
'version': '3.0-rc1',
|
||||
'ga': '',
|
||||
'primaryUrl': 'http://code.google.com/p/jquery-ui-map/',
|
||||
'url': 'http://jquery-ui-map.googlecode.com/',
|
||||
'forum': 'http://groups.google.com/group/jquery-ui-map-discuss/feed/rss_v2_0_msgs.xml',
|
||||
'subscribe': 'http://groups.google.com/group/jquery-ui-map-discuss/boxsubscribe',
|
||||
'exception': 'Unable to load due to either poor internet connection or some CDN\'s aren\'t as responsive as we would like them to be. Try refreshing the page :D.',
|
||||
'init': function() {
|
||||
//window._gaq = [['_setAccount', this.ga], ['_trackPageview'], ['_trackPageLoadTime']];
|
||||
//Modernizr.load({ 'test': ( location.href.indexOf(this.url) > -1 ), 'yep': 'http://www.google-analytics.com/ga.js' });
|
||||
this.test('Backbone', function() {
|
||||
$('#forum').append('<h2>Forum</h2><ul id="forum_posts"></ul><h2>Subscribe</h2><form id="forum_subscribe" class="subscribe" action="#"><label for="email">E-mail:</label><input id="email" type="text" name="email" /><input type="submit" name="sub" value="Subscribe" /></form>');
|
||||
ForumCollection = Backbone.Collection.extend({ 'url': 'http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q={0}'.format(encodeURIComponent(gmAPI.forum)), 'parse': function(response) { return response.responseData.feed.entries; } });
|
||||
ForumPost = Backbone.View.extend({ 'tagName': 'li', 'className': 'group-item', 'template': _.template('<a href="<%=link%>"><%=title%></a></h3>'), 'render': function() { $(this.el).html(this.template(this.model.toJSON())); return this; } });
|
||||
Forum = Backbone.View.extend({ 'el': $("#forum"), 'initialize': function() { this.col = new ForumCollection(); this.col.bind('reset', this.load, this); this.col.fetch(); }, 'add': function(post) { var view = new ForumPost({'model': post}); $('#forum_posts').append(view.render().el); }, 'load': function () { this.col.each(this.add); $('#forum_subscribe').attr('action', gmAPI.subscribe); $(this.el).show(); } });
|
||||
var app = new Forum();
|
||||
});
|
||||
this.test('prettyPrint', function() { prettyPrint(); });
|
||||
$('#version').text(this.version);
|
||||
},
|
||||
'redirect': function(url) { alert('This page is deprecated. Please update your URL. Redirecting to new page.'); window.location = url; },
|
||||
'col': [],
|
||||
'tests': [],
|
||||
'test': function(a, b) { if ( window[a] ) { b(); } },
|
||||
'add': function(a, b) { if (b) { this.col[a] = b; } else { this.col.push(a); } return this; },
|
||||
'load': function(a) { var self = this; if (a) { self.col[a](); } else { $.each(self.col, function(i,d) { try { d(); } catch (err) { alert(self.exception); } }); } },
|
||||
'timeStart': function(key, desc) { this.tests[key] = { 'start': new Date().getTime(), 'desc': desc }; },
|
||||
'timeEnd': function(key) { this.tests[key].elapsed = new Date().getTime(); },
|
||||
'report': function(id) { var i = 1; for ( var k in this.tests ) { var t = this.tests[k]; $(id).append('<div class="benchmark rounded"><div class="benchmark-result lt">' + (t.elapsed - t.start) + ' ms</div><div class="lt"><p class="benchmark-iteration">Benchmark case ' + i + '</p><p class="benchmark-title">' + t.desc + '</p></div></div>'); i++; }; }
|
||||
};
|
||||
|
||||
gmAPI.init();
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,2 @@
|
||||
/*! jQuery Mobile vGit Build: SHA1: b49cc06499abf8f987cf90f35349cfac0918c939 <> Date: Tue Oct 2 11:22:34 2012 -0700 jquerymobile.com | jquery.org/license !*/
|
||||
(function(a,b,c){typeof define=="function"&&define.amd?define(["jquery"],function(d){return c(d,a,b),d.mobile}):c(a.jQuery,a,b)})(this,document,function(a,b,c,d){(function(a,b,d){var e={};a.mobile=a.extend({},{version:"1.2.0",ns:"",subPageUrlKey:"ui-page",activePageClass:"ui-page-active",activeBtnClass:"ui-btn-active",focusClass:"ui-focus",ajaxEnabled:!0,hashListeningEnabled:!0,linkBindingEnabled:!0,defaultPageTransition:"fade",maxTransitionWidth:!1,minScrollBack:250,touchOverflowEnabled:!1,defaultDialogTransition:"pop",pageLoadErrorMessage:"Error Loading Page",pageLoadErrorMessageTheme:"e",phonegapNavigationEnabled:!1,autoInitializePage:!0,pushStateEnabled:!0,ignoreContentEnabled:!1,orientationChangeEnabled:!0,buttonMarkup:{hoverDelay:200},keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91},silentScroll:function(d){a.type(d)!=="number"&&(d=a.mobile.defaultHomeScroll),a.event.special.scrollstart.enabled=!1,setTimeout(function(){b.scrollTo(0,d),a(c).trigger("silentscroll",{x:0,y:d})},20),setTimeout(function(){a.event.special.scrollstart.enabled=!0},150)},nsNormalizeDict:e,nsNormalize:function(b){if(!b)return;return e[b]||(e[b]=a.camelCase(a.mobile.ns+b))},getInheritedTheme:function(a,b){var c=a[0],d="",e=/ui-(bar|body|overlay)-([a-z])\b/,f,g;while(c){f=c.className||"";if(f&&(g=e.exec(f))&&(d=g[2]))break;c=c.parentNode}return d||b||"a"},closestPageData:function(a){return a.closest(':jqmData(role="page"), :jqmData(role="dialog")').data("page")},enhanceable:function(a){return this.haveParents(a,"enhance")},hijackable:function(a){return this.haveParents(a,"ajax")},haveParents:function(b,c){if(!a.mobile.ignoreContentEnabled)return b;var d=b.length,e=a(),f,g,h;for(var i=0;i<d;i++){g=b.eq(i),h=!1,f=b[i];while(f){var j=f.getAttribute?f.getAttribute("data-"+a.mobile.ns+c):"";if(j==="false"){h=!0;break}f=f.parentNode}h||(e=e.add(g))}return e},getScreenHeight:function(){return b.innerHeight||a(b).height()}},a.mobile),a.fn.jqmData=function(b,c){var e;return typeof b!="undefined"&&(b&&(b=a.mobile.nsNormalize(b)),arguments.length<2||c===d?e=this.data(b):e=this.data(b,c)),e},a.jqmData=function(b,c,d){var e;return typeof c!="undefined"&&(e=a.data(b,c?a.mobile.nsNormalize(c):c,d)),e},a.fn.jqmRemoveData=function(b){return this.removeData(a.mobile.nsNormalize(b))},a.jqmRemoveData=function(b,c){return a.removeData(b,a.mobile.nsNormalize(c))},a.fn.removeWithDependents=function(){a.removeWithDependents(this)},a.removeWithDependents=function(b){var c=a(b);(c.jqmData("dependents")||a()).remove(),c.remove()},a.fn.addDependents=function(b){a.addDependents(a(this),b)},a.addDependents=function(b,c){var d=a(b).jqmData("dependents")||a();a(b).jqmData("dependents",a.merge(d,c))},a.fn.getEncodedText=function(){return a("<div/>").text(a(this).text()).html()},a.fn.jqmEnhanceable=function(){return a.mobile.enhanceable(this)},a.fn.jqmHijackable=function(){return a.mobile.hijackable(this)};var f=a.find,g=/:jqmData\(([^)]*)\)/g;a.find=function(b,c,d,e){return b=b.replace(g,"[data-"+(a.mobile.ns||"")+"$1]"),f.call(this,b,c,d,e)},a.extend(a.find,f),a.find.matches=function(b,c){return a.find(b,null,null,c)},a.find.matchesSelector=function(b,c){return a.find(c,null,null,[b]).length>0}})(a,this),function(a,b){var c=0,d=Array.prototype.slice,e=a.cleanData;a.cleanData=function(b){for(var c=0,d;(d=b[c])!=null;c++)try{a(d).triggerHandler("remove")}catch(f){}e(b)},a.widget=function(b,c,d){var e,f,g,h,i=b.split(".")[0];b=b.split(".")[1],e=i+"-"+b,d||(d=c,c=a.Widget),a.expr[":"][e]=function(b){return!!a.data(b,e)},a[i]=a[i]||{},f=a[i][b],g=a[i][b]=function(a,b){if(!this._createWidget)return new g(a,b);arguments.length&&this._createWidget(a,b)},a.extend(g,f,{version:d.version,_proto:a.extend({},d),_childConstructors:[]}),h=new c,h.options=a.widget.extend({},h.options),a.each(d,function(b,e){a.isFunction(e)&&(d[b]=function(){var a=function(){return c.prototype[b].apply(this,arguments)},d=function(a){return c.prototype[b].apply(this,a)};return function(){var b=this._super,c=this._superApply,f;return this._super=a,this._superApply=d,f=e.apply(this,arguments),this._super=b,this._superApply=c,f}}())}),g.prototype=a.widget.extend(h,{widgetEventPrefix:b},d,{constructor:g,namespace:i,widgetName:b,widgetBaseClass:e,widgetFullName:e}),f?(a.each(f._childConstructors,function(b,c){var d=c.prototype;a.widget(d.namespace+"."+d.widgetName,g,c._proto)}),delete f._childConstructors):c._childConstructors.push(g),a.widget.bridge(b,g)},a.widget.extend=function(c){var e=d.call(arguments,1),f=0,g=e.length,h,i;for(;f<g;f++)for(h in e[f])i=e[f][h],e[f].hasOwnProperty(h)&&i!==b&&(c[h]=a.isPlainObject(i)?a.widget.extend({},c[h],i):i);return c},a.widget.bridge=fuLine truncated
|
||||
@@ -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 ($.browser.msie)
|
||||
{
|
||||
// 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 (!$.browser.msie)
|
||||
{
|
||||
// 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 || $.browser.msie ) {
|
||||
$( this ).trigger( "load" ).trigger( "error" );
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
})( jQuery );
|
||||
@@ -0,0 +1,242 @@
|
||||
//SwipePlanes v1.2 jQuery Plugin by REMD
|
||||
$.fn.swipePlanes = function(opciones){
|
||||
return this.each(function(){
|
||||
|
||||
var randId = Math.round(100*Math.random()); ////IDENTIFICADOR ALEATORIO DE LA INSTANCIA//////////
|
||||
|
||||
//EL VISOR /////////////////////////////////////
|
||||
this.onselectstart = function(){return false;};
|
||||
this.unselectable = "on";
|
||||
$(this).css('-moz-user-select', 'none');
|
||||
$(this).css('-webkit-user-select', 'none');
|
||||
$(this).css('overflow','hidden');
|
||||
|
||||
if($(this).css('position') != 'absolute')$(this).css('position','relative');
|
||||
|
||||
|
||||
var anchoVisor = $(this).width();
|
||||
var altoVisor = $(this).height;
|
||||
var divVisor = this;
|
||||
|
||||
//El CONTENEDOR /////////////////////////////////////
|
||||
var divContenedor;
|
||||
var pagActual = 0;
|
||||
|
||||
divContenedor = $(this).children('div:first');
|
||||
divContenedor.css('transition','none');
|
||||
divContenedor.css('-moz-user-select', 'none');
|
||||
divContenedor.css('-webkit-user-select', 'none');
|
||||
divContenedor.css('position','relative');
|
||||
divContenedor.css('left','0px');
|
||||
|
||||
//LAS PAGINAS /////////////////////////////////////////
|
||||
var divPaginas;
|
||||
var bufferPaginas = 0;
|
||||
var metaPaginas = 0;
|
||||
var metaPagNum = 0;
|
||||
|
||||
divPaginas = divContenedor.children('div,a');
|
||||
divPaginas.css('display','inline-block');
|
||||
divPaginas.css('float','left');
|
||||
divPaginas.css('position','relative');
|
||||
|
||||
metaPaginas = new Array();
|
||||
metaPaginas[0] = 0;
|
||||
|
||||
divPaginas.each(function(){
|
||||
if((bufferPaginas+(this.offsetWidth)) > anchoVisor+metaPaginas[metaPagNum]){
|
||||
if(bufferPaginas > 0)metaPagNum++;
|
||||
metaPaginas[metaPagNum] = bufferPaginas;
|
||||
}
|
||||
|
||||
bufferPaginas += (this.offsetWidth + parseInt($(this).css('margin-left'))+parseInt($(this).css('margin-right')));
|
||||
});
|
||||
|
||||
metaPaginas[metaPagNum] -= anchoVisor - (bufferPaginas-metaPaginas[metaPagNum]); //Ajuste �ltimo salto
|
||||
|
||||
divContenedor.css('width',bufferPaginas+'px'); //Ajuste Contenedor al tamano de las paginas
|
||||
|
||||
generarControles($(this),metaPagNum);
|
||||
|
||||
//LOS EVENTOS ////////////////////////////////////////////
|
||||
var iX = 0,aX = 0,fX = 0; //Manejo de coordenadas
|
||||
var drag = 0,t = 0,ms = 0,metaEvento,dX = 0; //Manejo del entorno/tiempo
|
||||
|
||||
$(this).bind('touchstart',function(event){
|
||||
clearInterval(t);
|
||||
|
||||
if(event.pageX)iX = event.pageX;
|
||||
if(event.originalEvent.touches)iX = event.originalEvent.touches[0].pageX;
|
||||
|
||||
divContenedor.css('transition','none');
|
||||
|
||||
drag = 1;
|
||||
ms = 0;
|
||||
metaEvento = 'click';
|
||||
t = setInterval(function(){ms++;},1);
|
||||
});
|
||||
|
||||
$(this).bind('touchmove',function(event){
|
||||
if(event.pageX)aX = event.pageX;
|
||||
if(event.originalEvent.touches)aX = event.originalEvent.touches[0].pageX;
|
||||
dX = Math.abs(aX - iX);
|
||||
|
||||
if(dX > 50)event.preventDefault();
|
||||
|
||||
|
||||
if(drag && dX > 50){
|
||||
divContenedor.css('left',(((metaPaginas[pagActual]*-1)+(aX - iX)))+'px');
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$(this).bind('touchend touchcancel touchleave',function(event){
|
||||
|
||||
if(drag && dX > 20){
|
||||
drag = 0;
|
||||
console.log(metaPaginas);
|
||||
dX = Math.abs(fX - iX);
|
||||
clearInterval(t);
|
||||
|
||||
if(event.pageX)fX = event.pageX;
|
||||
if(event.originalEvent.touches)fX = aX;
|
||||
|
||||
if((iX-fX) > 0 && ms < 100 && dX > 50)metaEvento = 'swipeLeft';
|
||||
if((iX-fX) <= 0 && ms < 100 && dX > 50)metaEvento = 'swipeRight';
|
||||
if((iX-fX) > 0 && ms > 100 && dX > 50)metaEvento = 'moveLeft';
|
||||
if((iX-fX) <= 0 && ms > 100 && dX > 50)metaEvento = 'moveRight';
|
||||
if(dX <= 50)metaEvento = 'click';
|
||||
|
||||
switch(metaEvento){
|
||||
case 'swipeLeft':
|
||||
if(pagActual < metaPagNum){pagActual++;}
|
||||
break;
|
||||
|
||||
case 'moveLeft':
|
||||
if(pagActual < metaPagNum && dX > (Math.abs(anchoVisor/2))){pagActual++;}
|
||||
break;
|
||||
|
||||
case 'swipeRight':
|
||||
if(pagActual > 0){pagActual--;}
|
||||
break;
|
||||
|
||||
case 'moveRight':
|
||||
if(pagActual > 0 && dX > (Math.abs(anchoVisor/2))){pagActual--;}
|
||||
break;
|
||||
}
|
||||
|
||||
ms = 0; dX = 0; iX = 0; aX = 0; fX = 0; metaEvento = '';
|
||||
|
||||
irPagina(pagActual);
|
||||
}
|
||||
});
|
||||
|
||||
//EVENTOS CONTROLES /////////////////////////////////////////
|
||||
$('.'+randId+'swipePlanesMiniPag').click(function(){
|
||||
pagActual = $(this).attr('mpg');
|
||||
irPagina();
|
||||
});
|
||||
|
||||
$('.'+randId+'swipePlanesRowLeft').click(function(e){
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
if(pagActual > 0)pagActual--;
|
||||
irPagina();
|
||||
});
|
||||
|
||||
$('.'+randId+'swipePlanesRowRight').click(function(e){
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
if(pagActual < metaPagNum)pagActual++;
|
||||
irPagina();
|
||||
});
|
||||
|
||||
$(this).bind('mousemove',function(){
|
||||
$('.'+randId+'swipePlanesRowLeft').css('display','block');
|
||||
$('.'+randId+'swipePlanesRowRight').css('display','block');
|
||||
$('.'+randId+'swipePlanesRowLeft').css('opacity','1');
|
||||
$('.'+randId+'swipePlanesRowRight').css('opacity','1');
|
||||
});
|
||||
|
||||
$('.'+randId+'swipePlanesRowLeft').bind('mousemove',function(){
|
||||
$('.'+randId+'swipePlanesRowLeft').css('opacity','1');
|
||||
$('.'+randId+'swipePlanesRowRight').css('opacity','1');
|
||||
});
|
||||
|
||||
$('.'+randId+'swipePlanesRowRight').bind('mousemove',function(){
|
||||
$('.'+randId+'swipePlanesRowLeft').css('opacity','1');
|
||||
$('.'+randId+'swipePlanesRowRight').css('opacity','1');
|
||||
});
|
||||
|
||||
$(this).mouseout(function(){
|
||||
$('.'+randId+'swipePlanesRowLeft').css('opacity','0');
|
||||
$('.'+randId+'swipePlanesRowRight').css('opacity','0');
|
||||
});
|
||||
|
||||
//CONTROLES //////////////////////////////////////////////
|
||||
function generarControles(divVisor,metaPagNum){
|
||||
|
||||
|
||||
var i = 0;
|
||||
var miniPaginasHtml = '';
|
||||
var style = '';
|
||||
|
||||
for(i;i <= metaPagNum; i++){
|
||||
if(!i)style='background:#CECECE';
|
||||
else style='';
|
||||
miniPaginasHtml += '<div mpg="'+i+'" style="'+style+'" class="'+randId+'swipePlanesMiniPag"></div>';
|
||||
}
|
||||
// <div class="'+randId+'swipePlanesRowLeft"></div><div class="'+randId+'swipePlanesRowRight"></div>
|
||||
var controlesHtml = '<div class="'+randId+'swipePlanesPaginator">'+miniPaginasHtml+'</div>';
|
||||
|
||||
divVisor.append(controlesHtml);
|
||||
|
||||
$('.'+randId+'swipePlanesMiniPag').css('display','inline-block');
|
||||
$('.'+randId+'swipePlanesMiniPag').css('width','7px');
|
||||
$('.'+randId+'swipePlanesMiniPag').css('height','7px');
|
||||
$('.'+randId+'swipePlanesMiniPag').css('margin-left','2px');
|
||||
$('.'+randId+'swipePlanesMiniPag').css('margin-right','2px');
|
||||
$('.'+randId+'swipePlanesMiniPag').css('border','1px solid #CECECE');
|
||||
$('.'+randId+'swipePlanesMiniPag').css('border-radius','4px');
|
||||
$('.'+randId+'swipePlanesMiniPag').css('cursor','pointer');
|
||||
|
||||
$('.'+randId+'swipePlanesRowLeft').css('background-image','url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAABkCAYAAADE6GNbAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAKwwAACsMBNCkkqwAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNui8sowAAAAWdEVYdENyZWF0aW9uIFRpbWUAMTAvMTkvMTJlCtGpAAABaElEQVR4nO3cS3HEMBRE0atU1oaURTCIwxiSh4NQBNIQcDDEfp/OVF8AKp3yR5IXHsD3GIP/3HmefI4xOI6jey632vedj+5JRGWIWoaoZYhahqhliFqGqGWIWoaoZYhahqhliFqGqGWIWoZENed8RIzTCplzPrZt+4oYqw0SiYAmSDQCGiAZCCiGZCGgEJKJgCJINgIKIBUISIZUISARUomAJEg1AhIgHQgIhnQhIBDSiYAgSDcCAiAKCLgJUUHADYgSAi5C1BBwAaKIAIGPD1H9GbLWer5er5+Mydzp0hVRxFy+tdQwt54RJczth10FE/LWUsCEvX67MaHrSCcmfEHswqSs7B2YtC1KNSZ1r1WJSd80VmFKdr8VmLJtfDam9DySiSk/WGVhWk6IGZi2o240pvXMHolp//iw1npGjNMOicoQtQxRyxC1DFHLELUMUcsQtQxRyxC1DFHLELUMUettIIM3+XXbL64qrlAHZEgkAAAAAElFTkSuQmCC)');
|
||||
$('.'+randId+'swipePlanesRowLeft').css('position','absolute');
|
||||
$('.'+randId+'swipePlanesRowLeft').css('width','50px');
|
||||
$('.'+randId+'swipePlanesRowLeft').css('height','100px');
|
||||
$('.'+randId+'swipePlanesRowLeft').css('cursor','pointer');
|
||||
$('.'+randId+'swipePlanesRowLeft').css('left','0px');
|
||||
$('.'+randId+'swipePlanesRowLeft').css('top',((divVisor.height()/2)-50)+'px');
|
||||
$('.'+randId+'swipePlanesRowLeft').css('z-index','909');
|
||||
$('.'+randId+'swipePlanesRowLeft').css('display','none');
|
||||
$('.'+randId+'swipePlanesRowLeft').css('box-shadow','0 1px 3px rgba(0, 0, 0, 0.3);');
|
||||
|
||||
$('.'+randId+'swipePlanesRowRight').css('background-image','url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAABkCAYAAADE6GNbAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAKwwAACsMBNCkkqwAAABx0RVh0U29mdHdhcmUAQWRvYmUgRmlyZXdvcmtzIENTNui8sowAAAAWdEVYdENyZWF0aW9uIFRpbWUAMTAvMTkvMTJlCtGpAAABXklEQVR4nO3cvW2EQBRF4TPWxpTkwDXQw1IS7oEqXBINsKlTM+/nenVPDuKTYOZNwgC+xhj8567r4jHGYN/37meZats2ProfIipD1DJELUPUMkQtQ9QyRC1D1DJELUPUMkQtQ9QyRC1D1DLkd+u6PiPuM1MIZFmWz25M2KvVjQn9Rjox4R97FyZl1erApC2/1ZjUfaQSk74hVmFKdvYKTNmIko0pnbUyMeVDYxamZfrNwLSN8dGY1vNIJKb9YBWFaYdADEYCAvMYGQjMYaQgcB8jB7mbHOQ8z5/jOL7/ep0U5C4ChCAzCBCBzCJAABKBgGZIFAIaIZEIaIJEI6ABkoGAYkgWAgohmQgogmQjoABSgYBkSBUCEiGVCEiCVCMgAdKBgGBIFwICIZ0ICIJ0IyAI0o0AgYNVVIaoZYhahqhliFqGqGWIWoaoZYhahqhliFqGqGWIWm8DGbzJr9teHYWuULzgkDAAAAAASUVORK5CYII=)');
|
||||
$('.'+randId+'swipePlanesRowRight').css('position','absolute');
|
||||
$('.'+randId+'swipePlanesRowRight').css('width','50px');
|
||||
$('.'+randId+'swipePlanesRowRight').css('height','100px');
|
||||
$('.'+randId+'swipePlanesRowRight').css('cursor','pointer');
|
||||
$('.'+randId+'swipePlanesRowRight').css('right','0px');
|
||||
$('.'+randId+'swipePlanesRowRight').css('top',((divVisor.height()/2)-50)+'px');
|
||||
$('.'+randId+'swipePlanesRowRight').css('z-index','909');
|
||||
$('.'+randId+'swipePlanesRowRight').css('display','none');
|
||||
$('.'+randId+'swipePlanesRowRight').css('box-shadow','0 1px 3px rgba(0, 0, 0, 0.3);');
|
||||
|
||||
$('.'+randId+'swipePlanesPaginator').css('position','absolute');
|
||||
$('.'+randId+'swipePlanesPaginator').css('padding','0px 4px');
|
||||
$('.'+randId+'swipePlanesPaginator').css('top','10px');
|
||||
$('.'+randId+'swipePlanesPaginator').css('box-shadow','0 1px 3px rgba(0, 0, 0, 0.3);');
|
||||
$('.'+randId+'swipePlanesPaginator').css('border-radius','4px');
|
||||
$('.'+randId+'swipePlanesPaginator').css('left',((divVisor.width()/2)-($('.'+randId+'swipePlanesPaginator').width()/2))+'px');
|
||||
|
||||
}
|
||||
|
||||
function irPagina(){
|
||||
divContenedor.css('transition','left 500ms');
|
||||
divContenedor.css('left',((metaPaginas[pagActual])*-1)+'px');
|
||||
|
||||
$('.'+randId+'swipePlanesMiniPag').css('background','');
|
||||
$('.'+randId+'swipePlanesMiniPag[mpg='+pagActual+']').css('background','#CECECE');
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,373 @@
|
||||
/*!
|
||||
* jQuery FN Google Map 3.0-rc
|
||||
* http://code.google.com/p/jquery-ui-map/
|
||||
* Copyright (c) 2010 - 2012 Johan Säll Larsson
|
||||
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
( function($) {
|
||||
|
||||
/**
|
||||
* @param name:string
|
||||
* @param prototype:object
|
||||
*/
|
||||
$.a = function(name, prototype) {
|
||||
|
||||
var namespace = name.split('.')[0];
|
||||
name = name.split('.')[1];
|
||||
|
||||
$[namespace] = $[namespace] || {};
|
||||
$[namespace][name] = function(options, element) {
|
||||
if ( arguments.length ) {
|
||||
this._setup(options, element);
|
||||
}
|
||||
};
|
||||
|
||||
$[namespace][name].prototype = $.extend({
|
||||
'namespace': namespace,
|
||||
'pluginName': name
|
||||
}, prototype);
|
||||
|
||||
$.fn[name] = function(options) {
|
||||
|
||||
var isMethodCall = typeof options === "string",
|
||||
args = Array.prototype.slice.call(arguments, 1),
|
||||
returnValue = this;
|
||||
|
||||
if ( isMethodCall && options.substring(0, 1) === '_' ) {
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
this.each(function() {
|
||||
var instance = $.data(this, name);
|
||||
if (!instance) {
|
||||
instance = $.data(this, name, new $[namespace][name](options, this));
|
||||
}
|
||||
if (isMethodCall) {
|
||||
returnValue = instance[options].apply(instance, args);
|
||||
}
|
||||
});
|
||||
|
||||
return returnValue;
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
$.a('ui.gmap', {
|
||||
|
||||
/**
|
||||
* Map options
|
||||
* @see http://code.google.com/intl/sv-SE/apis/maps/documentation/javascript/reference.html#MapOptions
|
||||
*/
|
||||
options: {
|
||||
mapTypeId: 'roadmap',
|
||||
zoom: 5
|
||||
},
|
||||
|
||||
/**
|
||||
* Get or set options
|
||||
* @param key:string
|
||||
* @param options:object
|
||||
* @return object
|
||||
*/
|
||||
option: function(key, options) {
|
||||
if (options) {
|
||||
this.options[key] = options;
|
||||
this.get('map').set(key, options);
|
||||
return this;
|
||||
}
|
||||
return this.options[key];
|
||||
},
|
||||
|
||||
/**
|
||||
* Setup plugin basics,
|
||||
* @param options:object
|
||||
* @param element:node
|
||||
*/
|
||||
_setup: function(options, element) {
|
||||
this.el = element;
|
||||
options = options || {};
|
||||
jQuery.extend(this.options, options, { 'center': this._latLng(options.center) });
|
||||
this._create();
|
||||
if ( this._init ) { this._init(); }
|
||||
},
|
||||
|
||||
/**
|
||||
* Instanciate the Google Maps object
|
||||
*/
|
||||
_create: function() {
|
||||
var self = this;
|
||||
this.instance = { 'map': new google.maps.Map(self.el, self.options), 'markers': [], 'overlays': [], 'services': [] };
|
||||
google.maps.event.addListenerOnce(self.instance.map, 'bounds_changed', function() { $(self.el).trigger('init', self.instance.map); });
|
||||
self._call(self.options.callback, self.instance.map);
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a latitude longitude pair to the bounds.
|
||||
* @param position:google.maps.LatLng/string
|
||||
*/
|
||||
addBounds: function(position) {
|
||||
var bounds = this.get('bounds', new google.maps.LatLngBounds());
|
||||
bounds.extend(this._latLng(position));
|
||||
this.get('map').fitBounds(bounds);
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper function to check if a LatLng is within the viewport
|
||||
* @param marker:google.maps.Marker
|
||||
*/
|
||||
inViewport: function(marker) {
|
||||
var bounds = this.get('map').getBounds();
|
||||
return (bounds) ? bounds.contains(marker.getPosition()) : false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a custom control to the map
|
||||
* @param panel:jquery/node/string
|
||||
* @param position:google.maps.ControlPosition
|
||||
* @see http://code.google.com/intl/sv-SE/apis/maps/documentation/javascript/reference.html#ControlPosition
|
||||
*/
|
||||
addControl: function(panel, position) {
|
||||
this.get('map').controls[position].push(this._unwrap(panel));
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds a Marker to the map
|
||||
* @param markerOptions:google.maps.MarkerOptions
|
||||
* @param callback:function(map:google.maps.Map, marker:google.maps.Marker) (optional)
|
||||
* @return $(google.maps.Marker)
|
||||
* @see http://code.google.com/intl/sv-SE/apis/maps/documentation/javascript/reference.html#MarkerOptions
|
||||
*/
|
||||
addMarker: function(markerOptions, callback) {
|
||||
markerOptions.map = this.get('map');
|
||||
markerOptions.position = this._latLng(markerOptions.position);
|
||||
var marker = new (markerOptions.marker || google.maps.Marker)(markerOptions);
|
||||
var markers = this.get('markers');
|
||||
if ( marker.id ) {
|
||||
markers[marker.id] = marker;
|
||||
} else {
|
||||
markers.push(marker);
|
||||
}
|
||||
if ( marker.bounds ) {
|
||||
this.addBounds(marker.getPosition());
|
||||
}
|
||||
this._call(callback, markerOptions.map, marker);
|
||||
return $(marker);
|
||||
},
|
||||
|
||||
/**
|
||||
* Clears by type
|
||||
* @param ctx:string e.g. 'markers', 'overlays', 'services'
|
||||
*/
|
||||
clear: function(ctx) {
|
||||
this._c(this.get(ctx));
|
||||
this.set(ctx, []);
|
||||
return this;
|
||||
},
|
||||
|
||||
_c: function(obj) {
|
||||
for ( var property in obj ) {
|
||||
if ( obj.hasOwnProperty(property) ) {
|
||||
if ( obj[property] instanceof google.maps.MVCObject ) {
|
||||
google.maps.event.clearInstanceListeners(obj[property]);
|
||||
if ( obj[property].setMap ) {
|
||||
obj[property].setMap(null);
|
||||
}
|
||||
} else if ( obj[property] instanceof Array ) {
|
||||
this._c(obj[property]);
|
||||
}
|
||||
obj[property] = null;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the objects with a specific property and value, e.g. 'category', 'tags'
|
||||
* @param ctx:string in what context, e.g. 'markers'
|
||||
* @param options:object property:string the property to search within, value:string, operator:string (optional) (AND/OR)
|
||||
* @param callback:function(marker:google.maps.Marker, isFound:boolean)
|
||||
*/
|
||||
find: function(ctx, options, callback) {
|
||||
var obj = this.get(ctx);
|
||||
options.value = $.isArray(options.value) ? options.value : [options.value];
|
||||
for ( var property in obj ) {
|
||||
if ( obj.hasOwnProperty(property) ) {
|
||||
var isFound = false;
|
||||
for ( var value in options.value ) {
|
||||
if ( $.inArray(options.value[value], obj[property][options.property]) > -1 ) {
|
||||
isFound = true;
|
||||
} else {
|
||||
if ( options.operator && options.operator === 'AND' ) {
|
||||
isFound = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
callback(obj[property], isFound);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an instance property by key. Has the ability to set an object if the property does not exist
|
||||
* @param key:string
|
||||
* @param value:object(optional)
|
||||
*/
|
||||
get: function(key, value) {
|
||||
var instance = this.instance;
|
||||
if ( !instance[key] ) {
|
||||
if ( key.indexOf('>') > -1 ) {
|
||||
var e = key.replace(/ /g, '').split('>');
|
||||
for ( var i = 0; i < e.length; i++ ) {
|
||||
if ( !instance[e[i]] ) {
|
||||
if (value) {
|
||||
instance[e[i]] = ( (i + 1) < e.length ) ? [] : value;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
instance = instance[e[i]];
|
||||
}
|
||||
return instance;
|
||||
} else if ( value && !instance[key] ) {
|
||||
this.set(key, value);
|
||||
}
|
||||
}
|
||||
return instance[key];
|
||||
},
|
||||
|
||||
/**
|
||||
* Triggers an InfoWindow to open
|
||||
* @param infoWindowOptions:google.maps.InfoWindowOptions
|
||||
* @param marker:google.maps.Marker (optional)
|
||||
* @param callback:function (optional)
|
||||
* @see http://code.google.com/intl/sv-SE/apis/maps/documentation/javascript/reference.html#InfoWindowOptions
|
||||
*/
|
||||
openInfoWindow: function(infoWindowOptions, marker, callback) {
|
||||
var iw = this.get('iw', infoWindowOptions.infoWindow || new google.maps.InfoWindow);
|
||||
iw.setOptions(infoWindowOptions);
|
||||
iw.open(this.get('map'), this._unwrap(marker));
|
||||
this._call(callback, iw);
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Triggers an InfoWindow to close
|
||||
*/
|
||||
closeInfoWindow: function() {
|
||||
if ( this.get('iw') != null ) {
|
||||
this.get('iw').close();
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets an instance property
|
||||
* @param key:string
|
||||
* @param value:object
|
||||
*/
|
||||
set: function(key, value) {
|
||||
this.instance[key] = value;
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Refreshes the map
|
||||
*/
|
||||
refresh: function() {
|
||||
var map = this.get('map');
|
||||
var latLng = map.getCenter();
|
||||
$(map).triggerEvent('resize');
|
||||
map.setCenter(latLng);
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys the plugin.
|
||||
*/
|
||||
destroy: function() {
|
||||
this.clear('markers').clear('services').clear('overlays')._c(this.instance);
|
||||
jQuery.removeData(this.el, this.name);
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper method for calling a function
|
||||
* @param callback
|
||||
*/
|
||||
_call: function(callback) {
|
||||
if ( callback && $.isFunction(callback) ) {
|
||||
callback.apply(this, Array.prototype.slice.call(arguments, 1));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper method for google.maps.Latlng
|
||||
* @param latLng:string/google.maps.LatLng
|
||||
*/
|
||||
_latLng: function(latLng) {
|
||||
if ( !latLng ) {
|
||||
return new google.maps.LatLng(0.0, 0.0);
|
||||
}
|
||||
if ( latLng instanceof google.maps.LatLng ) {
|
||||
return latLng;
|
||||
} else {
|
||||
latLng = latLng.replace(/ /g,'').split(',');
|
||||
return new google.maps.LatLng(latLng[0], latLng[1]);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper method for unwrapping jQuery/DOM/string elements
|
||||
* @param obj:string/node/jQuery
|
||||
*/
|
||||
_unwrap: function(obj) {
|
||||
return (!obj) ? null : ( (obj instanceof jQuery) ? obj[0] : ((obj instanceof Object) ? obj : $('#'+obj)[0]) )
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
jQuery.fn.extend( {
|
||||
|
||||
triggerEvent: function(eventType) {
|
||||
google.maps.event.trigger(this[0], eventType);
|
||||
return this;
|
||||
},
|
||||
|
||||
addEventListener: function(eventType, eventDataOrCallback, eventCallback) {
|
||||
if ( google.maps && this[0] instanceof google.maps.MVCObject ) {
|
||||
google.maps.event.addListener(this[0], eventType, eventDataOrCallback);
|
||||
} else {
|
||||
if (eventCallback) {
|
||||
this.bind(eventType, eventDataOrCallback, eventCallback);
|
||||
} else {
|
||||
this.bind(eventType, eventDataOrCallback);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/*removeEventListener: function(eventType) {
|
||||
if ( google.maps && this[0] instanceof google.maps.MVCObject ) {
|
||||
if (eventType) {
|
||||
google.maps.event.clearListeners(this[0], eventType);
|
||||
} else {
|
||||
google.maps.event.clearInstanceListeners(this[0]);
|
||||
}
|
||||
} else {
|
||||
this.unbind(eventType);
|
||||
}
|
||||
return this;
|
||||
}*/
|
||||
|
||||
});
|
||||
|
||||
jQuery.each(('click rightclick dblclick mouseover mouseout drag dragend').split(' '), function(i, name) {
|
||||
jQuery.fn[name] = function(a, b) {
|
||||
return this.addEventListener(name, a, b);
|
||||
}
|
||||
});
|
||||
|
||||
} (jQuery) );
|
||||
@@ -0,0 +1,130 @@
|
||||
<%#= encoding: utf-8 %>
|
||||
// function slideshow() {
|
||||
// var $globalW = $(".global").width(),
|
||||
// $slideImg = $(".slideImg"),
|
||||
// $slidebanner = $(".slidebanner"),
|
||||
// $slideshow = $(".slideshow"),
|
||||
// $slideImgOW = $slideImg.width(),
|
||||
// $slideImgOH = $slideImg.height();
|
||||
// $slideImg.css({
|
||||
// "widht": $globalW,
|
||||
// "height": Math.floor(($globalW/$slideImgOW)*$slideImgOH),
|
||||
// });
|
||||
// $slideshow.css({
|
||||
// "width": $globalW,
|
||||
// "height": Math.floor(($globalW/$slideImgOW)*$slideImgOH),
|
||||
// });
|
||||
// alert(Math.floor(($globalW/$slideImgOW)*$slideImgOH))
|
||||
// }
|
||||
$('#index').live('pageinit',function(){
|
||||
var $globalW = $(window).width(),
|
||||
$slideshow = $(".slideshow");
|
||||
$slideshow.css({
|
||||
"width": $globalW, "height": Math.floor($globalW/720*240)
|
||||
});
|
||||
$(".slideImg").muImageResize({width: $globalW, height: Math.floor($globalW/720*240)});
|
||||
$(this).find(".newpic img").muImageResize({width: 280, height: 200});
|
||||
$('.slideshow').cycle({
|
||||
fx: $effect,
|
||||
timeout: $timeout
|
||||
});
|
||||
$(".newlist").css({
|
||||
"width" : $(".newitem").outerWidth()*(Math.floor($globalW/$(".newitem").outerWidth()))+30,
|
||||
})
|
||||
// var oc_timer;
|
||||
// clearTimeout(oc_timer);
|
||||
// oc_timer = setTimeout(function () {
|
||||
// $('.newlist').swipePlanes();
|
||||
// }, 1000);
|
||||
});
|
||||
$('#announcement_content').live('pageinit',function(){
|
||||
$(this).find(".newpic img").muImageResize({width: 320, height: 220});
|
||||
});
|
||||
|
||||
$('#map').live('pageinit', function() {
|
||||
var mobileDemo = { 'center': $map_center, 'zoom': $map_zoom };
|
||||
var $windowH = $(window).height();
|
||||
$("#map_canvas").css({
|
||||
'height' : $windowH,
|
||||
})
|
||||
gmAPI.add('basic_map', function() {
|
||||
$('#map_canvas').gmap({'center': mobileDemo.center, 'zoom': mobileDemo.zoom, 'disableDefaultUI':false, 'callback': function() {
|
||||
var self = this;
|
||||
self.addMarker({'position': this.get('map').getCenter() }).click(function() {
|
||||
self.openInfoWindow({ 'content': $info }, this);
|
||||
});
|
||||
}});
|
||||
}).load('basic_map');
|
||||
});
|
||||
|
||||
$('#map').live('pageshow', function() {
|
||||
gmAPI.add('basic_map', function() { $('#map_canvas').gmap('refresh'); }).load('basic_map');
|
||||
});
|
||||
|
||||
$(document).bind('pagebeforehide',function(){
|
||||
$("section.main-menu").removeClass("expanded");
|
||||
});
|
||||
$(document).bind("ready", function(){
|
||||
// $(".openmenu").live("tap", function(){
|
||||
// $("section.main-menu").toggleClass("expanded");
|
||||
// return!1
|
||||
// });
|
||||
$("body").delegate(".openmenu","vclick",function(){
|
||||
$("section.main-menu").toggleClass("expanded");
|
||||
return!1
|
||||
});
|
||||
// alert(navigator.userAgent)
|
||||
// $(".newpic img").muImageResize({width: 280, height: 100});
|
||||
// $('.newlist').swipePlanes();
|
||||
});
|
||||
|
||||
// $(window).resize(function(){
|
||||
// alert("Resize");
|
||||
// $(".slidebanner").removeAttr("style");
|
||||
// $(".slidebanner").find("div").removeAttr("style");
|
||||
// $(".slideImg").removeAttr("style");
|
||||
// var $globalW = $(window).width(),
|
||||
// $slideshow = $(".slideshow");
|
||||
// $slideshow.css({
|
||||
// "width": $globalW, "height": Math.floor($globalW/720*240)
|
||||
// });
|
||||
// $(".slideImg").muImageResize({width: $globalW, height: Math.floor($globalW/720*240)});
|
||||
// $('.slideshow').cycle({
|
||||
// fx:'scrollLeft',
|
||||
// timeout: 6000,
|
||||
// });
|
||||
// });
|
||||
$(window).bind("orientationchange", function(){
|
||||
var oc_timer;
|
||||
clearTimeout(oc_timer);
|
||||
oc_timer = setTimeout(function () {
|
||||
$(".slidebanner").removeAttr("style");
|
||||
$(".slidebanner").find("div").removeAttr("style");
|
||||
$(".slideImg").removeAttr("style");
|
||||
// $(".newlist").removeAttr("style");
|
||||
// $(".newlist").find(".clear").removeAttr("style");
|
||||
// $(".newitem").removeAttr("style");
|
||||
// $(".newlist").find(".clear").nextAll("div").remove();
|
||||
var $globalW = $(window).width(),
|
||||
$slideshow = $(".slideshow"),
|
||||
$windowH = $(window).height();
|
||||
$slideshow.css({
|
||||
"width": $globalW, "height": Math.floor($globalW/720*240)
|
||||
});
|
||||
|
||||
$(".slideImg").muImageResize({width: $globalW, height: Math.floor($globalW/720*240)});
|
||||
$('.slideshow').cycle({
|
||||
fx: $effect,
|
||||
timeout: $timeout
|
||||
});
|
||||
|
||||
$(".newlist").css({
|
||||
"width" : $(".newitem").outerWidth()*(Math.floor($globalW/$(".newitem").outerWidth()))+30,
|
||||
})
|
||||
|
||||
$("#map_canvas").css({
|
||||
'height' : $windowH,
|
||||
})
|
||||
// $('.newlist').swipePlanes();
|
||||
}, 500);
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
// This is a manifest file that'll be compiled into including all the files listed below.
|
||||
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
||||
// be included in the compiled file accessible from http://example.com/assets/application.js
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// the compiled file.
|
||||
//
|
||||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
@@ -0,0 +1,9 @@
|
||||
$('#feature .holder ul').cycle({
|
||||
fx: 'scrollDown',
|
||||
pager: '#feature-nav ul',
|
||||
pause: 1,
|
||||
pagerAnchorBuilder: function(idx, slide) {
|
||||
// return selector string for existing anchor
|
||||
return '#feature-nav ul li:eq(' + idx + ') a';
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
// This is a manifest file that'll be compiled into including all the files listed below.
|
||||
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
||||
// be included in the compiled file accessible from http://example.com/assets/application.js
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// the compiled file.
|
||||
//
|
||||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
//= require jquery.form
|
||||
//= require bootstrap
|
||||
//= require jquery.masonry.min
|
||||
//= require jquery.tinyscrollbar.min
|
||||
//= require orbit-1.0
|
||||
//= require tinymce-jquery
|
||||
//= require tinymce_orbit
|
||||
//= require orbit-bar-search
|
||||
//= require orbit-bar-member
|
||||
//= require side_bar_history
|
||||
//= require rss
|
||||
//= require ajax_form
|
||||
//= require inc/ajax_setting
|
||||
//= require lib/bootstrap-datetimepicker
|
||||
//= require datetimepicker
|
||||
@@ -0,0 +1,208 @@
|
||||
var viewportwidth,
|
||||
viewportheight;
|
||||
function resize() {
|
||||
viewportheight=$(window).height();
|
||||
viewportwidth=$(window).width();
|
||||
if(window.navigator.userAgent.indexOf("MSIE")>0){
|
||||
windH=document.clientHeight;
|
||||
windW=document.clientWidht;
|
||||
}
|
||||
}
|
||||
$(document).ready(function(){
|
||||
|
||||
$('.tip').tooltip({
|
||||
placement: "left"
|
||||
});
|
||||
|
||||
$(document).on('click', '.privacy', function() {
|
||||
|
||||
switch ($(this).val()) {
|
||||
case 'true':
|
||||
$(this).parents('.controls').children('.select-role').slideUp(300);
|
||||
break;
|
||||
case 'false':
|
||||
$(this).parents('.controls').children('.select-role').slideDown(300);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
var $role = $('.select-role');
|
||||
var method =$('.privacy:eq(1)').attr('checked');
|
||||
if(method == 'checked'){
|
||||
$role.slideDown(0);
|
||||
}
|
||||
$('.privacy').each(function($i) {
|
||||
$(this).click(function() {
|
||||
switch ($i) {
|
||||
case 0:
|
||||
$role.slideUp(300);
|
||||
break;
|
||||
case 1:
|
||||
$role.slideDown(300);
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/*tinyscrollbar&windows-Size*/
|
||||
resize();
|
||||
mainResize()
|
||||
mainTablePosition();
|
||||
itemPosition()
|
||||
$('#collapse-menu').on({
|
||||
click: function(){
|
||||
$('body').toggleClass("folded");
|
||||
if($('#collapse-menu > i').attr("class")=="icon-chevron-right"){
|
||||
$('#collapse-menu > i').removeClass('icon-chevron-right');
|
||||
$('#collapse-menu > i').addClass('icon-chevron-left');
|
||||
} else if($('#collapse-menu > i').attr("class")=="icon-chevron-left"){
|
||||
$('#collapse-menu > i').removeClass('icon-chevron-left');
|
||||
$('#collapse-menu > i').addClass('icon-chevron-right');
|
||||
}
|
||||
resize();
|
||||
mainResize();
|
||||
mainTablePosition();
|
||||
itemPosition()
|
||||
}
|
||||
})
|
||||
|
||||
$('.with_action').on({
|
||||
mouseleave: function(){
|
||||
$('.quick-edit').find('.dropdown').removeClass("open");
|
||||
}
|
||||
})
|
||||
|
||||
$(window).resize(function(){
|
||||
resize();
|
||||
mainResize();
|
||||
mainTablePosition();
|
||||
itemPosition()
|
||||
});
|
||||
|
||||
});
|
||||
/*main-table position*/
|
||||
function mainTablePosition() {
|
||||
var $height = $('#main-wrap .subnav').length && $('#main-wrap .subnav').height();
|
||||
var $table = $('.main-list').length && $('.main-list:last');
|
||||
if($table && $table==0){
|
||||
// $table.css({marginTop:$height});
|
||||
$table.stop().animate({marginTop:$height}, 500)
|
||||
}
|
||||
else if($table){
|
||||
if($height>0){
|
||||
$height = $height-18;
|
||||
}
|
||||
$table.stop().animate({marginTop:$height}, 500, function(){
|
||||
resize();
|
||||
mainResize();
|
||||
});
|
||||
}
|
||||
else if($('#main-wrap .subnav')){
|
||||
var $object = $('#main-wrap .subnav').next();
|
||||
// $object.css({marginTop:$height});
|
||||
$object.stop().animate({marginTop:$height}, 500)
|
||||
};
|
||||
};
|
||||
|
||||
function moduleNav() {
|
||||
var $moduleNav = $('#module-nav'),
|
||||
$userDataW = $('.user-data').width();
|
||||
$moduleNav.css("width", $userDataW);
|
||||
}
|
||||
function itemPosition() {
|
||||
moduleNav();
|
||||
if($('#isotope').length>0 && $('.user-info').length>0){
|
||||
if(viewportwidth<=1200){
|
||||
if($('body').attr("class")=="folded"){
|
||||
$('#isotope').find('.detail').css("width", 550);
|
||||
$('#isotope').masonry({
|
||||
itemSelector: '.item',
|
||||
isAnimated: true
|
||||
});
|
||||
}else{
|
||||
$('#isotope').find('.detail').css("width", 435);
|
||||
$('#isotope').masonry({
|
||||
itemSelector: '.item',
|
||||
isAnimated: true
|
||||
});
|
||||
}
|
||||
}else if(viewportwidth>=1201 && viewportwidth<=1280){
|
||||
if($('body').attr("class")=="folded"){
|
||||
$('#isotope').find('.detail').css("width", 385);
|
||||
$('#isotope').masonry({
|
||||
itemSelector: '.item',
|
||||
isAnimated: true
|
||||
});
|
||||
}else{
|
||||
$('#isotope').find('.detail').css("width", 325);
|
||||
$('#isotope').masonry({
|
||||
itemSelector: '.item',
|
||||
isAnimated: true
|
||||
});
|
||||
}
|
||||
}else if(viewportwidth>=1281 && viewportwidth<=1440){
|
||||
if($('body').attr("class")=="folded"){
|
||||
$('#isotope').find('.detail').css("width", 470);
|
||||
$('#isotope').masonry({
|
||||
itemSelector: '.item',
|
||||
isAnimated: true
|
||||
});
|
||||
}else{
|
||||
$('#isotope').find('.detail').css("width", 410);
|
||||
$('#isotope').masonry({
|
||||
itemSelector: '.item',
|
||||
isAnimated: true
|
||||
});
|
||||
}
|
||||
}else if(viewportwidth>=1441){
|
||||
if($('#isotope').length>0){
|
||||
$('#isotope').find('.detail').css("width", 500);
|
||||
$('#isotope').masonry({
|
||||
itemSelector: '.item',
|
||||
isAnimated: true
|
||||
});
|
||||
}
|
||||
}
|
||||
}else if($('#isotope').length>0){
|
||||
$('#isotope').masonry({
|
||||
itemSelector: '.item',
|
||||
isAnimated: true
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function mainResize() {
|
||||
var $mainWrapMarginLeft = parseInt($('#main-wrap').css("margin-left"))-2,
|
||||
$subWiget = $('#sub-wiget').width()+18;
|
||||
$orbitBar = $('#orbit-bar').height(),
|
||||
$brand = $('#brand').height(),
|
||||
$collapseMenu = $('#collapse-menu').height()+$('#position').height()+1,
|
||||
$mainSidebar = $('#main-sidebar').width()+5,
|
||||
$formActionPadding = parseInt($('.form-fixed').css("padding-left"))+parseInt($('.form-fixed').css("padding-right")),
|
||||
$scrollContent = $('#main-sidebar .nav-list').height();
|
||||
$('#main-sidebar').css("height", viewportheight-$orbitBar);
|
||||
$('#main-sidebar .viewport').css("height", viewportheight-$orbitBar-$collapseMenu);
|
||||
$('.user-roles .viewport').css("height", viewportheight-$orbitBar-$brand-30);
|
||||
$('#main-sidebar .viewport').css("top", $collapseMenu);
|
||||
$('#main-sidebar .scrollbar').css("top", $collapseMenu);
|
||||
$('#post-body').css("width", viewportwidth-$mainWrapMarginLeft-$subWiget);
|
||||
$('.post-title').css("width", viewportwidth-$mainWrapMarginLeft-$subWiget-20);
|
||||
$('#main-wrap .subnav').css("width", viewportwidth-$mainWrapMarginLeft);
|
||||
$('#main-wrap .table-label').css("width", viewportwidth-$mainWrapMarginLeft);
|
||||
$('.form-fixed').css("width", viewportwidth-$mainWrapMarginLeft-$formActionPadding);
|
||||
$('.user-info').css("height", viewportheight-$orbitBar-30);
|
||||
$('#main-sidebar').tinyscrollbar();
|
||||
$('.detal-list').tinyscrollbar();
|
||||
$('.user-roles').tinyscrollbar();
|
||||
if((viewportheight-$orbitBar-$collapseMenu)>=$scrollContent){
|
||||
$('#main-sidebar .overview').css("top", '0px');
|
||||
}
|
||||
};
|
||||
$(window).scroll(function () {
|
||||
//var $mainWrapMarginLeft = parseInt($('#main-wrap').css("margin-left"))-1;
|
||||
//var $subnavWidth = parseInt($('#main-wrap > .subnav').css("width"));
|
||||
var $winLeft = $(window).scrollLeft()
|
||||
$(".table-label").css({left:$winLeft*-1} );
|
||||
//$(".table-label").css({left:$mainWrapMarginLeft+($winLeft*-1)} );
|
||||
//$("#main-wrap > .subnav").css({width:$subnavWidth+($winLeft)} );
|
||||
});
|
||||
@@ -0,0 +1,115 @@
|
||||
var viewportwidth,
|
||||
viewportheight;
|
||||
function resize() {
|
||||
viewportheight=$(window).height();
|
||||
viewportwidth=$(window).width();
|
||||
if(window.navigator.userAgent.indexOf("MSIE")>0){
|
||||
windH=document.clientHeight;
|
||||
windW=document.clientWidht;
|
||||
}
|
||||
}
|
||||
$(document).ready(function(){
|
||||
|
||||
$('.tip').tooltip({
|
||||
placement: "left"
|
||||
});
|
||||
|
||||
|
||||
$(document).on('click', '.privacy', function() {
|
||||
|
||||
switch ($(this).val()) {
|
||||
case 'true':
|
||||
$(this).parents('.controls').children('.select-role').slideUp(300);
|
||||
break;
|
||||
case 'false':
|
||||
$(this).parents('.controls').children('.select-role').slideDown(300);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
var $role = $('.select-role');
|
||||
var method =$('.privacy:eq(1)').attr('checked');
|
||||
if(method == 'checked'){
|
||||
$role.slideDown(0);
|
||||
}
|
||||
$('.privacy').each(function($i) {
|
||||
$(this).click(function() {
|
||||
switch ($i) {
|
||||
case 0:
|
||||
$role.slideUp(300);
|
||||
break;
|
||||
case 1:
|
||||
$role.slideDown(300);
|
||||
break;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/*tinyscrollbar&windows-Size*/
|
||||
resize();
|
||||
var $mainWrapMarginLeft = parseInt($('#main-wrap').css("margin-left"))-2,
|
||||
$subWiget = $('#sub-wiget').width()+18;
|
||||
$orbitBar = $('#orbit-bar').height(),
|
||||
$mainSidebar = $('#main-sidebar').width()+5,
|
||||
$formActionPadding = parseInt($('.form-fixed').css("padding-left"))+parseInt($('.form-fixed').css("padding-right"));
|
||||
$('#main-sidebar').css("height", viewportheight-$orbitBar);
|
||||
$('#main-sidebar .viewport').css("height", viewportheight-$orbitBar);
|
||||
$('#post-body').css("width", viewportwidth-$mainWrapMarginLeft-$subWiget);
|
||||
$('.post-title').css("width", viewportwidth-$mainWrapMarginLeft-$subWiget-16);
|
||||
$('#main-wrap .subnav').css("width", viewportwidth-$mainWrapMarginLeft);
|
||||
$('.form-fixed').css("width", viewportwidth-$mainWrapMarginLeft-$formActionPadding);
|
||||
$('#main-sidebar').tinyscrollbar({size:(viewportheight-$orbitBar-4)});
|
||||
$('.detal-list').tinyscrollbar();
|
||||
mainTablePosition();
|
||||
|
||||
/*isotope*/
|
||||
var $container = $('#isotope');
|
||||
$container.isotope({
|
||||
itemSelector : '.item',
|
||||
layoutMode : 'masonry',
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
$(window).resize(function(){
|
||||
resize();
|
||||
var $mainWrapMarginLeft = parseInt($('#main-wrap').css("margin-left"))-2,
|
||||
$subWiget = $('#sub-wiget').width()+18;
|
||||
$orbitBar = $('#orbit-bar').height(),
|
||||
$mainSidebar = $('#main-sidebar').width()+5,
|
||||
$formActionPadding = parseInt($('.form-fixed').css("padding-left"))+parseInt($('.form-fixed').css("padding-right"));
|
||||
$('#main-sidebar').css("height", viewportheight-$orbitBar);
|
||||
$('#main-sidebar .viewport').css("height", viewportheight-$orbitBar);
|
||||
$('#post-body').css("width", viewportwidth-$mainWrapMarginLeft-$subWiget);
|
||||
$('.post-title').css("width", viewportwidth-$mainWrapMarginLeft-$subWiget-16);
|
||||
$('#main-wrap .subnav').css("width", viewportwidth-$mainWrapMarginLeft);
|
||||
$('.form-fixed').css("width", viewportwidth-$mainWrapMarginLeft-$formActionPadding);
|
||||
$('#main-sidebar').tinyscrollbar({size:(viewportheight-$orbitBar-4)});
|
||||
mainTablePosition();
|
||||
});
|
||||
/*main-table position*/
|
||||
function mainTablePosition() {
|
||||
var $height = $('#main-wrap .subnav').length && $('#main-wrap .subnav').height();
|
||||
var $table = $('.main-list').length && $('.main-list:last');
|
||||
if($table && $table==0){
|
||||
$table.css({marginTop:$height});
|
||||
}
|
||||
else if($table){
|
||||
if($height>0){
|
||||
$height = $height-17;
|
||||
}
|
||||
$table.stop().animate({marginTop:$height},500);
|
||||
}
|
||||
else if($('#main-wrap .subnav')){
|
||||
var $object = $('#main-wrap .subnav').next();
|
||||
$object.css({marginTop:$height});
|
||||
};
|
||||
};
|
||||
$(window).scroll(function () {
|
||||
//var $mainWrapMarginLeft = parseInt($('#main-wrap').css("margin-left"))-1;
|
||||
//var $subnavWidth = parseInt($('#main-wrap > .subnav').css("width"));
|
||||
var $winLeft = $(window).scrollLeft()
|
||||
$(".table-label").css({left:$winLeft*-1} );
|
||||
//$(".table-label").css({left:$mainWrapMarginLeft+($winLeft*-1)} );
|
||||
//$("#main-wrap > .subnav").css({width:$subnavWidth+($winLeft)} );
|
||||
});
|
||||
@@ -0,0 +1,15 @@
|
||||
$(document).on('click', '.orbit-bar-member', function(){
|
||||
$(this).hasClass('open') ? $(this).removeClass('open') : $(this).addClass('open');
|
||||
$('.bar-login .dropdown-menu').toggle();
|
||||
return false;
|
||||
});
|
||||
|
||||
$(document).click(function() {
|
||||
$('.orbit-bar-member').removeClass("open");
|
||||
$('.bar-login .dropdown-menu').hide();
|
||||
});
|
||||
|
||||
$(document).on('click', '.bar-login .dropdown-menu', function(e) {
|
||||
e.stopPropagation();
|
||||
$('.bar-login .dropdown-menu').show();
|
||||
});
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
$(document).ready(function(){
|
||||
$('.search').tooltip({
|
||||
placement: "bottom"
|
||||
});
|
||||
});
|
||||
$(document).on('mouseenter', '.orbit-bar-search', function (){
|
||||
$(this).parents('.search').stop().animate({
|
||||
'width':'265px',
|
||||
},200);
|
||||
$('.navbar-search').stop().animate({
|
||||
'left':'4px',
|
||||
'opacity':'1'
|
||||
},500);
|
||||
$(this).parents('.search').css({
|
||||
'background-color': 'rgba(0, 0, 0, 0.5)',
|
||||
});
|
||||
$(this).parents('.search').addClass('visible');
|
||||
});
|
||||
|
||||
|
||||
$(document).on('mouseleave', '.search.visible', function (){
|
||||
$(this).stop().animate({
|
||||
'width':'28px',
|
||||
},500);
|
||||
$('.navbar-search').stop().animate({
|
||||
'left':'30px',
|
||||
'opacity':'0',
|
||||
},200);
|
||||
$(this).css({
|
||||
'background-color': 'transparent',
|
||||
});
|
||||
$(this).removeClass('visible');
|
||||
});
|
||||
|
||||
$(document).on("mouseenter",".orbit-bar-language, .language-menu",function(){
|
||||
$(this).parents('.language').addClass("open")
|
||||
})
|
||||
|
||||
$(document).on("mouseleave",".orbit-bar-language, .language-menu",function(){
|
||||
$(this).parents('.language').removeClass("open")
|
||||
})
|
||||
@@ -0,0 +1,243 @@
|
||||
//for timeline parent library, will be accessable by main library and API library for other people to use.. default inherits orbitDesktopAPI
|
||||
// Harry Bomrah
|
||||
|
||||
var orbitTimeline = function(dom){
|
||||
t = this;
|
||||
this.dom = $(dom);
|
||||
this.timelineHtml = $("<div class='t_bottom t_scale' id='timeline_scale'></div>");
|
||||
//this.marker = t.timelineHtml.find("#timline_marker");
|
||||
this.scale = "";
|
||||
//this.container = t.timelineHtml.find("#t_container");
|
||||
this.events = new Array;
|
||||
this.monthList = ["","January","February","March","April","May","June","July","August","September","October","November","December"];
|
||||
this.dt = new Date();
|
||||
this.fromdate = [t.dt.getFullYear(),t.dt.getMonth()+1];
|
||||
this.ajaxload = true;
|
||||
this.halfline = $(window).width()/2 + 200;
|
||||
this.initialize = function(){
|
||||
t.dom.html(t.timelineHtml);
|
||||
$("div.scrollbar").hide();
|
||||
t.constructTimeScale(function(timelineScale){
|
||||
$("#timeline_scale").html(timelineScale);
|
||||
var totalyearwidth =timelineScale.find(".year").length * timelineScale.find(".year").outerWidth();
|
||||
var totalul = 0;
|
||||
$(".t_scale").css({"min-width":$(".tinycanvas .viewport").width()+500 + "px"})
|
||||
for(eve in t.events){
|
||||
t.makeBubble(t.events[eve]);
|
||||
totalul = $("#scale_wrapper ul").length
|
||||
$(".t_scale").width((totalul*350) + totalyearwidth);
|
||||
}
|
||||
t.bubble_fx();
|
||||
var scrollvalue = 0;
|
||||
$('.tinycanvas').tinyscrollbar({
|
||||
axis: 'x',
|
||||
onMove: function(x){
|
||||
if(x > scrollvalue)
|
||||
t.timeScaleForward();
|
||||
// else
|
||||
// t.timeScaleBackward();
|
||||
scrollvalue = x;
|
||||
var limit = $("#timeline_scale").outerWidth() - $(".tinycanvas .scrollbar").outerWidth();
|
||||
if(t.ajaxload){
|
||||
if((limit - x) < 10){
|
||||
t.eventAjaxLoad(function(){
|
||||
var totalul = 0;
|
||||
for(eve in t.events){
|
||||
t.makeBubble(t.events[eve]);
|
||||
totalul = $("#scale_wrapper ul").length
|
||||
$(".t_scale").width((totalul*360) + totalyearwidth + 314);
|
||||
}
|
||||
$('.tinycanvas').tinyscrollbar_update(x);
|
||||
t.bubble_fx();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
this.constructTimeScale = function(callbackFn){
|
||||
var mon ="",year="",formname;
|
||||
var scale = $("<div id='scale_wrapper'></div>");
|
||||
$.getJSON("/desktop_orbit/gettimelinespan",{"get":"papers"},function(years){
|
||||
var $ul = $("<ul></ul>");
|
||||
var startyear = years.startyear, endyear = years.endyear,year = years.startyear;
|
||||
$ul.append('<li><a href="'+startyear+'" class="wh3 hh3 admbg active" onclick="return false;">'+startyear+'</a></li>');
|
||||
while(year > endyear){
|
||||
year--;
|
||||
$ul.append('<li><a href="'+year+'" class="wh3 hh3 admbg" onclick="return false;">'+year+'</a></li>');
|
||||
}
|
||||
$("div#orbit div#year_navigation").html($ul);
|
||||
})
|
||||
$.getJSON("/desktop_orbit/eventajaxload",{"event":"papers","from":t.fromdate},function(papersArray){
|
||||
$.each(papersArray,function(i,pa){
|
||||
$.each(pa.papers,function(i,paper){
|
||||
var dt = new Date(paper.created_at);
|
||||
var cur_mon = paper.created_at.substr(5,2);
|
||||
var cur_year = dt.getFullYear();
|
||||
var cdt = paper.created_at.substr(0,7).replace("-","");
|
||||
formname = (cur_mon.charAt(0) == "0"?cur_mon.charAt(1) : cur_mon)
|
||||
var bubbleData = {"fulldate" : t.monthList[parseInt(formname)] +", " + dt.getDate() + ", " + cur_year,"title":paper.title,"jtitle":"Harry","coauthors":paper.coauthors,"abstract":paper.abstract,"timestamp":cdt}
|
||||
t.events.push(bubbleData);
|
||||
if(cur_year != year){
|
||||
year = cur_year;
|
||||
scale.append($("<div class='group year w1 h1 hp vp thmtxt thmc1' for='"+year+"'>"+year+"</div><div class='region_year group' data-content='"+year+"'></div>"));
|
||||
}
|
||||
if(cur_mon != mon){
|
||||
mon = cur_mon;
|
||||
var yr = scale.find("div[data-content="+year+"]");
|
||||
yr.append($("<div class='group month' data-content='"+cdt+"'><div class='month_heading vp hp'>"+t.monthList[parseInt(formname)]+"</div><div class='bubble_list'></div></div>"))
|
||||
}
|
||||
});
|
||||
});
|
||||
//scale.append($("<div class='group year w1 h1 hp vp thmtxt thmc1'>"+year+"</div><div class='region_year group' data-content='"+(year-1)+"'></div>"));
|
||||
t.fromdate = [year,formname-1];
|
||||
if(typeof callbackFn == "function"){
|
||||
callbackFn.call(this,scale);
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
this.makeBubble = function(bubbleData){
|
||||
var totalul = $("#scale_wrapper").find("div[data-content="+bubbleData.timestamp+"] ul").length;
|
||||
var targetul = $("#scale_wrapper div[data-content="+bubbleData.timestamp+"] div.bubble_list ul").eq(totalul-1);
|
||||
if(totalul == 0){
|
||||
var ul = $("<ul></ul>");
|
||||
$("#scale_wrapper").find("div[data-content="+bubbleData.timestamp+"] div.bubble_list").append(ul);
|
||||
targetul = ul;
|
||||
}else{
|
||||
var totalli = targetul.find("li").length;
|
||||
if(totalli >= 5){
|
||||
var ul = $("<ul></ul>");
|
||||
$("#scale_wrapper").find("div[data-content="+bubbleData.timestamp+"] div.bubble_list").append(ul);
|
||||
targetul = ul;
|
||||
}
|
||||
}
|
||||
var bt = (bubbleData.title.length > 70? bubbleData.title.substr(0,70) + "..." : bubbleData.title);
|
||||
var bubble = $("<li class='bubble hh3 admbg vp hp'>"+bt+"<span class='date'>"+bubbleData.fulldate+"</span></li>");
|
||||
targetul.prepend(bubble);
|
||||
bubble.show();
|
||||
bubble.click(function(){
|
||||
var thisbubble = $(this);
|
||||
$(this).parents(dom)
|
||||
.find('.bubble, .date')
|
||||
.removeClass('thmc1 thmtxt');
|
||||
|
||||
o.toolPopup({
|
||||
parent: $(this).parent(),
|
||||
html : "<div class='bubble_content'><h2>"+bubbleData.jtitle+"</h2><h3>Co-Authors</h3><span class='context'>"+bubbleData.coauthors+"</span><h3>Abstract</h3><span class='context'>"+bubbleData.abstract+"</span></div>",
|
||||
height: "392px",
|
||||
width:"310px",
|
||||
beforeClose : function(){
|
||||
$("div.bubble_arrow").remove();
|
||||
thisbubble.parents(dom)
|
||||
.find('.bubble, .date')
|
||||
.removeClass('thmc1 thmtxt');
|
||||
},
|
||||
onOpen : function(){
|
||||
thisbubble.append('<div class="bubble_arrow"/>');
|
||||
},
|
||||
beforeOpen : function(){
|
||||
thisbubble.addClass('thmc1 thmtxt');
|
||||
thisbubble.find('.date').addClass('thmtxt');
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
this.eventAjaxLoad = function(callbackFn){
|
||||
t.events = [];
|
||||
var mon ="",year="",formname;
|
||||
var scale = $("#scale_wrapper");
|
||||
|
||||
t.ajaxload = false;
|
||||
$.getJSON("/desktop_orbit/eventajaxload",{"from":t.fromdate},function(papersArray){
|
||||
$.each(papersArray,function(i,pa){
|
||||
$.each(pa.papers,function(i,paper){
|
||||
var dt = new Date(paper.created_at);
|
||||
var cur_mon = paper.created_at.substr(5,2);
|
||||
var cur_year = dt.getFullYear();
|
||||
var cdt = paper.created_at.substr(0,7).replace("-","");
|
||||
formname = (cur_mon.charAt(0) == "0"?cur_mon.charAt(1) : cur_mon)
|
||||
var bubbleData = {"fulldate" : t.monthList[parseInt(formname)] +", " + dt.getDate() + ", " + cur_year,"title":paper.title,"jtitle":"Harry","coauthors":paper.coauthors,"abstract":paper.abstract,"timestamp":cdt}
|
||||
t.events.push(bubbleData);
|
||||
if(cur_year != year){
|
||||
year = cur_year;
|
||||
if(scale.find("div[data-content="+year+"]").length == 0){
|
||||
scale.append($("<div class='group year w1 h1 hp vp thmtxt thmc1' for='"+year+"'>"+year+"</div><div class='region_year group' data-content='"+year+"'></div>"));
|
||||
}
|
||||
}
|
||||
if(cur_mon != mon){
|
||||
mon = cur_mon;
|
||||
var yr = scale.find("div[data-content="+year+"]");
|
||||
yr.append($("<div class='group month' data-content='"+cdt+"'><div class='month_heading vp hp'>"+t.monthList[parseInt(formname)]+"</div><div class='bubble_list'></div></div>"))
|
||||
}
|
||||
});
|
||||
});
|
||||
if(papersArray.length != 0){
|
||||
// if(scale.find("div[data-content="+(year-1)+"]").length == 0)
|
||||
// scale.append($("<div class='group year w1 h1 hp vp thmtxt thmc1'>"+year+"</div><div class='region_year group' data-content='"+(year-1)+"'></div>"));
|
||||
t.ajaxload = true;
|
||||
t.fromdate = [year,formname-1];
|
||||
}
|
||||
if(typeof callbackFn == "function"){
|
||||
callbackFn.call(this,scale);
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
this.bubble_fx = function(){
|
||||
$('.bubble').on({
|
||||
mouseover: function(){
|
||||
$(this)
|
||||
.addClass('hover')
|
||||
.append('<span class="icon-chevron-right" />');
|
||||
},
|
||||
mouseout: function(){
|
||||
$(this)
|
||||
.removeClass('hover')
|
||||
.find('.icon-chevron-right').remove();
|
||||
},
|
||||
});
|
||||
}
|
||||
this.timeScaleForward = function(){
|
||||
|
||||
// var lastregion = regions.eq(regions.length-1);
|
||||
// if(lastregion.offset().left < halfline){
|
||||
// var year = lastregion.attr("data-content");
|
||||
// $("div#orbit div#year_navigation ul a").removeClass("active");
|
||||
// $("div#orbit div#year_navigation ul a[href="+year+"]").addClass("active");
|
||||
// }
|
||||
var regions = $("div.region_year");
|
||||
regions.each(function(){
|
||||
var offset = $(this).offset().left;
|
||||
if(offset < t.halfline){
|
||||
if(offset > 156){
|
||||
var year = $(this).attr("data-content");
|
||||
$("div#orbit div#year_navigation ul a").removeClass("active");
|
||||
$("div#orbit div#year_navigation ul a[href="+year+"]").addClass("active");
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
this.timeScaleBackward = function(){
|
||||
var regions = $("div.region_year");
|
||||
regions.each(function(){
|
||||
var offset = $(this).offset().left * -1
|
||||
if(offset > t.halfline){
|
||||
if(offset > 156){
|
||||
var year = $(this).attr("data-content");
|
||||
$("div#orbit div#year_navigation ul a").removeClass("active");
|
||||
$("div#orbit div#year_navigation ul a[href="+year+"]").addClass("active");
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
this.ajaxEventPull = function(){
|
||||
if(!t.update){
|
||||
t.update = true;
|
||||
$.getJSON("/desktop_orbit/ajaxeventpull",{"from":t.fromdate},function(){
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
$(document).ready(function() {
|
||||
$('body').prepend("<div id='orbit_bar_temp'/>");
|
||||
$("#orbit_bar_temp").load('/load_orbit_bar',function(){
|
||||
$('body').prepend($(this).html());
|
||||
$(this).remove();
|
||||
});
|
||||
});
|
||||
+1600
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,211 @@
|
||||
// JavaScript Document
|
||||
//Harry Bomrah
|
||||
var orbitDesktopAPI = function(){
|
||||
o = this;
|
||||
this.windowcounter = 0;
|
||||
this.notify = function(msg,type,time){
|
||||
//takes 3 arguments
|
||||
//msg (string) : message to display
|
||||
//type (string : success, imp, alert
|
||||
//time (int) : duration for notification in seconds
|
||||
var $notify = $("#orbitnote");
|
||||
var img, n_height;
|
||||
if(!type)type="";
|
||||
switch(type){
|
||||
case "alert":
|
||||
img = "note_alert.png";
|
||||
break;
|
||||
case "imp":
|
||||
img = "note_imp.png";
|
||||
break;
|
||||
case "success":
|
||||
img = "note_success.png";
|
||||
break;
|
||||
default:
|
||||
img = "note_alert.png";
|
||||
break;
|
||||
}
|
||||
$notify.find("img#note_img").attr("src",o.notifyImgPath+img);
|
||||
$notify.find(".note_message").html(msg);
|
||||
n_height = $notify.outerHeight();
|
||||
if(!time)time=5000; else time=time*1000;
|
||||
$notify
|
||||
.css({'top':-n_height, 'display':'block', 'opacity':0})
|
||||
.animate({top:0,opacity:1},200)
|
||||
.delay(time)
|
||||
.animate({top:-n_height,opacity:0},200);
|
||||
};
|
||||
this.executeFunc = function(func,callbackFn){
|
||||
//takes 2 arguments
|
||||
//func (object Function) : the function which has to be executed
|
||||
//callbackFn (object function) : the function for callback
|
||||
func.call(this);
|
||||
if(callbackFn){
|
||||
callbackFn.call(this,func);
|
||||
}
|
||||
};
|
||||
this.sortJSON = function(field, reverse, primer){
|
||||
//takes 3 arguments
|
||||
//field (string): it is the field on which sorting has to be done
|
||||
//reverse (boolean): this is for asc or desc
|
||||
//primer (method): for example pass parseInt for converting the field attribute in integer
|
||||
var key = function (x) {return primer ? primer(x[field]) : x[field]};
|
||||
return function (a,b) {
|
||||
var A = key(a), B = key(b);
|
||||
return ((A < B) ? -1 : (A > B) ? +1 : 0) * [-1,1][+!!reverse];
|
||||
}
|
||||
};
|
||||
this.rgb2hex = function(rgb) {
|
||||
// takes 1 parameter
|
||||
// rgb (string) : pass rgb string to convert
|
||||
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
|
||||
var hex = function(x) {
|
||||
return ("0" + parseInt(x).toString(16)).slice(-2);
|
||||
}
|
||||
return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
|
||||
};
|
||||
this.changeWallpaper = function(wallpaper){
|
||||
//takes 1 parameter
|
||||
//wallpaper (string): takes wallpaper and sets the wallpaper
|
||||
$("img#thmbackground").attr("src",o.wallpaperPath+wallpaper);
|
||||
o.saveWallpaper(wallpaper);
|
||||
};
|
||||
this.confirm = function(settings,callbackfn){
|
||||
//takes set of arguments in array
|
||||
//settings.buttons (array string) : name of buttons to be displayed
|
||||
//settings.highlighted (integer) : takes either 1 or 2.. will highlight the button which is passed
|
||||
//settings.message (string) : takes a string and message to be displayed on the confirmbox
|
||||
//callbackfn (object function) : function to callback
|
||||
|
||||
if(!settings.buttons)settings.buttons=["Ok","Cancel"];
|
||||
if(settings.highlighted!=1 && settings.highlighted!=2)settings.highlighted=2;
|
||||
if(!settings.message)settings.message = "Are you sure?"
|
||||
var $confirm = $("#orbitdiag");
|
||||
$confirm.find(".diag_action a").removeClass("thmc1 thmtxt").addClass("admbg admtxt");
|
||||
$confirm.find(".diag_message").text(settings.message);
|
||||
if(settings.highlighted == 1)
|
||||
$confirm.find("#diag_confirm").removeClass("admbg admtxt").addClass("thmc1 thmtxt");
|
||||
if(settings.highlighted == 2)
|
||||
$confirm.find("#diag_cancel").removeClass("admbg admtxt").addClass("thmc1 thmtxt");
|
||||
$confirm.find("#diag_confirm").text(settings.buttons[0]).one("click",function(){
|
||||
$confirm.stop(1,1).fadeOut();
|
||||
$confirm.find(".diag_action a").unbind();
|
||||
if(typeof callbackfn=="function")
|
||||
callbackfn.call(this,true);
|
||||
});
|
||||
$confirm.find("#diag_cancel").text(settings.buttons[1]).one("click",function(){
|
||||
$confirm.stop(1,1).fadeOut();
|
||||
$confirm.find(".diag_action a").unbind();
|
||||
if(typeof callbackfn=="function")
|
||||
callbackfn.call(this,false);
|
||||
});
|
||||
$confirm.stop(1,1).fadeIn();
|
||||
};
|
||||
this.getArrayfromJson = function(tjson,key){
|
||||
// returns array and takes json object and key
|
||||
//json (json object) : json object from which the key has to be extracted
|
||||
// key (string) : key which has to be extracted
|
||||
var tempArray = new Array;
|
||||
$.each(tjson,function(i,val){
|
||||
tempArray.push(val[key]);
|
||||
})
|
||||
return tempArray;
|
||||
};
|
||||
this.appWindow = function(settings,callbackfn){
|
||||
//takes set of arguments as array and gives callback
|
||||
//settings.method (string) : like open and close
|
||||
//settings.title (string) : the window title
|
||||
//settings.extUrl (boolean) : true for opening external url else false
|
||||
//settings.appid (string) : appid.. user can use this appid to open or close or refresh the window
|
||||
//settings.url (string) : it is the url if you want to force external url to open in appwindow... you have to pass extURL in appid if you want to open externalurl
|
||||
if(typeof settings == "undefined")settings = {};
|
||||
if(!settings.appid){
|
||||
o.notify("Invalid AppID.","imp",3);
|
||||
return;
|
||||
}
|
||||
if(!settings.method)settings.method = "open";
|
||||
if(!settings.extUrl)settings.extUrl = true;
|
||||
if(settings.method == 'open'){
|
||||
var appurl = "http://www.rulingcom.com";
|
||||
o.windowcounter++;
|
||||
if(!settings.title)settings.title = "New Window "+o.windowcounter;
|
||||
if(settings.extUrl){
|
||||
if(settings.url){
|
||||
|
||||
if(settings.url.substr(0,4)!="http")settings.url = "http://"+settings.url;
|
||||
console.log(settings.url)
|
||||
var urlregex = new RegExp("^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([0-9A-Za-z]+\.)");
|
||||
if(urlregex.test(settings.url))
|
||||
appurl = settings.url;
|
||||
else{
|
||||
o.notify("Invalid URL","alert",3);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else{
|
||||
o.notify("Invalid URL","alert",3);
|
||||
return;
|
||||
}
|
||||
}
|
||||
var whtml =$('<div id="app_frame_'+o.windowcounter+'" class="thmc2 app_frame" data-app="'+settings.appid+'"><div id="content"><div id="header" class="hh3"><div class="dtitle hh3 hp" style="text-transform:capitalize;"><span class="thmtxth">'+settings.title+'</span></div><span class="icon-remove hh3 hp thmtxt"></span></div><div id="holder_'+o.windowcounter+'" class="app_holder"><iframe src="'+appurl+'" frameborder="0" scrolling="auto"></iframe><div class="clear"></div></div></div></div>');
|
||||
$(o.contentHolder).append(whtml);
|
||||
var parentwindow = $(o.contentHolder).find("div#app_frame_"+o.windowcounter);
|
||||
var app_holder_height = parentwindow.height() - 72;
|
||||
var app_holder_width = parentwindow.width();
|
||||
parentwindow.find("iframe").attr({"height":app_holder_height,"width":app_holder_width});
|
||||
parentwindow.find("div.app_holder").height(app_holder_height);
|
||||
parentwindow.find("span.icon-remove").click(function(){
|
||||
parentwindow.remove();
|
||||
})
|
||||
}
|
||||
if(typeof callbackfn=="function"){
|
||||
callbackfn.call(this);
|
||||
}
|
||||
};
|
||||
this.toolPopup = function(settings){
|
||||
if(settings == "destroy"){
|
||||
$(".desktop_toolpopup").hide("fold",function(){
|
||||
$(this).remove();
|
||||
$(this).parent().css("position","");
|
||||
})
|
||||
return;
|
||||
}
|
||||
if(settings.parent){
|
||||
if(settings.parent.find("div.desktop_toolpopup").length == 0){
|
||||
settings.height = (!settings.height ? "50px" : settings.height);
|
||||
settings.width = (!settings.width ? "150px" : settings.width);
|
||||
settings.html = (!settings.html ? "" : settings.html);
|
||||
|
||||
//Events
|
||||
settings.onClose = (!settings.onClose ? function(){} : settings.onClose);
|
||||
settings.beforeOpen = (!settings.beforeOpen ? function(){} : settings.beforeOpen);
|
||||
settings.onOpen = (!settings.onOpen ? function(){} : settings.onOpen);
|
||||
settings.beforeClose = (!settings.beforeClose ? function(){} : settings.beforeClose);
|
||||
//Events end
|
||||
|
||||
var leftpos = settings.parent.outerWidth();
|
||||
var toolpopup = $("<div class='desktop_toolpopup' style='height:"+settings.height+";width:"+settings.width+"; left:"+leftpos+"px;'>"+settings.html+"</div>");
|
||||
settings.parent.css("position","relative");
|
||||
settings.parent.prepend(toolpopup);
|
||||
toolpopup.click(function(event){
|
||||
event.stopPropagation();
|
||||
});
|
||||
settings.beforeOpen.call(this);
|
||||
toolpopup.show("fold",function(){
|
||||
settings.onOpen.call(this);
|
||||
$(document).unbind("click");
|
||||
$(document).one("click",function(e){
|
||||
settings.beforeClose.call(this);
|
||||
toolpopup.hide("fold",function(){
|
||||
toolpopup.remove();
|
||||
settings.parent.css("position","");
|
||||
settings.onClose.call(this);
|
||||
});
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
orbitDesktopAPI.prototype.notifyImgPath = "temp";
|
||||
orbitDesktopAPI.prototype.wallpaperPath = "temp";
|
||||
@@ -0,0 +1,28 @@
|
||||
$(document).ready(function(){
|
||||
bindTreeDragHandle();
|
||||
});
|
||||
|
||||
var bindTreeDragHandle = function(){
|
||||
$('ol.sortable').nestedSortable({
|
||||
disableNesting: 'no-nest',
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'i',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
maxLevels: 3,
|
||||
opacity: .5,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 25,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
|
||||
stop: function(event, ui) {
|
||||
$.post("<%= Rails.application.routes.url_helpers.admin_update_position_path %>", { id: ui.item.attr('id'), parent_id: ui.item.parent().closest('li').attr('id'), position: ui.item.index() } );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$("div.editable").live("mouseenter mouseleave", function (event) {
|
||||
$(this).children('.edit_link').toggle();
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
$(function (){
|
||||
$(".engine_loading").load($(this).attr("widget_path"));
|
||||
});
|
||||
@@ -0,0 +1,120 @@
|
||||
$(document).ready(function(){
|
||||
dropmenu();
|
||||
tab();
|
||||
tooltip();
|
||||
accordion();
|
||||
});
|
||||
|
||||
function dropmenu(){
|
||||
if( !$('.rc_dm').length ){
|
||||
return;
|
||||
}
|
||||
$('.rc_dm').each(function(){
|
||||
$(this)
|
||||
.find('.dm_ctrl')
|
||||
.click(function(){
|
||||
var target = $(this).attr('rel');
|
||||
var w = $(this).outerWidth();
|
||||
var h = $(this).outerHeight();
|
||||
var p = $(this).position();
|
||||
|
||||
$('.dm_list').not('#'+target).hide();
|
||||
$('#'+target)
|
||||
.css({
|
||||
width: w,
|
||||
zIndex: 999,
|
||||
left: p.left,
|
||||
top: p.top + h
|
||||
})
|
||||
.toggle();
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
$(document).click(function(){
|
||||
$('.dm_list').hide();
|
||||
});
|
||||
}
|
||||
|
||||
function tab(){
|
||||
if( !$('.rc_tab').length ){
|
||||
return;
|
||||
}
|
||||
$('.rc_tab').each(function(){
|
||||
$(this).find('.tab_ctrl:first').addClass('recent');
|
||||
$(this).find('.tab_content:not(:first)').hide();
|
||||
$(this).find('.tab_ctrl').click(function(){
|
||||
var target = $(this).attr('href');
|
||||
$(this)
|
||||
.parents('.rc_tab')
|
||||
.find('.tab_content').hide()
|
||||
.end()
|
||||
.find('.tab_ctrl').removeClass('recent');
|
||||
$(this).addClass('recent');
|
||||
$(target).show();
|
||||
return false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function tooltip(){
|
||||
if( !$('.rc_tip').length ){
|
||||
return;
|
||||
}
|
||||
$('.rc_tip').each(function(){
|
||||
$(this).css({position: 'relative'});
|
||||
var t = $(this).data('tip');
|
||||
|
||||
$(this)
|
||||
.mouseover(function(){
|
||||
var th = $(this).find('.td').outerHeight();
|
||||
var p = $(this).offset();
|
||||
|
||||
$(this).append('<span class="td">'+t+'</span>');
|
||||
$(this).find('.td').show().css('display','inline-block');
|
||||
$(document).mousemove(function(e){
|
||||
$(this).find('.td').css({
|
||||
left: e.pageX - p.left + 16,
|
||||
top: e.pageY - p.top - th - 20
|
||||
});
|
||||
});
|
||||
})
|
||||
.mouseout(function(){
|
||||
$(this).find('.td').hide().detach();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function accordion(){
|
||||
if( !$('.rc_accor').length ){
|
||||
return;
|
||||
}
|
||||
$('.rc_accor').each(function(){
|
||||
$(this).find('.ac_ctrl:first').addClass('recent');
|
||||
$(this).find('.ac_content:not(:first)').hide();
|
||||
if($(this).hasClass('av')){
|
||||
$(this).find('.ac_ctrl').click(function(){
|
||||
var index = $(this).parents('.av').find('.ac_ctrl').index(this);
|
||||
$(this).siblings('.ac_ctrl').removeClass('recent');
|
||||
$(this).addClass('recent');
|
||||
$(this).parents('.rc_accor').find('.ac_content:not(:eq('+index+'))').stop().slideUp();
|
||||
$(this).parents('.rc_accor').find('.ac_content:eq('+index+')').stop().slideToggle();
|
||||
return false;
|
||||
});
|
||||
} else if($(this).hasClass('ah')){
|
||||
var w = $(this).find('.ac_content').css('width');
|
||||
$(this).find('.ac_content:not(:eq(0))').css({width:0});
|
||||
$(this).find('.ac_ctrl').click(function(){
|
||||
var index = $(this).parents('.ah').find('.ac_ctrl').index(this);
|
||||
$(this).siblings('.ac_ctrl').removeClass('recent');
|
||||
$(this).addClass('recent');
|
||||
$(this).parents('.rc_accor').find('.ac_content:not(:eq('+index+'))').stop().animate({width:0});
|
||||
$(this).parents('.rc_accor').find('.ac_content:eq('+index+')').stop().show().animate({width:w});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,586 @@
|
||||
//Created by Harry Bomrah on Sep 21 2011
|
||||
$rss = jQuery.noConflict();
|
||||
var rcom={
|
||||
//Pass dom and will return binded dom with starting year till current
|
||||
insertDatePanel : function(dom,year){
|
||||
if(!year)year=1901;
|
||||
if(dom=="")return false;
|
||||
domid=dom.attr("id");
|
||||
var dt = new Date();
|
||||
current_year=dt.getFullYear();
|
||||
var dthtml="Year: <select name='"+domid+"_year'>";
|
||||
for(i=current_year;i>=year;i--){
|
||||
dthtml+="<option value='"+i+"'>"+i+"</option>";
|
||||
}
|
||||
dthtml+="</select> Date: <select name='"+domid+"_date'>";
|
||||
for(i=1;i<=31;i++){
|
||||
if(i<10)
|
||||
dthtml+="<option value='0"+i+"'>"+i+"</option>";
|
||||
else
|
||||
dthtml+="<option value='"+i+"'>"+i+"</option>";
|
||||
}
|
||||
dthtml+="</select> Month: <select name='"+domid+"_month'>";
|
||||
var months= Array("","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
|
||||
for(i=1;i<12;i++){
|
||||
if(i<10)
|
||||
dthtml+="<option value='0"+i+"'>"+months[i]+"</option>";
|
||||
else
|
||||
dthtml+="<option value='"+i+"'>"+months[i]+"</option>";
|
||||
}
|
||||
dthtml+="</select>";
|
||||
dom.html(dthtml);
|
||||
},
|
||||
|
||||
//loading overlay around a dom...
|
||||
loadingWrapper : function(dom, display){
|
||||
if(display){
|
||||
dom.prepend("<div id='loading_wrapper' class='loading'></div>");
|
||||
$rss("#loading_wrapper").height(dom.height());
|
||||
$rss("#loading_wrapper").width(dom.width());
|
||||
}else{
|
||||
domId=dom.attr("id");
|
||||
$rss("#"+domId+" #loading_wrapper").remove();
|
||||
}
|
||||
},
|
||||
|
||||
//validating a dom....
|
||||
validate : function(dom, validation, errormsg){
|
||||
var domValue = dom.val();
|
||||
var error = false;
|
||||
var regex="";
|
||||
var msg = "";
|
||||
switch(validation){
|
||||
case "required":
|
||||
if(domValue=="")error=true;
|
||||
msg="Cannot be empty.";
|
||||
break;
|
||||
case "email":
|
||||
regex=/^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
|
||||
msg="Invalid Email Address.";
|
||||
break;
|
||||
case "number":
|
||||
regex=/^\d*[0-9](|.\d*[0-9]|,\d*[0-9])?$/;
|
||||
msg = "Only numbers are accepted.";
|
||||
break;
|
||||
case "alphanumeric":
|
||||
regex=/^\s*[a-zA-Z0-9,\s]+\s*$/;
|
||||
msg="Only numbers, alphabets and spaces are allowed.";
|
||||
break;
|
||||
}
|
||||
domId=dom.attr("name");
|
||||
if(errormsg=="")errormsg=msg;
|
||||
if(regex!="")if(!regex.test(domValue))error=true;
|
||||
if(error){$rss("#"+domId+"_error").remove();dom.after("<span id='"+domId+"_error' class='error'>"+errormsg+"</span>");return false;} else{ $rss("#"+domId+"_error").remove();return true;}
|
||||
},
|
||||
|
||||
bindToSpinner : function(dom,data,callbackFn){
|
||||
var domId = dom.attr("id");
|
||||
var dhtml="";
|
||||
var spinnerValue=Array();
|
||||
var spinnerDisplay=Array();
|
||||
$rss.each(data,function(i,it){
|
||||
$rss.each(data[i],function(key,it){
|
||||
spinnerValue.push(it);
|
||||
});
|
||||
});
|
||||
dhtml="<select name='"+domId+"'>";
|
||||
for(i=0,y=1,z=0;i<spinnerValue.length/2;i++,y+=2,z+=2){
|
||||
dhtml+="<option value='"+spinnerValue[z]+"'>"+spinnerValue[y]+"</option>";
|
||||
}
|
||||
dhtml+="</select>";
|
||||
dom.html(dhtml);
|
||||
if(typeof callbackFn=="function")
|
||||
callbackFn.call(this, dhtml);
|
||||
},
|
||||
|
||||
//binds the recieved json to a table
|
||||
bindToTable : function(dom,data,headers,actions,css_class,callbackFn){
|
||||
if(!css_class)css_class="";
|
||||
var dhtml="<table width='100%' cellpadding='5' cellspacing='5' class='"+css_class+"' ><thead><tr>";
|
||||
var domId = dom.attr("id");
|
||||
if(actions){
|
||||
var btnTitles=Array();
|
||||
var btnFunctions=Array();
|
||||
$rss.each(actions,function(title,func){
|
||||
btnTitles.push(title);
|
||||
btnFunctions.push(func);
|
||||
});
|
||||
rcom.translate(btnTitles,function(convertedData){
|
||||
btnTitles=convertedData.slice();
|
||||
|
||||
rcom.translate(headers,function(convertedData){
|
||||
headers=convertedData;
|
||||
if(!data)return;
|
||||
$rss.each(headers,function(i,head){
|
||||
dhtml+="<th>"+head+"</th>";
|
||||
});
|
||||
dhtml+="</thead></tr>";
|
||||
if(data.length==0)dhtml+="<tr><td colspan='"+headers.length+"' align='center'>No Data</td></tr>";
|
||||
$rss.each(data,function(i,item){
|
||||
var cl="";
|
||||
if(i%2!=0)cl="even";
|
||||
dhtml+="<tr id='"+domId+"_"+item.id+"' class='"+cl+"'>";
|
||||
$rss.each(item,function(i,it){
|
||||
if(i!="id"){
|
||||
if(it==null)it="Not Set";
|
||||
dhtml+="<td align='center'>"+it+"</td>";
|
||||
}
|
||||
})
|
||||
dhtml+="<td align='center'>";
|
||||
for(x=0;x<btnTitles.length;x++){
|
||||
dhtml+="<button onclick='"+btnFunctions[x]+"("+item.id+")'>"+btnTitles[x]+"</button>";
|
||||
}
|
||||
dhtml+="</td>";
|
||||
dhtml+="</tr>";
|
||||
});
|
||||
dhtml+="</table>";
|
||||
dom.html(dhtml);
|
||||
});
|
||||
});
|
||||
}else{
|
||||
rcom.translate(headers,function(convertedData){
|
||||
headers=convertedData;
|
||||
if(!data)return;
|
||||
if(headers.length>0){
|
||||
$rss.each(headers,function(i,head){
|
||||
dhtml+="<th>"+head+"</th>";
|
||||
});
|
||||
}
|
||||
dhtml+="</thead></tr>";
|
||||
if(data.length==0)dhtml+="<tr><td colspan='"+headers.length+"' align='center'>No Data</td></tr>";
|
||||
|
||||
$rss.each(data,function(i,item){
|
||||
var cl="";
|
||||
if(i%2!=0)cl="even";
|
||||
dhtml+="<tr id='"+domId+"_"+item.id+"' class='"+cl+"'>";
|
||||
$rss.each(item,function(i,it){
|
||||
if(i!="id"){
|
||||
if(it==null)it="Not Set";
|
||||
dhtml+="<td align='center'>"+it+"</td>";
|
||||
}
|
||||
})
|
||||
dhtml+="</tr>";
|
||||
});
|
||||
dhtml+="</table>";
|
||||
dom.html(dhtml);
|
||||
});
|
||||
}
|
||||
|
||||
if(typeof callbackFn=="function")
|
||||
callbackFn.call(this, dhtml);
|
||||
},
|
||||
//convert to date string which can be directly inserted in database or according to any format.
|
||||
convertToInsertableDate : function(y,m,d,format){
|
||||
var dt="";
|
||||
if(m<10)m="0"+m;
|
||||
if(d<10)d="0"+d;
|
||||
switch(format){
|
||||
case "yyyy-mm-dd":
|
||||
dt= y+"-"+m+"-"+d;
|
||||
break;
|
||||
case "dd-mm-yyyy":
|
||||
dt= d+"-"+m+"-"+y;
|
||||
break;
|
||||
case "mm-dd-yyyy":
|
||||
dt= m+"-"+d+"-"+y;
|
||||
break;
|
||||
default:
|
||||
dt= y+"-"+m+"-"+d;
|
||||
break;
|
||||
}
|
||||
return dt;
|
||||
},
|
||||
//a fucntion to show specific divs and hide all other
|
||||
showDoms : function(doms){
|
||||
$rss("body").find("div").each(function(){$rss(this).hide();});
|
||||
$rss.each(doms,function(i,dom){
|
||||
dom.show();
|
||||
});
|
||||
},
|
||||
|
||||
//a function to translate the word or array..
|
||||
translate : function(data,callbackFn){
|
||||
var cdata="";
|
||||
var status =true;
|
||||
if(!data){
|
||||
if(typeof callbackFn=="function")
|
||||
callbackFn.call(this,cdata);
|
||||
status=false;
|
||||
}
|
||||
if(data==""){
|
||||
if(typeof callbackFn=="function")
|
||||
callbackFn.call(this,cdata);
|
||||
status=false;
|
||||
}
|
||||
if(status){
|
||||
$rss.getJSON("../../classes/translate.php", {fn:"translateThis",tData:data},function(convertedData){
|
||||
if(typeof callbackFn=="function")
|
||||
callbackFn.call(this, convertedData);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// a function to bind JSON to list
|
||||
bindToList : function(dom,data,callbackFn){
|
||||
var domId = dom.attr("id");
|
||||
var dhtml="";
|
||||
var listValue=Array();
|
||||
var listDisplay=Array();
|
||||
$rss.each(data,function(i,it){
|
||||
$rss.each(data[i],function(key,it){
|
||||
listValue.push(it);
|
||||
});
|
||||
});
|
||||
dhtml="<ul id='"+domId+"_list'>";
|
||||
for(i=0,y=1,z=0;i<listValue.length/2;i++,y+=2,z+=2){
|
||||
dhtml+="<li id='li_"+listValue[z]+"'>"+listValue[y]+"</li>";
|
||||
}
|
||||
dhtml+="</ul>";
|
||||
dom.html(dhtml);
|
||||
if(typeof callbackFn=="function")
|
||||
callbackFn.call(this,dhtml);
|
||||
},
|
||||
makeDraggable : function(handler,dom){
|
||||
handler.css("position","absolute");
|
||||
dom.css("position","absolute");
|
||||
var puranix=0;
|
||||
var nayeex=0;
|
||||
var puraniy=0;
|
||||
var nayeey=0;
|
||||
var offset="";
|
||||
var zIndex=dom.css("z-index");
|
||||
handler.mousedown(function(e){
|
||||
puranix=e.clientX;
|
||||
puraniy=e.clientY;
|
||||
offset=dom.offset();
|
||||
$rss(this).mousemove(function(e){
|
||||
nayeex=e.clientX-puranix;
|
||||
nayeex+=offset.left;
|
||||
nayeey=e.clientY-puraniy;
|
||||
nayeey+=offset.top;
|
||||
dom.css({"left":nayeex+"px","top":nayeey+"px","z-index":"9999"});
|
||||
})
|
||||
}).mouseup(function(){
|
||||
$rss(this).unbind("mousemove");
|
||||
dom.css("z-index",zIndex);
|
||||
})
|
||||
},
|
||||
|
||||
//automatically scrolls to the bottom of the div
|
||||
scrollToBottom : function(dom){
|
||||
var domId = dom.attr("id");
|
||||
// var domScrollHeight = document.getElementById(domId).scrollHeight;
|
||||
var obj = document.getElementById(domId);
|
||||
|
||||
if((obj.scrollTop+100) >= (obj.scrollHeight - obj.offsetHeight))
|
||||
dom.scrollTop(obj.scrollHeight);
|
||||
},
|
||||
|
||||
/*ajax loading of images... needs following settings
|
||||
dom:in which images ve to be loaded
|
||||
url:the server url for making ajax calls
|
||||
limit:how many images to load
|
||||
divClass:the class of div surrounding each image
|
||||
nameClass:class for span showing name
|
||||
fn:function to be called in on the server
|
||||
imageSrc:the image source of all the images.
|
||||
bindTo:to bind images to a onclick function or else will be binded to normal a tag.
|
||||
urlKey:to specify the key of the value.. if bindTo is used, this will be neglected..
|
||||
returns json;
|
||||
*/
|
||||
loadImages : function(settings,callbackFn){
|
||||
|
||||
var dom = settings.dom;
|
||||
var domid= dom.attr("id");
|
||||
var temp_array=Array();
|
||||
var starting = $rss("#"+domid+" img:last").attr("id");
|
||||
if(typeof starting != 'undefined'){
|
||||
starting = starting.substr(4,starting.length-1);
|
||||
}else{starting = 0};
|
||||
var temp_var="";
|
||||
var json = "";
|
||||
var dhtml="";
|
||||
var extraparam="";
|
||||
if(typeof settings.extraParam != "undefined"){
|
||||
extraparam = settings.extraParam;
|
||||
}
|
||||
$rss.getJSON(settings.url,{fn:settings.fn,id:settings.whereId,limit:settings.limit,start:starting,extra:extraparam},function(images){
|
||||
json = eval(images);
|
||||
$rss.each(images,function(i,pic){
|
||||
var temp_array=Array();
|
||||
var a_var=Array();
|
||||
var name_var="";
|
||||
var title="";
|
||||
$rss.each(pic,function(i,value){
|
||||
temp_array.push(value);
|
||||
})
|
||||
if(temp_array.length>=4){
|
||||
name_var="<span class='"+settings.nameClass+"'>"+temp_array[3]+"</span></div>"
|
||||
}
|
||||
if(temp_array[2]==null)
|
||||
title = "";
|
||||
else
|
||||
title = temp_array[2];
|
||||
if(typeof settings.bindTo!="undefined"){
|
||||
a_var[1]="onclick='"+settings.bindTo+"("+temp_array[0]+");return false;'";
|
||||
a_var[0]="";
|
||||
}else{a_var[0]='?'+settings.urlKey+'='+temp_array[0];a_var[1]="";}
|
||||
dhtml="<div class='"+settings.divClass+"' id='img_holder_"+temp_array[0]+"' ><a href='"+a_var[0]+"' "+a_var[1]+" title='"+title+"'><img id='pic_"+temp_array[0]+"' style='display:none' src='"+settings.imageSrc+temp_array[1]+"' /></a>"+name_var;
|
||||
dom.delay(100).append(dhtml);
|
||||
$rss("#pic_"+pic.id).delay(100).fadeIn(200);
|
||||
|
||||
})
|
||||
if(typeof callbackFn=="function")
|
||||
callbackFn.call(this,json);
|
||||
})
|
||||
|
||||
|
||||
},
|
||||
|
||||
//function to get url variables...
|
||||
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(hash[0]);
|
||||
vars[hash[0]] = hash[1];
|
||||
}
|
||||
if(vars[0] == window.location.href){
|
||||
vars =[];
|
||||
}
|
||||
return vars;
|
||||
},
|
||||
/*function to open a modalwindow on a page.. self reliant no images, no css needed.
|
||||
settings
|
||||
|
||||
width:in percentage or pixcel
|
||||
height:in percentage or pixcel
|
||||
closeBtn:true or false
|
||||
envClose:closing through background click, true or flase
|
||||
loadDiv:load html from a div
|
||||
loadPage:load a page
|
||||
loadHtml: load html
|
||||
|
||||
*/
|
||||
modalWindow : function(settings,callbackFn){
|
||||
|
||||
var envClose = settings.envClose;
|
||||
var dhtml="";
|
||||
if(typeof envClose == "undefined")
|
||||
envClose = true;
|
||||
var closeBtn = settings.closeBtn;
|
||||
if(typeof closeBtn == "undefined")
|
||||
closeBtn = true;
|
||||
|
||||
var rgmaskHeight = $rss(window).height();
|
||||
var rgmaskWidth = $rss(window).width();
|
||||
var tempheight = settings.height;
|
||||
var tempwidth = settings.width;
|
||||
|
||||
var maxheight = (rgmaskHeight*85)/100;
|
||||
var maxwidth = (rgmaskWidth*85)/100;
|
||||
|
||||
if(typeof tempheight!="undefined"){
|
||||
tempheight = tempheight.toString();
|
||||
if(tempheight.charAt(tempheight.length-1)=='%')
|
||||
tempheight=(rgmaskHeight*parseInt(tempheight.substr(0,tempheight.length)))/100;
|
||||
if(tempheight>maxheight)
|
||||
tempheight=maxheight;
|
||||
}else{tempheight="auto";}
|
||||
if(typeof tempwidth!="undefined"){
|
||||
tempwidth = tempwidth.toString();
|
||||
if(tempwidth.charAt(tempwidth.length-1)=='%')
|
||||
tempwidth=(rgmaskWidth*parseInt(tempwidth.substr(0,tempwidth.length)))/100;
|
||||
if(tempwidth>maxwidth)
|
||||
tempwidth=maxwidth;
|
||||
}else{tempwidth="auto";}
|
||||
$rss("body").append('<div class="rgmask" id="rgsheath" style="height:'+rgmaskHeight+'px"></div>');
|
||||
$rss("#rgsheath").css({background: "#000", width: "100%", position: "fixed", top: 0, left: 0,opacity:0.5,'z-index':199});
|
||||
$rss("body").append('<div id="rgWindow"></div>');
|
||||
$rss("#rgWindow").css({"position": "fixed", "z-index": "999", "background": "#fff", "border": "solid 1px #ccc", "padding": "10px", "border-radius": "5px", "-webkit-border-radius": "5px", "-moz-border-radius": "5px", "-ms-border-radius": "5px", "box-shadow": "0 0 20px rgba(0,0,0,0.7)","-webkit-box-shadow": "0 0 20px rgba(0,0,0,0.7)","-moz-box-shadow": "0 0 20px rgba(0,0,0,0.7)","-ms-box-shadow": "0 0 20px rgba(0,0,0,0.7)"});
|
||||
var rgWTop = (rgmaskHeight-20)/2;
|
||||
var rgWLeft = (rgmaskWidth-20)/2;
|
||||
$rss("#rgWindow").css({top:rgWTop+"px", left:rgWLeft+"px"});
|
||||
if(typeof settings.loadDiv!="undefined"){
|
||||
dhtml = $rss(settings.loadDiv).html();
|
||||
$rss("#rgWindow").html(dhtml).hide();
|
||||
prepareWindow();
|
||||
}
|
||||
if(typeof settings.loadHtml!="undefined"){
|
||||
dhtml = settings.loadHtml;
|
||||
$rss("#rgWindow").html(dhtml).hide();
|
||||
prepareWindow();
|
||||
}
|
||||
if(typeof settings.loadPage!="undefined"){
|
||||
$rss("#rgWindow").load(settings.loadPage,function(){$rss(this).hide();dhtml=$rss(this).html();prepareWindow();});
|
||||
}
|
||||
function prepareWindow(){
|
||||
if(tempheight!="auto")
|
||||
rgWTop = (rgmaskHeight-tempheight)/2;
|
||||
else{
|
||||
tempheight=$rss("#rgWindow").height()+30;
|
||||
if(tempheight>maxheight)
|
||||
tempheight=maxheight;
|
||||
rgWTop=(rgmaskHeight-tempheight)/2;
|
||||
}
|
||||
if(tempwidth!="auto")
|
||||
rgWLeft = (rgmaskWidth-tempwidth)/2;
|
||||
else{
|
||||
tempwidth=$rss("#rgWindow").width();
|
||||
if(tempwidth>maxwidth)
|
||||
tempwidth=maxwidth;
|
||||
rgWLeft=(rgmaskWidth-tempwidth)/2;
|
||||
}
|
||||
tempwidth=parseInt(tempwidth)+25;
|
||||
$rss("#rgWindow").empty().show();
|
||||
var closebtn = "";
|
||||
if(closeBtn)
|
||||
closebtn='<a href="" style="display:block; width:20px; height:20px; line-height:19px; text-align:center; position:absolute; right:-10px; top: -10px; font-family:Tahoma; font-weight:bold; border:solid 1px #000; border-radius: 10px;text-shadow:0px 1px 0 #DDD; background-color:#CCC; font-size:10px; text-decoration:none; color:#666; padding-left:1px; box-shadow: 0 0 5px #000000;" id="close_modal">X</a>';
|
||||
$rss("#rgWindow").animate({"width":tempwidth+"px","height":tempheight+"px",top:rgWTop+"px", left:rgWLeft+"px"},500,function(){$rss("#rgWindow").html(closebtn+"<div id='rgContent' style='padding:5px; overflow:auto; overflow-x:none; height:"+tempheight+"px;'>"+dhtml+"</div>");
|
||||
$rss("#close_modal").mouseover(function(){$rss(this).css("color","#999");}).mouseout(function(){$rss(this).css("color","#666");})
|
||||
$rss("#close_modal").click(function(){rcom.modalWindowClose(); return false;})
|
||||
if(envClose)
|
||||
$rss("#rgsheath").click(function(){
|
||||
rcom.modalWindowClose();
|
||||
})
|
||||
$rss(document).one("keydown",function(e){
|
||||
if (e.keyCode == 27){
|
||||
rcom.modalWindowClose();
|
||||
return false;
|
||||
}
|
||||
})
|
||||
|
||||
if(typeof callbackFn=="function")
|
||||
callbackFn.call(this,$rss("#rgWindow"));
|
||||
});
|
||||
}
|
||||
},
|
||||
modalWindowUpdate : function(settings,callbackFn){
|
||||
var rgmaskHeight = $rss(window).height();
|
||||
var rgmaskWidth = $rss(window).width();
|
||||
var tempheight = settings.height;
|
||||
var tempwidth = settings.width;
|
||||
var dhtml = "";
|
||||
var maxheight = (rgmaskHeight*85)/100;
|
||||
var maxwidth = (rgmaskWidth*85)/100;
|
||||
if(typeof tempheight!="undefined"){
|
||||
tempheight = tempheight.toString();
|
||||
if(tempheight.charAt(tempheight.length-1)=='%')
|
||||
tempheight=(rgmaskHeight*parseInt(tempheight.substr(0,tempheight.length)))/100;
|
||||
if(tempheight>maxheight)
|
||||
tempheight=maxheight;
|
||||
}else{tempheight="auto";}
|
||||
if(typeof tempwidth!="undefined"){
|
||||
tempwidth = tempwidth.toString();
|
||||
if(tempwidth.charAt(tempwidth.length-1)=='%')
|
||||
tempwidth=(rgmaskWidth*parseInt(tempwidth.substr(0,tempwidth.length)))/100;
|
||||
if(tempwidth>maxwidth)
|
||||
tempwidth=maxwidth;
|
||||
}else{tempwidth="auto";};
|
||||
$rss("body").append("<div id='rgwindow_temp_div'></div>");
|
||||
|
||||
if(typeof settings.loadDiv!="undefined"){
|
||||
dhtml = $rss("#"+settings.loadDiv).html();
|
||||
$rss("#rgwindow_temp_div").html(dhtml).hide();
|
||||
prepareWindow();
|
||||
}
|
||||
if(typeof settings.loadHtml!="undefined"){
|
||||
dhtml = settings.loadHtml;
|
||||
$rss("#rgwindow_temp_div").html(dhtml).hide();
|
||||
prepareWindow();
|
||||
}
|
||||
if(typeof settings.loadPage!="undefined"){
|
||||
$rss("#rgwindow_temp_div").load(settings.loadPage,function(){$rss(this).hide();dhtml=$rss(this).html();prepareWindow();});
|
||||
}
|
||||
function prepareWindow(){
|
||||
if(tempheight!="auto")
|
||||
rgWTop = (rgmaskHeight-tempheight)/2;
|
||||
else{
|
||||
tempheight=$rss("#rgwindow_temp_div").height()+30;
|
||||
if(tempheight>maxheight)
|
||||
tempheight=maxheight;
|
||||
rgWTop=(rgmaskHeight-tempheight)/2;
|
||||
}
|
||||
if(tempwidth!="auto")
|
||||
rgWLeft = (rgmaskWidth-tempwidth)/2;
|
||||
else{
|
||||
tempwidth=$rss("#rgwindow_temp_div").width();
|
||||
if(tempwidth>maxwidth)
|
||||
tempwidth=maxwidth;
|
||||
rgWLeft=(rgmaskWidth-tempwidth)/2;
|
||||
}
|
||||
tempwidth=parseInt(tempwidth)+25;
|
||||
$rss("#rgContent").empty();
|
||||
$rss("#rgWindow").animate({"width":tempwidth+"px","height":tempheight+"px",top:rgWTop+"px", left:rgWLeft+"px"},500,function(){$rss("#rgContent").css("height",tempheight+"px").html(dhtml)});
|
||||
$rss("#rgwindow_temp_div").remove();
|
||||
}
|
||||
},
|
||||
modalWindowClose : function(callbackFn){
|
||||
if($rss("#rgWindow").length>0){
|
||||
$rss("#rgWindow").empty();
|
||||
var rgmaskHeight = $rss(window).height();
|
||||
var rgmaskWidth = $rss(window).width();
|
||||
var x = (rgmaskHeight-20)/2;
|
||||
var y = (rgmaskWidth-20)/2
|
||||
$rss("#rgWindow").animate({top:x+"px", left:y+"px","width":"50px","height":"50px"},300,function(){$rss(this).fadeOut(100).remove();$rss("#rgsheath").fadeOut(500).remove();})
|
||||
}
|
||||
if(typeof callbackFn=="function")
|
||||
callbackFn.call(this,"harry");
|
||||
},
|
||||
bindDomToHead : function(dom){
|
||||
var gc = dom.css("background");
|
||||
var t = dom.offset();
|
||||
var gw = dom.width();
|
||||
$rss(window).scroll(function(){
|
||||
var wt = $rss(window).scrollTop();
|
||||
if ( wt > t.top ) {
|
||||
var cssObj = {
|
||||
'position':'fixed',
|
||||
'top':0,
|
||||
'width':gw,
|
||||
'background':gc,
|
||||
'box-shadow':'0 1px 0 rgba(0,0,0,0.2)',
|
||||
'z-index':99
|
||||
}
|
||||
dom.css(cssObj);
|
||||
} else {
|
||||
dom.attr('style',"");
|
||||
}
|
||||
});
|
||||
},
|
||||
progressBar : function(dom,settings){
|
||||
var domid = dom.prop("id");
|
||||
if($rss("#rss_progressbar_div_"+domid).length==0){
|
||||
if(typeof settings.top == "undefined")
|
||||
settings.value = 1;
|
||||
if(typeof settings.top == "undefined")
|
||||
settings.top = (dom.height()-12)/2;
|
||||
dom.append("<div id='rss_progressbar_div_"+domid+"' style='display:none;padding: 2px;background: #333;background: -webkit-linear-gradient(#111, #333);background: -moz-linear-gradient(#111, #333);background: -ms-linear-gradient(#111, #333);position: absolute;top: "+settings.top+"px;left: 50%;margin-left: -45%;width: 84%;box-shadow: inset 0 0 2px #000;border-radius: 4px;'><div id='rss_progressbar_"+domid+"' style='height: 8px; background: #36c;background: -webkit-linear-gradient(#7A98E7, #36c);background: -moz-linear-gradient(#7A98E7, #36c);background: -ms-linear-gradient(#7A98E7, #36c);border-radius: 2px; width: "+settings.value+"%;'></div></div>");
|
||||
$rss("#rss_progressbar_div_"+domid).fadeIn(500);
|
||||
}
|
||||
},
|
||||
progressBarValue : function(dom,value){
|
||||
var domid = dom.prop("id");
|
||||
if($rss("#rss_progressbar_div_"+domid).length==1){
|
||||
$rss("#rss_progressbar_"+domid).animate({"width":value+"%"},100);
|
||||
|
||||
}
|
||||
},
|
||||
progressBarClose : function(dom){
|
||||
var domid = dom.prop("id");
|
||||
$rss("#rss_progressbar_div_"+domid).fadeOut(500,function(){$(this).remove();});
|
||||
},
|
||||
getInternetExplorerVersion: function(){
|
||||
var rv = -1; // Return value assumes failure.
|
||||
if (navigator.appName == 'Microsoft Internet Explorer')
|
||||
{
|
||||
var ua = navigator.userAgent;
|
||||
var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
|
||||
if (re.exec(ua) != null)
|
||||
rv = parseFloat( RegExp.$1 );
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
$ = jQuery.noConflict();
|
||||
@@ -0,0 +1,9 @@
|
||||
$(document).ready(function(){
|
||||
$('#screen-shot .holder')
|
||||
.before('<div id="scr-nav"/>')
|
||||
.cycle({
|
||||
pager: '#scr-nav',
|
||||
fx: 'scrollLeft',
|
||||
pause: 1
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,40 @@
|
||||
var history_edited = false;
|
||||
|
||||
$('#back_main a.reload').live('click',
|
||||
function () {
|
||||
$.getScript(this.href);
|
||||
history.replaceState(null, document.title, this.href);
|
||||
history_edited = true;
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
$('#back_main form').live('submit', function () {
|
||||
$.post(this.action, $(this).serialize(), null, 'script');
|
||||
history_edited = true;
|
||||
return false;
|
||||
});
|
||||
|
||||
$(document).on('click', '.js_history',
|
||||
function () {
|
||||
$.getScript(this.href);
|
||||
history.pushState(null, document.title, this.href);
|
||||
history_edited = true;
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
$(document).on('click', '.pagination a',
|
||||
function () {
|
||||
$.getScript(this.href);
|
||||
history.pushState(null, document.title, this.href);
|
||||
history_edited = true;
|
||||
return false;
|
||||
}
|
||||
);
|
||||
|
||||
$(window).bind("popstate", function () {
|
||||
if (history_edited) {
|
||||
$.getScript(location.href);
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
// This is a manifest file that'll be compiled into including all the files listed below.
|
||||
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
||||
// be included in the compiled file accessible from http://example.com/assets/application.js
|
||||
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
||||
// the compiled file.
|
||||
//
|
||||
//= require jquery
|
||||
//= require jquery.ui.draggable
|
||||
//= require jquery.ui.droppable
|
||||
//= require jquery.ui.sortable
|
||||
//= require jquery_ujs
|
||||
//= require bootstrap
|
||||
//= require jquery.tinyscrollbar.min
|
||||
//= require orbit-1.0
|
||||
//= require orbit-bar-search
|
||||
//= require side_bar_history
|
||||
//= require page_edit
|
||||
//= require tinymce-jquery
|
||||
//= require tinymce_orbit
|
||||
//= require lib/jquery.ui.nestedSortable.js
|
||||
@@ -0,0 +1,19 @@
|
||||
<%#= encoding: utf-8 %>
|
||||
$(document).on('click', '.list-remove', function(){
|
||||
if(confirm("<%= I18n.t('sure?') %>")){
|
||||
var a = [];
|
||||
$('.checkbox_in_list').each(function(){
|
||||
if (this.checked) a.push("ids[]=" + this.value);
|
||||
});
|
||||
var url = $(this).attr('rel');
|
||||
if (url.indexOf('?') > -1){
|
||||
$.getScript(url + '&' + a.join('&'));
|
||||
}else{
|
||||
$.getScript(url + '?' + a.join('&'));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '#check_all', function(){
|
||||
$('.checkbox_in_list').attr("checked", this.checked);
|
||||
});
|
||||
@@ -0,0 +1,100 @@
|
||||
function load_tinymce() {
|
||||
$('.tinymce_textarea').tinymce({
|
||||
|
||||
// General options
|
||||
theme: 'advanced',
|
||||
file_browser_callback : 'myFileBrowser',
|
||||
plugins : "autolink,lists,pagebreak,style,layer,table,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave",
|
||||
|
||||
// Theme options
|
||||
theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,formatselect,fontselect,fontsizeselect",
|
||||
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,forecolor,backcolor",
|
||||
theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,fullscreen",
|
||||
theme_advanced_toolbar_location : "top",
|
||||
theme_advanced_toolbar_align : "left",
|
||||
theme_advanced_statusbar_location : "bottom",
|
||||
theme_advanced_resizing : true,
|
||||
|
||||
// Skin options
|
||||
skin : "o2k7",
|
||||
skin_variant : "silver",
|
||||
font_size_style_values : "xx-small,x-small,small,medium,large,x-large,xx-large",
|
||||
// Drop lists for link/image/media/template dialogs
|
||||
template_external_list_url : "js/template_list.js",
|
||||
// external_link_list_url : "js/link_list.js",
|
||||
// external_image_list_url : "js/image_list.js",
|
||||
// media_external_list_url : "js/media_list.js"
|
||||
|
||||
content_css: "<%= asset_path('tinymce_orbit.css') %>",
|
||||
|
||||
// Style formats
|
||||
style_formats : [
|
||||
{title : 'Bold text', inline : 'b'},
|
||||
{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
|
||||
{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
|
||||
{title : 'Example 1', inline : 'span', classes : 'example1'},
|
||||
{title : 'Example 2', inline : 'span', classes : 'example2'},
|
||||
{title : 'Table styles'},
|
||||
{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
|
||||
],
|
||||
|
||||
// Replace values for the template plugin
|
||||
template_replace_values : {
|
||||
username : "Some User",
|
||||
staffid : "991234"
|
||||
},
|
||||
|
||||
// Valide HTML elements
|
||||
valid_elements : '*[*]',
|
||||
valid_children : '*[*]',
|
||||
|
||||
// Height & width
|
||||
height : '400',
|
||||
width : '100%'
|
||||
});
|
||||
}
|
||||
function myFileBrowser(field_name, url, type, win) {
|
||||
var cmsURL = window.location.toString();
|
||||
cmsURL = cmsURL.split("/");
|
||||
cmsURL = "<%= Rails.application.routes.url_helpers.file_upload_admin_assets_path %>";
|
||||
|
||||
// script URL - use an absolute path!
|
||||
if (cmsURL.indexOf("?") < 0) {
|
||||
//add the type as the only query parameter
|
||||
cmsURL = cmsURL + "?type=" + type;
|
||||
}
|
||||
else {
|
||||
//add the type as an additional query parameter
|
||||
// (PHP session ID is now included if there is one at all)
|
||||
cmsURL = cmsURL + "&type=" + type;
|
||||
}
|
||||
|
||||
tinyMCE.activeEditor.windowManager.open({
|
||||
file : cmsURL,
|
||||
title : 'File Browser',
|
||||
width : 530, // Your dimensions may differ - toy around with them!
|
||||
height : 350,
|
||||
resizable : "no",
|
||||
inline : "no", // This parameter only has an effect if you use the inlinepopups plugin!
|
||||
close_previous : "no"
|
||||
}, {
|
||||
window : win,
|
||||
input : field_name,
|
||||
alt : "alt",
|
||||
title : "title"
|
||||
});
|
||||
return false;
|
||||
}
|
||||
function ajaxSave() {
|
||||
var ed = tinyMCE.get('content');
|
||||
// Do you ajax call here, window.setTimeout fakes ajax call
|
||||
ed.setProgressState(1); // Show progress
|
||||
window.setTimeout(function() {
|
||||
ed.setProgressState(0); // Hide progress
|
||||
alert(ed.getContent());
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
load_tinymce();
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
$('div a.hide').live( "click", function(){
|
||||
$(this).parent().next().hide();
|
||||
$(this).replaceWith("<a href='#' class='show'><%= t(:show) %></a>");
|
||||
});
|
||||
$('div a.show').live( "click", function(){
|
||||
$(this).parent().next().show();
|
||||
$(this).replaceWith("<a href='#' class='hide'><%= t(:hide) %></a>");
|
||||
});
|
||||
@@ -0,0 +1,10 @@
|
||||
$(document).ready(function(){
|
||||
$('#user_role_id').change(function(){
|
||||
$('#roles .attributes_block').hide();
|
||||
$('#'+this.value+'_block').toggle();
|
||||
});
|
||||
|
||||
$('.sub_role_select').change(function(){
|
||||
$('#sub_role_' + this.value).toggle();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user