code stringlengths 1 2.08M | language stringclasses 1
value |
|---|---|
/*
Transform a table to a jqGrid.
Peter Romianowski <peter.romianowski@optivo.de>
If the first column of the table contains checkboxes or
radiobuttons then the jqGrid is made selectable.
*/
// Addition - selector can be a class or id
function tableToGrid(selector, options) {
jQuery(selector).each(function() {
if(this.grid) {return;} //Adedd from Tony Tomov
// This is a small "hack" to make the width of the jqGrid 100%
jQuery(this).width("99%");
var w = jQuery(this).width();
// Text whether we have single or multi select
var inputCheckbox = jQuery('tr td:first-child input[type=checkbox]:first', jQuery(this));
var inputRadio = jQuery('tr td:first-child input[type=radio]:first', jQuery(this));
var selectMultiple = inputCheckbox.length > 0;
var selectSingle = !selectMultiple && inputRadio.length > 0;
var selectable = selectMultiple || selectSingle;
//var inputName = inputCheckbox.attr("name") || inputRadio.attr("name");
// Build up the columnModel and the data
var colModel = [];
var colNames = [];
jQuery('th', jQuery(this)).each(function() {
if (colModel.length === 0 && selectable) {
colModel.push({
name: '__selection__',
index: '__selection__',
width: 0,
hidden: true
});
colNames.push('__selection__');
} else {
colModel.push({
name: jQuery(this).attr("id") || jQuery.trim(jQuery.jgrid.stripHtml(jQuery(this).html())).split(' ').join('_'),
index: jQuery(this).attr("id") || jQuery.trim(jQuery.jgrid.stripHtml(jQuery(this).html())).split(' ').join('_'),
width: jQuery(this).width() || 150
});
colNames.push(jQuery(this).html());
}
});
var data = [];
var rowIds = [];
var rowChecked = [];
jQuery('tbody > tr', jQuery(this)).each(function() {
var row = {};
var rowPos = 0;
jQuery('td', jQuery(this)).each(function() {
if (rowPos === 0 && selectable) {
var input = jQuery('input', jQuery(this));
var rowId = input.attr("value");
rowIds.push(rowId || data.length);
if (input.is(":checked")) {
rowChecked.push(rowId);
}
row[colModel[rowPos].name] = input.attr("value");
} else {
row[colModel[rowPos].name] = jQuery(this).html();
}
rowPos++;
});
if(rowPos >0) { data.push(row); }
});
// Clear the original HTML table
jQuery(this).empty();
// Mark it as jqGrid
jQuery(this).addClass("scroll");
jQuery(this).jqGrid(jQuery.extend({
datatype: "local",
width: w,
colNames: colNames,
colModel: colModel,
multiselect: selectMultiple
//inputName: inputName,
//inputValueCol: imputName != null ? "__selection__" : null
}, options || {}));
// Add data
var a;
for (a = 0; a < data.length; a++) {
var id = null;
if (rowIds.length > 0) {
id = rowIds[a];
if (id && id.replace) {
// We have to do this since the value of a checkbox
// or radio button can be anything
id = encodeURIComponent(id).replace(/[.\-%]/g, "_");
}
}
if (id === null) {
id = a + 1;
}
jQuery(this).jqGrid("addRowData",id, data[a]);
}
// Set the selection
for (a = 0; a < rowChecked.length; a++) {
jQuery(this).jqGrid("setSelection",rowChecked[a]);
}
});
};
| JavaScript |
/*
* jqFilter jQuery jqGrid filter addon.
* Copyright (c) 2011, Tony Tomov, tony@trirand.com
* Dual licensed under the MIT and GPL licenses
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl-2.0.html
*
* The work is inspired from this Stefan Pirvu
* http://www.codeproject.com/KB/scripting/json-filtering.aspx
*
* The filter uses JSON entities to hold filter rules and groups. Here is an example of a filter:
{ "groupOp": "AND",
"groups" : [
{ "groupOp": "OR",
"rules": [
{ "field": "name", "op": "eq", "data": "England" },
{ "field": "id", "op": "le", "data": "5"}
]
}
],
"rules": [
{ "field": "name", "op": "eq", "data": "Romania" },
{ "field": "id", "op": "le", "data": "1"}
]
}
*/
/*jshint eqeqeq:false, eqnull:true, devel:true */
/*global jQuery */
(function ($) {
"use strict";
$.fn.jqFilter = function( arg ) {
if (typeof arg === 'string') {
var fn = $.fn.jqFilter[arg];
if (!fn) {
throw ("jqFilter - No such method: " + arg);
}
var args = $.makeArray(arguments).slice(1);
return fn.apply(this,args);
}
var p = $.extend(true,{
filter: null,
columns: [],
onChange : null,
afterRedraw : null,
checkValues : null,
error: false,
errmsg : "",
errorcheck : true,
showQuery : true,
sopt : null,
ops : [
{"name": "eq", "description": "equal", "operator":"="},
{"name": "ne", "description": "not equal", "operator":"<>"},
{"name": "lt", "description": "less", "operator":"<"},
{"name": "le", "description": "less or equal","operator":"<="},
{"name": "gt", "description": "greater", "operator":">"},
{"name": "ge", "description": "greater or equal", "operator":">="},
{"name": "bw", "description": "begins with", "operator":"LIKE"},
{"name": "bn", "description": "does not begin with", "operator":"NOT LIKE"},
{"name": "in", "description": "in", "operator":"IN"},
{"name": "ni", "description": "not in", "operator":"NOT IN"},
{"name": "ew", "description": "ends with", "operator":"LIKE"},
{"name": "en", "description": "does not end with", "operator":"NOT LIKE"},
{"name": "cn", "description": "contains", "operator":"LIKE"},
{"name": "nc", "description": "does not contain", "operator":"NOT LIKE"},
{"name": "nu", "description": "is null", "operator":"IS NULL"},
{"name": "nn", "description": "is not null", "operator":"IS NOT NULL"}
],
numopts : ['eq','ne', 'lt', 'le', 'gt', 'ge', 'nu', 'nn', 'in', 'ni'],
stropts : ['eq', 'ne', 'bw', 'bn', 'ew', 'en', 'cn', 'nc', 'nu', 'nn', 'in', 'ni'],
strarr : ['text', 'string', 'blob'],
_gridsopt : [], // grid translated strings, do not tuch
groupOps : [{ op: "AND", text: "AND" }, { op: "OR", text: "OR" }],
groupButton : true,
ruleButtons : true,
direction : "ltr"
}, $.jgrid.filter, arg || {});
return this.each( function() {
if (this.filter) {return;}
this.p = p;
// setup filter in case if they is not defined
if (this.p.filter === null || this.p.filter === undefined) {
this.p.filter = {
groupOp: this.p.groupOps[0].op,
rules: [],
groups: []
};
}
var i, len = this.p.columns.length, cl,
isIE = /msie/i.test(navigator.userAgent) && !window.opera;
// translating the options
if(this.p._gridsopt.length) {
// ['eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc']
for(i=0;i<this.p._gridsopt.length;i++) {
this.p.ops[i].description = this.p._gridsopt[i];
}
}
this.p.initFilter = $.extend(true,{},this.p.filter);
// set default values for the columns if they are not set
if( !len ) {return;}
for(i=0; i < len; i++) {
cl = this.p.columns[i];
if( cl.stype ) {
// grid compatibility
cl.inputtype = cl.stype;
} else if(!cl.inputtype) {
cl.inputtype = 'text';
}
if( cl.sorttype ) {
// grid compatibility
cl.searchtype = cl.sorttype;
} else if (!cl.searchtype) {
cl.searchtype = 'string';
}
if(cl.hidden === undefined) {
// jqGrid compatibility
cl.hidden = false;
}
if(!cl.label) {
cl.label = cl.name;
}
if(cl.index) {
cl.name = cl.index;
}
if(!cl.hasOwnProperty('searchoptions')) {
cl.searchoptions = {};
}
if(!cl.hasOwnProperty('searchrules')) {
cl.searchrules = {};
}
}
if(this.p.showQuery) {
$(this).append("<table class='queryresult ui-widget ui-widget-content' style='display:block;max-width:440px;border:0px none;' dir='"+this.p.direction+"'><tbody><tr><td class='query'></td></tr></tbody></table>");
}
/*
*Perform checking.
*
*/
var checkData = function(val, colModelItem) {
var ret = [true,""];
if($.isFunction(colModelItem.searchrules)) {
ret = colModelItem.searchrules(val, colModelItem);
} else if($.jgrid && $.jgrid.checkValues) {
try {
ret = $.jgrid.checkValues(val, -1, null, colModelItem.searchrules, colModelItem.label);
} catch (e) {}
}
if(ret && ret.length && ret[0] === false) {
p.error = !ret[0];
p.errmsg = ret[1];
}
};
/* moving to common
randId = function() {
return Math.floor(Math.random()*10000).toString();
};
*/
this.onchange = function ( ){
// clear any error
this.p.error = false;
this.p.errmsg="";
return $.isFunction(this.p.onChange) ? this.p.onChange.call( this, this.p ) : false;
};
/*
* Redraw the filter every time when new field is added/deleted
* and field is changed
*/
this.reDraw = function() {
$("table.group:first",this).remove();
var t = this.createTableForGroup(p.filter, null);
$(this).append(t);
if($.isFunction(this.p.afterRedraw) ) {
this.p.afterRedraw.call(this, this.p);
}
};
/*
* Creates a grouping data for the filter
* @param group - object
* @param parentgroup - object
*/
this.createTableForGroup = function(group, parentgroup) {
var that = this, i;
// this table will hold all the group (tables) and rules (rows)
var table = $("<table class='group ui-widget ui-widget-content' style='border:0px none;'><tbody></tbody></table>"),
// create error message row
align = "left";
if(this.p.direction == "rtl") {
align = "right";
table.attr("dir","rtl");
}
if(parentgroup === null) {
table.append("<tr class='error' style='display:none;'><th colspan='5' class='ui-state-error' align='"+align+"'></th></tr>");
}
var tr = $("<tr></tr>");
table.append(tr);
// this header will hold the group operator type and group action buttons for
// creating subgroup "+ {}", creating rule "+" or deleting the group "-"
var th = $("<th colspan='5' align='"+align+"'></th>");
tr.append(th);
if(this.p.ruleButtons === true) {
// dropdown for: choosing group operator type
var groupOpSelect = $("<select class='opsel'></select>");
th.append(groupOpSelect);
// populate dropdown with all posible group operators: or, and
var str= "", selected;
for (i = 0; i < p.groupOps.length; i++) {
selected = group.groupOp === that.p.groupOps[i].op ? " selected='selected'" :"";
str += "<option value='"+that.p.groupOps[i].op+"'" + selected+">"+that.p.groupOps[i].text+"</option>";
}
groupOpSelect
.append(str)
.bind('change',function() {
group.groupOp = $(groupOpSelect).val();
that.onchange(); // signals that the filter has changed
});
}
// button for adding a new subgroup
var inputAddSubgroup ="<span></span>";
if(this.p.groupButton) {
inputAddSubgroup = $("<input type='button' value='+ {}' title='Add subgroup' class='add-group'/>");
inputAddSubgroup.bind('click',function() {
if (group.groups === undefined ) {
group.groups = [];
}
group.groups.push({
groupOp: p.groupOps[0].op,
rules: [],
groups: []
}); // adding a new group
that.reDraw(); // the html has changed, force reDraw
that.onchange(); // signals that the filter has changed
return false;
});
}
th.append(inputAddSubgroup);
if(this.p.ruleButtons === true) {
// button for adding a new rule
var inputAddRule = $("<input type='button' value='+' title='Add rule' class='add-rule ui-add'/>"), cm;
inputAddRule.bind('click',function() {
//if(!group) { group = {};}
if (group.rules === undefined) {
group.rules = [];
}
for (i = 0; i < that.p.columns.length; i++) {
// but show only serchable and serchhidden = true fields
var searchable = (that.p.columns[i].search === undefined) ? true: that.p.columns[i].search ,
hidden = (that.p.columns[i].hidden === true),
ignoreHiding = (that.p.columns[i].searchoptions.searchhidden === true);
if ((ignoreHiding && searchable) || (searchable && !hidden)) {
cm = that.p.columns[i];
break;
}
}
var opr;
if( cm.searchoptions.sopt ) {opr = cm.searchoptions.sopt;}
else if(that.p.sopt) { opr= that.p.sopt; }
else if ( $.inArray(cm.searchtype, that.p.strarr) !== -1 ) {opr = that.p.stropts;}
else {opr = that.p.numopts;}
group.rules.push({
field: cm.name,
op: opr[0],
data: ""
}); // adding a new rule
that.reDraw(); // the html has changed, force reDraw
// for the moment no change have been made to the rule, so
// this will not trigger onchange event
return false;
});
th.append(inputAddRule);
}
// button for delete the group
if (parentgroup !== null) { // ignore the first group
var inputDeleteGroup = $("<input type='button' value='-' title='Delete group' class='delete-group'/>");
th.append(inputDeleteGroup);
inputDeleteGroup.bind('click',function() {
// remove group from parent
for (i = 0; i < parentgroup.groups.length; i++) {
if (parentgroup.groups[i] === group) {
parentgroup.groups.splice(i, 1);
break;
}
}
that.reDraw(); // the html has changed, force reDraw
that.onchange(); // signals that the filter has changed
return false;
});
}
// append subgroup rows
if (group.groups !== undefined) {
for (i = 0; i < group.groups.length; i++) {
var trHolderForSubgroup = $("<tr></tr>");
table.append(trHolderForSubgroup);
var tdFirstHolderForSubgroup = $("<td class='first'></td>");
trHolderForSubgroup.append(tdFirstHolderForSubgroup);
var tdMainHolderForSubgroup = $("<td colspan='4'></td>");
tdMainHolderForSubgroup.append(this.createTableForGroup(group.groups[i], group));
trHolderForSubgroup.append(tdMainHolderForSubgroup);
}
}
if(group.groupOp === undefined) {
group.groupOp = that.p.groupOps[0].op;
}
// append rules rows
if (group.rules !== undefined) {
for (i = 0; i < group.rules.length; i++) {
table.append(
this.createTableRowForRule(group.rules[i], group)
);
}
}
return table;
};
/*
* Create the rule data for the filter
*/
this.createTableRowForRule = function(rule, group ) {
// save current entity in a variable so that it could
// be referenced in anonimous method calls
var that=this, tr = $("<tr></tr>"),
//document.createElement("tr"),
// first column used for padding
//tdFirstHolderForRule = document.createElement("td"),
i, op, trpar, cm, str="", selected;
//tdFirstHolderForRule.setAttribute("class", "first");
tr.append("<td class='first'></td>");
// create field container
var ruleFieldTd = $("<td class='columns'></td>");
tr.append(ruleFieldTd);
// dropdown for: choosing field
var ruleFieldSelect = $("<select></select>"), ina, aoprs = [];
ruleFieldTd.append(ruleFieldSelect);
ruleFieldSelect.bind('change',function() {
rule.field = $(ruleFieldSelect).val();
trpar = $(this).parents("tr:first");
for (i=0;i<that.p.columns.length;i++) {
if(that.p.columns[i].name === rule.field) {
cm = that.p.columns[i];
break;
}
}
if(!cm) {return;}
cm.searchoptions.id = $.jgrid.randId();
if(isIE && cm.inputtype === "text") {
if(!cm.searchoptions.size) {
cm.searchoptions.size = 10;
}
}
var elm = $.jgrid.createEl(cm.inputtype,cm.searchoptions, "", true, that.p.ajaxSelectOptions, true);
$(elm).addClass("input-elm");
//that.createElement(rule, "");
if( cm.searchoptions.sopt ) {op = cm.searchoptions.sopt;}
else if(that.p.sopt) { op= that.p.sopt; }
else if ($.inArray(cm.searchtype, that.p.strarr) !== -1) {op = that.p.stropts;}
else {op = that.p.numopts;}
// operators
var s ="", so = 0;
aoprs = [];
$.each(that.p.ops, function() { aoprs.push(this.name); });
for ( i = 0 ; i < op.length; i++) {
ina = $.inArray(op[i],aoprs);
if(ina !== -1) {
if(so===0) {
rule.op = that.p.ops[ina].name;
}
s += "<option value='"+that.p.ops[ina].name+"'>"+that.p.ops[ina].description+"</option>";
so++;
}
}
$(".selectopts",trpar).empty().append( s );
$(".selectopts",trpar)[0].selectedIndex = 0;
if( $.browser.msie && $.browser.version < 9) {
var sw = parseInt($("select.selectopts",trpar)[0].offsetWidth, 10) + 1;
$(".selectopts",trpar).width( sw );
$(".selectopts",trpar).css("width","auto");
}
// data
$(".data",trpar).empty().append( elm );
$.jgrid.bindEv( elm, cm.searchoptions, that);
$(".input-elm",trpar).bind('change',function( e ) {
var tmo = $(this).hasClass("ui-autocomplete-input") ? 200 :0;
setTimeout(function(){
var elem = e.target;
rule.data = elem.nodeName.toUpperCase() === "SPAN" && cm.searchoptions && $.isFunction(cm.searchoptions.custom_value) ?
cm.searchoptions.custom_value($(elem).children(".customelement:first"), 'get') : elem.value;
that.onchange(); // signals that the filter has changed
}, tmo);
});
setTimeout(function(){ //IE, Opera, Chrome
rule.data = $(elm).val();
that.onchange(); // signals that the filter has changed
}, 0);
});
// populate drop down with user provided column definitions
var j=0;
for (i = 0; i < that.p.columns.length; i++) {
// but show only serchable and serchhidden = true fields
var searchable = (that.p.columns[i].search === undefined) ? true: that.p.columns[i].search,
hidden = (that.p.columns[i].hidden === true),
ignoreHiding = (that.p.columns[i].searchoptions.searchhidden === true);
if ((ignoreHiding && searchable) || (searchable && !hidden)) {
selected = "";
if(rule.field === that.p.columns[i].name) {
selected = " selected='selected'";
j=i;
}
str += "<option value='"+that.p.columns[i].name+"'" +selected+">"+that.p.columns[i].label+"</option>";
}
}
ruleFieldSelect.append( str );
// create operator container
var ruleOperatorTd = $("<td class='operators'></td>");
tr.append(ruleOperatorTd);
cm = p.columns[j];
// create it here so it can be referentiated in the onchange event
//var RD = that.createElement(rule, rule.data);
cm.searchoptions.id = $.jgrid.randId();
if(isIE && cm.inputtype === "text") {
if(!cm.searchoptions.size) {
cm.searchoptions.size = 10;
}
}
var ruleDataInput = $.jgrid.createEl(cm.inputtype,cm.searchoptions, rule.data, true, that.p.ajaxSelectOptions, true);
if(rule.op == 'nu' || rule.op == 'nn') {
$(ruleDataInput).attr('readonly','true');
$(ruleDataInput).attr('disabled','true');
} //retain the state of disabled text fields in case of null ops
// dropdown for: choosing operator
var ruleOperatorSelect = $("<select class='selectopts'></select>");
ruleOperatorTd.append(ruleOperatorSelect);
ruleOperatorSelect.bind('change',function() {
rule.op = $(ruleOperatorSelect).val();
trpar = $(this).parents("tr:first");
var rd = $(".input-elm",trpar)[0];
if (rule.op === "nu" || rule.op === "nn") { // disable for operator "is null" and "is not null"
rule.data = "";
rd.value = "";
rd.setAttribute("readonly", "true");
rd.setAttribute("disabled", "true");
} else {
rd.removeAttribute("readonly");
rd.removeAttribute("disabled");
}
that.onchange(); // signals that the filter has changed
});
// populate drop down with all available operators
if( cm.searchoptions.sopt ) {op = cm.searchoptions.sopt;}
else if(that.p.sopt) { op= that.p.sopt; }
else if ($.inArray(cm.searchtype, that.p.strarr) !== -1) {op = that.p.stropts;}
else {op = that.p.numopts;}
str="";
$.each(that.p.ops, function() { aoprs.push(this.name); });
for ( i = 0; i < op.length; i++) {
ina = $.inArray(op[i],aoprs);
if(ina !== -1) {
selected = rule.op === that.p.ops[ina].name ? " selected='selected'" : "";
str += "<option value='"+that.p.ops[ina].name+"'"+selected+">"+that.p.ops[ina].description+"</option>";
}
}
ruleOperatorSelect.append( str );
// create data container
var ruleDataTd = $("<td class='data'></td>");
tr.append(ruleDataTd);
// textbox for: data
// is created previously
//ruleDataInput.setAttribute("type", "text");
ruleDataTd.append(ruleDataInput);
$.jgrid.bindEv( ruleDataInput, cm.searchoptions, that);
$(ruleDataInput)
.addClass("input-elm")
.bind('change', function() {
rule.data = cm.inputtype === 'custom' ? cm.searchoptions.custom_value($(this).children(".customelement:first"),'get') : $(this).val();
that.onchange(); // signals that the filter has changed
});
// create action container
var ruleDeleteTd = $("<td></td>");
tr.append(ruleDeleteTd);
// create button for: delete rule
if(this.p.ruleButtons === true) {
var ruleDeleteInput = $("<input type='button' value='-' title='Delete rule' class='delete-rule ui-del'/>");
ruleDeleteTd.append(ruleDeleteInput);
//$(ruleDeleteInput).html("").height(20).width(30).button({icons: { primary: "ui-icon-minus", text:false}});
ruleDeleteInput.bind('click',function() {
// remove rule from group
for (i = 0; i < group.rules.length; i++) {
if (group.rules[i] === rule) {
group.rules.splice(i, 1);
break;
}
}
that.reDraw(); // the html has changed, force reDraw
that.onchange(); // signals that the filter has changed
return false;
});
}
return tr;
};
this.getStringForGroup = function(group) {
var s = "(", index;
if (group.groups !== undefined) {
for (index = 0; index < group.groups.length; index++) {
if (s.length > 1) {
s += " " + group.groupOp + " ";
}
try {
s += this.getStringForGroup(group.groups[index]);
} catch (eg) {alert(eg);}
}
}
if (group.rules !== undefined) {
try{
for (index = 0; index < group.rules.length; index++) {
if (s.length > 1) {
s += " " + group.groupOp + " ";
}
s += this.getStringForRule(group.rules[index]);
}
} catch (e) {alert(e);}
}
s += ")";
if (s === "()") {
return ""; // ignore groups that don't have rules
}
return s;
};
this.getStringForRule = function(rule) {
var opUF = "",opC="", i, cm, ret, val,
numtypes = ['int', 'integer', 'float', 'number', 'currency']; // jqGrid
for (i = 0; i < this.p.ops.length; i++) {
if (this.p.ops[i].name === rule.op) {
opUF = this.p.ops[i].operator;
opC = this.p.ops[i].name;
break;
}
}
for (i=0; i<this.p.columns.length; i++) {
if(this.p.columns[i].name === rule.field) {
cm = this.p.columns[i];
break;
}
}
if (cm == null) { return ""; }
val = rule.data;
if(opC === 'bw' || opC === 'bn') { val = val+"%"; }
if(opC === 'ew' || opC === 'en') { val = "%"+val; }
if(opC === 'cn' || opC === 'nc') { val = "%"+val+"%"; }
if(opC === 'in' || opC === 'ni') { val = " ("+val+")"; }
if(p.errorcheck) { checkData(rule.data, cm); }
if($.inArray(cm.searchtype, numtypes) !== -1 || opC === 'nn' || opC === 'nu') { ret = rule.field + " " + opUF + " " + val; }
else { ret = rule.field + " " + opUF + " \"" + val + "\""; }
return ret;
};
this.resetFilter = function () {
this.p.filter = $.extend(true,{},this.p.initFilter);
this.reDraw();
this.onchange();
};
this.hideError = function() {
$("th.ui-state-error", this).html("");
$("tr.error", this).hide();
};
this.showError = function() {
$("th.ui-state-error", this).html(this.p.errmsg);
$("tr.error", this).show();
};
this.toUserFriendlyString = function() {
return this.getStringForGroup(p.filter);
};
this.toString = function() {
// this will obtain a string that can be used to match an item.
var that = this;
function getStringRule(rule) {
if(that.p.errorcheck) {
var i, cm;
for (i=0; i<that.p.columns.length; i++) {
if(that.p.columns[i].name === rule.field) {
cm = that.p.columns[i];
break;
}
}
if(cm) {checkData(rule.data, cm);}
}
return rule.op + "(item." + rule.field + ",'" + rule.data + "')";
}
function getStringForGroup(group) {
var s = "(", index;
if (group.groups !== undefined) {
for (index = 0; index < group.groups.length; index++) {
if (s.length > 1) {
if (group.groupOp === "OR") {
s += " || ";
}
else {
s += " && ";
}
}
s += getStringForGroup(group.groups[index]);
}
}
if (group.rules !== undefined) {
for (index = 0; index < group.rules.length; index++) {
if (s.length > 1) {
if (group.groupOp === "OR") {
s += " || ";
}
else {
s += " && ";
}
}
s += getStringRule(group.rules[index]);
}
}
s += ")";
if (s === "()") {
return ""; // ignore groups that don't have rules
}
return s;
}
return getStringForGroup(this.p.filter);
};
// Here we init the filter
this.reDraw();
if(this.p.showQuery) {
this.onchange();
}
// mark is as created so that it will not be created twice on this element
this.filter = true;
});
};
$.extend($.fn.jqFilter,{
/*
* Return SQL like string. Can be used directly
*/
toSQLString : function()
{
var s ="";
this.each(function(){
s = this.toUserFriendlyString();
});
return s;
},
/*
* Return filter data as object.
*/
filterData : function()
{
var s;
this.each(function(){
s = this.p.filter;
});
return s;
},
getParameter : function (param) {
if(param !== undefined) {
if (this.p.hasOwnProperty(param) ) {
return this.p[param];
}
}
return this.p;
},
resetFilter: function() {
return this.each(function(){
this.resetFilter();
});
},
addFilter: function (pfilter) {
if (typeof pfilter === "string") {
pfilter = $.jgrid.parse( pfilter );
}
this.each(function(){
this.p.filter = pfilter;
this.reDraw();
this.onchange();
});
}
});
})(jQuery);
| JavaScript |
/*
* jqModal - Minimalist Modaling with jQuery
* (http://dev.iceburg.net/jquery/jqmodal/)
*
* Copyright (c) 2007,2008 Brice Burgess <bhb@iceburg.net>
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* $Version: 07/06/2008 +r13
*/
(function($) {
$.fn.jqm=function(o){
var p={
overlay: 50,
closeoverlay : true,
overlayClass: 'jqmOverlay',
closeClass: 'jqmClose',
trigger: '.jqModal',
ajax: F,
ajaxText: '',
target: F,
modal: F,
toTop: F,
onShow: F,
onHide: F,
onLoad: F
};
return this.each(function(){if(this._jqm)return H[this._jqm].c=$.extend({},H[this._jqm].c,o);s++;this._jqm=s;
H[s]={c:$.extend(p,$.jqm.params,o),a:F,w:$(this).addClass('jqmID'+s),s:s};
if(p.trigger)$(this).jqmAddTrigger(p.trigger);
});};
$.fn.jqmAddClose=function(e){return hs(this,e,'jqmHide');};
$.fn.jqmAddTrigger=function(e){return hs(this,e,'jqmShow');};
$.fn.jqmShow=function(t){return this.each(function(){$.jqm.open(this._jqm,t);});};
$.fn.jqmHide=function(t){return this.each(function(){$.jqm.close(this._jqm,t)});};
$.jqm = {
hash:{},
open:function(s,t){var h=H[s],c=h.c,cc='.'+c.closeClass,z=(parseInt(h.w.css('z-index')));z=(z>0)?z:3000;var o=$('<div></div>').css({height:'100%',width:'100%',position:'fixed',left:0,top:0,'z-index':z-1,opacity:c.overlay/100});if(h.a)return F;h.t=t;h.a=true;h.w.css('z-index',z);
if(c.modal) {if(!A[0])setTimeout(function(){L('bind');},1);A.push(s);}
else if(c.overlay > 0) {if(c.closeoverlay) h.w.jqmAddClose(o);}
else o=F;
h.o=(o)?o.addClass(c.overlayClass).prependTo('body'):F;
if(ie6){try{$('html,body').css({height:'100%',width:'100%'});if(o){o=o.css({position:'absolute'})[0];for(var y in {Top:1,Left:1})o.style.setExpression(y.toLowerCase(),"(_=(document.documentElement.scroll"+y+" || document.body.scroll"+y+"))+'px'");}}catch(__){}}
if(c.ajax) {var r=c.target||h.w,u=c.ajax;r=(typeof r == 'string')?$(r,h.w):$(r);u=(u.substr(0,1) == '@')?$(t).attr(u.substring(1)):u;
r.html(c.ajaxText).load(u,function(){if(c.onLoad)c.onLoad.call(this,h);if(cc)h.w.jqmAddClose($(cc,h.w));e(h);});}
else if(cc)h.w.jqmAddClose($(cc,h.w));
if(c.toTop&&h.o)h.w.before('<span id="jqmP'+h.w[0]._jqm+'"></span>').insertAfter(h.o);
(c.onShow)?c.onShow(h):h.w.show();e(h);return F;
},
close:function(s){var h=H[s];if(!h.a)return F;h.a=F;
if(A[0]){A.pop();if(!A[0])L('unbind');}
if(h.c.toTop&&h.o)$('#jqmP'+h.w[0]._jqm).after(h.w).remove();
if(h.c.onHide)h.c.onHide(h);else{h.w.hide();if(h.o)h.o.remove();} return F;
},
params:{}};
var s=0,H=$.jqm.hash,A=[],ie6=$.browser.msie&&($.browser.version == "6.0"),F=false,
e=function(h){var i=$('<iframe src="javascript:false;document.write(\'\');" class="jqm"></iframe>').css({opacity:0});if(ie6)if(h.o)h.o.html('<p style="width:100%;height:100%"/>').prepend(i);else if(!$('iframe.jqm',h.w)[0])h.w.prepend(i); f(h);},
f=function(h){try{$(':input:visible',h.w)[0].focus();}catch(_){}},
L=function(t){$(document)[t]("keypress",m)[t]("keydown",m)[t]("mousedown",m);},
m=function(e){var h=H[A[A.length-1]],r=(!$(e.target).parents('.jqmID'+h.s)[0]);if(r)f(h);return !r;},
hs=function(w,t,c){return w.each(function(){var s=this._jqm;$(t).each(function() {
if(!this[c]){this[c]=[];$(this).click(function(){for(var i in {jqmShow:1,jqmHide:1})for(var s in this[i])if(H[this[i][s]])H[this[i][s]].w[i](this);return F;});}this[c].push(s);});});};
})(jQuery); | JavaScript |
/*jshint eqeqeq:false */
/*global jQuery */
(function($){
/**
* jqGrid extension for custom methods
* Tony Tomov tony@trirand.com
* http://trirand.com/blog/
*
* Wildraid wildraid@mail.ru
* Oleg Kiriljuk oleg.kiriljuk@ok-soft-gmbh.com
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl-2.0.html
**/
"use strict";
$.jgrid.extend({
getColProp : function(colname){
var ret ={}, $t = this[0];
if ( !$t.grid ) { return false; }
var cM = $t.p.colModel, i;
for ( i=0;i<cM.length;i++ ) {
if ( cM[i].name == colname ) {
ret = cM[i];
break;
}
}
return ret;
},
setColProp : function(colname, obj){
//do not set width will not work
return this.each(function(){
if ( this.grid ) {
if ( obj ) {
var cM = this.p.colModel, i;
for ( i=0;i<cM.length;i++ ) {
if ( cM[i].name == colname ) {
$.extend(true, this.p.colModel[i],obj);
break;
}
}
}
}
});
},
sortGrid : function(colname,reload, sor){
return this.each(function(){
var $t=this,idx=-1,i;
if ( !$t.grid ) { return;}
if ( !colname ) { colname = $t.p.sortname; }
for ( i=0;i<$t.p.colModel.length;i++ ) {
if ( $t.p.colModel[i].index == colname || $t.p.colModel[i].name==colname ) {
idx = i;
break;
}
}
if ( idx!=-1 ){
var sort = $t.p.colModel[idx].sortable;
if ( typeof sort !== 'boolean' ) { sort = true; }
if ( typeof reload !=='boolean' ) { reload = false; }
if ( sort ) { $t.sortData("jqgh_"+$t.p.id+"_" + colname, idx, reload, sor); }
}
});
},
clearBeforeUnload : function () {
return this.each(function(){
var grid = this.grid;
grid.emptyRows.call(this, true, true); // this work quick enough and reduce the size of memory leaks if we have someone
//$(document).unbind("mouseup"); // TODO add namespace
$(grid.hDiv).unbind("mousemove"); // TODO add namespace
$(this).unbind();
grid.dragEnd = null;
grid.dragMove = null;
grid.dragStart = null;
grid.emptyRows = null;
grid.populate = null;
grid.populateVisible = null;
grid.scrollGrid = null;
grid.selectionPreserver = null;
grid.bDiv = null;
grid.cDiv = null;
grid.hDiv = null;
grid.cols = null;
var i, l = grid.headers.length;
for (i = 0; i < l; i++) {
grid.headers[i].el = null;
}
this.formatCol = null;
this.sortData = null;
this.updatepager = null;
this.refreshIndex = null;
this.setHeadCheckBox = null;
this.constructTr = null;
this.formatter = null;
this.addXmlData = null;
this.addJSONData = null;
});
},
GridDestroy : function () {
return this.each(function(){
if ( this.grid ) {
if ( this.p.pager ) { // if not part of grid
$(this.p.pager).remove();
}
try {
$(this).jqGrid('clearBeforeUnload');
$("#gbox_"+$.jgrid.jqID(this.id)).remove();
} catch (_) {}
}
});
},
GridUnload : function(){
return this.each(function(){
if ( !this.grid ) {return;}
var defgrid = {id: $(this).attr('id'),cl: $(this).attr('class')};
if (this.p.pager) {
$(this.p.pager).empty().removeClass("ui-state-default ui-jqgrid-pager corner-bottom");
}
var newtable = document.createElement('table');
$(newtable).attr({id:defgrid.id});
newtable.className = defgrid.cl;
var gid = $.jgrid.jqID(this.id);
$(newtable).removeClass("ui-jqgrid-btable");
if( $(this.p.pager).parents("#gbox_"+gid).length === 1 ) {
$(newtable).insertBefore("#gbox_"+gid).show();
$(this.p.pager).insertBefore("#gbox_"+gid);
} else {
$(newtable).insertBefore("#gbox_"+gid).show();
}
$(this).jqGrid('clearBeforeUnload');
$("#gbox_"+gid).remove();
});
},
setGridState : function(state) {
return this.each(function(){
if ( !this.grid ) {return;}
var $t = this;
if(state == 'hidden'){
$(".ui-jqgrid-bdiv, .ui-jqgrid-hdiv","#gview_"+$.jgrid.jqID($t.p.id)).slideUp("fast");
if($t.p.pager) {$($t.p.pager).slideUp("fast");}
if($t.p.toppager) {$($t.p.toppager).slideUp("fast");}
if($t.p.toolbar[0]===true) {
if( $t.p.toolbar[1]=='both') {
$($t.grid.ubDiv).slideUp("fast");
}
$($t.grid.uDiv).slideUp("fast");
}
if($t.p.footerrow) { $(".ui-jqgrid-sdiv","#gbox_"+$.jgrid.jqID($t.p.id)).slideUp("fast"); }
$(".ui-jqgrid-titlebar-close span",$t.grid.cDiv).removeClass("ui-icon-circle-triangle-n").addClass("ui-icon-circle-triangle-s");
$t.p.gridstate = 'hidden';
} else if(state=='visible') {
$(".ui-jqgrid-hdiv, .ui-jqgrid-bdiv","#gview_"+$.jgrid.jqID($t.p.id)).slideDown("fast");
if($t.p.pager) {$($t.p.pager).slideDown("fast");}
if($t.p.toppager) {$($t.p.toppager).slideDown("fast");}
if($t.p.toolbar[0]===true) {
if( $t.p.toolbar[1]=='both') {
$($t.grid.ubDiv).slideDown("fast");
}
$($t.grid.uDiv).slideDown("fast");
}
if($t.p.footerrow) { $(".ui-jqgrid-sdiv","#gbox_"+$.jgrid.jqID($t.p.id)).slideDown("fast"); }
$(".ui-jqgrid-titlebar-close span",$t.grid.cDiv).removeClass("ui-icon-circle-triangle-s").addClass("ui-icon-circle-triangle-n");
$t.p.gridstate = 'visible';
}
});
},
filterToolbar : function(p){
p = $.extend({
autosearch: true,
searchOnEnter : true,
beforeSearch: null,
afterSearch: null,
beforeClear: null,
afterClear: null,
searchurl : '',
stringResult: false,
groupOp: 'AND',
defaultSearch : "bw"
},p || {});
return this.each(function(){
var $t = this;
if(this.ftoolbar) { return; }
var triggerToolbar = function() {
var sdata={}, j=0, v, nm, sopt={},so;
$.each($t.p.colModel,function(){
nm = this.index || this.name;
so = (this.searchoptions && this.searchoptions.sopt) ? this.searchoptions.sopt[0] : this.stype=='select'? 'eq' : p.defaultSearch;
v = $("#gs_"+$.jgrid.jqID(this.name), (this.frozen===true && $t.p.frozenColumns === true) ? $t.grid.fhDiv : $t.grid.hDiv).val();
if(v) {
sdata[nm] = v;
sopt[nm] = so;
j++;
} else {
try {
delete $t.p.postData[nm];
} catch (z) {}
}
});
var sd = j>0 ? true : false;
if(p.stringResult === true || $t.p.datatype == "local") {
var ruleGroup = "{\"groupOp\":\"" + p.groupOp + "\",\"rules\":[";
var gi=0;
$.each(sdata,function(i,n){
if (gi > 0) {ruleGroup += ",";}
ruleGroup += "{\"field\":\"" + i + "\",";
ruleGroup += "\"op\":\"" + sopt[i] + "\",";
n+="";
ruleGroup += "\"data\":\"" + n.replace(/\\/g,'\\\\').replace(/\"/g,'\\"') + "\"}";
gi++;
});
ruleGroup += "]}";
$.extend($t.p.postData,{filters:ruleGroup});
$.each(['searchField', 'searchString', 'searchOper'], function(i, n){
if($t.p.postData.hasOwnProperty(n)) { delete $t.p.postData[n];}
});
} else {
$.extend($t.p.postData,sdata);
}
var saveurl;
if($t.p.searchurl) {
saveurl = $t.p.url;
$($t).jqGrid("setGridParam",{url:$t.p.searchurl});
}
var bsr = $($t).triggerHandler("jqGridToolbarBeforeSearch") === 'stop' ? true : false;
if(!bsr && $.isFunction(p.beforeSearch)){bsr = p.beforeSearch.call($t);}
if(!bsr) { $($t).jqGrid("setGridParam",{search:sd}).trigger("reloadGrid",[{page:1}]); }
if(saveurl) {$($t).jqGrid("setGridParam",{url:saveurl});}
$($t).triggerHandler("jqGridToolbarAfterSearch");
if($.isFunction(p.afterSearch)){p.afterSearch.call($t);}
};
var clearToolbar = function(trigger){
var sdata={}, j=0, nm;
trigger = (typeof trigger !== 'boolean') ? true : trigger;
$.each($t.p.colModel,function(){
var v;
if(this.searchoptions && this.searchoptions.defaultValue !== undefined) { v = this.searchoptions.defaultValue; }
nm = this.index || this.name;
switch (this.stype) {
case 'select' :
$("#gs_"+$.jgrid.jqID(this.name)+" option",(this.frozen===true && $t.p.frozenColumns === true) ? $t.grid.fhDiv : $t.grid.hDiv).each(function (i){
if(i===0) { this.selected = true; }
if ($(this).val() == v) {
this.selected = true;
return false;
}
});
if ( v !== undefined ) {
// post the key and not the text
sdata[nm] = v;
j++;
} else {
try {
delete $t.p.postData[nm];
} catch(e) {}
}
break;
case 'text':
$("#gs_"+$.jgrid.jqID(this.name),(this.frozen===true && $t.p.frozenColumns === true) ? $t.grid.fhDiv : $t.grid.hDiv).val(v);
if(v !== undefined) {
sdata[nm] = v;
j++;
} else {
try {
delete $t.p.postData[nm];
} catch (y){}
}
break;
}
});
var sd = j>0 ? true : false;
if(p.stringResult === true || $t.p.datatype == "local") {
var ruleGroup = "{\"groupOp\":\"" + p.groupOp + "\",\"rules\":[";
var gi=0;
$.each(sdata,function(i,n){
if (gi > 0) {ruleGroup += ",";}
ruleGroup += "{\"field\":\"" + i + "\",";
ruleGroup += "\"op\":\"" + "eq" + "\",";
n+="";
ruleGroup += "\"data\":\"" + n.replace(/\\/g,'\\\\').replace(/\"/g,'\\"') + "\"}";
gi++;
});
ruleGroup += "]}";
$.extend($t.p.postData,{filters:ruleGroup});
$.each(['searchField', 'searchString', 'searchOper'], function(i, n){
if($t.p.postData.hasOwnProperty(n)) { delete $t.p.postData[n];}
});
} else {
$.extend($t.p.postData,sdata);
}
var saveurl;
if($t.p.searchurl) {
saveurl = $t.p.url;
$($t).jqGrid("setGridParam",{url:$t.p.searchurl});
}
var bcv = $($t).triggerHandler("jqGridToolbarBeforeClear") === 'stop' ? true : false;
if(!bcv && $.isFunction(p.beforeClear)){bcv = p.beforeClear.call($t);}
if(!bcv) {
if(trigger) {
$($t).jqGrid("setGridParam",{search:sd}).trigger("reloadGrid",[{page:1}]);
}
}
if(saveurl) {$($t).jqGrid("setGridParam",{url:saveurl});}
$($t).triggerHandler("jqGridToolbarAfterClear");
if($.isFunction(p.afterClear)){p.afterClear();}
};
var toggleToolbar = function(){
var trow = $("tr.ui-search-toolbar",$t.grid.hDiv),
trow2 = $t.p.frozenColumns === true ? $("tr.ui-search-toolbar",$t.grid.fhDiv) : false;
if(trow.css("display")=='none') {
trow.show();
if(trow2) {
trow2.show();
}
} else {
trow.hide();
if(trow2) {
trow2.hide();
}
}
};
// create the row
var tr = $("<tr class='ui-search-toolbar' role='rowheader'></tr>");
var timeoutHnd;
$.each($t.p.colModel,function(){
var cm=this, thd , th, soptions,surl,self;
th = $("<th role='columnheader' class='ui-state-default ui-th-column ui-th-"+$t.p.direction+"'></th>");
thd = $("<div style='position:relative;height:100%;padding-right:0.3em;'></div>");
if(this.hidden===true) { $(th).css("display","none");}
this.search = this.search === false ? false : true;
if(this.stype === undefined) {this.stype='text';}
soptions = $.extend({},this.searchoptions || {});
if(this.search){
switch (this.stype)
{
case "select":
surl = this.surl || soptions.dataUrl;
if(surl) {
// data returned should have already constructed html select
// primitive jQuery load
self = thd;
$.ajax($.extend({
url: surl,
dataType: "html",
success: function(res) {
if(soptions.buildSelect !== undefined) {
var d = soptions.buildSelect(res);
if (d) { $(self).append(d); }
} else {
$(self).append(res);
}
if(soptions.defaultValue !== undefined) { $("select",self).val(soptions.defaultValue); }
$("select",self).attr({name:cm.index || cm.name, id: "gs_"+cm.name});
if(soptions.attr) {$("select",self).attr(soptions.attr);}
$("select",self).css({width: "100%"});
// preserve autoserch
$.jgrid.bindEv( $("select",self)[0], soptions, $t);
if(p.autosearch===true){
$("select",self).change(function(){
triggerToolbar();
return false;
});
}
res=null;
}
}, $.jgrid.ajaxOptions, $t.p.ajaxSelectOptions || {} ));
} else {
var oSv, sep, delim;
if(cm.searchoptions) {
oSv = cm.searchoptions.value === undefined ? "" : cm.searchoptions.value;
sep = cm.searchoptions.separator === undefined ? ":" : cm.searchoptions.separator;
delim = cm.searchoptions.delimiter === undefined ? ";" : cm.searchoptions.delimiter;
} else if(cm.editoptions) {
oSv = cm.editoptions.value === undefined ? "" : cm.editoptions.value;
sep = cm.editoptions.separator === undefined ? ":" : cm.editoptions.separator;
delim = cm.editoptions.delimiter === undefined ? ";" : cm.editoptions.delimiter;
}
if (oSv) {
var elem = document.createElement("select");
elem.style.width = "100%";
$(elem).attr({name:cm.index || cm.name, id: "gs_"+cm.name});
var so, sv, ov, key, k;
if(typeof oSv === "string") {
so = oSv.split(delim);
for(k=0; k<so.length;k++){
sv = so[k].split(sep);
ov = document.createElement("option");
ov.value = sv[0]; ov.innerHTML = sv[1];
elem.appendChild(ov);
}
} else if(typeof oSv === "object" ) {
for (key in oSv) {
if(oSv.hasOwnProperty(key)) {
ov = document.createElement("option");
ov.value = key; ov.innerHTML = oSv[key];
elem.appendChild(ov);
}
}
}
if(soptions.defaultValue !== undefined) { $(elem).val(soptions.defaultValue); }
if(soptions.attr) {$(elem).attr(soptions.attr);}
$.jgrid.bindEv( elem , soptions, $t);
$(thd).append(elem);
if(p.autosearch===true){
$(elem).change(function(){
triggerToolbar();
return false;
});
}
}
}
break;
case 'text':
var df = soptions.defaultValue !== undefined ? soptions.defaultValue: "";
$(thd).append("<input type='text' style='width:95%;padding:0px;' name='"+(cm.index || cm.name)+"' id='gs_"+cm.name+"' value='"+df+"'/>");
if(soptions.attr) {$("input",thd).attr(soptions.attr);}
$.jgrid.bindEv( $("input",thd)[0], soptions, $t);
if(p.autosearch===true){
if(p.searchOnEnter) {
$("input",thd).keypress(function(e){
var key = e.charCode || e.keyCode || 0;
if(key == 13){
triggerToolbar();
return false;
}
return this;
});
} else {
$("input",thd).keydown(function(e){
var key = e.which;
switch (key) {
case 13:
return false;
case 9 :
case 16:
case 37:
case 38:
case 39:
case 40:
case 27:
break;
default :
if(timeoutHnd) { clearTimeout(timeoutHnd); }
timeoutHnd = setTimeout(function(){triggerToolbar();},500);
}
});
}
}
break;
}
}
$(th).append(thd);
$(tr).append(th);
});
$("table thead",$t.grid.hDiv).append(tr);
this.ftoolbar = true;
this.triggerToolbar = triggerToolbar;
this.clearToolbar = clearToolbar;
this.toggleToolbar = toggleToolbar;
});
},
destroyFilterToolbar: function () {
return this.each(function () {
if (!this.ftoolbar) {
return;
}
this.triggerToolbar = null;
this.clearToolbar = null;
this.toggleToolbar = null;
this.ftoolbar = false;
$(this.grid.hDiv).find("table thead tr.ui-search-toolbar").remove();
});
},
destroyGroupHeader : function(nullHeader)
{
if(nullHeader === undefined) {
nullHeader = true;
}
return this.each(function()
{
var $t = this, $tr, i, l, headers, $th, $resizing, grid = $t.grid,
thead = $("table.ui-jqgrid-htable thead", grid.hDiv), cm = $t.p.colModel, hc;
if(!grid) { return; }
$(this).unbind('.setGroupHeaders');
$tr = $("<tr>", {role: "rowheader"}).addClass("ui-jqgrid-labels");
headers = grid.headers;
for (i = 0, l = headers.length; i < l; i++) {
hc = cm[i].hidden ? "none" : "";
$th = $(headers[i].el)
.width(headers[i].width)
.css('display',hc);
try {
$th.removeAttr("rowSpan");
} catch (rs) {
//IE 6/7
$th.attr("rowSpan",1);
}
$tr.append($th);
$resizing = $th.children("span.ui-jqgrid-resize");
if ($resizing.length>0) {// resizable column
$resizing[0].style.height = "";
}
$th.children("div")[0].style.top = "";
}
$(thead).children('tr.ui-jqgrid-labels').remove();
$(thead).prepend($tr);
if(nullHeader === true) {
$($t).jqGrid('setGridParam',{ 'groupHeader': null});
}
});
},
setGroupHeaders : function ( o ) {
o = $.extend({
useColSpanStyle : false,
groupHeaders: []
},o || {});
return this.each(function(){
this.p.groupHeader = o;
var ts = this,
i, cmi, skip = 0, $tr, $colHeader, th, $th, thStyle,
iCol,
cghi,
//startColumnName,
numberOfColumns,
titleText,
cVisibleColumns,
colModel = ts.p.colModel,
cml = colModel.length,
ths = ts.grid.headers,
$htable = $("table.ui-jqgrid-htable", ts.grid.hDiv),
$trLabels = $htable.children("thead").children("tr.ui-jqgrid-labels:last").addClass("jqg-second-row-header"),
$thead = $htable.children("thead"),
$theadInTable,
$firstHeaderRow = $htable.find(".jqg-first-row-header");
if($firstHeaderRow[0] === undefined) {
$firstHeaderRow = $('<tr>', {role: "row", "aria-hidden": "true"}).addClass("jqg-first-row-header").css("height", "auto");
} else {
$firstHeaderRow.empty();
}
var $firstRow,
inColumnHeader = function (text, columnHeaders) {
var length = columnHeaders.length, i;
for (i = 0; i < length; i++) {
if (columnHeaders[i].startColumnName === text) {
return i;
}
}
return -1;
};
$(ts).prepend($thead);
$tr = $('<tr>', {role: "rowheader"}).addClass("ui-jqgrid-labels jqg-third-row-header");
for (i = 0; i < cml; i++) {
th = ths[i].el;
$th = $(th);
cmi = colModel[i];
// build the next cell for the first header row
thStyle = { height: '0px', width: ths[i].width + 'px', display: (cmi.hidden ? 'none' : '')};
$("<th>", {role: 'gridcell'}).css(thStyle).addClass("ui-first-th-"+ts.p.direction).appendTo($firstHeaderRow);
th.style.width = ""; // remove unneeded style
iCol = inColumnHeader(cmi.name, o.groupHeaders);
if (iCol >= 0) {
cghi = o.groupHeaders[iCol];
numberOfColumns = cghi.numberOfColumns;
titleText = cghi.titleText;
// caclulate the number of visible columns from the next numberOfColumns columns
for (cVisibleColumns = 0, iCol = 0; iCol < numberOfColumns && (i + iCol < cml); iCol++) {
if (!colModel[i + iCol].hidden) {
cVisibleColumns++;
}
}
// The next numberOfColumns headers will be moved in the next row
// in the current row will be placed the new column header with the titleText.
// The text will be over the cVisibleColumns columns
$colHeader = $('<th>').attr({role: "columnheader"})
.addClass("ui-state-default ui-th-column-header ui-th-"+ts.p.direction)
.css({'height':'22px', 'border-top': '0px none'})
.html(titleText);
if(cVisibleColumns > 0) {
$colHeader.attr("colspan", String(cVisibleColumns));
}
if (ts.p.headertitles) {
$colHeader.attr("title", $colHeader.text());
}
// hide if not a visible cols
if( cVisibleColumns === 0) {
$colHeader.hide();
}
$th.before($colHeader); // insert new column header before the current
$tr.append(th); // move the current header in the next row
// set the coumter of headers which will be moved in the next row
skip = numberOfColumns - 1;
} else {
if (skip === 0) {
if (o.useColSpanStyle) {
// expand the header height to two rows
$th.attr("rowspan", "2");
} else {
$('<th>', {role: "columnheader"})
.addClass("ui-state-default ui-th-column-header ui-th-"+ts.p.direction)
.css({"display": cmi.hidden ? 'none' : '', 'border-top': '0px none'})
.insertBefore($th);
$tr.append(th);
}
} else {
// move the header to the next row
//$th.css({"padding-top": "2px", height: "19px"});
$tr.append(th);
skip--;
}
}
}
$theadInTable = $(ts).children("thead");
$theadInTable.prepend($firstHeaderRow);
$tr.insertAfter($trLabels);
$htable.append($theadInTable);
if (o.useColSpanStyle) {
// Increase the height of resizing span of visible headers
$htable.find("span.ui-jqgrid-resize").each(function () {
var $parent = $(this).parent();
if ($parent.is(":visible")) {
this.style.cssText = 'height: ' + $parent.height() + 'px !important; cursor: col-resize;';
}
});
// Set position of the sortable div (the main lable)
// with the column header text to the middle of the cell.
// One should not do this for hidden headers.
$htable.find("div.ui-jqgrid-sortable").each(function () {
var $ts = $(this), $parent = $ts.parent();
if ($parent.is(":visible") && $parent.is(":has(span.ui-jqgrid-resize)")) {
$ts.css('top', ($parent.height() - $ts.outerHeight()) / 2 + 'px');
}
});
}
$firstRow = $theadInTable.find("tr.jqg-first-row-header");
$(ts).bind('jqGridResizeStop.setGroupHeaders', function (e, nw, idx) {
$firstRow.find('th').eq(idx).width(nw);
});
});
},
setFrozenColumns : function () {
return this.each(function() {
if ( !this.grid ) {return;}
var $t = this, cm = $t.p.colModel,i=0, len = cm.length, maxfrozen = -1, frozen= false;
// TODO treeGrid and grouping Support
if($t.p.subGrid === true || $t.p.treeGrid === true || $t.p.cellEdit === true || $t.p.sortable || $t.p.scroll || $t.p.grouping )
{
return;
}
if($t.p.rownumbers) { i++; }
if($t.p.multiselect) { i++; }
// get the max index of frozen col
while(i<len)
{
// from left, no breaking frozen
if(cm[i].frozen === true)
{
frozen = true;
maxfrozen = i;
} else {
break;
}
i++;
}
if( maxfrozen>=0 && frozen) {
var top = $t.p.caption ? $($t.grid.cDiv).outerHeight() : 0,
hth = $(".ui-jqgrid-htable","#gview_"+$.jgrid.jqID($t.p.id)).height();
//headers
if($t.p.toppager) {
top = top + $($t.grid.topDiv).outerHeight();
}
if($t.p.toolbar[0] === true) {
if($t.p.toolbar[1] != "bottom") {
top = top + $($t.grid.uDiv).outerHeight();
}
}
$t.grid.fhDiv = $('<div style="position:absolute;left:0px;top:'+top+'px;height:'+hth+'px;" class="frozen-div ui-state-default ui-jqgrid-hdiv"></div>');
$t.grid.fbDiv = $('<div style="position:absolute;left:0px;top:'+(parseInt(top,10)+parseInt(hth,10) + 1)+'px;overflow-y:hidden" class="frozen-bdiv ui-jqgrid-bdiv"></div>');
$("#gview_"+$.jgrid.jqID($t.p.id)).append($t.grid.fhDiv);
var htbl = $(".ui-jqgrid-htable","#gview_"+$.jgrid.jqID($t.p.id)).clone(true);
// groupheader support - only if useColSpanstyle is false
if($t.p.groupHeader) {
$("tr.jqg-first-row-header, tr.jqg-third-row-header", htbl).each(function(){
$("th:gt("+maxfrozen+")",this).remove();
});
var swapfroz = -1, fdel = -1;
$("tr.jqg-second-row-header th", htbl).each(function(){
var cs= parseInt($(this).attr("colspan"),10);
if(cs) {
swapfroz = swapfroz+cs;
fdel++;
}
if(swapfroz === maxfrozen) {
return false;
}
});
if(swapfroz !== maxfrozen) {
fdel = maxfrozen;
}
$("tr.jqg-second-row-header", htbl).each(function(){
$("th:gt("+fdel+")",this).remove();
});
} else {
$("tr",htbl).each(function(){
$("th:gt("+maxfrozen+")",this).remove();
});
}
$(htbl).width(1);
// resizing stuff
$($t.grid.fhDiv).append(htbl)
.mousemove(function (e) {
if($t.grid.resizing){ $t.grid.dragMove(e);return false; }
});
$($t).bind('jqGridResizeStop.setFrozenColumns', function (e, w, index) {
var rhth = $(".ui-jqgrid-htable",$t.grid.fhDiv);
$("th:eq("+index+")",rhth).width( w );
var btd = $(".ui-jqgrid-btable",$t.grid.fbDiv);
$("tr:first td:eq("+index+")",btd).width( w );
});
// sorting stuff
$($t).bind('jqGridOnSortCol.setFrozenColumns', function (index, idxcol) {
var previousSelectedTh = $("tr.ui-jqgrid-labels:last th:eq("+$t.p.lastsort+")",$t.grid.fhDiv), newSelectedTh = $("tr.ui-jqgrid-labels:last th:eq("+idxcol+")",$t.grid.fhDiv);
$("span.ui-grid-ico-sort",previousSelectedTh).addClass('ui-state-disabled');
$(previousSelectedTh).attr("aria-selected","false");
$("span.ui-icon-"+$t.p.sortorder,newSelectedTh).removeClass('ui-state-disabled');
$(newSelectedTh).attr("aria-selected","true");
if(!$t.p.viewsortcols[0]) {
if($t.p.lastsort != idxcol) {
$("span.s-ico",previousSelectedTh).hide();
$("span.s-ico",newSelectedTh).show();
}
}
});
// data stuff
//TODO support for setRowData
$("#gview_"+$.jgrid.jqID($t.p.id)).append($t.grid.fbDiv);
$($t.grid.bDiv).scroll(function () {
$($t.grid.fbDiv).scrollTop($(this).scrollTop());
});
if($t.p.hoverrows === true) {
$("#"+$.jgrid.jqID($t.p.id)).unbind('mouseover').unbind('mouseout');
}
$($t).bind('jqGridAfterGridComplete.setFrozenColumns', function () {
$("#"+$.jgrid.jqID($t.p.id)+"_frozen").remove();
$($t.grid.fbDiv).height($($t.grid.bDiv).height()-16);
var btbl = $("#"+$.jgrid.jqID($t.p.id)).clone(true);
$("tr",btbl).each(function(){
$("td:gt("+maxfrozen+")",this).remove();
});
$(btbl).width(1).attr("id",$t.p.id+"_frozen");
$($t.grid.fbDiv).append(btbl);
if($t.p.hoverrows === true) {
$("tr.jqgrow", btbl).hover(
function(){ $(this).addClass("ui-state-hover"); $("#"+$.jgrid.jqID(this.id), "#"+$.jgrid.jqID($t.p.id)).addClass("ui-state-hover"); },
function(){ $(this).removeClass("ui-state-hover"); $("#"+$.jgrid.jqID(this.id), "#"+$.jgrid.jqID($t.p.id)).removeClass("ui-state-hover"); }
);
$("tr.jqgrow", "#"+$.jgrid.jqID($t.p.id)).hover(
function(){ $(this).addClass("ui-state-hover"); $("#"+$.jgrid.jqID(this.id), "#"+$.jgrid.jqID($t.p.id)+"_frozen").addClass("ui-state-hover");},
function(){ $(this).removeClass("ui-state-hover"); $("#"+$.jgrid.jqID(this.id), "#"+$.jgrid.jqID($t.p.id)+"_frozen").removeClass("ui-state-hover"); }
);
}
btbl=null;
});
$t.p.frozenColumns = true;
}
});
},
destroyFrozenColumns : function() {
return this.each(function() {
if ( !this.grid ) {return;}
if(this.p.frozenColumns === true) {
var $t = this;
$($t.grid.fhDiv).remove();
$($t.grid.fbDiv).remove();
$t.grid.fhDiv = null; $t.grid.fbDiv=null;
$(this).unbind('.setFrozenColumns');
if($t.p.hoverrows === true) {
var ptr;
$("#"+$.jgrid.jqID($t.p.id)).bind('mouseover',function(e) {
ptr = $(e.target).closest("tr.jqgrow");
if($(ptr).attr("class") !== "ui-subgrid") {
$(ptr).addClass("ui-state-hover");
}
}).bind('mouseout',function(e) {
ptr = $(e.target).closest("tr.jqgrow");
$(ptr).removeClass("ui-state-hover");
});
}
this.p.frozenColumns = false;
}
});
}
});
})(jQuery);
| JavaScript |
/*jshint evil:true, eqeqeq:false, eqnull:true, devel:true */
/*global jQuery */
(function($){
/*
**
* jqGrid addons using jQuery UI
* Author: Mark Williams
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl-2.0.html
* depends on jQuery UI
**/
"use strict";
if ($.browser.msie && $.browser.version==8) {
$.expr[":"].hidden = function(elem) {
return elem.offsetWidth === 0 || elem.offsetHeight === 0 ||
elem.style.display == "none";
};
}
// requiere load multiselect before grid
$.jgrid._multiselect = false;
if($.ui) {
if ($.ui.multiselect ) {
if($.ui.multiselect.prototype._setSelected) {
var setSelected = $.ui.multiselect.prototype._setSelected;
$.ui.multiselect.prototype._setSelected = function(item,selected) {
var ret = setSelected.call(this,item,selected);
if (selected && this.selectedList) {
var elt = this.element;
this.selectedList.find('li').each(function() {
if ($(this).data('optionLink')) {
$(this).data('optionLink').remove().appendTo(elt);
}
});
}
return ret;
};
}
if($.ui.multiselect.prototype.destroy) {
$.ui.multiselect.prototype.destroy = function() {
this.element.show();
this.container.remove();
if ($.Widget === undefined) {
$.widget.prototype.destroy.apply(this, arguments);
} else {
$.Widget.prototype.destroy.apply(this, arguments);
}
};
}
$.jgrid._multiselect = true;
}
}
$.jgrid.extend({
sortableColumns : function (tblrow)
{
return this.each(function (){
var ts = this, tid= $.jgrid.jqID( ts.p.id );
function start() {ts.p.disableClick = true;}
var sortable_opts = {
"tolerance" : "pointer",
"axis" : "x",
"scrollSensitivity": "1",
"items": '>th:not(:has(#jqgh_'+tid+'_cb'+',#jqgh_'+tid+'_rn'+',#jqgh_'+tid+'_subgrid),:hidden)',
"placeholder": {
element: function(item) {
var el = $(document.createElement(item[0].nodeName))
.addClass(item[0].className+" ui-sortable-placeholder ui-state-highlight")
.removeClass("ui-sortable-helper")[0];
return el;
},
update: function(self, p) {
p.height(self.currentItem.innerHeight() - parseInt(self.currentItem.css('paddingTop')||0, 10) - parseInt(self.currentItem.css('paddingBottom')||0, 10));
p.width(self.currentItem.innerWidth() - parseInt(self.currentItem.css('paddingLeft')||0, 10) - parseInt(self.currentItem.css('paddingRight')||0, 10));
}
},
"update": function(event, ui) {
var p = $(ui.item).parent(),
th = $(">th", p),
colModel = ts.p.colModel,
cmMap = {}, tid= ts.p.id+"_";
$.each(colModel, function(i) { cmMap[this.name]=i; });
var permutation = [];
th.each(function() {
var id = $(">div", this).get(0).id.replace(/^jqgh_/, "").replace(tid,"");
if (cmMap.hasOwnProperty(id)) {
permutation.push(cmMap[id]);
}
});
$(ts).jqGrid("remapColumns",permutation, true, true);
if ($.isFunction(ts.p.sortable.update)) {
ts.p.sortable.update(permutation);
}
setTimeout(function(){ts.p.disableClick=false;}, 50);
}
};
if (ts.p.sortable.options) {
$.extend(sortable_opts, ts.p.sortable.options);
} else if ($.isFunction(ts.p.sortable)) {
ts.p.sortable = { "update" : ts.p.sortable };
}
if (sortable_opts.start) {
var s = sortable_opts.start;
sortable_opts.start = function(e,ui) {
start();
s.call(this,e,ui);
};
} else {
sortable_opts.start = start;
}
if (ts.p.sortable.exclude) {
sortable_opts.items += ":not("+ts.p.sortable.exclude+")";
}
tblrow.sortable(sortable_opts).data("sortable").floating = true;
});
},
columnChooser : function(opts) {
var self = this;
if($("#colchooser_"+$.jgrid.jqID(self[0].p.id)).length ) { return; }
var selector = $('<div id="colchooser_'+self[0].p.id+'" style="position:relative;overflow:hidden"><div><select multiple="multiple"></select></div></div>');
var select = $('select', selector);
function insert(perm,i,v) {
if(i>=0){
var a = perm.slice();
var b = a.splice(i,Math.max(perm.length-i,i));
if(i>perm.length) { i = perm.length; }
a[i] = v;
return a.concat(b);
}
}
opts = $.extend({
"width" : 420,
"height" : 240,
"classname" : null,
"done" : function(perm) { if (perm) { self.jqGrid("remapColumns", perm, true); } },
/* msel is either the name of a ui widget class that
extends a multiselect, or a function that supports
creating a multiselect object (with no argument,
or when passed an object), and destroying it (when
passed the string "destroy"). */
"msel" : "multiselect",
/* "msel_opts" : {}, */
/* dlog is either the name of a ui widget class that
behaves in a dialog-like way, or a function, that
supports creating a dialog (when passed dlog_opts)
or destroying a dialog (when passed the string
"destroy")
*/
"dlog" : "dialog",
"dialog_opts" : {
"minWidth": 470
},
/* dlog_opts is either an option object to be passed
to "dlog", or (more likely) a function that creates
the options object.
The default produces a suitable options object for
ui.dialog */
"dlog_opts" : function(opts) {
var buttons = {};
buttons[opts.bSubmit] = function() {
opts.apply_perm();
opts.cleanup(false);
};
buttons[opts.bCancel] = function() {
opts.cleanup(true);
};
return $.extend(true, {
"buttons": buttons,
"close": function() {
opts.cleanup(true);
},
"modal" : opts.modal || false,
"resizable": opts.resizable || true,
"width": opts.width+20
}, opts.dialog_opts || {});
},
/* Function to get the permutation array, and pass it to the
"done" function */
"apply_perm" : function() {
$('option',select).each(function() {
if (this.selected) {
self.jqGrid("showCol", colModel[this.value].name);
} else {
self.jqGrid("hideCol", colModel[this.value].name);
}
});
var perm = [];
//fixedCols.slice(0);
$('option:selected',select).each(function() { perm.push(parseInt(this.value,10)); });
$.each(perm, function() { delete colMap[colModel[parseInt(this,10)].name]; });
$.each(colMap, function() {
var ti = parseInt(this,10);
perm = insert(perm,ti,ti);
});
if (opts.done) {
opts.done.call(self, perm);
}
},
/* Function to cleanup the dialog, and select. Also calls the
done function with no permutation (to indicate that the
columnChooser was aborted */
"cleanup" : function(calldone) {
call(opts.dlog, selector, 'destroy');
call(opts.msel, select, 'destroy');
selector.remove();
if (calldone && opts.done) {
opts.done.call(self);
}
},
"msel_opts" : {}
}, $.jgrid.col, opts || {});
if($.ui) {
if ($.ui.multiselect ) {
if(opts.msel == "multiselect") {
if(!$.jgrid._multiselect) {
// should be in language file
alert("Multiselect plugin loaded after jqGrid. Please load the plugin before the jqGrid!");
return;
}
opts.msel_opts = $.extend($.ui.multiselect.defaults,opts.msel_opts);
}
}
}
if (opts.caption) {
selector.attr("title", opts.caption);
}
if (opts.classname) {
selector.addClass(opts.classname);
select.addClass(opts.classname);
}
if (opts.width) {
$(">div",selector).css({"width": opts.width,"margin":"0 auto"});
select.css("width", opts.width);
}
if (opts.height) {
$(">div",selector).css("height", opts.height);
select.css("height", opts.height - 10);
}
var colModel = self.jqGrid("getGridParam", "colModel");
var colNames = self.jqGrid("getGridParam", "colNames");
var colMap = {}, fixedCols = [];
select.empty();
$.each(colModel, function(i) {
colMap[this.name] = i;
if (this.hidedlg) {
if (!this.hidden) {
fixedCols.push(i);
}
return;
}
select.append("<option value='"+i+"' "+
(this.hidden?"":"selected='selected'")+">"+$.jgrid.stripHtml(colNames[i])+"</option>");
});
function call(fn, obj) {
if (!fn) { return; }
if (typeof fn == 'string') {
if ($.fn[fn]) {
$.fn[fn].apply(obj, $.makeArray(arguments).slice(2));
}
} else if ($.isFunction(fn)) {
fn.apply(obj, $.makeArray(arguments).slice(2));
}
}
var dopts = $.isFunction(opts.dlog_opts) ? opts.dlog_opts.call(self, opts) : opts.dlog_opts;
call(opts.dlog, selector, dopts);
var mopts = $.isFunction(opts.msel_opts) ? opts.msel_opts.call(self, opts) : opts.msel_opts;
call(opts.msel, select, mopts);
},
sortableRows : function (opts) {
// Can accept all sortable options and events
return this.each(function(){
var $t = this;
if(!$t.grid) { return; }
// Currently we disable a treeGrid sortable
if($t.p.treeGrid) { return; }
if($.fn.sortable) {
opts = $.extend({
"cursor":"move",
"axis" : "y",
"items": ".jqgrow"
},
opts || {});
if(opts.start && $.isFunction(opts.start)) {
opts._start_ = opts.start;
delete opts.start;
} else {opts._start_=false;}
if(opts.update && $.isFunction(opts.update)) {
opts._update_ = opts.update;
delete opts.update;
} else {opts._update_ = false;}
opts.start = function(ev,ui) {
$(ui.item).css("border-width","0px");
$("td",ui.item).each(function(i){
this.style.width = $t.grid.cols[i].style.width;
});
if($t.p.subGrid) {
var subgid = $(ui.item).attr("id");
try {
$($t).jqGrid('collapseSubGridRow',subgid);
} catch (e) {}
}
if(opts._start_) {
opts._start_.apply(this,[ev,ui]);
}
};
opts.update = function (ev,ui) {
$(ui.item).css("border-width","");
if($t.p.rownumbers === true) {
$("td.jqgrid-rownum",$t.rows).each(function( i ){
$(this).html( i+1+(parseInt($t.p.page,10)-1)*parseInt($t.p.rowNum,10) );
});
}
if(opts._update_) {
opts._update_.apply(this,[ev,ui]);
}
};
$("tbody:first",$t).sortable(opts);
$("tbody:first",$t).disableSelection();
}
});
},
gridDnD : function(opts) {
return this.each(function(){
var $t = this, i, cn;
if(!$t.grid) { return; }
// Currently we disable a treeGrid drag and drop
if($t.p.treeGrid) { return; }
if(!$.fn.draggable || !$.fn.droppable) { return; }
function updateDnD ()
{
var datadnd = $.data($t,"dnd");
$("tr.jqgrow:not(.ui-draggable)",$t).draggable($.isFunction(datadnd.drag) ? datadnd.drag.call($($t),datadnd) : datadnd.drag);
}
var appender = "<table id='jqgrid_dnd' class='ui-jqgrid-dnd'></table>";
if($("#jqgrid_dnd")[0] === undefined) {
$('body').append(appender);
}
if(typeof opts == 'string' && opts == 'updateDnD' && $t.p.jqgdnd===true) {
updateDnD();
return;
}
opts = $.extend({
"drag" : function (opts) {
return $.extend({
start : function (ev, ui) {
var i, subgid;
// if we are in subgrid mode try to collapse the node
if($t.p.subGrid) {
subgid = $(ui.helper).attr("id");
try {
$($t).jqGrid('collapseSubGridRow',subgid);
} catch (e) {}
}
// hack
// drag and drop does not insert tr in table, when the table has no rows
// we try to insert new empty row on the target(s)
for (i=0;i<$.data($t,"dnd").connectWith.length;i++){
if($($.data($t,"dnd").connectWith[i]).jqGrid('getGridParam','reccount') == "0" ){
$($.data($t,"dnd").connectWith[i]).jqGrid('addRowData','jqg_empty_row',{});
}
}
ui.helper.addClass("ui-state-highlight");
$("td",ui.helper).each(function(i) {
this.style.width = $t.grid.headers[i].width+"px";
});
if(opts.onstart && $.isFunction(opts.onstart) ) { opts.onstart.call($($t),ev,ui); }
},
stop :function(ev,ui) {
var i, ids;
if(ui.helper.dropped && !opts.dragcopy) {
ids = $(ui.helper).attr("id");
if(ids === undefined) { ids = $(this).attr("id"); }
$($t).jqGrid('delRowData',ids );
}
// if we have a empty row inserted from start event try to delete it
for (i=0;i<$.data($t,"dnd").connectWith.length;i++){
$($.data($t,"dnd").connectWith[i]).jqGrid('delRowData','jqg_empty_row');
}
if(opts.onstop && $.isFunction(opts.onstop) ) { opts.onstop.call($($t),ev,ui); }
}
},opts.drag_opts || {});
},
"drop" : function (opts) {
return $.extend({
accept: function(d) {
if (!$(d).hasClass('jqgrow')) { return d;}
var tid = $(d).closest("table.ui-jqgrid-btable");
if(tid.length > 0 && $.data(tid[0],"dnd") !== undefined) {
var cn = $.data(tid[0],"dnd").connectWith;
return $.inArray('#'+$.jgrid.jqID(this.id),cn) != -1 ? true : false;
}
return false;
},
drop: function(ev, ui) {
if (!$(ui.draggable).hasClass('jqgrow')) { return; }
var accept = $(ui.draggable).attr("id");
var getdata = ui.draggable.parent().parent().jqGrid('getRowData',accept);
if(!opts.dropbyname) {
var j =0, tmpdata = {}, nm, key;
var dropmodel = $("#"+$.jgrid.jqID(this.id)).jqGrid('getGridParam','colModel');
try {
for (key in getdata) {
if (getdata.hasOwnProperty(key)) {
nm = dropmodel[j].name;
if( !(nm == 'cb' || nm =='rn' || nm == 'subgrid' )) {
if(getdata.hasOwnProperty(key) && dropmodel[j]) {
tmpdata[nm] = getdata[key];
}
}
j++;
}
}
getdata = tmpdata;
} catch (e) {}
}
ui.helper.dropped = true;
if(opts.beforedrop && $.isFunction(opts.beforedrop) ) {
//parameters to this callback - event, element, data to be inserted, sender, reciever
// should return object which will be inserted into the reciever
var datatoinsert = opts.beforedrop.call(this,ev,ui,getdata,$('#'+$.jgrid.jqID($t.p.id)),$(this));
if (datatoinsert !== undefined && datatoinsert !== null && typeof datatoinsert == "object") { getdata = datatoinsert; }
}
if(ui.helper.dropped) {
var grid;
if(opts.autoid) {
if($.isFunction(opts.autoid)) {
grid = opts.autoid.call(this,getdata);
} else {
grid = Math.ceil(Math.random()*1000);
grid = opts.autoidprefix+grid;
}
}
// NULL is interpreted as undefined while null as object
$("#"+$.jgrid.jqID(this.id)).jqGrid('addRowData',grid,getdata,opts.droppos);
}
if(opts.ondrop && $.isFunction(opts.ondrop) ) { opts.ondrop.call(this,ev,ui, getdata); }
}}, opts.drop_opts || {});
},
"onstart" : null,
"onstop" : null,
"beforedrop": null,
"ondrop" : null,
"drop_opts" : {
"activeClass": "ui-state-active",
"hoverClass": "ui-state-hover"
},
"drag_opts" : {
"revert": "invalid",
"helper": "clone",
"cursor": "move",
"appendTo" : "#jqgrid_dnd",
"zIndex": 5000
},
"dragcopy": false,
"dropbyname" : false,
"droppos" : "first",
"autoid" : true,
"autoidprefix" : "dnd_"
}, opts || {});
if(!opts.connectWith) { return; }
opts.connectWith = opts.connectWith.split(",");
opts.connectWith = $.map(opts.connectWith,function(n){return $.trim(n);});
$.data($t,"dnd",opts);
if($t.p.reccount != "0" && !$t.p.jqgdnd) {
updateDnD();
}
$t.p.jqgdnd = true;
for (i=0;i<opts.connectWith.length;i++){
cn =opts.connectWith[i];
$(cn).droppable($.isFunction(opts.drop) ? opts.drop.call($($t),opts) : opts.drop);
}
});
},
gridResize : function(opts) {
return this.each(function(){
var $t = this, gID = $.jgrid.jqID($t.p.id);
if(!$t.grid || !$.fn.resizable) { return; }
opts = $.extend({}, opts || {});
if(opts.alsoResize ) {
opts._alsoResize_ = opts.alsoResize;
delete opts.alsoResize;
} else {
opts._alsoResize_ = false;
}
if(opts.stop && $.isFunction(opts.stop)) {
opts._stop_ = opts.stop;
delete opts.stop;
} else {
opts._stop_ = false;
}
opts.stop = function (ev, ui) {
$($t).jqGrid('setGridParam',{height:$("#gview_"+gID+" .ui-jqgrid-bdiv").height()});
$($t).jqGrid('setGridWidth',ui.size.width,opts.shrinkToFit);
if(opts._stop_) { opts._stop_.call($t,ev,ui); }
};
if(opts._alsoResize_) {
var optstest = "{\'#gview_"+gID+" .ui-jqgrid-bdiv\':true,'" +opts._alsoResize_+"':true}";
opts.alsoResize = eval('('+optstest+')'); // the only way that I found to do this
} else {
opts.alsoResize = $(".ui-jqgrid-bdiv","#gview_"+gID);
}
delete opts._alsoResize_;
$("#gbox_"+gID).resizable(opts);
});
}
});
})(jQuery);
| JavaScript |
/*
**
* formatter for values but most of the values if for jqGrid
* Some of this was inspired and based on how YUI does the table datagrid but in jQuery fashion
* we are trying to keep it as light as possible
* Joshua Burnett josh@9ci.com
* http://www.greenbill.com
*
* Changes from Tony Tomov tony@trirand.com
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl-2.0.html
*
**/
/*jshint eqeqeq:false */
/*global jQuery */
(function($) {
"use strict";
$.fmatter = {};
//opts can be id:row id for the row, rowdata:the data for the row, colmodel:the column model for this column
//example {id:1234,}
$.extend($.fmatter,{
isBoolean : function(o) {
return typeof o === 'boolean';
},
isObject : function(o) {
return (o && (typeof o === 'object' || $.isFunction(o))) || false;
},
isString : function(o) {
return typeof o === 'string';
},
isNumber : function(o) {
return typeof o === 'number' && isFinite(o);
},
isNull : function(o) {
return o === null;
},
isUndefined : function(o) {
return o === undefined;
},
isValue : function (o) {
return (this.isObject(o) || this.isString(o) || this.isNumber(o) || this.isBoolean(o));
},
isEmpty : function(o) {
if(!this.isString(o) && this.isValue(o)) {
return false;
}
if (!this.isValue(o)){
return true;
}
o = $.trim(o).replace(/\ \;/ig,'').replace(/\ \;/ig,'');
return o==="";
}
});
$.fn.fmatter = function(formatType, cellval, opts, rwd, act) {
// build main options before element iteration
var v=cellval;
opts = $.extend({}, $.jgrid.formatter, opts);
try {
v = $.fn.fmatter[formatType].call(this, cellval, opts, rwd, act);
} catch(fe){}
return v;
};
$.fmatter.util = {
// Taken from YAHOO utils
NumberFormat : function(nData,opts) {
if(!$.fmatter.isNumber(nData)) {
nData *= 1;
}
if($.fmatter.isNumber(nData)) {
var bNegative = (nData < 0);
var sOutput = String(nData);
var sDecimalSeparator = opts.decimalSeparator || ".";
var nDotIndex;
if($.fmatter.isNumber(opts.decimalPlaces)) {
// Round to the correct decimal place
var nDecimalPlaces = opts.decimalPlaces;
var nDecimal = Math.pow(10, nDecimalPlaces);
sOutput = String(Math.round(nData*nDecimal)/nDecimal);
nDotIndex = sOutput.lastIndexOf(".");
if(nDecimalPlaces > 0) {
// Add the decimal separator
if(nDotIndex < 0) {
sOutput += sDecimalSeparator;
nDotIndex = sOutput.length-1;
}
// Replace the "."
else if(sDecimalSeparator !== "."){
sOutput = sOutput.replace(".",sDecimalSeparator);
}
// Add missing zeros
while((sOutput.length - 1 - nDotIndex) < nDecimalPlaces) {
sOutput += "0";
}
}
}
if(opts.thousandsSeparator) {
var sThousandsSeparator = opts.thousandsSeparator;
nDotIndex = sOutput.lastIndexOf(sDecimalSeparator);
nDotIndex = (nDotIndex > -1) ? nDotIndex : sOutput.length;
var sNewOutput = sOutput.substring(nDotIndex);
var nCount = -1, i;
for (i=nDotIndex; i>0; i--) {
nCount++;
if ((nCount%3 === 0) && (i !== nDotIndex) && (!bNegative || (i > 1))) {
sNewOutput = sThousandsSeparator + sNewOutput;
}
sNewOutput = sOutput.charAt(i-1) + sNewOutput;
}
sOutput = sNewOutput;
}
// Prepend prefix
sOutput = (opts.prefix) ? opts.prefix + sOutput : sOutput;
// Append suffix
sOutput = (opts.suffix) ? sOutput + opts.suffix : sOutput;
return sOutput;
}
return nData;
},
// Tony Tomov
// PHP implementation. Sorry not all options are supported.
// Feel free to add them if you want
DateFormat : function (format, date, newformat, opts) {
var token = /\\.|[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]/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,
msDateRegExp = new RegExp("^\/Date\\((([-+])?[0-9]+)(([-+])([0-9]{2})([0-9]{2}))?\\)\/$"),
msMatch = ((typeof date === 'string') ? date.match(msDateRegExp): null),
pad = function (value, length) {
value = String(value);
length = parseInt(length,10) || 2;
while (value.length < length) { value = '0' + value; }
return value;
},
ts = {m : 1, d : 1, y : 1970, h : 0, i : 0, s : 0, u:0},
timestamp=0, dM, k,hl,
dateFormat=["i18n"];
// Internationalization strings
dateFormat.i18n = {
dayNames: opts.dayNames,
monthNames: opts.monthNames
};
if( opts.masks.hasOwnProperty(format) ) { format = opts.masks[format]; }
if( !isNaN( date - 0 ) && String(format).toLowerCase() == "u") {
//Unix timestamp
timestamp = new Date( parseFloat(date)*1000 );
} else if(date.constructor === Date) {
timestamp = date;
// Microsoft date format support
} else if( msMatch !== null ) {
timestamp = new Date(parseInt(msMatch[1], 10));
if (msMatch[3]) {
var offset = Number(msMatch[5]) * 60 + Number(msMatch[6]);
offset *= ((msMatch[4] == '-') ? 1 : -1);
offset -= timestamp.getTimezoneOffset();
timestamp.setTime(Number(Number(timestamp) + (offset * 60 * 1000)));
}
} else {
date = String(date).split(/[\\\/:_;.,\t\T\s-]/);
format = format.split(/[\\\/:_;.,\t\T\s-]/);
// parsing for month names
for(k=0,hl=format.length;k<hl;k++){
if(format[k] == 'M') {
dM = $.inArray(date[k],dateFormat.i18n.monthNames);
if(dM !== -1 && dM < 12){date[k] = dM+1;}
}
if(format[k] == 'F') {
dM = $.inArray(date[k],dateFormat.i18n.monthNames);
if(dM !== -1 && dM > 11){date[k] = dM+1-12;}
}
if(date[k]) {
ts[format[k].toLowerCase()] = parseInt(date[k],10);
}
}
if(ts.f) {ts.m = ts.f;}
if( ts.m === 0 && ts.y === 0 && ts.d === 0) {
return " " ;
}
ts.m = parseInt(ts.m,10)-1;
var ty = ts.y;
if (ty >= 70 && ty <= 99) {ts.y = 1900+ts.y;}
else if (ty >=0 && ty <=69) {ts.y= 2000+ts.y;}
timestamp = new Date(ts.y, ts.m, ts.d, ts.h, ts.i, ts.s, ts.u);
}
if( opts.masks.hasOwnProperty(newformat) ) {
newformat = opts.masks[newformat];
} else if ( !newformat ) {
newformat = 'Y-m-d';
}
var
G = timestamp.getHours(),
i = timestamp.getMinutes(),
j = timestamp.getDate(),
n = timestamp.getMonth() + 1,
o = timestamp.getTimezoneOffset(),
s = timestamp.getSeconds(),
u = timestamp.getMilliseconds(),
w = timestamp.getDay(),
Y = timestamp.getFullYear(),
N = (w + 6) % 7 + 1,
z = (new Date(Y, n - 1, j) - new Date(Y, 0, 1)) / 86400000,
flags = {
// Day
d: pad(j),
D: dateFormat.i18n.dayNames[w],
j: j,
l: dateFormat.i18n.dayNames[w + 7],
N: N,
S: opts.S(j),
//j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th',
w: w,
z: z,
// Week
W: N < 5 ? Math.floor((z + N - 1) / 7) + 1 : Math.floor((z + N - 1) / 7) || ((new Date(Y - 1, 0, 1).getDay() + 6) % 7 < 4 ? 53 : 52),
// Month
F: dateFormat.i18n.monthNames[n - 1 + 12],
m: pad(n),
M: dateFormat.i18n.monthNames[n - 1],
n: n,
t: '?',
// Year
L: '?',
o: '?',
Y: Y,
y: String(Y).substring(2),
// Time
a: G < 12 ? opts.AmPm[0] : opts.AmPm[1],
A: G < 12 ? opts.AmPm[2] : opts.AmPm[3],
B: '?',
g: G % 12 || 12,
G: G,
h: pad(G % 12 || 12),
H: pad(G),
i: pad(i),
s: pad(s),
u: u,
// Timezone
e: '?',
I: '?',
O: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
P: '?',
T: (String(timestamp).match(timezone) || [""]).pop().replace(timezoneClip, ""),
Z: '?',
// Full Date/Time
c: '?',
r: '?',
U: Math.floor(timestamp / 1000)
};
return newformat.replace(token, function ($0) {
return flags.hasOwnProperty($0) ? flags[$0] : $0.substring(1);
});
}
};
$.fn.fmatter.defaultFormat = function(cellval, opts) {
return ($.fmatter.isValue(cellval) && cellval!=="" ) ? cellval : opts.defaultValue || " ";
};
$.fn.fmatter.email = function(cellval, opts) {
if(!$.fmatter.isEmpty(cellval)) {
return "<a href=\"mailto:" + cellval + "\">" + cellval + "</a>";
}
return $.fn.fmatter.defaultFormat(cellval,opts );
};
$.fn.fmatter.checkbox =function(cval, opts) {
var op = $.extend({},opts.checkbox), ds;
if(opts.colModel !== undefined && !$.fmatter.isUndefined(opts.colModel.formatoptions)) {
op = $.extend({},op,opts.colModel.formatoptions);
}
if(op.disabled===true) {ds = "disabled=\"disabled\"";} else {ds="";}
if($.fmatter.isEmpty(cval) || $.fmatter.isUndefined(cval) ) {cval = $.fn.fmatter.defaultFormat(cval,op);}
cval=String(cval);
cval=cval.toLowerCase();
var bchk = cval.search(/(false|0|no|n|off)/i)<0 ? " checked='checked' " : "";
return "<input type=\"checkbox\" " + bchk + " value=\""+ cval+"\" offval=\"no\" "+ds+ "/>";
};
$.fn.fmatter.link = function(cellval, opts) {
var op = {target:opts.target};
var target = "";
if(opts.colModel !== undefined && !$.fmatter.isUndefined(opts.colModel.formatoptions)) {
op = $.extend({},op,opts.colModel.formatoptions);
}
if(op.target) {target = 'target=' + op.target;}
if(!$.fmatter.isEmpty(cellval)) {
return "<a "+target+" href=\"" + cellval + "\">" + cellval + "</a>";
}
return $.fn.fmatter.defaultFormat(cellval,opts);
};
$.fn.fmatter.showlink = function(cellval, opts) {
var op = {baseLinkUrl: opts.baseLinkUrl,showAction:opts.showAction, addParam: opts.addParam || "", target: opts.target, idName: opts.idName},
target = "", idUrl;
if(opts.colModel !== undefined && !$.fmatter.isUndefined(opts.colModel.formatoptions)) {
op = $.extend({},op,opts.colModel.formatoptions);
}
if(op.target) {target = 'target=' + op.target;}
idUrl = op.baseLinkUrl+op.showAction + '?'+ op.idName+'='+opts.rowId+op.addParam;
if($.fmatter.isString(cellval) || $.fmatter.isNumber(cellval)) { //add this one even if its blank string
return "<a "+target+" href=\"" + idUrl + "\">" + cellval + "</a>";
}
return $.fn.fmatter.defaultFormat(cellval,opts);
};
$.fn.fmatter.integer = function(cellval, opts) {
var op = $.extend({},opts.integer);
if(opts.colModel !== undefined && !$.fmatter.isUndefined(opts.colModel.formatoptions)) {
op = $.extend({},op,opts.colModel.formatoptions);
}
if($.fmatter.isEmpty(cellval)) {
return op.defaultValue;
}
return $.fmatter.util.NumberFormat(cellval,op);
};
$.fn.fmatter.number = function (cellval, opts) {
var op = $.extend({},opts.number);
if(opts.colModel !== undefined && !$.fmatter.isUndefined(opts.colModel.formatoptions)) {
op = $.extend({},op,opts.colModel.formatoptions);
}
if($.fmatter.isEmpty(cellval)) {
return op.defaultValue;
}
return $.fmatter.util.NumberFormat(cellval,op);
};
$.fn.fmatter.currency = function (cellval, opts) {
var op = $.extend({},opts.currency);
if(opts.colModel !== undefined && !$.fmatter.isUndefined(opts.colModel.formatoptions)) {
op = $.extend({},op,opts.colModel.formatoptions);
}
if($.fmatter.isEmpty(cellval)) {
return op.defaultValue;
}
return $.fmatter.util.NumberFormat(cellval,op);
};
$.fn.fmatter.date = function (cellval, opts, rwd, act) {
var op = $.extend({},opts.date);
if(opts.colModel !== undefined && !$.fmatter.isUndefined(opts.colModel.formatoptions)) {
op = $.extend({},op,opts.colModel.formatoptions);
}
if(!op.reformatAfterEdit && act=='edit'){
return $.fn.fmatter.defaultFormat(cellval, opts);
}
if(!$.fmatter.isEmpty(cellval)) {
return $.fmatter.util.DateFormat(op.srcformat,cellval,op.newformat,op);
}
return $.fn.fmatter.defaultFormat(cellval, opts);
};
$.fn.fmatter.select = function (cellval,opts) {
// jqGrid specific
cellval = String(cellval);
var oSelect = false, ret=[], sep, delim;
if(!$.fmatter.isUndefined(opts.colModel.formatoptions)){
oSelect= opts.colModel.formatoptions.value;
sep = opts.colModel.formatoptions.separator === undefined ? ":" : opts.colModel.formatoptions.separator;
delim = opts.colModel.formatoptions.delimiter === undefined ? ";" : opts.colModel.formatoptions.delimiter;
} else if(!$.fmatter.isUndefined(opts.colModel.editoptions)){
oSelect= opts.colModel.editoptions.value;
sep = opts.colModel.editoptions.separator === undefined ? ":" : opts.colModel.editoptions.separator;
delim = opts.colModel.editoptions.delimiter === undefined ? ";" : opts.colModel.editoptions.delimiter;
}
if (oSelect) {
var msl = opts.colModel.editoptions.multiple === true ? true : false,
scell = [], sv;
if(msl) {scell = cellval.split(",");scell = $.map(scell,function(n){return $.trim(n);});}
if ($.fmatter.isString(oSelect)) {
// mybe here we can use some caching with care ????
var so = oSelect.split(delim), j=0, i;
for(i=0; i<so.length;i++){
sv = so[i].split(sep);
if(sv.length > 2 ) {
sv[1] = $.map(sv,function(n,i){if(i>0) {return n;}}).join(sep);
}
if(msl) {
if($.inArray(sv[0],scell)>-1) {
ret[j] = sv[1];
j++;
}
} else if($.trim(sv[0])==$.trim(cellval)) {
ret[0] = sv[1];
break;
}
}
} else if($.fmatter.isObject(oSelect)) {
// this is quicker
if(msl) {
ret = $.map(scell, function(n){
return oSelect[n];
});
} else {
ret[0] = oSelect[cellval] || "";
}
}
}
cellval = ret.join(", ");
return cellval === "" ? $.fn.fmatter.defaultFormat(cellval,opts) : cellval;
};
$.fn.fmatter.rowactions = function(act) {
var $tr = $(this).closest("tr.jqgrow"),
$actionsDiv = $(this).parent(),
rid = $tr.attr("id"),
$grid = $(this).closest("table.ui-jqgrid-btable"),
$t = $grid[0],
p = $t.p,
cm = p.colModel[$.jgrid.getCellIndex(this)],
op = {
keys: false,
onEdit: null,
onSuccess: null,
afterSave: null,
onError: null,
afterRestore: null,
extraparam: {},
url: null,
restoreAfterError: true,
mtype: "POST",
delOptions: {},
editOptions: {}
},
saverow = function(rowid, res) {
if($.isFunction(op.afterSave)) { op.afterSave.call($t, rowid, res); }
$actionsDiv.find("div.ui-inline-edit,div.ui-inline-del").show();
$actionsDiv.find("div.ui-inline-save,div.ui-inline-cancel").hide();
},
restorerow = function(rowid) {
if($.isFunction(op.afterRestore)) { op.afterRestore.call($t, rowid); }
$actionsDiv.find("div.ui-inline-edit,div.ui-inline-del").show();
$actionsDiv.find("div.ui-inline-save,div.ui-inline-cancel").hide();
};
if (!$.fmatter.isUndefined(cm.formatoptions)) {
op = $.extend(op,cm.formatoptions);
}
if (!$.fmatter.isUndefined(p.editOptions)) {
op.editOptions = p.editOptions;
}
if (!$.fmatter.isUndefined(p.delOptions)) {
op.delOptions = p.delOptions;
}
if ($tr.hasClass("jqgrid-new-row")){
op.extraparam[p.prmNames.oper] = p.prmNames.addoper;
}
var actop = {
keys: op.keys,
oneditfunc: op.onEdit,
successfunc: op.onSuccess,
url: op.url,
extraparam: op.extraparam,
aftersavefunc: saverow,
errorfunc: op.onError,
afterrestorefunc: restorerow,
restoreAfterError: op.restoreAfterError,
mtype: op.mtype
};
switch(act)
{
case 'edit':
$grid.jqGrid('editRow', rid, actop);
$actionsDiv.find("div.ui-inline-edit,div.ui-inline-del").hide();
$actionsDiv.find("div.ui-inline-save,div.ui-inline-cancel").show();
$grid.triggerHandler("jqGridAfterGridComplete");
break;
case 'save':
if ($grid.jqGrid('saveRow', rid, actop)) {
$actionsDiv.find("div.ui-inline-edit,div.ui-inline-del").show();
$actionsDiv.find("div.ui-inline-save,div.ui-inline-cancel").hide();
$grid.triggerHandler("jqGridAfterGridComplete");
}
break;
case 'cancel' :
$grid.jqGrid('restoreRow', rid, restorerow);
$actionsDiv.find("div.ui-inline-edit,div.ui-inline-del").show();
$actionsDiv.find("div.ui-inline-save,div.ui-inline-cancel").hide();
$grid.triggerHandler("jqGridAfterGridComplete");
break;
case 'del':
$grid.jqGrid('delGridRow', rid, op.delOptions);
break;
case 'formedit':
$grid.jqGrid('setSelection', rid);
$grid.jqGrid('editGridRow', rid, op.editOptions);
break;
}
};
$.fn.fmatter.actions = function(cellval,opts) {
var op={keys:false, editbutton:true, delbutton:true, editformbutton: false},
rowid=opts.rowId, str="",ocl;
if(!$.fmatter.isUndefined(opts.colModel.formatoptions)) {
op = $.extend(op,opts.colModel.formatoptions);
}
if(rowid === undefined || $.fmatter.isEmpty(rowid)) {return "";}
if(op.editformbutton){
ocl = "onclick=jQuery.fn.fmatter.rowactions.call(this,'formedit'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover'); ";
str += "<div title='"+$.jgrid.nav.edittitle+"' style='float:left;cursor:pointer;' class='ui-pg-div ui-inline-edit' "+ocl+"><span class='ui-icon ui-icon-pencil'></span></div>";
} else if(op.editbutton){
ocl = "onclick=jQuery.fn.fmatter.rowactions.call(this,'edit'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover') ";
str += "<div title='"+$.jgrid.nav.edittitle+"' style='float:left;cursor:pointer;' class='ui-pg-div ui-inline-edit' "+ocl+"><span class='ui-icon ui-icon-pencil'></span></div>";
}
if(op.delbutton) {
ocl = "onclick=jQuery.fn.fmatter.rowactions.call(this,'del'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover'); ";
str += "<div title='"+$.jgrid.nav.deltitle+"' style='float:left;margin-left:5px;' class='ui-pg-div ui-inline-del' "+ocl+"><span class='ui-icon ui-icon-trash'></span></div>";
}
ocl = "onclick=jQuery.fn.fmatter.rowactions.call(this,'save'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover'); ";
str += "<div title='"+$.jgrid.edit.bSubmit+"' style='float:left;display:none' class='ui-pg-div ui-inline-save' "+ocl+"><span class='ui-icon ui-icon-disk'></span></div>";
ocl = "onclick=jQuery.fn.fmatter.rowactions.call(this,'cancel'); onmouseover=jQuery(this).addClass('ui-state-hover'); onmouseout=jQuery(this).removeClass('ui-state-hover'); ";
str += "<div title='"+$.jgrid.edit.bCancel+"' style='float:left;display:none;margin-left:5px;' class='ui-pg-div ui-inline-cancel' "+ocl+"><span class='ui-icon ui-icon-cancel'></span></div>";
return "<div style='margin-left:8px;'>" + str + "</div>";
};
$.unformat = function (cellval,options,pos,cnt) {
// specific for jqGrid only
var ret, formatType = options.colModel.formatter,
op =options.colModel.formatoptions || {}, sep,
re = /([\.\*\_\'\(\)\{\}\+\?\\])/g,
unformatFunc = options.colModel.unformat||($.fn.fmatter[formatType] && $.fn.fmatter[formatType].unformat);
if(unformatFunc !== undefined && $.isFunction(unformatFunc) ) {
ret = unformatFunc.call(this, $(cellval).text(), options, cellval);
} else if(!$.fmatter.isUndefined(formatType) && $.fmatter.isString(formatType) ) {
var opts = $.jgrid.formatter || {}, stripTag;
switch(formatType) {
case 'integer' :
op = $.extend({},opts.integer,op);
sep = op.thousandsSeparator.replace(re,"\\$1");
stripTag = new RegExp(sep, "g");
ret = $(cellval).text().replace(stripTag,'');
break;
case 'number' :
op = $.extend({},opts.number,op);
sep = op.thousandsSeparator.replace(re,"\\$1");
stripTag = new RegExp(sep, "g");
ret = $(cellval).text().replace(stripTag,"").replace(op.decimalSeparator,'.');
break;
case 'currency':
op = $.extend({},opts.currency,op);
sep = op.thousandsSeparator.replace(re,"\\$1");
stripTag = new RegExp(sep, "g");
ret = $(cellval).text();
if (op.prefix && op.prefix.length) {
ret = ret.substr(op.prefix.length);
}
if (op.suffix && op.suffix.length) {
ret = ret.substr(0, ret.length - op.suffix.length);
}
ret = ret.replace(stripTag,'').replace(op.decimalSeparator,'.');
break;
case 'checkbox':
var cbv = (options.colModel.editoptions) ? options.colModel.editoptions.value.split(":") : ["Yes","No"];
ret = $('input',cellval).is(":checked") ? cbv[0] : cbv[1];
break;
case 'select' :
ret = $.unformat.select(cellval,options,pos,cnt);
break;
case 'actions':
return "";
default:
ret= $(cellval).text();
}
}
return ret !== undefined ? ret : cnt===true ? $(cellval).text() : $.jgrid.htmlDecode($(cellval).html());
};
$.unformat.select = function (cellval,options,pos,cnt) {
// Spacial case when we have local data and perform a sort
// cnt is set to true only in sortDataArray
var ret = [];
var cell = $(cellval).text();
if(cnt===true) {return cell;}
var op = $.extend({}, !$.fmatter.isUndefined(options.colModel.formatoptions) ? options.colModel.formatoptions: options.colModel.editoptions),
sep = op.separator === undefined ? ":" : op.separator,
delim = op.delimiter === undefined ? ";" : op.delimiter;
if(op.value){
var oSelect = op.value,
msl = op.multiple === true ? true : false,
scell = [], sv;
if(msl) {scell = cell.split(",");scell = $.map(scell,function(n){return $.trim(n);});}
if ($.fmatter.isString(oSelect)) {
var so = oSelect.split(delim), j=0, i;
for(i=0; i<so.length;i++){
sv = so[i].split(sep);
if(sv.length > 2 ) {
sv[1] = $.map(sv,function(n,i){if(i>0) {return n;}}).join(sep);
}
if(msl) {
if($.inArray(sv[1],scell)>-1) {
ret[j] = sv[0];
j++;
}
} else if($.trim(sv[1])==$.trim(cell)) {
ret[0] = sv[0];
break;
}
}
} else if($.fmatter.isObject(oSelect) || $.isArray(oSelect) ){
if(!msl) {scell[0] = cell;}
ret = $.map(scell, function(n){
var rv;
$.each(oSelect, function(i,val){
if (val == n) {
rv = i;
return false;
}
});
if( rv !== undefined ) {return rv;}
});
}
return ret.join(", ");
}
return cell || "";
};
$.unformat.date = function (cellval, opts) {
var op = $.jgrid.formatter.date || {};
if(!$.fmatter.isUndefined(opts.formatoptions)) {
op = $.extend({},op,opts.formatoptions);
}
if(!$.fmatter.isEmpty(cellval)) {
return $.fmatter.util.DateFormat(op.newformat,cellval,op.srcformat,op);
}
return $.fn.fmatter.defaultFormat(cellval, opts);
};
})(jQuery);
| JavaScript |
/*
* jqDnR - Minimalistic Drag'n'Resize for jQuery.
*
* Copyright (c) 2007 Brice Burgess <bhb@iceburg.net>, http://www.iceburg.net
* Licensed under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
* $Version: 2007.08.19 +r2
*/
(function($){
$.fn.jqDrag=function(h){return i(this,h,'d');};
$.fn.jqResize=function(h,ar){return i(this,h,'r',ar);};
$.jqDnR={
dnr:{},
e:0,
drag:function(v){
if(M.k == 'd'){E.css({left:M.X+v.pageX-M.pX,top:M.Y+v.pageY-M.pY});}
else {
E.css({width:Math.max(v.pageX-M.pX+M.W,0),height:Math.max(v.pageY-M.pY+M.H,0)});
if(M1){E1.css({width:Math.max(v.pageX-M1.pX+M1.W,0),height:Math.max(v.pageY-M1.pY+M1.H,0)});}
}
return false;
},
stop:function(){
//E.css('opacity',M.o);
$(document).unbind('mousemove',J.drag).unbind('mouseup',J.stop);
}
};
var J=$.jqDnR,M=J.dnr,E=J.e,E1,M1,
i=function(e,h,k,aR){
return e.each(function(){
h=(h)?$(h,e):e;
h.bind('mousedown',{e:e,k:k},function(v){
var d=v.data,p={};E=d.e;E1 = aR ? $(aR) : false;
// attempt utilization of dimensions plugin to fix IE issues
if(E.css('position') != 'relative'){try{E.position(p);}catch(e){}}
M={
X:p.left||f('left')||0,
Y:p.top||f('top')||0,
W:f('width')||E[0].scrollWidth||0,
H:f('height')||E[0].scrollHeight||0,
pX:v.pageX,
pY:v.pageY,
k:d.k
//o:E.css('opacity')
};
// also resize
if(E1 && d.k != 'd'){
M1={
X:p.left||f1('left')||0,
Y:p.top||f1('top')||0,
W:E1[0].offsetWidth||f1('width')||0,
H:E1[0].offsetHeight||f1('height')||0,
pX:v.pageX,
pY:v.pageY,
k:d.k
};
} else {M1 = false;}
//E.css({opacity:0.8});
if($("input.hasDatepicker",E[0])[0]) {
try {$("input.hasDatepicker",E[0]).datepicker('hide');}catch (dpe){}
}
$(document).mousemove($.jqDnR.drag).mouseup($.jqDnR.stop);
return false;
});
});
},
f=function(k){return parseInt(E.css(k),10)||false;},
f1=function(k){return parseInt(E1.css(k),10)||false;};
})(jQuery); | JavaScript |
/*jshint eqeqeq:false, eqnull:true, devel:true */
/*global jQuery */
(function($){
/**
* jqGrid extension for manipulating Grid Data
* Tony Tomov tony@trirand.com
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl-2.0.html
**/
"use strict";
$.jgrid.inlineEdit = $.jgrid.inlineEdit || {};
$.jgrid.extend({
//Editing
editRow : function(rowid,keys,oneditfunc,successfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc) {
// Compatible mode old versions
var o={}, args = $.makeArray(arguments).slice(1);
if( $.type(args[0]) === "object" ) {
o = args[0];
} else {
if (keys !== undefined) { o.keys = keys; }
if ($.isFunction(oneditfunc)) { o.oneditfunc = oneditfunc; }
if ($.isFunction(successfunc)) { o.successfunc = successfunc; }
if (url !== undefined) { o.url = url; }
if (extraparam !== undefined) { o.extraparam = extraparam; }
if ($.isFunction(aftersavefunc)) { o.aftersavefunc = aftersavefunc; }
if ($.isFunction(errorfunc)) { o.errorfunc = errorfunc; }
if ($.isFunction(afterrestorefunc)) { o.afterrestorefunc = afterrestorefunc; }
// last two not as param, but as object (sorry)
//if (restoreAfterError !== undefined) { o.restoreAfterError = restoreAfterError; }
//if (mtype !== undefined) { o.mtype = mtype || "POST"; }
}
o = $.extend(true, {
keys : false,
oneditfunc: null,
successfunc: null,
url: null,
extraparam: {},
aftersavefunc: null,
errorfunc: null,
afterrestorefunc: null,
restoreAfterError: true,
mtype: "POST"
}, $.jgrid.inlineEdit, o );
// End compatible
return this.each(function(){
var $t = this, nm, tmp, editable, cnt=0, focus=null, svr={}, ind,cm;
if (!$t.grid ) { return; }
ind = $($t).jqGrid("getInd",rowid,true);
if( ind === false ) {return;}
editable = $(ind).attr("editable") || "0";
if (editable == "0" && !$(ind).hasClass("not-editable-row")) {
cm = $t.p.colModel;
$('td[role="gridcell"]',ind).each( function(i) {
nm = cm[i].name;
var treeg = $t.p.treeGrid===true && nm == $t.p.ExpandColumn;
if(treeg) { tmp = $("span:first",this).html();}
else {
try {
tmp = $.unformat.call($t,this,{rowId:rowid, colModel:cm[i]},i);
} catch (_) {
tmp = ( cm[i].edittype && cm[i].edittype == 'textarea' ) ? $(this).text() : $(this).html();
}
}
if ( nm != 'cb' && nm != 'subgrid' && nm != 'rn') {
if($t.p.autoencode) { tmp = $.jgrid.htmlDecode(tmp); }
svr[nm]=tmp;
if(cm[i].editable===true) {
if(focus===null) { focus = i; }
if (treeg) { $("span:first",this).html(""); }
else { $(this).html(""); }
var opt = $.extend({},cm[i].editoptions || {},{id:rowid+"_"+nm,name:nm});
if(!cm[i].edittype) { cm[i].edittype = "text"; }
if(tmp == " " || tmp == " " || (tmp.length==1 && tmp.charCodeAt(0)==160) ) {tmp='';}
var elc = $.jgrid.createEl.call($t,cm[i].edittype,opt,tmp,true,$.extend({},$.jgrid.ajaxOptions,$t.p.ajaxSelectOptions || {}));
$(elc).addClass("editable");
if(treeg) { $("span:first",this).append(elc); }
else { $(this).append(elc); }
$.jgrid.bindEv( elc, opt, $t);
//Again IE
if(cm[i].edittype == "select" && cm[i].editoptions!==undefined && cm[i].editoptions.multiple===true && cm[i].editoptions.dataUrl===undefined && $.browser.msie) {
$(elc).width($(elc).width());
}
cnt++;
}
}
});
if(cnt > 0) {
svr.id = rowid; $t.p.savedRow.push(svr);
$(ind).attr("editable","1");
$("td:eq("+focus+") input",ind).focus();
if(o.keys===true) {
$(ind).bind("keydown",function(e) {
if (e.keyCode === 27) {
$($t).jqGrid("restoreRow",rowid, o.afterrestorefunc);
if($t.p._inlinenav) {
try {
$($t).jqGrid('showAddEditButtons');
} catch (eer1) {}
}
return false;
}
if (e.keyCode === 13) {
var ta = e.target;
if(ta.tagName == 'TEXTAREA') { return true; }
if( $($t).jqGrid("saveRow", rowid, o ) ) {
if($t.p._inlinenav) {
try {
$($t).jqGrid('showAddEditButtons');
} catch (eer2) {}
}
}
return false;
}
});
}
$($t).triggerHandler("jqGridInlineEditRow", [rowid, o]);
if( $.isFunction(o.oneditfunc)) { o.oneditfunc.call($t, rowid); }
}
}
});
},
saveRow : function(rowid, successfunc, url, extraparam, aftersavefunc,errorfunc, afterrestorefunc) {
// Compatible mode old versions
var args = $.makeArray(arguments).slice(1), o = {};
if( $.type(args[0]) === "object" ) {
o = args[0];
} else {
if ($.isFunction(successfunc)) { o.successfunc = successfunc; }
if (url !== undefined) { o.url = url; }
if (extraparam !== undefined) { o.extraparam = extraparam; }
if ($.isFunction(aftersavefunc)) { o.aftersavefunc = aftersavefunc; }
if ($.isFunction(errorfunc)) { o.errorfunc = errorfunc; }
if ($.isFunction(afterrestorefunc)) { o.afterrestorefunc = afterrestorefunc; }
}
o = $.extend(true, {
successfunc: null,
url: null,
extraparam: {},
aftersavefunc: null,
errorfunc: null,
afterrestorefunc: null,
restoreAfterError: true,
mtype: "POST"
}, $.jgrid.inlineEdit, o );
// End compatible
var success = false;
var $t = this[0], nm, tmp={}, tmp2={}, tmp3= {}, editable, fr, cv, ind;
if (!$t.grid ) { return success; }
ind = $($t).jqGrid("getInd",rowid,true);
if(ind === false) {return success;}
editable = $(ind).attr("editable");
o.url = o.url || $t.p.editurl;
if (editable==="1") {
var cm;
$('td[role="gridcell"]',ind).each(function(i) {
cm = $t.p.colModel[i];
nm = cm.name;
if ( nm != 'cb' && nm != 'subgrid' && cm.editable===true && nm != 'rn' && !$(this).hasClass('not-editable-cell')) {
switch (cm.edittype) {
case "checkbox":
var cbv = ["Yes","No"];
if(cm.editoptions ) {
cbv = cm.editoptions.value.split(":");
}
tmp[nm]= $("input",this).is(":checked") ? cbv[0] : cbv[1];
break;
case 'text':
case 'password':
case 'textarea':
case "button" :
tmp[nm]=$("input, textarea",this).val();
break;
case 'select':
if(!cm.editoptions.multiple) {
tmp[nm] = $("select option:selected",this).val();
tmp2[nm] = $("select option:selected", this).text();
} else {
var sel = $("select",this), selectedText = [];
tmp[nm] = $(sel).val();
if(tmp[nm]) { tmp[nm]= tmp[nm].join(","); } else { tmp[nm] =""; }
$("select option:selected",this).each(
function(i,selected){
selectedText[i] = $(selected).text();
}
);
tmp2[nm] = selectedText.join(",");
}
if(cm.formatter && cm.formatter == 'select') { tmp2={}; }
break;
case 'custom' :
try {
if(cm.editoptions && $.isFunction(cm.editoptions.custom_value)) {
tmp[nm] = cm.editoptions.custom_value.call($t, $(".customelement",this),'get');
if (tmp[nm] === undefined) { throw "e2"; }
} else { throw "e1"; }
} catch (e) {
if (e=="e1") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.nodefined,$.jgrid.edit.bClose); }
if (e=="e2") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.novalue,$.jgrid.edit.bClose); }
else { $.jgrid.info_dialog($.jgrid.errors.errcap,e.message,$.jgrid.edit.bClose); }
}
break;
}
cv = $.jgrid.checkValues(tmp[nm],i,$t);
if(cv[0] === false) {
cv[1] = tmp[nm] + " " + cv[1];
return false;
}
if($t.p.autoencode) { tmp[nm] = $.jgrid.htmlEncode(tmp[nm]); }
if(o.url !== 'clientArray' && cm.editoptions && cm.editoptions.NullIfEmpty === true) {
if(tmp[nm] === "") {
tmp3[nm] = 'null';
}
}
}
});
if (cv[0] === false){
try {
var positions = $.jgrid.findPos($("#"+$.jgrid.jqID(rowid), $t.grid.bDiv)[0]);
$.jgrid.info_dialog($.jgrid.errors.errcap,cv[1],$.jgrid.edit.bClose,{left:positions[0],top:positions[1]});
} catch (e) {
alert(cv[1]);
}
return success;
}
var idname, opers = $t.p.prmNames, oldRowId = rowid;
if ($t.p.keyIndex === false) {
idname = opers.id;
} else {
idname = $t.p.colModel[$t.p.keyIndex +
($t.p.rownumbers === true ? 1 : 0) +
($t.p.multiselect === true ? 1 : 0) +
($t.p.subGrid === true ? 1 : 0)].name;
}
if(tmp) {
tmp[opers.oper] = opers.editoper;
if (tmp[idname] === undefined) {
tmp[idname] = rowid;
} else if (ind.id !== $t.p.idPrefix + tmp[idname]) {
// rename rowid
var oldid = $.jgrid.stripPref($t.p.idPrefix, rowid);
if ($t.p._index[oldid] !== undefined) {
$t.p._index[tmp[idname]] = $t.p._index[oldid];
delete $t.p._index[oldid];
}
rowid = $t.p.idPrefix + tmp[idname];
$(ind).attr("id", rowid);
if ($t.p.selrow === oldRowId) {
$t.p.selrow = rowid;
}
if ($.isArray($t.p.selarrrow)) {
var i = $.inArray(oldRowId, $t.p.selarrrow);
if (i>=0) {
$t.p.selarrrow[i] = rowid;
}
}
if ($t.p.multiselect) {
var newCboxId = "jqg_" + $t.p.id + "_" + rowid;
$("input.cbox",ind)
.attr("id", newCboxId)
.attr("name", newCboxId);
}
// TODO: to test the case of frozen columns
}
if($t.p.inlineData === undefined) { $t.p.inlineData ={}; }
tmp = $.extend({},tmp,$t.p.inlineData,o.extraparam);
}
if (o.url == 'clientArray') {
tmp = $.extend({},tmp, tmp2);
if($t.p.autoencode) {
$.each(tmp,function(n,v){
tmp[n] = $.jgrid.htmlDecode(v);
});
}
var k, resp = $($t).jqGrid("setRowData",rowid,tmp);
$(ind).attr("editable","0");
for(k=0;k<$t.p.savedRow.length;k++) {
if( $t.p.savedRow[k].id == oldRowId) {fr = k; break;}
}
if(fr >= 0) { $t.p.savedRow.splice(fr,1); }
$($t).triggerHandler("jqGridInlineAfterSaveRow", [rowid, resp, tmp, o]);
if( $.isFunction(o.aftersavefunc) ) { o.aftersavefunc.call($t, rowid,resp, o); }
success = true;
$(ind).unbind("keydown");
} else {
$("#lui_"+$.jgrid.jqID($t.p.id)).show();
tmp3 = $.extend({},tmp,tmp3);
tmp3[idname] = $.jgrid.stripPref($t.p.idPrefix, tmp3[idname]);
$.ajax($.extend({
url:o.url,
data: $.isFunction($t.p.serializeRowData) ? $t.p.serializeRowData.call($t, tmp3) : tmp3,
type: o.mtype,
async : false, //?!?
complete: function(res,stat){
$("#lui_"+$.jgrid.jqID($t.p.id)).hide();
if (stat === "success"){
var ret = true, sucret, k;
sucret = $($t).triggerHandler("jqGridInlineSuccessSaveRow", [res, rowid, o]);
if (!$.isArray(sucret)) {sucret = [true, tmp];}
if (sucret[0] && $.isFunction(o.successfunc)) {sucret = o.successfunc.call($t, res);}
if($.isArray(sucret)) {
// expect array - status, data, rowid
ret = sucret[0];
tmp = sucret[1] || tmp;
} else {
ret = sucret;
}
if (ret===true) {
if($t.p.autoencode) {
$.each(tmp,function(n,v){
tmp[n] = $.jgrid.htmlDecode(v);
});
}
tmp = $.extend({},tmp, tmp2);
$($t).jqGrid("setRowData",rowid,tmp);
$(ind).attr("editable","0");
for(k=0;k<$t.p.savedRow.length;k++) {
if( $t.p.savedRow[k].id == rowid) {fr = k; break;}
}
if(fr >= 0) { $t.p.savedRow.splice(fr,1); }
$($t).triggerHandler("jqGridInlineAfterSaveRow", [rowid, res, tmp, o]);
if( $.isFunction(o.aftersavefunc) ) { o.aftersavefunc.call($t, rowid,res); }
success = true;
$(ind).unbind("keydown");
} else {
$($t).triggerHandler("jqGridInlineErrorSaveRow", [rowid, res, stat, null, o]);
if($.isFunction(o.errorfunc) ) {
o.errorfunc.call($t, rowid, res, stat, null);
}
if(o.restoreAfterError === true) {
$($t).jqGrid("restoreRow",rowid, o.afterrestorefunc);
}
}
}
},
error:function(res,stat,err){
$("#lui_"+$.jgrid.jqID($t.p.id)).hide();
$($t).triggerHandler("jqGridInlineErrorSaveRow", [rowid, res, stat, err, o]);
if($.isFunction(o.errorfunc) ) {
o.errorfunc.call($t, rowid, res, stat, err);
} else {
var rT = res.responseText || res.statusText;
try {
$.jgrid.info_dialog($.jgrid.errors.errcap,'<div class="ui-state-error">'+ rT +'</div>', $.jgrid.edit.bClose,{buttonalign:'right'});
} catch(e) {
alert(rT);
}
}
if(o.restoreAfterError === true) {
$($t).jqGrid("restoreRow",rowid, o.afterrestorefunc);
}
}
}, $.jgrid.ajaxOptions, $t.p.ajaxRowOptions || {}));
}
}
return success;
},
restoreRow : function(rowid, afterrestorefunc) {
// Compatible mode old versions
var args = $.makeArray(arguments).slice(1), o={};
if( $.type(args[0]) === "object" ) {
o = args[0];
} else {
if ($.isFunction(afterrestorefunc)) { o.afterrestorefunc = afterrestorefunc; }
}
o = $.extend(true, $.jgrid.inlineEdit, o );
// End compatible
return this.each(function(){
var $t= this, fr, ind, ares={}, k;
if (!$t.grid ) { return; }
ind = $($t).jqGrid("getInd",rowid,true);
if(ind === false) {return;}
for(k=0;k<$t.p.savedRow.length;k++) {
if( $t.p.savedRow[k].id == rowid) {fr = k; break;}
}
if(fr >= 0) {
if($.isFunction($.fn.datepicker)) {
try {
$("input.hasDatepicker","#"+$.jgrid.jqID(ind.id)).datepicker('hide');
} catch (e) {}
}
$.each($t.p.colModel, function(){
if(this.editable === true && $t.p.savedRow[fr].hasOwnProperty(this.name)) {
ares[this.name] = $t.p.savedRow[fr][this.name];
}
});
$($t).jqGrid("setRowData",rowid,ares);
$(ind).attr("editable","0").unbind("keydown");
$t.p.savedRow.splice(fr,1);
if($("#"+$.jgrid.jqID(rowid), "#"+$.jgrid.jqID($t.p.id)).hasClass("jqgrid-new-row")){
setTimeout(function(){$($t).jqGrid("delRowData",rowid);},0);
}
}
$($t).triggerHandler("jqGridInlineAfterRestoreRow", [rowid]);
if ($.isFunction(o.afterrestorefunc))
{
o.afterrestorefunc.call($t, rowid);
}
});
},
addRow : function ( p ) {
p = $.extend(true, {
rowID : null,
initdata : {},
position :"first",
useDefValues : true,
useFormatter : false,
addRowParams : {extraparam:{}}
},p || {});
return this.each(function(){
if (!this.grid ) { return; }
var $t = this;
p.rowID = $.isFunction(p.rowID) ? p.rowID.call($t, p) : ( (p.rowID != null) ? p.rowID : $.jgrid.randId());
if(p.useDefValues === true) {
$($t.p.colModel).each(function(){
if( this.editoptions && this.editoptions.defaultValue ) {
var opt = this.editoptions.defaultValue,
tmp = $.isFunction(opt) ? opt.call($t) : opt;
p.initdata[this.name] = tmp;
}
});
}
$($t).jqGrid('addRowData', p.rowID, p.initdata, p.position);
p.rowID = $t.p.idPrefix + p.rowID;
$("#"+$.jgrid.jqID(p.rowID), "#"+$.jgrid.jqID($t.p.id)).addClass("jqgrid-new-row");
if(p.useFormatter) {
$("#"+$.jgrid.jqID(p.rowID)+" .ui-inline-edit", "#"+$.jgrid.jqID($t.p.id)).click();
} else {
var opers = $t.p.prmNames,
oper = opers.oper;
p.addRowParams.extraparam[oper] = opers.addoper;
$($t).jqGrid('editRow', p.rowID, p.addRowParams);
$($t).jqGrid('setSelection', p.rowID);
}
});
},
inlineNav : function (elem, o) {
o = $.extend({
edit: true,
editicon: "ui-icon-pencil",
add: true,
addicon:"ui-icon-plus",
save: true,
saveicon:"ui-icon-disk",
cancel: true,
cancelicon:"ui-icon-cancel",
addParams : {},
editParams : {},
restoreAfterSelect : true
}, $.jgrid.nav, o ||{});
return this.each(function(){
if (!this.grid ) { return; }
var $t = this, onSelect, gID = $.jgrid.jqID($t.p.id);
$t.p._inlinenav = true;
// detect the formatactions column
if(o.addParams.useFormatter === true) {
var cm = $t.p.colModel,i;
for (i = 0; i<cm.length; i++) {
if(cm[i].formatter && cm[i].formatter === "actions" ) {
if(cm[i].formatoptions) {
var defaults = {
keys:false,
onEdit : null,
onSuccess: null,
afterSave:null,
onError: null,
afterRestore: null,
extraparam: {},
url: null
},
ap = $.extend( defaults, cm[i].formatoptions );
o.addParams.addRowParams = {
"keys" : ap.keys,
"oneditfunc" : ap.onEdit,
"successfunc" : ap.onSuccess,
"url" : ap.url,
"extraparam" : ap.extraparam,
"aftersavefunc" : ap.afterSavef,
"errorfunc": ap.onError,
"afterrestorefunc" : ap.afterRestore
};
}
break;
}
}
}
if(o.add) {
$($t).jqGrid('navButtonAdd', elem,{
caption : o.addtext,
title : o.addtitle,
buttonicon : o.addicon,
id : $t.p.id+"_iladd",
onClickButton : function () {
$($t).jqGrid('addRow', o.addParams);
if(!o.addParams.useFormatter) {
$("#"+gID+"_ilsave").removeClass('ui-state-disabled');
$("#"+gID+"_ilcancel").removeClass('ui-state-disabled');
$("#"+gID+"_iladd").addClass('ui-state-disabled');
$("#"+gID+"_iledit").addClass('ui-state-disabled');
}
}
});
}
if(o.edit) {
$($t).jqGrid('navButtonAdd', elem,{
caption : o.edittext,
title : o.edittitle,
buttonicon : o.editicon,
id : $t.p.id+"_iledit",
onClickButton : function () {
var sr = $($t).jqGrid('getGridParam','selrow');
if(sr) {
$($t).jqGrid('editRow', sr, o.editParams);
$("#"+gID+"_ilsave").removeClass('ui-state-disabled');
$("#"+gID+"_ilcancel").removeClass('ui-state-disabled');
$("#"+gID+"_iladd").addClass('ui-state-disabled');
$("#"+gID+"_iledit").addClass('ui-state-disabled');
} else {
$.jgrid.viewModal("#alertmod",{gbox:"#gbox_"+gID,jqm:true});$("#jqg_alrt").focus();
}
}
});
}
if(o.save) {
$($t).jqGrid('navButtonAdd', elem,{
caption : o.savetext || '',
title : o.savetitle || 'Save row',
buttonicon : o.saveicon,
id : $t.p.id+"_ilsave",
onClickButton : function () {
var sr = $t.p.savedRow[0].id;
if(sr) {
var opers = $t.p.prmNames,
oper = opers.oper;
if(!o.editParams.extraparam) {
o.editParams.extraparam = {};
}
if($("#"+$.jgrid.jqID(sr), "#"+gID ).hasClass("jqgrid-new-row")) {
o.editParams.extraparam[oper] = opers.addoper;
} else {
o.editParams.extraparam[oper] = opers.editoper;
}
if( $($t).jqGrid('saveRow', sr, o.editParams) ) {
$($t).jqGrid('showAddEditButtons');
}
} else {
$.jgrid.viewModal("#alertmod",{gbox:"#gbox_"+gID,jqm:true});$("#jqg_alrt").focus();
}
}
});
$("#"+gID+"_ilsave").addClass('ui-state-disabled');
}
if(o.cancel) {
$($t).jqGrid('navButtonAdd', elem,{
caption : o.canceltext || '',
title : o.canceltitle || 'Cancel row editing',
buttonicon : o.cancelicon,
id : $t.p.id+"_ilcancel",
onClickButton : function () {
var sr = $t.p.savedRow[0].id;
if(sr) {
$($t).jqGrid('restoreRow', sr, o.editParams);
$($t).jqGrid('showAddEditButtons');
} else {
$.jgrid.viewModal("#alertmod",{gbox:"#gbox_"+gID,jqm:true});$("#jqg_alrt").focus();
}
}
});
$("#"+gID+"_ilcancel").addClass('ui-state-disabled');
}
if(o.restoreAfterSelect === true) {
if($.isFunction($t.p.beforeSelectRow)) {
onSelect = $t.p.beforeSelectRow;
} else {
onSelect = false;
}
$t.p.beforeSelectRow = function(id, stat) {
var ret = true;
if($t.p.savedRow.length > 0 && $t.p._inlinenav===true && ( id !== $t.p.selrow && $t.p.selrow !==null) ) {
if($t.p.selrow == o.addParams.rowID ) {
$($t).jqGrid('delRowData', $t.p.selrow);
} else {
$($t).jqGrid('restoreRow', $t.p.selrow, o.editParams);
}
$($t).jqGrid('showAddEditButtons');
}
if(onSelect) {
ret = onSelect.call($t, id, stat);
}
return ret;
};
}
});
},
showAddEditButtons : function() {
return this.each(function(){
if (!this.grid ) { return; }
var gID = $.jgrid.jqID(this.p.id);
$("#"+gID+"_ilsave").addClass('ui-state-disabled');
$("#"+gID+"_ilcancel").addClass('ui-state-disabled');
$("#"+gID+"_iladd").removeClass('ui-state-disabled');
$("#"+gID+"_iledit").removeClass('ui-state-disabled');
});
}
//end inline edit
});
})(jQuery);
| JavaScript |
/*jshint eqeqeq:false, eqnull:true, devel:true */
/*global xmlJsonClass, jQuery */
(function($){
/**
* jqGrid extension for form editing Grid Data
* Tony Tomov tony@trirand.com
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl-2.0.html
**/
"use strict";
var rp_ge = {};
$.jgrid.extend({
searchGrid : function (p) {
p = $.extend(true, {
recreateFilter: false,
drag: true,
sField:'searchField',
sValue:'searchString',
sOper: 'searchOper',
sFilter: 'filters',
loadDefaults: true, // this options activates loading of default filters from grid's postData for Multipe Search only.
beforeShowSearch: null,
afterShowSearch : null,
onInitializeSearch: null,
afterRedraw : null,
afterChange: null,
closeAfterSearch : false,
closeAfterReset: false,
closeOnEscape : false,
searchOnEnter : false,
multipleSearch : false,
multipleGroup : false,
//cloneSearchRowOnAdd: true,
top : 0,
left: 0,
jqModal : true,
modal: false,
resize : true,
width: 450,
height: 'auto',
dataheight: 'auto',
showQuery: false,
errorcheck : true,
// translation
// if you want to change or remove the order change it in sopt
// ['eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc'],
sopt: null,
stringResult: undefined,
onClose : null,
onSearch : null,
onReset : null,
toTop : true,
overlay : 30,
columns : [],
tmplNames : null,
tmplFilters : null,
// translations - later in lang file
tmplLabel : ' Template: ',
showOnLoad: false,
layer: null
}, $.jgrid.search, p || {});
return this.each(function() {
var $t = this;
if(!$t.grid) {return;}
var fid = "fbox_"+$t.p.id,
showFrm = true,
IDs = {themodal:'searchmod'+fid,modalhead:'searchhd'+fid,modalcontent:'searchcnt'+fid, scrollelm : fid},
defaultFilters = $t.p.postData[p.sFilter];
if(typeof defaultFilters === "string") {
defaultFilters = $.jgrid.parse( defaultFilters );
}
if(p.recreateFilter === true) {
$("#"+$.jgrid.jqID(IDs.themodal)).remove();
}
function showFilter(_filter) {
showFrm = $($t).triggerHandler("jqGridFilterBeforeShow", [_filter]);
if(showFrm === undefined) {
showFrm = true;
}
if(showFrm && $.isFunction(p.beforeShowSearch)) {
showFrm = p.beforeShowSearch.call($t,_filter);
}
if(showFrm) {
$.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(fid),jqm:p.jqModal, modal:p.modal, overlay: p.overlay, toTop: p.toTop});
$($t).triggerHandler("jqGridFilterAfterShow", [_filter]);
if($.isFunction(p.afterShowSearch)) {
p.afterShowSearch.call($t, _filter);
}
}
}
if ( $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined ) {
showFilter($("#fbox_"+$.jgrid.jqID(+$t.p.id)));
} else {
var fil = $("<div><div id='"+fid+"' class='searchFilter' style='overflow:auto'></div></div>").insertBefore("#gview_"+$.jgrid.jqID($t.p.id)),
align = "left", butleft ="";
if($t.p.direction == "rtl") {
align = "right";
butleft = " style='text-align:left'";
fil.attr("dir","rtl");
}
var columns = $.extend([],$t.p.colModel),
bS ="<a href='javascript:void(0)' id='"+fid+"_search' class='fm-button ui-state-default ui-corner-all fm-button-icon-right ui-reset'><span class='ui-icon ui-icon-search'></span>"+p.Find+"</a>",
bC ="<a href='javascript:void(0)' id='"+fid+"_reset' class='fm-button ui-state-default ui-corner-all fm-button-icon-left ui-search'><span class='ui-icon ui-icon-arrowreturnthick-1-w'></span>"+p.Reset+"</a>",
bQ = "", tmpl="", colnm, found = false, bt, cmi=-1;
if(p.showQuery) {
bQ ="<a href='javascript:void(0)' id='"+fid+"_query' class='fm-button ui-state-default ui-corner-all fm-button-icon-left'><span class='ui-icon ui-icon-comment'></span>Query</a>";
}
if(!p.columns.length) {
$.each(columns, function(i,n){
if(!n.label) {
n.label = $t.p.colNames[i];
}
// find first searchable column and set it if no default filter
if(!found) {
var searchable = (n.search === undefined) ? true: n.search ,
hidden = (n.hidden === true),
ignoreHiding = (n.searchoptions && n.searchoptions.searchhidden === true);
if ((ignoreHiding && searchable) || (searchable && !hidden)) {
found = true;
colnm = n.index || n.name;
cmi =i;
}
}
});
} else {
columns = p.columns;
}
// old behaviour
if( (!defaultFilters && colnm) || p.multipleSearch === false ) {
var cmop = "eq";
if(cmi >=0 && columns[cmi].searchoptions && columns[cmi].searchoptions.sopt) {
cmop = columns[cmi].searchoptions.sopt[0];
} else if(p.sopt && p.sopt.length) {
cmop = p.sopt[0];
}
defaultFilters = {"groupOp": "AND",rules:[{"field":colnm,"op":cmop,"data":""}]};
}
found = false;
if(p.tmplNames && p.tmplNames.length) {
found = true;
tmpl = p.tmplLabel;
tmpl += "<select class='ui-template'>";
tmpl += "<option value='default'>Default</option>";
$.each(p.tmplNames, function(i,n){
tmpl += "<option value='"+i+"'>"+n+"</option>";
});
tmpl += "</select>";
}
bt = "<table class='EditTable' style='border:0px none;margin-top:5px' id='"+fid+"_2'><tbody><tr><td colspan='2'><hr class='ui-widget-content' style='margin:1px'/></td></tr><tr><td class='EditButton' style='text-align:"+align+"'>"+bC+tmpl+"</td><td class='EditButton' "+butleft+">"+bQ+bS+"</td></tr></tbody></table>";
fid = $.jgrid.jqID( fid);
$("#"+fid).jqFilter({
columns : columns,
filter: p.loadDefaults ? defaultFilters : null,
showQuery: p.showQuery,
errorcheck : p.errorcheck,
sopt: p.sopt,
groupButton : p.multipleGroup,
ruleButtons : p.multipleSearch,
afterRedraw : p.afterRedraw,
_gridsopt : $.jgrid.search.odata,
ajaxSelectOptions: $t.p.ajaxSelectOptions,
groupOps: p.groupOps,
onChange : function() {
if(this.p.showQuery) {
$('.query',this).html(this.toUserFriendlyString());
}
if ($.isFunction(p.afterChange)) {
p.afterChange.call($t, $("#"+fid), p);
}
},
direction : $t.p.direction
});
fil.append( bt );
if(found && p.tmplFilters && p.tmplFilters.length) {
$(".ui-template", fil).bind('change', function(){
var curtempl = $(this).val();
if(curtempl=="default") {
$("#"+fid).jqFilter('addFilter', defaultFilters);
} else {
$("#"+fid).jqFilter('addFilter', p.tmplFilters[parseInt(curtempl,10)]);
}
return false;
});
}
if(p.multipleGroup === true) {p.multipleSearch = true;}
$($t).triggerHandler("jqGridFilterInitialize", [$("#"+fid)]);
if($.isFunction(p.onInitializeSearch) ) {
p.onInitializeSearch.call($t, $("#"+fid));
}
p.gbox = "#gbox_"+fid;
if (p.layer) {
$.jgrid.createModal(IDs ,fil,p,"#gview_"+$.jgrid.jqID($t.p.id),$("#gbox_"+$.jgrid.jqID($t.p.id))[0], "#"+$.jgrid.jqID(p.layer), {position: "relative"});
} else {
$.jgrid.createModal(IDs ,fil,p,"#gview_"+$.jgrid.jqID($t.p.id),$("#gbox_"+$.jgrid.jqID($t.p.id))[0]);
}
if (p.searchOnEnter || p.closeOnEscape) {
$("#"+$.jgrid.jqID(IDs.themodal)).keydown(function (e) {
var $target = $(e.target);
if (p.searchOnEnter && e.which === 13 && // 13 === $.ui.keyCode.ENTER
!$target.hasClass('add-group') && !$target.hasClass('add-rule') &&
!$target.hasClass('delete-group') && !$target.hasClass('delete-rule') &&
(!$target.hasClass("fm-button") || !$target.is("[id$=_query]"))) {
$("#"+fid+"_search").focus().click();
return false;
}
if (p.closeOnEscape && e.which === 27) { // 27 === $.ui.keyCode.ESCAPE
$("#"+$.jgrid.jqID(IDs.modalhead)).find(".ui-jqdialog-titlebar-close").focus().click();
return false;
}
});
}
if(bQ) {
$("#"+fid+"_query").bind('click', function(){
$(".queryresult", fil).toggle();
return false;
});
}
if (p.stringResult===undefined) {
// to provide backward compatibility, inferring stringResult value from multipleSearch
p.stringResult = p.multipleSearch;
}
$("#"+fid+"_search").bind('click', function(){
var fl = $("#"+fid),
sdata={}, res ,
filters = fl.jqFilter('filterData');
if(p.errorcheck) {
fl[0].hideError();
if(!p.showQuery) {fl.jqFilter('toSQLString');}
if(fl[0].p.error) {
fl[0].showError();
return false;
}
}
if(p.stringResult) {
try {
// xmlJsonClass or JSON.stringify
res = xmlJsonClass.toJson(filters, '', '', false);
} catch (e) {
try {
res = JSON.stringify(filters);
} catch (e2) { }
}
if(typeof res==="string") {
sdata[p.sFilter] = res;
$.each([p.sField,p.sValue, p.sOper], function() {sdata[this] = "";});
}
} else {
if(p.multipleSearch) {
sdata[p.sFilter] = filters;
$.each([p.sField,p.sValue, p.sOper], function() {sdata[this] = "";});
} else {
sdata[p.sField] = filters.rules[0].field;
sdata[p.sValue] = filters.rules[0].data;
sdata[p.sOper] = filters.rules[0].op;
sdata[p.sFilter] = "";
}
}
$t.p.search = true;
$.extend($t.p.postData,sdata);
$($t).triggerHandler("jqGridFilterSearch");
if($.isFunction(p.onSearch) ) {
p.onSearch.call($t);
}
$($t).trigger("reloadGrid",[{page:1}]);
if(p.closeAfterSearch) {
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID($t.p.id),jqm:p.jqModal,onClose: p.onClose});
}
return false;
});
$("#"+fid+"_reset").bind('click', function(){
var sdata={},
fl = $("#"+fid);
$t.p.search = false;
if(p.multipleSearch===false) {
sdata[p.sField] = sdata[p.sValue] = sdata[p.sOper] = "";
} else {
sdata[p.sFilter] = "";
}
fl[0].resetFilter();
if(found) {
$(".ui-template", fil).val("default");
}
$.extend($t.p.postData,sdata);
$($t).triggerHandler("jqGridFilterReset");
if($.isFunction(p.onReset) ) {
p.onReset.call($t);
}
$($t).trigger("reloadGrid",[{page:1}]);
return false;
});
showFilter($("#"+fid));
$(".fm-button:not(.ui-state-disabled)",fil).hover(
function(){$(this).addClass('ui-state-hover');},
function(){$(this).removeClass('ui-state-hover');}
);
}
});
},
editGridRow : function(rowid, p){
p = $.extend(true, {
top : 0,
left: 0,
width: 300,
height: 'auto',
dataheight: 'auto',
modal: false,
overlay : 30,
drag: true,
resize: true,
url: null,
mtype : "POST",
clearAfterAdd :true,
closeAfterEdit : false,
reloadAfterSubmit : true,
onInitializeForm: null,
beforeInitData: null,
beforeShowForm: null,
afterShowForm: null,
beforeSubmit: null,
afterSubmit: null,
onclickSubmit: null,
afterComplete: null,
onclickPgButtons : null,
afterclickPgButtons: null,
editData : {},
recreateForm : false,
jqModal : true,
closeOnEscape : false,
addedrow : "first",
topinfo : '',
bottominfo: '',
saveicon : [],
closeicon : [],
savekey: [false,13],
navkeys: [false,38,40],
checkOnSubmit : false,
checkOnUpdate : false,
_savedData : {},
processing : false,
onClose : null,
ajaxEditOptions : {},
serializeEditData : null,
viewPagerButtons : true
}, $.jgrid.edit, p || {});
rp_ge[$(this)[0].p.id] = p;
return this.each(function(){
var $t = this;
if (!$t.grid || !rowid) {return;}
var gID = $t.p.id,
frmgr = "FrmGrid_"+gID, frmtborg = "TblGrid_"+gID, frmtb = "#"+$.jgrid.jqID(frmtborg),
IDs = {themodal:'editmod'+gID,modalhead:'edithd'+gID,modalcontent:'editcnt'+gID, scrollelm : frmgr},
onBeforeShow = $.isFunction(rp_ge[$t.p.id].beforeShowForm) ? rp_ge[$t.p.id].beforeShowForm : false,
onAfterShow = $.isFunction(rp_ge[$t.p.id].afterShowForm) ? rp_ge[$t.p.id].afterShowForm : false,
onBeforeInit = $.isFunction(rp_ge[$t.p.id].beforeInitData) ? rp_ge[$t.p.id].beforeInitData : false,
onInitializeForm = $.isFunction(rp_ge[$t.p.id].onInitializeForm) ? rp_ge[$t.p.id].onInitializeForm : false,
showFrm = true,
maxCols = 1, maxRows=0, postdata, extpost, newData, diff, frmoper;
frmgr = $.jgrid.jqID(frmgr);
if (rowid === "new") {
rowid = "_empty";
frmoper = "add";
p.caption=rp_ge[$t.p.id].addCaption;
} else {
p.caption=rp_ge[$t.p.id].editCaption;
frmoper = "edit";
}
if(p.recreateForm===true && $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined) {
$("#"+$.jgrid.jqID(IDs.themodal)).remove();
}
var closeovrl = true;
if(p.checkOnUpdate && p.jqModal && !p.modal) {
closeovrl = false;
}
function getFormData(){
$(frmtb+" > tbody > tr > td > .FormElement").each(function() {
var celm = $(".customelement", this);
if (celm.length) {
var elem = celm[0], nm = $(elem).attr('name');
$.each($t.p.colModel, function(){
if(this.name === nm && this.editoptions && $.isFunction(this.editoptions.custom_value)) {
try {
postdata[nm] = this.editoptions.custom_value.call($t, $("#"+$.jgrid.jqID(nm),frmtb),'get');
if (postdata[nm] === undefined) {throw "e1";}
} catch (e) {
if (e==="e1") {$.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.novalue,$.jgrid.edit.bClose);}
else {$.jgrid.info_dialog($.jgrid.errors.errcap,e.message,$.jgrid.edit.bClose);}
}
return true;
}
});
} else {
switch ($(this).get(0).type) {
case "checkbox":
if($(this).is(":checked")) {
postdata[this.name]= $(this).val();
}else {
var ofv = $(this).attr("offval");
postdata[this.name]= ofv;
}
break;
case "select-one":
postdata[this.name]= $("option:selected",this).val();
extpost[this.name]= $("option:selected",this).text();
break;
case "select-multiple":
postdata[this.name]= $(this).val();
if(postdata[this.name]) {postdata[this.name] = postdata[this.name].join(",");}
else {postdata[this.name] ="";}
var selectedText = [];
$("option:selected",this).each(
function(i,selected){
selectedText[i] = $(selected).text();
}
);
extpost[this.name]= selectedText.join(",");
break;
case "password":
case "text":
case "textarea":
case "button":
postdata[this.name] = $(this).val();
break;
}
if($t.p.autoencode) {postdata[this.name] = $.jgrid.htmlEncode(postdata[this.name]);}
}
});
return true;
}
function createData(rowid,obj,tb,maxcols){
var nm, hc,trdata, cnt=0,tmp, dc,elc, retpos=[], ind=false,
tdtmpl = "<td class='CaptionTD'> </td><td class='DataTD'> </td>", tmpl="", i; //*2
for (i =1; i<=maxcols;i++) {
tmpl += tdtmpl;
}
if(rowid != '_empty') {
ind = $(obj).jqGrid("getInd",rowid);
}
$(obj.p.colModel).each( function(i) {
nm = this.name;
// hidden fields are included in the form
if(this.editrules && this.editrules.edithidden === true) {
hc = false;
} else {
hc = this.hidden === true ? true : false;
}
dc = hc ? "style='display:none'" : "";
if ( nm !== 'cb' && nm !== 'subgrid' && this.editable===true && nm !== 'rn') {
if(ind === false) {
tmp = "";
} else {
if(nm == obj.p.ExpandColumn && obj.p.treeGrid === true) {
tmp = $("td[role='gridcell']:eq("+i+")",obj.rows[ind]).text();
} else {
try {
tmp = $.unformat.call(obj, $("td[role='gridcell']:eq("+i+")",obj.rows[ind]),{rowId:rowid, colModel:this},i);
} catch (_) {
tmp = (this.edittype && this.edittype == "textarea") ? $("td[role='gridcell']:eq("+i+")",obj.rows[ind]).text() : $("td[role='gridcell']:eq("+i+")",obj.rows[ind]).html();
}
if(!tmp || tmp == " " || tmp == " " || (tmp.length==1 && tmp.charCodeAt(0)==160) ) {tmp='';}
}
}
var opt = $.extend({}, this.editoptions || {} ,{id:nm,name:nm}),
frmopt = $.extend({}, {elmprefix:'',elmsuffix:'',rowabove:false,rowcontent:''}, this.formoptions || {}),
rp = parseInt(frmopt.rowpos,10) || cnt+1,
cp = parseInt((parseInt(frmopt.colpos,10) || 1)*2,10);
if(rowid == "_empty" && opt.defaultValue ) {
tmp = $.isFunction(opt.defaultValue) ? opt.defaultValue.call($t) : opt.defaultValue;
}
if(!this.edittype) {this.edittype = "text";}
if($t.p.autoencode) {tmp = $.jgrid.htmlDecode(tmp);}
elc = $.jgrid.createEl.call($t,this.edittype,opt,tmp,false,$.extend({},$.jgrid.ajaxOptions,obj.p.ajaxSelectOptions || {}));
if(tmp === "" && this.edittype == "checkbox") {tmp = $(elc).attr("offval");}
if(tmp === "" && this.edittype == "select") {tmp = $("option:eq(0)",elc).text();}
if(rp_ge[$t.p.id].checkOnSubmit || rp_ge[$t.p.id].checkOnUpdate) {rp_ge[$t.p.id]._savedData[nm] = tmp;}
$(elc).addClass("FormElement");
if(this.edittype == 'text' || this.edittype == 'textarea') {
$(elc).addClass("ui-widget-content ui-corner-all");
}
trdata = $(tb).find("tr[rowpos="+rp+"]");
if(frmopt.rowabove) {
var newdata = $("<tr><td class='contentinfo' colspan='"+(maxcols*2)+"'>"+frmopt.rowcontent+"</td></tr>");
$(tb).append(newdata);
newdata[0].rp = rp;
}
if ( trdata.length===0 ) {
trdata = $("<tr "+dc+" rowpos='"+rp+"'></tr>").addClass("FormData").attr("id","tr_"+nm);
$(trdata).append(tmpl);
$(tb).append(trdata);
trdata[0].rp = rp;
}
$("td:eq("+(cp-2)+")",trdata[0]).html(frmopt.label === undefined ? obj.p.colNames[i]: frmopt.label);
$("td:eq("+(cp-1)+")",trdata[0]).append(frmopt.elmprefix).append(elc).append(frmopt.elmsuffix);
if($.isFunction(opt.custom_value) && rowid !== "_empty" ) {
opt.custom_value.call($t, $("#"+nm,"#"+frmgr),'set',tmp);
}
$.jgrid.bindEv( elc, opt, $t);
retpos[cnt] = i;
cnt++;
}
});
if( cnt > 0) {
var idrow = $("<tr class='FormData' style='display:none'><td class='CaptionTD'></td><td colspan='"+ (maxcols*2-1)+"' class='DataTD'><input class='FormElement' id='id_g' type='text' name='"+obj.p.id+"_id' value='"+rowid+"'/></td></tr>");
idrow[0].rp = cnt+999;
$(tb).append(idrow);
if(rp_ge[$t.p.id].checkOnSubmit || rp_ge[$t.p.id].checkOnUpdate) {rp_ge[$t.p.id]._savedData[obj.p.id+"_id"] = rowid;}
}
return retpos;
}
function fillData(rowid,obj,fmid){
var nm,cnt=0,tmp, fld,opt,vl,vlc;
if(rp_ge[$t.p.id].checkOnSubmit || rp_ge[$t.p.id].checkOnUpdate) {rp_ge[$t.p.id]._savedData = {};rp_ge[$t.p.id]._savedData[obj.p.id+"_id"]=rowid;}
var cm = obj.p.colModel;
if(rowid == '_empty') {
$(cm).each(function(){
nm = this.name;
opt = $.extend({}, this.editoptions || {} );
fld = $("#"+$.jgrid.jqID(nm),"#"+fmid);
if(fld && fld.length && fld[0] !== null) {
vl = "";
if(opt.defaultValue ) {
vl = $.isFunction(opt.defaultValue) ? opt.defaultValue.call($t) : opt.defaultValue;
if(fld[0].type=='checkbox') {
vlc = vl.toLowerCase();
if(vlc.search(/(false|0|no|off|undefined)/i)<0 && vlc!=="") {
fld[0].checked = true;
fld[0].defaultChecked = true;
fld[0].value = vl;
} else {
fld[0].checked = false;
fld[0].defaultChecked = false;
}
} else {fld.val(vl);}
} else {
if( fld[0].type=='checkbox' ) {
fld[0].checked = false;
fld[0].defaultChecked = false;
vl = $(fld).attr("offval");
} else if (fld[0].type && fld[0].type.substr(0,6)=='select') {
fld[0].selectedIndex = 0;
} else {
fld.val(vl);
}
}
if(rp_ge[$t.p.id].checkOnSubmit===true || rp_ge[$t.p.id].checkOnUpdate) {rp_ge[$t.p.id]._savedData[nm] = vl;}
}
});
$("#id_g","#"+fmid).val(rowid);
return;
}
var tre = $(obj).jqGrid("getInd",rowid,true);
if(!tre) {return;}
$('td[role="gridcell"]',tre).each( function(i) {
nm = cm[i].name;
// hidden fields are included in the form
if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn' && cm[i].editable===true) {
if(nm == obj.p.ExpandColumn && obj.p.treeGrid === true) {
tmp = $(this).text();
} else {
try {
tmp = $.unformat.call(obj, $(this),{rowId:rowid, colModel:cm[i]},i);
} catch (_) {
tmp = cm[i].edittype=="textarea" ? $(this).text() : $(this).html();
}
}
if($t.p.autoencode) {tmp = $.jgrid.htmlDecode(tmp);}
if(rp_ge[$t.p.id].checkOnSubmit===true || rp_ge[$t.p.id].checkOnUpdate) {rp_ge[$t.p.id]._savedData[nm] = tmp;}
nm = $.jgrid.jqID(nm);
switch (cm[i].edittype) {
case "password":
case "text":
case "button" :
case "image":
case "textarea":
if(tmp == " " || tmp == " " || (tmp.length==1 && tmp.charCodeAt(0)==160) ) {tmp='';}
$("#"+nm,"#"+fmid).val(tmp);
break;
case "select":
var opv = tmp.split(",");
opv = $.map(opv,function(n){return $.trim(n);});
$("#"+nm+" option","#"+fmid).each(function(){
if (!cm[i].editoptions.multiple && ($.trim(tmp) == $.trim($(this).text()) || opv[0] == $.trim($(this).text()) || opv[0] == $.trim($(this).val())) ){
this.selected= true;
} else if (cm[i].editoptions.multiple){
if( $.inArray($.trim($(this).text()), opv ) > -1 || $.inArray($.trim($(this).val()), opv ) > -1 ){
this.selected = true;
}else{
this.selected = false;
}
} else {
this.selected = false;
}
});
break;
case "checkbox":
tmp = String(tmp);
if(cm[i].editoptions && cm[i].editoptions.value) {
var cb = cm[i].editoptions.value.split(":");
if(cb[0] == tmp) {
$("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("checked",true);
$("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("defaultChecked",true); //ie
} else {
$("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("checked", false);
$("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("defaultChecked", false); //ie
}
} else {
tmp = tmp.toLowerCase();
if(tmp.search(/(false|0|no|off|undefined)/i)<0 && tmp!=="") {
$("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("checked",true);
$("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("defaultChecked",true); //ie
} else {
$("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("checked", false);
$("#"+nm,"#"+fmid)[$t.p.useProp ? 'prop': 'attr']("defaultChecked", false); //ie
}
}
break;
case 'custom' :
try {
if(cm[i].editoptions && $.isFunction(cm[i].editoptions.custom_value)) {
cm[i].editoptions.custom_value.call($t, $("#"+nm,"#"+fmid),'set',tmp);
} else {throw "e1";}
} catch (e) {
if (e=="e1") {$.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.nodefined,$.jgrid.edit.bClose);}
else {$.jgrid.info_dialog($.jgrid.errors.errcap,e.message,$.jgrid.edit.bClose);}
}
break;
}
cnt++;
}
});
if(cnt>0) {$("#id_g",frmtb).val(rowid);}
}
function setNulls() {
$.each($t.p.colModel, function(i,n){
if(n.editoptions && n.editoptions.NullIfEmpty === true) {
if(postdata.hasOwnProperty(n.name) && postdata[n.name] === "") {
postdata[n.name] = 'null';
}
}
});
}
function postIt() {
var copydata, ret=[true,"",""], onCS = {}, opers = $t.p.prmNames, idname, oper, key, selr, i;
var retvals = $($t).triggerHandler("jqGridAddEditBeforeCheckValues", [$("#"+frmgr), frmoper]);
if(retvals && typeof retvals === 'object') {postdata = retvals;}
if($.isFunction(rp_ge[$t.p.id].beforeCheckValues)) {
retvals = rp_ge[$t.p.id].beforeCheckValues.call($t, postdata,$("#"+frmgr),postdata[$t.p.id+"_id"] == "_empty" ? opers.addoper : opers.editoper);
if(retvals && typeof retvals === 'object') {postdata = retvals;}
}
for( key in postdata ){
if(postdata.hasOwnProperty(key)) {
ret = $.jgrid.checkValues.call($t,postdata[key],key,$t);
if(ret[0] === false) {break;}
}
}
setNulls();
if(ret[0]) {
onCS = $($t).triggerHandler("jqGridAddEditClickSubmit", [rp_ge[$t.p.id], postdata, frmoper]);
if( onCS === undefined && $.isFunction( rp_ge[$t.p.id].onclickSubmit)) {
onCS = rp_ge[$t.p.id].onclickSubmit.call($t, rp_ge[$t.p.id], postdata) || {};
}
ret = $($t).triggerHandler("jqGridAddEditBeforeSubmit", [postdata, $("#"+frmgr), frmoper]);
if(ret === undefined) {
ret = [true,"",""];
}
if( ret[0] && $.isFunction(rp_ge[$t.p.id].beforeSubmit)) {
ret = rp_ge[$t.p.id].beforeSubmit.call($t,postdata,$("#"+frmgr));
}
}
if(ret[0] && !rp_ge[$t.p.id].processing) {
rp_ge[$t.p.id].processing = true;
$("#sData", frmtb+"_2").addClass('ui-state-active');
oper = opers.oper;
idname = opers.id;
// we add to pos data array the action - the name is oper
postdata[oper] = ($.trim(postdata[$t.p.id+"_id"]) == "_empty") ? opers.addoper : opers.editoper;
if(postdata[oper] != opers.addoper) {
postdata[idname] = postdata[$t.p.id+"_id"];
} else {
// check to see if we have allredy this field in the form and if yes lieve it
if( postdata[idname] === undefined ) {postdata[idname] = postdata[$t.p.id+"_id"];}
}
delete postdata[$t.p.id+"_id"];
postdata = $.extend(postdata,rp_ge[$t.p.id].editData,onCS);
if($t.p.treeGrid === true) {
if(postdata[oper] == opers.addoper) {
selr = $($t).jqGrid("getGridParam", 'selrow');
var tr_par_id = $t.p.treeGridModel == 'adjacency' ? $t.p.treeReader.parent_id_field : 'parent_id';
postdata[tr_par_id] = selr;
}
for(i in $t.p.treeReader){
if($t.p.treeReader.hasOwnProperty(i)) {
var itm = $t.p.treeReader[i];
if(postdata.hasOwnProperty(itm)) {
if(postdata[oper] == opers.addoper && i === 'parent_id_field') {continue;}
delete postdata[itm];
}
}
}
}
postdata[idname] = $.jgrid.stripPref($t.p.idPrefix, postdata[idname]);
var ajaxOptions = $.extend({
url: rp_ge[$t.p.id].url || $($t).jqGrid('getGridParam','editurl'),
type: rp_ge[$t.p.id].mtype,
data: $.isFunction(rp_ge[$t.p.id].serializeEditData) ? rp_ge[$t.p.id].serializeEditData.call($t,postdata) : postdata,
complete:function(data,status){
var key;
postdata[idname] = $t.p.idPrefix + postdata[idname];
if(status != "success") {
ret[0] = false;
ret[1] = $($t).triggerHandler("jqGridAddEditErrorTextFormat", [data, frmoper]);
if ($.isFunction(rp_ge[$t.p.id].errorTextFormat)) {
ret[1] = rp_ge[$t.p.id].errorTextFormat.call($t, data);
} else {
ret[1] = status + " Status: '" + data.statusText + "'. Error code: " + data.status;
}
} else {
// data is posted successful
// execute aftersubmit with the returned data from server
ret = $($t).triggerHandler("jqGridAddEditAfterSubmit", [data, postdata, frmoper]);
if(ret === undefined) {
ret = [true,"",""];
}
if( ret[0] && $.isFunction(rp_ge[$t.p.id].afterSubmit) ) {
ret = rp_ge[$t.p.id].afterSubmit.call($t, data,postdata);
}
}
if(ret[0] === false) {
$("#FormError>td",frmtb).html(ret[1]);
$("#FormError",frmtb).show();
} else {
// remove some values if formattaer select or checkbox
$.each($t.p.colModel, function(){
if(extpost[this.name] && this.formatter && this.formatter=='select') {
try {delete extpost[this.name];} catch (e) {}
}
});
postdata = $.extend(postdata,extpost);
if($t.p.autoencode) {
$.each(postdata,function(n,v){
postdata[n] = $.jgrid.htmlDecode(v);
});
}
//rp_ge[$t.p.id].reloadAfterSubmit = rp_ge[$t.p.id].reloadAfterSubmit && $t.p.datatype != "local";
// the action is add
if(postdata[oper] == opers.addoper ) {
//id processing
// user not set the id ret[2]
if(!ret[2]) {ret[2] = $.jgrid.randId();}
postdata[idname] = ret[2];
if(rp_ge[$t.p.id].closeAfterAdd) {
if(rp_ge[$t.p.id].reloadAfterSubmit) {$($t).trigger("reloadGrid");}
else {
if($t.p.treeGrid === true){
$($t).jqGrid("addChildNode",ret[2],selr,postdata );
} else {
$($t).jqGrid("addRowData",ret[2],postdata,p.addedrow);
$($t).jqGrid("setSelection",ret[2]);
}
}
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose});
} else if (rp_ge[$t.p.id].clearAfterAdd) {
if(rp_ge[$t.p.id].reloadAfterSubmit) {$($t).trigger("reloadGrid");}
else {
if($t.p.treeGrid === true){
$($t).jqGrid("addChildNode",ret[2],selr,postdata );
} else {
$($t).jqGrid("addRowData",ret[2],postdata,p.addedrow);
}
}
fillData("_empty",$t,frmgr);
} else {
if(rp_ge[$t.p.id].reloadAfterSubmit) {$($t).trigger("reloadGrid");}
else {
if($t.p.treeGrid === true){
$($t).jqGrid("addChildNode",ret[2],selr,postdata );
} else {
$($t).jqGrid("addRowData",ret[2],postdata,p.addedrow);
}
}
}
} else {
// the action is update
if(rp_ge[$t.p.id].reloadAfterSubmit) {
$($t).trigger("reloadGrid");
if( !rp_ge[$t.p.id].closeAfterEdit ) {setTimeout(function(){$($t).jqGrid("setSelection",postdata[idname]);},1000);}
} else {
if($t.p.treeGrid === true) {
$($t).jqGrid("setTreeRow", postdata[idname],postdata);
} else {
$($t).jqGrid("setRowData", postdata[idname],postdata);
}
}
if(rp_ge[$t.p.id].closeAfterEdit) {$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose});}
}
if($.isFunction(rp_ge[$t.p.id].afterComplete)) {
copydata = data;
setTimeout(function(){
$($t).triggerHandler("jqGridAddEditAfterComplete", [copydata, postdata, $("#"+frmgr), frmoper]);
rp_ge[$t.p.id].afterComplete.call($t, copydata, postdata, $("#"+frmgr));
copydata=null;
},500);
}
if(rp_ge[$t.p.id].checkOnSubmit || rp_ge[$t.p.id].checkOnUpdate) {
$("#"+frmgr).data("disabled",false);
if(rp_ge[$t.p.id]._savedData[$t.p.id+"_id"] !="_empty"){
for(key in rp_ge[$t.p.id]._savedData) {
if(rp_ge[$t.p.id]._savedData.hasOwnProperty(key) && postdata[key]) {
rp_ge[$t.p.id]._savedData[key] = postdata[key];
}
}
}
}
}
rp_ge[$t.p.id].processing=false;
$("#sData", frmtb+"_2").removeClass('ui-state-active');
try{$(':input:visible',"#"+frmgr)[0].focus();} catch (e){}
}
}, $.jgrid.ajaxOptions, rp_ge[$t.p.id].ajaxEditOptions );
if (!ajaxOptions.url && !rp_ge[$t.p.id].useDataProxy) {
if ($.isFunction($t.p.dataProxy)) {
rp_ge[$t.p.id].useDataProxy = true;
} else {
ret[0]=false;ret[1] += " "+$.jgrid.errors.nourl;
}
}
if (ret[0]) {
if (rp_ge[$t.p.id].useDataProxy) {
var dpret = $t.p.dataProxy.call($t, ajaxOptions, "set_"+$t.p.id);
if(dpret === undefined) {
dpret = [true, ""];
}
if(dpret[0] === false ) {
ret[0] = false;
ret[1] = dpret[1] || "Error deleting the selected row!" ;
} else {
if(ajaxOptions.data.oper == opers.addoper && rp_ge[$t.p.id].closeAfterAdd ) {
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});
}
if(ajaxOptions.data.oper == opers.editoper && rp_ge[$t.p.id].closeAfterEdit ) {
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});
}
}
} else {
$.ajax(ajaxOptions);
}
}
}
if(ret[0] === false) {
$("#FormError>td",frmtb).html(ret[1]);
$("#FormError",frmtb).show();
// return;
}
}
function compareData(nObj, oObj ) {
var ret = false,key;
for (key in nObj) {
if(nObj.hasOwnProperty(key) && nObj[key] != oObj[key]) {
ret = true;
break;
}
}
return ret;
}
function checkUpdates () {
var stat = true;
$("#FormError",frmtb).hide();
if(rp_ge[$t.p.id].checkOnUpdate) {
postdata = {};extpost={};
getFormData();
newData = $.extend({},postdata,extpost);
diff = compareData(newData,rp_ge[$t.p.id]._savedData);
if(diff) {
$("#"+frmgr).data("disabled",true);
$(".confirm","#"+IDs.themodal).show();
stat = false;
}
}
return stat;
}
function restoreInline()
{
var i;
if (rowid !== "_empty" && $t.p.savedRow !== undefined && $t.p.savedRow.length > 0 && $.isFunction($.fn.jqGrid.restoreRow)) {
for (i=0;i<$t.p.savedRow.length;i++) {
if ($t.p.savedRow[i].id == rowid) {
$($t).jqGrid('restoreRow',rowid);
break;
}
}
}
}
function updateNav(cr, posarr){
var totr = posarr[1].length-1;
if (cr===0) {
$("#pData",frmtb+"_2").addClass('ui-state-disabled');
} else if( posarr[1][cr-1] !== undefined && $("#"+$.jgrid.jqID(posarr[1][cr-1])).hasClass('ui-state-disabled')) {
$("#pData",frmtb+"_2").addClass('ui-state-disabled');
} else {
$("#pData",frmtb+"_2").removeClass('ui-state-disabled');
}
if (cr==totr) {
$("#nData",frmtb+"_2").addClass('ui-state-disabled');
} else if( posarr[1][cr+1] !== undefined && $("#"+$.jgrid.jqID(posarr[1][cr+1])).hasClass('ui-state-disabled')) {
$("#nData",frmtb+"_2").addClass('ui-state-disabled');
} else {
$("#nData",frmtb+"_2").removeClass('ui-state-disabled');
}
}
function getCurrPos() {
var rowsInGrid = $($t).jqGrid("getDataIDs"),
selrow = $("#id_g",frmtb).val(),
pos = $.inArray(selrow,rowsInGrid);
return [pos,rowsInGrid];
}
if ( $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined ) {
showFrm = $($t).triggerHandler("jqGridAddEditBeforeInitData", [$("#"+$.jgrid.jqID(frmgr)), frmoper]);
if(showFrm === undefined) {
showFrm = true;
}
if(showFrm && onBeforeInit) {
showFrm = onBeforeInit.call($t,$("#"+frmgr));
}
if(showFrm === false) {return;}
restoreInline();
$(".ui-jqdialog-title","#"+$.jgrid.jqID(IDs.modalhead)).html(p.caption);
$("#FormError",frmtb).hide();
if(rp_ge[$t.p.id].topinfo) {
$(".topinfo",frmtb).html(rp_ge[$t.p.id].topinfo);
$(".tinfo",frmtb).show();
} else {
$(".tinfo",frmtb).hide();
}
if(rp_ge[$t.p.id].bottominfo) {
$(".bottominfo",frmtb+"_2").html(rp_ge[$t.p.id].bottominfo);
$(".binfo",frmtb+"_2").show();
} else {
$(".binfo",frmtb+"_2").hide();
}
// filldata
fillData(rowid,$t,frmgr);
///
if(rowid=="_empty" || !rp_ge[$t.p.id].viewPagerButtons) {
$("#pData, #nData",frmtb+"_2").hide();
} else {
$("#pData, #nData",frmtb+"_2").show();
}
if(rp_ge[$t.p.id].processing===true) {
rp_ge[$t.p.id].processing=false;
$("#sData", frmtb+"_2").removeClass('ui-state-active');
}
if($("#"+frmgr).data("disabled")===true) {
$(".confirm","#"+$.jgrid.jqID(IDs.themodal)).hide();
$("#"+frmgr).data("disabled",false);
}
$($t).triggerHandler("jqGridAddEditBeforeShowForm", [$("#"+frmgr), frmoper]);
if(onBeforeShow) { onBeforeShow.call($t, $("#"+frmgr)); }
$("#"+$.jgrid.jqID(IDs.themodal)).data("onClose",rp_ge[$t.p.id].onClose);
$.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, jqM: false, overlay: p.overlay, modal:p.modal});
if(!closeovrl) {
$(".jqmOverlay").click(function(){
if(!checkUpdates()) {return false;}
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});
return false;
});
}
$($t).triggerHandler("jqGridAddEditAfterShowForm", [$("#"+frmgr), frmoper]);
if(onAfterShow) { onAfterShow.call($t, $("#"+frmgr)); }
} else {
var dh = isNaN(p.dataheight) ? p.dataheight : p.dataheight+"px",
frm = $("<form name='FormPost' id='"+frmgr+"' class='FormGrid' onSubmit='return false;' style='width:100%;overflow:auto;position:relative;height:"+dh+";'></form>").data("disabled",false),
tbl = $("<table id='"+frmtborg+"' class='EditTable' cellspacing='0' cellpadding='0' border='0'><tbody></tbody></table>");
showFrm = $($t).triggerHandler("jqGridAddEditBeforeInitData", [$("#"+frmgr), frmoper]);
if(showFrm === undefined) {
showFrm = true;
}
if(showFrm && onBeforeInit) {
showFrm = onBeforeInit.call($t,$("#"+frmgr));
}
if(showFrm === false) {return;}
restoreInline();
$($t.p.colModel).each( function() {
var fmto = this.formoptions;
maxCols = Math.max(maxCols, fmto ? fmto.colpos || 0 : 0 );
maxRows = Math.max(maxRows, fmto ? fmto.rowpos || 0 : 0 );
});
$(frm).append(tbl);
var flr = $("<tr id='FormError' style='display:none'><td class='ui-state-error' colspan='"+(maxCols*2)+"'></td></tr>");
flr[0].rp = 0;
$(tbl).append(flr);
//topinfo
flr = $("<tr style='display:none' class='tinfo'><td class='topinfo' colspan='"+(maxCols*2)+"'>"+rp_ge[$t.p.id].topinfo+"</td></tr>");
flr[0].rp = 0;
$(tbl).append(flr);
// set the id.
// use carefull only to change here colproperties.
// create data
var rtlb = $t.p.direction == "rtl" ? true :false,
bp = rtlb ? "nData" : "pData",
bn = rtlb ? "pData" : "nData";
createData(rowid,$t,tbl,maxCols);
// buttons at footer
var bP = "<a href='javascript:void(0)' id='"+bp+"' class='fm-button ui-state-default ui-corner-left'><span class='ui-icon ui-icon-triangle-1-w'></span></a>",
bN = "<a href='javascript:void(0)' id='"+bn+"' class='fm-button ui-state-default ui-corner-right'><span class='ui-icon ui-icon-triangle-1-e'></span></a>",
bS ="<a href='javascript:void(0)' id='sData' class='fm-button ui-state-default ui-corner-all'>"+p.bSubmit+"</a>",
bC ="<a href='javascript:void(0)' id='cData' class='fm-button ui-state-default ui-corner-all'>"+p.bCancel+"</a>";
var bt = "<table border='0' cellspacing='0' cellpadding='0' class='EditTable' id='"+frmtborg+"_2'><tbody><tr><td colspan='2'><hr class='ui-widget-content' style='margin:1px'/></td></tr><tr id='Act_Buttons'><td class='navButton'>"+(rtlb ? bN+bP : bP+bN)+"</td><td class='EditButton'>"+bS+bC+"</td></tr>";
bt += "<tr style='display:none' class='binfo'><td class='bottominfo' colspan='2'>"+rp_ge[$t.p.id].bottominfo+"</td></tr>";
bt += "</tbody></table>";
if(maxRows > 0) {
var sd=[];
$.each($(tbl)[0].rows,function(i,r){
sd[i] = r;
});
sd.sort(function(a,b){
if(a.rp > b.rp) {return 1;}
if(a.rp < b.rp) {return -1;}
return 0;
});
$.each(sd, function(index, row) {
$('tbody',tbl).append(row);
});
}
p.gbox = "#gbox_"+$.jgrid.jqID(gID);
var cle = false;
if(p.closeOnEscape===true){
p.closeOnEscape = false;
cle = true;
}
var tms = $("<span></span>").append(frm).append(bt);
$.jgrid.createModal(IDs,tms,p,"#gview_"+$.jgrid.jqID($t.p.id),$("#gbox_"+$.jgrid.jqID($t.p.id))[0]);
if(rtlb) {
$("#pData, #nData",frmtb+"_2").css("float","right");
$(".EditButton",frmtb+"_2").css("text-align","left");
}
if(rp_ge[$t.p.id].topinfo) {$(".tinfo",frmtb).show();}
if(rp_ge[$t.p.id].bottominfo) {$(".binfo",frmtb+"_2").show();}
tms = null;bt=null;
$("#"+$.jgrid.jqID(IDs.themodal)).keydown( function( e ) {
var wkey = e.target;
if ($("#"+frmgr).data("disabled")===true ) {return false;}//??
if(rp_ge[$t.p.id].savekey[0] === true && e.which == rp_ge[$t.p.id].savekey[1]) { // save
if(wkey.tagName != "TEXTAREA") {
$("#sData", frmtb+"_2").trigger("click");
return false;
}
}
if(e.which === 27) {
if(!checkUpdates()) {return false;}
if(cle) {$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:p.gbox,jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});}
return false;
}
if(rp_ge[$t.p.id].navkeys[0]===true) {
if($("#id_g",frmtb).val() == "_empty") {return true;}
if(e.which == rp_ge[$t.p.id].navkeys[1]){ //up
$("#pData", frmtb+"_2").trigger("click");
return false;
}
if(e.which == rp_ge[$t.p.id].navkeys[2]){ //down
$("#nData", frmtb+"_2").trigger("click");
return false;
}
}
});
if(p.checkOnUpdate) {
$("a.ui-jqdialog-titlebar-close span","#"+$.jgrid.jqID(IDs.themodal)).removeClass("jqmClose");
$("a.ui-jqdialog-titlebar-close","#"+$.jgrid.jqID(IDs.themodal)).unbind("click")
.click(function(){
if(!checkUpdates()) {return false;}
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose});
return false;
});
}
p.saveicon = $.extend([true,"left","ui-icon-disk"],p.saveicon);
p.closeicon = $.extend([true,"left","ui-icon-close"],p.closeicon);
// beforeinitdata after creation of the form
if(p.saveicon[0]===true) {
$("#sData",frmtb+"_2").addClass(p.saveicon[1] == "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
.append("<span class='ui-icon "+p.saveicon[2]+"'></span>");
}
if(p.closeicon[0]===true) {
$("#cData",frmtb+"_2").addClass(p.closeicon[1] == "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
.append("<span class='ui-icon "+p.closeicon[2]+"'></span>");
}
if(rp_ge[$t.p.id].checkOnSubmit || rp_ge[$t.p.id].checkOnUpdate) {
bS ="<a href='javascript:void(0)' id='sNew' class='fm-button ui-state-default ui-corner-all' style='z-index:1002'>"+p.bYes+"</a>";
bN ="<a href='javascript:void(0)' id='nNew' class='fm-button ui-state-default ui-corner-all' style='z-index:1002'>"+p.bNo+"</a>";
bC ="<a href='javascript:void(0)' id='cNew' class='fm-button ui-state-default ui-corner-all' style='z-index:1002'>"+p.bExit+"</a>";
var ii, zI = p.zIndex || 999;zI ++;
if ($.browser.msie && $.browser.version ==6) {
ii = '<iframe style="display:block;position:absolute;z-index:-1;filter:Alpha(Opacity=\'0\');" src="javascript:false;"></iframe>';
} else {ii="";}
$("<div class='ui-widget-overlay jqgrid-overlay confirm' style='z-index:"+zI+";display:none;'> "+ii+"</div><div class='confirm ui-widget-content ui-jqconfirm' style='z-index:"+(zI+1)+"'>"+p.saveData+"<br/><br/>"+bS+bN+bC+"</div>").insertAfter("#"+frmgr);
$("#sNew","#"+$.jgrid.jqID(IDs.themodal)).click(function(){
postIt();
$("#"+frmgr).data("disabled",false);
$(".confirm","#"+$.jgrid.jqID(IDs.themodal)).hide();
return false;
});
$("#nNew","#"+$.jgrid.jqID(IDs.themodal)).click(function(){
$(".confirm","#"+$.jgrid.jqID(IDs.themodal)).hide();
$("#"+frmgr).data("disabled",false);
setTimeout(function(){$(":input","#"+frmgr)[0].focus();},0);
return false;
});
$("#cNew","#"+$.jgrid.jqID(IDs.themodal)).click(function(){
$(".confirm","#"+$.jgrid.jqID(IDs.themodal)).hide();
$("#"+frmgr).data("disabled",false);
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose});
return false;
});
}
// here initform - only once
$($t).triggerHandler("jqGridAddEditInitializeForm", [$("#"+frmgr), frmoper]);
if(onInitializeForm) {onInitializeForm.call($t,$("#"+frmgr));}
if(rowid=="_empty" || !rp_ge[$t.p.id].viewPagerButtons) {$("#pData,#nData",frmtb+"_2").hide();} else {$("#pData,#nData",frmtb+"_2").show();}
$($t).triggerHandler("jqGridAddEditBeforeShowForm", [$("#"+frmgr), frmoper]);
if(onBeforeShow) { onBeforeShow.call($t, $("#"+frmgr));}
$("#"+$.jgrid.jqID(IDs.themodal)).data("onClose",rp_ge[$t.p.id].onClose);
$.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, overlay: p.overlay,modal:p.modal});
if(!closeovrl) {
$(".jqmOverlay").click(function(){
if(!checkUpdates()) {return false;}
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});
return false;
});
}
$($t).triggerHandler("jqGridAddEditAfterShowForm", [$("#"+frmgr), frmoper]);
if(onAfterShow) { onAfterShow.call($t, $("#"+frmgr)); }
$(".fm-button","#"+$.jgrid.jqID(IDs.themodal)).hover(
function(){$(this).addClass('ui-state-hover');},
function(){$(this).removeClass('ui-state-hover');}
);
$("#sData", frmtb+"_2").click(function(){
postdata = {};extpost={};
$("#FormError",frmtb).hide();
// all depend on ret array
//ret[0] - succes
//ret[1] - msg if not succes
//ret[2] - the id that will be set if reload after submit false
getFormData();
if(postdata[$t.p.id+"_id"] == "_empty") {postIt();}
else if(p.checkOnSubmit===true ) {
newData = $.extend({},postdata,extpost);
diff = compareData(newData,rp_ge[$t.p.id]._savedData);
if(diff) {
$("#"+frmgr).data("disabled",true);
$(".confirm","#"+$.jgrid.jqID(IDs.themodal)).show();
} else {
postIt();
}
} else {
postIt();
}
return false;
});
$("#cData", frmtb+"_2").click(function(){
if(!checkUpdates()) {return false;}
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal,onClose: rp_ge[$t.p.id].onClose});
return false;
});
$("#nData", frmtb+"_2").click(function(){
if(!checkUpdates()) {return false;}
$("#FormError",frmtb).hide();
var npos = getCurrPos();
npos[0] = parseInt(npos[0],10);
if(npos[0] != -1 && npos[1][npos[0]+1]) {
$($t).triggerHandler("jqGridAddEditClickPgButtons", ['next',$("#"+frmgr),npos[1][npos[0]]]);
var nposret;
if($.isFunction(p.onclickPgButtons)) {
nposret = p.onclickPgButtons.call($t, 'next',$("#"+frmgr),npos[1][npos[0]]);
if( nposret !== undefined && nposret === false ) {return false;}
}
if( $("#"+$.jgrid.jqID(npos[1][npos[0]+1])).hasClass('ui-state-disabled')) {return false;}
fillData(npos[1][npos[0]+1],$t,frmgr);
$($t).jqGrid("setSelection",npos[1][npos[0]+1]);
$($t).triggerHandler("jqGridAddEditAfterClickPgButtons", ['next',$("#"+frmgr),npos[1][npos[0]]]);
if($.isFunction(p.afterclickPgButtons)) {
p.afterclickPgButtons.call($t, 'next',$("#"+frmgr),npos[1][npos[0]+1]);
}
updateNav(npos[0]+1,npos);
}
return false;
});
$("#pData", frmtb+"_2").click(function(){
if(!checkUpdates()) {return false;}
$("#FormError",frmtb).hide();
var ppos = getCurrPos();
if(ppos[0] != -1 && ppos[1][ppos[0]-1]) {
$($t).triggerHandler("jqGridAddEditClickPgButtons", ['prev',$("#"+frmgr),ppos[1][ppos[0]]]);
var pposret;
if($.isFunction(p.onclickPgButtons)) {
pposret = p.onclickPgButtons.call($t, 'prev',$("#"+frmgr),ppos[1][ppos[0]]);
if( pposret !== undefined && pposret === false ) {return false;}
}
if( $("#"+$.jgrid.jqID(ppos[1][ppos[0]-1])).hasClass('ui-state-disabled')) {return false;}
fillData(ppos[1][ppos[0]-1],$t,frmgr);
$($t).jqGrid("setSelection",ppos[1][ppos[0]-1]);
$($t).triggerHandler("jqGridAddEditAfterClickPgButtons", ['prev',$("#"+frmgr),ppos[1][ppos[0]]]);
if($.isFunction(p.afterclickPgButtons)) {
p.afterclickPgButtons.call($t, 'prev',$("#"+frmgr),ppos[1][ppos[0]-1]);
}
updateNav(ppos[0]-1,ppos);
}
return false;
});
}
var posInit =getCurrPos();
updateNav(posInit[0],posInit);
});
},
viewGridRow : function(rowid, p){
p = $.extend(true, {
top : 0,
left: 0,
width: 0,
height: 'auto',
dataheight: 'auto',
modal: false,
overlay: 30,
drag: true,
resize: true,
jqModal: true,
closeOnEscape : false,
labelswidth: '30%',
closeicon: [],
navkeys: [false,38,40],
onClose: null,
beforeShowForm : null,
beforeInitData : null,
viewPagerButtons : true
}, $.jgrid.view, p || {});
rp_ge[$(this)[0].p.id] = p;
return this.each(function(){
var $t = this;
if (!$t.grid || !rowid) {return;}
var gID = $t.p.id,
frmgr = "ViewGrid_"+$.jgrid.jqID( gID ), frmtb = "ViewTbl_" + $.jgrid.jqID( gID ),
frmgr_id = "ViewGrid_"+gID, frmtb_id = "ViewTbl_"+gID,
IDs = {themodal:'viewmod'+gID,modalhead:'viewhd'+gID,modalcontent:'viewcnt'+gID, scrollelm : frmgr},
onBeforeInit = $.isFunction(rp_ge[$t.p.id].beforeInitData) ? rp_ge[$t.p.id].beforeInitData : false,
showFrm = true,
maxCols = 1, maxRows=0;
function focusaref(){ //Sfari 3 issues
if(rp_ge[$t.p.id].closeOnEscape===true || rp_ge[$t.p.id].navkeys[0]===true) {
setTimeout(function(){$(".ui-jqdialog-titlebar-close","#"+$.jgrid.jqID(IDs.modalhead)).focus();},0);
}
}
function createData(rowid,obj,tb,maxcols){
var nm, hc,trdata, cnt=0,tmp, dc, retpos=[], ind=false, i,
tdtmpl = "<td class='CaptionTD form-view-label ui-widget-content' width='"+p.labelswidth+"'> </td><td class='DataTD form-view-data ui-helper-reset ui-widget-content'> </td>", tmpl="",
tdtmpl2 = "<td class='CaptionTD form-view-label ui-widget-content'> </td><td class='DataTD form-view-data ui-widget-content'> </td>",
fmtnum = ['integer','number','currency'],max1 =0, max2=0 ,maxw,setme, viewfld;
for (i=1;i<=maxcols;i++) {
tmpl += i == 1 ? tdtmpl : tdtmpl2;
}
// find max number align rigth with property formatter
$(obj.p.colModel).each( function() {
if(this.editrules && this.editrules.edithidden === true) {
hc = false;
} else {
hc = this.hidden === true ? true : false;
}
if(!hc && this.align==='right') {
if(this.formatter && $.inArray(this.formatter,fmtnum) !== -1 ) {
max1 = Math.max(max1,parseInt(this.width,10));
} else {
max2 = Math.max(max2,parseInt(this.width,10));
}
}
});
maxw = max1 !==0 ? max1 : max2 !==0 ? max2 : 0;
ind = $(obj).jqGrid("getInd",rowid);
$(obj.p.colModel).each( function(i) {
nm = this.name;
setme = false;
// hidden fields are included in the form
if(this.editrules && this.editrules.edithidden === true) {
hc = false;
} else {
hc = this.hidden === true ? true : false;
}
dc = hc ? "style='display:none'" : "";
viewfld = (typeof this.viewable !== 'boolean') ? true : this.viewable;
if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn' && viewfld) {
if(ind === false) {
tmp = "";
} else {
if(nm == obj.p.ExpandColumn && obj.p.treeGrid === true) {
tmp = $("td:eq("+i+")",obj.rows[ind]).text();
} else {
tmp = $("td:eq("+i+")",obj.rows[ind]).html();
}
}
setme = this.align === 'right' && maxw !==0 ? true : false;
var frmopt = $.extend({},{rowabove:false,rowcontent:''}, this.formoptions || {}),
rp = parseInt(frmopt.rowpos,10) || cnt+1,
cp = parseInt((parseInt(frmopt.colpos,10) || 1)*2,10);
if(frmopt.rowabove) {
var newdata = $("<tr><td class='contentinfo' colspan='"+(maxcols*2)+"'>"+frmopt.rowcontent+"</td></tr>");
$(tb).append(newdata);
newdata[0].rp = rp;
}
trdata = $(tb).find("tr[rowpos="+rp+"]");
if ( trdata.length===0 ) {
trdata = $("<tr "+dc+" rowpos='"+rp+"'></tr>").addClass("FormData").attr("id","trv_"+nm);
$(trdata).append(tmpl);
$(tb).append(trdata);
trdata[0].rp = rp;
}
$("td:eq("+(cp-2)+")",trdata[0]).html('<b>'+ (frmopt.label === undefined ? obj.p.colNames[i]: frmopt.label)+'</b>');
$("td:eq("+(cp-1)+")",trdata[0]).append("<span>"+tmp+"</span>").attr("id","v_"+nm);
if(setme){
$("td:eq("+(cp-1)+") span",trdata[0]).css({'text-align':'right',width:maxw+"px"});
}
retpos[cnt] = i;
cnt++;
}
});
if( cnt > 0) {
var idrow = $("<tr class='FormData' style='display:none'><td class='CaptionTD'></td><td colspan='"+ (maxcols*2-1)+"' class='DataTD'><input class='FormElement' id='id_g' type='text' name='id' value='"+rowid+"'/></td></tr>");
idrow[0].rp = cnt+99;
$(tb).append(idrow);
}
return retpos;
}
function fillData(rowid,obj){
var nm, hc,cnt=0,tmp, opt,trv;
trv = $(obj).jqGrid("getInd",rowid,true);
if(!trv) {return;}
$('td',trv).each( function(i) {
nm = obj.p.colModel[i].name;
// hidden fields are included in the form
if(obj.p.colModel[i].editrules && obj.p.colModel[i].editrules.edithidden === true) {
hc = false;
} else {
hc = obj.p.colModel[i].hidden === true ? true : false;
}
if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn') {
if(nm == obj.p.ExpandColumn && obj.p.treeGrid === true) {
tmp = $(this).text();
} else {
tmp = $(this).html();
}
opt = $.extend({},obj.p.colModel[i].editoptions || {});
nm = $.jgrid.jqID("v_"+nm);
$("#"+nm+" span","#"+frmtb).html(tmp);
if (hc) {$("#"+nm,"#"+frmtb).parents("tr:first").hide();}
cnt++;
}
});
if(cnt>0) {$("#id_g","#"+frmtb).val(rowid);}
}
function updateNav(cr,posarr){
var totr = posarr[1].length-1;
if (cr===0) {
$("#pData","#"+frmtb+"_2").addClass('ui-state-disabled');
} else if( posarr[1][cr-1] !== undefined && $("#"+$.jgrid.jqID(posarr[1][cr-1])).hasClass('ui-state-disabled')) {
$("#pData",frmtb+"_2").addClass('ui-state-disabled');
} else {
$("#pData","#"+frmtb+"_2").removeClass('ui-state-disabled');
}
if (cr==totr) {
$("#nData","#"+frmtb+"_2").addClass('ui-state-disabled');
} else if( posarr[1][cr+1] !== undefined && $("#"+$.jgrid.jqID(posarr[1][cr+1])).hasClass('ui-state-disabled')) {
$("#nData",frmtb+"_2").addClass('ui-state-disabled');
} else {
$("#nData","#"+frmtb+"_2").removeClass('ui-state-disabled');
}
}
function getCurrPos() {
var rowsInGrid = $($t).jqGrid("getDataIDs"),
selrow = $("#id_g","#"+frmtb).val(),
pos = $.inArray(selrow,rowsInGrid);
return [pos,rowsInGrid];
}
if ( $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined ) {
if(onBeforeInit) {
showFrm = onBeforeInit.call($t,$("#"+frmgr));
if(showFrm === undefined) {
showFrm = true;
}
}
if(showFrm === false) {return;}
$(".ui-jqdialog-title","#"+$.jgrid.jqID(IDs.modalhead)).html(p.caption);
$("#FormError","#"+frmtb).hide();
fillData(rowid,$t);
if($.isFunction(rp_ge[$t.p.id].beforeShowForm)) {rp_ge[$t.p.id].beforeShowForm.call($t,$("#"+frmgr));}
$.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, jqM: false, overlay: p.overlay, modal:p.modal});
focusaref();
} else {
var dh = isNaN(p.dataheight) ? p.dataheight : p.dataheight+"px";
var frm = $("<form name='FormPost' id='"+frmgr_id+"' class='FormGrid' style='width:100%;overflow:auto;position:relative;height:"+dh+";'></form>"),
tbl =$("<table id='"+frmtb_id+"' class='EditTable' cellspacing='1' cellpadding='2' border='0' style='table-layout:fixed'><tbody></tbody></table>");
if(onBeforeInit) {
showFrm = onBeforeInit.call($t,$("#"+frmgr));
if(showFrm === undefined) {
showFrm = true;
}
}
if(showFrm === false) {return;}
$($t.p.colModel).each( function() {
var fmto = this.formoptions;
maxCols = Math.max(maxCols, fmto ? fmto.colpos || 0 : 0 );
maxRows = Math.max(maxRows, fmto ? fmto.rowpos || 0 : 0 );
});
// set the id.
$(frm).append(tbl);
createData(rowid, $t, tbl, maxCols);
var rtlb = $t.p.direction == "rtl" ? true :false,
bp = rtlb ? "nData" : "pData",
bn = rtlb ? "pData" : "nData",
// buttons at footer
bP = "<a href='javascript:void(0)' id='"+bp+"' class='fm-button ui-state-default ui-corner-left'><span class='ui-icon ui-icon-triangle-1-w'></span></a>",
bN = "<a href='javascript:void(0)' id='"+bn+"' class='fm-button ui-state-default ui-corner-right'><span class='ui-icon ui-icon-triangle-1-e'></span></a>",
bC ="<a href='javascript:void(0)' id='cData' class='fm-button ui-state-default ui-corner-all'>"+p.bClose+"</a>";
if(maxRows > 0) {
var sd=[];
$.each($(tbl)[0].rows,function(i,r){
sd[i] = r;
});
sd.sort(function(a,b){
if(a.rp > b.rp) {return 1;}
if(a.rp < b.rp) {return -1;}
return 0;
});
$.each(sd, function(index, row) {
$('tbody',tbl).append(row);
});
}
p.gbox = "#gbox_"+$.jgrid.jqID(gID);
var bt = $("<span></span>").append(frm).append("<table border='0' class='EditTable' id='"+frmtb+"_2'><tbody><tr id='Act_Buttons'><td class='navButton' width='"+p.labelswidth+"'>"+(rtlb ? bN+bP : bP+bN)+"</td><td class='EditButton'>"+bC+"</td></tr></tbody></table>");
$.jgrid.createModal(IDs,bt,p,"#gview_"+$.jgrid.jqID($t.p.id),$("#gview_"+$.jgrid.jqID($t.p.id))[0]);
if(rtlb) {
$("#pData, #nData","#"+frmtb+"_2").css("float","right");
$(".EditButton","#"+frmtb+"_2").css("text-align","left");
}
if(!p.viewPagerButtons) {$("#pData, #nData","#"+frmtb+"_2").hide();}
bt = null;
$("#"+IDs.themodal).keydown( function( e ) {
if(e.which === 27) {
if(rp_ge[$t.p.id].closeOnEscape) {$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:p.gbox,jqm:p.jqModal, onClose: p.onClose});}
return false;
}
if(p.navkeys[0]===true) {
if(e.which === p.navkeys[1]){ //up
$("#pData", "#"+frmtb+"_2").trigger("click");
return false;
}
if(e.which === p.navkeys[2]){ //down
$("#nData", "#"+frmtb+"_2").trigger("click");
return false;
}
}
});
p.closeicon = $.extend([true,"left","ui-icon-close"],p.closeicon);
if(p.closeicon[0]===true) {
$("#cData","#"+frmtb+"_2").addClass(p.closeicon[1] == "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
.append("<span class='ui-icon "+p.closeicon[2]+"'></span>");
}
if($.isFunction(p.beforeShowForm)) {p.beforeShowForm.call($t,$("#"+frmgr));}
$.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, modal:p.modal});
$(".fm-button:not(.ui-state-disabled)","#"+frmtb+"_2").hover(
function(){$(this).addClass('ui-state-hover');},
function(){$(this).removeClass('ui-state-hover');}
);
focusaref();
$("#cData", "#"+frmtb+"_2").click(function(){
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: p.onClose});
return false;
});
$("#nData", "#"+frmtb+"_2").click(function(){
$("#FormError","#"+frmtb).hide();
var npos = getCurrPos();
npos[0] = parseInt(npos[0],10);
if(npos[0] != -1 && npos[1][npos[0]+1]) {
if($.isFunction(p.onclickPgButtons)) {
p.onclickPgButtons.call($t,'next',$("#"+frmgr),npos[1][npos[0]]);
}
fillData(npos[1][npos[0]+1],$t);
$($t).jqGrid("setSelection",npos[1][npos[0]+1]);
if($.isFunction(p.afterclickPgButtons)) {
p.afterclickPgButtons.call($t,'next',$("#"+frmgr),npos[1][npos[0]+1]);
}
updateNav(npos[0]+1,npos);
}
focusaref();
return false;
});
$("#pData", "#"+frmtb+"_2").click(function(){
$("#FormError","#"+frmtb).hide();
var ppos = getCurrPos();
if(ppos[0] != -1 && ppos[1][ppos[0]-1]) {
if($.isFunction(p.onclickPgButtons)) {
p.onclickPgButtons.call($t,'prev',$("#"+frmgr),ppos[1][ppos[0]]);
}
fillData(ppos[1][ppos[0]-1],$t);
$($t).jqGrid("setSelection",ppos[1][ppos[0]-1]);
if($.isFunction(p.afterclickPgButtons)) {
p.afterclickPgButtons.call($t,'prev',$("#"+frmgr),ppos[1][ppos[0]-1]);
}
updateNav(ppos[0]-1,ppos);
}
focusaref();
return false;
});
}
var posInit =getCurrPos();
updateNav(posInit[0],posInit);
});
},
delGridRow : function(rowids,p) {
p = $.extend(true, {
top : 0,
left: 0,
width: 240,
height: 'auto',
dataheight : 'auto',
modal: false,
overlay: 30,
drag: true,
resize: true,
url : '',
mtype : "POST",
reloadAfterSubmit: true,
beforeShowForm: null,
beforeInitData : null,
afterShowForm: null,
beforeSubmit: null,
onclickSubmit: null,
afterSubmit: null,
jqModal : true,
closeOnEscape : false,
delData: {},
delicon : [],
cancelicon : [],
onClose : null,
ajaxDelOptions : {},
processing : false,
serializeDelData : null,
useDataProxy : false
}, $.jgrid.del, p ||{});
rp_ge[$(this)[0].p.id] = p;
return this.each(function(){
var $t = this;
if (!$t.grid ) {return;}
if(!rowids) {return;}
var onBeforeShow = $.isFunction( rp_ge[$t.p.id].beforeShowForm ),
onAfterShow = $.isFunction( rp_ge[$t.p.id].afterShowForm ),
onBeforeInit = $.isFunction(rp_ge[$t.p.id].beforeInitData) ? rp_ge[$t.p.id].beforeInitData : false,
gID = $t.p.id, onCS = {},
showFrm = true,
dtbl = "DelTbl_"+$.jgrid.jqID(gID),postd, idname, opers, oper,
dtbl_id = "DelTbl_" + gID,
IDs = {themodal:'delmod'+gID,modalhead:'delhd'+gID,modalcontent:'delcnt'+gID, scrollelm: dtbl};
if ($.isArray(rowids)) {rowids = rowids.join();}
if ( $("#"+$.jgrid.jqID(IDs.themodal))[0] !== undefined ) {
if(onBeforeInit) {
showFrm = onBeforeInit.call($t,$("#"+dtbl));
if(showFrm === undefined) {
showFrm = true;
}
}
if(showFrm === false) {return;}
$("#DelData>td","#"+dtbl).text(rowids);
$("#DelError","#"+dtbl).hide();
if( rp_ge[$t.p.id].processing === true) {
rp_ge[$t.p.id].processing=false;
$("#dData", "#"+dtbl).removeClass('ui-state-active');
}
if(onBeforeShow) {rp_ge[$t.p.id].beforeShowForm.call($t,$("#"+dtbl));}
$.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:rp_ge[$t.p.id].jqModal,jqM: false, overlay: rp_ge[$t.p.id].overlay, modal:rp_ge[$t.p.id].modal});
if(onAfterShow) {rp_ge[$t.p.id].afterShowForm.call($t,$("#"+dtbl));}
} else {
var dh = isNaN(rp_ge[$t.p.id].dataheight) ? rp_ge[$t.p.id].dataheight : rp_ge[$t.p.id].dataheight+"px";
var tbl = "<div id='"+dtbl_id+"' class='formdata' style='width:100%;overflow:auto;position:relative;height:"+dh+";'>";
tbl += "<table class='DelTable'><tbody>";
// error data
tbl += "<tr id='DelError' style='display:none'><td class='ui-state-error'></td></tr>";
tbl += "<tr id='DelData' style='display:none'><td >"+rowids+"</td></tr>";
tbl += "<tr><td class=\"delmsg\" style=\"white-space:pre;\">"+rp_ge[$t.p.id].msg+"</td></tr><tr><td > </td></tr>";
// buttons at footer
tbl += "</tbody></table></div>";
var bS = "<a href='javascript:void(0)' id='dData' class='fm-button ui-state-default ui-corner-all'>"+p.bSubmit+"</a>",
bC = "<a href='javascript:void(0)' id='eData' class='fm-button ui-state-default ui-corner-all'>"+p.bCancel+"</a>";
tbl += "<table cellspacing='0' cellpadding='0' border='0' class='EditTable' id='"+dtbl+"_2'><tbody><tr><td><hr class='ui-widget-content' style='margin:1px'/></td></tr><tr><td class='DelButton EditButton'>"+bS+" "+bC+"</td></tr></tbody></table>";
p.gbox = "#gbox_"+$.jgrid.jqID(gID);
$.jgrid.createModal(IDs,tbl,p,"#gview_"+$.jgrid.jqID($t.p.id),$("#gview_"+$.jgrid.jqID($t.p.id))[0]);
if(onBeforeInit) {
showFrm = onBeforeInit.call($t,$("#"+dtbl));
if(showFrm === undefined) {
showFrm = true;
}
}
if(showFrm === false) {return;}
$(".fm-button","#"+dtbl+"_2").hover(
function(){$(this).addClass('ui-state-hover');},
function(){$(this).removeClass('ui-state-hover');}
);
p.delicon = $.extend([true,"left","ui-icon-scissors"],rp_ge[$t.p.id].delicon);
p.cancelicon = $.extend([true,"left","ui-icon-cancel"],rp_ge[$t.p.id].cancelicon);
if(p.delicon[0]===true) {
$("#dData","#"+dtbl+"_2").addClass(p.delicon[1] == "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
.append("<span class='ui-icon "+p.delicon[2]+"'></span>");
}
if(p.cancelicon[0]===true) {
$("#eData","#"+dtbl+"_2").addClass(p.cancelicon[1] == "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
.append("<span class='ui-icon "+p.cancelicon[2]+"'></span>");
}
$("#dData","#"+dtbl+"_2").click(function(){
var ret=[true,""], pk,
postdata = $("#DelData>td","#"+dtbl).text(); //the pair is name=val1,val2,...
onCS = {};
if( $.isFunction( rp_ge[$t.p.id].onclickSubmit ) ) {onCS = rp_ge[$t.p.id].onclickSubmit.call($t,rp_ge[$t.p.id], postdata) || {};}
if( $.isFunction( rp_ge[$t.p.id].beforeSubmit ) ) {ret = rp_ge[$t.p.id].beforeSubmit.call($t,postdata);}
if(ret[0] && !rp_ge[$t.p.id].processing) {
rp_ge[$t.p.id].processing = true;
opers = $t.p.prmNames;
postd = $.extend({},rp_ge[$t.p.id].delData, onCS);
oper = opers.oper;
postd[oper] = opers.deloper;
idname = opers.id;
postdata = String(postdata).split(",");
if(!postdata.length) { return false; }
for(pk in postdata) {
if(postdata.hasOwnProperty(pk)) {
postdata[pk] = $.jgrid.stripPref($t.p.idPrefix, postdata[pk]);
}
}
postd[idname] = postdata.join();
$(this).addClass('ui-state-active');
var ajaxOptions = $.extend({
url: rp_ge[$t.p.id].url || $($t).jqGrid('getGridParam','editurl'),
type: rp_ge[$t.p.id].mtype,
data: $.isFunction(rp_ge[$t.p.id].serializeDelData) ? rp_ge[$t.p.id].serializeDelData.call($t,postd) : postd,
complete:function(data,status){
var i;
if(status != "success") {
ret[0] = false;
if ($.isFunction(rp_ge[$t.p.id].errorTextFormat)) {
ret[1] = rp_ge[$t.p.id].errorTextFormat.call($t,data);
} else {
ret[1] = status + " Status: '" + data.statusText + "'. Error code: " + data.status;
}
} else {
// data is posted successful
// execute aftersubmit with the returned data from server
if( $.isFunction( rp_ge[$t.p.id].afterSubmit ) ) {
ret = rp_ge[$t.p.id].afterSubmit.call($t,data,postd);
}
}
if(ret[0] === false) {
$("#DelError>td","#"+dtbl).html(ret[1]);
$("#DelError","#"+dtbl).show();
} else {
if(rp_ge[$t.p.id].reloadAfterSubmit && $t.p.datatype != "local") {
$($t).trigger("reloadGrid");
} else {
if($t.p.treeGrid===true){
try {$($t).jqGrid("delTreeNode",$t.p.idPrefix+postdata[0]);} catch(e){}
} else {
for(i=0;i<postdata.length;i++) {
$($t).jqGrid("delRowData",$t.p.idPrefix+ postdata[i]);
}
}
$t.p.selrow = null;
$t.p.selarrrow = [];
}
if($.isFunction(rp_ge[$t.p.id].afterComplete)) {
setTimeout(function(){rp_ge[$t.p.id].afterComplete.call($t,data,postdata);},500);
}
}
rp_ge[$t.p.id].processing=false;
$("#dData", "#"+dtbl+"_2").removeClass('ui-state-active');
if(ret[0]) {$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});}
}
}, $.jgrid.ajaxOptions, rp_ge[$t.p.id].ajaxDelOptions);
if (!ajaxOptions.url && !rp_ge[$t.p.id].useDataProxy) {
if ($.isFunction($t.p.dataProxy)) {
rp_ge[$t.p.id].useDataProxy = true;
} else {
ret[0]=false;ret[1] += " "+$.jgrid.errors.nourl;
}
}
if (ret[0]) {
if (rp_ge[$t.p.id].useDataProxy) {
var dpret = $t.p.dataProxy.call($t, ajaxOptions, "del_"+$t.p.id);
if(dpret === undefined) {
dpret = [true, ""];
}
if(dpret[0] === false ) {
ret[0] = false;
ret[1] = dpret[1] || "Error deleting the selected row!" ;
} else {
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:p.jqModal, onClose: rp_ge[$t.p.id].onClose});
}
}
else {$.ajax(ajaxOptions);}
}
}
if(ret[0] === false) {
$("#DelError>td","#"+dtbl).html(ret[1]);
$("#DelError","#"+dtbl).show();
}
return false;
});
$("#eData", "#"+dtbl+"_2").click(function(){
$.jgrid.hideModal("#"+$.jgrid.jqID(IDs.themodal),{gb:"#gbox_"+$.jgrid.jqID(gID),jqm:rp_ge[$t.p.id].jqModal, onClose: rp_ge[$t.p.id].onClose});
return false;
});
if(onBeforeShow) {rp_ge[$t.p.id].beforeShowForm.call($t,$("#"+dtbl));}
$.jgrid.viewModal("#"+$.jgrid.jqID(IDs.themodal),{gbox:"#gbox_"+$.jgrid.jqID(gID),jqm:rp_ge[$t.p.id].jqModal, overlay: rp_ge[$t.p.id].overlay, modal:rp_ge[$t.p.id].modal});
if(onAfterShow) {rp_ge[$t.p.id].afterShowForm.call($t,$("#"+dtbl));}
}
if(rp_ge[$t.p.id].closeOnEscape===true) {
setTimeout(function(){$(".ui-jqdialog-titlebar-close","#"+$.jgrid.jqID(IDs.modalhead)).focus();},0);
}
});
},
navGrid : function (elem, o, pEdit,pAdd,pDel,pSearch, pView) {
o = $.extend({
edit: true,
editicon: "ui-icon-pencil",
add: true,
addicon:"ui-icon-plus",
del: true,
delicon:"ui-icon-trash",
search: true,
searchicon:"ui-icon-search",
refresh: true,
refreshicon:"ui-icon-refresh",
refreshstate: 'firstpage',
view: false,
viewicon : "ui-icon-document",
position : "left",
closeOnEscape : true,
beforeRefresh : null,
afterRefresh : null,
cloneToTop : false,
alertwidth : 200,
alertheight : 'auto',
alerttop: null,
alertleft: null,
alertzIndex : null
}, $.jgrid.nav, o ||{});
return this.each(function() {
if(this.nav) {return;}
var alertIDs = {themodal: 'alertmod_' + this.p.id, modalhead: 'alerthd_' + this.p.id,modalcontent: 'alertcnt_' + this.p.id},
$t = this, twd, tdw;
if(!$t.grid || typeof elem !== 'string') {return;}
if ($("#"+alertIDs.themodal)[0] === undefined) {
if(!o.alerttop && !o.alertleft) {
if (window.innerWidth !== undefined) {
o.alertleft = window.innerWidth;
o.alerttop = window.innerHeight;
} else if (document.documentElement !== undefined && document.documentElement.clientWidth !== undefined && document.documentElement.clientWidth !== 0) {
o.alertleft = document.documentElement.clientWidth;
o.alerttop = document.documentElement.clientHeight;
} else {
o.alertleft=1024;
o.alerttop=768;
}
o.alertleft = o.alertleft/2 - parseInt(o.alertwidth,10)/2;
o.alerttop = o.alerttop/2-25;
}
$.jgrid.createModal(alertIDs,
"<div>"+o.alerttext+"</div><span tabindex='0'><span tabindex='-1' id='jqg_alrt'></span></span>",
{
gbox:"#gbox_"+$.jgrid.jqID($t.p.id),
jqModal:true,
drag:true,
resize:true,
caption:o.alertcap,
top:o.alerttop,
left:o.alertleft,
width:o.alertwidth,
height: o.alertheight,
closeOnEscape:o.closeOnEscape,
zIndex: o.alertzIndex
},
"#gview_"+$.jgrid.jqID($t.p.id),
$("#gbox_"+$.jgrid.jqID($t.p.id))[0],
true
);
}
var clone = 1, i,
onHoverIn = function () {
if (!$(this).hasClass('ui-state-disabled')) {
$(this).addClass("ui-state-hover");
}
},
onHoverOut = function () {
$(this).removeClass("ui-state-hover");
};
if(o.cloneToTop && $t.p.toppager) {clone = 2;}
for(i = 0; i<clone; i++) {
var tbd,
navtbl = $("<table cellspacing='0' cellpadding='0' border='0' class='ui-pg-table navtable' style='float:left;table-layout:auto;'><tbody><tr></tr></tbody></table>"),
sep = "<td class='ui-pg-button ui-state-disabled' style='width:4px;'><span class='ui-separator'></span></td>",
pgid, elemids;
if(i===0) {
pgid = elem;
elemids = $t.p.id;
if(pgid == $t.p.toppager) {
elemids += "_top";
clone = 1;
}
} else {
pgid = $t.p.toppager;
elemids = $t.p.id+"_top";
}
if($t.p.direction == "rtl") {$(navtbl).attr("dir","rtl").css("float","right");}
if (o.add) {
pAdd = pAdd || {};
tbd = $("<td class='ui-pg-button ui-corner-all'></td>");
$(tbd).append("<div class='ui-pg-div'><span class='ui-icon "+o.addicon+"'></span>"+o.addtext+"</div>");
$("tr",navtbl).append(tbd);
$(tbd,navtbl)
.attr({"title":o.addtitle || "",id : pAdd.id || "add_"+elemids})
.click(function(){
if (!$(this).hasClass('ui-state-disabled')) {
if ($.isFunction( o.addfunc )) {
o.addfunc.call($t);
} else {
$($t).jqGrid("editGridRow","new",pAdd);
}
}
return false;
}).hover(onHoverIn, onHoverOut);
tbd = null;
}
if (o.edit) {
tbd = $("<td class='ui-pg-button ui-corner-all'></td>");
pEdit = pEdit || {};
$(tbd).append("<div class='ui-pg-div'><span class='ui-icon "+o.editicon+"'></span>"+o.edittext+"</div>");
$("tr",navtbl).append(tbd);
$(tbd,navtbl)
.attr({"title":o.edittitle || "",id: pEdit.id || "edit_"+elemids})
.click(function(){
if (!$(this).hasClass('ui-state-disabled')) {
var sr = $t.p.selrow;
if (sr) {
if($.isFunction( o.editfunc ) ) {
o.editfunc.call($t, sr);
} else {
$($t).jqGrid("editGridRow",sr,pEdit);
}
} else {
$.jgrid.viewModal("#"+alertIDs.themodal,{gbox:"#gbox_"+$.jgrid.jqID($t.p.id),jqm:true});
$("#jqg_alrt").focus();
}
}
return false;
}).hover(onHoverIn, onHoverOut);
tbd = null;
}
if (o.view) {
tbd = $("<td class='ui-pg-button ui-corner-all'></td>");
pView = pView || {};
$(tbd).append("<div class='ui-pg-div'><span class='ui-icon "+o.viewicon+"'></span>"+o.viewtext+"</div>");
$("tr",navtbl).append(tbd);
$(tbd,navtbl)
.attr({"title":o.viewtitle || "",id: pView.id || "view_"+elemids})
.click(function(){
if (!$(this).hasClass('ui-state-disabled')) {
var sr = $t.p.selrow;
if (sr) {
if($.isFunction( o.viewfunc ) ) {
o.viewfunc.call($t, sr);
} else {
$($t).jqGrid("viewGridRow",sr,pView);
}
} else {
$.jgrid.viewModal("#"+alertIDs.themodal,{gbox:"#gbox_"+$.jgrid.jqID($t.p.id),jqm:true});
$("#jqg_alrt").focus();
}
}
return false;
}).hover(onHoverIn, onHoverOut);
tbd = null;
}
if (o.del) {
tbd = $("<td class='ui-pg-button ui-corner-all'></td>");
pDel = pDel || {};
$(tbd).append("<div class='ui-pg-div'><span class='ui-icon "+o.delicon+"'></span>"+o.deltext+"</div>");
$("tr",navtbl).append(tbd);
$(tbd,navtbl)
.attr({"title":o.deltitle || "",id: pDel.id || "del_"+elemids})
.click(function(){
if (!$(this).hasClass('ui-state-disabled')) {
var dr;
if($t.p.multiselect) {
dr = $t.p.selarrrow;
if(dr.length===0) {dr = null;}
} else {
dr = $t.p.selrow;
}
if(dr){
if($.isFunction( o.delfunc )){
o.delfunc.call($t, dr);
}else{
$($t).jqGrid("delGridRow",dr,pDel);
}
} else {
$.jgrid.viewModal("#"+alertIDs.themodal,{gbox:"#gbox_"+$.jgrid.jqID($t.p.id),jqm:true});$("#jqg_alrt").focus();
}
}
return false;
}).hover(onHoverIn, onHoverOut);
tbd = null;
}
if(o.add || o.edit || o.del || o.view) {$("tr",navtbl).append(sep);}
if (o.search) {
tbd = $("<td class='ui-pg-button ui-corner-all'></td>");
pSearch = pSearch || {};
$(tbd).append("<div class='ui-pg-div'><span class='ui-icon "+o.searchicon+"'></span>"+o.searchtext+"</div>");
$("tr",navtbl).append(tbd);
$(tbd,navtbl)
.attr({"title":o.searchtitle || "",id:pSearch.id || "search_"+elemids})
.click(function(){
if (!$(this).hasClass('ui-state-disabled')) {
if($.isFunction( o.searchfunc )) {
o.searchfunc.call($t, pSearch);
} else {
$($t).jqGrid("searchGrid",pSearch);
}
}
return false;
}).hover(onHoverIn, onHoverOut);
if (pSearch.showOnLoad && pSearch.showOnLoad === true) {
$(tbd,navtbl).click();
}
tbd = null;
}
if (o.refresh) {
tbd = $("<td class='ui-pg-button ui-corner-all'></td>");
$(tbd).append("<div class='ui-pg-div'><span class='ui-icon "+o.refreshicon+"'></span>"+o.refreshtext+"</div>");
$("tr",navtbl).append(tbd);
$(tbd,navtbl)
.attr({"title":o.refreshtitle || "",id: "refresh_"+elemids})
.click(function(){
if (!$(this).hasClass('ui-state-disabled')) {
if($.isFunction(o.beforeRefresh)) {o.beforeRefresh.call($t);}
$t.p.search = false;
try {
var gID = $t.p.id;
$t.p.postData.filters ="";
$("#fbox_"+$.jgrid.jqID(gID)).jqFilter('resetFilter');
if($.isFunction($t.clearToolbar)) {$t.clearToolbar.call($t,false);}
} catch (e) {}
switch (o.refreshstate) {
case 'firstpage':
$($t).trigger("reloadGrid", [{page:1}]);
break;
case 'current':
$($t).trigger("reloadGrid", [{current:true}]);
break;
}
if($.isFunction(o.afterRefresh)) {o.afterRefresh.call($t);}
}
return false;
}).hover(onHoverIn, onHoverOut);
tbd = null;
}
tdw = $(".ui-jqgrid").css("font-size") || "11px";
$('body').append("<div id='testpg2' class='ui-jqgrid ui-widget ui-widget-content' style='font-size:"+tdw+";visibility:hidden;' ></div>");
twd = $(navtbl).clone().appendTo("#testpg2").width();
$("#testpg2").remove();
$(pgid+"_"+o.position,pgid).append(navtbl);
if($t.p._nvtd) {
if(twd > $t.p._nvtd[0] ) {
$(pgid+"_"+o.position,pgid).width(twd);
$t.p._nvtd[0] = twd;
}
$t.p._nvtd[1] = twd;
}
tdw =null;twd=null;navtbl =null;
this.nav = true;
}
});
},
navButtonAdd : function (elem, p) {
p = $.extend({
caption : "newButton",
title: '',
buttonicon : 'ui-icon-newwin',
onClickButton: null,
position : "last",
cursor : 'pointer'
}, p ||{});
return this.each(function() {
if( !this.grid) {return;}
if( typeof elem === "string" && elem.indexOf("#") !== 0) {elem = "#"+$.jgrid.jqID(elem);}
var findnav = $(".navtable",elem)[0], $t = this;
if (findnav) {
if( p.id && $("#"+$.jgrid.jqID(p.id), findnav)[0] !== undefined ) {return;}
var tbd = $("<td></td>");
if(p.buttonicon.toString().toUpperCase() == "NONE") {
$(tbd).addClass('ui-pg-button ui-corner-all').append("<div class='ui-pg-div'>"+p.caption+"</div>");
} else {
$(tbd).addClass('ui-pg-button ui-corner-all').append("<div class='ui-pg-div'><span class='ui-icon "+p.buttonicon+"'></span>"+p.caption+"</div>");
}
if(p.id) {$(tbd).attr("id",p.id);}
if(p.position=='first'){
if(findnav.rows[0].cells.length ===0 ) {
$("tr",findnav).append(tbd);
} else {
$("tr td:eq(0)",findnav).before(tbd);
}
} else {
$("tr",findnav).append(tbd);
}
$(tbd,findnav)
.attr("title",p.title || "")
.click(function(e){
if (!$(this).hasClass('ui-state-disabled')) {
if ($.isFunction(p.onClickButton) ) {p.onClickButton.call($t,e);}
}
return false;
})
.hover(
function () {
if (!$(this).hasClass('ui-state-disabled')) {
$(this).addClass('ui-state-hover');
}
},
function () {$(this).removeClass("ui-state-hover");}
);
}
});
},
navSeparatorAdd:function (elem,p) {
p = $.extend({
sepclass : "ui-separator",
sepcontent: '',
position : "last"
}, p ||{});
return this.each(function() {
if( !this.grid) {return;}
if( typeof elem === "string" && elem.indexOf("#") !== 0) {elem = "#"+$.jgrid.jqID(elem);}
var findnav = $(".navtable",elem)[0];
if(findnav) {
var sep = "<td class='ui-pg-button ui-state-disabled' style='width:4px;'><span class='"+p.sepclass+"'></span>"+p.sepcontent+"</td>";
if (p.position === 'first') {
if (findnav.rows[0].cells.length === 0) {
$("tr", findnav).append(sep);
} else {
$("tr td:eq(0)", findnav).before(sep);
}
} else {
$("tr", findnav).append(sep);
}
}
});
},
GridToForm : function( rowid, formid ) {
return this.each(function(){
var $t = this, i;
if (!$t.grid) {return;}
var rowdata = $($t).jqGrid("getRowData",rowid);
if (rowdata) {
for(i in rowdata) {
if(rowdata.hasOwnProperty(i)) {
if ( $("[name="+$.jgrid.jqID(i)+"]",formid).is("input:radio") || $("[name="+$.jgrid.jqID(i)+"]",formid).is("input:checkbox")) {
$("[name="+$.jgrid.jqID(i)+"]",formid).each( function() {
if( $(this).val() == rowdata[i] ) {
$(this)[$t.p.useProp ? 'prop': 'attr']("checked",true);
} else {
$(this)[$t.p.useProp ? 'prop': 'attr']("checked", false);
}
});
} else {
// this is very slow on big table and form.
$("[name="+$.jgrid.jqID(i)+"]",formid).val(rowdata[i]);
}
}
}
}
});
},
FormToGrid : function(rowid, formid, mode, position){
return this.each(function() {
var $t = this;
if(!$t.grid) {return;}
if(!mode) {mode = 'set';}
if(!position) {position = 'first';}
var fields = $(formid).serializeArray();
var griddata = {};
$.each(fields, function(i, field){
griddata[field.name] = field.value;
});
if(mode=='add') {$($t).jqGrid("addRowData",rowid,griddata, position);}
else if(mode=='set') {$($t).jqGrid("setRowData",rowid,griddata);}
});
}
});
})(jQuery);
| JavaScript |
/*jshint eqeqeq:false */
/*global jQuery */
(function($){
/*
* jqGrid common function
* Tony Tomov tony@trirand.com
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl-2.0.html
*/
"use strict";
$.extend($.jgrid,{
// Modal functions
showModal : function(h) {
h.w.show();
},
closeModal : function(h) {
h.w.hide().attr("aria-hidden","true");
if(h.o) {h.o.remove();}
},
hideModal : function (selector,o) {
o = $.extend({jqm : true, gb :''}, o || {});
if(o.onClose) {
var oncret = o.gb && typeof o.gb === "string" && o.gb.substr(0,6) === "#gbox_" ? o.onClose.call($("#" + o.gb.substr(6))[0], selector) : o.onClose(selector);
if (typeof oncret === 'boolean' && !oncret ) { return; }
}
if ($.fn.jqm && o.jqm === true) {
$(selector).attr("aria-hidden","true").jqmHide();
} else {
if(o.gb !== '') {
try {$(".jqgrid-overlay:first",o.gb).hide();} catch (e){}
}
$(selector).hide().attr("aria-hidden","true");
}
},
//Helper functions
findPos : function(obj) {
var curleft = 0, curtop = 0;
if (obj.offsetParent) {
do {
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
} while (obj = obj.offsetParent);
//do not change obj == obj.offsetParent
}
return [curleft,curtop];
},
createModal : function(aIDs, content, p, insertSelector, posSelector, appendsel, css) {
p = $.extend(true, {}, $.jgrid.jqModal || {}, p);
var mw = document.createElement('div'), rtlsup, self = this;
css = $.extend({}, css || {});
rtlsup = $(p.gbox).attr("dir") == "rtl" ? true : false;
mw.className= "ui-widget ui-widget-content ui-corner-all ui-jqdialog";
mw.id = aIDs.themodal;
var mh = document.createElement('div');
mh.className = "ui-jqdialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix";
mh.id = aIDs.modalhead;
$(mh).append("<span class='ui-jqdialog-title'>"+p.caption+"</span>");
var ahr= $("<a href='javascript:void(0)' class='ui-jqdialog-titlebar-close ui-corner-all'></a>")
.hover(function(){ahr.addClass('ui-state-hover');},
function(){ahr.removeClass('ui-state-hover');})
.append("<span class='ui-icon ui-icon-closethick'></span>");
$(mh).append(ahr);
if(rtlsup) {
mw.dir = "rtl";
$(".ui-jqdialog-title",mh).css("float","right");
$(".ui-jqdialog-titlebar-close",mh).css("left",0.3+"em");
} else {
mw.dir = "ltr";
$(".ui-jqdialog-title",mh).css("float","left");
$(".ui-jqdialog-titlebar-close",mh).css("right",0.3+"em");
}
var mc = document.createElement('div');
$(mc).addClass("ui-jqdialog-content ui-widget-content").attr("id",aIDs.modalcontent);
$(mc).append(content);
mw.appendChild(mc);
$(mw).prepend(mh);
if(appendsel===true) { $('body').append(mw); } //append as first child in body -for alert dialog
else if (typeof appendsel === "string") {
$(appendsel).append(mw);
} else {$(mw).insertBefore(insertSelector);}
$(mw).css(css);
if(p.jqModal === undefined) {p.jqModal = true;} // internal use
var coord = {};
if ( $.fn.jqm && p.jqModal === true) {
if(p.left ===0 && p.top===0 && p.overlay) {
var pos = [];
pos = $.jgrid.findPos(posSelector);
p.left = pos[0] + 4;
p.top = pos[1] + 4;
}
coord.top = p.top+"px";
coord.left = p.left;
} else if(p.left !==0 || p.top!==0) {
coord.left = p.left;
coord.top = p.top+"px";
}
$("a.ui-jqdialog-titlebar-close",mh).click(function(){
var oncm = $("#"+$.jgrid.jqID(aIDs.themodal)).data("onClose") || p.onClose;
var gboxclose = $("#"+$.jgrid.jqID(aIDs.themodal)).data("gbox") || p.gbox;
self.hideModal("#"+$.jgrid.jqID(aIDs.themodal),{gb:gboxclose,jqm:p.jqModal,onClose:oncm});
return false;
});
if (p.width === 0 || !p.width) {p.width = 300;}
if(p.height === 0 || !p.height) {p.height =200;}
if(!p.zIndex) {
var parentZ = $(insertSelector).parents("*[role=dialog]").filter(':first').css("z-index");
if(parentZ) {
p.zIndex = parseInt(parentZ,10)+2;
} else {
p.zIndex = 950;
}
}
var rtlt = 0;
if( rtlsup && coord.left && !appendsel) {
rtlt = $(p.gbox).width()- (!isNaN(p.width) ? parseInt(p.width,10) :0) - 8; // to do
// just in case
coord.left = parseInt(coord.left,10) + parseInt(rtlt,10);
}
if(coord.left) { coord.left += "px"; }
$(mw).css($.extend({
width: isNaN(p.width) ? "auto": p.width+"px",
height:isNaN(p.height) ? "auto" : p.height + "px",
zIndex:p.zIndex,
overflow: 'hidden'
},coord))
.attr({tabIndex: "-1","role":"dialog","aria-labelledby":aIDs.modalhead,"aria-hidden":"true"});
if(p.drag === undefined) { p.drag=true;}
if(p.resize === undefined) {p.resize=true;}
if (p.drag) {
$(mh).css('cursor','move');
if($.fn.jqDrag) {
$(mw).jqDrag(mh);
} else {
try {
$(mw).draggable({handle: $("#"+$.jgrid.jqID(mh.id))});
} catch (e) {}
}
}
if(p.resize) {
if($.fn.jqResize) {
$(mw).append("<div class='jqResize ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se'></div>");
$("#"+$.jgrid.jqID(aIDs.themodal)).jqResize(".jqResize",aIDs.scrollelm ? "#"+$.jgrid.jqID(aIDs.scrollelm) : false);
} else {
try {
$(mw).resizable({handles: 'se, sw',alsoResize: aIDs.scrollelm ? "#"+$.jgrid.jqID(aIDs.scrollelm) : false});
} catch (r) {}
}
}
if(p.closeOnEscape === true){
$(mw).keydown( function( e ) {
if( e.which == 27 ) {
var cone = $("#"+$.jgrid.jqID(aIDs.themodal)).data("onClose") || p.onClose;
self.hideModal("#"+$.jgrid.jqID(aIDs.themodal),{gb:p.gbox,jqm:p.jqModal,onClose: cone});
}
});
}
},
viewModal : function (selector,o){
o = $.extend({
toTop: true,
overlay: 10,
modal: false,
overlayClass : 'ui-widget-overlay',
onShow: $.jgrid.showModal,
onHide: $.jgrid.closeModal,
gbox: '',
jqm : true,
jqM : true
}, o || {});
if ($.fn.jqm && o.jqm === true) {
if(o.jqM) { $(selector).attr("aria-hidden","false").jqm(o).jqmShow(); }
else {$(selector).attr("aria-hidden","false").jqmShow();}
} else {
if(o.gbox !== '') {
$(".jqgrid-overlay:first",o.gbox).show();
$(selector).data("gbox",o.gbox);
}
$(selector).show().attr("aria-hidden","false");
try{$(':input:visible',selector)[0].focus();}catch(_){}
}
},
info_dialog : function(caption, content,c_b, modalopt) {
var mopt = {
width:290,
height:'auto',
dataheight: 'auto',
drag: true,
resize: false,
left:250,
top:170,
zIndex : 1000,
jqModal : true,
modal : false,
closeOnEscape : true,
align: 'center',
buttonalign : 'center',
buttons : []
// {text:'textbutt', id:"buttid", onClick : function(){...}}
// if the id is not provided we set it like info_button_+ the index in the array - i.e info_button_0,info_button_1...
};
$.extend(true, mopt, $.jgrid.jqModal || {}, {caption:"<b>"+caption+"</b>"}, modalopt || {});
var jm = mopt.jqModal, self = this;
if($.fn.jqm && !jm) { jm = false; }
// in case there is no jqModal
var buttstr ="", i;
if(mopt.buttons.length > 0) {
for(i=0;i<mopt.buttons.length;i++) {
if(mopt.buttons[i].id === undefined) { mopt.buttons[i].id = "info_button_"+i; }
buttstr += "<a href='javascript:void(0)' id='"+mopt.buttons[i].id+"' class='fm-button ui-state-default ui-corner-all'>"+mopt.buttons[i].text+"</a>";
}
}
var dh = isNaN(mopt.dataheight) ? mopt.dataheight : mopt.dataheight+"px",
cn = "text-align:"+mopt.align+";";
var cnt = "<div id='info_id'>";
cnt += "<div id='infocnt' style='margin:0px;padding-bottom:1em;width:100%;overflow:auto;position:relative;height:"+dh+";"+cn+"'>"+content+"</div>";
cnt += c_b ? "<div class='ui-widget-content ui-helper-clearfix' style='text-align:"+mopt.buttonalign+";padding-bottom:0.8em;padding-top:0.5em;background-image: none;border-width: 1px 0 0 0;'><a href='javascript:void(0)' id='closedialog' class='fm-button ui-state-default ui-corner-all'>"+c_b+"</a>"+buttstr+"</div>" :
buttstr !== "" ? "<div class='ui-widget-content ui-helper-clearfix' style='text-align:"+mopt.buttonalign+";padding-bottom:0.8em;padding-top:0.5em;background-image: none;border-width: 1px 0 0 0;'>"+buttstr+"</div>" : "";
cnt += "</div>";
try {
if($("#info_dialog").attr("aria-hidden") == "false") {
$.jgrid.hideModal("#info_dialog",{jqm:jm});
}
$("#info_dialog").remove();
} catch (e){}
$.jgrid.createModal({
themodal:'info_dialog',
modalhead:'info_head',
modalcontent:'info_content',
scrollelm: 'infocnt'},
cnt,
mopt,
'','',true
);
// attach onclick after inserting into the dom
if(buttstr) {
$.each(mopt.buttons,function(i){
$("#"+$.jgrid.jqID(this.id),"#info_id").bind('click',function(){mopt.buttons[i].onClick.call($("#info_dialog")); return false;});
});
}
$("#closedialog", "#info_id").click(function(){
self.hideModal("#info_dialog",{jqm:jm});
return false;
});
$(".fm-button","#info_dialog").hover(
function(){$(this).addClass('ui-state-hover');},
function(){$(this).removeClass('ui-state-hover');}
);
if($.isFunction(mopt.beforeOpen) ) { mopt.beforeOpen(); }
$.jgrid.viewModal("#info_dialog",{
onHide: function(h) {
h.w.hide().remove();
if(h.o) { h.o.remove(); }
},
modal :mopt.modal,
jqm:jm
});
if($.isFunction(mopt.afterOpen) ) { mopt.afterOpen(); }
try{ $("#info_dialog").focus();} catch (m){}
},
bindEv: function (el, opt, $t) {
if($.isFunction(opt.dataInit)) {
opt.dataInit.call($t,el);
}
if(opt.dataEvents) {
$.each(opt.dataEvents, function() {
if (this.data !== undefined) {
$(el).bind(this.type, this.data, this.fn);
} else {
$(el).bind(this.type, this.fn);
}
});
}
},
// Form Functions
createEl : function(eltype,options,vl,autowidth, ajaxso) {
var elem = "", $t = this;
function setAttributes(elm, atr, exl ) {
var exclude = ['dataInit','dataEvents','dataUrl', 'buildSelect','sopt', 'searchhidden', 'defaultValue', 'attr', 'custom_element', 'custom_value'];
if(exl !== undefined && $.isArray(exl)) {
$.merge(exclude, exl);
}
$.each(atr, function(key, value){
if($.inArray(key, exclude) === -1) {
$(elm).attr(key,value);
}
});
if(!atr.hasOwnProperty('id')) {
$(elm).attr('id', $.jgrid.randId());
}
}
switch (eltype)
{
case "textarea" :
elem = document.createElement("textarea");
if(autowidth) {
if(!options.cols) { $(elem).css({width:"98%"});}
} else if (!options.cols) { options.cols = 20; }
if(!options.rows) { options.rows = 2; }
if(vl==' ' || vl==' ' || (vl.length==1 && vl.charCodeAt(0)==160)) {vl="";}
elem.value = vl;
setAttributes(elem, options);
$(elem).attr({"role":"textbox","multiline":"true"});
break;
case "checkbox" : //what code for simple checkbox
elem = document.createElement("input");
elem.type = "checkbox";
if( !options.value ) {
var vl1 = vl.toLowerCase();
if(vl1.search(/(false|0|no|off|undefined)/i)<0 && vl1!=="") {
elem.checked=true;
elem.defaultChecked=true;
elem.value = vl;
} else {
elem.value = "on";
}
$(elem).attr("offval","off");
} else {
var cbval = options.value.split(":");
if(vl === cbval[0]) {
elem.checked=true;
elem.defaultChecked=true;
}
elem.value = cbval[0];
$(elem).attr("offval",cbval[1]);
}
setAttributes(elem, options, ['value']);
$(elem).attr("role","checkbox");
break;
case "select" :
elem = document.createElement("select");
elem.setAttribute("role","select");
var msl, ovm = [];
if(options.multiple===true) {
msl = true;
elem.multiple="multiple";
$(elem).attr("aria-multiselectable","true");
} else { msl = false; }
if(options.dataUrl !== undefined) {
var rowid = options.name ? String(options.id).substring(0, String(options.id).length - String(options.name).length - 1) : String(options.id),
postData = options.postData || ajaxso.postData;
if ($t.p && $t.p.idPrefix) {
rowid = $.jgrid.stripPref($t.p.idPrefix, rowid);
} else {
postData = undefined; // don't use postData for searching from jqFilter. One can implement the feature in the future if required.
}
$.ajax($.extend({
url: options.dataUrl,
type : "GET",
dataType: "html",
data: $.isFunction(postData) ? postData.call($t, rowid, vl, String(options.name)) : postData,
context: {elem:elem, options:options, vl:vl},
success: function(data){
var a, ovm = [], elem = this.elem, vl = this.vl,
options = $.extend({},this.options),
msl = options.multiple===true;
if($.isFunction(options.buildSelect)) {
var b = options.buildSelect.call($t,data);
a = $(b).html();
} else {
a = $(data).html();
}
if(a) {
$(elem).append(a);
setAttributes(elem, options);
if(options.size === undefined) { options.size = msl ? 3 : 1;}
if(msl) {
ovm = vl.split(",");
ovm = $.map(ovm,function(n){return $.trim(n);});
} else {
ovm[0] = $.trim(vl);
}
//$(elem).attr(options);
setTimeout(function(){
$("option",elem).each(function(i){
//if(i===0) { this.selected = ""; }
// fix IE8/IE7 problem with selecting of the first item on multiple=true
if (i === 0 && elem.multiple) { this.selected = false; }
$(this).attr("role","option");
if($.inArray($.trim($(this).text()),ovm) > -1 || $.inArray($.trim($(this).val()),ovm) > -1 ) {
this.selected= "selected";
}
});
},0);
}
}
},ajaxso || {}));
} else if(options.value) {
var i;
if(options.size === undefined) {
options.size = msl ? 3 : 1;
}
if(msl) {
ovm = vl.split(",");
ovm = $.map(ovm,function(n){return $.trim(n);});
}
if(typeof options.value === 'function') { options.value = options.value(); }
var so,sv, ov,
sep = options.separator === undefined ? ":" : options.separator,
delim = options.delimiter === undefined ? ";" : options.delimiter;
if(typeof options.value === 'string') {
so = options.value.split(delim);
for(i=0; i<so.length;i++){
sv = so[i].split(sep);
if(sv.length > 2 ) {
sv[1] = $.map(sv,function(n,ii){if(ii>0) { return n;} }).join(sep);
}
ov = document.createElement("option");
ov.setAttribute("role","option");
ov.value = sv[0]; ov.innerHTML = sv[1];
elem.appendChild(ov);
if (!msl && ($.trim(sv[0]) == $.trim(vl) || $.trim(sv[1]) == $.trim(vl))) { ov.selected ="selected"; }
if (msl && ($.inArray($.trim(sv[1]), ovm)>-1 || $.inArray($.trim(sv[0]), ovm)>-1)) {ov.selected ="selected";}
}
} else if (typeof options.value === 'object') {
var oSv = options.value, key;
for (key in oSv) {
if (oSv.hasOwnProperty(key ) ){
ov = document.createElement("option");
ov.setAttribute("role","option");
ov.value = key; ov.innerHTML = oSv[key];
elem.appendChild(ov);
if (!msl && ( $.trim(key) == $.trim(vl) || $.trim(oSv[key]) == $.trim(vl)) ) { ov.selected ="selected"; }
if (msl && ($.inArray($.trim(oSv[key]),ovm)>-1 || $.inArray($.trim(key),ovm)>-1)) { ov.selected ="selected"; }
}
}
}
setAttributes(elem, options, ['value']);
}
break;
case "text" :
case "password" :
case "button" :
var role;
if(eltype=="button") { role = "button"; }
else { role = "textbox"; }
elem = document.createElement("input");
elem.type = eltype;
elem.value = vl;
setAttributes(elem, options);
if(eltype != "button"){
if(autowidth) {
if(!options.size) { $(elem).css({width:"98%"}); }
} else if (!options.size) { options.size = 20; }
}
$(elem).attr("role",role);
break;
case "image" :
case "file" :
elem = document.createElement("input");
elem.type = eltype;
setAttributes(elem, options);
break;
case "custom" :
elem = document.createElement("span");
try {
if($.isFunction(options.custom_element)) {
var celm = options.custom_element.call($t,vl,options);
if(celm) {
celm = $(celm).addClass("customelement").attr({id:options.id,name:options.name});
$(elem).empty().append(celm);
} else {
throw "e2";
}
} else {
throw "e1";
}
} catch (e) {
if (e=="e1") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_element' "+$.jgrid.edit.msg.nodefined, $.jgrid.edit.bClose);}
if (e=="e2") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_element' "+$.jgrid.edit.msg.novalue,$.jgrid.edit.bClose);}
else { $.jgrid.info_dialog($.jgrid.errors.errcap,typeof e==="string"?e:e.message,$.jgrid.edit.bClose); }
}
break;
}
return elem;
},
// Date Validation Javascript
checkDate : function (format, date) {
var daysInFebruary = function(year){
// February has 29 days in any year evenly divisible by four,
// EXCEPT for centurial years which are not also divisible by 400.
return (((year % 4 === 0) && ( year % 100 !== 0 || (year % 400 === 0))) ? 29 : 28 );
},
daysArray = function(n) {
var i;
for (i = 1; i <= n; i++) {
this[i] = 31;
if (i==4 || i==6 || i==9 || i==11) {this[i] = 30;}
if (i==2) {this[i] = 29;}
}
return this;
};
var tsp = {}, sep;
format = format.toLowerCase();
//we search for /,-,. for the date separator
if(format.indexOf("/") != -1) {
sep = "/";
} else if(format.indexOf("-") != -1) {
sep = "-";
} else if(format.indexOf(".") != -1) {
sep = ".";
} else {
sep = "/";
}
format = format.split(sep);
date = date.split(sep);
if (date.length != 3) { return false; }
var j=-1,yln, dln=-1, mln=-1, i;
for(i=0;i<format.length;i++){
var dv = isNaN(date[i]) ? 0 : parseInt(date[i],10);
tsp[format[i]] = dv;
yln = format[i];
if(yln.indexOf("y") != -1) { j=i; }
if(yln.indexOf("m") != -1) { mln=i; }
if(yln.indexOf("d") != -1) { dln=i; }
}
if (format[j] == "y" || format[j] == "yyyy") {
yln=4;
} else if(format[j] =="yy"){
yln = 2;
} else {
yln = -1;
}
var daysInMonth = daysArray(12),
strDate;
if (j === -1) {
return false;
}
strDate = tsp[format[j]].toString();
if(yln == 2 && strDate.length == 1) {yln = 1;}
if (strDate.length != yln || (tsp[format[j]]===0 && date[j]!="00")){
return false;
}
if(mln === -1) {
return false;
}
strDate = tsp[format[mln]].toString();
if (strDate.length<1 || tsp[format[mln]]<1 || tsp[format[mln]]>12){
return false;
}
if(dln === -1) {
return false;
}
strDate = tsp[format[dln]].toString();
if (strDate.length<1 || tsp[format[dln]]<1 || tsp[format[dln]]>31 || (tsp[format[mln]]==2 && tsp[format[dln]]>daysInFebruary(tsp[format[j]])) || tsp[format[dln]] > daysInMonth[tsp[format[mln]]]){
return false;
}
return true;
},
isEmpty : function(val)
{
if (val.match(/^\s+$/) || val === "") {
return true;
}
return false;
},
checkTime : function(time){
// checks only hh:ss (and optional am/pm)
var re = /^(\d{1,2}):(\d{2})([ap]m)?$/,regs;
if(!$.jgrid.isEmpty(time))
{
regs = time.match(re);
if(regs) {
if(regs[3]) {
if(regs[1] < 1 || regs[1] > 12) { return false; }
} else {
if(regs[1] > 23) { return false; }
}
if(regs[2] > 59) {
return false;
}
} else {
return false;
}
}
return true;
},
checkValues : function(val, valref,g, customobject, nam) {
var edtrul,i, nm, dft, len;
if(customobject === undefined) {
if(typeof valref==='string'){
for( i =0, len=g.p.colModel.length;i<len; i++){
if(g.p.colModel[i].name==valref) {
edtrul = g.p.colModel[i].editrules;
valref = i;
try { nm = g.p.colModel[i].formoptions.label; } catch (e) {}
break;
}
}
} else if(valref >=0) {
edtrul = g.p.colModel[valref].editrules;
}
} else {
edtrul = customobject;
nm = nam===undefined ? "_" : nam;
}
if(edtrul) {
if(!nm) { nm = g.p.colNames[valref]; }
if(edtrul.required === true) {
if( $.jgrid.isEmpty(val) ) { return [false,nm+": "+$.jgrid.edit.msg.required,""]; }
}
// force required
var rqfield = edtrul.required === false ? false : true;
if(edtrul.number === true) {
if( !(rqfield === false && $.jgrid.isEmpty(val)) ) {
if(isNaN(val)) { return [false,nm+": "+$.jgrid.edit.msg.number,""]; }
}
}
if(edtrul.minValue !== undefined && !isNaN(edtrul.minValue)) {
if (parseFloat(val) < parseFloat(edtrul.minValue) ) { return [false,nm+": "+$.jgrid.edit.msg.minValue+" "+edtrul.minValue,""];}
}
if(edtrul.maxValue !== undefined && !isNaN(edtrul.maxValue)) {
if (parseFloat(val) > parseFloat(edtrul.maxValue) ) { return [false,nm+": "+$.jgrid.edit.msg.maxValue+" "+edtrul.maxValue,""];}
}
var filter;
if(edtrul.email === true) {
if( !(rqfield === false && $.jgrid.isEmpty(val)) ) {
// taken from $ Validate plugin
filter = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i;
if(!filter.test(val)) {return [false,nm+": "+$.jgrid.edit.msg.email,""];}
}
}
if(edtrul.integer === true) {
if( !(rqfield === false && $.jgrid.isEmpty(val)) ) {
if(isNaN(val)) { return [false,nm+": "+$.jgrid.edit.msg.integer,""]; }
if ((val % 1 !== 0) || (val.indexOf('.') != -1)) { return [false,nm+": "+$.jgrid.edit.msg.integer,""];}
}
}
if(edtrul.date === true) {
if( !(rqfield === false && $.jgrid.isEmpty(val)) ) {
if(g.p.colModel[valref].formatoptions && g.p.colModel[valref].formatoptions.newformat) {
dft = g.p.colModel[valref].formatoptions.newformat;
} else {
dft = g.p.colModel[valref].datefmt || "Y-m-d";
}
if(!$.jgrid.checkDate (dft, val)) { return [false,nm+": "+$.jgrid.edit.msg.date+" - "+dft,""]; }
}
}
if(edtrul.time === true) {
if( !(rqfield === false && $.jgrid.isEmpty(val)) ) {
if(!$.jgrid.checkTime (val)) { return [false,nm+": "+$.jgrid.edit.msg.date+" - hh:mm (am/pm)",""]; }
}
}
if(edtrul.url === true) {
if( !(rqfield === false && $.jgrid.isEmpty(val)) ) {
filter = /^(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
if(!filter.test(val)) {return [false,nm+": "+$.jgrid.edit.msg.url,""];}
}
}
if(edtrul.custom === true) {
if( !(rqfield === false && $.jgrid.isEmpty(val)) ) {
if($.isFunction(edtrul.custom_func)) {
var ret = edtrul.custom_func.call(g,val,nm);
return $.isArray(ret) ? ret : [false,$.jgrid.edit.msg.customarray,""];
}
return [false,$.jgrid.edit.msg.customfcheck,""];
}
}
}
return [true,"",""];
}
});
})(jQuery);
| JavaScript |
/*jshint eqeqeq:false, eqnull:true, devel:true */
/*global jQuery, xmlJsonClass */
(function($){
/*
* jqGrid extension for constructing Grid Data from external file
* Tony Tomov tony@trirand.com
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl-2.0.html
**/
"use strict";
$.jgrid.extend({
jqGridImport : function(o) {
o = $.extend({
imptype : "xml", // xml, json, xmlstring, jsonstring
impstring: "",
impurl: "",
mtype: "GET",
impData : {},
xmlGrid :{
config : "roots>grid",
data: "roots>rows"
},
jsonGrid :{
config : "grid",
data: "data"
},
ajaxOptions :{}
}, o || {});
return this.each(function(){
var $t = this;
var xmlConvert = function (xml,o) {
var cnfg = $(o.xmlGrid.config,xml)[0];
var xmldata = $(o.xmlGrid.data,xml)[0], jstr, jstr1, key;
if(xmlJsonClass.xml2json && $.jgrid.parse) {
jstr = xmlJsonClass.xml2json(cnfg," ");
jstr = $.jgrid.parse(jstr);
for(key in jstr) {
if(jstr.hasOwnProperty(key)) {
jstr1=jstr[key];
}
}
if(xmldata) {
// save the datatype
var svdatatype = jstr.grid.datatype;
jstr.grid.datatype = 'xmlstring';
jstr.grid.datastr = xml;
$($t).jqGrid( jstr1 ).jqGrid("setGridParam",{datatype:svdatatype});
} else {
$($t).jqGrid( jstr1 );
}
jstr = null;jstr1=null;
} else {
alert("xml2json or parse are not present");
}
};
var jsonConvert = function (jsonstr,o){
if (jsonstr && typeof jsonstr == 'string') {
var _jsonparse = false;
if($.jgrid.useJSON) {
$.jgrid.useJSON = false;
_jsonparse = true;
}
var json = $.jgrid.parse(jsonstr);
if(_jsonparse) { $.jgrid.useJSON = true; }
var gprm = json[o.jsonGrid.config];
var jdata = json[o.jsonGrid.data];
if(jdata) {
var svdatatype = gprm.datatype;
gprm.datatype = 'jsonstring';
gprm.datastr = jdata;
$($t).jqGrid( gprm ).jqGrid("setGridParam",{datatype:svdatatype});
} else {
$($t).jqGrid( gprm );
}
}
};
switch (o.imptype){
case 'xml':
$.ajax($.extend({
url:o.impurl,
type:o.mtype,
data: o.impData,
dataType:"xml",
complete: function(xml,stat) {
if(stat == 'success') {
xmlConvert(xml.responseXML,o);
$($t).triggerHandler("jqGridImportComplete", [xml, o]);
if($.isFunction(o.importComplete)) {
o.importComplete(xml);
}
}
xml=null;
}
}, o.ajaxOptions));
break;
case 'xmlstring' :
// we need to make just the conversion and use the same code as xml
if(o.impstring && typeof o.impstring == 'string') {
var xmld = $.jgrid.stringToDoc(o.impstring);
if(xmld) {
xmlConvert(xmld,o);
$($t).triggerHandler("jqGridImportComplete", [xmld, o]);
if($.isFunction(o.importComplete)) {
o.importComplete(xmld);
}
o.impstring = null;
}
xmld = null;
}
break;
case 'json':
$.ajax($.extend({
url:o.impurl,
type:o.mtype,
data: o.impData,
dataType:"json",
complete: function(json) {
try {
jsonConvert(json.responseText,o );
$($t).triggerHandler("jqGridImportComplete", [json, o]);
if($.isFunction(o.importComplete)) {
o.importComplete(json);
}
} catch (ee){}
json=null;
}
}, o.ajaxOptions ));
break;
case 'jsonstring' :
if(o.impstring && typeof o.impstring == 'string') {
jsonConvert(o.impstring,o );
$($t).triggerHandler("jqGridImportComplete", [o.impstring, o]);
if($.isFunction(o.importComplete)) {
o.importComplete(o.impstring);
}
o.impstring = null;
}
break;
}
});
},
jqGridExport : function(o) {
o = $.extend({
exptype : "xmlstring",
root: "grid",
ident: "\t"
}, o || {});
var ret = null;
this.each(function () {
if(!this.grid) { return;}
var key, gprm = $.extend(true, {},$(this).jqGrid("getGridParam"));
// we need to check for:
// 1.multiselect, 2.subgrid 3. treegrid and remove the unneded columns from colNames
if(gprm.rownumbers) {
gprm.colNames.splice(0,1);
gprm.colModel.splice(0,1);
}
if(gprm.multiselect) {
gprm.colNames.splice(0,1);
gprm.colModel.splice(0,1);
}
if(gprm.subGrid) {
gprm.colNames.splice(0,1);
gprm.colModel.splice(0,1);
}
gprm.knv = null;
if(gprm.treeGrid) {
for (key in gprm.treeReader) {
if(gprm.treeReader.hasOwnProperty(key)) {
gprm.colNames.splice(gprm.colNames.length-1);
gprm.colModel.splice(gprm.colModel.length-1);
}
}
}
switch (o.exptype) {
case 'xmlstring' :
ret = "<"+o.root+">"+xmlJsonClass.json2xml(gprm,o.ident)+"</"+o.root+">";
break;
case 'jsonstring' :
ret = "{"+ xmlJsonClass.toJson(gprm,o.root,o.ident,false)+"}";
if(gprm.postData.filters !== undefined) {
ret=ret.replace(/filters":"/,'filters":');
ret=ret.replace(/}]}"/,'}]}');
}
break;
}
});
return ret;
},
excelExport : function(o) {
o = $.extend({
exptype : "remote",
url : null,
oper: "oper",
tag: "excel",
exportOptions : {}
}, o || {});
return this.each(function(){
if(!this.grid) { return;}
var url;
if(o.exptype == "remote") {
var pdata = $.extend({},this.p.postData);
pdata[o.oper] = o.tag;
var params = jQuery.param(pdata);
if(o.url.indexOf("?") != -1) { url = o.url+"&"+params; }
else { url = o.url+"?"+params; }
window.location = url;
}
});
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Ukrainian Translation v1.0 02.07.2009
* Sergey Dyagovchenko
* http://d.sumy.ua
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Перегляд {0} - {1} з {2}",
emptyrecords: "Немає записів для перегляду",
loadtext: "Завантаження...",
pgtext : "Стор. {0} з {1}"
},
search : {
caption: "Пошук...",
Find: "Знайти",
Reset: "Скидання",
odata : ['рівно', 'не рівно', 'менше', 'менше або рівне','більше','більше або рівне', 'починається з','не починається з','знаходиться в','не знаходиться в','закінчується на','не закінчується на','містить','не містить'],
groupOps: [ { op: "AND", text: "все" }, { op: "OR", text: "будь-який" } ],
matchText: " збігається",
rulesText: " правила"
},
edit : {
addCaption: "Додати запис",
editCaption: "Змінити запис",
bSubmit: "Зберегти",
bCancel: "Відміна",
bClose: "Закрити",
saveData: "До данних були внесені зміни! Зберегти зміни?",
bYes : "Так",
bNo : "Ні",
bExit : "Відміна",
msg: {
required:"Поле є обов'язковим",
number:"Будь ласка, введіть правильне число",
minValue:"значення повинне бути більше або дорівнює",
maxValue:"значення повинно бути менше або дорівнює",
email: "некоректна адреса електронної пошти",
integer: "Будь ласка, введення дійсне ціле значення",
date: "Будь ласка, введення дійсне значення дати",
url: "не дійсний URL. Необхідна приставка ('http://' or 'https://')",
nodefined : " is not defined!",
novalue : " return value is required!",
customarray : "Custom function should return array!",
customfcheck : "Custom function should be present in case of custom checking!"
}
},
view : {
caption: "Переглянути запис",
bClose: "Закрити"
},
del : {
caption: "Видалити",
msg: "Видалити обраний запис(и)?",
bSubmit: "Видалити",
bCancel: "Відміна"
},
nav : {
edittext: " ",
edittitle: "Змінити вибраний запис",
addtext:" ",
addtitle: "Додати новий запис",
deltext: " ",
deltitle: "Видалити вибраний запис",
searchtext: " ",
searchtitle: "Знайти записи",
refreshtext: "",
refreshtitle: "Оновити таблицю",
alertcap: "Попередження",
alerttext: "Будь ласка, виберіть запис",
viewtext: "",
viewtitle: "Переглянути обраний запис"
},
col : {
caption: "Показати/Приховати стовпці",
bSubmit: "Зберегти",
bCancel: "Відміна"
},
errors : {
errcap : "Помилка",
nourl : "URL не задан",
norecords: "Немає записів для обробки",
model : "Число полів не відповідає числу стовпців таблиці!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0,00'},
currency : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0,00'},
date : {
dayNames: [
"Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб",
"Неділя", "Понеділок", "Вівторок", "Середа", "Четвер", "П'ятниця", "Субота"
],
monthNames: [
"Січ", "Лют", "Бер", "Кві", "Тра", "Чер", "Лип", "Сер", "Вер", "Жов", "Лис", "Гру",
"Січень", "Лютий", "Березень", "Квітень", "Травень", "Червень", "Липень", "Серпень", "Вересень", "Жовтень", "Листопад", "Грудень"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
srcformat: 'Y-m-d',
newformat: 'd.m.Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n.j.Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y G:i:s",
MonthDay: "F d",
ShortTime: "G:i",
LongTime: "G:i:s",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Montenegrian Translation
* Bild Studio info@bild-studio.net
* http://www.bild-studio.com
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Pregled {0} - {1} od {2}",
emptyrecords: "Ne postoji nijedan zapis",
loadtext: "Učitivanje...",
pgtext : "Strana {0} od {1}"
},
search : {
caption: "Traženje...",
Find: "Traži",
Reset: "Resetuj",
odata : ['jednako', 'nije jednako', 'manje', 'manje ili jednako','veće','veće ili jednako', 'počinje sa','ne počinje sa','je u','nije u','završava sa','ne završava sa','sadrži','ne sadrži'],
groupOps: [ { op: "AND", text: "sva" }, { op: "OR", text: "bilo koje" } ],
matchText: " primjeni",
rulesText: " pravila"
},
edit : {
addCaption: "Dodaj zapis",
editCaption: "Izmjeni zapis",
bSubmit: "Pošalji",
bCancel: "Odustani",
bClose: "Zatvori",
saveData: "Podatak je izmjenjen! Sačuvaj izmjene?",
bYes : "Da",
bNo : "Ne",
bExit : "Odustani",
msg: {
required:"Polje je obavezno",
number:"Unesite ispravan broj",
minValue:"vrijednost mora biti veća od ili jednaka sa ",
maxValue:"vrijednost mora biti manja ili jednaka sa",
email: "nije ispravna email adresa, nije valjda da ne umiješ ukucati mail!?",
integer: "Ne zajebaji se unesi cjelobrojnu vrijednost ",
date: "Unesite ispravan datum",
url: "nije ispravan URL. Potreban je prefiks ('http://' or 'https://')",
nodefined : " nije definisan!",
novalue : " zahtjevana je povratna vrijednost!",
customarray : "Prilagođena funkcija treba da vrati niz!",
customfcheck : "Prilagođena funkcija treba da bude prisutana u slučaju prilagođene provjere!"
}
},
view : {
caption: "Pogledaj zapis",
bClose: "Zatvori"
},
del : {
caption: "Izbrisi",
msg: "Izbrisi izabran(e) zapise(e)?",
bSubmit: "Izbriši",
bCancel: "Odbaci"
},
nav : {
edittext: "",
edittitle: "Izmjeni izabrani red",
addtext:"",
addtitle: "Dodaj novi red",
deltext: "",
deltitle: "Izbriši izabran red",
searchtext: "",
searchtitle: "Nađi zapise",
refreshtext: "",
refreshtitle: "Ponovo učitaj podatke",
alertcap: "Upozorenje",
alerttext: "Izaberite red",
viewtext: "",
viewtitle: "Pogledaj izabrani red"
},
col : {
caption: "Izaberi kolone",
bSubmit: "OK",
bCancel: "Odbaci"
},
errors : {
errcap : "Greška",
nourl : "Nije postavljen URL",
norecords: "Nema zapisa za obradu",
model : "Dužina modela colNames <> colModel!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0.00'},
currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},
date : {
dayNames: [
"Ned", "Pon", "Uto", "Sre", "Čet", "Pet", "Sub",
"Nedelja", "Ponedeljak", "Utorak", "Srijeda", "Četvrtak", "Petak", "Subota"
],
monthNames: [
"Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Avg", "Sep", "Okt", "Nov", "Dec",
"Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Catalan Translation
* Traducció jqGrid en Catatà per Faserline, S.L.
* http://www.faserline.com
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Mostrant {0} - {1} de {2}",
emptyrecords: "Sense registres que mostrar",
loadtext: "Carregant...",
pgtext : "Pàgina {0} de {1}"
},
search : {
caption: "Cerca...",
Find: "Cercar",
Reset: "Buidar",
odata : ['equal', 'not equal', 'less', 'less or equal','greater','greater or equal', 'begins with','does not begin with','is in','is not in','ends with','does not end with','contains','does not contain'],
groupOps: [ { op: "AND", text: "tot" }, { op: "OR", text: "qualsevol" } ],
matchText: " match",
rulesText: " rules"
},
edit : {
addCaption: "Afegir registre",
editCaption: "Modificar registre",
bSubmit: "Guardar",
bCancel: "Cancelar",
bClose: "Tancar",
saveData: "Les dades han canviat. Guardar canvis?",
bYes : "Yes",
bNo : "No",
bExit : "Cancel",
msg: {
required:"Camp obligatori",
number:"Introdueixi un nombre",
minValue:"El valor ha de ser major o igual que ",
maxValue:"El valor ha de ser menor o igual a ",
email: "no és una direcció de correu vàlida",
integer: "Introdueixi un valor enter",
date: "Introdueixi una data correcta ",
url: "no és una URL vàlida. Prefix requerit ('http://' or 'https://')",
nodefined : " is not defined!",
novalue : " return value is required!",
customarray : "Custom function should return array!",
customfcheck : "Custom function should be present in case of custom checking!"
}
},
view : {
caption: "Veure registre",
bClose: "Tancar"
},
del : {
caption: "Eliminar",
msg: "¿Desitja eliminar els registres seleccionats?",
bSubmit: "Eliminar",
bCancel: "Cancelar"
},
nav : {
edittext: " ",
edittitle: "Modificar fila seleccionada",
addtext:" ",
addtitle: "Agregar nova fila",
deltext: " ",
deltitle: "Eliminar fila seleccionada",
searchtext: " ",
searchtitle: "Cercar informació",
refreshtext: "",
refreshtitle: "Refrescar taula",
alertcap: "Avís",
alerttext: "Seleccioni una fila",
viewtext: " ",
viewtitle: "Veure fila seleccionada"
},
// setcolumns module
col : {
caption: "Mostrar/ocultar columnes",
bSubmit: "Enviar",
bCancel: "Cancelar"
},
errors : {
errcap : "Error",
nourl : "No s'ha especificat una URL",
norecords: "No hi ha dades per processar",
model : "Les columnes de noms són diferents de les columnes del model"
},
formatter : {
integer : {thousandsSeparator: ".", defaultValue: '0'},
number : {decimalSeparator:",", thousandsSeparator: ".", decimalPlaces: 2, defaultValue: '0,00'},
currency : {decimalSeparator:",", thousandsSeparator: ".", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0,00'},
date : {
dayNames: [
"Dg", "Dl", "Dt", "Dc", "Dj", "Dv", "Ds",
"Diumenge", "Dilluns", "Dimarts", "Dimecres", "Dijous", "Divendres", "Dissabte"
],
monthNames: [
"Gen", "Febr", "Març", "Abr", "Maig", "Juny", "Jul", "Ag", "Set", "Oct", "Nov", "Des",
"Gener", "Febrer", "Març", "Abril", "Maig", "Juny", "Juliol", "Agost", "Setembre", "Octubre", "Novembre", "Desembre"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
srcformat: 'Y-m-d',
newformat: 'd-m-Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: 'show',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Portuguese Translation
* Tradu��o da jqGrid em Portugues por Frederico Carvalho, http://www.eyeviewdesign.pt
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "View {0} - {1} of {2}",
emptyrecords: "No records to view",
loadtext: "A carregar...",
pgtext : "Page {0} of {1}"
},
search : {
caption: "Busca...",
Find: "Procurar",
Reset: "Limpar",
odata : ['equal', 'not equal', 'less', 'less or equal','greater','greater or equal', 'begins with','does not begin with','is in','is not in','ends with','does not end with','contains','does not contain'],
groupOps: [ { op: "AND", text: "all" }, { op: "OR", text: "any" } ],
matchText: " match",
rulesText: " rules"
},
edit : {
addCaption: "Adicionar Registo",
editCaption: "Modificar Registo",
bSubmit: "Submeter",
bCancel: "Cancelar",
bClose: "Fechar",
saveData: "Data has been changed! Save changes?",
bYes : "Yes",
bNo : "No",
bExit : "Cancel",
msg: {
required:"Campo obrigat�rio",
number:"Por favor, introduza um numero",
minValue:"O valor deve ser maior ou igual que",
maxValue:"O valor deve ser menor ou igual a",
email: "N�o � um endere�o de email v�lido",
integer: "Por favor, introduza um numero inteiro",
url: "is not a valid URL. Prefix required ('http://' or 'https://')",
nodefined : " is not defined!",
novalue : " return value is required!",
customarray : "Custom function should return array!",
customfcheck : "Custom function should be present in case of custom checking!"
}
},
view : {
caption: "View Record",
bClose: "Close"
},
del : {
caption: "Eliminar",
msg: "Deseja eliminar o(s) registo(s) seleccionado(s)?",
bSubmit: "Eliminar",
bCancel: "Cancelar"
},
nav : {
edittext: " ",
edittitle: "Modificar registo seleccionado",
addtext:" ",
addtitle: "Adicionar novo registo",
deltext: " ",
deltitle: "Eliminar registo seleccionado",
searchtext: " ",
searchtitle: "Procurar",
refreshtext: "",
refreshtitle: "Actualizar",
alertcap: "Aviso",
alerttext: "Por favor, seleccione um registo",
viewtext: "",
viewtitle: "View selected row"
},
col : {
caption: "Mostrar/Ocultar Colunas",
bSubmit: "Enviar",
bCancel: "Cancelar"
},
errors : {
errcap : "Erro",
nourl : "N�o especificou um url",
norecords: "N�o existem dados para processar",
model : "Tamanho do colNames <> colModel!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0.00'},
currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},
date : {
dayNames: [
"Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab",
"Domingo", "Segunda-Feira", "Ter�a-Feira", "Quarta-Feira", "Quinta-Feira", "Sexta-Feira", "S�bado"
],
monthNames: [
"Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez",
"Janeiro", "Fevereiro", "Mar�o", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return j < 11 || j > 13 ? ['�', '�', '�', '�'][Math.min((j - 1) % 10, 3)] : '�'},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Hebrew Translation
* Shuki Shukrun shukrun.shuki@gmail.com
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "מציג {0} - {1} מתוך {2}",
emptyrecords: "אין רשומות להציג",
loadtext: "טוען...",
pgtext : "דף {0} מתוך {1}"
},
search : {
caption: "מחפש...",
Find: "חפש",
Reset: "התחל",
odata : ['שווה', 'לא שווה', 'קטן', 'קטן או שווה','גדול','גדול או שווה', 'מתחיל ב','לא מתחיל ב','נמצא ב','לא נמצא ב','מסתיים ב','לא מסתיים ב','מכיל','לא מכיל'],
groupOps: [ { op: "AND", text: "הכל" }, { op: "OR", text: "אחד מ" } ],
matchText: " תואם",
rulesText: " חוקים"
},
edit : {
addCaption: "הוסף רשומה",
editCaption: "ערוך רשומה",
bSubmit: "שלח",
bCancel: "בטל",
bClose: "סגור",
saveData: "נתונים השתנו! לשמור?",
bYes : "כן",
bNo : "לא",
bExit : "בטל",
msg: {
required:"שדה חובה",
number:"אנא, הכנס מספר תקין",
minValue:"ערך צריך להיות גדול או שווה ל ",
maxValue:"ערך צריך להיות קטן או שווה ל ",
email: "היא לא כתובת איימל תקינה",
integer: "אנא, הכנס מספר שלם",
date: "אנא, הכנס תאריך תקין",
url: "הכתובת אינה תקינה. דרושה תחילית ('http://' או 'https://')",
nodefined : " is not defined!",
novalue : " return value is required!",
customarray : "Custom function should return array!",
customfcheck : "Custom function should be present in case of custom checking!"
}
},
view : {
caption: "הצג רשומה",
bClose: "סגור"
},
del : {
caption: "מחק",
msg: "האם למחוק את הרשומה/ות המסומנות?",
bSubmit: "מחק",
bCancel: "בטל"
},
nav : {
edittext: "",
edittitle: "ערוך שורה מסומנת",
addtext:"",
addtitle: "הוסף שורה חדשה",
deltext: "",
deltitle: "מחק שורה מסומנת",
searchtext: "",
searchtitle: "חפש רשומות",
refreshtext: "",
refreshtitle: "טען גריד מחדש",
alertcap: "אזהרה",
alerttext: "אנא, בחר שורה",
viewtext: "",
viewtitle: "הצג שורה מסומנת"
},
col : {
caption: "הצג/הסתר עמודות",
bSubmit: "שלח",
bCancel: "בטל"
},
errors : {
errcap : "שגיאה",
nourl : "לא הוגדרה כתובת url",
norecords: "אין רשומות לעבד",
model : "אורך של colNames <> colModel!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0.00'},
currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},
date : {
dayNames: [
"א", "ב", "ג", "ד", "ה", "ו", "ש",
"ראשון", "שני", "שלישי", "רביעי", "חמישי", "שישי", "שבת"
],
monthNames: [
"ינו", "פבר", "מרץ", "אפר", "מאי", "יונ", "יול", "אוג", "ספט", "אוק", "נוב", "דצמ",
"ינואר", "פברואר", "מרץ", "אפריל", "מאי", "יוני", "יולי", "אוגוסט", "ספטמבר", "אוקטובר", "נובמבר", "דצמבר"
],
AmPm : ["לפני הצהרים","אחר הצהרים","לפני הצהרים","אחר הצהרים"],
S: function (j) {return j < 11 || j > 13 ? ['', '', '', ''][Math.min((j - 1) % 10, 3)] : ''},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Vietnamese Translation
* Lê Đình Dũng dungtdc@gmail.com
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "View {0} - {1} of {2}",
emptyrecords: "Không có dữ liệu",
loadtext: "Đang nạp dữ liệu...",
pgtext : "Trang {0} trong tổng số {1}"
},
search : {
caption: "Tìm kiếm...",
Find: "Tìm",
Reset: "Khởi tạo lại",
odata : ['bằng', 'không bằng', 'bé hơn', 'bé hơn hoặc bằng','lớn hơn','lớn hơn hoặc bằng', 'bắt đầu với','không bắt đầu với','trong','không nằm trong','kết thúc với','không kết thúc với','chứa','không chứa'],
groupOps: [ { op: "VÀ", text: "tất cả" }, { op: "HOẶC", text: "bất kỳ" } ],
matchText: " đúng",
rulesText: " quy tắc"
},
edit : {
addCaption: "Thêm bản ghi",
editCaption: "Sửa bản ghi",
bSubmit: "Gửi",
bCancel: "Hủy bỏ",
bClose: "Đóng",
saveData: "Dữ liệu đã thay đổi! Có lưu thay đổi không?",
bYes : "Có",
bNo : "Không",
bExit : "Hủy bỏ",
msg: {
required:"Trường dữ liệu bắt buộc có",
number:"Hãy điền đúng số",
minValue:"giá trị phải lớn hơn hoặc bằng với ",
maxValue:"giá trị phải bé hơn hoặc bằng",
email: "không phải là một email đúng",
integer: "Hãy điền đúng số nguyên",
date: "Hãy điền đúng ngày tháng",
url: "không phải là URL. Khởi đầu bắt buộc là ('http://' hoặc 'https://')",
nodefined : " chưa được định nghĩa!",
novalue : " giá trị trả về bắt buộc phải có!",
customarray : "Hàm nên trả về một mảng!",
customfcheck : "Custom function should be present in case of custom checking!"
}
},
view : {
caption: "Xem bản ghi",
bClose: "Đóng"
},
del : {
caption: "Xóa",
msg: "Xóa bản ghi đã chọn?",
bSubmit: "Xóa",
bCancel: "Hủy bỏ"
},
nav : {
edittext: "",
edittitle: "Sửa dòng đã chọn",
addtext:"",
addtitle: "Thêm mới 1 dòng",
deltext: "",
deltitle: "Xóa dòng đã chọn",
searchtext: "",
searchtitle: "Tìm bản ghi",
refreshtext: "",
refreshtitle: "Nạp lại lưới",
alertcap: "Cảnh báo",
alerttext: "Hãy chọn một dòng",
viewtext: "",
viewtitle: "Xem dòng đã chọn"
},
col : {
caption: "Chọn cột",
bSubmit: "OK",
bCancel: "Hủy bỏ"
},
errors : {
errcap : "Lỗi",
nourl : "không url được đặt",
norecords: "Không có bản ghi để xử lý",
model : "Chiều dài của colNames <> colModel!"
},
formatter : {
integer : {thousandsSeparator: ".", defaultValue: '0'},
number : {decimalSeparator:",", thousandsSeparator: ".", decimalPlaces: 2, defaultValue: '0'},
currency : {decimalSeparator:",", thousandsSeparator: ".", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0'},
date : {
dayNames: [
"CN", "T2", "T3", "T4", "T5", "T6", "T7",
"Chủ nhật", "Thứ hai", "Thứ ba", "Thứ tư", "Thứ năm", "Thứ sáu", "Thứ bảy"
],
monthNames: [
"Th1", "Th2", "Th3", "Th4", "Th5", "Th6", "Th7", "Th8", "Th9", "Th10", "Th11", "Th12",
"Tháng một", "Tháng hai", "Tháng ba", "Tháng tư", "Tháng năm", "Tháng sáu", "Tháng bảy", "Tháng tám", "Tháng chín", "Tháng mười", "Tháng mười một", "Tháng mười hai"
],
AmPm : ["sáng","chiều","SÁNG","CHIỀU"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th';},
srcformat: 'Y-m-d',
newformat: 'n/j/Y',
masks : {
// see http://php.net/manual/en/function.date.php for PHP format used in jqGrid
// and see http://docs.jquery.com/UI/Datepicker/formatDate
// and https://github.com/jquery/globalize#dates for alternative formats used frequently
// one can find on https://github.com/jquery/globalize/tree/master/lib/cultures many
// information about date, time, numbers and currency formats used in different countries
// one should just convert the information in PHP format
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
// short date:
// n - Numeric representation of a month, without leading zeros
// j - Day of the month without leading zeros
// Y - A full numeric representation of a year, 4 digits
// example: 3/1/2012 which means 1 March 2012
ShortDate: "n/j/Y", // in jQuery UI Datepicker: "M/d/yyyy"
// long date:
// l - A full textual representation of the day of the week
// F - A full textual representation of a month
// d - Day of the month, 2 digits with leading zeros
// Y - A full numeric representation of a year, 4 digits
LongDate: "l, F d, Y", // in jQuery UI Datepicker: "dddd, MMMM dd, yyyy"
// long date with long time:
// l - A full textual representation of the day of the week
// F - A full textual representation of a month
// d - Day of the month, 2 digits with leading zeros
// Y - A full numeric representation of a year, 4 digits
// g - 12-hour format of an hour without leading zeros
// i - Minutes with leading zeros
// s - Seconds, with leading zeros
// A - Uppercase Ante meridiem and Post meridiem (AM or PM)
FullDateTime: "l, F d, Y g:i:s A", // in jQuery UI Datepicker: "dddd, MMMM dd, yyyy h:mm:ss tt"
// month day:
// F - A full textual representation of a month
// d - Day of the month, 2 digits with leading zeros
MonthDay: "F d", // in jQuery UI Datepicker: "MMMM dd"
// short time (without seconds)
// g - 12-hour format of an hour without leading zeros
// i - Minutes with leading zeros
// A - Uppercase Ante meridiem and Post meridiem (AM or PM)
ShortTime: "g:i A", // in jQuery UI Datepicker: "h:mm tt"
// long time (with seconds)
// g - 12-hour format of an hour without leading zeros
// i - Minutes with leading zeros
// s - Seconds, with leading zeros
// A - Uppercase Ante meridiem and Post meridiem (AM or PM)
LongTime: "g:i:s A", // in jQuery UI Datepicker: "h:mm:ss tt"
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
// month with year
// Y - A full numeric representation of a year, 4 digits
// F - A full textual representation of a month
YearMonth: "F, Y" // in jQuery UI Datepicker: "MMMM, yyyy"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Spanish Translation
* Traduccion jqGrid en Español por Yamil Bracho
* Traduccion corregida y ampliada por Faserline, S.L.
* http://www.faserline.com
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Mostrando {0} - {1} de {2}",
emptyrecords: "Sin registros que mostrar",
loadtext: "Cargando...",
pgtext : "Página {0} de {1}"
},
search : {
caption: "Búsqueda...",
Find: "Buscar",
Reset: "Limpiar",
odata : ['igual ', 'no igual a', 'menor que', 'menor o igual que','mayor que','mayor o igual a', 'empiece por','no empiece por','está en','no está en','termina por','no termina por','contiene','no contiene'],
groupOps: [ { op: "AND", text: "todo" }, { op: "OR", text: "cualquier" } ],
matchText: " match",
rulesText: " reglas"
},
edit : {
addCaption: "Agregar registro",
editCaption: "Modificar registro",
bSubmit: "Guardar",
bCancel: "Cancelar",
bClose: "Cerrar",
saveData: "Se han modificado los datos, ¿guardar cambios?",
bYes : "Si",
bNo : "No",
bExit : "Cancelar",
msg: {
required:"Campo obligatorio",
number:"Introduzca un número",
minValue:"El valor debe ser mayor o igual a ",
maxValue:"El valor debe ser menor o igual a ",
email: "no es una dirección de correo válida",
integer: "Introduzca un valor entero",
date: "Introduza una fecha correcta ",
url: "no es una URL válida. Prefijo requerido ('http://' or 'https://')",
nodefined : " no está definido.",
novalue : " valor de retorno es requerido.",
customarray : "La función personalizada debe devolver un array.",
customfcheck : "La función personalizada debe estar presente en el caso de validación personalizada."
}
},
view : {
caption: "Consultar registro",
bClose: "Cerrar"
},
del : {
caption: "Eliminar",
msg: "¿Desea eliminar los registros seleccionados?",
bSubmit: "Eliminar",
bCancel: "Cancelar"
},
nav : {
edittext: " ",
edittitle: "Modificar fila seleccionada",
addtext:" ",
addtitle: "Agregar nueva fila",
deltext: " ",
deltitle: "Eliminar fila seleccionada",
searchtext: " ",
searchtitle: "Buscar información",
refreshtext: "",
refreshtitle: "Recargar datos",
alertcap: "Aviso",
alerttext: "Seleccione una fila",
viewtext: "",
viewtitle: "Ver fila seleccionada"
},
col : {
caption: "Mostrar/ocultar columnas",
bSubmit: "Enviar",
bCancel: "Cancelar"
},
errors : {
errcap : "Error",
nourl : "No se ha especificado una URL",
norecords: "No hay datos para procesar",
model : "Las columnas de nombres son diferentes de las columnas de modelo"
},
formatter : {
integer : {thousandsSeparator: ".", defaultValue: '0'},
number : {decimalSeparator:",", thousandsSeparator: ".", decimalPlaces: 2, defaultValue: '0,00'},
currency : {decimalSeparator:",", thousandsSeparator: ".", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0,00'},
date : {
dayNames: [
"Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa",
"Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado"
],
monthNames: [
"Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic",
"Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
srcformat: 'Y-m-d',
newformat: 'd-m-Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Polish Translation
* Łukasz Schab lukasz@freetree.pl
* http://FreeTree.pl
*
* Updated names, abbreviations, currency and date/time formats for Polish norms (also corresponding with CLDR v21.0.1 --> http://cldr.unicode.org/index)
* Tomasz Pęczek tpeczek@gmail.com
* http://tpeczek.blogspot.com; http://tpeczek.codeplex.com
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Pokaż {0} - {1} z {2}",
emptyrecords: "Brak rekordów do pokazania",
loadtext: "Ładowanie...",
pgtext : "Strona {0} z {1}"
},
search : {
caption: "Wyszukiwanie...",
Find: "Szukaj",
Reset: "Czyść",
odata : ['dokładnie', 'różne od', 'mniejsze od', 'mniejsze lub równe', 'większe od', 'większe lub równe', 'zaczyna się od', 'nie zaczyna się od', 'jest w', 'nie jest w', 'kończy się na', 'nie kończy się na', 'zawiera', 'nie zawiera'],
groupOps: [ { op: "AND", text: "oraz" }, { op: "OR", text: "lub" } ],
matchText: " pasuje",
rulesText: " reguły"
},
edit : {
addCaption: "Dodaj rekord",
editCaption: "Edytuj rekord",
bSubmit: "Zapisz",
bCancel: "Anuluj",
bClose: "Zamknij",
saveData: "Dane zostały zmienione! Zapisać zmiany?",
bYes: "Tak",
bNo: "Nie",
bExit: "Anuluj",
msg: {
required: "Pole jest wymagane",
number: "Proszę wpisać poprawną liczbę",
minValue: "wartość musi być większa lub równa od",
maxValue: "wartość musi być mniejsza lub równa od",
email: "nie jest poprawnym adresem e-mail",
integer: "Proszę wpisać poprawną liczbę",
date: "Proszę podaj poprawną datę",
url: "jest niewłaściwym adresem URL. Pamiętaj o prefiksie ('http://' lub 'https://')",
nodefined: " niezdefiniowane!",
novalue: " wymagana jest wartość zwracana!",
customarray: "Funkcja niestandardowa powinna zwracać tablicę!",
customfcheck: "Funkcja niestandardowa powinna być obecna w przypadku niestandardowego sprawdzania!"
}
},
view : {
caption: "Pokaż rekord",
bClose: "Zamknij"
},
del : {
caption: "Usuń",
msg: "Czy usunąć wybrany rekord(y)?",
bSubmit: "Usuń",
bCancel: "Anuluj"
},
nav : {
edittext: "",
edittitle: "Edytuj wybrany wiersz",
addtext: "",
addtitle: "Dodaj nowy wiersz",
deltext: "",
deltitle: "Usuń wybrany wiersz",
searchtext: "",
searchtitle: "Wyszukaj rekord",
refreshtext: "",
refreshtitle: "Przeładuj",
alertcap: "Uwaga",
alerttext: "Proszę wybrać wiersz",
viewtext: "",
viewtitle: "Pokaż wybrany wiersz"
},
col : {
caption: "Pokaż/Ukryj kolumny",
bSubmit: "Zatwierdź",
bCancel: "Anuluj"
},
errors : {
errcap: "Błąd",
nourl: "Brak adresu url",
norecords: "Brak danych",
model : "Długość colNames <> colModel!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0,00'},
currency : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:" zł", defaultValue: '0,00'},
date : {
dayNames: [
"niedz.", "pon.", "wt.", "śr.", "czw.", "pt.", "sob.",
"niedziela", "poniedziałek", "wtorek", "środa", "czwartek", "piątek", "sobota"
],
monthNames: [
"sty", "lut", "mar", "kwi", "maj", "cze", "lip", "sie", "wrz", "paź", "lis", "gru",
"styczeń", "luty", "marzec", "kwiecień", "maj", "czerwiec", "lipiec", "sierpień", "wrzesień", "październik", "listopad", "grudzień"
],
AmPm : ["","","",""],
S: function (j) {return '';},
srcformat: 'Y-m-d',
newformat: 'd.m.Y',
masks : {
ISO8601Long: "Y-m-d H:i:s",
ISO8601Short: "Y-m-d",
ShortDate: "d.m.y",
LongDate: "l, j F Y",
FullDateTime: "l, j F Y H:i:s",
MonthDay: "j F",
ShortTime: "H:i",
LongTime: "H:i:s",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery); | JavaScript |
;(function($){
/**
* jqGrid German Translation
* Version 1.0.0 (developed for jQuery Grid 3.3.1)
* Olaf Klöppel opensource@blue-hit.de
* http://blue-hit.de/
*
* Updated for jqGrid 3.8
* Andreas Flack
* http://www.contentcontrol-berlin.de
*
* Updated for jQuery 4.4
* Oleg Kiriljuk oleg.kiriljuk@ok-soft-gmbh.com
* the format corresponds now the format from
* https://github.com/jquery/globalize/blob/master/lib/cultures/globalize.culture.de.js
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Zeige {0} - {1} von {2}",
emptyrecords: "Keine Datensätze vorhanden",
loadtext: "Lädt...",
pgtext : "Seite {0} von {1}"
},
search : {
caption: "Suche...",
Find: "Suchen",
Reset: "Zurücksetzen",
odata : ['gleich', 'ungleich', 'kleiner', 'kleiner gleich','größer','größer gleich', 'beginnt mit','beginnt nicht mit','ist in','ist nicht in','endet mit','endet nicht mit','enthält','enthält nicht'],
groupOps: [ { op: "AND", text: "alle" }, { op: "OR", text: "mindestens eine" } ],
matchText: " erfülle",
rulesText: " Bedingung(en)"
},
edit : {
addCaption: "Datensatz hinzufügen",
editCaption: "Datensatz bearbeiten",
bSubmit: "Speichern",
bCancel: "Abbrechen",
bClose: "Schließen",
saveData: "Daten wurden geändert! Änderungen speichern?",
bYes : "ja",
bNo : "nein",
bExit : "abbrechen",
msg: {
required:"Feld ist erforderlich",
number: "Bitte geben Sie eine Zahl ein",
minValue:"Wert muss größer oder gleich sein, als ",
maxValue:"Wert muss kleiner oder gleich sein, als ",
email: "ist keine gültige E-Mail-Adresse",
integer: "Bitte geben Sie eine Ganzzahl ein",
date: "Bitte geben Sie ein gültiges Datum ein",
url: "ist keine gültige URL. Präfix muss eingegeben werden ('http://' oder 'https://')",
nodefined : " ist nicht definiert!",
novalue : " Rückgabewert ist erforderlich!",
customarray : "Benutzerdefinierte Funktion sollte ein Array zurückgeben!",
customfcheck : "Benutzerdefinierte Funktion sollte im Falle der benutzerdefinierten Überprüfung vorhanden sein!"
}
},
view : {
caption: "Datensatz anzeigen",
bClose: "Schließen"
},
del : {
caption: "Löschen",
msg: "Ausgewählte Datensätze löschen?",
bSubmit: "Löschen",
bCancel: "Abbrechen"
},
nav : {
edittext: " ",
edittitle: "Ausgewählte Zeile editieren",
addtext:" ",
addtitle: "Neue Zeile einfügen",
deltext: " ",
deltitle: "Ausgewählte Zeile löschen",
searchtext: " ",
searchtitle: "Datensatz suchen",
refreshtext: "",
refreshtitle: "Tabelle neu laden",
alertcap: "Warnung",
alerttext: "Bitte Zeile auswählen",
viewtext: "",
viewtitle: "Ausgewählte Zeile anzeigen"
},
col : {
caption: "Spalten auswählen",
bSubmit: "Speichern",
bCancel: "Abbrechen"
},
errors : {
errcap : "Fehler",
nourl : "Keine URL angegeben",
norecords: "Keine Datensätze zu bearbeiten",
model : "colNames und colModel sind unterschiedlich lang!"
},
formatter : {
integer : {thousandsSeparator: ".", defaultValue: '0'},
number : {decimalSeparator:",", thousandsSeparator: ".", decimalPlaces: 2, defaultValue: '0,00'},
currency : {decimalSeparator:",", thousandsSeparator: ".", decimalPlaces: 2, prefix: "", suffix:" €", defaultValue: '0,00'},
date : {
dayNames: [
"So", "Mo", "Di", "Mi", "Do", "Fr", "Sa",
"Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"
],
monthNames: [
"Jan", "Feb", "Mar", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez",
"Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"
],
AmPm : ["","","",""],
S: function (j) {return '.';}, // one can also use 'er' instead of '.' but one have to use additional word like 'der' or 'den' before
srcformat: 'Y-m-d',
newformat: 'd.m.Y',
masks : {
// see http://php.net/manual/en/function.date.php for PHP format used in jqGrid
// and see http://docs.jquery.com/UI/Datepicker/formatDate
// and https://github.com/jquery/globalize#dates for alternative formats used frequently
ISO8601Long: "Y-m-d H:i:s",
ISO8601Short: "Y-m-d",
// short date:
// d - Day of the month, 2 digits with leading zeros
// m - Numeric representation of a month, with leading zeros
// Y - A full numeric representation of a year, 4 digits
ShortDate: "d.m.Y", // in jQuery UI Datepicker: "dd.MM.yyyy"
// long date:
// l - A full textual representation of the day of the week
// j - Day of the month without leading zeros
// F - A full textual representation of a month
// Y - A full numeric representation of a year, 4 digits
LongDate: "l, j. F Y", // in jQuery UI Datepicker: "dddd, d. MMMM yyyy"
// long date with long time:
// l - A full textual representation of the day of the week
// j - Day of the month without leading zeros
// F - A full textual representation of a month
// Y - A full numeric representation of a year, 4 digits
// H - 24-hour format of an hour with leading zeros
// i - Minutes with leading zeros
// s - Seconds, with leading zeros
FullDateTime: "l, j. F Y H:i:s", // in jQuery UI Datepicker: "dddd, d. MMMM yyyy HH:mm:ss"
// month day:
// d - Day of the month, 2 digits with leading zeros
// F - A full textual representation of a month
MonthDay: "d F", // in jQuery UI Datepicker: "dd MMMM"
// short time (without seconds)
// H - 24-hour format of an hour with leading zeros
// i - Minutes with leading zeros
ShortTime: "H:i", // in jQuery UI Datepicker: "HH:mm"
// long time (with seconds)
// H - 24-hour format of an hour with leading zeros
// i - Minutes with leading zeros
// s - Seconds, with leading zeros
LongTime: "H:i:s", // in jQuery UI Datepicker: "HH:mm:ss"
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
// month with year
// F - A full textual representation of a month
// Y - A full numeric representation of a year, 4 digits
YearMonth: "F Y" // in jQuery UI Datepicker: "MMMM yyyy"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery); | JavaScript |
;(function($){
/**
* jqGrid Russian Translation v1.0 02.07.2009 (based on translation by Alexey Kanaev v1.1 21.01.2009, http://softcore.com.ru)
* Sergey Dyagovchenko
* http://d.sumy.ua
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Просмотр {0} - {1} из {2}",
emptyrecords: "Нет записей для просмотра",
loadtext: "Загрузка...",
pgtext : "Стр. {0} из {1}"
},
search : {
caption: "Поиск...",
Find: "Найти",
Reset: "Сброс",
odata : ['равно', 'не равно', 'меньше', 'меньше или равно','больше','больше или равно', 'начинается с','не начинается с','находится в','не находится в','заканчивается на','не заканчивается на','содержит','не содержит'],
groupOps: [ { op: "AND", text: "все" }, { op: "OR", text: "любой" } ],
matchText: " совпадает",
rulesText: " правила"
},
edit : {
addCaption: "Добавить запись",
editCaption: "Редактировать запись",
bSubmit: "Сохранить",
bCancel: "Отмена",
bClose: "Закрыть",
saveData: "Данные были измененны! Сохранить изменения?",
bYes : "Да",
bNo : "Нет",
bExit : "Отмена",
msg: {
required:"Поле является обязательным",
number:"Пожалуйста, введите правильное число",
minValue:"значение должно быть больше либо равно",
maxValue:"значение должно быть меньше либо равно",
email: "некорректное значение e-mail",
integer: "Пожалуйста, введите целое число",
date: "Пожалуйста, введите правильную дату",
url: "неверная ссылка. Необходимо ввести префикс ('http://' или 'https://')",
nodefined : " не определено!",
novalue : " возвращаемое значение обязательно!",
customarray : "Пользовательская функция должна возвращать массив!",
customfcheck : "Пользовательская функция должна присутствовать в случаи пользовательской проверки!"
}
},
view : {
caption: "Просмотр записи",
bClose: "Закрыть"
},
del : {
caption: "Удалить",
msg: "Удалить выбранную запись(и)?",
bSubmit: "Удалить",
bCancel: "Отмена"
},
nav : {
edittext: " ",
edittitle: "Редактировать выбранную запись",
addtext:" ",
addtitle: "Добавить новую запись",
deltext: " ",
deltitle: "Удалить выбранную запись",
searchtext: " ",
searchtitle: "Найти записи",
refreshtext: "",
refreshtitle: "Обновить таблицу",
alertcap: "Внимание",
alerttext: "Пожалуйста, выберите запись",
viewtext: "",
viewtitle: "Просмотреть выбранную запись"
},
col : {
caption: "Показать/скрыть столбцы",
bSubmit: "Сохранить",
bCancel: "Отмена"
},
errors : {
errcap : "Ошибка",
nourl : "URL не установлен",
norecords: "Нет записей для обработки",
model : "Число полей не соответствует числу столбцов таблицы!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0,00'},
currency : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0,00'},
date : {
dayNames: [
"Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб",
"Воскресение", "Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота"
],
monthNames: [
"Янв", "Фев", "Мар", "Апр", "Май", "Июн", "Июл", "Авг", "Сен", "Окт", "Ноя", "Дек",
"Январь", "Февраль", "Март", "Апрель", "Май", "Июнь", "Июль", "Август", "Сентябрь", "Октябрь", "Ноябрь", "Декабрь"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
srcformat: 'Y-m-d',
newformat: 'd.m.Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n.j.Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y G:i:s",
MonthDay: "F d",
ShortTime: "G:i",
LongTime: "G:i:s",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Swedish Translation
* Harald Normann harald.normann@wts.se, harald.normann@gmail.com
* http://www.worldteamsoftware.com
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Visar {0} - {1} av {2}",
emptyrecords: "Det finns inga poster att visa",
loadtext: "Laddar...",
pgtext : "Sida {0} av {1}"
},
search : {
caption: "Sök Poster - Ange sökvillkor",
Find: "Sök",
Reset: "Nollställ Villkor",
odata : ['lika', 'ej lika', 'mindre', 'mindre eller lika','större','större eller lika', 'börjar med','börjar inte med','tillhör','tillhör inte','slutar med','slutar inte med','innehåller','innehåller inte'],
groupOps: [ { op: "AND", text: "alla" }, { op: "OR", text: "eller" } ],
matchText: " träff",
rulesText: " regler"
},
edit : {
addCaption: "Ny Post",
editCaption: "Redigera Post",
bSubmit: "Spara",
bCancel: "Avbryt",
bClose: "Stäng",
saveData: "Data har ändrats! Spara förändringar?",
bYes : "Ja",
bNo : "Nej",
bExit : "Avbryt",
msg: {
required:"Fältet är obligatoriskt",
number:"Välj korrekt nummer",
minValue:"värdet måste vara större än eller lika med",
maxValue:"värdet måste vara mindre än eller lika med",
email: "är inte korrekt e-post adress",
integer: "Var god ange korrekt heltal",
date: "Var god ange korrekt datum",
url: "är inte en korrekt URL. Prefix måste anges ('http://' or 'https://')",
nodefined : " är inte definierad!",
novalue : " returvärde måste anges!",
customarray : "Custom funktion måste returnera en vektor!",
customfcheck : "Custom funktion måste finnas om Custom kontroll sker!"
}
},
view : {
caption: "Visa Post",
bClose: "Stäng"
},
del : {
caption: "Radera",
msg: "Radera markerad(e) post(er)?",
bSubmit: "Radera",
bCancel: "Avbryt"
},
nav : {
edittext: "",
edittitle: "Redigera markerad rad",
addtext:"",
addtitle: "Skapa ny post",
deltext: "",
deltitle: "Radera markerad rad",
searchtext: "",
searchtitle: "Sök poster",
refreshtext: "",
refreshtitle: "Uppdatera data",
alertcap: "Varning",
alerttext: "Ingen rad är markerad",
viewtext: "",
viewtitle: "Visa markerad rad"
},
col : {
caption: "Välj Kolumner",
bSubmit: "OK",
bCancel: "Avbryt"
},
errors : {
errcap : "Fel",
nourl : "URL saknas",
norecords: "Det finns inga poster att bearbeta",
model : "Antal colNames <> colModel!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0,00'},
currency : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"Kr", defaultValue: '0,00'},
date : {
dayNames: [
"Sön", "Mån", "Tis", "Ons", "Tor", "Fre", "Lör",
"Söndag", "Måndag", "Tisdag", "Onsdag", "Torsdag", "Fredag", "Lördag"
],
monthNames: [
"Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec",
"Januari", "Februari", "Mars", "April", "Maj", "Juni", "Juli", "Augusti", "September", "Oktober", "November", "December"
],
AmPm : ["fm","em","FM","EM"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
srcformat: 'Y-m-d',
newformat: 'Y-m-d',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Lithuanian Translation
* aur1mas aur1mas@devnet.lt
* http://aur1mas.devnet.lt
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Peržiūrima {0} - {1} iš {2}",
emptyrecords: "Įrašų nėra",
loadtext: "Kraunama...",
pgtext : "Puslapis {0} iš {1}"
},
search : {
caption: "Paieška...",
Find: "Ieškoti",
Reset: "Atstatyti",
odata : ['lygu', 'nelygu', 'mažiau', 'mažiau arba lygu','daugiau','daugiau arba lygu', 'prasideda','neprasideda','reikšmė yra','reikšmės nėra','baigiasi','nesibaigia','yra sudarytas','nėra sudarytas'],
groupOps: [ { op: "AND", text: "visi" }, { op: "OR", text: "bet kuris" } ],
matchText: " match",
rulesText: " rules"
},
edit : {
addCaption: "Sukurti įrašą",
editCaption: "Redaguoti įrašą",
bSubmit: "Išsaugoti",
bCancel: "Atšaukti",
bClose: "Uždaryti",
saveData: "Duomenys buvo pakeisti! Išsaugoti pakeitimus?",
bYes : "Taip",
bNo : "Ne",
bExit : "Atšaukti",
msg: {
required:"Privalomas laukas",
number:"Įveskite tinkamą numerį",
minValue:"reikšmė turi būti didesnė arba lygi ",
maxValue:"reikšmė turi būti mažesnė arba lygi",
email: "neteisingas el. pašto adresas",
integer: "Įveskite teisingą sveikąjį skaičių",
date: "Įveskite teisingą datą",
url: "blogas adresas. Nepamirškite pridėti ('http://' arba 'https://')",
nodefined : " nėra apibrėžta!",
novalue : " turi būti gražinama kokia nors reikšmė!",
customarray : "Custom f-ja turi grąžinti masyvą!",
customfcheck : "Custom f-ja tūrėtų būti sukurta, prieš bandant ją naudoti!"
}
},
view : {
caption: "Peržiūrėti įrašus",
bClose: "Uždaryti"
},
del : {
caption: "Ištrinti",
msg: "Ištrinti pažymėtus įrašus(-ą)?",
bSubmit: "Ištrinti",
bCancel: "Atšaukti"
},
nav : {
edittext: "",
edittitle: "Redaguoti pažymėtą eilutę",
addtext:"",
addtitle: "Pridėti naują eilutę",
deltext: "",
deltitle: "Ištrinti pažymėtą eilutę",
searchtext: "",
searchtitle: "Rasti įrašus",
refreshtext: "",
refreshtitle: "Perkrauti lentelę",
alertcap: "Įspėjimas",
alerttext: "Pasirinkite eilutę",
viewtext: "",
viewtitle: "Peržiūrėti pasirinktą eilutę"
},
col : {
caption: "Pasirinkti stulpelius",
bSubmit: "Gerai",
bCancel: "Atšaukti"
},
errors : {
errcap : "Klaida",
nourl : "Url reikšmė turi būti perduota",
norecords: "Nėra įrašų, kuriuos būtų galima apdoroti",
model : "colNames skaičius <> colModel skaičiui!"
},
formatter : {
integer : {thousandsSeparator: "", defaultValue: '0'},
number : {decimalSeparator:",", thousandsSeparator: "", decimalPlaces: 2, defaultValue: '0.00'},
currency : {decimalSeparator:",", thousandsSeparator: "", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},
date : {
dayNames: [
"Sek", "Pir", "Ant", "Tre", "Ket", "Pen", "Šeš",
"Sekmadienis", "Pirmadienis", "Antradienis", "Trečiadienis", "Ketvirtadienis", "Penktadienis", "Šeštadienis"
],
monthNames: [
"Sau", "Vas", "Kov", "Bal", "Geg", "Bir", "Lie", "Rugj", "Rugs", "Spa", "Lap", "Gru",
"Sausis", "Vasaris", "Kovas", "Balandis", "Gegužė", "Birželis", "Liepa", "Rugpjūtis", "Rugsėjis", "Spalis", "Lapkritis", "Gruodis"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
(function(a) {
a.jgrid = a.jgrid || {};
a.extend(a.jgrid,{
defaults:
{
recordtext: "regels {0} - {1} van {2}",
emptyrecords: "Geen data gevonden.",
loadtext: "laden...",
pgtext: "pagina {0} van {1}"
},
search:
{
caption: "Zoeken...",
Find: "Zoek",
Reset: "Herstellen",
odata: ["gelijk aan", "niet gelijk aan", "kleiner dan", "kleiner dan of gelijk aan", "groter dan", "groter dan of gelijk aan", "begint met", "begint niet met", "is in", "is niet in", "eindigd met", "eindigd niet met", "bevat", "bevat niet"],
groupOps: [{ op: "AND", text: "alle" }, { op: "OR", text: "een van de"}],
matchText: " match",
rulesText: " regels"
},
edit:
{
addCaption: "Nieuw",
editCaption: "Bewerken",
bSubmit: "Opslaan",
bCancel: "Annuleren",
bClose: "Sluiten",
saveData: "Er is data aangepast! Wijzigingen opslaan?",
bYes: "Ja",
bNo: "Nee",
bExit: "Sluiten",
msg:
{
required: "Veld is verplicht",
number: "Voer a.u.b. geldig nummer in",
minValue: "Waarde moet groter of gelijk zijn aan ",
maxValue: "Waarde moet kleiner of gelijks zijn aan",
email: "is geen geldig e-mailadres",
integer: "Voer a.u.b. een geldig getal in",
date: "Voer a.u.b. een geldige waarde in",
url: "is geen geldige URL. Prefix is verplicht ('http://' or 'https://')",
nodefined : " is not defined!",
novalue : " return value is required!",
customarray : "Custom function should return array!",
customfcheck : "Custom function should be present in case of custom checking!"
}
},
view:
{
caption: "Tonen",
bClose: "Sluiten"
},
del:
{
caption: "Verwijderen",
msg: "Verwijder geselecteerde regel(s)?",
bSubmit: "Verwijderen",
bCancel: "Annuleren"
},
nav:
{
edittext: "",
edittitle: "Bewerken",
addtext: "",
addtitle: "Nieuw",
deltext: "",
deltitle: "Verwijderen",
searchtext: "",
searchtitle: "Zoeken",
refreshtext: "",
refreshtitle: "Vernieuwen",
alertcap: "Waarschuwing",
alerttext: "Selecteer a.u.b. een regel",
viewtext: "",
viewtitle: "Openen"
},
col:
{
caption: "Tonen/verbergen kolommen",
bSubmit: "OK",
bCancel: "Annuleren"
},
errors:
{
errcap: "Fout",
nourl: "Er is geen URL gedefinieerd",
norecords: "Geen data om te verwerken",
model: "Lengte van 'colNames' is niet gelijk aan 'colModel'!"
},
formatter:
{
integer:
{
thousandsSeparator: ".",
defaultValue: "0"
},
number:
{
decimalSeparator: ",",
thousandsSeparator: ".",
decimalPlaces: 2,
defaultValue: "0.00"
},
currency:
{
decimalSeparator: ",",
thousandsSeparator: ".",
decimalPlaces: 2,
prefix: "EUR ",
suffix: "",
defaultValue: "0.00"
},
date:
{
dayNames: ["Zo", "Ma", "Di", "Wo", "Do", "Vr", "Za", "Zondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag"],
monthNames: ["Jan", "Feb", "Maa", "Apr", "Mei", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "October", "November", "December"],
AmPm: ["am", "pm", "AM", "PM"],
S: function(b) {
return b < 11 || b > 13 ? ["st", "nd", "rd", "th"][Math.min((b - 1) % 10, 3)] : "th"
},
srcformat: "Y-m-d",
newformat: "d/m/Y",
masks:
{
ISO8601Long: "Y-m-d H:i:s",
ISO8601Short: "Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l d F Y G:i:s",
MonthDay: "d F",
ShortTime: "G:i",
LongTime: "G:i:s",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit: false
},
baseLinkUrl: "",
showAction: "",
target: "",
checkbox:
{
disabled: true
},
idName: "id"
}
});
})(jQuery); | JavaScript |
;(function($){
/**
* jqGrid Danish Translation
* Kaare Rasmussen kjs@jasonic.dk
* http://jasonic.dk/blog
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = {
defaults : {
recordtext: "View {0} - {1} of {2}",
emptyrecords: "No records to view",
loadtext: "Loading...",
pgtext : "Page {0} of {1}"
},
search : {
caption: "Søg...",
Find: "Find",
Reset: "Nulstil",
odata : ['equal', 'not equal', 'less', 'less or equal','greater','greater or equal', 'begins with','does not begin with','is in','is not in','ends with','does not end with','contains','does not contain'],
groupOps: [ { op: "AND", text: "all" }, { op: "OR", text: "any" } ],
matchText: " match",
rulesText: " rules"
},
edit : {
addCaption: "Tilføj",
editCaption: "Ret",
bSubmit: "Send",
bCancel: "Annuller",
bClose: "Luk",
saveData: "Data has been changed! Save changes?",
bYes : "Yes",
bNo : "No",
bExit : "Cancel",
msg: {
required:"Felt er nødvendigt",
number:"Indtast venligst et validt tal",
minValue:"værdi skal være større end eller lig med",
maxValue:"værdi skal være mindre end eller lig med",
email: "er ikke en valid email",
integer: "Indtast venligst et validt heltalt",
date: "Indtast venligst en valid datoværdi",
url: "is not a valid URL. Prefix required ('http://' or 'https://')",
nodefined : " is not defined!",
novalue : " return value is required!",
customarray : "Custom function should return array!",
customfcheck : "Custom function should be present in case of custom checking!"
}
},
view : {
caption: "View Record",
bClose: "Close"
},
del : {
caption: "Slet",
msg: "Slet valgte række(r)?",
bSubmit: "Slet",
bCancel: "Annuller"
},
nav : {
edittext: " ",
edittitle: "Rediger valgte række",
addtext:" ",
addtitle: "Tilføj ny række",
deltext: " ",
deltitle: "Slet valgte række",
searchtext: " ",
searchtitle: "Find poster",
refreshtext: "",
refreshtitle: "Indlæs igen",
alertcap: "Advarsel",
alerttext: "Vælg venligst række",
viewtext: "",
viewtitle: "View selected row"
},
col : {
caption: "Vis/skjul kolonner",
bSubmit: "Send",
bCancel: "Annuller"
},
errors : {
errcap : "Fejl",
nourl : "Ingel url valgt",
norecords: "Ingen poster at behandle",
model : "colNames og colModel har ikke samme længde!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0,00'},
currency : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0,00'},
date : {
dayNames: [
"Søn", "Man", "Tirs", "Ons", "Tors", "Fre", "Lør",
"Søndag", "Mandag", "Tirsdag", "Onsdag", "Torsdag", "Fredag", "Lørdag"
],
monthNames: [
"Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec",
"Januar", "Februar", "Marts", "April", "Maj", "Juni", "Juli", "August", "September", "Oktober", "November", "December"
],
AmPm : ["","","",""],
S: function (j) {return '.'},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "j/n/Y",
LongDate: "l d. F Y",
FullDateTime: "l d F Y G:i:s",
MonthDay: "d. F",
ShortTime: "G:i",
LongTime: "G:i:s",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
};
// DK
})(jQuery);
| JavaScript |
;(function ($) {
/**
* jqGrid Persian Translation
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults: {
recordtext: "نمابش {0} - {1} از {2}",
emptyrecords: "رکوردی یافت نشد",
loadtext: "بارگزاري...",
pgtext: "صفحه {0} از {1}"
},
search: {
caption: "جستجو...",
Find: "يافته ها",
Reset: "از نو",
odata: ['برابر', 'نا برابر', 'به', 'کوچکتر', 'از', 'بزرگتر', 'شروع با', 'شروع نشود با', 'نباشد', 'عضو این نباشد', 'اتمام با', 'تمام نشود با', 'حاوی', 'نباشد حاوی'],
groupOps: [{
op: "AND",
text: "کل"
},
{
op: "OR",
text: "مجموع"
}],
matchText: " حاوی",
rulesText: " اطلاعات"
},
edit: {
addCaption: "اضافه کردن رکورد",
editCaption: "ويرايش رکورد",
bSubmit: "ثبت",
bCancel: "انصراف",
bClose: "بستن",
saveData: "دیتا تعییر کرد! ذخیره شود؟",
bYes: "بله",
bNo: "خیر",
bExit: "انصراف",
msg: {
required: "فيلدها بايد ختما پر شوند",
number: "لطفا عدد وعتبر وارد کنيد",
minValue: "مقدار وارد شده بايد بزرگتر يا مساوي با",
maxValue: "مقدار وارد شده بايد کوچکتر يا مساوي",
email: "پست الکترونيک وارد شده معتبر نيست",
integer: "لطفا يک عدد صحيح وارد کنيد",
date: "لطفا يک تاريخ معتبر وارد کنيد",
url: "این آدرس صحیح نمی باشد. پیشوند نیاز است ('http://' یا 'https://')",
nodefined: " تعریف نشده!",
novalue: " مقدار برگشتی اجباری است!",
customarray: "تابع شما باید مقدار آرایه داشته باشد!",
customfcheck: "برای داشتن متد دلخواه شما باید سطون با چکینگ دلخواه داشته باشید!"
}
},
view: {
caption: "نمایش رکورد",
bClose: "بستن"
},
del: {
caption: "حذف",
msg: "از حذف گزينه هاي انتخاب شده مطمئن هستيد؟",
bSubmit: "حذف",
bCancel: "ابطال"
},
nav: {
edittext: " ",
edittitle: "ويرايش رديف هاي انتخاب شده",
addtext: " ",
addtitle: "افزودن رديف جديد",
deltext: " ",
deltitle: "حذف ردبف هاي انتیاب شده",
searchtext: " ",
searchtitle: "جستجوي رديف",
refreshtext: "",
refreshtitle: "بازيابي مجدد صفحه",
alertcap: "اخطار",
alerttext: "لطفا يک رديف انتخاب کنيد",
viewtext: "",
viewtitle: "نمایش رکورد های انتخاب شده"
},
col: {
caption: "نمايش/عدم نمايش ستون",
bSubmit: "ثبت",
bCancel: "انصراف"
},
errors: {
errcap: "خطا",
nourl: "هيچ آدرسي تنظيم نشده است",
norecords: "هيچ رکوردي براي پردازش موجود نيست",
model: "طول نام ستون ها محالف ستون هاي مدل مي باشد!"
},
formatter: {
integer: {
thousandsSeparator: " ",
defaultValue: "0"
},
number: {
decimalSeparator: ".",
thousandsSeparator: " ",
decimalPlaces: 2,
defaultValue: "0.00"
},
currency: {
decimalSeparator: ".",
thousandsSeparator: " ",
decimalPlaces: 2,
prefix: "",
suffix: "",
defaultValue: "0"
},
date: {
dayNames: ["يک", "دو", "سه", "چهار", "پنج", "جمع", "شنب", "يکشنبه", "دوشنبه", "سه شنبه", "چهارشنبه", "پنجشنبه", "جمعه", "شنبه"],
monthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "ژانويه", "فوريه", "مارس", "آوريل", "مه", "ژوئن", "ژوئيه", "اوت", "سپتامبر", "اکتبر", "نوامبر", "December"],
AmPm: ["ب.ظ", "ب.ظ", "ق.ظ", "ق.ظ"],
S: function (b) {
return b < 11 || b > 13 ? ["st", "nd", "rd", "th"][Math.min((b - 1) % 10, 3)] : "th"
},
srcformat: "Y-m-d",
newformat: "d/m/Y",
masks: {
ISO8601Long: "Y-m-d H:i:s",
ISO8601Short: "Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit: false
},
baseLinkUrl: "",
showAction: "نمايش",
target: "",
checkbox: {
disabled: true
},
idName: "id"
}
});
})(jQuery); | JavaScript |
;(function($){
/**
* jqGrid Serbian latin Translation
* Bild Studio info@bild-studio.net
* http://www.bild-studio.com
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Pregled {0} - {1} od {2}",
emptyrecords: "Ne postoji nijedan zapis",
loadtext: "Učitivanje...",
pgtext : "Strana {0} od {1}"
},
search : {
caption: "Traženje...",
Find: "Traži",
Reset: "Resetuj",
odata : ['jednako', 'nije jednako', 'manje', 'manje ili jednako','veće','veće ili jednako', 'počinje sa','ne počinje sa','je u','nije u','završava sa','ne završava sa','sadrži','ne sadrži'],
groupOps: [ { op: "AND", text: "sva" }, { op: "OR", text: "bilo koje" } ],
matchText: " primeni",
rulesText: " pravila"
},
edit : {
addCaption: "Dodaj zapis",
editCaption: "Izmeni zapis",
bSubmit: "Pošalji",
bCancel: "Odustani",
bClose: "Zatvori",
saveData: "Podatak je izmenjen! Sačuvaj izmene?",
bYes : "Da",
bNo : "Ne",
bExit : "Odustani",
msg: {
required: "Polje je obavezno",
number: "Unesite ispravan broj",
minValue: "vrednost mora biti veća od ili jednaka sa ",
maxValue: "vrednost mora biti manja ili jednaka sa",
email: "nije ispravna email adresa, nije valjda da ne umeš ukucati mail!?",
integer: "Unesi celobrojnu vrednost ",
date: "Unesite ispravan datum",
url: "nije ispravan URL. Potreban je prefiks ('http://' or 'https://')",
nodefined : " nije definisan!",
novalue : " zahtevana je povratna vrednost!",
customarray : "Prilagođena funkcija treba da vrati niz!",
customfcheck : "Prilagođena funkcija treba da bude prisutana u slučaju prilagođene provere!"
}
},
view : {
caption: "Pogledaj zapis",
bClose: "Zatvori"
},
del : {
caption: "Izbrisi",
msg: "Izbrisi izabran(e) zapise(e)?",
bSubmit: "Izbriši",
bCancel: "Odbaci"
},
nav : {
edittext: "",
edittitle: "Izmeni izabrani red",
addtext:"",
addtitle: "Dodaj novi red",
deltext: "",
deltitle: "Izbriši izabran red",
searchtext: "",
searchtitle: "Nađi zapise",
refreshtext: "",
refreshtitle: "Ponovo učitaj podatke",
alertcap: "Upozorenje",
alerttext: "Izaberite red",
viewtext: "",
viewtitle: "Pogledaj izabrani red"
},
col : {
caption: "Izaberi kolone",
bSubmit: "OK",
bCancel: "Odbaci"
},
errors : {
errcap : "Greška",
nourl : "Nije postavljen URL",
norecords: "Nema zapisa za obradu",
model : "Dužina modela colNames <> colModel!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0.00'},
currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},
date : {
dayNames: [
"Ned", "Pon", "Uto", "Sre", "Čet", "Pet", "Sub",
"Nedelja", "Ponedeljak", "Utorak", "Srijeda", "Četvrtak", "Petak", "Subota"
],
monthNames: [
"Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Avg", "Sep", "Okt", "Nov", "Dec",
"Januar", "Februar", "Mart", "April", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Brazilian-Portuguese Translation
* Sergio Righi sergio.righi@gmail.com
* http://curve.com.br
*
* Updated by Jonnas Fonini
* http://fonini.net
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Ver {0} - {1} de {2}",
emptyrecords: "Nenhum registro para visualizar",
loadtext: "Carregando...",
pgtext : "Página {0} de {1}"
},
search : {
caption: "Procurar...",
Find: "Procurar",
Reset: "Resetar",
odata : ['igual', 'diferente', 'menor', 'menor ou igual','maior','maior ou igual', 'inicia com','não inicia com','está em','não está em','termina com','não termina com','contém','não contém','nulo','não nulo'],
groupOps: [ { op: "AND", text: "all" }, { op: "OR", text: "any" } ],
matchText: " igual a",
rulesText: " regras"
},
edit : {
addCaption: "Incluir",
editCaption: "Alterar",
bSubmit: "Enviar",
bCancel: "Cancelar",
bClose: "Fechar",
saveData: "Os dados foram alterados! Salvar alterações?",
bYes : "Sim",
bNo : "Não",
bExit : "Cancelar",
msg: {
required:"Campo obrigatório",
number:"Por favor, informe um número válido",
minValue:"valor deve ser igual ou maior que ",
maxValue:"valor deve ser menor ou igual a",
email: "este e-mail não é válido",
integer: "Por favor, informe um valor inteiro",
date: "Por favor, informe uma data válida",
url: "não é uma URL válida. Prefixo obrigatório ('http://' or 'https://')",
nodefined : " não está definido!",
novalue : " um valor de retorno é obrigatório!",
customarray : "Função customizada deve retornar um array!",
customfcheck : "Função customizada deve estar presente em caso de validação customizada!"
}
},
view : {
caption: "Ver Registro",
bClose: "Fechar"
},
del : {
caption: "Apagar",
msg: "Apagar registro(s) selecionado(s)?",
bSubmit: "Apagar",
bCancel: "Cancelar"
},
nav : {
edittext: " ",
edittitle: "Alterar registro selecionado",
addtext:" ",
addtitle: "Incluir novo registro",
deltext: " ",
deltitle: "Apagar registro selecionado",
searchtext: " ",
searchtitle: "Procurar registros",
refreshtext: "",
refreshtitle: "Recarregando tabela",
alertcap: "Aviso",
alerttext: "Por favor, selecione um registro",
viewtext: "",
viewtitle: "Ver linha selecionada"
},
col : {
caption: "Mostrar/Esconder Colunas",
bSubmit: "Enviar",
bCancel: "Cancelar"
},
errors : {
errcap : "Erro",
nourl : "Nenhuma URL definida",
norecords: "Sem registros para exibir",
model : "Comprimento de colNames <> colModel!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0,00'},
currency : {decimalSeparator:",", thousandsSeparator: ".", decimalPlaces: 2, prefix: "R$ ", suffix:"", defaultValue: '0,00'},
date : {
dayNames: [
"Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb",
"Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado"
],
monthNames: [
"Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez",
"Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return j < 11 || j > 13 ? ['º', 'º', 'º', 'º'][Math.min((j - 1) % 10, 3)] : 'º'},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Croatian Translation
* Version 1.0.1 (developed for jQuery Grid 4.4)
* msajko@gmail.com
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Pregled {0} - {1} od {2}",
emptyrecords: "Nema zapisa",
loadtext: "Učitavam...",
pgtext : "Stranica {0} od {1}"
},
search : {
caption: "Traži...",
Find: "Pretraživanje",
Reset: "Poništi",
odata : ['jednak', 'nije identičan', 'manje', 'manje ili identično','veće','veše ili identično', 'počinje sa','ne počinje sa ','je u','nije u','završava sa','ne završava sa','sadrži','ne sadrži'],
groupOps: [ { op: "I", text: "sve" }, { op: "ILI", text: "bilo koji" } ],
matchText: " podudata se",
rulesText: " pravila"
},
edit : {
addCaption: "Dodaj zapis",
editCaption: "Promijeni zapis",
bSubmit: "Preuzmi",
bCancel: "Odustani",
bClose: "Zatvri",
saveData: "Podaci su promijenjeni! Preuzmi promijene?",
bYes : "Da",
bNo : "Ne",
bExit : "Odustani",
msg: {
required:"Polje je obavezno",
number:"Molim, unesite ispravan broj",
minValue:"Vrijednost mora biti veća ili identična ",
maxValue:"Vrijednost mora biti manja ili identična",
email: "neispravan e-mail",
integer: "Molim, unjeti ispravan cijeli broj (integer)",
date: "Molim, unjeti ispravan datum ",
url: "neispravan URL. Prefiks je obavezan ('http://' or 'https://')",
nodefined : " nije definiran!",
novalue : " zahtjevan podatak je obavezan!",
customarray : "Opcionalna funkcija trebala bi bili polje (array)!",
customfcheck : "Custom function should be present in case of custom checking!"
}
},
view : {
caption: "Otvori zapis",
bClose: "Zatvori"
},
del : {
caption: "Obriši",
msg: "Obriši označen zapis ili više njih?",
bSubmit: "Obriši",
bCancel: "Odustani"
},
nav : {
edittext: " ",
edittitle: "Promijeni obilježeni red",
addtext:" ",
addtitle: "Dodaj novi red",
deltext: " ",
deltitle: "Obriši obilježeni red",
searchtext: " ",
searchtitle: "Potraži zapise",
refreshtext: "",
refreshtitle: "Ponovo preuzmi podatke",
alertcap: "Upozorenje",
alerttext: "Molim, odaberi red",
viewtext: "",
viewtitle: "Pregled obilježenog reda"
},
col : {
caption: "Obilježi kolonu",
bSubmit: "Uredu",
bCancel: "Odustani"
},
errors : {
errcap : "Greška",
nourl : "Nedostaje URL",
norecords: "Bez zapisa za obradu",
model : "colNames i colModel imaju različitu duljinu!"
},
formatter : {
integer : {thousandsSeparator: ".", defaultValue: '0'},
number : {decimalSeparator:",", thousandsSeparator: ".", decimalPlaces: 2, defaultValue: '0,00'},
currency : {decimalSeparator:",", thousandsSeparator: ".", decimalPlaces: 2, prefix: "", suffix:" Kn", defaultValue: '0,00'},
date : {
dayNames: [
"Ned", "Pon", "Uto", "Sri", "Čet", "Pet", "Sub",
"Nedjelja", "Ponedjeljak", "Utorak", "Srijeda", "Četvrtak", "Petak", "Subota"
],
monthNames: [
"Sij", "Vel", "Ožu", "Tra", "Svi", "Lip", "Srp", "Kol", "Ruj", "Lis", "Stu", "Pro",
"Siječanj", "Veljača", "Ožujak", "Travanj", "Svibanj", "Lipanj", "Srpanj", "Kolovoz", "Rujan", "Listopad", "Studeni", "Prosinac"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return ''},
srcformat: 'Y-m-d',
newformat: 'd.m.Y.',
masks : {
// see http://php.net/manual/en/function.date.php for PHP format used in jqGrid
// and see http://docs.jquery.com/UI/Datepicker/formatDate
// and https://github.com/jquery/globalize#dates for alternative formats used frequently
ISO8601Long: "Y-m-d H:i:s",
ISO8601Short: "Y-m-d",
// short date:
// d - Day of the month, 2 digits with leading zeros
// m - Numeric representation of a month, with leading zeros
// Y - A full numeric representation of a year, 4 digits
ShortDate: "d.m.Y.", // in jQuery UI Datepicker: "dd.mm.yy."
// long date:
// l - A full textual representation of the day of the week
// j - Day of the month without leading zeros
// F - A full textual representation of a month
// Y - A full numeric representation of a year, 4 digits
LongDate: "l, j. F Y", // in jQuery UI Datepicker: "dddd, d. MMMM yyyy"
// long date with long time:
// l - A full textual representation of the day of the week
// j - Day of the month without leading zeros
// F - A full textual representation of a month
// Y - A full numeric representation of a year, 4 digits
// H - 24-hour format of an hour with leading zeros
// i - Minutes with leading zeros
// s - Seconds, with leading zeros
FullDateTime: "l, j. F Y H:i:s", // in jQuery UI Datepicker: "dddd, d. MMMM yyyy HH:mm:ss"
// month day:
// d - Day of the month, 2 digits with leading zeros
// F - A full textual representation of a month
MonthDay: "d F", // in jQuery UI Datepicker: "dd MMMM"
// short time (without seconds)
// H - 24-hour format of an hour with leading zeros
// i - Minutes with leading zeros
ShortTime: "H:i", // in jQuery UI Datepicker: "HH:mm"
// long time (with seconds)
// H - 24-hour format of an hour with leading zeros
// i - Minutes with leading zeros
// s - Seconds, with leading zeros
LongTime: "H:i:s", // in jQuery UI Datepicker: "HH:mm:ss"
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
// month with year
// F - A full textual representation of a month
// Y - A full numeric representation of a year, 4 digits
YearMonth: "F Y" // in jQuery UI Datepicker: "MMMM yyyy"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery); | JavaScript |
;(function($){
/**
* jqGrid Turkish Translation
* Erhan Gündoğan (erhan@trposta.net)
* http://blog.zakkum.com
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "{0}-{1} listeleniyor. Toplam:{2}",
emptyrecords: "Kayıt bulunamadı",
loadtext: "Yükleniyor...",
pgtext : "{0}/{1}. Sayfa"
},
search : {
caption: "Arama...",
Find: "Bul",
Reset: "Temizle",
odata : ['eşit', 'eşit değil', 'daha az', 'daha az veya eşit', 'daha fazla', 'daha fazla veya eşit', 'ile başlayan', 'ile başlamayan', 'içinde', 'içinde değil', 'ile biten', 'ile bitmeyen', 'içeren', 'içermeyen'],
groupOps: [ { op: "VE", text: "tüm" }, { op: "VEYA", text: "herhangi" } ],
matchText: " uyan",
rulesText: " kurallar"
},
edit : {
addCaption: "Kayıt Ekle",
editCaption: "Kayıt Düzenle",
bSubmit: "Gönder",
bCancel: "İptal",
bClose: "Kapat",
saveData: "Veriler değişti! Kayıt edilsin mi?",
bYes : "Evet",
bNo : "Hayıt",
bExit : "İptal",
msg: {
required:"Alan gerekli",
number:"Lütfen bir numara giriniz",
minValue:"girilen değer daha büyük ya da buna eşit olmalıdır",
maxValue:"girilen değer daha küçük ya da buna eşit olmalıdır",
email: "geçerli bir e-posta adresi değildir",
integer: "Lütfen bir tamsayı giriniz",
url: "Geçerli bir URL değil. ('http://' or 'https://') ön eki gerekli.",
nodefined : " is not defined!",
novalue : " return value is required!",
customarray : "Custom function should return array!",
customfcheck : "Custom function should be present in case of custom checking!"
}
},
view : {
caption: "Kayıt Görüntüle",
bClose: "Kapat"
},
del : {
caption: "Sil",
msg: "Seçilen kayıtlar silinsin mi?",
bSubmit: "Sil",
bCancel: "İptal"
},
nav : {
edittext: " ",
edittitle: "Seçili satırı düzenle",
addtext:" ",
addtitle: "Yeni satır ekle",
deltext: " ",
deltitle: "Seçili satırı sil",
searchtext: " ",
searchtitle: "Kayıtları bul",
refreshtext: "",
refreshtitle: "Tabloyu yenile",
alertcap: "Uyarı",
alerttext: "Lütfen bir satır seçiniz",
viewtext: "",
viewtitle: "Seçilen satırı görüntüle"
},
col : {
caption: "Sütunları göster/gizle",
bSubmit: "Gönder",
bCancel: "İptal"
},
errors : {
errcap : "Hata",
nourl : "Bir url yapılandırılmamış",
norecords: "İşlem yapılacak bir kayıt yok",
model : "colNames uzunluğu <> colModel!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0.00'},
currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},
date : {
dayNames: [
"Paz", "Pts", "Sal", "Çar", "Per", "Cum", "Cts",
"Pazar", "Pazartesi", "Salı", "Çarşamba", "Perşembe", "Cuma", "Cumartesi"
],
monthNames: [
"Oca", "Şub", "Mar", "Nis", "May", "Haz", "Tem", "Ağu", "Eyl", "Eki", "Kas", "Ara",
"Ocak", "Şubat", "Mart", "Nisan", "Mayıs", "Haziran", "Temmuz", "Ağustos", "Eylül", "Ekim", "Kasım", "Aralık"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Danish Translation
* Aesiras A/S
* http://www.aesiras.dk
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Vis {0} - {1} of {2}",
emptyrecords: "Ingen linjer fundet",
loadtext: "Henter...",
pgtext : "Side {0} af {1}"
},
search : {
caption: "Søg...",
Find: "Find",
Reset: "Nulstil",
odata : ['lig', 'forskellige fra', 'mindre', 'mindre eller lig','større','større eller lig', 'begynder med','begynder ikke med','findes i','findes ikke i','ender med','ender ikke med','indeholder','indeholder ikke'],
groupOps: [ { op: "AND", text: "all" }, { op: "OR", text: "any" } ],
matchText: " lig",
rulesText: " regler"
},
edit : {
addCaption: "Tilføj",
editCaption: "Ret",
bSubmit: "Send",
bCancel: "Annuller",
bClose: "Luk",
saveData: "Data er ændret. Gem data?",
bYes : "Ja",
bNo : "Nej",
bExit : "Fortryd",
msg: {
required:"Felt er nødvendigt",
number:"Indtast venligst et validt tal",
minValue:"værdi skal være større end eller lig med",
maxValue:"værdi skal være mindre end eller lig med",
email: "er ikke en gyldig email",
integer: "Indtast venligst et gyldigt heltal",
date: "Indtast venligst en gyldig datoværdi",
url: "er ugyldig URL. Prefix mangler ('http://' or 'https://')",
nodefined : " er ikke defineret!",
novalue : " returværdi kræves!",
customarray : "Custom function should return array!",
customfcheck : "Custom function should be present in case of custom checking!"
}
},
view : {
caption: "Vis linje",
bClose: "Luk"
},
del : {
caption: "Slet",
msg: "Slet valgte linje(r)?",
bSubmit: "Slet",
bCancel: "Fortryd"
},
nav : {
edittext: " ",
edittitle: "Rediger valgte linje",
addtext:" ",
addtitle: "Tilføj ny linje",
deltext: " ",
deltitle: "Slet valgte linje",
searchtext: " ",
searchtitle: "Find linjer",
refreshtext: "",
refreshtitle: "Indlæs igen",
alertcap: "Advarsel",
alerttext: "Vælg venligst linje",
viewtext: "",
viewtitle: "Vis valgte linje"
},
col : {
caption: "Vis/skjul kolonner",
bSubmit: "Opdatere",
bCancel: "Fortryd"
},
errors : {
errcap : "Fejl",
nourl : "Ingen url valgt",
norecords: "Ingen linjer at behandle",
model : "colNames og colModel har ikke samme længde!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0,00'},
currency : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0,00'},
date : {
dayNames: [
"Søn", "Man", "Tir", "Ons", "Tor", "Fre", "Lør",
"Søndag", "Mandag", "Tirsdag", "Onsdag", "Torsdag", "Fredag", "Lørdag"
],
monthNames: [
"Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec",
"Januar", "Februar", "Marts", "April", "Maj", "Juni", "Juli", "August", "September", "Oktober", "November", "December"
],
AmPm : ["","","",""],
S: function (j) {return '.'},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "j/n/Y",
LongDate: "l d. F Y",
FullDateTime: "l d F Y G:i:s",
MonthDay: "d. F",
ShortTime: "G:i",
LongTime: "G:i:s",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
// DA
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Romanian Translation
* Alexandru Emil Lupu contact@alecslupu.ro
* http://www.alecslupu.ro/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Vizualizare {0} - {1} din {2}",
emptyrecords: "Nu există înregistrări de vizualizat",
loadtext: "Încărcare...",
pgtext : "Pagina {0} din {1}"
},
search : {
caption: "Caută...",
Find: "Caută",
Reset: "Resetare",
odata : ['egal', 'diferit', 'mai mic', 'mai mic sau egal','mai mare','mai mare sau egal', 'începe cu','nu începe cu','se găsește în','nu se găsește în','se termină cu','nu se termină cu','conține',''],
groupOps: [ { op: "AND", text: "toate" }, { op: "OR", text: "oricare" } ],
matchText: " găsite",
rulesText: " reguli"
},
edit : {
addCaption: "Adăugare înregistrare",
editCaption: "Modificare înregistrare",
bSubmit: "Salvează",
bCancel: "Anulare",
bClose: "Închide",
saveData: "Informațiile au fost modificate! Salvați modificările?",
bYes : "Da",
bNo : "Nu",
bExit : "Anulare",
msg: {
required:"Câmpul este obligatoriu",
number:"Vă rugăm introduceți un număr valid",
minValue:"valoarea trebuie sa fie mai mare sau egală cu",
maxValue:"valoarea trebuie sa fie mai mică sau egală cu",
email: "nu este o adresă de e-mail validă",
integer: "Vă rugăm introduceți un număr valid",
date: "Vă rugăm să introduceți o dată validă",
url: "Nu este un URL valid. Prefixul este necesar('http://' or 'https://')",
nodefined : " is not defined!",
novalue : " return value is required!",
customarray : "Custom function should return array!",
customfcheck : "Custom function should be present in case of custom checking!"
}
},
view : {
caption: "Vizualizare înregistrare",
bClose: "Închidere"
},
del : {
caption: "Ștegere",
msg: "Ștergeți înregistrarea (înregistrările) selectate?",
bSubmit: "Șterge",
bCancel: "Anulare"
},
nav : {
edittext: "",
edittitle: "Modifică rândul selectat",
addtext:"",
addtitle: "Adaugă rând nou",
deltext: "",
deltitle: "Șterge rândul selectat",
searchtext: "",
searchtitle: "Căutare înregistrări",
refreshtext: "",
refreshtitle: "Reîncarcare Grid",
alertcap: "Avertisment",
alerttext: "Vă rugăm să selectați un rând",
viewtext: "",
viewtitle: "Vizualizează rândul selectat"
},
col : {
caption: "Arată/Ascunde coloanele",
bSubmit: "Salvează",
bCancel: "Anulare"
},
errors : {
errcap : "Eroare",
nourl : "Niciun url nu este setat",
norecords: "Nu sunt înregistrări de procesat",
model : "Lungimea colNames <> colModel!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0,00'},
currency : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0,00'},
date : {
dayNames: [
"Dum", "Lun", "Mar", "Mie", "Joi", "Vin", "Sâm",
"Duminică", "Luni", "Marți", "Miercuri", "Joi", "Vineri", "Sâmbătă"
],
monthNames: [
"Ian", "Feb", "Mar", "Apr", "Mai", "Iun", "Iul", "Aug", "Sep", "Oct", "Noi", "Dec",
"Ianuarie", "Februarie", "Martie", "Aprilie", "Mai", "Iunie", "Iulie", "August", "Septembrie", "Octombrie", "Noiembrie", "Decembrie"
],
AmPm : ["am","pm","AM","PM"],
/*
Here is a problem in romanian:
M / F
1st = primul / prima
2nd = Al doilea / A doua
3rd = Al treilea / A treia
4th = Al patrulea/ A patra
5th = Al cincilea / A cincea
6th = Al șaselea / A șasea
7th = Al șaptelea / A șaptea
....
*/
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Greek (el) Translation
* Alex Cicovic
* http://www.alexcicovic.com
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "View {0} - {1} of {2}",
emptyrecords: "No records to view",
loadtext: "Φόρτωση...",
pgtext : "Page {0} of {1}"
},
search : {
caption: "Αναζήτηση...",
Find: "Εύρεση",
Reset: "Επαναφορά",
odata : ['equal', 'not equal', 'less', 'less or equal','greater','greater or equal', 'begins with','does not begin with','is in','is not in','ends with','does not end with','contains','does not contain'],
groupOps: [ { op: "AND", text: "all" }, { op: "OR", text: "any" } ],
matchText: " match",
rulesText: " rules"
},
edit : {
addCaption: "Εισαγωγή Εγγραφής",
editCaption: "Επεξεργασία Εγγραφής",
bSubmit: "Καταχώρηση",
bCancel: "Άκυρο",
bClose: "Κλείσιμο",
saveData: "Data has been changed! Save changes?",
bYes : "Yes",
bNo : "No",
bExit : "Cancel",
msg: {
required:"Το πεδίο είναι απαραίτητο",
number:"Το πεδίο δέχεται μόνο αριθμούς",
minValue:"Η τιμή πρέπει να είναι μεγαλύτερη ή ίση του ",
maxValue:"Η τιμή πρέπει να είναι μικρότερη ή ίση του ",
email: "Η διεύθυνση e-mail δεν είναι έγκυρη",
integer: "Το πεδίο δέχεται μόνο ακέραιους αριθμούς",
url: "is not a valid URL. Prefix required ('http://' or 'https://')",
nodefined : " is not defined!",
novalue : " return value is required!",
customarray : "Custom function should return array!",
customfcheck : "Custom function should be present in case of custom checking!"
}
},
view : {
caption: "View Record",
bClose: "Close"
},
del : {
caption: "Διαγραφή",
msg: "Διαγραφή των επιλεγμένων εγγραφών;",
bSubmit: "Ναι",
bCancel: "Άκυρο"
},
nav : {
edittext: " ",
edittitle: "Επεξεργασία επιλεγμένης εγγραφής",
addtext:" ",
addtitle: "Εισαγωγή νέας εγγραφής",
deltext: " ",
deltitle: "Διαγραφή επιλεγμένης εγγραφής",
searchtext: " ",
searchtitle: "Εύρεση Εγγραφών",
refreshtext: "",
refreshtitle: "Ανανέωση Πίνακα",
alertcap: "Προσοχή",
alerttext: "Δεν έχετε επιλέξει εγγραφή",
viewtext: "",
viewtitle: "View selected row"
},
col : {
caption: "Εμφάνιση / Απόκρυψη Στηλών",
bSubmit: "ΟΚ",
bCancel: "Άκυρο"
},
errors : {
errcap : "Σφάλμα",
nourl : "Δεν έχει δοθεί διεύθυνση χειρισμού για τη συγκεκριμένη ενέργεια",
norecords: "Δεν υπάρχουν εγγραφές προς επεξεργασία",
model : "Άνισος αριθμός πεδίων colNames/colModel!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0.00'},
currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},
date : {
dayNames: [
"Κυρ", "Δευ", "Τρι", "Τετ", "Πεμ", "Παρ", "Σαβ",
"Κυριακή", "Δευτέρα", "Τρίτη", "Τετάρτη", "Πέμπτη", "Παρασκευή", "Σάββατο"
],
monthNames: [
"Ιαν", "Φεβ", "Μαρ", "Απρ", "Μαι", "Ιουν", "Ιουλ", "Αυγ", "Σεπ", "Οκτ", "Νοε", "Δεκ",
"Ιανουάριος", "Φεβρουάριος", "Μάρτιος", "Απρίλιος", "Μάιος", "Ιούνιος", "Ιούλιος", "Αύγουστος", "Σεπτέμβριος", "Οκτώβριος", "Νοέμβριος", "Δεκέμβριος"
],
AmPm : ["πμ","μμ","ΠΜ","ΜΜ"],
S: function (j) {return j == 1 || j > 1 ? ['η'][Math.min((j - 1) % 10, 3)] : ''},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Bulgarian Translation
* Tony Tomov tony@trirand.com
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "{0} - {1} �� {2}",
emptyrecords: "���� �����(�)",
loadtext: "��������...",
pgtext : "���. {0} �� {1}"
},
search : {
caption: "�������...",
Find: "������",
Reset: "�������",
odata : ['�����', '��������', '��-�����', '��-����� ���=','��-������','��-������ ��� =', '������� �','�� ������� �','�� ������ �','�� �� ������ �','�������� �','�� ��������� �','�������', '�� �������' ],
groupOps: [ { op: "AND", text: " � " }, { op: "OR", text: "���" } ],
matchText: " ������",
rulesText: " ������"
},
edit : {
addCaption: "��� �����",
editCaption: "�������� �����",
bSubmit: "������",
bCancel: "�����",
bClose: "�������",
saveData: "������� �� ���������! �� ������� �� ���������?",
bYes : "��",
bNo : "��",
bExit : "�����",
msg: {
required:"������ � ������������",
number:"�������� ������� �����!",
minValue:"���������� ������ �� � ��-������ ��� ����� ��",
maxValue:"���������� ������ �� � ��-����� ��� ����� ��",
email: "�� � ������� ��. �����",
integer: "�������� ������� ���� �����",
date: "�������� ������� ����",
url: "e ��������� URL. �������� �� �������('http://' ��� 'https://')",
nodefined : " � ������������!",
novalue : " ������� ������� �� ��������!",
customarray : "������. ������� ������ �� ����� �����!",
customfcheck : "������������� ������� � ������������ ��� ���� ��� �������!"
}
},
view : {
caption: "������� �����",
bClose: "�������"
},
del : {
caption: "���������",
msg: "�� ������ �� ��������� �����?",
bSubmit: "������",
bCancel: "�����"
},
nav : {
edittext: " ",
edittitle: "�������� ������ �����",
addtext:" ",
addtitle: "�������� ��� �����",
deltext: " ",
deltitle: "��������� ������ �����",
searchtext: " ",
searchtitle: "������� �����(�)",
refreshtext: "",
refreshtitle: "������ �������",
alertcap: "��������������",
alerttext: "����, �������� �����",
viewtext: "",
viewtitle: "������� ������ �����"
},
col : {
caption: "����� ������",
bSubmit: "��",
bCancel: "�����"
},
errors : {
errcap : "������",
nourl : "���� ������� url �����",
norecords: "���� ����� �� ���������",
model : "������ �� ����������� �� �������!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0.00'},
currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:" ��.", defaultValue: '0.00'},
date : {
dayNames: [
"���", "���", "��", "��", "���", "���", "���",
"������", "����������", "�������", "�����", "���������", "�����", "������"
],
monthNames: [
"���", "���", "���", "���", "���", "���", "���", "���", "���", "���", "���", "���",
"������", "��������", "����", "�����", "���", "���", "���", "������", "���������", "��������", "�������", "��������"
],
AmPm : ["","","",""],
S: function (j) {
if(j==7 || j==8 || j== 27 || j== 28) {
return '��';
}
return ['��', '��', '��'][Math.min((j - 1) % 10, 2)];
},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid English Translation
* Tony Tomov tony@trirand.com
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Data {0} - {1} dari {2}",
emptyrecords: "Tidak ada data",
loadtext: "Memuat...",
pgtext : "Halaman {0} dari {1}"
},
search : {
caption: "Pencarian",
Find: "Cari !",
Reset: "Segarkan",
odata : ['sama dengan', 'tidak sama dengan', 'kurang dari',
'kurang dari atau sama dengan','lebih besar','lebih besar atau sama dengan',
'dimulai dengan','tidak dimulai dengan','di dalam','tidak di dalam','diakhiri dengan',
'tidak diakhiri dengan','mengandung','tidak mengandung'],
groupOps: [ { op: "AND", text: "all" }, { op: "OR", text: "any" } ],
matchText: " match",
rulesText: " rules"
},
edit : {
addCaption: "Tambah Data",
editCaption: "Sunting Data",
bSubmit: "Submit",
bCancel: "Tutup",
bClose: "Tutup",
saveData: "Data telah berubah! Simpan perubahan?",
bYes : "Ya",
bNo : "Tidak",
bExit : "Tutup",
msg: {
required:"kolom wajib diisi",
number:"hanya nomer yang diperbolehkan",
minValue:"kolom harus lebih besar dari atau sama dengan",
maxValue:"kolom harus lebih kecil atau sama dengan",
email: "alamat e-mail tidak valid",
integer: "hanya nilai integer yang diperbolehkan",
date: "nilai tanggal tidak valid",
url: "Bukan URL yang valid. Harap gunakan ('http://' or 'https://')",
nodefined : " belum didefinisikan!",
novalue : " return value is required!",
customarray : "Custom function should return array!",
customfcheck : "Custom function should be present in case of custom checking!"
}
},
view : {
caption: "Menampilkan data",
bClose: "Tutup"
},
del : {
caption: "Hapus",
msg: "Hapus data terpilih?",
bSubmit: "Hapus",
bCancel: "Batalkan"
},
nav : {
edittext: "",
edittitle: "Sunting data terpilih",
addtext:"",
addtitle: "Tambah baris baru",
deltext: "",
deltitle: "Hapus baris terpilih",
searchtext: "",
searchtitle: "Temukan data",
refreshtext: "",
refreshtitle: "Segarkan Grid",
alertcap: "Warning",
alerttext: "Harap pilih baris",
viewtext: "",
viewtitle: "Tampilkan baris terpilih"
},
col : {
caption: "Pilih Kolom",
bSubmit: "Ok",
bCancel: "Batal"
},
errors : {
errcap : "Error",
nourl : "Tidak ada url yang diset",
norecords: "Tidak ada data untuk diproses",
model : "Lebar dari colNames <> colModel!"
},
formatter : {
integer : {thousandsSeparator: ".", defaultValue: '0'},
number : {decimalSeparator:",", thousandsSeparator: ".", decimalPlaces: 2, defaultValue: '0'},
currency : {decimalSeparator:",", thousandsSeparator: ".", decimalPlaces: 2, prefix: "Rp. ", suffix:"", defaultValue: '0'},
date : {
dayNames: [
"Ming", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab",
"Minggu", "Senin", "Selasa", "Rabu", "Kamis", "Jumat", "Sabtu"
],
monthNames: [
"Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Agu", "Sep", "Okt", "Nov", "Des",
"Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th';},
srcformat: 'Y-m-d',
newformat: 'n/j/Y',
masks : {
// see http://php.net/manual/en/function.date.php for PHP format used in jqGrid
// and see http://docs.jquery.com/UI/Datepicker/formatDate
// and https://github.com/jquery/globalize#dates for alternative formats used frequently
// one can find on https://github.com/jquery/globalize/tree/master/lib/cultures many
// information about date, time, numbers and currency formats used in different countries
// one should just convert the information in PHP format
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
// short date:
// n - Numeric representation of a month, without leading zeros
// j - Day of the month without leading zeros
// Y - A full numeric representation of a year, 4 digits
// example: 3/1/2012 which means 1 March 2012
ShortDate: "n/j/Y", // in jQuery UI Datepicker: "M/d/yyyy"
// long date:
// l - A full textual representation of the day of the week
// F - A full textual representation of a month
// d - Day of the month, 2 digits with leading zeros
// Y - A full numeric representation of a year, 4 digits
LongDate: "l, F d, Y", // in jQuery UI Datepicker: "dddd, MMMM dd, yyyy"
// long date with long time:
// l - A full textual representation of the day of the week
// F - A full textual representation of a month
// d - Day of the month, 2 digits with leading zeros
// Y - A full numeric representation of a year, 4 digits
// g - 12-hour format of an hour without leading zeros
// i - Minutes with leading zeros
// s - Seconds, with leading zeros
// A - Uppercase Ante meridiem and Post meridiem (AM or PM)
FullDateTime: "l, F d, Y g:i:s A", // in jQuery UI Datepicker: "dddd, MMMM dd, yyyy h:mm:ss tt"
// month day:
// F - A full textual representation of a month
// d - Day of the month, 2 digits with leading zeros
MonthDay: "F d", // in jQuery UI Datepicker: "MMMM dd"
// short time (without seconds)
// g - 12-hour format of an hour without leading zeros
// i - Minutes with leading zeros
// A - Uppercase Ante meridiem and Post meridiem (AM or PM)
ShortTime: "g:i A", // in jQuery UI Datepicker: "h:mm tt"
// long time (with seconds)
// g - 12-hour format of an hour without leading zeros
// i - Minutes with leading zeros
// s - Seconds, with leading zeros
// A - Uppercase Ante meridiem and Post meridiem (AM or PM)
LongTime: "g:i:s A", // in jQuery UI Datepicker: "h:mm:ss tt"
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
// month with year
// Y - A full numeric representation of a year, 4 digits
// F - A full textual representation of a month
YearMonth: "F, Y" // in jQuery UI Datepicker: "MMMM, yyyy"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Icelandic Translation
* jtm@hi.is Univercity of Iceland
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Skoða {0} - {1} af {2}",
emptyrecords: "Engar færslur",
loadtext: "Hleður...",
pgtext : "Síða {0} af {1}"
},
search : {
caption: "Leita...",
Find: "Leita",
Reset: "Endursetja",
odata : ['sama og', 'ekki sama og', 'minna en', 'minna eða jafnt og','stærra en','stærra eða jafnt og', 'byrjar á','byrjar ekki á','er í','er ekki í','endar á','endar ekki á','inniheldur','inniheldur ekki'],
groupOps: [ { op: "AND", text: "allt" }, { op: "OR", text: "eða" } ],
matchText: " passar",
rulesText: " reglur"
},
edit : {
addCaption: "Bæta við færslu",
editCaption: "Breyta færslu",
bSubmit: "Vista",
bCancel: "Hætta við",
bClose: "Loka",
saveData: "Gögn hafa breyst! Vista breytingar?",
bYes : "Já",
bNo : "Nei",
bExit : "Hætta við",
msg: {
required:"Reitur er nauðsynlegur",
number:"Vinsamlega settu inn tölu",
minValue:"gildi verður að vera meira en eða jafnt og ",
maxValue:"gildi verður að vera minna en eða jafnt og ",
email: "er ekki löglegt email",
integer: "Vinsamlega settu inn tölu",
date: "Vinsamlega setti inn dagsetningu",
url: "er ekki löglegt URL. Vantar ('http://' eða 'https://')",
nodefined : " er ekki skilgreint!",
novalue : " skilagildi nauðsynlegt!",
customarray : "Fall skal skila fylki!",
customfcheck : "Fall skal vera skilgreint!"
}
},
view : {
caption: "Skoða færslu",
bClose: "Loka"
},
del : {
caption: "Eyða",
msg: "Eyða völdum færslum ?",
bSubmit: "Eyða",
bCancel: "Hætta við"
},
nav : {
edittext: " ",
edittitle: "Breyta færslu",
addtext:" ",
addtitle: "Ný færsla",
deltext: " ",
deltitle: "Eyða færslu",
searchtext: " ",
searchtitle: "Leita",
refreshtext: "",
refreshtitle: "Endurhlaða",
alertcap: "Viðvörun",
alerttext: "Vinsamlega veldu færslu",
viewtext: "",
viewtitle: "Skoða valda færslu"
},
col : {
caption: "Sýna / fela dálka",
bSubmit: "Vista",
bCancel: "Hætta við"
},
errors : {
errcap : "Villa",
nourl : "Vantar slóð",
norecords: "Engar færslur valdar",
model : "Lengd colNames <> colModel!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0.00'},
currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},
date : {
dayNames: [
"Sun", "Mán", "Þri", "Mið", "Fim", "Fös", "Lau",
"Sunnudagur", "Mánudagur", "Þriðjudagur", "Miðvikudagur", "Fimmtudagur", "Föstudagur", "Laugardagur"
],
monthNames: [
"Jan", "Feb", "Mar", "Apr", "Maí", "Jún", "Júl", "Ágú", "Sep", "Oct", "Nóv", "Des",
"Janúar", "Febrúar", "Mars", "Apríl", "Maí", "Júný", "Júlý", "Ágúst", "September", "Október", "Nóvember", "Desember"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Chinese Translation for v4.2
* henryyan 2011.11.30
* http://www.wsria.com
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* update 2011.11.30
* add double u3000 SPACE for search:odata to fix SEARCH box display err when narrow width from only use of eq/ne/cn/in/lt/gt operator under IE6/7
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "{0} - {1}\u3000共 {2} 条", // 共字前是全角空格
emptyrecords: "无数据显示",
loadtext: "读取中...",
pgtext : " {0} 共 {1} 页"
},
search : {
caption: "搜索...",
Find: "查找",
Reset: "重置",
odata : ['等于\u3000\u3000', '不等\u3000\u3000', '小于\u3000\u3000', '小于等于','大于\u3000\u3000','大于等于',
'开始于','不开始于','属于\u3000\u3000','不属于','结束于','不结束于','包含\u3000\u3000','不包含','空值于\u3000\u3000','非空值'],
groupOps: [ { op: "AND", text: "所有" }, { op: "OR", text: "任一" } ],
matchText: " 匹配",
rulesText: " 规则"
},
edit : {
addCaption: "添加记录",
editCaption: "编辑记录",
bSubmit: "提交",
bCancel: "取消",
bClose: "关闭",
saveData: "数据已改变,是否保存?",
bYes : "是",
bNo : "否",
bExit : "取消",
msg: {
required:"此字段必需",
number:"请输入有效数字",
minValue:"输值必须大于等于 ",
maxValue:"输值必须小于等于 ",
email: "这不是有效的e-mail地址",
integer: "请输入有效整数",
date: "请输入有效时间",
url: "无效网址。前缀必须为 ('http://' 或 'https://')",
nodefined : " 未定义!",
novalue : " 需要返回值!",
customarray : "自定义函数需要返回数组!",
customfcheck : "Custom function should be present in case of custom checking!"
}
},
view : {
caption: "查看记录",
bClose: "关闭"
},
del : {
caption: "删除",
msg: "删除所选记录?",
bSubmit: "删除",
bCancel: "取消"
},
nav : {
edittext: "",
edittitle: "编辑所选记录",
addtext:"",
addtitle: "添加新记录",
deltext: "",
deltitle: "删除所选记录",
searchtext: "",
searchtitle: "查找",
refreshtext: "",
refreshtitle: "刷新表格",
alertcap: "注意",
alerttext: "请选择记录",
viewtext: "",
viewtitle: "查看所选记录"
},
col : {
caption: "选择列",
bSubmit: "确定",
bCancel: "取消"
},
errors : {
errcap : "错误",
nourl : "没有设置url",
norecords: "没有要处理的记录",
model : "colNames 和 colModel 长度不等!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0.00'},
currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},
date : {
dayNames: [
"Sun", "Mon", "Tue", "Wed", "Thr", "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"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
srcformat: 'Y-m-d',
newformat: 'm-d-Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "Y/j/n",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Bulgarian Translation
* Tony Tomov tony@trirand.com
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "{0} - {1} от {2}",
emptyrecords: "Няма запис(и)",
loadtext: "Зареждам...",
pgtext : "Стр. {0} от {1}"
},
search : {
caption: "Търсене...",
Find: "Намери",
Reset: "Изчисти",
odata : ['равно', 'различно', 'по-малко', 'по-малко или=','по-голямо','по-голямо или =', 'започва с','не започва с','се намира в','не се намира в','завършва с','не завършава с','съдържа', 'не съдържа' ],
groupOps: [ { op: "AND", text: " И " }, { op: "OR", text: "ИЛИ" } ],
matchText: " включи",
rulesText: " клауза"
},
edit : {
addCaption: "Нов Запис",
editCaption: "Редакция Запис",
bSubmit: "Запиши",
bCancel: "Изход",
bClose: "Затвори",
saveData: "Данните са променени! Да съхраня ли промените?",
bYes : "Да",
bNo : "Не",
bExit : "Отказ",
msg: {
required:"Полето е задължително",
number:"Въведете валидно число!",
minValue:"стойността трябва да е по-голяма или равна от",
maxValue:"стойността трябва да е по-малка или равна от",
email: "не е валиден ел. адрес",
integer: "Въведете валидно цяло число",
date: "Въведете валидна дата",
url: "e невалиден URL. Изискава се префикс('http://' или 'https://')",
nodefined : " е недефинирана!",
novalue : " изисква връщане на стойност!",
customarray : "Потреб. Функция трябва да върне масив!",
customfcheck : "Потребителска функция е задължителна при този тип елемент!"
}
},
view : {
caption: "Преглед запис",
bClose: "Затвори"
},
del : {
caption: "Изтриване",
msg: "Да изтрия ли избраният запис?",
bSubmit: "Изтрий",
bCancel: "Отказ"
},
nav : {
edittext: " ",
edittitle: "Редакция избран запис",
addtext:" ",
addtitle: "Добавяне нов запис",
deltext: " ",
deltitle: "Изтриване избран запис",
searchtext: " ",
searchtitle: "Търсене запис(и)",
refreshtext: "",
refreshtitle: "Обнови таблица",
alertcap: "Предупреждение",
alerttext: "Моля, изберете запис",
viewtext: "",
viewtitle: "Преглед избран запис"
},
col : {
caption: "Избери колони",
bSubmit: "Ок",
bCancel: "Изход"
},
errors : {
errcap : "Грешка",
nourl : "Няма посочен url адрес",
norecords: "Няма запис за обработка",
model : "Модела не съответства на имената!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0.00'},
currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:" лв.", defaultValue: '0.00'},
date : {
dayNames: [
"Нед", "Пон", "Вт", "Ср", "Чет", "Пет", "Съб",
"Неделя", "Понеделник", "Вторник", "Сряда", "Четвъртък", "Петък", "Събота"
],
monthNames: [
"Яну", "Фев", "Мар", "Апр", "Май", "Юни", "Юли", "Авг", "Сеп", "Окт", "Нов", "Дек",
"Януари", "Февруари", "Март", "Април", "Май", "Юни", "Юли", "Август", "Септември", "Октомври", "Ноември", "Декември"
],
AmPm : ["","","",""],
S: function (j) {
if(j==7 || j==8 || j== 27 || j== 28) {
return 'ми';
}
return ['ви', 'ри', 'ти'][Math.min((j - 1) % 10, 2)];
},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Chinese (Taiwan) Translation for v4.2
* linquize
* https://github.com/linquize/jqGrid
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "{0} - {1} 共 {2} 條",
emptyrecords: "沒有記錄",
loadtext: "載入中...",
pgtext : " {0} 共 {1} 頁"
},
search : {
caption: "搜尋...",
Find: "搜尋",
Reset: "重設",
odata : ['等於 ', '不等於 ', '小於 ', '小於等於 ','大於 ','大於等於 ', '開始於 ','不開始於 ','在其中 ','不在其中 ','結束於 ','不結束於 ','包含 ','不包含 '],
groupOps: [ { op: "AND", text: "所有" }, { op: "OR", text: "任一" } ],
matchText: " 匹配",
rulesText: " 規則"
},
edit : {
addCaption: "新增記錄",
editCaption: "編輯記錄",
bSubmit: "提交",
bCancel: "取消",
bClose: "關閉",
saveData: "資料已改變,是否儲存?",
bYes : "是",
bNo : "否",
bExit : "取消",
msg: {
required:"此欄必要",
number:"請輸入有效的數字",
minValue:"值必須大於等於 ",
maxValue:"值必須小於等於 ",
email: "不是有效的e-mail地址",
integer: "請輸入有效整数",
date: "請輸入有效時間",
url: "網址無效。前綴必須為 ('http://' 或 'https://')",
nodefined : " 未定義!",
novalue : " 需要傳回值!",
customarray : "自訂函數應傳回陣列!",
customfcheck : "自訂檢查應有自訂函數!"
}
},
view : {
caption: "查看記錄",
bClose: "關閉"
},
del : {
caption: "刪除",
msg: "刪除已選記錄?",
bSubmit: "刪除",
bCancel: "取消"
},
nav : {
edittext: "",
edittitle: "編輯已選列",
addtext:"",
addtitle: "新增列",
deltext: "",
deltitle: "刪除已選列",
searchtext: "",
searchtitle: "搜尋記錄",
refreshtext: "",
refreshtitle: "重新整理表格",
alertcap: "警告",
alerttext: "請選擇列",
viewtext: "",
viewtitle: "檢視已選列"
},
col : {
caption: "選擇欄",
bSubmit: "確定",
bCancel: "取消"
},
errors : {
errcap : "錯誤",
nourl : "未設定URL",
norecords: "無需要處理的記錄",
model : "colNames 和 colModel 長度不同!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0.00'},
currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},
date : {
dayNames: [
"日", "一", "二", "三", "四", "五", "六",
"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"
],
monthNames: [
"一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二",
"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"
],
AmPm : ["上午","下午","上午","下午"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
srcformat: 'Y-m-d',
newformat: 'm-d-Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "Y/j/n",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Japanese Translation
* OKADA Yoshitada okada.dev@sth.jp
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "{2} \u4EF6\u4E2D {0} - {1} \u3092\u8868\u793A ",
emptyrecords: "\u8868\u793A\u3059\u308B\u30EC\u30B3\u30FC\u30C9\u304C\u3042\u308A\u307E\u305B\u3093",
loadtext: "\u8aad\u307f\u8fbc\u307f\u4e2d...",
pgtext : "{1} \u30DA\u30FC\u30B8\u4E2D {0} \u30DA\u30FC\u30B8\u76EE "
},
search : {
caption: "\u691c\u7d22...",
Find: "\u691c\u7d22",
Reset: "\u30ea\u30bb\u30c3\u30c8",
odata: ["\u6B21\u306B\u7B49\u3057\u3044", "\u6B21\u306B\u7B49\u3057\u304F\u306A\u3044",
"\u6B21\u3088\u308A\u5C0F\u3055\u3044", "\u6B21\u306B\u7B49\u3057\u3044\u304B\u5C0F\u3055\u3044",
"\u6B21\u3088\u308A\u5927\u304D\u3044", "\u6B21\u306B\u7B49\u3057\u3044\u304B\u5927\u304D\u3044",
"\u6B21\u3067\u59CB\u307E\u308B", "\u6B21\u3067\u59CB\u307E\u3089\u306A\u3044",
"\u6B21\u306B\u542B\u307E\u308C\u308B", "\u6B21\u306B\u542B\u307E\u308C\u306A\u3044",
"\u6B21\u3067\u7D42\u308F\u308B", "\u6B21\u3067\u7D42\u308F\u3089\u306A\u3044",
"\u6B21\u3092\u542B\u3080", "\u6B21\u3092\u542B\u307E\u306A\u3044"],
groupOps: [{
op: "AND",
text: "\u3059\u3079\u3066\u306E"
},
{
op: "OR",
text: "\u3044\u305A\u308C\u304B\u306E"
}],
matchText: " \u6B21\u306E",
rulesText: " \u6761\u4EF6\u3092\u6E80\u305F\u3059"
},
edit : {
addCaption: "\u30ec\u30b3\u30fc\u30c9\u8ffd\u52a0",
editCaption: "\u30ec\u30b3\u30fc\u30c9\u7de8\u96c6",
bSubmit: "\u9001\u4fe1",
bCancel: "\u30ad\u30e3\u30f3\u30bb\u30eb",
bClose: "\u9589\u3058\u308b",
saveData: "\u30C7\u30FC\u30BF\u304C\u5909\u66F4\u3055\u308C\u3066\u3044\u307E\u3059\u3002\u4FDD\u5B58\u3057\u307E\u3059\u304B\uFF1F",
bYes: "\u306F\u3044",
bNo: "\u3044\u3044\u3048",
bExit: "\u30AD\u30E3\u30F3\u30BB\u30EB",
msg: {
required:"\u3053\u306e\u9805\u76ee\u306f\u5fc5\u9808\u3067\u3059\u3002",
number:"\u6b63\u3057\u3044\u6570\u5024\u3092\u5165\u529b\u3057\u3066\u4e0b\u3055\u3044\u3002",
minValue:"\u6b21\u306e\u5024\u4ee5\u4e0a\u3067\u5165\u529b\u3057\u3066\u4e0b\u3055\u3044\u3002",
maxValue:"\u6b21\u306e\u5024\u4ee5\u4e0b\u3067\u5165\u529b\u3057\u3066\u4e0b\u3055\u3044\u3002",
email: "e-mail\u304c\u6b63\u3057\u304f\u3042\u308a\u307e\u305b\u3093\u3002",
integer: "\u6b63\u3057\u3044\u6574\u6570\u5024\u3092\u5165\u529b\u3057\u3066\u4e0b\u3055\u3044\u3002",
date: "\u6b63\u3057\u3044\u5024\u3092\u5165\u529b\u3057\u3066\u4e0b\u3055\u3044\u3002",
url: "\u306F\u6709\u52B9\u306AURL\u3067\u306F\u3042\u308A\u307E\u305B\u3093\u3002\20\u30D7\u30EC\u30D5\u30A3\u30C3\u30AF\u30B9\u304C\u5FC5\u8981\u3067\u3059\u3002 ('http://' \u307E\u305F\u306F 'https://')",
nodefined: " \u304C\u5B9A\u7FA9\u3055\u308C\u3066\u3044\u307E\u305B\u3093",
novalue: " \u623B\u308A\u5024\u304C\u5FC5\u8981\u3067\u3059",
customarray: "\u30AB\u30B9\u30BF\u30E0\u95A2\u6570\u306F\u914D\u5217\u3092\u8FD4\u3059\u5FC5\u8981\u304C\u3042\u308A\u307E\u3059",
customfcheck: "\u30AB\u30B9\u30BF\u30E0\u691C\u8A3C\u306B\u306F\u30AB\u30B9\u30BF\u30E0\u95A2\u6570\u304C\u5FC5\u8981\u3067\u3059"
}
},
view : {
caption: "\u30EC\u30B3\u30FC\u30C9\u3092\u8868\u793A",
bClose: "\u9589\u3058\u308B"
},
del : {
caption: "\u524a\u9664",
msg: "\u9078\u629e\u3057\u305f\u30ec\u30b3\u30fc\u30c9\u3092\u524a\u9664\u3057\u307e\u3059\u304b\uff1f",
bSubmit: "\u524a\u9664",
bCancel: "\u30ad\u30e3\u30f3\u30bb\u30eb"
},
nav : {
edittext: " ",
edittitle: "\u9078\u629e\u3057\u305f\u884c\u3092\u7de8\u96c6",
addtext:" ",
addtitle: "\u884c\u3092\u65b0\u898f\u8ffd\u52a0",
deltext: " ",
deltitle: "\u9078\u629e\u3057\u305f\u884c\u3092\u524a\u9664",
searchtext: " ",
searchtitle: "\u30ec\u30b3\u30fc\u30c9\u691c\u7d22",
refreshtext: "",
refreshtitle: "\u30b0\u30ea\u30c3\u30c9\u3092\u30ea\u30ed\u30fc\u30c9",
alertcap: "\u8b66\u544a",
alerttext: "\u884c\u3092\u9078\u629e\u3057\u3066\u4e0b\u3055\u3044\u3002",
viewtext: "",
viewtitle: "\u9078\u629E\u3057\u305F\u884C\u3092\u8868\u793A"
},
col : {
caption: "\u5217\u3092\u8868\u793a\uff0f\u96a0\u3059",
bSubmit: "\u9001\u4fe1",
bCancel: "\u30ad\u30e3\u30f3\u30bb\u30eb"
},
errors : {
errcap : "\u30a8\u30e9\u30fc",
nourl : "URL\u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u307e\u305b\u3093\u3002",
norecords: "\u51e6\u7406\u5bfe\u8c61\u306e\u30ec\u30b3\u30fc\u30c9\u304c\u3042\u308a\u307e\u305b\u3093\u3002",
model : "colNames\u306e\u9577\u3055\u304ccolModel\u3068\u4e00\u81f4\u3057\u307e\u305b\u3093\u3002"
},
formatter : {
integer: {
thousandsSeparator: ",",
defaultValue: '0'
},
number: {
decimalSeparator: ".",
thousandsSeparator: ",",
decimalPlaces: 2,
defaultValue: '0.00'
},
currency: {
decimalSeparator: ".",
thousandsSeparator: ",",
decimalPlaces: 0,
prefix: "",
suffix: "",
defaultValue: '0'
},
date : {
dayNames: [
"\u65e5", "\u6708", "\u706b", "\u6c34", "\u6728", "\u91d1", "\u571f",
"\u65e5", "\u6708", "\u706b", "\u6c34", "\u6728", "\u91d1", "\u571f"
],
monthNames: [
"1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
"1\u6708", "2\u6708", "3\u6708", "4\u6708", "5\u6708", "6\u6708", "7\u6708", "8\u6708", "9\u6708", "10\u6708", "11\u6708", "12\u6708"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) { return "\u756a\u76ee"; },
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid (fi) Finnish Translation
* Jukka Inkeri awot.fi 2010-05-19
* Alex Grönholm alex.gronholm@nextday.fi 2011-05-18
* http://awot.fi
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults: {
recordtext: "Rivit {0} - {1} / {2}",
emptyrecords: "Ei näytettäviä",
loadtext: "Haetaan...",
pgtext: "Sivu {0} / {1}"
},
search: {
caption: "Etsi...",
Find: "Etsi",
Reset: "Tyhjennä",
odata: ['on', 'ei ole', 'pienempi', 'pienempi tai yhtäsuuri','suurempi','suurempi tai yhtäsuuri', 'alkaa','ei ala','joukossa','ei joukossa','loppuu','ei lopu','sisältää','ei sisällä','on tyhjä','ei ole tyhjä'],
groupOps: [ { op: "AND", text: "kaikki" }, { op: "OR", text: "mikä tahansa" } ],
matchText: " täytä ehdot:",
rulesText: ""
},
edit: {
addCaption: "Uusi rivi",
editCaption: "Muokkaa riviä",
bSubmit: "OK",
bCancel: "Peru",
bClose: "Sulje",
saveData: "Tietoja muutettu! Tallennetaanko?",
bYes: "Kyllä",
bNo: "Ei",
bExit: "Peru",
msg: {
required: "pakollinen",
number: "Anna kelvollinen nro",
minValue: "arvon oltava suurempi tai yhtäsuuri kuin ",
maxValue: "arvon oltava pienempi tai yhtäsuuri kuin ",
email: "ei ole kelvollinen säpostiosoite",
integer: "Anna kelvollinen kokonaisluku",
date: "Anna kelvollinen pvm",
url: "Ei ole kelvollinen linkki(URL). Alku oltava ('http://' tai 'https://')",
nodefined: " ei ole määritelty!",
novalue: " paluuarvo vaaditaan!",
customarray: "Oman funktion tulee palauttaa jono!",
customfcheck: "Oma funktio on määriteltävä räätälöityä tarkastusta varten!"
}
},
view: {
caption: "Näytä rivi",
bClose: "Sulje"
},
del: {
caption: "Poista",
msg: "Poista valitut rivit?",
bSubmit: "Poista",
bCancel: "Peru"
},
nav: {
edittext: "",
edittitle: "Muokkaa valittua riviä",
addtext: "",
addtitle: "Uusi rivi",
deltext: "",
deltitle: "Poista valittu rivi",
searchtext: "",
searchtitle: "Etsi tietoja",
refreshtext: "",
refreshtitle: "Lataa uudelleen",
alertcap: "Varoitus",
alerttext: "Valitse rivi",
viewtext: "",
viewtitle: "Näyta valitut rivit"
},
col: {
caption: "Valitse sarakkeet",
bSubmit: "OK",
bCancel: "Peru"
},
errors : {
errcap: "Virhe",
nourl: "URL on asettamatta",
norecords: "Ei muokattavia tietoja",
model: "Pituus colNames <> colModel!"
},
formatter: {
integer: {thousandsSeparator: "", defaultValue: '0'},
number: {decimalSeparator:",", thousandsSeparator: "", decimalPlaces: 2, defaultValue: '0,00'},
currency: {decimalSeparator:",", thousandsSeparator: "", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0,00'},
date: {
dayNames: [
"Su", "Ma", "Ti", "Ke", "To", "Pe", "La",
"Sunnuntai", "Maanantai", "Tiistai", "Keskiviikko", "Torstai", "Perjantai", "Lauantai"
],
monthNames: [
"Tam", "Hel", "Maa", "Huh", "Tou", "Kes", "Hei", "Elo", "Syy", "Lok", "Mar", "Jou",
"Tammikuu", "Helmikuu", "Maaliskuu", "Huhtikuu", "Toukokuu", "Kesäkuu", "Heinäkuu", "Elokuu", "Syyskuu", "Lokakuu", "Marraskuu", "Joulukuu"
],
AmPm: ["am","pm","AM","PM"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
srcformat: 'Y-m-d',
newformat: 'd.m.Y',
masks: {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "d.m.Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox: {disabled:true},
idName: 'id'
}
});
// FI
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Galician Translation
* Translated by Jorge Barreiro <yortx.barry@gmail.com>
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Amosando {0} - {1} de {2}",
emptyrecords: "Sen rexistros que amosar",
loadtext: "Cargando...",
pgtext : "Páxina {0} de {1}"
},
search : {
caption: "Búsqueda...",
Find: "Buscar",
Reset: "Limpar",
odata : ['igual ', 'diferente a', 'menor que', 'menor ou igual que','maior que','maior ou igual a', 'empece por','non empece por','está en','non está en','termina por','non termina por','contén','non contén'],
groupOps: [ { op: "AND", text: "todo" }, { op: "OR", text: "calquera" } ],
matchText: " match",
rulesText: " regras"
},
edit : {
addCaption: "Engadir rexistro",
editCaption: "Modificar rexistro",
bSubmit: "Gardar",
bCancel: "Cancelar",
bClose: "Pechar",
saveData: "Modificáronse os datos, quere gardar os cambios?",
bYes : "Si",
bNo : "Non",
bExit : "Cancelar",
msg: {
required:"Campo obrigatorio",
number:"Introduza un número",
minValue:"O valor debe ser maior ou igual a ",
maxValue:"O valor debe ser menor ou igual a ",
email: "non é un enderezo de correo válido",
integer: "Introduza un valor enteiro",
date: "Introduza unha data correcta ",
url: "non é unha URL válida. Prefixo requerido ('http://' ou 'https://')",
nodefined : " non está definido.",
novalue : " o valor de retorno é obrigatorio.",
customarray : "A función persoalizada debe devolver un array.",
customfcheck : "A función persoalizada debe estar presente no caso de ter validación persoalizada."
}
},
view : {
caption: "Consultar rexistro",
bClose: "Pechar"
},
del : {
caption: "Eliminar",
msg: "Desexa eliminar os rexistros seleccionados?",
bSubmit: "Eliminar",
bCancel: "Cancelar"
},
nav : {
edittext: " ",
edittitle: "Modificar a fila seleccionada",
addtext:" ",
addtitle: "Engadir unha nova fila",
deltext: " ",
deltitle: "Eliminar a fila seleccionada",
searchtext: " ",
searchtitle: "Buscar información",
refreshtext: "",
refreshtitle: "Recargar datos",
alertcap: "Aviso",
alerttext: "Seleccione unha fila",
viewtext: "",
viewtitle: "Ver fila seleccionada"
},
col : {
caption: "Mostrar/ocultar columnas",
bSubmit: "Enviar",
bCancel: "Cancelar"
},
errors : {
errcap : "Erro",
nourl : "Non especificou unha URL",
norecords: "Non hai datos para procesar",
model : "As columnas de nomes son diferentes das columnas de modelo"
},
formatter : {
integer : {thousandsSeparator: ".", defaultValue: '0'},
number : {decimalSeparator:",", thousandsSeparator: ".", decimalPlaces: 2, defaultValue: '0,00'},
currency : {decimalSeparator:",", thousandsSeparator: ".", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0,00'},
date : {
dayNames: [
"Do", "Lu", "Ma", "Me", "Xo", "Ve", "Sa",
"Domingo", "Luns", "Martes", "Mércoles", "Xoves", "Vernes", "Sábado"
],
monthNames: [
"Xan", "Feb", "Mar", "Abr", "Mai", "Xuñ", "Xul", "Ago", "Set", "Out", "Nov", "Dec",
"Xaneiro", "Febreiro", "Marzo", "Abril", "Maio", "Xuño", "Xullo", "Agosto", "Setembro", "Outubro", "Novembro", "Decembro"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
srcformat: 'Y-m-d',
newformat: 'd-m-Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Serbian Translation
* Александар Миловац(Aleksandar Milovac) aleksandar.milovac@gmail.com
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Преглед {0} - {1} од {2}",
emptyrecords: "Не постоји ниједан запис",
loadtext: "Учитавање...",
pgtext : "Страна {0} од {1}"
},
search : {
caption: "Тражење...",
Find: "Тражи",
Reset: "Ресетуј",
odata : ['једнако', 'није једнако', 'мање', 'мање или једнако','веће','веће или једнако', 'почиње са','не почиње са','је у','није у','завршава са','не завршава са','садржи','не садржи'],
groupOps: [ { op: "И", text: "сви" }, { op: "ИЛИ", text: "сваки" } ],
matchText: " match",
rulesText: " правила"
},
edit : {
addCaption: "Додај запис",
editCaption: "Измени запис",
bSubmit: "Пошаљи",
bCancel: "Одустани",
bClose: "Затвори",
saveData: "Податак је измењен! Сачувај измене?",
bYes : "Да",
bNo : "Не",
bExit : "Одустани",
msg: {
required:"Поље је обавезно",
number:"Молим, унесите исправан број",
minValue:"вредност мора бити већа од или једнака са ",
maxValue:"вредност мора бити мања од или једнака са",
email: "није исправна имејл адреса",
integer: "Молим, унесите исправну целобројну вредност ",
date: "Молим, унесите исправан датум",
url: "није исправан УРЛ. Потребан је префикс ('http://' or 'https://')",
nodefined : " није дефинисан!",
novalue : " захтевана је повратна вредност!",
customarray : "Custom function should return array!",
customfcheck : "Custom function should be present in case of custom checking!"
}
},
view : {
caption: "Погледај запис",
bClose: "Затвори"
},
del : {
caption: "Избриши",
msg: "Избриши изабран(е) запис(е)?",
bSubmit: "Ибриши",
bCancel: "Одбаци"
},
nav : {
edittext: "",
edittitle: "Измени изабрани ред",
addtext:"",
addtitle: "Додај нови ред",
deltext: "",
deltitle: "Избриши изабран ред",
searchtext: "",
searchtitle: "Нађи записе",
refreshtext: "",
refreshtitle: "Поново учитај податке",
alertcap: "Упозорење",
alerttext: "Молим, изаберите ред",
viewtext: "",
viewtitle: "Погледај изабрани ред"
},
col : {
caption: "Изабери колоне",
bSubmit: "ОК",
bCancel: "Одбаци"
},
errors : {
errcap : "Грешка",
nourl : "Није постављен URL",
norecords: "Нема записа за обраду",
model : "Дужина модела colNames <> colModel!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0.00'},
currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},
date : {
dayNames: [
"Нед", "Пон", "Уто", "Сре", "Чет", "Пет", "Суб",
"Недеља", "Понедељак", "Уторак", "Среда", "Четвртак", "Петак", "Субота"
],
monthNames: [
"Јан", "Феб", "Мар", "Апр", "Мај", "Јун", "Јул", "Авг", "Сеп", "Окт", "Нов", "Дец",
"Јануар", "Фебруар", "Март", "Април", "Мај", "Јун", "Јул", "Август", "Септембар", "Октобар", "Новембар", "Децембар"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid French Translation
* Tony Tomov tony@trirand.com
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Enregistrements {0} - {1} sur {2}",
emptyrecords: "Aucun enregistrement à afficher",
loadtext: "Chargement...",
pgtext : "Page {0} sur {1}"
},
search : {
caption: "Recherche...",
Find: "Chercher",
Reset: "Réinitialiser",
odata : ['égal', 'différent', 'inférieur', 'inférieur ou égal','supérieur','supérieur ou égal', 'commence par','ne commence pas par','est dans',"n'est pas dans",'finit par','ne finit pas par','contient','ne contient pas'],
groupOps: [ { op: "AND", text: "tous" }, { op: "OR", text: "au moins un" } ],
matchText: " correspondance",
rulesText: " règles"
},
edit : {
addCaption: "Ajouter",
editCaption: "Editer",
bSubmit: "Valider",
bCancel: "Annuler",
bClose: "Fermer",
saveData: "Les données ont changé ! Enregistrer les modifications ?",
bYes: "Oui",
bNo: "Non",
bExit: "Annuler",
msg: {
required: "Champ obligatoire",
number: "Saisissez un nombre correct",
minValue: "La valeur doit être supérieure ou égale à",
maxValue: "La valeur doit être inférieure ou égale à",
email: "n'est pas un email correct",
integer: "Saisissez un entier correct",
url: "n'est pas une adresse correcte. Préfixe requis ('http://' or 'https://')",
nodefined : " n'est pas défini!",
novalue : " la valeur de retour est requise!",
customarray : "Une fonction personnalisée devrait retourner un tableau (array)!",
customfcheck : "Une fonction personnalisée devrait être présente dans le cas d'une vérification personnalisée!"
}
},
view : {
caption: "Voir les enregistrement",
bClose: "Fermer"
},
del : {
caption: "Supprimer",
msg: "Supprimer les enregistrements sélectionnés ?",
bSubmit: "Supprimer",
bCancel: "Annuler"
},
nav : {
edittext: " ",
edittitle: "Editer la ligne sélectionnée",
addtext:" ",
addtitle: "Ajouter une ligne",
deltext: " ",
deltitle: "Supprimer la ligne sélectionnée",
searchtext: " ",
searchtitle: "Chercher un enregistrement",
refreshtext: "",
refreshtitle: "Recharger le tableau",
alertcap: "Avertissement",
alerttext: "Veuillez sélectionner une ligne",
viewtext: "",
viewtitle: "Afficher la ligne sélectionnée"
},
col : {
caption: "Afficher/Masquer les colonnes",
bSubmit: "Valider",
bCancel: "Annuler"
},
errors : {
errcap : "Erreur",
nourl : "Aucune adresse n'est paramétrée",
norecords: "Aucun enregistrement à traiter",
model : "Nombre de titres (colNames) <> Nombre de données (colModel)!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0,00'},
currency : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0,00'},
date : {
dayNames: [
"Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam",
"Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"
],
monthNames: [
"Jan", "Fév", "Mar", "Avr", "Mai", "Jui", "Jul", "Aou", "Sep", "Oct", "Nov", "Déc",
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Décembre"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return j == 1 ? 'er' : 'e';},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Thai Translation
* Kittituch Manakul m.kittituch@Gmail.com
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "แสดง {0} - {1} จาก {2}",
emptyrecords: "ไม่พบข้อมูล",
loadtext: "กำลังร้องขอข้อมูล...",
pgtext : "หน้า {0} จาก {1}"
},
search : {
caption: "กำลังค้นหา...",
Find: "ค้นหา",
Reset: "คืนค่ากลับ",
odata : ['เท่ากับ', 'ไม่เท่ากับ', 'น้อยกว่า', 'ไม่มากกว่า','มากกกว่า','ไม่น้อยกว่า', 'ขึ้นต้นด้วย','ไม่ขึ้นต้นด้วย','มีคำใดคำหนึ่งใน','ไม่มีคำใดคำหนึ่งใน','ลงท้ายด้วย','ไม่ลงท้ายด้วย','มีคำว่า','ไม่มีคำว่า'],
groupOps: [ { op: "และ", text: "ทั้งหมด" }, { op: "หรือ", text: "ใดๆ" } ],
matchText: " ตรงกันกับ",
rulesText: " ตามกฏ"
},
edit : {
addCaption: "เพิ่มข้อมูล",
editCaption: "แก้ไขข้อมูล",
bSubmit: "บันทึก",
bCancel: "ยกเลิก",
bClose: "ปิด",
saveData: "คุณต้องการบันทึการแก้ไข ใช่หรือไม่?",
bYes : "บันทึก",
bNo : "ละทิ้งการแก้ไข",
bExit : "ยกเลิก",
msg: {
required:"ข้อมูลนี้จำเป็น",
number:"กรุณากรอกหมายเลขให้ถูกต้อง",
minValue:"ค่าของข้อมูลนี้ต้องไม่น้อยกว่า",
maxValue:"ค่าของข้อมูลนี้ต้องไม่มากกว่า",
email: "อีเมลล์นี้ไม่ถูกต้อง",
integer: "กรุณากรอกเป็นจำนวนเต็ม",
date: "กรุณากรอกวันที่ให้ถูกต้อง",
url: "URL ไม่ถูกต้อง URL จำเป็นต้องขึ้นต้นด้วย 'http://' หรือ 'https://'",
nodefined : "ไม่ได้ถูกกำหนดค่า!",
novalue : "ต้องการการคืนค่า!",
customarray : "ฟังก์ชันที่สร้างขึ้นต้องส่งค่ากลับเป็นแบบแอเรย์",
customfcheck : "ระบบต้องการฟังก์ชันที่สร้างขึ้นสำหรับการตรวจสอบ!"
}
},
view : {
caption: "เรียกดูข้อมูล",
bClose: "ปิด"
},
del : {
caption: "ลบข้อมูล",
msg: "คุณต้องการลบข้อมูลที่ถูกเลือก ใช่หรือไม่?",
bSubmit: "ต้องการลบ",
bCancel: "ยกเลิก"
},
nav : {
edittext: "",
edittitle: "แก้ไขข้อมูล",
addtext:"",
addtitle: "เพิ่มข้อมูล",
deltext: "",
deltitle: "ลบข้อมูล",
searchtext: "",
searchtitle: "ค้นหาข้อมูล",
refreshtext: "",
refreshtitle: "รีเฟรช",
alertcap: "คำเตือน",
alerttext: "กรุณาเลือกข้อมูล",
viewtext: "",
viewtitle: "ดูรายละเอียดข้อมูล"
},
col : {
caption: "กรุณาเลือกคอลัมน์",
bSubmit: "ตกลง",
bCancel: "ยกเลิก"
},
errors : {
errcap : "เกิดความผิดพลาด",
nourl : "ไม่ได้กำหนด URL",
norecords: "ไม่มีข้อมูลให้ดำเนินการ",
model : "จำนวนคอลัมน์ไม่เท่ากับจำนวนคอลัมน์โมเดล!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0.00'},
currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},
date : {
dayNames: [
"อา", "จ", "อ", "พ", "พฤ", "ศ", "ส",
"อาทิตย์", "จันทร์", "อังคาร", "พุธ", "พฤหัสบดี", "ศูกร์", "เสาร์"
],
monthNames: [
"ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค.",
"มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฏาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return ''},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid English Translation
* Tony Tomov tony@trirand.com
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "보기 {0} - {1} / {2}",
emptyrecords: "표시할 행이 없습니다",
loadtext: "조회중...",
pgtext : "페이지 {0} / {1}"
},
search : {
caption: "검색...",
Find: "찾기",
Reset: "초기화",
odata : ['같다', '같지 않다', '작다', '작거나 같다','크다','크거나 같다', '로 시작한다','로 시작하지 않는다','내에 있다','내에 있지 않다','로 끝난다','로 끝나지 않는다','내에 존재한다','내에 존재하지 않는다'],
groupOps: [ { op: "AND", text: "전부" }, { op: "OR", text: "임의" } ],
matchText: " 일치하다",
rulesText: " 적용하다"
},
edit : {
addCaption: "행 추가",
editCaption: "행 수정",
bSubmit: "전송",
bCancel: "취소",
bClose: "닫기",
saveData: "자료가 변경되었습니다! 저장하시겠습니까?",
bYes : "예",
bNo : "아니오",
bExit : "취소",
msg: {
required:"필수항목입니다",
number:"유효한 번호를 입력해 주세요",
minValue:"입력값은 크거나 같아야 합니다",
maxValue:"입력값은 작거나 같아야 합니다",
email: "유효하지 않은 이메일주소입니다",
integer: "유효한 숫자를 입력하세요",
date: "유효한 날짜를 입력하세요",
url: "은 유효하지 않은 URL입니다. 문장앞에 다음단어가 필요합니다('http://' or 'https://')",
nodefined : " 은 정의도지 않았습니다!",
novalue : " 반환값이 필요합니다!",
customarray : "사용자정의 함수는 배열을 반환해야 합니다!",
customfcheck : "Custom function should be present in case of custom checking!"
}
},
view : {
caption: "행 조회",
bClose: "닫기"
},
del : {
caption: "삭제",
msg: "선택된 행을 삭제하시겠습니까?",
bSubmit: "삭제",
bCancel: "취소"
},
nav : {
edittext: "",
edittitle: "선택된 행 편집",
addtext:"",
addtitle: "행 삽입",
deltext: "",
deltitle: "선택된 행 삭제",
searchtext: "",
searchtitle: "행 찾기",
refreshtext: "",
refreshtitle: "그리드 갱신",
alertcap: "경고",
alerttext: "행을 선택하세요",
viewtext: "",
viewtitle: "선택된 행 조회"
},
col : {
caption: "열을 선택하세요",
bSubmit: "확인",
bCancel: "취소"
},
errors : {
errcap : "오류",
nourl : "설정된 url이 없습니다",
norecords: "처리할 행이 없습니다",
model : "colNames의 길이가 colModel과 일치하지 않습니다!"
},
formatter : {
integer : {thousandsSeparator: ",", defaultValue: '0'},
number : {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2, defaultValue: '0.00'},
currency : {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},
date : {
dayNames: [
"Sun", "Mon", "Tue", "Wed", "Thr", "Fri", "Sat",
"일", "월", "화", "수", "목", "금", "토"
],
monthNames: [
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
"1월", "2월", "3월", "4월", "5월", "6월", "7월", "8월", "9월", "10월", "11월", "12월"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
srcformat: 'Y-m-d',
newformat: 'm-d-Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "Y/j/n",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Arabic Translation
*
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "تسجيل {0} - {1} على {2}",
emptyrecords: "لا يوجد تسجيل",
loadtext: "تحميل...",
pgtext : "صفحة {0} على {1}"
},
search : {
caption: "بحث...",
Find: "بحث",
Reset: "إلغاء",
odata : ['يساوي', 'يختلف', 'أقل', 'أقل أو يساوي','أكبر','أكبر أو يساوي', 'يبدأ بـ','لا يبدأ بـ','est dans',"n'est pas dans",'ينته بـ','لا ينته بـ','يحتوي','لا يحتوي'],
groupOps: [ { op: "مع", text: "الكل" }, { op: "أو", text: "لا أحد" } ],
matchText: " توافق",
rulesText: " قواعد"
},
edit : {
addCaption: "اضافة",
editCaption: "تحديث",
bSubmit: "تثبيث",
bCancel: "إلغاء",
bClose: "غلق",
saveData: "تغيرت المعطيات هل تريد التسجيل ?",
bYes: "نعم",
bNo: "لا",
bExit: "إلغاء",
msg: {
required: "خانة إجبارية",
number: "سجل رقم صحيح",
minValue: "يجب أن تكون القيمة أكبر أو تساوي 0",
maxValue: "يجب أن تكون القيمة أقل أو تساوي 0",
email: "بريد غير صحيح",
integer: "سجل عدد طبييعي صحيح",
url: "ليس عنوانا صحيحا. البداية الصحيحة ('http://' أو 'https://')",
nodefined : " ليس محدد!",
novalue : " قيمة الرجوع مطلوبة!",
customarray : "يجب على الدالة الشخصية أن تنتج جدولا",
customfcheck : "الدالة الشخصية مطلوبة في حالة التحقق الشخصي"
}
},
view : {
caption: "رأيت التسجيلات",
bClose: "غلق"
},
del : {
caption: "حذف",
msg: "حذف التسجيلات المختارة ?",
bSubmit: "حذف",
bCancel: "إلغاء"
},
nav : {
edittext: " ",
edittitle: "تغيير التسجيل المختار",
addtext:" ",
addtitle: "إضافة تسجيل",
deltext: " ",
deltitle: "حذف التسجيل المختار",
searchtext: " ",
searchtitle: "بحث عن تسجيل",
refreshtext: "",
refreshtitle: "تحديث الجدول",
alertcap: "تحذير",
alerttext: "يرجى إختيار السطر",
viewtext: "",
viewtitle: "إظهار السطر المختار"
},
col : {
caption: "إظهار/إخفاء الأعمدة",
bSubmit: "تثبيث",
bCancel: "إلغاء"
},
errors : {
errcap : "خطأ",
nourl : "لا يوجد عنوان محدد",
norecords: "لا يوجد تسجيل للمعالجة",
model : "عدد العناوين (colNames) <> عدد التسجيلات (colModel)!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0,00'},
currency : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0,00'},
date : {
dayNames: [
"الأحد", "الإثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت",
"الأحد", "الإثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت"
],
monthNames: [
"جانفي", "فيفري", "مارس", "أفريل", "ماي", "جوان", "جويلية", "أوت", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر",
"جانفي", "فيفري", "مارس", "أفريل", "ماي", "جوان", "جويلية", "أوت", "سبتمبر", "أكتوبر", "نوفمبر", "ديسمبر"
],
AmPm : ["صباحا","مساءا","صباحا","مساءا"],
S: function (j) {return j == 1 ? 'er' : 'e';},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Czech Translation
* Pavel Jirak pavel.jirak@jipas.cz
* doplnil Thomas Wagner xwagne01@stud.fit.vutbr.cz
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Zobrazeno {0} - {1} z {2} záznamů",
emptyrecords: "Nenalezeny žádné záznamy",
loadtext: "Načítám...",
pgtext : "Strana {0} z {1}"
},
search : {
caption: "Vyhledávám...",
Find: "Hledat",
Reset: "Reset",
odata : ['rovno', 'nerovono', 'menší', 'menší nebo rovno','větší', 'větší nebo rovno', 'začíná s', 'nezačíná s', 'je v', 'není v', 'končí s', 'nekončí s', 'obahuje', 'neobsahuje'],
groupOps: [ { op: "AND", text: "všech" }, { op: "OR", text: "některého z" } ],
matchText: " hledat podle",
rulesText: " pravidel"
},
edit : {
addCaption: "Přidat záznam",
editCaption: "Editace záznamu",
bSubmit: "Uložit",
bCancel: "Storno",
bClose: "Zavřít",
saveData: "Data byla změněna! Uložit změny?",
bYes : "Ano",
bNo : "Ne",
bExit : "Zrušit",
msg: {
required:"Pole je vyžadováno",
number:"Prosím, vložte validní číslo",
minValue:"hodnota musí být větší než nebo rovná ",
maxValue:"hodnota musí být menší než nebo rovná ",
email: "není validní e-mail",
integer: "Prosím, vložte celé číslo",
date: "Prosím, vložte validní datum",
url: "není platnou URL. Vyžadován prefix ('http://' or 'https://')",
nodefined : " není definován!",
novalue : " je vyžadována návratová hodnota!",
customarray : "Custom function mělá vrátit pole!",
customfcheck : "Custom function by měla být přítomna v případě custom checking!"
}
},
view : {
caption: "Zobrazit záznam",
bClose: "Zavřít"
},
del : {
caption: "Smazat",
msg: "Smazat vybraný(é) záznam(y)?",
bSubmit: "Smazat",
bCancel: "Storno"
},
nav : {
edittext: " ",
edittitle: "Editovat vybraný řádek",
addtext:" ",
addtitle: "Přidat nový řádek",
deltext: " ",
deltitle: "Smazat vybraný záznam ",
searchtext: " ",
searchtitle: "Najít záznamy",
refreshtext: "",
refreshtitle: "Obnovit tabulku",
alertcap: "Varování",
alerttext: "Prosím, vyberte řádek",
viewtext: "",
viewtitle: "Zobrazit vybraný řádek"
},
col : {
caption: "Zobrazit/Skrýt sloupce",
bSubmit: "Uložit",
bCancel: "Storno"
},
errors : {
errcap : "Chyba",
nourl : "Není nastavena url",
norecords: "Žádné záznamy ke zpracování",
model : "Délka colNames <> colModel!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0.00'},
currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},
date : {
dayNames: [
"Ne", "Po", "Út", "St", "Čt", "Pá", "So",
"Neděle", "Pondělí", "Úterý", "Středa", "Čtvrtek", "Pátek", "Sobota"
],
monthNames: [
"Led", "Úno", "Bře", "Dub", "Kvě", "Čer", "Čvc", "Srp", "Zář", "Říj", "Lis", "Pro",
"Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec"
],
AmPm : ["do","od","DO","OD"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid English Translation
* Tony Tomov tony@trirand.com
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "View {0} - {1} of {2}",
emptyrecords: "No records to view",
loadtext: "Loading...",
pgtext : "Page {0} of {1}"
},
search : {
caption: "Search...",
Find: "Find",
Reset: "Reset",
odata : ['equal', 'not equal', 'less', 'less or equal','greater','greater or equal', 'begins with','does not begin with','is in','is not in','ends with','does not end with','contains','does not contain'],
groupOps: [ { op: "AND", text: "all" }, { op: "OR", text: "any" } ],
matchText: " match",
rulesText: " rules"
},
edit : {
addCaption: "Add Record",
editCaption: "Edit Record",
bSubmit: "Submit",
bCancel: "Cancel",
bClose: "Close",
saveData: "Data has been changed! Save changes?",
bYes : "Yes",
bNo : "No",
bExit : "Cancel",
msg: {
required:"Field is required",
number:"Please, enter valid number",
minValue:"value must be greater than or equal to ",
maxValue:"value must be less than or equal to",
email: "is not a valid e-mail",
integer: "Please, enter valid integer value",
date: "Please, enter valid date value",
url: "is not a valid URL. Prefix required ('http://' or 'https://')",
nodefined : " is not defined!",
novalue : " return value is required!",
customarray : "Custom function should return array!",
customfcheck : "Custom function should be present in case of custom checking!"
}
},
view : {
caption: "View Record",
bClose: "Close"
},
del : {
caption: "Delete",
msg: "Delete selected record(s)?",
bSubmit: "Delete",
bCancel: "Cancel"
},
nav : {
edittext: "",
edittitle: "Edit selected row",
addtext:"",
addtitle: "Add new row",
deltext: "",
deltitle: "Delete selected row",
searchtext: "",
searchtitle: "Find records",
refreshtext: "",
refreshtitle: "Reload Grid",
alertcap: "Warning",
alerttext: "Please, select row",
viewtext: "",
viewtitle: "View selected row"
},
col : {
caption: "Select columns",
bSubmit: "Ok",
bCancel: "Cancel"
},
errors : {
errcap : "Error",
nourl : "No url is set",
norecords: "No records to process",
model : "Length of colNames <> colModel!"
},
formatter : {
integer : {thousandsSeparator: ",", defaultValue: '0'},
number : {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2, defaultValue: '0.00'},
currency : {decimalSeparator:".", thousandsSeparator: ",", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},
date : {
dayNames: [
"Sun", "Mon", "Tue", "Wed", "Thr", "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"
],
AmPm : ["am","pm","AM","PM"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th';},
srcformat: 'Y-m-d',
newformat: 'n/j/Y',
masks : {
// see http://php.net/manual/en/function.date.php for PHP format used in jqGrid
// and see http://docs.jquery.com/UI/Datepicker/formatDate
// and https://github.com/jquery/globalize#dates for alternative formats used frequently
// one can find on https://github.com/jquery/globalize/tree/master/lib/cultures many
// information about date, time, numbers and currency formats used in different countries
// one should just convert the information in PHP format
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
// short date:
// n - Numeric representation of a month, without leading zeros
// j - Day of the month without leading zeros
// Y - A full numeric representation of a year, 4 digits
// example: 3/1/2012 which means 1 March 2012
ShortDate: "n/j/Y", // in jQuery UI Datepicker: "M/d/yyyy"
// long date:
// l - A full textual representation of the day of the week
// F - A full textual representation of a month
// d - Day of the month, 2 digits with leading zeros
// Y - A full numeric representation of a year, 4 digits
LongDate: "l, F d, Y", // in jQuery UI Datepicker: "dddd, MMMM dd, yyyy"
// long date with long time:
// l - A full textual representation of the day of the week
// F - A full textual representation of a month
// d - Day of the month, 2 digits with leading zeros
// Y - A full numeric representation of a year, 4 digits
// g - 12-hour format of an hour without leading zeros
// i - Minutes with leading zeros
// s - Seconds, with leading zeros
// A - Uppercase Ante meridiem and Post meridiem (AM or PM)
FullDateTime: "l, F d, Y g:i:s A", // in jQuery UI Datepicker: "dddd, MMMM dd, yyyy h:mm:ss tt"
// month day:
// F - A full textual representation of a month
// d - Day of the month, 2 digits with leading zeros
MonthDay: "F d", // in jQuery UI Datepicker: "MMMM dd"
// short time (without seconds)
// g - 12-hour format of an hour without leading zeros
// i - Minutes with leading zeros
// A - Uppercase Ante meridiem and Post meridiem (AM or PM)
ShortTime: "g:i A", // in jQuery UI Datepicker: "h:mm tt"
// long time (with seconds)
// g - 12-hour format of an hour without leading zeros
// i - Minutes with leading zeros
// s - Seconds, with leading zeros
// A - Uppercase Ante meridiem and Post meridiem (AM or PM)
LongTime: "g:i:s A", // in jQuery UI Datepicker: "h:mm:ss tt"
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
// month with year
// Y - A full numeric representation of a year, 4 digits
// F - A full textual representation of a month
YearMonth: "F, Y" // in jQuery UI Datepicker: "MMMM, yyyy"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Hungarian Translation
* Őrszigety Ádám udx6bs@freemail.hu
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Oldal {0} - {1} / {2}",
emptyrecords: "Nincs találat",
loadtext: "Betöltés...",
pgtext : "Oldal {0} / {1}"
},
search : {
caption: "Keresés...",
Find: "Keres",
Reset: "Alapértelmezett",
odata : ['egyenlő', 'nem egyenlő', 'kevesebb', 'kevesebb vagy egyenlő','nagyobb','nagyobb vagy egyenlő', 'ezzel kezdődik','nem ezzel kezdődik','tartalmaz','nem tartalmaz','végződik','nem végződik','tartalmaz','nem tartalmaz'],
groupOps: [ { op: "AND", text: "all" }, { op: "OR", text: "any" } ],
matchText: " match",
rulesText: " rules"
},
edit : {
addCaption: "Új tétel",
editCaption: "Tétel szerkesztése",
bSubmit: "Mentés",
bCancel: "Mégse",
bClose: "Bezárás",
saveData: "A tétel megváltozott! Tétel mentése?",
bYes : "Igen",
bNo : "Nem",
bExit : "Mégse",
msg: {
required:"Kötelező mező",
number:"Kérjük, adjon meg egy helyes számot",
minValue:"Nagyobb vagy egyenlőnek kell lenni mint ",
maxValue:"Kisebb vagy egyenlőnek kell lennie mint",
email: "hibás emailcím",
integer: "Kérjük adjon meg egy helyes egész számot",
date: "Kérjük adjon meg egy helyes dátumot",
url: "nem helyes cím. Előtag kötelező ('http://' vagy 'https://')",
nodefined : " nem definiált!",
novalue : " visszatérési érték kötelező!!",
customarray : "Custom function should return array!",
customfcheck : "Custom function should be present in case of custom checking!"
}
},
view : {
caption: "Tétel megtekintése",
bClose: "Bezárás"
},
del : {
caption: "Törlés",
msg: "Kiválaztott tétel(ek) törlése?",
bSubmit: "Törlés",
bCancel: "Mégse"
},
nav : {
edittext: "",
edittitle: "Tétel szerkesztése",
addtext:"",
addtitle: "Új tétel hozzáadása",
deltext: "",
deltitle: "Tétel törlése",
searchtext: "",
searchtitle: "Keresés",
refreshtext: "",
refreshtitle: "Frissítés",
alertcap: "Figyelmeztetés",
alerttext: "Kérem válasszon tételt.",
viewtext: "",
viewtitle: "Tétel megtekintése"
},
col : {
caption: "Oszlopok kiválasztása",
bSubmit: "Ok",
bCancel: "Mégse"
},
errors : {
errcap : "Hiba",
nourl : "Nincs URL beállítva",
norecords: "Nincs feldolgozásra váró tétel",
model : "colNames és colModel hossza nem egyenlő!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0,00'},
currency : {decimalSeparator:",", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0,00'},
date : {
dayNames: [
"Va", "Hé", "Ke", "Sze", "Csü", "Pé", "Szo",
"Vasárnap", "Hétfő", "Kedd", "Szerda", "Csütörtök", "Péntek", "Szombat"
],
monthNames: [
"Jan", "Feb", "Már", "Ápr", "Máj", "Jún", "Júl", "Aug", "Szep", "Okt", "Nov", "Dec",
"Január", "Február", "Március", "Áprili", "Május", "Június", "Július", "Augusztus", "Szeptember", "Október", "November", "December"
],
AmPm : ["de","du","DE","DU"],
S: function (j) {return '.-ik';},
srcformat: 'Y-m-d',
newformat: 'Y/m/d',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "Y/j/n",
LongDate: "Y. F hó d., l",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "a g:i",
LongTime: "a g:i:s",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "Y, F"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid Slovak Translation
* Milan Cibulka
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
$.jgrid = $.jgrid || {};
$.extend($.jgrid,{
defaults : {
recordtext: "Zobrazených {0} - {1} z {2} záznamov",
emptyrecords: "Neboli nájdené žiadne záznamy",
loadtext: "Načítám...",
pgtext : "Strana {0} z {1}"
},
search : {
caption: "Vyhľadávam...",
Find: "Hľadať",
Reset: "Reset",
odata : ['rovná sa', 'nerovná sa', 'menšie', 'menšie alebo rovnajúce sa','väčšie', 'väčšie alebo rovnajúce sa', 'začína s', 'nezačína s', 'je v', 'nie je v', 'končí s', 'nekončí s', 'obahuje', 'neobsahuje'],
groupOps: [ { op: "AND", text: "všetkých" }, { op: "OR", text: "niektorého z" } ],
matchText: " hľadať podla",
rulesText: " pravidiel"
},
edit : {
addCaption: "Pridať záznam",
editCaption: "Editácia záznamov",
bSubmit: "Uložiť",
bCancel: "Storno",
bClose: "Zavrieť",
saveData: "Údaje boli zmenené! Uložiť zmeny?",
bYes : "Ano",
bNo : "Nie",
bExit : "Zrušiť",
msg: {
required:"Pole je požadované",
number:"Prosím, vložte valídne číslo",
minValue:"hodnota musí býť väčšia ako alebo rovná ",
maxValue:"hodnota musí býť menšia ako alebo rovná ",
email: "nie je valídny e-mail",
integer: "Prosím, vložte celé číslo",
date: "Prosím, vložte valídny dátum",
url: "nie je platnou URL. Požadovaný prefix ('http://' alebo 'https://')",
nodefined : " nie je definovaný!",
novalue : " je vyžadovaná návratová hodnota!",
customarray : "Custom function mala vrátiť pole!",
customfcheck : "Custom function by mala byť prítomná v prípade custom checking!"
}
},
view : {
caption: "Zobraziť záznam",
bClose: "Zavrieť"
},
del : {
caption: "Zmazať",
msg: "Zmazať vybraný(é) záznam(y)?",
bSubmit: "Zmazať",
bCancel: "Storno"
},
nav : {
edittext: " ",
edittitle: "Editovať vybraný riadok",
addtext:" ",
addtitle: "Pridať nový riadek",
deltext: " ",
deltitle: "Zmazať vybraný záznam ",
searchtext: " ",
searchtitle: "Nájsť záznamy",
refreshtext: "",
refreshtitle: "Obnoviť tabuľku",
alertcap: "Varovanie",
alerttext: "Prosím, vyberte riadok",
viewtext: "",
viewtitle: "Zobraziť vybraný riadok"
},
col : {
caption: "Zobrazit/Skrýť stĺpce",
bSubmit: "Uložiť",
bCancel: "Storno"
},
errors : {
errcap : "Chyba",
nourl : "Nie je nastavená url",
norecords: "Žiadne záznamy k spracovaniu",
model : "Dĺžka colNames <> colModel!"
},
formatter : {
integer : {thousandsSeparator: " ", defaultValue: '0'},
number : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, defaultValue: '0.00'},
currency : {decimalSeparator:".", thousandsSeparator: " ", decimalPlaces: 2, prefix: "", suffix:"", defaultValue: '0.00'},
date : {
dayNames: [
"Ne", "Po", "Ut", "St", "Št", "Pi", "So",
"Nedela", "Pondelok", "Utorok", "Streda", "Štvrtok", "Piatek", "Sobota"
],
monthNames: [
"Jan", "Feb", "Mar", "Apr", "Máj", "Jún", "Júl", "Aug", "Sep", "Okt", "Nov", "Dec",
"Január", "Február", "Marec", "Apríl", "Máj", "Jún", "Júl", "August", "September", "Október", "November", "December"
],
AmPm : ["do","od","DO","OD"],
S: function (j) {return j < 11 || j > 13 ? ['st', 'nd', 'rd', 'th'][Math.min((j - 1) % 10, 3)] : 'th'},
srcformat: 'Y-m-d',
newformat: 'd/m/Y',
masks : {
ISO8601Long:"Y-m-d H:i:s",
ISO8601Short:"Y-m-d",
ShortDate: "n/j/Y",
LongDate: "l, F d, Y",
FullDateTime: "l, F d, Y g:i:s A",
MonthDay: "F d",
ShortTime: "g:i A",
LongTime: "g:i:s A",
SortableDateTime: "Y-m-d\\TH:i:s",
UniversalSortableDateTime: "Y-m-d H:i:sO",
YearMonth: "F, Y"
},
reformatAfterEdit : false
},
baseLinkUrl: '',
showAction: '',
target: '',
checkbox : {disabled:true},
idName : 'id'
}
});
})(jQuery);
| JavaScript |
/*
The below work is licensed under Creative Commons GNU LGPL License.
Original work:
License: http://creativecommons.org/licenses/LGPL/2.1/
Author: Stefan Goessner/2006
Web: http://goessner.net/
Modifications made:
Version: 0.9-p5
Description: Restructured code, JSLint validated (no strict whitespaces),
added handling of empty arrays, empty strings, and int/floats values.
Author: Michael Schøler/2008-01-29
Web: http://michael.hinnerup.net/blog/2008/01/26/converting-json-to-xml-and-xml-to-json/
Description: json2xml added support to convert functions as CDATA
so it will be easy to write characters that cause some problems when convert
Author: Tony Tomov
*/
/*global alert */
var xmlJsonClass = {
// Param "xml": Element or document DOM node.
// Param "tab": Tab or indent string for pretty output formatting omit or use empty string "" to supress.
// Returns: JSON string
xml2json: function(xml, tab) {
if (xml.nodeType === 9) {
// document node
xml = xml.documentElement;
}
var nws = this.removeWhite(xml);
var obj = this.toObj(nws);
var json = this.toJson(obj, xml.nodeName, "\t");
return "{\n" + tab + (tab ? json.replace(/\t/g, tab) : json.replace(/\t|\n/g, "")) + "\n}";
},
// Param "o": JavaScript object
// Param "tab": tab or indent string for pretty output formatting omit or use empty string "" to supress.
// Returns: XML string
json2xml: function(o, tab) {
var toXml = function(v, name, ind) {
var xml = "";
var i, n;
if (v instanceof Array) {
if (v.length === 0) {
xml += ind + "<"+name+">__EMPTY_ARRAY_</"+name+">\n";
}
else {
for (i = 0, n = v.length; i < n; i += 1) {
var sXml = ind + toXml(v[i], name, ind+"\t") + "\n";
xml += sXml;
}
}
}
else if (typeof(v) === "object") {
var hasChild = false;
xml += ind + "<" + name;
var m;
for (m in v) if (v.hasOwnProperty(m)) {
if (m.charAt(0) === "@") {
xml += " " + m.substr(1) + "=\"" + v[m].toString() + "\"";
}
else {
hasChild = true;
}
}
xml += hasChild ? ">" : "/>";
if (hasChild) {
for (m in v) if (v.hasOwnProperty(m)) {
if (m === "#text") {
xml += v[m];
}
else if (m === "#cdata") {
xml += "<![CDATA[" + v[m] + "]]>";
}
else if (m.charAt(0) !== "@") {
xml += toXml(v[m], m, ind+"\t");
}
}
xml += (xml.charAt(xml.length - 1) === "\n" ? ind : "") + "</" + name + ">";
}
}
else if (typeof(v) === "function") {
xml += ind + "<" + name + ">" + "<![CDATA[" + v + "]]>" + "</" + name + ">";
}
else {
if (v === undefined ) { v = ""; }
if (v.toString() === "\"\"" || v.toString().length === 0) {
xml += ind + "<" + name + ">__EMPTY_STRING_</" + name + ">";
}
else {
xml += ind + "<" + name + ">" + v.toString() + "</" + name + ">";
}
}
return xml;
};
var xml = "";
var m;
for (m in o) if (o.hasOwnProperty(m)) {
xml += toXml(o[m], m, "");
}
return tab ? xml.replace(/\t/g, tab) : xml.replace(/\t|\n/g, "");
},
// Internal methods
toObj: function(xml) {
var o = {};
var FuncTest = /function/i;
if (xml.nodeType === 1) {
// element node ..
if (xml.attributes.length) {
// element with attributes ..
var i;
for (i = 0; i < xml.attributes.length; i += 1) {
o["@" + xml.attributes[i].nodeName] = (xml.attributes[i].nodeValue || "").toString();
}
}
if (xml.firstChild) {
// element has child nodes ..
var textChild = 0, cdataChild = 0, hasElementChild = false;
var n;
for (n = xml.firstChild; n; n = n.nextSibling) {
if (n.nodeType === 1) {
hasElementChild = true;
}
else if (n.nodeType === 3 && n.nodeValue.match(/[^ \f\n\r\t\v]/)) {
// non-whitespace text
textChild += 1;
}
else if (n.nodeType === 4) {
// cdata section node
cdataChild += 1;
}
}
if (hasElementChild) {
if (textChild < 2 && cdataChild < 2) {
// structured element with evtl. a single text or/and cdata node ..
this.removeWhite(xml);
for (n = xml.firstChild; n; n = n.nextSibling) {
if (n.nodeType === 3) {
// text node
o["#text"] = this.escape(n.nodeValue);
}
else if (n.nodeType === 4) {
// cdata node
if (FuncTest.test(n.nodeValue)) {
o[n.nodeName] = [o[n.nodeName], n.nodeValue];
} else {
o["#cdata"] = this.escape(n.nodeValue);
}
}
else if (o[n.nodeName]) {
// multiple occurence of element ..
if (o[n.nodeName] instanceof Array) {
o[n.nodeName][o[n.nodeName].length] = this.toObj(n);
}
else {
o[n.nodeName] = [o[n.nodeName], this.toObj(n)];
}
}
else {
// first occurence of element ..
o[n.nodeName] = this.toObj(n);
}
}
}
else {
// mixed content
if (!xml.attributes.length) {
o = this.escape(this.innerXml(xml));
}
else {
o["#text"] = this.escape(this.innerXml(xml));
}
}
}
else if (textChild) {
// pure text
if (!xml.attributes.length) {
o = this.escape(this.innerXml(xml));
if (o === "__EMPTY_ARRAY_") {
o = "[]";
} else if (o === "__EMPTY_STRING_") {
o = "";
}
}
else {
o["#text"] = this.escape(this.innerXml(xml));
}
}
else if (cdataChild) {
// cdata
if (cdataChild > 1) {
o = this.escape(this.innerXml(xml));
}
else {
for (n = xml.firstChild; n; n = n.nextSibling) {
if(FuncTest.test(xml.firstChild.nodeValue)) {
o = xml.firstChild.nodeValue;
break;
} else {
o["#cdata"] = this.escape(n.nodeValue);
}
}
}
}
}
if (!xml.attributes.length && !xml.firstChild) {
o = null;
}
}
else if (xml.nodeType === 9) {
// document.node
o = this.toObj(xml.documentElement);
}
else {
alert("unhandled node type: " + xml.nodeType);
}
return o;
},
toJson: function(o, name, ind, wellform) {
if(wellform === undefined) wellform = true;
var json = name ? ("\"" + name + "\"") : "", tab = "\t", newline = "\n";
if(!wellform) {
tab= ""; newline= "";
}
if (o === "[]") {
json += (name ? ":[]" : "[]");
}
else if (o instanceof Array) {
var n, i, ar=[];
for (i = 0, n = o.length; i < n; i += 1) {
ar[i] = this.toJson(o[i], "", ind + tab, wellform);
}
json += (name ? ":[" : "[") + (ar.length > 1 ? (newline + ind + tab + ar.join(","+newline + ind + tab) + newline + ind) : ar.join("")) + "]";
}
else if (o === null) {
json += (name && ":") + "null";
}
else if (typeof(o) === "object") {
var arr = [], m;
for (m in o) {
if (o.hasOwnProperty(m)) {
arr[arr.length] = this.toJson(o[m], m, ind + tab, wellform);
}
}
json += (name ? ":{" : "{") + (arr.length > 1 ? (newline + ind + tab + arr.join(","+newline + ind + tab) + newline + ind) : arr.join("")) + "}";
}
else if (typeof(o) === "string") {
/*
var objRegExp = /(^-?\d+\.?\d*$)/;
var FuncTest = /function/i;
var os = o.toString();
if (objRegExp.test(os) || FuncTest.test(os) || os==="false" || os==="true") {
// int or float
json += (name && ":") + "\"" +os + "\"";
}
else {
*/
json += (name && ":") + "\"" + o.replace(/\\/g,'\\\\').replace(/\"/g,'\\"') + "\"";
//}
}
else {
json += (name && ":") + o.toString();
}
return json;
},
innerXml: function(node) {
var s = "";
if ("innerHTML" in node) {
s = node.innerHTML;
}
else {
var asXml = function(n) {
var s = "", i;
if (n.nodeType === 1) {
s += "<" + n.nodeName;
for (i = 0; i < n.attributes.length; i += 1) {
s += " " + n.attributes[i].nodeName + "=\"" + (n.attributes[i].nodeValue || "").toString() + "\"";
}
if (n.firstChild) {
s += ">";
for (var c = n.firstChild; c; c = c.nextSibling) {
s += asXml(c);
}
s += "</" + n.nodeName + ">";
}
else {
s += "/>";
}
}
else if (n.nodeType === 3) {
s += n.nodeValue;
}
else if (n.nodeType === 4) {
s += "<![CDATA[" + n.nodeValue + "]]>";
}
return s;
};
for (var c = node.firstChild; c; c = c.nextSibling) {
s += asXml(c);
}
}
return s;
},
escape: function(txt) {
return txt.replace(/[\\]/g, "\\\\").replace(/[\"]/g, '\\"').replace(/[\n]/g, '\\n').replace(/[\r]/g, '\\r');
},
removeWhite: function(e) {
e.normalize();
var n;
for (n = e.firstChild; n; ) {
if (n.nodeType === 3) {
// text node
if (!n.nodeValue.match(/[^ \f\n\r\t\v]/)) {
// pure whitespace text node
var nxt = n.nextSibling;
e.removeChild(n);
n = nxt;
}
else {
n = n.nextSibling;
}
}
else if (n.nodeType === 1) {
// element node
this.removeWhite(n);
n = n.nextSibling;
}
else {
// any other node
n = n.nextSibling;
}
}
return e;
}
}; | JavaScript |
/*jshint eqeqeq:false */
/*global jQuery */
(function($){
/*
**
* jqGrid extension for cellediting Grid Data
* Tony Tomov tony@trirand.com
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl-2.0.html
**/
/**
* all events and options here are aded anonynous and not in the base grid
* since the array is to big. Here is the order of execution.
* From this point we use jQuery isFunction
* formatCell
* beforeEditCell,
* onSelectCell (used only for noneditable cels)
* afterEditCell,
* beforeSaveCell, (called before validation of values if any)
* beforeSubmitCell (if cellsubmit remote (ajax))
* afterSubmitCell(if cellsubmit remote (ajax)),
* afterSaveCell,
* errorCell,
* serializeCellData - new
* Options
* cellsubmit (remote,clientArray) (added in grid options)
* cellurl
* ajaxCellOptions
* */
"use strict";
$.jgrid.extend({
editCell : function (iRow,iCol, ed){
return this.each(function (){
var $t = this, nm, tmp,cc, cm;
if (!$t.grid || $t.p.cellEdit !== true) {return;}
iCol = parseInt(iCol,10);
// select the row that can be used for other methods
$t.p.selrow = $t.rows[iRow].id;
if (!$t.p.knv) {$($t).jqGrid("GridNav");}
// check to see if we have already edited cell
if ($t.p.savedRow.length>0) {
// prevent second click on that field and enable selects
if (ed===true ) {
if(iRow == $t.p.iRow && iCol == $t.p.iCol){
return;
}
}
// save the cell
$($t).jqGrid("saveCell",$t.p.savedRow[0].id,$t.p.savedRow[0].ic);
} else {
window.setTimeout(function () { $("#"+$.jgrid.jqID($t.p.knv)).attr("tabindex","-1").focus();},0);
}
cm = $t.p.colModel[iCol];
nm = cm.name;
if (nm=='subgrid' || nm=='cb' || nm=='rn') {return;}
cc = $("td:eq("+iCol+")",$t.rows[iRow]);
if (cm.editable===true && ed===true && !cc.hasClass("not-editable-cell")) {
if(parseInt($t.p.iCol,10)>=0 && parseInt($t.p.iRow,10)>=0) {
$("td:eq("+$t.p.iCol+")",$t.rows[$t.p.iRow]).removeClass("edit-cell ui-state-highlight");
$($t.rows[$t.p.iRow]).removeClass("selected-row ui-state-hover");
}
$(cc).addClass("edit-cell ui-state-highlight");
$($t.rows[iRow]).addClass("selected-row ui-state-hover");
try {
tmp = $.unformat.call($t,cc,{rowId: $t.rows[iRow].id, colModel:cm},iCol);
} catch (_) {
tmp = ( cm.edittype && cm.edittype == 'textarea' ) ? $(cc).text() : $(cc).html();
}
if($t.p.autoencode) { tmp = $.jgrid.htmlDecode(tmp); }
if (!cm.edittype) {cm.edittype = "text";}
$t.p.savedRow.push({id:iRow,ic:iCol,name:nm,v:tmp});
if(tmp === " " || tmp === " " || (tmp.length===1 && tmp.charCodeAt(0)===160) ) {tmp='';}
if($.isFunction($t.p.formatCell)) {
var tmp2 = $t.p.formatCell.call($t, $t.rows[iRow].id,nm,tmp,iRow,iCol);
if(tmp2 !== undefined ) {tmp = tmp2;}
}
var opt = $.extend({}, cm.editoptions || {} ,{id:iRow+"_"+nm,name:nm});
var elc = $.jgrid.createEl.call($t,cm.edittype,opt,tmp,true,$.extend({},$.jgrid.ajaxOptions,$t.p.ajaxSelectOptions || {}));
$($t).triggerHandler("jqGridBeforeEditCell", [$t.rows[iRow].id, nm, tmp, iRow, iCol]);
if ($.isFunction($t.p.beforeEditCell)) {
$t.p.beforeEditCell.call($t, $t.rows[iRow].id,nm,tmp,iRow,iCol);
}
$(cc).html("").append(elc).attr("tabindex","0");
$.jgrid.bindEv( elc, opt, $t);
window.setTimeout(function () { $(elc).focus();},0);
$("input, select, textarea",cc).bind("keydown",function(e) {
if (e.keyCode === 27) {
if($("input.hasDatepicker",cc).length >0) {
if( $(".ui-datepicker").is(":hidden") ) { $($t).jqGrid("restoreCell",iRow,iCol); }
else { $("input.hasDatepicker",cc).datepicker('hide'); }
} else {
$($t).jqGrid("restoreCell",iRow,iCol);
}
} //ESC
if (e.keyCode === 13) {
$($t).jqGrid("saveCell",iRow,iCol);
// Prevent default action
return false;
} //Enter
if (e.keyCode === 9) {
if(!$t.grid.hDiv.loading ) {
if (e.shiftKey) {$($t).jqGrid("prevCell",iRow,iCol);} //Shift TAb
else {$($t).jqGrid("nextCell",iRow,iCol);} //Tab
} else {
return false;
}
}
e.stopPropagation();
});
$($t).triggerHandler("jqGridAfterEditCell", [$t.rows[iRow].id, nm, tmp, iRow, iCol]);
if ($.isFunction($t.p.afterEditCell)) {
$t.p.afterEditCell.call($t, $t.rows[iRow].id,nm,tmp,iRow,iCol);
}
} else {
if (parseInt($t.p.iCol,10)>=0 && parseInt($t.p.iRow,10)>=0) {
$("td:eq("+$t.p.iCol+")",$t.rows[$t.p.iRow]).removeClass("edit-cell ui-state-highlight");
$($t.rows[$t.p.iRow]).removeClass("selected-row ui-state-hover");
}
cc.addClass("edit-cell ui-state-highlight");
$($t.rows[iRow]).addClass("selected-row ui-state-hover");
tmp = cc.html().replace(/\ \;/ig,'');
$($t).triggerHandler("jqGridSelectCell", [$t.rows[iRow].id, nm, tmp, iRow, iCol]);
if ($.isFunction($t.p.onSelectCell)) {
$t.p.onSelectCell.call($t, $t.rows[iRow].id,nm,tmp,iRow,iCol);
}
}
$t.p.iCol = iCol; $t.p.iRow = iRow;
});
},
saveCell : function (iRow, iCol){
return this.each(function(){
var $t= this, fr;
if (!$t.grid || $t.p.cellEdit !== true) {return;}
if ( $t.p.savedRow.length >= 1) {fr = 0;} else {fr=null;}
if(fr !== null) {
var cc = $("td:eq("+iCol+")",$t.rows[iRow]),v,v2,
cm = $t.p.colModel[iCol], nm = cm.name, nmjq = $.jgrid.jqID(nm) ;
switch (cm.edittype) {
case "select":
if(!cm.editoptions.multiple) {
v = $("#"+iRow+"_"+nmjq+" option:selected",$t.rows[iRow]).val();
v2 = $("#"+iRow+"_"+nmjq+" option:selected",$t.rows[iRow]).text();
} else {
var sel = $("#"+iRow+"_"+nmjq,$t.rows[iRow]), selectedText = [];
v = $(sel).val();
if(v) { v.join(",");} else { v=""; }
$("option:selected",sel).each(
function(i,selected){
selectedText[i] = $(selected).text();
}
);
v2 = selectedText.join(",");
}
if(cm.formatter) { v2 = v; }
break;
case "checkbox":
var cbv = ["Yes","No"];
if(cm.editoptions){
cbv = cm.editoptions.value.split(":");
}
v = $("#"+iRow+"_"+nmjq,$t.rows[iRow]).is(":checked") ? cbv[0] : cbv[1];
v2=v;
break;
case "password":
case "text":
case "textarea":
case "button" :
v = $("#"+iRow+"_"+nmjq,$t.rows[iRow]).val();
v2=v;
break;
case 'custom' :
try {
if(cm.editoptions && $.isFunction(cm.editoptions.custom_value)) {
v = cm.editoptions.custom_value.call($t, $(".customelement",cc),'get');
if (v===undefined) { throw "e2";} else { v2=v; }
} else { throw "e1"; }
} catch (e) {
if (e=="e1") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.nodefined,$.jgrid.edit.bClose); }
if (e=="e2") { $.jgrid.info_dialog($.jgrid.errors.errcap,"function 'custom_value' "+$.jgrid.edit.msg.novalue,$.jgrid.edit.bClose); }
else {$.jgrid.info_dialog($.jgrid.errors.errcap,e.message,$.jgrid.edit.bClose); }
}
break;
}
// The common approach is if nothing changed do not do anything
if (v2 !== $t.p.savedRow[fr].v){
var vvv = $($t).triggerHandler("jqGridBeforeSaveCell", [$t.rows[iRow].id, nm, v, iRow, iCol]);
if (vvv) {v = vvv; v2=vvv;}
if ($.isFunction($t.p.beforeSaveCell)) {
var vv = $t.p.beforeSaveCell.call($t, $t.rows[iRow].id,nm, v, iRow,iCol);
if (vv) {v = vv; v2=vv;}
}
var cv = $.jgrid.checkValues(v,iCol,$t);
if(cv[0] === true) {
var addpost = $($t).triggerHandler("jqGridBeforeSubmitCell", [$t.rows[iRow].id, nm, v, iRow, iCol]) || {};
if ($.isFunction($t.p.beforeSubmitCell)) {
addpost = $t.p.beforeSubmitCell.call($t, $t.rows[iRow].id,nm, v, iRow,iCol);
if (!addpost) {addpost={};}
}
if( $("input.hasDatepicker",cc).length >0) { $("input.hasDatepicker",cc).datepicker('hide'); }
if ($t.p.cellsubmit == 'remote') {
if ($t.p.cellurl) {
var postdata = {};
if($t.p.autoencode) { v = $.jgrid.htmlEncode(v); }
postdata[nm] = v;
var idname,oper, opers;
opers = $t.p.prmNames;
idname = opers.id;
oper = opers.oper;
postdata[idname] = $.jgrid.stripPref($t.p.idPrefix, $t.rows[iRow].id);
postdata[oper] = opers.editoper;
postdata = $.extend(addpost,postdata);
$("#lui_"+$.jgrid.jqID($t.p.id)).show();
$t.grid.hDiv.loading = true;
$.ajax( $.extend( {
url: $t.p.cellurl,
data :$.isFunction($t.p.serializeCellData) ? $t.p.serializeCellData.call($t, postdata) : postdata,
type: "POST",
complete: function (result, stat) {
$("#lui_"+$t.p.id).hide();
$t.grid.hDiv.loading = false;
if (stat == 'success') {
var ret = $($t).triggerHandler("jqGridAfterSubmitCell", [$t, result, postdata.id, nm, v, iRow, iCol]) || [true, ''];
if (ret[0] === true && $.isFunction($t.p.afterSubmitCell)) {
ret = $t.p.afterSubmitCell.call($t, result,postdata.id,nm,v,iRow,iCol);
}
if(ret[0] === true){
$(cc).empty();
$($t).jqGrid("setCell",$t.rows[iRow].id, iCol, v2, false, false, true);
$(cc).addClass("dirty-cell");
$($t.rows[iRow]).addClass("edited");
$($t).triggerHandler("jqGridAfterSaveCell", [$t.rows[iRow].id, nm, v, iRow, iCol]);
if ($.isFunction($t.p.afterSaveCell)) {
$t.p.afterSaveCell.call($t, $t.rows[iRow].id,nm, v, iRow,iCol);
}
$t.p.savedRow.splice(0,1);
} else {
$.jgrid.info_dialog($.jgrid.errors.errcap,ret[1],$.jgrid.edit.bClose);
$($t).jqGrid("restoreCell",iRow,iCol);
}
}
},
error:function(res,stat,err) {
$("#lui_"+$.jgrid.jqID($t.p.id)).hide();
$t.grid.hDiv.loading = false;
$($t).triggerHandler("jqGridErrorCell", [res, stat, err]);
if ($.isFunction($t.p.errorCell)) {
$t.p.errorCell.call($t, res,stat,err);
$($t).jqGrid("restoreCell",iRow,iCol);
} else {
$.jgrid.info_dialog($.jgrid.errors.errcap,res.status+" : "+res.statusText+"<br/>"+stat,$.jgrid.edit.bClose);
$($t).jqGrid("restoreCell",iRow,iCol);
}
}
}, $.jgrid.ajaxOptions, $t.p.ajaxCellOptions || {}));
} else {
try {
$.jgrid.info_dialog($.jgrid.errors.errcap,$.jgrid.errors.nourl,$.jgrid.edit.bClose);
$($t).jqGrid("restoreCell",iRow,iCol);
} catch (e) {}
}
}
if ($t.p.cellsubmit == 'clientArray') {
$(cc).empty();
$($t).jqGrid("setCell",$t.rows[iRow].id,iCol, v2, false, false, true);
$(cc).addClass("dirty-cell");
$($t.rows[iRow]).addClass("edited");
$($t).triggerHandler("jqGridAfterSaveCell", [$t.rows[iRow].id, nm, v, iRow, iCol]);
if ($.isFunction($t.p.afterSaveCell)) {
$t.p.afterSaveCell.call($t, $t.rows[iRow].id,nm, v, iRow,iCol);
}
$t.p.savedRow.splice(0,1);
}
} else {
try {
window.setTimeout(function(){$.jgrid.info_dialog($.jgrid.errors.errcap,v+" "+cv[1],$.jgrid.edit.bClose);},100);
$($t).jqGrid("restoreCell",iRow,iCol);
} catch (e) {}
}
} else {
$($t).jqGrid("restoreCell",iRow,iCol);
}
}
if ($.browser.opera) {
$("#"+$.jgrid.jqID($t.p.knv)).attr("tabindex","-1").focus();
} else {
window.setTimeout(function () { $("#"+$.jgrid.jqID($t.p.knv)).attr("tabindex","-1").focus();},0);
}
});
},
restoreCell : function(iRow, iCol) {
return this.each(function(){
var $t= this, fr;
if (!$t.grid || $t.p.cellEdit !== true ) {return;}
if ( $t.p.savedRow.length >= 1) {fr = 0;} else {fr=null;}
if(fr !== null) {
var cc = $("td:eq("+iCol+")",$t.rows[iRow]);
// datepicker fix
if($.isFunction($.fn.datepicker)) {
try {
$("input.hasDatepicker",cc).datepicker('hide');
} catch (e) {}
}
$(cc).empty().attr("tabindex","-1");
$($t).jqGrid("setCell",$t.rows[iRow].id, iCol, $t.p.savedRow[fr].v, false, false, true);
$($t).triggerHandler("jqGridAfterRestoreCell", [$t.rows[iRow].id, $t.p.savedRow[fr].v, iRow, iCol]);
if ($.isFunction($t.p.afterRestoreCell)) {
$t.p.afterRestoreCell.call($t, $t.rows[iRow].id, $t.p.savedRow[fr].v, iRow, iCol);
}
$t.p.savedRow.splice(0,1);
}
window.setTimeout(function () { $("#"+$t.p.knv).attr("tabindex","-1").focus();},0);
});
},
nextCell : function (iRow,iCol) {
return this.each(function (){
var $t = this, nCol=false, i;
if (!$t.grid || $t.p.cellEdit !== true) {return;}
// try to find next editable cell
for (i=iCol+1; i<$t.p.colModel.length; i++) {
if ( $t.p.colModel[i].editable ===true) {
nCol = i; break;
}
}
if(nCol !== false) {
$($t).jqGrid("editCell",iRow,nCol,true);
} else {
if ($t.p.savedRow.length >0) {
$($t).jqGrid("saveCell",iRow,iCol);
}
}
});
},
prevCell : function (iRow,iCol) {
return this.each(function (){
var $t = this, nCol=false, i;
if (!$t.grid || $t.p.cellEdit !== true) {return;}
// try to find next editable cell
for (i=iCol-1; i>=0; i--) {
if ( $t.p.colModel[i].editable ===true) {
nCol = i; break;
}
}
if(nCol !== false) {
$($t).jqGrid("editCell",iRow,nCol,true);
} else {
if ($t.p.savedRow.length >0) {
$($t).jqGrid("saveCell",iRow,iCol);
}
}
});
},
GridNav : function() {
return this.each(function () {
var $t = this;
if (!$t.grid || $t.p.cellEdit !== true ) {return;}
// trick to process keydown on non input elements
$t.p.knv = $t.p.id + "_kn";
var selection = $("<div style='position:fixed;top:-1000000px;width:1px;height:1px;' tabindex='0'><div tabindex='-1' style='width:1px;height:1px;' id='"+$t.p.knv+"'></div></div>"),
i, kdir;
function scrollGrid(iR, iC, tp){
if (tp.substr(0,1)=='v') {
var ch = $($t.grid.bDiv)[0].clientHeight,
st = $($t.grid.bDiv)[0].scrollTop,
nROT = $t.rows[iR].offsetTop+$t.rows[iR].clientHeight,
pROT = $t.rows[iR].offsetTop;
if(tp == 'vd') {
if(nROT >= ch) {
$($t.grid.bDiv)[0].scrollTop = $($t.grid.bDiv)[0].scrollTop + $t.rows[iR].clientHeight;
}
}
if(tp == 'vu'){
if (pROT < st ) {
$($t.grid.bDiv)[0].scrollTop = $($t.grid.bDiv)[0].scrollTop - $t.rows[iR].clientHeight;
}
}
}
if(tp=='h') {
var cw = $($t.grid.bDiv)[0].clientWidth,
sl = $($t.grid.bDiv)[0].scrollLeft,
nCOL = $t.rows[iR].cells[iC].offsetLeft+$t.rows[iR].cells[iC].clientWidth,
pCOL = $t.rows[iR].cells[iC].offsetLeft;
if(nCOL >= cw+parseInt(sl,10)) {
$($t.grid.bDiv)[0].scrollLeft = $($t.grid.bDiv)[0].scrollLeft + $t.rows[iR].cells[iC].clientWidth;
} else if (pCOL < sl) {
$($t.grid.bDiv)[0].scrollLeft = $($t.grid.bDiv)[0].scrollLeft - $t.rows[iR].cells[iC].clientWidth;
}
}
}
function findNextVisible(iC,act){
var ind, i;
if(act == 'lft') {
ind = iC+1;
for (i=iC;i>=0;i--){
if ($t.p.colModel[i].hidden !== true) {
ind = i;
break;
}
}
}
if(act == 'rgt') {
ind = iC-1;
for (i=iC; i<$t.p.colModel.length;i++){
if ($t.p.colModel[i].hidden !== true) {
ind = i;
break;
}
}
}
return ind;
}
$(selection).insertBefore($t.grid.cDiv);
$("#"+$t.p.knv)
.focus()
.keydown(function (e){
kdir = e.keyCode;
if($t.p.direction == "rtl") {
if(kdir===37) { kdir = 39;}
else if (kdir===39) { kdir = 37; }
}
switch (kdir) {
case 38:
if ($t.p.iRow-1 >0 ) {
scrollGrid($t.p.iRow-1,$t.p.iCol,'vu');
$($t).jqGrid("editCell",$t.p.iRow-1,$t.p.iCol,false);
}
break;
case 40 :
if ($t.p.iRow+1 <= $t.rows.length-1) {
scrollGrid($t.p.iRow+1,$t.p.iCol,'vd');
$($t).jqGrid("editCell",$t.p.iRow+1,$t.p.iCol,false);
}
break;
case 37 :
if ($t.p.iCol -1 >= 0) {
i = findNextVisible($t.p.iCol-1,'lft');
scrollGrid($t.p.iRow, i,'h');
$($t).jqGrid("editCell",$t.p.iRow, i,false);
}
break;
case 39 :
if ($t.p.iCol +1 <= $t.p.colModel.length-1) {
i = findNextVisible($t.p.iCol+1,'rgt');
scrollGrid($t.p.iRow,i,'h');
$($t).jqGrid("editCell",$t.p.iRow,i,false);
}
break;
case 13:
if (parseInt($t.p.iCol,10)>=0 && parseInt($t.p.iRow,10)>=0) {
$($t).jqGrid("editCell",$t.p.iRow,$t.p.iCol,true);
}
break;
default :
return true;
}
return false;
});
});
},
getChangedCells : function (mthd) {
var ret=[];
if (!mthd) {mthd='all';}
this.each(function(){
var $t= this,nm;
if (!$t.grid || $t.p.cellEdit !== true ) {return;}
$($t.rows).each(function(j){
var res = {};
if ($(this).hasClass("edited")) {
$('td',this).each( function(i) {
nm = $t.p.colModel[i].name;
if ( nm !== 'cb' && nm !== 'subgrid') {
if (mthd=='dirty') {
if ($(this).hasClass('dirty-cell')) {
try {
res[nm] = $.unformat.call($t,this,{rowId:$t.rows[j].id, colModel:$t.p.colModel[i]},i);
} catch (e){
res[nm] = $.jgrid.htmlDecode($(this).html());
}
}
} else {
try {
res[nm] = $.unformat.call($t,this,{rowId:$t.rows[j].id,colModel:$t.p.colModel[i]},i);
} catch (e) {
res[nm] = $.jgrid.htmlDecode($(this).html());
}
}
}
});
res.id = this.id;
ret.push(res);
}
});
});
return ret;
}
/// end cell editing
});
})(jQuery);
| JavaScript |
//This file should be used if you want to debug and develop
function jqGridInclude()
{
var pathtojsfiles = "js/"; // need to be ajusted
// set include to false if you do not want some modules to be included
var modules = [
{ include: true, incfile:'i18n/grid.locale-en.js'}, // jqGrid translation
{ include: true, incfile:'grid.base.js'}, // jqGrid base
{ include: true, incfile:'grid.common.js'}, // jqGrid common for editing
{ include: true, incfile:'grid.formedit.js'}, // jqGrid Form editing
{ include: true, incfile:'grid.inlinedit.js'}, // jqGrid inline editing
{ include: true, incfile:'grid.celledit.js'}, // jqGrid cell editing
{ include: true, incfile:'grid.subgrid.js'}, //jqGrid subgrid
{ include: true, incfile:'grid.treegrid.js'}, //jqGrid treegrid
{ include: true, incfile:'grid.grouping.js'}, //jqGrid grouping
{ include: true, incfile:'grid.custom.js'}, //jqGrid custom
{ include: true, incfile:'grid.tbltogrid.js'}, //jqGrid table to grid
{ include: true, incfile:'grid.import.js'}, //jqGrid import
{ include: true, incfile:'jquery.fmatter.js'}, //jqGrid formater
{ include: true, incfile:'JsonXml.js'}, //xmljson utils
{ include: true, incfile:'grid.jqueryui.js'}, //jQuery UI utils
{ include: true, incfile:'grid.filter.js'} // filter Plugin
];
var filename;
for(var i=0;i<modules.length; i++)
{
if(modules[i].include === true) {
filename = pathtojsfiles+modules[i].incfile;
if(jQuery.browser.safari) {
jQuery.ajax({url:filename,dataType:'script', async:false, cache: true});
} else {
if (jQuery.browser.msie) {
document.write('<script charset="utf-8" type="text/javascript" src="'+filename+'"></script>');
} else {
IncludeJavaScript(filename);
}
}
}
}
function IncludeJavaScript(jsFile)
{
var oHead = document.getElementsByTagName('head')[0];
var oScript = document.createElement('script');
oScript.setAttribute('type', 'text/javascript');
oScript.setAttribute('language', 'javascript');
oScript.setAttribute('src', jsFile);
oHead.appendChild(oScript);
}
}
jqGridInclude();
| JavaScript |
/**
* jqGrid extension - Tree Grid
* Tony Tomov tony@trirand.com
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
**/
/*jshint eqeqeq:false */
/*global jQuery */
(function($) {
"use strict";
$.jgrid.extend({
setTreeNode : function(i, len){
return this.each(function(){
var $t = this;
if( !$t.grid || !$t.p.treeGrid ) {return;}
var expCol = $t.p.expColInd,
expanded = $t.p.treeReader.expanded_field,
isLeaf = $t.p.treeReader.leaf_field,
level = $t.p.treeReader.level_field,
icon = $t.p.treeReader.icon_field,
loaded = $t.p.treeReader.loaded, lft, rgt, curLevel, ident,lftpos, twrap,
ldat, lf;
while(i<len) {
var ind = $t.rows[i].id, dind = $t.p._index[ind], expan;
ldat = $t.p.data[dind];
//$t.rows[i].level = ldat[level];
if($t.p.treeGridModel == 'nested') {
if(!ldat[isLeaf]) {
lft = parseInt(ldat[$t.p.treeReader.left_field],10);
rgt = parseInt(ldat[$t.p.treeReader.right_field],10);
// NS Model
ldat[isLeaf] = (rgt === lft+1) ? 'true' : 'false';
$t.rows[i].cells[$t.p._treeleafpos].innerHTML = ldat[isLeaf];
}
}
//else {
//row.parent_id = rd[$t.p.treeReader.parent_id_field];
//}
curLevel = parseInt(ldat[level],10);
if($t.p.tree_root_level === 0) {
ident = curLevel+1;
lftpos = curLevel;
} else {
ident = curLevel;
lftpos = curLevel -1;
}
twrap = "<div class='tree-wrap tree-wrap-"+$t.p.direction+"' style='width:"+(ident*18)+"px;'>";
twrap += "<div style='"+($t.p.direction=="rtl" ? "right:" : "left:")+(lftpos*18)+"px;' class='ui-icon ";
if(ldat[loaded] !== undefined) {
if(ldat[loaded]=="true" || ldat[loaded]===true) {
ldat[loaded] = true;
} else {
ldat[loaded] = false;
}
}
if(ldat[isLeaf] == "true" || ldat[isLeaf] === true) {
twrap += ((ldat[icon] !== undefined && ldat[icon] !== "") ? ldat[icon] : $t.p.treeIcons.leaf)+" tree-leaf treeclick";
ldat[isLeaf] = true;
lf="leaf";
} else {
ldat[isLeaf] = false;
lf="";
}
ldat[expanded] = ((ldat[expanded] == "true" || ldat[expanded] === true) ? true : false) && (ldat[loaded] || ldat[loaded] === undefined);
if(ldat[expanded] === false) {
twrap += ((ldat[isLeaf] === true) ? "'" : $t.p.treeIcons.plus+" tree-plus treeclick'");
} else {
twrap += ((ldat[isLeaf] === true) ? "'" : $t.p.treeIcons.minus+" tree-minus treeclick'");
}
twrap += "></div></div>";
$($t.rows[i].cells[expCol]).wrapInner("<span class='cell-wrapper"+lf+"'></span>").prepend(twrap);
if(curLevel !== parseInt($t.p.tree_root_level,10)) {
var pn = $($t).jqGrid('getNodeParent',ldat);
expan = pn && pn.hasOwnProperty(expanded) ? pn[expanded] : true;
if( !expan ){
$($t.rows[i]).css("display","none");
}
}
$($t.rows[i].cells[expCol])
.find("div.treeclick")
.bind("click",function(e){
var target = e.target || e.srcElement,
ind2 =$(target,$t.rows).closest("tr.jqgrow")[0].id,
pos = $t.p._index[ind2];
if(!$t.p.data[pos][isLeaf]){
if($t.p.data[pos][expanded]){
$($t).jqGrid("collapseRow",$t.p.data[pos]);
$($t).jqGrid("collapseNode",$t.p.data[pos]);
} else {
$($t).jqGrid("expandRow",$t.p.data[pos]);
$($t).jqGrid("expandNode",$t.p.data[pos]);
}
}
return false;
});
if($t.p.ExpandColClick === true) {
$($t.rows[i].cells[expCol])
.find("span.cell-wrapper")
.css("cursor","pointer")
.bind("click",function(e) {
var target = e.target || e.srcElement,
ind2 =$(target,$t.rows).closest("tr.jqgrow")[0].id,
pos = $t.p._index[ind2];
if(!$t.p.data[pos][isLeaf]){
if($t.p.data[pos][expanded]){
$($t).jqGrid("collapseRow",$t.p.data[pos]);
$($t).jqGrid("collapseNode",$t.p.data[pos]);
} else {
$($t).jqGrid("expandRow",$t.p.data[pos]);
$($t).jqGrid("expandNode",$t.p.data[pos]);
}
}
$($t).jqGrid("setSelection",ind2);
return false;
});
}
i++;
}
});
},
setTreeGrid : function() {
return this.each(function (){
var $t = this, i=0, pico, ecol = false, nm, key, tkey, dupcols=[];
if(!$t.p.treeGrid) {return;}
if(!$t.p.treedatatype ) {$.extend($t.p,{treedatatype: $t.p.datatype});}
$t.p.subGrid = false;$t.p.altRows =false;
$t.p.pgbuttons = false;$t.p.pginput = false;
$t.p.gridview = true;
if($t.p.rowTotal === null ) { $t.p.rowNum = 10000; }
$t.p.multiselect = false;$t.p.rowList = [];
$t.p.expColInd = 0;
pico = 'ui-icon-triangle-1-' + ($t.p.direction=="rtl" ? 'w' : 'e');
$t.p.treeIcons = $.extend({plus:pico,minus:'ui-icon-triangle-1-s',leaf:'ui-icon-radio-off'},$t.p.treeIcons || {});
if($t.p.treeGridModel == 'nested') {
$t.p.treeReader = $.extend({
level_field: "level",
left_field:"lft",
right_field: "rgt",
leaf_field: "isLeaf",
expanded_field: "expanded",
loaded: "loaded",
icon_field: "icon"
},$t.p.treeReader);
} else if($t.p.treeGridModel == 'adjacency') {
$t.p.treeReader = $.extend({
level_field: "level",
parent_id_field: "parent",
leaf_field: "isLeaf",
expanded_field: "expanded",
loaded: "loaded",
icon_field: "icon"
},$t.p.treeReader );
}
for ( key in $t.p.colModel){
if($t.p.colModel.hasOwnProperty(key)) {
nm = $t.p.colModel[key].name;
if( nm == $t.p.ExpandColumn && !ecol ) {
ecol = true;
$t.p.expColInd = i;
}
i++;
//
for(tkey in $t.p.treeReader) {
if($t.p.treeReader.hasOwnProperty(tkey) && $t.p.treeReader[tkey] == nm) {
dupcols.push(nm);
}
}
}
}
$.each($t.p.treeReader,function(j,n){
if(n && $.inArray(n, dupcols) === -1){
if(j==='leaf_field') { $t.p._treeleafpos= i; }
i++;
$t.p.colNames.push(n);
$t.p.colModel.push({name:n,width:1,hidden:true,sortable:false,resizable:false,hidedlg:true,editable:true,search:false});
}
});
});
},
expandRow: function (record){
this.each(function(){
var $t = this;
if(!$t.grid || !$t.p.treeGrid) {return;}
var childern = $($t).jqGrid("getNodeChildren",record),
//if ($($t).jqGrid("isVisibleNode",record)) {
expanded = $t.p.treeReader.expanded_field,
rows = $t.rows;
$(childern).each(function(){
var id = $.jgrid.getAccessor(this,$t.p.localReader.id);
$(rows.namedItem(id)).css("display","");
if(this[expanded]) {
$($t).jqGrid("expandRow",this);
}
});
//}
});
},
collapseRow : function (record) {
this.each(function(){
var $t = this;
if(!$t.grid || !$t.p.treeGrid) {return;}
var childern = $($t).jqGrid("getNodeChildren",record),
expanded = $t.p.treeReader.expanded_field,
rows = $t.rows;
$(childern).each(function(){
var id = $.jgrid.getAccessor(this,$t.p.localReader.id);
$(rows.namedItem(id)).css("display","none");
if(this[expanded]){
$($t).jqGrid("collapseRow",this);
}
});
});
},
// NS ,adjacency models
getRootNodes : function() {
var result = [];
this.each(function(){
var $t = this;
if(!$t.grid || !$t.p.treeGrid) {return;}
switch ($t.p.treeGridModel) {
case 'nested' :
var level = $t.p.treeReader.level_field;
$($t.p.data).each(function(){
if(parseInt(this[level],10) === parseInt($t.p.tree_root_level,10)) {
result.push(this);
}
});
break;
case 'adjacency' :
var parent_id = $t.p.treeReader.parent_id_field;
$($t.p.data).each(function(){
if(this[parent_id] === null || String(this[parent_id]).toLowerCase() == "null") {
result.push(this);
}
});
break;
}
});
return result;
},
getNodeDepth : function(rc) {
var ret = null;
this.each(function(){
if(!this.grid || !this.p.treeGrid) {return;}
var $t = this;
switch ($t.p.treeGridModel) {
case 'nested' :
var level = $t.p.treeReader.level_field;
ret = parseInt(rc[level],10) - parseInt($t.p.tree_root_level,10);
break;
case 'adjacency' :
ret = $($t).jqGrid("getNodeAncestors",rc).length;
break;
}
});
return ret;
},
getNodeParent : function(rc) {
var result = null;
this.each(function(){
var $t = this;
if(!$t.grid || !$t.p.treeGrid) {return;}
switch ($t.p.treeGridModel) {
case 'nested' :
var lftc = $t.p.treeReader.left_field,
rgtc = $t.p.treeReader.right_field,
levelc = $t.p.treeReader.level_field,
lft = parseInt(rc[lftc],10), rgt = parseInt(rc[rgtc],10), level = parseInt(rc[levelc],10);
$(this.p.data).each(function(){
if(parseInt(this[levelc],10) === level-1 && parseInt(this[lftc],10) < lft && parseInt(this[rgtc],10) > rgt) {
result = this;
return false;
}
});
break;
case 'adjacency' :
var parent_id = $t.p.treeReader.parent_id_field,
dtid = $t.p.localReader.id;
$(this.p.data).each(function(){
if(this[dtid] == rc[parent_id] ) {
result = this;
return false;
}
});
break;
}
});
return result;
},
getNodeChildren : function(rc) {
var result = [];
this.each(function(){
var $t = this;
if(!$t.grid || !$t.p.treeGrid) {return;}
switch ($t.p.treeGridModel) {
case 'nested' :
var lftc = $t.p.treeReader.left_field,
rgtc = $t.p.treeReader.right_field,
levelc = $t.p.treeReader.level_field,
lft = parseInt(rc[lftc],10), rgt = parseInt(rc[rgtc],10), level = parseInt(rc[levelc],10);
$(this.p.data).each(function(){
if(parseInt(this[levelc],10) === level+1 && parseInt(this[lftc],10) > lft && parseInt(this[rgtc],10) < rgt) {
result.push(this);
}
});
break;
case 'adjacency' :
var parent_id = $t.p.treeReader.parent_id_field,
dtid = $t.p.localReader.id;
$(this.p.data).each(function(){
if(this[parent_id] == rc[dtid]) {
result.push(this);
}
});
break;
}
});
return result;
},
getFullTreeNode : function(rc) {
var result = [];
this.each(function(){
var $t = this, len;
if(!$t.grid || !$t.p.treeGrid) {return;}
switch ($t.p.treeGridModel) {
case 'nested' :
var lftc = $t.p.treeReader.left_field,
rgtc = $t.p.treeReader.right_field,
levelc = $t.p.treeReader.level_field,
lft = parseInt(rc[lftc],10), rgt = parseInt(rc[rgtc],10), level = parseInt(rc[levelc],10);
$(this.p.data).each(function(){
if(parseInt(this[levelc],10) >= level && parseInt(this[lftc],10) >= lft && parseInt(this[lftc],10) <= rgt) {
result.push(this);
}
});
break;
case 'adjacency' :
if(rc) {
result.push(rc);
var parent_id = $t.p.treeReader.parent_id_field,
dtid = $t.p.localReader.id;
$(this.p.data).each(function(i){
len = result.length;
for (i = 0; i < len; i++) {
if (result[i][dtid] == this[parent_id]) {
result.push(this);
break;
}
}
});
}
break;
}
});
return result;
},
// End NS, adjacency Model
getNodeAncestors : function(rc) {
var ancestors = [];
this.each(function(){
if(!this.grid || !this.p.treeGrid) {return;}
var parent = $(this).jqGrid("getNodeParent",rc);
while (parent) {
ancestors.push(parent);
parent = $(this).jqGrid("getNodeParent",parent);
}
});
return ancestors;
},
isVisibleNode : function(rc) {
var result = true;
this.each(function(){
var $t = this;
if(!$t.grid || !$t.p.treeGrid) {return;}
var ancestors = $($t).jqGrid("getNodeAncestors",rc),
expanded = $t.p.treeReader.expanded_field;
$(ancestors).each(function(){
result = result && this[expanded];
if(!result) {return false;}
});
});
return result;
},
isNodeLoaded : function(rc) {
var result;
this.each(function(){
var $t = this;
if(!$t.grid || !$t.p.treeGrid) {return;}
var isLeaf = $t.p.treeReader.leaf_field;
if(rc !== undefined ) {
if(rc.loaded !== undefined) {
result = rc.loaded;
} else if( rc[isLeaf] || $($t).jqGrid("getNodeChildren",rc).length > 0){
result = true;
} else {
result = false;
}
} else {
result = false;
}
});
return result;
},
expandNode : function(rc) {
return this.each(function(){
if(!this.grid || !this.p.treeGrid) {return;}
var expanded = this.p.treeReader.expanded_field,
parent = this.p.treeReader.parent_id_field,
loaded = this.p.treeReader.loaded,
level = this.p.treeReader.level_field,
lft = this.p.treeReader.left_field,
rgt = this.p.treeReader.right_field;
if(!rc[expanded]) {
var id = $.jgrid.getAccessor(rc,this.p.localReader.id);
var rc1 = $("#"+$.jgrid.jqID(id),this.grid.bDiv)[0];
var position = this.p._index[id];
if( $(this).jqGrid("isNodeLoaded",this.p.data[position]) ) {
rc[expanded] = true;
$("div.treeclick",rc1).removeClass(this.p.treeIcons.plus+" tree-plus").addClass(this.p.treeIcons.minus+" tree-minus");
} else if (!this.grid.hDiv.loading) {
rc[expanded] = true;
$("div.treeclick",rc1).removeClass(this.p.treeIcons.plus+" tree-plus").addClass(this.p.treeIcons.minus+" tree-minus");
this.p.treeANode = rc1.rowIndex;
this.p.datatype = this.p.treedatatype;
if(this.p.treeGridModel == 'nested') {
$(this).jqGrid("setGridParam",{postData:{nodeid:id,n_left:rc[lft],n_right:rc[rgt],n_level:rc[level]}});
} else {
$(this).jqGrid("setGridParam",{postData:{nodeid:id,parentid:rc[parent],n_level:rc[level]}} );
}
$(this).trigger("reloadGrid");
rc[loaded] = true;
if(this.p.treeGridModel == 'nested') {
$(this).jqGrid("setGridParam",{postData:{nodeid:'',n_left:'',n_right:'',n_level:''}});
} else {
$(this).jqGrid("setGridParam",{postData:{nodeid:'',parentid:'',n_level:''}});
}
}
}
});
},
collapseNode : function(rc) {
return this.each(function(){
if(!this.grid || !this.p.treeGrid) {return;}
var expanded = this.p.treeReader.expanded_field;
if(rc[expanded]) {
rc[expanded] = false;
var id = $.jgrid.getAccessor(rc,this.p.localReader.id);
var rc1 = $("#"+$.jgrid.jqID(id),this.grid.bDiv)[0];
$("div.treeclick",rc1).removeClass(this.p.treeIcons.minus+" tree-minus").addClass(this.p.treeIcons.plus+" tree-plus");
}
});
},
SortTree : function( sortname, newDir, st, datefmt) {
return this.each(function(){
if(!this.grid || !this.p.treeGrid) {return;}
var i, len,
rec, records = [], $t = this, query, roots,
rt = $(this).jqGrid("getRootNodes");
// Sorting roots
query = $.jgrid.from(rt);
query.orderBy(sortname,newDir,st, datefmt);
roots = query.select();
// Sorting children
for (i = 0, len = roots.length; i < len; i++) {
rec = roots[i];
records.push(rec);
$(this).jqGrid("collectChildrenSortTree",records, rec, sortname, newDir,st, datefmt);
}
$.each(records, function(index) {
var id = $.jgrid.getAccessor(this,$t.p.localReader.id);
$('#'+$.jgrid.jqID($t.p.id)+ ' tbody tr:eq('+index+')').after($('tr#'+$.jgrid.jqID(id),$t.grid.bDiv));
});
query = null;roots=null;records=null;
});
},
collectChildrenSortTree : function(records, rec, sortname, newDir,st, datefmt) {
return this.each(function(){
if(!this.grid || !this.p.treeGrid) {return;}
var i, len,
child, ch, query, children;
ch = $(this).jqGrid("getNodeChildren",rec);
query = $.jgrid.from(ch);
query.orderBy(sortname, newDir, st, datefmt);
children = query.select();
for (i = 0, len = children.length; i < len; i++) {
child = children[i];
records.push(child);
$(this).jqGrid("collectChildrenSortTree",records, child, sortname, newDir, st, datefmt);
}
});
},
// experimental
setTreeRow : function(rowid, data) {
var success=false;
this.each(function(){
var t = this;
if(!t.grid || !t.p.treeGrid) {return;}
success = $(t).jqGrid("setRowData",rowid,data);
});
return success;
},
delTreeNode : function (rowid) {
return this.each(function () {
var $t = this, rid = $t.p.localReader.id, i,
left = $t.p.treeReader.left_field,
right = $t.p.treeReader.right_field, myright, width, res, key;
if(!$t.grid || !$t.p.treeGrid) {return;}
var rc = $t.p._index[rowid];
if (rc !== undefined) {
// nested
myright = parseInt($t.p.data[rc][right],10);
width = myright - parseInt($t.p.data[rc][left],10) + 1;
var dr = $($t).jqGrid("getFullTreeNode",$t.p.data[rc]);
if(dr.length>0){
for (i=0;i<dr.length;i++){
$($t).jqGrid("delRowData",dr[i][rid]);
}
}
if( $t.p.treeGridModel === "nested") {
// ToDo - update grid data
res = $.jgrid.from($t.p.data)
.greater(left,myright,{stype:'integer'})
.select();
if(res.length) {
for( key in res) {
if(res.hasOwnProperty(key)) {
res[key][left] = parseInt(res[key][left],10) - width ;
}
}
}
res = $.jgrid.from($t.p.data)
.greater(right,myright,{stype:'integer'})
.select();
if(res.length) {
for( key in res) {
if(res.hasOwnProperty(key)) {
res[key][right] = parseInt(res[key][right],10) - width ;
}
}
}
}
}
});
},
addChildNode : function( nodeid, parentid, data, expandData ) {
//return this.each(function(){
var $t = this[0];
if(data) {
// we suppose tha the id is autoincremet and
var expanded = $t.p.treeReader.expanded_field,
isLeaf = $t.p.treeReader.leaf_field,
level = $t.p.treeReader.level_field,
//icon = $t.p.treeReader.icon_field,
parent = $t.p.treeReader.parent_id_field,
left = $t.p.treeReader.left_field,
right = $t.p.treeReader.right_field,
loaded = $t.p.treeReader.loaded,
method, parentindex, parentdata, parentlevel, i, len, max=0, rowind = parentid, leaf, maxright;
if(expandData===undefined) {expandData = false;}
if ( nodeid === undefined || nodeid === null ) {
i = $t.p.data.length-1;
if( i>= 0 ) {
while(i>=0){max = Math.max(max, parseInt($t.p.data[i][$t.p.localReader.id],10)); i--;}
}
nodeid = max+1;
}
var prow = $($t).jqGrid('getInd', parentid);
leaf = false;
// if not a parent we assume root
if ( parentid === undefined || parentid === null || parentid==="") {
parentid = null;
rowind = null;
method = 'last';
parentlevel = $t.p.tree_root_level;
i = $t.p.data.length+1;
} else {
method = 'after';
parentindex = $t.p._index[parentid];
parentdata = $t.p.data[parentindex];
parentid = parentdata[$t.p.localReader.id];
parentlevel = parseInt(parentdata[level],10)+1;
var childs = $($t).jqGrid('getFullTreeNode', parentdata);
// if there are child nodes get the last index of it
if(childs.length) {
i = childs[childs.length-1][$t.p.localReader.id];
rowind = i;
i = $($t).jqGrid('getInd',rowind)+1;
} else {
i = $($t).jqGrid('getInd', parentid)+1;
}
// if the node is leaf
if(parentdata[isLeaf]) {
leaf = true;
parentdata[expanded] = true;
//var prow = $($t).jqGrid('getInd', parentid);
$($t.rows[prow])
.find("span.cell-wrapperleaf").removeClass("cell-wrapperleaf").addClass("cell-wrapper")
.end()
.find("div.tree-leaf").removeClass($t.p.treeIcons.leaf+" tree-leaf").addClass($t.p.treeIcons.minus+" tree-minus");
$t.p.data[parentindex][isLeaf] = false;
parentdata[loaded] = true;
}
}
len = i+1;
if( data[expanded]===undefined) {data[expanded]= false;}
if( data[loaded]===undefined ) { data[loaded] = false;}
data[level] = parentlevel;
if( data[isLeaf]===undefined) {data[isLeaf]= true;}
if( $t.p.treeGridModel === "adjacency") {
data[parent] = parentid;
}
if( $t.p.treeGridModel === "nested") {
// this method requiere more attention
var query, res, key;
//maxright = parseInt(maxright,10);
// ToDo - update grid data
if(parentid !== null) {
maxright = parseInt(parentdata[right],10);
query = $.jgrid.from($t.p.data);
query = query.greaterOrEquals(right,maxright,{stype:'integer'});
res = query.select();
if(res.length) {
for( key in res) {
if(res.hasOwnProperty(key)) {
res[key][left] = res[key][left] > maxright ? parseInt(res[key][left],10) +2 : res[key][left];
res[key][right] = res[key][right] >= maxright ? parseInt(res[key][right],10) +2 : res[key][right];
}
}
}
data[left] = maxright;
data[right]= maxright+1;
} else {
maxright = parseInt( $($t).jqGrid('getCol', right, false, 'max'), 10);
res = $.jgrid.from($t.p.data)
.greater(left,maxright,{stype:'integer'})
.select();
if(res.length) {
for( key in res) {
if(res.hasOwnProperty(key)) {
res[key][left] = parseInt(res[key][left],10) +2 ;
}
}
}
res = $.jgrid.from($t.p.data)
.greater(right,maxright,{stype:'integer'})
.select();
if(res.length) {
for( key in res) {
if(res.hasOwnProperty(key)) {
res[key][right] = parseInt(res[key][right],10) +2 ;
}
}
}
data[left] = maxright+1;
data[right] = maxright + 2;
}
}
if( parentid === null || $($t).jqGrid("isNodeLoaded",parentdata) || leaf ) {
$($t).jqGrid('addRowData', nodeid, data, method, rowind);
$($t).jqGrid('setTreeNode', i, len);
}
if(parentdata && !parentdata[expanded] && expandData) {
$($t.rows[prow])
.find("div.treeclick")
.click();
}
}
//});
}
});
})(jQuery);
| JavaScript |
/*jshint eqeqeq:false */
/*global jQuery */
(function($){
/**
* jqGrid extension for SubGrid Data
* Tony Tomov tony@trirand.com
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl-2.0.html
**/
"use strict";
$.jgrid.extend({
setSubGrid : function () {
return this.each(function (){
var $t = this, cm, i,
suboptions = {
plusicon : "ui-icon-plus",
minusicon : "ui-icon-minus",
openicon: "ui-icon-carat-1-sw",
expandOnLoad: false,
delayOnLoad : 50,
selectOnExpand : false,
reloadOnExpand : true
};
$t.p.subGridOptions = $.extend(suboptions, $t.p.subGridOptions || {});
$t.p.colNames.unshift("");
$t.p.colModel.unshift({name:'subgrid',width: ($.browser.safari || $.browser.webkit) ? $t.p.subGridWidth+$t.p.cellLayout : $t.p.subGridWidth,sortable: false,resizable:false,hidedlg:true,search:false,fixed:true});
cm = $t.p.subGridModel;
if(cm[0]) {
cm[0].align = $.extend([],cm[0].align || []);
for(i=0;i<cm[0].name.length;i++) { cm[0].align[i] = cm[0].align[i] || 'left';}
}
});
},
addSubGridCell :function (pos,iRow) {
var prp='',ic,sid;
this.each(function(){
prp = this.formatCol(pos,iRow);
sid= this.p.id;
ic = this.p.subGridOptions.plusicon;
});
return "<td role=\"gridcell\" aria-describedby=\""+sid+"_subgrid\" class=\"ui-sgcollapsed sgcollapsed\" "+prp+"><a href='javascript:void(0);'><span class='ui-icon "+ic+"'></span></a></td>";
},
addSubGrid : function( pos, sind ) {
return this.each(function(){
var ts = this;
if (!ts.grid ) { return; }
//-------------------------
var subGridCell = function(trdiv,cell,pos)
{
var tddiv = $("<td align='"+ts.p.subGridModel[0].align[pos]+"'></td>").html(cell);
$(trdiv).append(tddiv);
};
var subGridXml = function(sjxml, sbid){
var tddiv, i, sgmap,
dummy = $("<table cellspacing='0' cellpadding='0' border='0'><tbody></tbody></table>"),
trdiv = $("<tr></tr>");
for (i = 0; i<ts.p.subGridModel[0].name.length; i++) {
tddiv = $("<th class='ui-state-default ui-th-subgrid ui-th-column ui-th-"+ts.p.direction+"'></th>");
$(tddiv).html(ts.p.subGridModel[0].name[i]);
$(tddiv).width( ts.p.subGridModel[0].width[i]);
$(trdiv).append(tddiv);
}
$(dummy).append(trdiv);
if (sjxml){
sgmap = ts.p.xmlReader.subgrid;
$(sgmap.root+" "+sgmap.row, sjxml).each( function(){
trdiv = $("<tr class='ui-widget-content ui-subtblcell'></tr>");
if(sgmap.repeatitems === true) {
$(sgmap.cell,this).each( function(i) {
subGridCell(trdiv, $(this).text() || ' ',i);
});
} else {
var f = ts.p.subGridModel[0].mapping || ts.p.subGridModel[0].name;
if (f) {
for (i=0;i<f.length;i++) {
subGridCell(trdiv, $(f[i],this).text() || ' ',i);
}
}
}
$(dummy).append(trdiv);
});
}
var pID = $("table:first",ts.grid.bDiv).attr("id")+"_";
$("#"+$.jgrid.jqID(pID+sbid)).append(dummy);
ts.grid.hDiv.loading = false;
$("#load_"+$.jgrid.jqID(ts.p.id)).hide();
return false;
};
var subGridJson = function(sjxml, sbid){
var tddiv,result,i,cur, sgmap,j,
dummy = $("<table cellspacing='0' cellpadding='0' border='0'><tbody></tbody></table>"),
trdiv = $("<tr></tr>");
for (i = 0; i<ts.p.subGridModel[0].name.length; i++) {
tddiv = $("<th class='ui-state-default ui-th-subgrid ui-th-column ui-th-"+ts.p.direction+"'></th>");
$(tddiv).html(ts.p.subGridModel[0].name[i]);
$(tddiv).width( ts.p.subGridModel[0].width[i]);
$(trdiv).append(tddiv);
}
$(dummy).append(trdiv);
if (sjxml){
sgmap = ts.p.jsonReader.subgrid;
result = $.jgrid.getAccessor(sjxml, sgmap.root);
if ( result !== undefined ) {
for (i=0;i<result.length;i++) {
cur = result[i];
trdiv = $("<tr class='ui-widget-content ui-subtblcell'></tr>");
if(sgmap.repeatitems === true) {
if(sgmap.cell) { cur=cur[sgmap.cell]; }
for (j=0;j<cur.length;j++) {
subGridCell(trdiv, cur[j] || ' ',j);
}
} else {
var f = ts.p.subGridModel[0].mapping || ts.p.subGridModel[0].name;
if(f.length) {
for (j=0;j<f.length;j++) {
subGridCell(trdiv, cur[f[j]] || ' ',j);
}
}
}
$(dummy).append(trdiv);
}
}
}
var pID = $("table:first",ts.grid.bDiv).attr("id")+"_";
$("#"+$.jgrid.jqID(pID+sbid)).append(dummy);
ts.grid.hDiv.loading = false;
$("#load_"+$.jgrid.jqID(ts.p.id)).hide();
return false;
};
var populatesubgrid = function( rd )
{
var sid,dp, i, j;
sid = $(rd).attr("id");
dp = {nd_: (new Date().getTime())};
dp[ts.p.prmNames.subgridid]=sid;
if(!ts.p.subGridModel[0]) { return false; }
if(ts.p.subGridModel[0].params) {
for(j=0; j < ts.p.subGridModel[0].params.length; j++) {
for(i=0; i<ts.p.colModel.length; i++) {
if(ts.p.colModel[i].name === ts.p.subGridModel[0].params[j]) {
dp[ts.p.colModel[i].name]= $("td:eq("+i+")",rd).text().replace(/\ \;/ig,'');
}
}
}
}
if(!ts.grid.hDiv.loading) {
ts.grid.hDiv.loading = true;
$("#load_"+$.jgrid.jqID(ts.p.id)).show();
if(!ts.p.subgridtype) { ts.p.subgridtype = ts.p.datatype; }
if($.isFunction(ts.p.subgridtype)) {
ts.p.subgridtype.call(ts, dp);
} else {
ts.p.subgridtype = ts.p.subgridtype.toLowerCase();
}
switch(ts.p.subgridtype) {
case "xml":
case "json":
$.ajax($.extend({
type:ts.p.mtype,
url: ts.p.subGridUrl,
dataType:ts.p.subgridtype,
data: $.isFunction(ts.p.serializeSubGridData)? ts.p.serializeSubGridData.call(ts, dp) : dp,
complete: function(sxml) {
if(ts.p.subgridtype === "xml") {
subGridXml(sxml.responseXML, sid);
} else {
subGridJson($.jgrid.parse(sxml.responseText),sid);
}
sxml=null;
}
}, $.jgrid.ajaxOptions, ts.p.ajaxSubgridOptions || {}));
break;
}
}
return false;
};
var _id, pID,atd, nhc=0, bfsc, r;
$.each(ts.p.colModel,function(){
if(this.hidden === true || this.name === 'rn' || this.name === 'cb') {
nhc++;
}
});
var len = ts.rows.length, i=1;
if( sind !== undefined && sind > 0) {
i = sind;
len = sind+1;
}
while(i < len) {
if($(ts.rows[i]).hasClass('jqgrow')) {
$(ts.rows[i].cells[pos]).bind('click', function() {
var tr = $(this).parent("tr")[0];
r = tr.nextSibling;
if($(this).hasClass("sgcollapsed")) {
pID = ts.p.id;
_id = tr.id;
if(ts.p.subGridOptions.reloadOnExpand === true || ( ts.p.subGridOptions.reloadOnExpand === false && !$(r).hasClass('ui-subgrid') ) ) {
atd = pos >=1 ? "<td colspan='"+pos+"'> </td>":"";
bfsc = $(ts).triggerHandler("jqGridSubGridBeforeExpand", [pID + "_" + _id, _id]);
bfsc = (bfsc === false || bfsc === 'stop') ? false : true;
if(bfsc && $.isFunction(ts.p.subGridBeforeExpand)) {
bfsc = ts.p.subGridBeforeExpand.call(ts, pID+"_"+_id,_id);
}
if(bfsc === false) {return false;}
$(tr).after( "<tr role='row' class='ui-subgrid'>"+atd+"<td class='ui-widget-content subgrid-cell'><span class='ui-icon "+ts.p.subGridOptions.openicon+"'></span></td><td colspan='"+parseInt(ts.p.colNames.length-1-nhc,10)+"' class='ui-widget-content subgrid-data'><div id="+pID+"_"+_id+" class='tablediv'></div></td></tr>" );
$(ts).triggerHandler("jqGridSubGridRowExpanded", [pID + "_" + _id, _id]);
if( $.isFunction(ts.p.subGridRowExpanded)) {
ts.p.subGridRowExpanded.call(ts, pID+"_"+ _id,_id);
} else {
populatesubgrid(tr);
}
} else {
$(r).show();
}
$(this).html("<a href='javascript:void(0);'><span class='ui-icon "+ts.p.subGridOptions.minusicon+"'></span></a>").removeClass("sgcollapsed").addClass("sgexpanded");
if(ts.p.subGridOptions.selectOnExpand) {
$(ts).jqGrid('setSelection',_id);
}
} else if($(this).hasClass("sgexpanded")) {
bfsc = $(ts).triggerHandler("jqGridSubGridRowColapsed", [pID + "_" + _id, _id]);
bfsc = (bfsc === false || bfsc === 'stop') ? false : true;
if( bfsc && $.isFunction(ts.p.subGridRowColapsed)) {
_id = tr.id;
bfsc = ts.p.subGridRowColapsed.call(ts, pID+"_"+_id,_id );
}
if(bfsc===false) {return false;}
if(ts.p.subGridOptions.reloadOnExpand === true) {
$(r).remove(".ui-subgrid");
} else if($(r).hasClass('ui-subgrid')) { // incase of dynamic deleting
$(r).hide();
}
$(this).html("<a href='javascript:void(0);'><span class='ui-icon "+ts.p.subGridOptions.plusicon+"'></span></a>").removeClass("sgexpanded").addClass("sgcollapsed");
}
return false;
});
}
i++;
}
if(ts.p.subGridOptions.expandOnLoad === true) {
$(ts.rows).filter('.jqgrow').each(function(index,row){
$(row.cells[0]).click();
});
}
ts.subGridXml = function(xml,sid) {subGridXml(xml,sid);};
ts.subGridJson = function(json,sid) {subGridJson(json,sid);};
});
},
expandSubGridRow : function(rowid) {
return this.each(function () {
var $t = this;
if(!$t.grid && !rowid) {return;}
if($t.p.subGrid===true) {
var rc = $(this).jqGrid("getInd",rowid,true);
if(rc) {
var sgc = $("td.sgcollapsed",rc)[0];
if(sgc) {
$(sgc).trigger("click");
}
}
}
});
},
collapseSubGridRow : function(rowid) {
return this.each(function () {
var $t = this;
if(!$t.grid && !rowid) {return;}
if($t.p.subGrid===true) {
var rc = $(this).jqGrid("getInd",rowid,true);
if(rc) {
var sgc = $("td.sgexpanded",rc)[0];
if(sgc) {
$(sgc).trigger("click");
}
}
}
});
},
toggleSubGridRow : function(rowid) {
return this.each(function () {
var $t = this;
if(!$t.grid && !rowid) {return;}
if($t.p.subGrid===true) {
var rc = $(this).jqGrid("getInd",rowid,true);
if(rc) {
var sgc = $("td.sgcollapsed",rc)[0];
if(sgc) {
$(sgc).trigger("click");
} else {
sgc = $("td.sgexpanded",rc)[0];
if(sgc) {
$(sgc).trigger("click");
}
}
}
}
});
}
});
})(jQuery);
| JavaScript |
/*jshint eqeqeq:false, eqnull:true */
/*global jQuery */
// Grouping module
(function($){
"use strict";
$.extend($.jgrid,{
template : function(format){ //jqgformat
var args = $.makeArray(arguments).slice(1), j, al = args.length;
if(format==null) { format = ""; }
return format.replace(/\{([\w\-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g, function(m,i){
if(!isNaN(parseInt(i,10))) {
return args[parseInt(i,10)];
}
for(j=0; j < al;j++) {
if($.isArray(args[j])) {
var nmarr = args[ j ],
k = nmarr.length;
while(k--) {
if(i===nmarr[k].nm) {
return nmarr[k].v;
}
}
}
}
});
}
});
$.jgrid.extend({
groupingSetup : function () {
return this.each(function (){
var $t = this, i, j, cml, cm = $t.p.colModel, grp = $t.p.groupingView;
if(grp !== null && ( (typeof grp === 'object') || $.isFunction(grp) ) ) {
if(!grp.groupField.length) {
$t.p.grouping = false;
} else {
if (grp.visibiltyOnNextGrouping === undefined) {
grp.visibiltyOnNextGrouping = [];
}
grp.lastvalues=[];
grp.groups =[];
grp.counters =[];
for(i=0;i<grp.groupField.length;i++) {
if(!grp.groupOrder[i]) {
grp.groupOrder[i] = 'asc';
}
if(!grp.groupText[i]) {
grp.groupText[i] = '{0}';
}
if( typeof grp.groupColumnShow[i] !== 'boolean') {
grp.groupColumnShow[i] = true;
}
if( typeof grp.groupSummary[i] !== 'boolean') {
grp.groupSummary[i] = false;
}
if(grp.groupColumnShow[i] === true) {
grp.visibiltyOnNextGrouping[i] = true;
$($t).jqGrid('showCol',grp.groupField[i]);
} else {
grp.visibiltyOnNextGrouping[i] = $("#"+$.jgrid.jqID($t.p.id+"_"+grp.groupField[i])).is(":visible");
$($t).jqGrid('hideCol',grp.groupField[i]);
}
}
grp.summary =[];
for(j=0, cml = cm.length; j < cml; j++) {
if(cm[j].summaryType) {
grp.summary.push({nm:cm[j].name,st:cm[j].summaryType, v: '', sr: cm[j].summaryRound, srt: cm[j].summaryRoundType || 'round'});
}
}
}
} else {
$t.p.grouping = false;
}
});
},
groupingPrepare : function (rData, gdata, record, irow) {
this.each(function(){
var grp = this.p.groupingView, $t= this, i,
grlen = grp.groupField.length,
fieldName,
v,
displayName,
displayValue,
changed = 0;
for(i=0;i<grlen;i++) {
fieldName = grp.groupField[i];
displayName = grp.displayField[i];
v = record[fieldName];
displayValue = displayName == null ? null : record[displayName];
if( displayValue == null ) {
displayValue = v;
}
if( v !== undefined ) {
if(irow === 0 ) {
// First record always starts a new group
grp.groups.push({idx:i,dataIndex:fieldName,value:v, displayValue: displayValue, startRow: irow, cnt:1, summary : [] } );
grp.lastvalues[i] = v;
grp.counters[i] = {cnt:1, pos:grp.groups.length-1, summary: $.extend(true,[],grp.summary)};
$.each(grp.counters[i].summary,function() {
if ($.isFunction(this.st)) {
this.v = this.st.call($t, this.v, this.nm, record);
} else {
this.v = $($t).jqGrid('groupingCalculations.handler',this.st, this.v, this.nm, this.sr, this.srt, record);
}
});
grp.groups[grp.counters[i].pos].summary = grp.counters[i].summary;
} else {
if( typeof v !== "object" && grp.lastvalues[i] !== v ) {
// This record is not in same group as previous one
grp.groups.push({idx:i,dataIndex:fieldName,value:v, displayValue: displayValue, startRow: irow, cnt:1, summary : [] } );
grp.lastvalues[i] = v;
changed = 1;
grp.counters[i] = {cnt:1, pos:grp.groups.length-1, summary: $.extend(true,[],grp.summary)};
$.each(grp.counters[i].summary,function() {
if ($.isFunction(this.st)) {
this.v = this.st.call($t, this.v, this.nm, record);
} else {
this.v = $($t).jqGrid('groupingCalculations.handler',this.st, this.v, this.nm, this.sr, this.srt, record);
}
});
grp.groups[grp.counters[i].pos].summary = grp.counters[i].summary;
} else {
if (changed === 1) {
// This group has changed because an earlier group changed.
grp.groups.push({idx:i,dataIndex:fieldName,value:v, displayValue: displayValue, startRow: irow, cnt:1, summary : [] } );
grp.lastvalues[i] = v;
grp.counters[i] = {cnt:1, pos:grp.groups.length-1, summary: $.extend(true,[],grp.summary)};
$.each(grp.counters[i].summary,function() {
if ($.isFunction(this.st)) {
this.v = this.st.call($t, this.v, this.nm, record);
} else {
this.v = $($t).jqGrid('groupingCalculations.handler',this.st, this.v, this.nm, this.sr, this.srt, record);
}
});
grp.groups[grp.counters[i].pos].summary = grp.counters[i].summary;
} else {
grp.counters[i].cnt += 1;
grp.groups[grp.counters[i].pos].cnt = grp.counters[i].cnt;
$.each(grp.counters[i].summary,function() {
if ($.isFunction(this.st)) {
this.v = this.st.call($t, this.v, this.nm, record);
} else {
this.v = $($t).jqGrid('groupingCalculations.handler',this.st, this.v, this.nm, this.sr, this.srt, record);
}
});
grp.groups[grp.counters[i].pos].summary = grp.counters[i].summary;
}
}
}
}
}
gdata.push( rData );
});
return gdata;
},
groupingToggle : function(hid){
this.each(function(){
var $t = this,
grp = $t.p.groupingView,
strpos = hid.split('_'),
//uid = hid.substring(0,strpos+1),
num = parseInt(strpos[strpos.length-2], 10);
strpos.splice(strpos.length-2,2);
var uid = strpos.join("_"),
minus = grp.minusicon,
plus = grp.plusicon,
tar = $("#"+$.jgrid.jqID(hid)),
r = tar.length ? tar[0].nextSibling : null,
tarspan = $("#"+$.jgrid.jqID(hid)+" span."+"tree-wrap-"+$t.p.direction),
collapsed = false, tspan;
if( tarspan.hasClass(minus) ) {
if(grp.showSummaryOnHide) {
if(r){
while(r) {
if($(r).hasClass('jqfoot') ) {
var lv = parseInt($(r).attr("jqfootlevel"),10);
if( lv <= num) {
break;
}
}
$(r).hide();
r = r.nextSibling;
}
}
} else {
if(r){
while(r) {
if( $(r).hasClass(uid+"_"+String(num) ) || $(r).hasClass(uid+"_"+String(num-1))) { break; }
$(r).hide();
r = r.nextSibling;
}
}
}
tarspan.removeClass(minus).addClass(plus);
collapsed = true;
} else {
if(r){
while(r) {
if($(r).hasClass(uid+"_"+String(num)) || $(r).hasClass(uid+"_"+String(num-1)) ) { break; }
$(r).show();
tspan = $(r).find("span."+"tree-wrap-"+$t.p.direction);
if( tspan && $(tspan).hasClass(plus) ) {
$(tspan).removeClass(plus).addClass(minus);
}
r = r.nextSibling;
}
}
tarspan.removeClass(plus).addClass(minus);
}
$($t).triggerHandler("jqGridGroupingClickGroup", [hid , collapsed]);
if( $.isFunction($t.p.onClickGroup)) { $t.p.onClickGroup.call($t, hid , collapsed); }
});
return false;
},
groupingRender : function (grdata, colspans ) {
return this.each(function(){
var $t = this,
grp = $t.p.groupingView,
str = "", icon = "", hid, clid, pmrtl = grp.groupCollapse ? grp.plusicon : grp.minusicon, gv, cp=[], len =grp.groupField.length;
pmrtl += " tree-wrap-"+$t.p.direction;
$.each($t.p.colModel, function (i,n){
var ii;
for(ii=0;ii<len;ii++) {
if(grp.groupField[ii] === n.name ) {
cp[ii] = i;
break;
}
}
});
var toEnd = 0;
function findGroupIdx( ind , offset, grp) {
var ret = false, i;
if(offset===0) {
ret = grp[ind];
} else {
var id = grp[ind].idx;
if(id===0) {
ret = grp[ind];
} else {
for(i=ind;i >= 0; i--) {
if(grp[i].idx === id-offset) {
ret = grp[i];
break;
}
}
}
}
return ret;
}
var sumreverse = $.makeArray(grp.groupSummary);
sumreverse.reverse();
$.each(grp.groups,function(i,n){
toEnd++;
clid = $t.p.id+"ghead_"+n.idx;
hid = clid+"_"+i;
icon = "<span style='cursor:pointer;' class='ui-icon "+pmrtl+"' onclick=\"jQuery('#"+$.jgrid.jqID($t.p.id)+"').jqGrid('groupingToggle','"+hid+"');return false;\"></span>";
try {
gv = $t.formatter(hid, n.displayValue, cp[n.idx], n.value );
} catch (egv) {
gv = n.displayValue;
}
str += "<tr id=\""+hid+"\" role=\"row\" class= \"ui-widget-content jqgroup ui-row-"+$t.p.direction+" "+clid+"\"><td style=\"padding-left:"+(n.idx * 12) + "px;"+"\" colspan=\""+colspans+"\">"+icon+$.jgrid.template(grp.groupText[n.idx], gv, n.cnt, n.summary)+"</td></tr>";
var leaf = len-1 === n.idx;
if( leaf ) {
var gg = grp.groups[i+1], k, kk, ik;
var end = gg !== undefined ? grp.groups[i+1].startRow : grdata.length;
for(kk=n.startRow;kk<end;kk++) {
str += grdata[kk].join('');
}
var jj;
if (gg !== undefined) {
for (jj = 0; jj < grp.groupField.length; jj++) {
if (gg.dataIndex === grp.groupField[jj]) {
break;
}
}
toEnd = grp.groupField.length - jj;
}
for (ik = 0; ik < toEnd; ik++) {
if(!sumreverse[ik]) { continue; }
var hhdr = "";
if(grp.groupCollapse && !grp.showSummaryOnHide) {
hhdr = " style=\"display:none;\"";
}
str += "<tr"+hhdr+" jqfootlevel=\""+(n.idx-ik)+"\" role=\"row\" class=\"ui-widget-content jqfoot ui-row-"+$t.p.direction+"\">";
var fdata = findGroupIdx(i, ik, grp.groups),
cm = $t.p.colModel,
vv, grlen = fdata.cnt;
for(k=0; k<colspans;k++) {
var tmpdata = "<td "+$t.formatCol(k,1,'')+"> </td>",
tplfld = "{0}";
$.each(fdata.summary,function(){
if(this.nm === cm[k].name) {
if(cm[k].summaryTpl) {
tplfld = cm[k].summaryTpl;
}
if(typeof this.st === 'string' && this.st.toLowerCase() === 'avg') {
if(this.v && grlen > 0) {
this.v = (this.v/grlen);
}
}
try {
vv = $t.formatter('', this.v, k, this);
} catch (ef) {
vv = this.v;
}
tmpdata= "<td "+$t.formatCol(k,1,'')+">"+$.jgrid.format(tplfld,vv)+ "</td>";
return false;
}
});
str += tmpdata;
}
str += "</tr>";
}
toEnd = jj;
}
});
$("#"+$.jgrid.jqID($t.p.id)+" tbody:first").append(str);
// free up memory
str = null;
});
},
groupingGroupBy : function (name, options ) {
return this.each(function(){
var $t = this;
if(typeof name === "string") {
name = [name];
}
var grp = $t.p.groupingView;
$t.p.grouping = true;
//Set default, in case visibilityOnNextGrouping is undefined
if (grp.visibiltyOnNextGrouping === undefined) {
grp.visibiltyOnNextGrouping = [];
}
var i;
// show previous hidden groups if they are hidden and weren't removed yet
for(i=0;i<grp.groupField.length;i++) {
if(!grp.groupColumnShow[i] && grp.visibiltyOnNextGrouping[i]) {
$($t).jqGrid('showCol',grp.groupField[i]);
}
}
// set visibility status of current group columns on next grouping
for(i=0;i<name.length;i++) {
grp.visibiltyOnNextGrouping[i] = $("#"+$.jgrid.jqID($t.p.id)+"_"+$.jgrid.jqID(name[i])).is(":visible");
}
$t.p.groupingView = $.extend($t.p.groupingView, options || {});
grp.groupField = name;
$($t).trigger("reloadGrid");
});
},
groupingRemove : function (current) {
return this.each(function(){
var $t = this;
if(current === undefined) {
current = true;
}
$t.p.grouping = false;
if(current===true) {
var grp = $t.p.groupingView, i;
// show previous hidden groups if they are hidden and weren't removed yet
for(i=0;i<grp.groupField.length;i++) {
if (!grp.groupColumnShow[i] && grp.visibiltyOnNextGrouping[i]) {
$($t).jqGrid('showCol', grp.groupField);
}
}
$("tr.jqgroup, tr.jqfoot","#"+$.jgrid.jqID($t.p.id)+" tbody:first").remove();
$("tr.jqgrow:hidden","#"+$.jgrid.jqID($t.p.id)+" tbody:first").show();
} else {
$($t).trigger("reloadGrid");
}
});
},
groupingCalculations : {
handler: function(fn, v, field, round, roundType, rc) {
var funcs = {
sum: function() {
return parseFloat(v||0) + parseFloat((rc[field]||0));
},
min: function() {
if(v==="") {
return parseFloat(rc[field]||0);
}
return Math.min(parseFloat(v),parseFloat(rc[field]||0));
},
max: function() {
if(v==="") {
return parseFloat(rc[field]||0);
}
return Math.max(parseFloat(v),parseFloat(rc[field]||0));
},
count: function() {
if(v==="") {v=0;}
if(rc.hasOwnProperty(field)) {
return v+1;
}
return 0;
},
avg: function() {
// the same as sum, but at end we divide it
// so use sum instead of duplicating the code (?)
return funcs.sum();
}
};
if(!funcs[fn]) {
throw ("jqGrid Grouping No such method: " + fn);
}
var res = funcs[fn]();
if (round != null) {
if (roundType == 'fixed') {
res = res.toFixed(round);
} else {
var mul = Math.pow(10, round);
res = Math.round(res * mul) / mul;
}
}
return res;
}
}
});
})(jQuery);
| JavaScript |
/* Plugin: searchFilter v1.2.9
* Author: Kasey Speakman (kasey@cornerspeed.com)
* License: Dual Licensed, MIT and GPL v2 (http://www.gnu.org/licenses/gpl-2.0.html)
*
* REQUIREMENTS:
* jQuery 1.3+ (http://jquery.com/)
* A Themeroller Theme (http://jqueryui.com/themeroller/)
*
* SECURITY WARNING
* You should always implement server-side checking to ensure that
* the query will fail when forged/invalid data is received.
* Clever users can send any value they want through JavaScript and HTTP POST/GET.
*
* THEMES
* Simply include the CSS file for your Themeroller theme.
*
* DESCRIPTION
* This plugin creates a new searchFilter object in the specified container
*
* INPUT TYPE
* fields: an array of field objects. each object has the following properties:
* text: a string containing the display name of the field (e.g. "Field 1")
* itemval: a string containing the actual field name (e.g. "field1")
* optional properties:
* ops: an array of operators in the same format as jQuery.fn.searchFilter.defaults.operators
* that is: [ { op: 'gt', text: 'greater than'}, { op:'lt', text: 'less than'}, ... ]
* if not specified, the passed-in options used, and failting that, jQuery.fn.searchFilter.defaults.operators will be used
* *** NOTE ***
* Specifying a dataUrl or dataValues property means that a <select ...> (drop-down-list) will be generated
* instead of a text input <input type='text'.../> where the user would normally type in their search data
* ************
* dataUrl: a url that will return the html select for this field, this url will only be called once for this field
* dataValues: the possible values for this field in the form [ { text: 'Data Display Text', value: 'data_actual_value' }, { ... } ]
* dataInit: a function that you can use to initialize the data field. this function is passed the jQuery-fied data element
* dataEvents: list of events to apply to the data element. uses $("#id").bind(type, [data], fn) to bind events to data element
* *** JSON of this object could look like this: ***
* var fields = [
* {
* text: 'Field Display Name',
* itemval: 'field_actual_name',
* // below this are optional values
* ops: [ // this format is the same as jQuery.fn.searchFilter.defaults.operators
* { op: 'gt', text: 'greater than' },
* { op: 'lt', text: 'less than' }
* ],
* dataUrl: 'http://server/path/script.php?propName=propValue', // using this creates a select for the data input instead of an input type='text'
* dataValues: [ // using this creates a select for the data input instead of an input type='text'
* { text: 'Data Value Display Name', value: 'data_actual_value' },
* { ... }
* ],
* dataInit: function(jElem) { jElem.datepicker(options); },
* dataEvents: [ // these are the same options that you pass to $("#id").bind(type, [data], fn)
* { type: 'click', data: { i: 7 }, fn: function(e) { console.log(e.data.i); } },
* { type: 'keypress', fn: function(e) { console.log('keypress'); } }
* ]
* },
* { ... }
* ]
* options: name:value properties containing various creation options
* see jQuery.fn.searchFilter.defaults for the overridable options
*
* RETURN TYPE: This plugin returns a SearchFilter object, which has additional SearchFilter methods:
* Methods
* add: Adds a filter. added to the end of the list unless a jQuery event object or valid row number is passed.
* del: Removes a filter. removed from the end of the list unless a jQuery event object or valid row number is passed.
* reset: resets filters back to original state (only one blank filter), and calls onReset
* search: puts the search rules into an object and calls onSearch with it
* close: calls the onClose event handler
*
* USAGE
* HTML
* <head>
* ...
* <script src="path/to/jquery.min.js" type="text/javascript"></script>
* <link href="path/to/themeroller.css" rel="Stylesheet" type="text/css" />
* <script src="path/to/jquery.searchFilter.js" type="text/javascript"></script>
* <link href="path/to/jquery.searchFilter.css" rel="Stylesheet" type="text/css" />
* ...
* </head>
* <body>
* ...
* <div id='mySearch'></div>
* ...
* </body>
* JQUERY
* Methods
* initializing: $("#mySearch").searchFilter([{text: "Field 1", value: "field1"},{text: "Field 2", value: "field2"}], {onSearch: myFilterRuleReceiverFn, onReset: myFilterResetFn });
* Manual Methods (there's no need to call these methods unless you are trying to manipulate searchFilter with script)
* add: $("#mySearch").searchFilter().add(); // appends a blank filter
* $("#mySearch").searchFilter().add(0); // copies the first filter as second
* del: $("#mySearch").searchFilter().del(); // removes the bottom filter
* $("#mySearch").searchFilter().del(1); // removes the second filter
* search: $("#mySearch").searchFilter().search(); // invokes onSearch, passing it a ruleGroup object
* reset: $("#mySearch").searchFilter().reset(); // resets rules and invokes onReset
* close: $("#mySearch").searchFilter().close(); // without an onClose handler, equivalent to $("#mySearch").hide();
*
* NOTE: You can get the jQuery object back from the SearchFilter object by chaining .$
* Example
* $("#mySearch").searchFilter().add().add().reset().$.hide();
* Verbose Example
* $("#mySearch") // gets jQuery object for the HTML element with id="mySearch"
* .searchFilter() // gets the SearchFilter object for an existing search filter
* .add() // adds a new filter to the end of the list
* .add() // adds another new filter to the end of the list
* .reset() // resets filters back to original state, triggers onReset
* .$ // returns jQuery object for $("#mySearch")
* .hide(); // equivalent to $("#mySearch").hide();
*/
jQuery.fn.searchFilter = function(fields, options) {
function SearchFilter(jQ, fields, options) {
//---------------------------------------------------------------
// PUBLIC VARS
//---------------------------------------------------------------
this.$ = jQ; // makes the jQuery object available as .$ from the return value
//---------------------------------------------------------------
// PUBLIC FUNCTIONS
//---------------------------------------------------------------
this.add = function(i) {
if (i == null) jQ.find(".ui-add-last").click();
else jQ.find(".sf:eq(" + i + ") .ui-add").click();
return this;
};
this.del = function(i) {
if (i == null) jQ.find(".sf:last .ui-del").click();
else jQ.find(".sf:eq(" + i + ") .ui-del").click();
return this;
};
this.search = function(e) {
jQ.find(".ui-search").click();
return this;
};
this.reset = function(o) {
if(o===undefined) o = false;
jQ.find(".ui-reset").trigger('click',[o]);
return this;
};
this.close = function() {
jQ.find(".ui-closer").click();
return this;
};
//---------------------------------------------------------------
// "CONSTRUCTOR" (in air quotes)
//---------------------------------------------------------------
if (fields != null) { // type coercion matches undefined as well as null
//---------------------------------------------------------------
// UTILITY FUNCTIONS
//---------------------------------------------------------------
function hover() {
jQuery(this).toggleClass("ui-state-hover");
return false;
}
function active(e) {
jQuery(this).toggleClass("ui-state-active", (e.type == "mousedown"));
return false;
}
function buildOpt(value, text) {
return "<option value='" + value + "'>" + text + "</option>";
}
function buildSel(className, options, isHidden) {
return "<select class='" + className + "'" + (isHidden ? " style='display:none;'" : "") + ">" + options + "</select>";
}
function initData(selector, fn) {
var jElem = jQ.find("tr.sf td.data " + selector);
if (jElem[0] != null)
fn(jElem);
}
function bindDataEvents(selector, events) {
var jElem = jQ.find("tr.sf td.data " + selector);
if (jElem[0] != null) {
jQuery.each(events, function() {
if (this.data != null)
jElem.bind(this.type, this.data, this.fn);
else
jElem.bind(this.type, this.fn);
});
}
}
//---------------------------------------------------------------
// SUPER IMPORTANT PRIVATE VARS
//---------------------------------------------------------------
// copies jQuery.fn.searchFilter.defaults.options properties onto an empty object, then options onto that
var opts = jQuery.extend({}, jQuery.fn.searchFilter.defaults, options);
// this is keeps track of the last asynchronous setup
var highest_late_setup = -1;
//---------------------------------------------------------------
// CREATION PROCESS STARTS
//---------------------------------------------------------------
// generate the global ops
var gOps_html = "";
jQuery.each(opts.groupOps, function() { gOps_html += buildOpt(this.op, this.text); });
gOps_html = "<select name='groupOp'>" + gOps_html + "</select>";
/* original content - doesn't minify very well
jQ
.html("") // clear any old content
.addClass("ui-searchFilter") // add classes
.append( // add content
"\
<div class='ui-widget-overlay' style='z-index: -1'> </div>\
<table class='ui-widget-content ui-corner-all'>\
<thead>\
<tr>\
<td colspan='5' class='ui-widget-header ui-corner-all' style='line-height: 18px;'>\
<div class='ui-closer ui-state-default ui-corner-all ui-helper-clearfix' style='float: right;'>\
<span class='ui-icon ui-icon-close'></span>\
</div>\
" + opts.windowTitle + "\
</td>\
</tr>\
</thead>\
<tbody>\
<tr class='sf'>\
<td class='fields'></td>\
<td class='ops'></td>\
<td class='data'></td>\
<td><div class='ui-del ui-state-default ui-corner-all'><span class='ui-icon ui-icon-minus'></span></div></td>\
<td><div class='ui-add ui-state-default ui-corner-all'><span class='ui-icon ui-icon-plus'></span></div></td>\
</tr>\
<tr>\
<td colspan='5' class='divider'><div> </div></td>\
</tr>\
</tbody>\
<tfoot>\
<tr>\
<td colspan='3'>\
<span class='ui-reset ui-state-default ui-corner-all' style='display: inline-block; float: left;'><span class='ui-icon ui-icon-arrowreturnthick-1-w' style='float: left;'></span><span style='line-height: 18px; padding: 0 7px 0 3px;'>" + opts.resetText + "</span></span>\
<span class='ui-search ui-state-default ui-corner-all' style='display: inline-block; float: right;'><span class='ui-icon ui-icon-search' style='float: left;'></span><span style='line-height: 18px; padding: 0 7px 0 3px;'>" + opts.searchText + "</span></span>\
<span class='matchText'>" + opts.matchText + "</span> \
" + gOps_html + " \
<span class='rulesText'>" + opts.rulesText + "</span>\
</td>\
<td> </td>\
<td><div class='ui-add-last ui-state-default ui-corner-all'><span class='ui-icon ui-icon-plusthick'></span></div></td>\
</tr>\
</tfoot>\
</table>\
");
/* end hard-to-minify code */
/* begin easier to minify code */
jQ.html("").addClass("ui-searchFilter").append("<div class='ui-widget-overlay' style='z-index: -1'> </div><table class='ui-widget-content ui-corner-all'><thead><tr><td colspan='5' class='ui-widget-header ui-corner-all' style='line-height: 18px;'><div class='ui-closer ui-state-default ui-corner-all ui-helper-clearfix' style='float: right;'><span class='ui-icon ui-icon-close'></span></div>" + opts.windowTitle + "</td></tr></thead><tbody><tr class='sf'><td class='fields'></td><td class='ops'></td><td class='data'></td><td><div class='ui-del ui-state-default ui-corner-all'><span class='ui-icon ui-icon-minus'></span></div></td><td><div class='ui-add ui-state-default ui-corner-all'><span class='ui-icon ui-icon-plus'></span></div></td></tr><tr><td colspan='5' class='divider'><hr class='ui-widget-content' style='margin:1px'/></td></tr></tbody><tfoot><tr><td colspan='3'><span class='ui-reset ui-state-default ui-corner-all' style='display: inline-block; float: left;'><span class='ui-icon ui-icon-arrowreturnthick-1-w' style='float: left;'></span><span style='line-height: 18px; padding: 0 7px 0 3px;'>" + opts.resetText + "</span></span><span class='ui-search ui-state-default ui-corner-all' style='display: inline-block; float: right;'><span class='ui-icon ui-icon-search' style='float: left;'></span><span style='line-height: 18px; padding: 0 7px 0 3px;'>" + opts.searchText + "</span></span><span class='matchText'>" + opts.matchText + "</span> " + gOps_html + " <span class='rulesText'>" + opts.rulesText + "</span></td><td> </td><td><div class='ui-add-last ui-state-default ui-corner-all'><span class='ui-icon ui-icon-plusthick'></span></div></td></tr></tfoot></table>");
/* end easier-to-minify code */
var jRow = jQ.find("tr.sf");
var jFields = jRow.find("td.fields");
var jOps = jRow.find("td.ops");
var jData = jRow.find("td.data");
// generate the defaults
var default_ops_html = "";
jQuery.each(opts.operators, function() { default_ops_html += buildOpt(this.op, this.text); });
default_ops_html = buildSel("default", default_ops_html, true);
jOps.append(default_ops_html);
var default_data_html = "<input type='text' class='default' style='display:none;' />";
jData.append(default_data_html);
// generate the field list as a string
var fields_html = "";
var has_custom_ops = false;
var has_custom_data = false;
jQuery.each(fields, function(i) {
var field_num = i;
fields_html += buildOpt(this.itemval, this.text);
// add custom ops if they exist
if (this.ops != null) {
has_custom_ops = true;
var custom_ops = "";
jQuery.each(this.ops, function() { custom_ops += buildOpt(this.op, this.text); });
custom_ops = buildSel("field" + field_num, custom_ops, true);
jOps.append(custom_ops);
}
// add custom data if it is given
if (this.dataUrl != null) {
if (i > highest_late_setup) highest_late_setup = i;
has_custom_data = true;
var dEvents = this.dataEvents;
var iEvent = this.dataInit;
var bs = this.buildSelect;
jQuery.ajax(jQuery.extend({
url : this.dataUrl,
complete: function(data) {
var $d;
if(bs != null) $d =jQuery("<div />").append(bs(data));
else $d = jQuery("<div />").append(data.responseText);
$d.find("select").addClass("field" + field_num).hide();
jData.append($d.html());
if (iEvent) initData(".field" + i, iEvent);
if (dEvents) bindDataEvents(".field" + i, dEvents);
if (i == highest_late_setup) { // change should get called no more than twice when this searchFilter is constructed
jQ.find("tr.sf td.fields select[name='field']").change();
}
}
},opts.ajaxSelectOptions));
} else if (this.dataValues != null) {
has_custom_data = true;
var custom_data = "";
jQuery.each(this.dataValues, function() { custom_data += buildOpt(this.value, this.text); });
custom_data = buildSel("field" + field_num, custom_data, true);
jData.append(custom_data);
} else if (this.dataEvents != null || this.dataInit != null) {
has_custom_data = true;
var custom_data = "<input type='text' class='field" + field_num + "' />";
jData.append(custom_data);
}
// attach events to data if they exist
if (this.dataInit != null && i != highest_late_setup)
initData(".field" + i, this.dataInit);
if (this.dataEvents != null && i != highest_late_setup)
bindDataEvents(".field" + i, this.dataEvents);
});
fields_html = "<select name='field'>" + fields_html + "</select>";
jFields.append(fields_html);
// setup the field select with an on-change event if there are custom ops or data
var jFSelect = jFields.find("select[name='field']");
if (has_custom_ops) jFSelect.change(function(e) {
var index = e.target.selectedIndex;
var td = jQuery(e.target).parents("tr.sf").find("td.ops");
td.find("select").removeAttr("name").hide(); // disown and hide all elements
var jElem = td.find(".field" + index);
if (jElem[0] == null) jElem = td.find(".default"); // if there's not an element for that field, use the default one
jElem.attr("name", "op").show();
return false;
});
else jOps.find(".default").attr("name", "op").show();
if (has_custom_data) jFSelect.change(function(e) {
var index = e.target.selectedIndex;
var td = jQuery(e.target).parents("tr.sf").find("td.data");
td.find("select,input").removeClass("vdata").hide(); // disown and hide all elements
var jElem = td.find(".field" + index);
if (jElem[0] == null) jElem = td.find(".default"); // if there's not an element for that field, use the default one
jElem.show().addClass("vdata");
return false;
});
else jData.find(".default").show().addClass("vdata");
// go ahead and call the change event and setup the ops and data values
if (has_custom_ops || has_custom_data) jFSelect.change();
// bind events
jQ.find(".ui-state-default").hover(hover, hover).mousedown(active).mouseup(active); // add hover/active effects to all buttons
jQ.find(".ui-closer").click(function(e) {
opts.onClose(jQuery(jQ.selector));
return false;
});
jQ.find(".ui-del").click(function(e) {
var row = jQuery(e.target).parents(".sf");
if (row.siblings(".sf").length > 0) { // doesn't remove if there's only one filter left
if (opts.datepickerFix === true && jQuery.fn.datepicker !== undefined)
row.find(".hasDatepicker").datepicker("destroy"); // clean up datepicker's $.data mess
row.remove(); // also unbinds
} else { // resets the filter if it's the last one
row.find("select[name='field']")[0].selectedIndex = 0;
row.find("select[name='op']")[0].selectedIndex = 0;
row.find(".data input").val(""); // blank all input values
row.find(".data select").each(function() { this.selectedIndex = 0; }); // select first option on all selects
row.find("select[name='field']").change(function(event){event.stopPropagation();}); // trigger any change events
}
return false;
});
jQ.find(".ui-add").click(function(e) {
var row = jQuery(e.target).parents(".sf");
var newRow = row.clone(true).insertAfter(row);
newRow.find(".ui-state-default").removeClass("ui-state-hover ui-state-active");
if (opts.clone) {
newRow.find("select[name='field']")[0].selectedIndex = row.find("select[name='field']")[0].selectedIndex;
var stupid_browser = (newRow.find("select[name='op']")[0] == null); // true for IE6
if (!stupid_browser)
newRow.find("select[name='op']").focus()[0].selectedIndex = row.find("select[name='op']")[0].selectedIndex;
var jElem = newRow.find("select.vdata");
if (jElem[0] != null) // select doesn't copy it's selected index when cloned
jElem[0].selectedIndex = row.find("select.vdata")[0].selectedIndex;
} else {
newRow.find(".data input").val(""); // blank all input values
newRow.find("select[name='field']").focus();
}
if (opts.datepickerFix === true && jQuery.fn.datepicker !== undefined) { // using $.data to associate data with document elements is Not Good
row.find(".hasDatepicker").each(function() {
var settings = jQuery.data(this, "datepicker").settings;
newRow.find("#" + this.id).unbind().removeAttr("id").removeClass("hasDatepicker").datepicker(settings);
});
}
newRow.find("select[name='field']").change(function(event){event.stopPropagation();} );
return false;
});
jQ.find(".ui-search").click(function(e) {
var ui = jQuery(jQ.selector); // pointer to search box wrapper element
var ruleGroup;
var group_op = ui.find("select[name='groupOp'] :selected").val(); // puls "AND" or "OR"
if (!opts.stringResult) {
ruleGroup = {
groupOp: group_op,
rules: []
};
} else {
ruleGroup = "{\"groupOp\":\"" + group_op + "\",\"rules\":[";
}
ui.find(".sf").each(function(i) {
var tField = jQuery(this).find("select[name='field'] :selected").val();
var tOp = jQuery(this).find("select[name='op'] :selected").val();
var tData = jQuery(this).find("input.vdata,select.vdata :selected").val();
tData += "";
if (!opts.stringResult) {
ruleGroup.rules.push({
field: tField,
op: tOp,
data: tData
});
} else {
tData = tData.replace(/\\/g,'\\\\').replace(/\"/g,'\\"');
if (i > 0) ruleGroup += ",";
ruleGroup += "{\"field\":\"" + tField + "\",";
ruleGroup += "\"op\":\"" + tOp + "\",";
ruleGroup += "\"data\":\"" + tData + "\"}";
}
});
if (opts.stringResult) ruleGroup += "]}";
opts.onSearch(ruleGroup);
return false;
});
jQ.find(".ui-reset").click(function(e,op) {
var ui = jQuery(jQ.selector);
ui.find(".ui-del").click(); // removes all filters, resets the last one
ui.find("select[name='groupOp']")[0].selectedIndex = 0; // changes the op back to the default one
opts.onReset(op);
return false;
});
jQ.find(".ui-add-last").click(function() {
var row = jQuery(jQ.selector + " .sf:last");
var newRow = row.clone(true).insertAfter(row);
newRow.find(".ui-state-default").removeClass("ui-state-hover ui-state-active");
newRow.find(".data input").val(""); // blank all input values
newRow.find("select[name='field']").focus();
if (opts.datepickerFix === true && jQuery.fn.datepicker !== undefined) { // using $.data to associate data with document elements is Not Good
row.find(".hasDatepicker").each(function() {
var settings = jQuery.data(this, "datepicker").settings;
newRow.find("#" + this.id).unbind().removeAttr("id").removeClass("hasDatepicker").datepicker(settings);
});
}
newRow.find("select[name='field']").change(function(event){event.stopPropagation();});
return false;
});
this.setGroupOp = function(setting) {
/* a "setter" for groupping argument.
* ("AND" or "OR")
*
* Inputs:
* setting - a string
*
* Returns:
* Does not return anything. May add success / failure reporting in future versions.
*
* author: Daniel Dotsenko (dotsa@hotmail.com)
*/
selDOMobj = jQ.find("select[name='groupOp']")[0];
var indexmap = {}, l = selDOMobj.options.length, i;
for (i=0; i<l; i++) {
indexmap[selDOMobj.options[i].value] = i;
}
selDOMobj.selectedIndex = indexmap[setting];
jQuery(selDOMobj).change(function(event){event.stopPropagation();});
};
this.setFilter = function(settings) {
/* a "setter" for an arbitrary SearchFilter's filter line.
* designed to abstract the DOM manipulations required to infer
* a particular filter is a fit to the search box.
*
* Inputs:
* settings - an "object" (dictionary)
* index (optional*) (to be implemented in the future) : signed integer index (from top to bottom per DOM) of the filter line to fill.
* Negative integers (rooted in -1 and lower) denote position of the line from the bottom.
* sfref (optional*) : DOM object referencing individual '.sf' (normally a TR element) to be populated. (optional)
* filter (mandatory) : object (dictionary) of form {'field':'field_value','op':'op_value','data':'data value'}
*
* * It is mandatory to have either index or sfref defined.
*
* Returns:
* Does not return anything. May add success / failure reporting in future versions.
*
* author: Daniel Dotsenko (dotsa@hotmail.com)
*/
var o = settings['sfref'], filter = settings['filter'];
// setting up valueindexmap that we will need to manipulate SELECT elements.
var fields = [], i, j , l, lj, li,
valueindexmap = {};
// example of valueindexmap:
// {'field1':{'index':0,'ops':{'eq':0,'ne':1}},'fieldX':{'index':1,'ops':{'eq':0,'ne':1},'data':{'true':0,'false':1}}},
// if data is undefined it's a INPUT field. If defined, it's SELECT
selDOMobj = o.find("select[name='field']")[0];
for (i=0, l=selDOMobj.options.length; i<l; i++) {
valueindexmap[selDOMobj.options[i].value] = {'index':i,'ops':{}};
fields.push(selDOMobj.options[i].value);
}
for (i=0, li=fields.length; i < li; i++) {
selDOMobj = o.find(".ops > select[class='field"+i+"']")[0];
if (selDOMobj) {
for (j=0, lj=selDOMobj.options.length; j<lj; j++) {
valueindexmap[fields[i]]['ops'][selDOMobj.options[j].value] = j;
}
}
selDOMobj = o.find(".data > select[class='field"+i+"']")[0];
if (selDOMobj) {
valueindexmap[fields[i]]['data'] = {}; // this setting is the flag that 'data' is contained in a SELECT
for (j=0, lj=selDOMobj.options.length; j<lj; j++) {
valueindexmap[fields[i]]['data'][selDOMobj.options[j].value] = j;
}
}
} // done populating valueindexmap
// preparsing the index values for SELECT elements.
var fieldvalue, fieldindex, opindex, datavalue, dataindex;
fieldvalue = filter['field'];
if (valueindexmap[fieldvalue]) {
fieldindex = valueindexmap[fieldvalue]['index'];
}
if (fieldindex != null) {
opindex = valueindexmap[fieldvalue]['ops'][filter['op']];
if(opindex === undefined) {
for(i=0,li=options.operators.length; i<li;i++) {
if(options.operators[i].op == filter.op ){
opindex = i;
break;
}
}
}
datavalue = filter['data'];
if (valueindexmap[fieldvalue]['data'] == null) {
dataindex = -1; // 'data' is not SELECT, Making the var 'defined'
} else {
dataindex = valueindexmap[fieldvalue]['data'][datavalue]; // 'undefined' may come from here.
}
}
// only if values for 'field' and 'op' and 'data' are 'found' in mapping...
if (fieldindex != null && opindex != null && dataindex != null) {
o.find("select[name='field']")[0].selectedIndex = fieldindex;
o.find("select[name='field']").change();
o.find("select[name='op']")[0].selectedIndex = opindex;
o.find("input.vdata").val(datavalue); // if jquery does not find any INPUT, it does not set any. This means we deal with SELECT
o = o.find("select.vdata")[0];
if (o) {
o.selectedIndex = dataindex;
}
return true
} else {
return false
}
}; // end of this.setFilter fn
} // end of if fields != null
}
return new SearchFilter(this, fields, options);
};
jQuery.fn.searchFilter.version = '1.2.9';
/* This property contains the default options */
jQuery.fn.searchFilter.defaults = {
/*
* PROPERTY
* TYPE: boolean
* DESCRIPTION: clone a row if it is added from an existing row
* when false, any new added rows will be blank.
*/
clone: true,
/*
* PROPERTY
* TYPE: boolean
* DESCRIPTION: current version of datepicker uses a data store,
* which is incompatible with $().clone(true)
*/
datepickerFix: true,
/*
* FUNCTION
* DESCRIPTION: the function that will be called when the user clicks Reset
* INPUT TYPE: JS object if stringResult is false, otherwise is JSON string
*/
onReset: function(data) { alert("Reset Clicked. Data Returned: " + data) },
/*
* FUNCTION
* DESCRIPTION: the function that will be called when the user clicks Search
* INPUT TYPE: JS object if stringResult is false, otherwise is JSON string
*/
onSearch: function(data) { alert("Search Clicked. Data Returned: " + data) },
/*
* FUNCTION
* DESCRIPTION: the function that will be called when the user clicks the Closer icon
* or the close() function is called
* if left null, it simply does a .hide() on the searchFilter
* INPUT TYPE: a jQuery object for the searchFilter
*/
onClose: function(jElem) { jElem.hide(); },
/*
* PROPERTY
* TYPE: array of objects, each object has the properties op and text
* DESCRIPTION: the selectable operators that are applied between rules
* e.g. for {op:"AND", text:"all"}
* the search filter box will say: match all rules
* the server should interpret this as putting the AND op between each rule:
* rule1 AND rule2 AND rule3
* text will be the option text, and op will be the option value
*/
groupOps: [
{ op: "AND", text: "all" },
{ op: "OR", text: "any" }
],
/*
* PROPERTY
* TYPE: array of objects, each object has the properties op and text
* DESCRIPTION: the operators that will appear as drop-down options
* text will be the option text, and op will be the option value
*/
operators: [
{ op: "eq", text: "is equal to" },
{ op: "ne", text: "is not equal to" },
{ op: "lt", text: "is less than" },
{ op: "le", text: "is less or equal to" },
{ op: "gt", text: "is greater than" },
{ op: "ge", text: "is greater or equal to" },
{ op: "in", text: "is in" },
{ op: "ni", text: "is not in" },
{ op: "bw", text: "begins with" },
{ op: "bn", text: "does not begin with" },
{ op: "ew", text: "ends with" },
{ op: "en", text: "does not end with" },
{ op: "cn", text: "contains" },
{ op: "nc", text: "does not contain" }
],
/*
* PROPERTY
* TYPE: string
* DESCRIPTION: part of the phrase: _match_ ANY/ALL rules
*/
matchText: "match",
/*
* PROPERTY
* TYPE: string
* DESCRIPTION: part of the phrase: match ANY/ALL _rules_
*/
rulesText: "rules",
/*
* PROPERTY
* TYPE: string
* DESCRIPTION: the text that will be displayed in the reset button
*/
resetText: "Reset",
/*
* PROPERTY
* TYPE: string
* DESCRIPTION: the text that will be displayed in the search button
*/
searchText: "Search",
/*
* PROPERTY
* TYPE: boolean
* DESCRIPTION: a flag that, when set, will make the onSearch and onReset return strings instead of objects
*/
stringResult: true,
/*
* PROPERTY
* TYPE: string
* DESCRIPTION: the title of the searchFilter window
*/
windowTitle: "Search Rules",
/*
* PROPERTY
* TYPE: object
* DESCRIPTION: options to extend the ajax request
*/
ajaxSelectOptions : {}
}; /* end of searchFilter */ | JavaScript |
/*
* ContextMenu - jQuery plugin for right-click context menus
*
* Author: Chris Domigan
* Contributors: Dan G. Switzer, II
* Parts of this plugin are inspired by Joern Zaefferer's Tooltip plugin
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Version: r2
* Date: 16 July 2007
*
* For documentation visit http://www.trendskitchens.co.nz/jquery/contextmenu/
*
*/
(function($) {
var menu, shadow, content, hash, currentTarget;
var defaults = {
menuStyle: {
listStyle: 'none',
padding: '1px',
margin: '0px',
backgroundColor: '#fff',
border: '1px solid #999',
width: '100px'
},
itemStyle: {
margin: '0px',
color: '#000',
display: 'block',
cursor: 'default',
padding: '3px',
border: '1px solid #fff',
backgroundColor: 'transparent'
},
itemHoverStyle: {
border: '1px solid #0a246a',
backgroundColor: '#b6bdd2'
},
eventPosX: 'pageX',
eventPosY: 'pageY',
shadow : true,
onContextMenu: null,
onShowMenu: null
};
$.fn.contextMenu = function(id, options) {
if (!menu) { // Create singleton menu
menu = $('<div id="jqContextMenu"></div>')
.hide()
.css({position:'absolute', zIndex:'500'})
.appendTo('body')
.bind('click', function(e) {
e.stopPropagation();
});
}
if (!shadow) {
shadow = $('<div></div>')
.css({backgroundColor:'#000',position:'absolute',opacity:0.2,zIndex:499})
.appendTo('body')
.hide();
}
hash = hash || [];
hash.push({
id : id,
menuStyle: $.extend({}, defaults.menuStyle, options.menuStyle || {}),
itemStyle: $.extend({}, defaults.itemStyle, options.itemStyle || {}),
itemHoverStyle: $.extend({}, defaults.itemHoverStyle, options.itemHoverStyle || {}),
bindings: options.bindings || {},
shadow: options.shadow || options.shadow === false ? options.shadow : defaults.shadow,
onContextMenu: options.onContextMenu || defaults.onContextMenu,
onShowMenu: options.onShowMenu || defaults.onShowMenu,
eventPosX: options.eventPosX || defaults.eventPosX,
eventPosY: options.eventPosY || defaults.eventPosY
});
var index = hash.length - 1;
$(this).bind('contextmenu', function(e) {
// Check if onContextMenu() defined
var bShowContext = (!!hash[index].onContextMenu) ? hash[index].onContextMenu(e) : true;
currentTarget = e.target;
if (bShowContext) {
display(index, this, e );
return false;
}
});
return this;
};
function display(index, trigger, e ) {
var cur = hash[index];
content = $('#'+cur.id).find('ul:first').clone(true);
content.css(cur.menuStyle).find('li').css(cur.itemStyle).hover(
function() {
$(this).css(cur.itemHoverStyle);
},
function(){
$(this).css(cur.itemStyle);
}
).find('img').css({verticalAlign:'middle',paddingRight:'2px'});
// Send the content to the menu
menu.html(content);
// if there's an onShowMenu, run it now -- must run after content has been added
// if you try to alter the content variable before the menu.html(), IE6 has issues
// updating the content
if (!!cur.onShowMenu) menu = cur.onShowMenu(e, menu);
$.each(cur.bindings, function(id, func) {
$('#'+id, menu).bind('click', function() {
hide();
func(trigger, currentTarget);
});
});
menu.css({'left':e[cur.eventPosX],'top':e[cur.eventPosY]}).show();
if (cur.shadow) shadow.css({width:menu.width(),height:menu.height(),left:e.pageX+2,top:e.pageY+2}).show();
$(document).one('click', hide);
}
function hide() {
menu.hide();
shadow.hide();
}
// Apply defaults
$.contextMenu = {
defaults : function(userDefaults) {
$.each(userDefaults, function(i, val) {
if (typeof val == 'object' && defaults[i]) {
$.extend(defaults[i], val);
}
else defaults[i] = val;
});
}
};
})(jQuery);
$(function() {
$('div.contextMenu').hide();
}); | JavaScript |
/**
* TableDnD plug-in for JQuery, allows you to drag and drop table rows
* You can set up various options to control how the system will work
* Copyright (c) Denis Howlett <denish@isocra.com>
* Licensed like jQuery, see http://docs.jquery.com/License.
*
* Configuration options:
*
* onDragStyle
* This is the style that is assigned to the row during drag. There are limitations to the styles that can be
* associated with a row (such as you can't assign a border--well you can, but it won't be
* displayed). (So instead consider using onDragClass.) The CSS style to apply is specified as
* a map (as used in the jQuery css(...) function).
* onDropStyle
* This is the style that is assigned to the row when it is dropped. As for onDragStyle, there are limitations
* to what you can do. Also this replaces the original style, so again consider using onDragClass which
* is simply added and then removed on drop.
* onDragClass
* This class is added for the duration of the drag and then removed when the row is dropped. It is more
* flexible than using onDragStyle since it can be inherited by the row cells and other content. The default
* is class is tDnD_whileDrag. So to use the default, simply customise this CSS class in your
* stylesheet.
* onDrop
* Pass a function that will be called when the row is dropped. The function takes 2 parameters: the table
* and the row that was dropped. You can work out the new order of the rows by using
* table.rows.
* onDragStart
* Pass a function that will be called when the user starts dragging. The function takes 2 parameters: the
* table and the row which the user has started to drag.
* onAllowDrop
* Pass a function that will be called as a row is over another row. If the function returns true, allow
* dropping on that row, otherwise not. The function takes 2 parameters: the dragged row and the row under
* the cursor. It returns a boolean: true allows the drop, false doesn't allow it.
* scrollAmount
* This is the number of pixels to scroll if the user moves the mouse cursor to the top or bottom of the
* window. The page should automatically scroll up or down as appropriate (tested in IE6, IE7, Safari, FF2,
* FF3 beta
* dragHandle
* This is the name of a class that you assign to one or more cells in each row that is draggable. If you
* specify this class, then you are responsible for setting cursor: move in the CSS and only these cells
* will have the drag behaviour. If you do not specify a dragHandle, then you get the old behaviour where
* the whole row is draggable.
*
* Other ways to control behaviour:
*
* Add class="nodrop" to any rows for which you don't want to allow dropping, and class="nodrag" to any rows
* that you don't want to be draggable.
*
* Inside the onDrop method you can also call $.tableDnD.serialize() this returns a string of the form
* <tableID>[]=<rowID1>&<tableID>[]=<rowID2> so that you can send this back to the server. The table must have
* an ID as must all the rows.
*
* Other methods:
*
* $("...").tableDnDUpdate()
* Will update all the matching tables, that is it will reapply the mousedown method to the rows (or handle cells).
* This is useful if you have updated the table rows using Ajax and you want to make the table draggable again.
* The table maintains the original configuration (so you don't have to specify it again).
*
* $("...").tableDnDSerialize()
* Will serialize and return the serialized string as above, but for each of the matching tables--so it can be
* called from anywhere and isn't dependent on the currentTable being set up correctly before calling
*
* Known problems:
* - Auto-scoll has some problems with IE7 (it scrolls even when it shouldn't), work-around: set scrollAmount to 0
*
* Version 0.2: 2008-02-20 First public version
* Version 0.3: 2008-02-07 Added onDragStart option
* Made the scroll amount configurable (default is 5 as before)
* Version 0.4: 2008-03-15 Changed the noDrag/noDrop attributes to nodrag/nodrop classes
* Added onAllowDrop to control dropping
* Fixed a bug which meant that you couldn't set the scroll amount in both directions
* Added serialize method
* Version 0.5: 2008-05-16 Changed so that if you specify a dragHandle class it doesn't make the whole row
* draggable
* Improved the serialize method to use a default (and settable) regular expression.
* Added tableDnDupate() and tableDnDSerialize() to be called when you are outside the table
*/
jQuery.tableDnD = {
/** Keep hold of the current table being dragged */
currentTable : null,
/** Keep hold of the current drag object if any */
dragObject: null,
/** The current mouse offset */
mouseOffset: null,
/** Remember the old value of Y so that we don't do too much processing */
oldY: 0,
/** Actually build the structure */
build: function(options) {
// Set up the defaults if any
this.each(function() {
// This is bound to each matching table, set up the defaults and override with user options
this.tableDnDConfig = jQuery.extend({
onDragStyle: null,
onDropStyle: null,
// Add in the default class for whileDragging
onDragClass: "tDnD_whileDrag",
onDrop: null,
onDragStart: null,
scrollAmount: 5,
serializeRegexp: /[^\-]*$/, // The regular expression to use to trim row IDs
serializeParamName: null, // If you want to specify another parameter name instead of the table ID
dragHandle: null // If you give the name of a class here, then only Cells with this class will be draggable
}, options || {});
// Now make the rows draggable
jQuery.tableDnD.makeDraggable(this);
});
// Now we need to capture the mouse up and mouse move event
// We can use bind so that we don't interfere with other event handlers
jQuery(document)
.bind('mousemove', jQuery.tableDnD.mousemove)
.bind('mouseup', jQuery.tableDnD.mouseup);
// Don't break the chain
return this;
},
/** This function makes all the rows on the table draggable apart from those marked as "NoDrag" */
makeDraggable: function(table) {
var config = table.tableDnDConfig;
if (table.tableDnDConfig.dragHandle) {
// We only need to add the event to the specified cells
var cells = jQuery("td."+table.tableDnDConfig.dragHandle, table);
cells.each(function() {
// The cell is bound to "this"
jQuery(this).mousedown(function(ev) {
jQuery.tableDnD.dragObject = this.parentNode;
jQuery.tableDnD.currentTable = table;
jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
if (config.onDragStart) {
// Call the onDrop method if there is one
config.onDragStart(table, this);
}
return false;
});
})
} else {
// For backwards compatibility, we add the event to the whole row
var rows = jQuery("tr", table); // get all the rows as a wrapped set
rows.each(function() {
// Iterate through each row, the row is bound to "this"
var row = jQuery(this);
if (! row.hasClass("nodrag")) {
row.mousedown(function(ev) {
if (ev.target.tagName == "TD") {
jQuery.tableDnD.dragObject = this;
jQuery.tableDnD.currentTable = table;
jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
if (config.onDragStart) {
// Call the onDrop method if there is one
config.onDragStart(table, this);
}
return false;
}
}).css("cursor", "move"); // Store the tableDnD object
}
});
}
},
updateTables: function() {
this.each(function() {
// this is now bound to each matching table
if (this.tableDnDConfig) {
jQuery.tableDnD.makeDraggable(this);
}
})
},
/** Get the mouse coordinates from the event (allowing for browser differences) */
mouseCoords: function(ev){
if(ev.pageX || ev.pageY){
return {x:ev.pageX, y:ev.pageY};
}
return {
x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
y:ev.clientY + document.body.scrollTop - document.body.clientTop
};
},
/** Given a target element and a mouse event, get the mouse offset from that element.
To do this we need the element's position and the mouse position */
getMouseOffset: function(target, ev) {
ev = ev || window.event;
var docPos = this.getPosition(target);
var mousePos = this.mouseCoords(ev);
return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
},
/** Get the position of an element by going up the DOM tree and adding up all the offsets */
getPosition: function(e){
var left = 0;
var top = 0;
/** Safari fix -- thanks to Luis Chato for this! */
if (e.offsetHeight == 0) {
/** Safari 2 doesn't correctly grab the offsetTop of a table row
this is detailed here:
http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in-safari/
the solution is likewise noted there, grab the offset of a table cell in the row - the firstChild.
note that firefox will return a text node as a first child, so designing a more thorough
solution may need to take that into account, for now this seems to work in firefox, safari, ie */
e = e.firstChild; // a table cell
}
if (e && e.offsetParent) {
while (e.offsetParent){
left += e.offsetLeft;
top += e.offsetTop;
e = e.offsetParent;
}
left += e.offsetLeft;
top += e.offsetTop;
}
return {x:left, y:top};
},
mousemove: function(ev) {
if (jQuery.tableDnD.dragObject == null) {
return;
}
var dragObj = jQuery(jQuery.tableDnD.dragObject);
var config = jQuery.tableDnD.currentTable.tableDnDConfig;
var mousePos = jQuery.tableDnD.mouseCoords(ev);
var y = mousePos.y - jQuery.tableDnD.mouseOffset.y;
//auto scroll the window
var yOffset = window.pageYOffset;
if (document.all) {
// Windows version
//yOffset=document.body.scrollTop;
if (typeof document.compatMode != 'undefined' &&
document.compatMode != 'BackCompat') {
yOffset = document.documentElement.scrollTop;
}
else if (typeof document.body != 'undefined') {
yOffset=document.body.scrollTop;
}
}
if (mousePos.y-yOffset < config.scrollAmount) {
window.scrollBy(0, -config.scrollAmount);
} else {
var windowHeight = window.innerHeight ? window.innerHeight
: document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
if (windowHeight-(mousePos.y-yOffset) < config.scrollAmount) {
window.scrollBy(0, config.scrollAmount);
}
}
if (y != jQuery.tableDnD.oldY) {
// work out if we're going up or down...
var movingDown = y > jQuery.tableDnD.oldY;
// update the old value
jQuery.tableDnD.oldY = y;
// update the style to show we're dragging
if (config.onDragClass) {
dragObj.addClass(config.onDragClass);
} else {
dragObj.css(config.onDragStyle);
}
// If we're over a row then move the dragged row to there so that the user sees the
// effect dynamically
var currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y);
if (currentRow) {
// TODO worry about what happens when there are multiple TBODIES
if (movingDown && jQuery.tableDnD.dragObject != currentRow) {
jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow.nextSibling);
} else if (! movingDown && jQuery.tableDnD.dragObject != currentRow) {
jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow);
}
}
}
return false;
},
/** We're only worried about the y position really, because we can only move rows up and down */
findDropTargetRow: function(draggedRow, y) {
var rows = jQuery.tableDnD.currentTable.rows;
for (var i=0; i<rows.length; i++) {
var row = rows[i];
var rowY = this.getPosition(row).y;
var rowHeight = parseInt(row.offsetHeight)/2;
if (row.offsetHeight == 0) {
rowY = this.getPosition(row.firstChild).y;
rowHeight = parseInt(row.firstChild.offsetHeight)/2;
}
// Because we always have to insert before, we need to offset the height a bit
if ((y > rowY - rowHeight) && (y < (rowY + rowHeight))) {
// that's the row we're over
// If it's the same as the current row, ignore it
if (row == draggedRow) {return null;}
var config = jQuery.tableDnD.currentTable.tableDnDConfig;
if (config.onAllowDrop) {
if (config.onAllowDrop(draggedRow, row)) {
return row;
} else {
return null;
}
} else {
// If a row has nodrop class, then don't allow dropping (inspired by John Tarr and Famic)
var nodrop = jQuery(row).hasClass("nodrop");
if (! nodrop) {
return row;
} else {
return null;
}
}
return row;
}
}
return null;
},
mouseup: function(e) {
if (jQuery.tableDnD.currentTable && jQuery.tableDnD.dragObject) {
var droppedRow = jQuery.tableDnD.dragObject;
var config = jQuery.tableDnD.currentTable.tableDnDConfig;
// If we have a dragObject, then we need to release it,
// The row will already have been moved to the right place so we just reset stuff
if (config.onDragClass) {
jQuery(droppedRow).removeClass(config.onDragClass);
} else {
jQuery(droppedRow).css(config.onDropStyle);
}
jQuery.tableDnD.dragObject = null;
if (config.onDrop) {
// Call the onDrop method if there is one
config.onDrop(jQuery.tableDnD.currentTable, droppedRow);
}
jQuery.tableDnD.currentTable = null; // let go of the table too
}
},
serialize: function() {
if (jQuery.tableDnD.currentTable) {
return jQuery.tableDnD.serializeTable(jQuery.tableDnD.currentTable);
} else {
return "Error: No Table id set, you need to set an id on your table and every row";
}
},
serializeTable: function(table) {
var result = "";
var tableId = table.id;
var rows = table.rows;
for (var i=0; i<rows.length; i++) {
if (result.length > 0) result += "&";
var rowId = rows[i].id;
if (rowId && rowId && table.tableDnDConfig && table.tableDnDConfig.serializeRegexp) {
rowId = rowId.match(table.tableDnDConfig.serializeRegexp)[0];
}
result += tableId + '[]=' + rowId;
}
return result;
},
serializeTables: function() {
var result = "";
this.each(function() {
// this is now bound to each matching table
result += jQuery.tableDnD.serializeTable(this);
});
return result;
}
}
jQuery.fn.extend(
{
tableDnD : jQuery.tableDnD.build,
tableDnDUpdate : jQuery.tableDnD.updateTables,
tableDnDSerialize: jQuery.tableDnD.serializeTables
}
); | JavaScript |
(function($){
/*
* jqGrid methods without support. Use as you wish
* Tony Tomov tony@trirand.com
* http://trirand.com/blog/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl-2.0.html
*
* This list of deprecated methods.
* If you instead want to use them, please include this file after the grid main file.
* Some methods will be then overwritten.
*
*/
/*global jQuery, $ */
$.jgrid.extend({
// This is the ols search Filter method used in navigator.
searchGrid : function (p) {
p = $.extend({
recreateFilter: false,
drag: true,
sField:'searchField',
sValue:'searchString',
sOper: 'searchOper',
sFilter: 'filters',
loadDefaults: true, // this options activates loading of default filters from grid's postData for Multipe Search only.
beforeShowSearch: null,
afterShowSearch : null,
onInitializeSearch: null,
closeAfterSearch : false,
closeAfterReset: false,
closeOnEscape : false,
multipleSearch : false,
cloneSearchRowOnAdd: true,
// translation
// if you want to change or remove the order change it in sopt
// ['bw','eq','ne','lt','le','gt','ge','ew','cn']
sopt: null,
// Note: stringResult is intentionally declared "undefined by default".
// you are velcome to define stringResult expressly in the options you pass to searchGrid()
// stringResult is a "safeguard" measure to insure we post sensible data when communicated as form-encoded
// see http://github.com/tonytomov/jqGrid/issues/#issue/36
//
// If this value is not expressly defined in the incoming options,
// lower in the code we will infer the value based on value of multipleSearch
stringResult: undefined,
onClose : null,
// useDataProxy allows ADD, EDIT and DEL code to bypass calling $.ajax
// directly when grid's 'dataProxy' property (grid.p.dataProxy) is a function.
// Used for "editGridRow" and "delGridRow" below and automatically flipped to TRUE
// when ajax setting's 'url' (grid's 'editurl') property is undefined.
// When 'useDataProxy' is true, instead of calling $.ajax.call(gridDOMobj, o, i) we call
// gridDOMobj.p.dataProxy.call(gridDOMobj, o, i)
//
// Behavior is extremely similar to when 'datatype' is a function, but arguments are slightly different.
// Normally the following is fed to datatype.call(a, b, c):
// a = Pointer to grid's table DOM element, b = grid.p.postdata, c = "load_"+grid's ID
// In cases of "edit" and "del" the following is fed:
// a = Pointer to grid's table DOM element (same),
// b = extended Ajax Options including postdata in "data" property. (different object type)
// c = "set_"+grid's ID in case of "edit" and "del_"+grid's ID in case of "del" (same type, different content)
// The major difference is that complete ajax options object, with attached "complete" and "error"
// callback functions is fed instead of only post data.
// This allows you to emulate a $.ajax call (including calling "complete"/"error"),
// while retrieving the data locally in the browser.
useDataProxy: false,
overlay : true
}, $.jgrid.search, p || {});
return this.each(function() {
var $t = this;
if(!$t.grid) {return;}
var fid = "fbox_"+$t.p.id,
showFrm = true;
function applyDefaultFilters(gridDOMobj, filterSettings) {
/*
gridDOMobj = ointer to grid DOM object ( $(#list)[0] )
What we need from gridDOMobj:
gridDOMobj.SearchFilter is the pointer to the Search box, once it's created.
gridDOMobj.p.postData - dictionary of post settings. These can be overriden at grid creation to
contain default filter settings. We will parse these and will populate the search with defaults.
filterSettings - same settings object you (would) pass to $().jqGrid('searchGrid', filterSettings);
*/
// Pulling default filter settings out of postData property of grid's properties.:
var defaultFilters = gridDOMobj.p.postData[filterSettings.sFilter];
// example of what we might get: {"groupOp":"and","rules":[{"field":"amount","op":"eq","data":"100"}]}
// suppose we have imported this with grid import, the this is a string.
if(typeof(defaultFilters) == "string") {
defaultFilters = $.jgrid.parse(defaultFilters);
}
if (defaultFilters) {
if (defaultFilters.groupOp) {
gridDOMobj.SearchFilter.setGroupOp(defaultFilters.groupOp);
}
if (defaultFilters.rules) {
var f, i = 0, li = defaultFilters.rules.length, success = false;
for (; i < li; i++) {
f = defaultFilters.rules[i];
// we are not trying to counter all issues with filter declaration here. Just the basics to avoid lookup exceptions.
if (f.field !== undefined && f.op !== undefined && f.data !== undefined) {
success = gridDOMobj.SearchFilter.setFilter({
'sfref':gridDOMobj.SearchFilter.$.find(".sf:last"),
'filter':$.extend({},f)
});
if (success) { gridDOMobj.SearchFilter.add(); }
}
}
}
}
} // end of applyDefaultFilters
function hideFilter(selector) {
if(p.onClose){
var fclm = p.onClose(selector);
if(typeof fclm == 'boolean' && !fclm) { return; }
}
selector.hide();
if(p.overlay === true) {
$(".jqgrid-overlay:first","#gbox_"+$t.p.id).hide();
}
}
function showFilter(){
var fl = $(".ui-searchFilter").length;
if(fl > 1) {
var zI = $("#"+fid).css("zIndex");
$("#"+fid).css({zIndex:parseInt(zI,10)+fl});
}
$("#"+fid).show();
if(p.overlay === true) {
$(".jqgrid-overlay:first","#gbox_"+$t.p.id).show();
}
try{$(':input:visible',"#"+fid)[0].focus();}catch(_){}
}
function searchFilters(filters) {
var hasFilters = (filters !== undefined),
grid = $("#"+$t.p.id),
sdata={};
if(p.multipleSearch===false) {
sdata[p.sField] = filters.rules[0].field;
sdata[p.sValue] = filters.rules[0].data;
sdata[p.sOper] = filters.rules[0].op;
if(sdata.hasOwnProperty(p.sFilter) ) {
delete sdata[p.sFilter];
}
} else {
sdata[p.sFilter] = filters;
$.each([p.sField, p.sValue, p.sOper], function(i, n){
if(sdata.hasOwnProperty(n)) { delete sdata[n];}
});
}
grid[0].p.search = hasFilters;
$.extend(grid[0].p.postData,sdata);
grid.trigger("reloadGrid",[{page:1}]);
if(p.closeAfterSearch) { hideFilter($("#"+fid)); }
}
function resetFilters(op) {
var reload = op && op.hasOwnProperty("reload") ? op.reload : true,
grid = $("#"+$t.p.id),
sdata={};
grid[0].p.search = false;
if(p.multipleSearch===false) {
sdata[p.sField] = sdata[p.sValue] = sdata[p.sOper] = "";
} else {
sdata[p.sFilter] = "";
}
$.extend(grid[0].p.postData,sdata);
if(reload) {
grid.trigger("reloadGrid",[{page:1}]);
}
if(p.closeAfterReset) { hideFilter($("#"+fid)); }
}
if($.fn.searchFilter) {
if(p.recreateFilter===true) {$("#"+fid).remove();}
if( $("#"+fid).html() !== null ) {
if ( $.isFunction(p.beforeShowSearch) ) {
showFrm = p.beforeShowSearch($("#"+fid));
if(typeof(showFrm) == "undefined") {
showFrm = true;
}
}
if(showFrm === false) { return; }
showFilter();
if( $.isFunction(p.afterShowSearch) ) { p.afterShowSearch($("#"+fid)); }
} else {
var fields = [],
colNames = $("#"+$t.p.id).jqGrid("getGridParam","colNames"),
colModel = $("#"+$t.p.id).jqGrid("getGridParam","colModel"),
stempl = ['eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc'],
j,pos,k,oprtr=[];
if (p.sopt !==null) {
k=0;
for(j=0;j<p.sopt.length;j++) {
if( (pos= $.inArray(p.sopt[j],stempl)) != -1 ){
oprtr[k] = {op:p.sopt[j],text: p.odata[pos]};
k++;
}
}
} else {
for(j=0;j<stempl.length;j++) {
oprtr[j] = {op:stempl[j],text: p.odata[j]};
}
}
$.each(colModel, function(i, v) {
var searchable = (typeof v.search === 'undefined') ? true: v.search ,
hidden = (v.hidden === true),
soptions = $.extend({}, {text: colNames[i], itemval: v.index || v.name}, this.searchoptions),
ignoreHiding = (soptions.searchhidden === true);
if(typeof soptions.sopt !== 'undefined') {
k=0;
soptions.ops =[];
if(soptions.sopt.length>0) {
for(j=0;j<soptions.sopt.length;j++) {
if( (pos= $.inArray(soptions.sopt[j],stempl)) != -1 ){
soptions.ops[k] = {op:soptions.sopt[j],text: p.odata[pos]};
k++;
}
}
}
}
if(typeof(this.stype) === 'undefined') { this.stype='text'; }
if(this.stype == 'select') {
if ( soptions.dataUrl !== undefined) {}
else {
var eov;
if(soptions.value) {
eov = soptions.value;
} else if(this.editoptions) {
eov = this.editoptions.value;
}
if(eov) {
soptions.dataValues =[];
if(typeof(eov) === 'string') {
var so = eov.split(";"),sv;
for(j=0;j<so.length;j++) {
sv = so[j].split(":");
soptions.dataValues[j] ={value:sv[0],text:sv[1]};
}
} else if (typeof(eov) === 'object') {
j=0;
for (var key in eov) {
if(eov.hasOwnProperty(key)) {
soptions.dataValues[j] ={value:key,text:eov[key]};
j++;
}
}
}
}
}
}
if ((ignoreHiding && searchable) || (searchable && !hidden)) {
fields.push(soptions);
}
});
if(fields.length>0){
$("<div id='"+fid+"' role='dialog' tabindex='-1'></div>").insertBefore("#gview_"+$t.p.id);
// Before we create searchFilter we need to decide if we want to get back a string or a JS object.
// see http://github.com/tonytomov/jqGrid/issues/#issue/36 for background on the issue.
// If p.stringResult is defined, it was explisitly passed to us by user. Honor the choice, whatever it is.
if (p.stringResult===undefined) {
// to provide backward compatibility, inferring stringResult value from multipleSearch
p.stringResult = p.multipleSearch;
}
// we preserve the return value here to retain access to .add() and other good methods of search form.
$t.SearchFilter = $("#"+fid).searchFilter(fields, { groupOps: p.groupOps, operators: oprtr, onClose:hideFilter, resetText: p.Reset, searchText: p.Find, windowTitle: p.caption, rulesText:p.rulesText, matchText:p.matchText, onSearch: searchFilters, onReset: resetFilters,stringResult:p.stringResult, ajaxSelectOptions: $.extend({},$.jgrid.ajaxOptions,$t.p.ajaxSelectOptions ||{}), clone: p.cloneSearchRowOnAdd });
$(".ui-widget-overlay","#"+fid).remove();
if($t.p.direction=="rtl") { $(".ui-closer","#"+fid).css("float","left"); }
if (p.drag===true) {
$("#"+fid+" table thead tr:first td:first").css('cursor','move');
if(jQuery.fn.jqDrag) {
$("#"+fid).jqDrag($("#"+fid+" table thead tr:first td:first"));
} else {
try {
$("#"+fid).draggable({handle: $("#"+fid+" table thead tr:first td:first")});
} catch (e) {}
}
}
if(p.multipleSearch === false) {
$(".ui-del, .ui-add, .ui-del, .ui-add-last, .matchText, .rulesText", "#"+fid).hide();
$("select[name='groupOp']","#"+fid).hide();
}
if (p.multipleSearch === true && p.loadDefaults === true) {
applyDefaultFilters($t, p);
}
if ( $.isFunction(p.onInitializeSearch) ) { p.onInitializeSearch( $("#"+fid) ); }
if ( $.isFunction(p.beforeShowSearch) ) {
showFrm = p.beforeShowSearch($("#"+fid));
if(typeof(showFrm) == "undefined") {
showFrm = true;
}
}
if(showFrm === false) { return; }
showFilter();
if( $.isFunction(p.afterShowSearch) ) { p.afterShowSearch($("#"+fid)); }
if(p.closeOnEscape===true){
$("#"+fid).keydown( function( e ) {
if( e.which == 27 ) {
hideFilter($("#"+fid));
}
if (e.which == 13) {
$(".ui-search", this).click();
}
});
}
}
}
}
});
},
// methods taken from grid.custom.
updateGridRows : function (data, rowidname, jsonreader) {
var nm, success=false, title;
this.each(function(){
var t = this, vl, ind, srow, sid;
if(!t.grid) {return false;}
if(!rowidname) { rowidname = "id"; }
if( data && data.length >0 ) {
$(data).each(function(j){
srow = this;
ind = t.rows.namedItem(srow[rowidname]);
if(ind) {
sid = srow[rowidname];
if(jsonreader === true){
if(t.p.jsonReader.repeatitems === true) {
if(t.p.jsonReader.cell) {srow = srow[t.p.jsonReader.cell];}
for (var k=0;k<srow.length;k++) {
vl = t.formatter( sid, srow[k], k, srow, 'edit');
title = t.p.colModel[k].title ? {"title":$.jgrid.stripHtml(vl)} : {};
if(t.p.treeGrid===true && nm == t.p.ExpandColumn) {
$("td:eq("+k+") > span:first",ind).html(vl).attr(title);
} else {
$("td:eq("+k+")",ind).html(vl).attr(title);
}
}
success = true;
return true;
}
}
$(t.p.colModel).each(function(i){
nm = jsonreader===true ? this.jsonmap || this.name :this.name;
if( srow[nm] !== undefined) {
vl = t.formatter( sid, srow[nm], i, srow, 'edit');
title = this.title ? {"title":$.jgrid.stripHtml(vl)} : {};
if(t.p.treeGrid===true && nm == t.p.ExpandColumn) {
$("td:eq("+i+") > span:first",ind).html(vl).attr(title);
} else {
$("td:eq("+i+")",ind).html(vl).attr(title);
}
success = true;
}
});
}
});
}
});
return success;
},
// Form search - sorry for this method. Instead use ne jqFilter method.
filterGrid : function(gridid,p){
p = $.extend({
gridModel : false,
gridNames : false,
gridToolbar : false,
filterModel: [], // label/name/stype/defval/surl/sopt
formtype : "horizontal", // horizontal/vertical
autosearch: true, // if set to false a serch button should be enabled.
formclass: "filterform",
tableclass: "filtertable",
buttonclass: "filterbutton",
searchButton: "Search",
clearButton: "Clear",
enableSearch : false,
enableClear: false,
beforeSearch: null,
afterSearch: null,
beforeClear: null,
afterClear: null,
url : '',
marksearched: true
},p || {});
return this.each(function(){
var self = this;
this.p = p;
if(this.p.filterModel.length === 0 && this.p.gridModel===false) { alert("No filter is set"); return;}
if( !gridid) {alert("No target grid is set!"); return;}
this.p.gridid = gridid.indexOf("#") != -1 ? gridid : "#"+gridid;
var gcolMod = $(this.p.gridid).jqGrid("getGridParam",'colModel');
if(gcolMod) {
if( this.p.gridModel === true) {
var thegrid = $(this.p.gridid)[0];
var sh;
// we should use the options search, edittype, editoptions
// additionally surl and defval can be added in grid colModel
$.each(gcolMod, function (i,n) {
var tmpFil = [];
this.search = this.search === false ? false : true;
if(this.editrules && this.editrules.searchhidden === true) {
sh = true;
} else {
if(this.hidden === true ) {
sh = false;
} else {
sh = true;
}
}
if( this.search === true && sh === true) {
if(self.p.gridNames===true) {
tmpFil.label = thegrid.p.colNames[i];
} else {
tmpFil.label = '';
}
tmpFil.name = this.name;
tmpFil.index = this.index || this.name;
// we support only text and selects, so all other to text
tmpFil.stype = this.edittype || 'text';
if(tmpFil.stype != 'select' ) {
tmpFil.stype = 'text';
}
tmpFil.defval = this.defval || '';
tmpFil.surl = this.surl || '';
tmpFil.sopt = this.editoptions || {};
tmpFil.width = this.width;
self.p.filterModel.push(tmpFil);
}
});
} else {
$.each(self.p.filterModel,function(i,n) {
for(var j=0;j<gcolMod.length;j++) {
if(this.name == gcolMod[j].name) {
this.index = gcolMod[j].index || this.name;
break;
}
}
if(!this.index) {
this.index = this.name;
}
});
}
} else {
alert("Could not get grid colModel"); return;
}
var triggerSearch = function() {
var sdata={}, j=0, v;
var gr = $(self.p.gridid)[0], nm;
gr.p.searchdata = {};
if($.isFunction(self.p.beforeSearch)){self.p.beforeSearch();}
$.each(self.p.filterModel,function(i,n){
nm = this.index;
if(this.stype === 'select') {
v = $("select[name="+nm+"]",self).val();
if(v) {
sdata[nm] = v;
if(self.p.marksearched){
$("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell");
}
j++;
} else {
if(self.p.marksearched){
$("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell");
}
try {
delete gr.p.postData[this.index];
} catch (e) {}
}
} else {
v = $("input[name="+nm+"]",self).val();
if(v) {
sdata[nm] = v;
if(self.p.marksearched){
$("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell");
}
j++;
} else {
if(self.p.marksearched){
$("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell");
}
try {
delete gr.p.postData[this.index];
} catch(x) {}
}
}
});
var sd = j>0 ? true : false;
$.extend(gr.p.postData,sdata);
var saveurl;
if(self.p.url) {
saveurl = $(gr).jqGrid("getGridParam",'url');
$(gr).jqGrid("setGridParam",{url:self.p.url});
}
$(gr).jqGrid("setGridParam",{search:sd}).trigger("reloadGrid",[{page:1}]);
if(saveurl) {$(gr).jqGrid("setGridParam",{url:saveurl});}
if($.isFunction(self.p.afterSearch)){self.p.afterSearch();}
};
var clearSearch = function(){
var sdata={}, v, j=0;
var gr = $(self.p.gridid)[0], nm;
if($.isFunction(self.p.beforeClear)){self.p.beforeClear();}
$.each(self.p.filterModel,function(i,n){
nm = this.index;
v = (this.defval) ? this.defval : "";
if(!this.stype){this.stype='text';}
switch (this.stype) {
case 'select' :
var v1;
$("select[name="+nm+"] option",self).each(function (i){
if(i===0) { this.selected = true; }
if ($(this).text() == v) {
this.selected = true;
v1 = $(this).val();
return false;
}
});
if(v1) {
// post the key and not the text
sdata[nm] = v1;
if(self.p.marksearched){
$("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell");
}
j++;
} else {
if(self.p.marksearched){
$("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell");
}
try {
delete gr.p.postData[this.index];
} catch (e) {}
}
break;
case 'text':
$("input[name="+nm+"]",self).val(v);
if(v) {
sdata[nm] = v;
if(self.p.marksearched){
$("#jqgh_"+this.name,gr.grid.hDiv).addClass("dirty-cell");
}
j++;
} else {
if(self.p.marksearched){
$("#jqgh_"+this.name,gr.grid.hDiv).removeClass("dirty-cell");
}
try {
delete gr.p.postData[this.index];
} catch (k) {}
}
break;
}
});
var sd = j>0 ? true : false;
$.extend(gr.p.postData,sdata);
var saveurl;
if(self.p.url) {
saveurl = $(gr).jqGrid("getGridParam",'url');
$(gr).jqGrid("setGridParam",{url:self.p.url});
}
$(gr).jqGrid("setGridParam",{search:sd}).trigger("reloadGrid",[{page:1}]);
if(saveurl) {$(gr).jqGrid("setGridParam",{url:saveurl});}
if($.isFunction(self.p.afterClear)){self.p.afterClear();}
};
var tbl;
var formFill = function(){
var tr = document.createElement("tr");
var tr1, sb, cb,tl,td;
if(self.p.formtype=='horizontal'){
$(tbl).append(tr);
}
$.each(self.p.filterModel,function(i,n){
tl = document.createElement("td");
$(tl).append("<label for='"+this.name+"'>"+this.label+"</label>");
td = document.createElement("td");
var $t=this;
if(!this.stype) { this.stype='text';}
switch (this.stype)
{
case "select":
if(this.surl) {
// data returned should have already constructed html select
$(td).load(this.surl,function(){
if($t.defval) { $("select",this).val($t.defval); }
$("select",this).attr({name:$t.index || $t.name, id: "sg_"+$t.name});
if($t.sopt) { $("select",this).attr($t.sopt); }
if(self.p.gridToolbar===true && $t.width) {
$("select",this).width($t.width);
}
if(self.p.autosearch===true){
$("select",this).change(function(e){
triggerSearch();
return false;
});
}
});
} else {
// sopt to construct the values
if($t.sopt.value) {
var oSv = $t.sopt.value;
var elem = document.createElement("select");
$(elem).attr({name:$t.index || $t.name, id: "sg_"+$t.name}).attr($t.sopt);
var so, sv, ov;
if(typeof oSv === "string") {
so = oSv.split(";");
for(var k=0; k<so.length;k++){
sv = so[k].split(":");
ov = document.createElement("option");
ov.value = sv[0]; ov.innerHTML = sv[1];
if (sv[1]==$t.defval) { ov.selected ="selected"; }
elem.appendChild(ov);
}
} else if(typeof oSv === "object" ) {
for ( var key in oSv) {
if(oSv.hasOwnProperty(key)) {
i++;
ov = document.createElement("option");
ov.value = key; ov.innerHTML = oSv[key];
if (oSv[key]==$t.defval) { ov.selected ="selected"; }
elem.appendChild(ov);
}
}
}
if(self.p.gridToolbar===true && $t.width) {
$(elem).width($t.width);
}
$(td).append(elem);
if(self.p.autosearch===true){
$(elem).change(function(e){
triggerSearch();
return false;
});
}
}
}
break;
case 'text':
var df = this.defval ? this.defval: "";
$(td).append("<input type='text' name='"+(this.index || this.name)+"' id='sg_"+this.name+"' value='"+df+"'/>");
if($t.sopt) { $("input",td).attr($t.sopt); }
if(self.p.gridToolbar===true && $t.width) {
if($.browser.msie) {
$("input",td).width($t.width-4);
} else {
$("input",td).width($t.width-2);
}
}
if(self.p.autosearch===true){
$("input",td).keypress(function(e){
var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
if(key == 13){
triggerSearch();
return false;
}
return this;
});
}
break;
}
if(self.p.formtype=='horizontal'){
if(self.p.gridToolbar===true && self.p.gridNames===false) {
$(tr).append(td);
} else {
$(tr).append(tl).append(td);
}
$(tr).append(td);
} else {
tr1 = document.createElement("tr");
$(tr1).append(tl).append(td);
$(tbl).append(tr1);
}
});
td = document.createElement("td");
if(self.p.enableSearch === true){
sb = "<input type='button' id='sButton' class='"+self.p.buttonclass+"' value='"+self.p.searchButton+"'/>";
$(td).append(sb);
$("input#sButton",td).click(function(){
triggerSearch();
return false;
});
}
if(self.p.enableClear === true) {
cb = "<input type='button' id='cButton' class='"+self.p.buttonclass+"' value='"+self.p.clearButton+"'/>";
$(td).append(cb);
$("input#cButton",td).click(function(){
clearSearch();
return false;
});
}
if(self.p.enableClear === true || self.p.enableSearch === true) {
if(self.p.formtype=='horizontal') {
$(tr).append(td);
} else {
tr1 = document.createElement("tr");
$(tr1).append("<td> </td>").append(td);
$(tbl).append(tr1);
}
}
};
var frm = $("<form name='SearchForm' style=display:inline;' class='"+this.p.formclass+"'></form>");
tbl =$("<table class='"+this.p.tableclass+"' cellspacing='0' cellpading='0' border='0'><tbody></tbody></table>");
$(frm).append(tbl);
formFill();
$(this).append(frm);
this.triggerSearch = triggerSearch;
this.clearSearch = clearSearch;
});
}
});
})(jQuery);
| JavaScript |
/*
* jQuery UI Multiselect
*
* Authors:
* Michael Aufreiter (quasipartikel.at)
* Yanick Rochon (yanick.rochon[at]gmail[dot]com)
*
* Dual licensed under the MIT (MIT-LICENSE.txt)
* and GPL (GPL-LICENSE.txt) licenses.
*
* http://www.quasipartikel.at/multiselect/
*
*
* Depends:
* ui.core.js
* ui.sortable.js
*
* Optional:
* localization (http://plugins.jquery.com/project/localisation)
* scrollTo (http://plugins.jquery.com/project/ScrollTo)
*
* Todo:
* Make batch actions faster
* Implement dynamic insertion through remote calls
*/
(function($) {
$.widget("ui.multiselect", {
_init: function() {
this.element.hide();
this.id = this.element.attr("id");
this.container = $('<div class="ui-multiselect ui-helper-clearfix ui-widget"></div>').insertAfter(this.element);
this.count = 0; // number of currently selected options
this.selectedContainer = $('<div class="selected"></div>').appendTo(this.container);
this.availableContainer = $('<div class="available"></div>').appendTo(this.container);
this.selectedActions = $('<div class="actions ui-widget-header ui-helper-clearfix"><span class="count">0 '+$.ui.multiselect.locale.itemsCount+'</span><a href="#" class="remove-all">'+$.ui.multiselect.locale.removeAll+'</a></div>').appendTo(this.selectedContainer);
this.availableActions = $('<div class="actions ui-widget-header ui-helper-clearfix"><input type="text" class="search empty ui-widget-content ui-corner-all"/><a href="#" class="add-all">'+$.ui.multiselect.locale.addAll+'</a></div>').appendTo(this.availableContainer);
this.selectedList = $('<ul class="selected connected-list"><li class="ui-helper-hidden-accessible"></li></ul>').bind('selectstart', function(){return false;}).appendTo(this.selectedContainer);
this.availableList = $('<ul class="available connected-list"><li class="ui-helper-hidden-accessible"></li></ul>').bind('selectstart', function(){return false;}).appendTo(this.availableContainer);
var that = this;
// set dimensions
this.container.width(this.element.width()+1);
this.selectedContainer.width(Math.floor(this.element.width()*this.options.dividerLocation));
this.availableContainer.width(Math.floor(this.element.width()*(1-this.options.dividerLocation)));
// fix list height to match <option> depending on their individual header's heights
this.selectedList.height(Math.max(this.element.height()-this.selectedActions.height(),1));
this.availableList.height(Math.max(this.element.height()-this.availableActions.height(),1));
if ( !this.options.animated ) {
this.options.show = 'show';
this.options.hide = 'hide';
}
// init lists
this._populateLists(this.element.find('option'));
// make selection sortable
if (this.options.sortable) {
$("ul.selected").sortable({
placeholder: 'ui-state-highlight',
axis: 'y',
update: function(event, ui) {
// apply the new sort order to the original selectbox
that.selectedList.find('li').each(function() {
if ($(this).data('optionLink'))
$(this).data('optionLink').remove().appendTo(that.element);
});
},
receive: function(event, ui) {
ui.item.data('optionLink').attr('selected', true);
// increment count
that.count += 1;
that._updateCount();
// workaround, because there's no way to reference
// the new element, see http://dev.jqueryui.com/ticket/4303
that.selectedList.children('.ui-draggable').each(function() {
$(this).removeClass('ui-draggable');
$(this).data('optionLink', ui.item.data('optionLink'));
$(this).data('idx', ui.item.data('idx'));
that._applyItemState($(this), true);
});
// workaround according to http://dev.jqueryui.com/ticket/4088
setTimeout(function() { ui.item.remove(); }, 1);
}
});
}
// set up livesearch
if (this.options.searchable) {
this._registerSearchEvents(this.availableContainer.find('input.search'));
} else {
$('.search').hide();
}
// batch actions
$(".remove-all").click(function() {
that._populateLists(that.element.find('option').removeAttr('selected'));
return false;
});
$(".add-all").click(function() {
that._populateLists(that.element.find('option').attr('selected', 'selected'));
return false;
});
},
destroy: function() {
this.element.show();
this.container.remove();
$.widget.prototype.destroy.apply(this, arguments);
},
_populateLists: function(options) {
this.selectedList.children('.ui-element').remove();
this.availableList.children('.ui-element').remove();
this.count = 0;
var that = this;
var items = $(options.map(function(i) {
var item = that._getOptionNode(this).appendTo(this.selected ? that.selectedList : that.availableList).show();
if (this.selected) that.count += 1;
that._applyItemState(item, this.selected);
item.data('idx', i);
return item[0];
}));
// update count
this._updateCount();
},
_updateCount: function() {
this.selectedContainer.find('span.count').text(this.count+" "+$.ui.multiselect.locale.itemsCount);
},
_getOptionNode: function(option) {
option = $(option);
var node = $('<li class="ui-state-default ui-element" title="'+option.text()+'"><span class="ui-icon"/>'+option.text()+'<a href="#" class="action"><span class="ui-corner-all ui-icon"/></a></li>').hide();
node.data('optionLink', option);
return node;
},
// clones an item with associated data
// didn't find a smarter away around this
_cloneWithData: function(clonee) {
var clone = clonee.clone();
clone.data('optionLink', clonee.data('optionLink'));
clone.data('idx', clonee.data('idx'));
return clone;
},
_setSelected: function(item, selected) {
item.data('optionLink').attr('selected', selected);
if (selected) {
var selectedItem = this._cloneWithData(item);
item[this.options.hide](this.options.animated, function() { $(this).remove(); });
selectedItem.appendTo(this.selectedList).hide()[this.options.show](this.options.animated);
this._applyItemState(selectedItem, true);
return selectedItem;
} else {
// look for successor based on initial option index
var items = this.availableList.find('li'), comparator = this.options.nodeComparator;
var succ = null, i = item.data('idx'), direction = comparator(item, $(items[i]));
// TODO: test needed for dynamic list populating
if ( direction ) {
while (i>=0 && i<items.length) {
direction > 0 ? i++ : i--;
if ( direction != comparator(item, $(items[i])) ) {
// going up, go back one item down, otherwise leave as is
succ = items[direction > 0 ? i : i+1];
break;
}
}
} else {
succ = items[i];
}
var availableItem = this._cloneWithData(item);
succ ? availableItem.insertBefore($(succ)) : availableItem.appendTo(this.availableList);
item[this.options.hide](this.options.animated, function() { $(this).remove(); });
availableItem.hide()[this.options.show](this.options.animated);
this._applyItemState(availableItem, false);
return availableItem;
}
},
_applyItemState: function(item, selected) {
if (selected) {
if (this.options.sortable)
item.children('span').addClass('ui-icon-arrowthick-2-n-s').removeClass('ui-helper-hidden').addClass('ui-icon');
else
item.children('span').removeClass('ui-icon-arrowthick-2-n-s').addClass('ui-helper-hidden').removeClass('ui-icon');
item.find('a.action span').addClass('ui-icon-minus').removeClass('ui-icon-plus');
this._registerRemoveEvents(item.find('a.action'));
} else {
item.children('span').removeClass('ui-icon-arrowthick-2-n-s').addClass('ui-helper-hidden').removeClass('ui-icon');
item.find('a.action span').addClass('ui-icon-plus').removeClass('ui-icon-minus');
this._registerAddEvents(item.find('a.action'));
}
this._registerHoverEvents(item);
},
// taken from John Resig's liveUpdate script
_filter: function(list) {
var input = $(this);
var rows = list.children('li'),
cache = rows.map(function(){
return $(this).text().toLowerCase();
});
var term = $.trim(input.val().toLowerCase()), scores = [];
if (!term) {
rows.show();
} else {
rows.hide();
cache.each(function(i) {
if (this.indexOf(term)>-1) { scores.push(i); }
});
$.each(scores, function() {
$(rows[this]).show();
});
}
},
_registerHoverEvents: function(elements) {
elements.removeClass('ui-state-hover');
elements.mouseover(function() {
$(this).addClass('ui-state-hover');
});
elements.mouseout(function() {
$(this).removeClass('ui-state-hover');
});
},
_registerAddEvents: function(elements) {
var that = this;
elements.click(function() {
var item = that._setSelected($(this).parent(), true);
that.count += 1;
that._updateCount();
return false;
})
// make draggable
.each(function() {
$(this).parent().draggable({
connectToSortable: 'ul.selected',
helper: function() {
var selectedItem = that._cloneWithData($(this)).width($(this).width() - 50);
selectedItem.width($(this).width());
return selectedItem;
},
appendTo: '.ui-multiselect',
containment: '.ui-multiselect',
revert: 'invalid'
});
});
},
_registerRemoveEvents: function(elements) {
var that = this;
elements.click(function() {
that._setSelected($(this).parent(), false);
that.count -= 1;
that._updateCount();
return false;
});
},
_registerSearchEvents: function(input) {
var that = this;
input.focus(function() {
$(this).addClass('ui-state-active');
})
.blur(function() {
$(this).removeClass('ui-state-active');
})
.keypress(function(e) {
if (e.keyCode == 13)
return false;
})
.keyup(function() {
that._filter.apply(this, [that.availableList]);
});
}
});
$.extend($.ui.multiselect, {
defaults: {
sortable: true,
searchable: true,
animated: 'fast',
show: 'slideDown',
hide: 'slideUp',
dividerLocation: 0.6,
nodeComparator: function(node1,node2) {
var text1 = node1.text(),
text2 = node2.text();
return text1 == text2 ? 0 : (text1 < text2 ? -1 : 1);
}
},
locale: {
addAll:'Add all',
removeAll:'Remove all',
itemsCount:'items selected'
}
});
})(jQuery);
| JavaScript |
;(function($){
/**
* jqGrid extension for manipulating columns properties
* Piotr Roznicki roznicki@o2.pl
* http://www.roznicki.prv.pl
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl-2.0.html
**/
$.jgrid.extend({
setColumns : function(p) {
p = $.extend({
top : 0,
left: 0,
width: 200,
height: 'auto',
dataheight: 'auto',
modal: false,
drag: true,
beforeShowForm: null,
afterShowForm: null,
afterSubmitForm: null,
closeOnEscape : true,
ShrinkToFit : false,
jqModal : false,
saveicon: [true,"left","ui-icon-disk"],
closeicon: [true,"left","ui-icon-close"],
onClose : null,
colnameview : true,
closeAfterSubmit : true,
updateAfterCheck : false,
recreateForm : false
}, $.jgrid.col, p ||{});
return this.each(function(){
var $t = this;
if (!$t.grid ) { return; }
var onBeforeShow = typeof p.beforeShowForm === 'function' ? true: false;
var onAfterShow = typeof p.afterShowForm === 'function' ? true: false;
var onAfterSubmit = typeof p.afterSubmitForm === 'function' ? true: false;
var gID = $t.p.id,
dtbl = "ColTbl_"+gID,
IDs = {themodal:'colmod'+gID,modalhead:'colhd'+gID,modalcontent:'colcnt'+gID, scrollelm: dtbl};
if(p.recreateForm===true && $("#"+IDs.themodal).html() != null) {
$("#"+IDs.themodal).remove();
}
if ( $("#"+IDs.themodal).html() != null ) {
if(onBeforeShow) { p.beforeShowForm($("#"+dtbl)); }
$.jgrid.viewModal("#"+IDs.themodal,{gbox:"#gbox_"+gID,jqm:p.jqModal, jqM:false, modal:p.modal});
if(onAfterShow) { p.afterShowForm($("#"+dtbl)); }
} else {
var dh = isNaN(p.dataheight) ? p.dataheight : p.dataheight+"px";
var formdata = "<div id='"+dtbl+"' class='formdata' style='width:100%;overflow:auto;position:relative;height:"+dh+";'>";
formdata += "<table class='ColTable' cellspacing='1' cellpading='2' border='0'><tbody>";
for(i=0;i<this.p.colNames.length;i++){
if(!$t.p.colModel[i].hidedlg) { // added from T. Tomov
formdata += "<tr><td style='white-space: pre;'><input type='checkbox' style='margin-right:5px;' id='col_" + this.p.colModel[i].name + "' class='cbox' value='T' " +
((this.p.colModel[i].hidden===false)?"checked":"") + "/>" + "<label for='col_" + this.p.colModel[i].name + "'>" + this.p.colNames[i] + ((p.colnameview) ? " (" + this.p.colModel[i].name + ")" : "" )+ "</label></td></tr>";
}
}
formdata += "</tbody></table></div>"
var bS = !p.updateAfterCheck ? "<a href='javascript:void(0)' id='dData' class='fm-button ui-state-default ui-corner-all'>"+p.bSubmit+"</a>" : "",
bC ="<a href='javascript:void(0)' id='eData' class='fm-button ui-state-default ui-corner-all'>"+p.bCancel+"</a>";
formdata += "<table border='0' class='EditTable' id='"+dtbl+"_2'><tbody><tr style='display:block;height:3px;'><td></td></tr><tr><td class='DataTD ui-widget-content'></td></tr><tr><td class='ColButton EditButton'>"+bS+" "+bC+"</td></tr></tbody></table>";
p.gbox = "#gbox_"+gID;
$.jgrid.createModal(IDs,formdata,p,"#gview_"+$t.p.id,$("#gview_"+$t.p.id)[0]);
if(p.saveicon[0]==true) {
$("#dData","#"+dtbl+"_2").addClass(p.saveicon[1] == "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
.append("<span class='ui-icon "+p.saveicon[2]+"'></span>");
}
if(p.closeicon[0]==true) {
$("#eData","#"+dtbl+"_2").addClass(p.closeicon[1] == "right" ? 'fm-button-icon-right' : 'fm-button-icon-left')
.append("<span class='ui-icon "+p.closeicon[2]+"'></span>");
}
if(!p.updateAfterCheck) {
$("#dData","#"+dtbl+"_2").click(function(e){
for(i=0;i<$t.p.colModel.length;i++){
if(!$t.p.colModel[i].hidedlg) { // added from T. Tomov
var nm = $t.p.colModel[i].name.replace(/\./g, "\\.");
if($("#col_" + nm,"#"+dtbl).attr("checked")) {
$($t).jqGrid("showCol",$t.p.colModel[i].name);
$("#col_" + nm,"#"+dtbl).attr("defaultChecked",true); // Added from T. Tomov IE BUG
} else {
$($t).jqGrid("hideCol",$t.p.colModel[i].name);
$("#col_" + nm,"#"+dtbl).attr("defaultChecked",""); // Added from T. Tomov IE BUG
}
}
}
if(p.ShrinkToFit===true) {
$($t).jqGrid("setGridWidth",$t.grid.width-0.001,true);
}
if(p.closeAfterSubmit) $.jgrid.hideModal("#"+IDs.themodal,{gb:"#gbox_"+gID,jqm:p.jqModal, onClose: p.onClose});
if (onAfterSubmit) { p.afterSubmitForm($("#"+dtbl)); }
return false;
});
} else {
$(":input","#"+dtbl).click(function(e){
var cn = this.id.substr(4);
if(cn){
if(this.checked) {
$($t).jqGrid("showCol",cn);
} else {
$($t).jqGrid("hideCol",cn);
}
if(p.ShrinkToFit===true) {
$($t).jqGrid("setGridWidth",$t.grid.width-0.001,true);
}
}
return this;
});
}
$("#eData", "#"+dtbl+"_2").click(function(e){
$.jgrid.hideModal("#"+IDs.themodal,{gb:"#gbox_"+gID,jqm:p.jqModal, onClose: p.onClose});
return false;
});
$("#dData, #eData","#"+dtbl+"_2").hover(
function(){$(this).addClass('ui-state-hover');},
function(){$(this).removeClass('ui-state-hover');}
);
if(onBeforeShow) { p.beforeShowForm($("#"+dtbl)); }
$.jgrid.viewModal("#"+IDs.themodal,{gbox:"#gbox_"+gID,jqm:p.jqModal, jqM: true, modal:p.modal});
if(onAfterShow) { p.afterShowForm($("#"+dtbl)); }
}
});
}
});
})(jQuery); | JavaScript |
;(function($){
/**
* jqGrid extension
* Paul Tiseo ptiseo@wasteconsultants.com
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl-2.0.html
**/
$.jgrid.extend({
getPostData : function(){
var $t = this[0];
if(!$t.grid) { return; }
return $t.p.postData;
},
setPostData : function( newdata ) {
var $t = this[0];
if(!$t.grid) { return; }
// check if newdata is correct type
if ( typeof(newdata) === 'object' ) {
$t.p.postData = newdata;
}
else {
alert("Error: cannot add a non-object postData value. postData unchanged.");
}
},
appendPostData : function( newdata ) {
var $t = this[0];
if(!$t.grid) { return; }
// check if newdata is correct type
if ( typeof(newdata) === 'object' ) {
$.extend($t.p.postData, newdata);
}
else {
alert("Error: cannot append a non-object postData value. postData unchanged.");
}
},
setPostDataItem : function( key, val ) {
var $t = this[0];
if(!$t.grid) { return; }
$t.p.postData[key] = val;
},
getPostDataItem : function( key ) {
var $t = this[0];
if(!$t.grid) { return; }
return $t.p.postData[key];
},
removePostDataItem : function( key ) {
var $t = this[0];
if(!$t.grid) { return; }
delete $t.p.postData[key];
},
getUserData : function(){
var $t = this[0];
if(!$t.grid) { return; }
return $t.p.userData;
},
getUserDataItem : function( key ) {
var $t = this[0];
if(!$t.grid) { return; }
return $t.p.userData[key];
}
});
})(jQuery); | JavaScript |
;
(function($) { /*******************************************************************************************/
// jquery.pajinate.js - version 0.4
// A jQuery plugin for paginating through any number of DOM elements
//
// Copyright (c) 2010, Wes Nolte (http://wesnolte.com)
// Licensed under the MIT License (MIT-LICENSE.txt)
// http://www.opensource.org/licenses/mit-license.php
// Created: 2010-04-16 | Updated: 2010-04-26
//
/*******************************************************************************************/
$.fn.pajinate = function(options) {
// Set some state information
var current_page = 'current_page';
var items_per_page = 'items_per_page';
var meta;
// Setup default option values
var defaults = {
item_container_id: '.content',
items_per_page: 10,
nav_panel_id: '.page_navigation',
nav_info_id: '.info_text',
num_page_links_to_display: 20,
start_page: 0,
wrap_around: false,
nav_label_first: 'First',
nav_label_prev: 'Prev',
nav_label_next: 'Next',
nav_label_last: 'Last',
nav_order: ["first", "prev", "num", "next", "last"],
nav_label_info: 'Showing {0}-{1} of {2} results',
show_first_last: true,
abort_on_small_lists: false,
jquery_ui: false,
jquery_ui_active: "ui-state-highlight",
jquery_ui_default: "ui-state-default",
jquery_ui_disabled: "ui-state-disabled",
on_show : false,
on_hide : false
};
var options = $.extend(defaults, options);
var $item_container;
var $page_container;
var $items;
var $nav_panels;
var total_page_no_links;
var jquery_ui_default_class = options.jquery_ui ? options.jquery_ui_default : '';
var jquery_ui_active_class = options.jquery_ui ? options.jquery_ui_active : '';
var jquery_ui_disabled_class = options.jquery_ui ? options.jquery_ui_disabled : '';
return this.each(function() {
$page_container = $(this);
$item_container = $(this).find(options.item_container_id);
$items = $page_container.find(options.item_container_id).children();
if (options.abort_on_small_lists && options.items_per_page >= $items.size()) return $page_container;
meta = $page_container;
// Initialize meta data
meta.data(current_page, 0);
meta.data(items_per_page, options.items_per_page);
// Get the total number of items
var total_items = $item_container.children().size();
// Calculate the number of pages needed
var number_of_pages = Math.ceil(total_items / options.items_per_page);
// Construct the nav bar
var more = '<span class="ellipse more">...</span>';
var less = '<span class="ellipse less">...</span>';
var first = !options.show_first_last ? '' : '<a class="first_link ' + jquery_ui_default_class + '" href="">' + options.nav_label_first + '</a>';
var last = !options.show_first_last ? '' : '<a class="last_link ' + jquery_ui_default_class + '" href="">' + options.nav_label_last + '</a>';
var navigation_html = "";
for (var i = 0; i < options.nav_order.length; i++) {
switch (options.nav_order[i]) {
case "first":
navigation_html += first;
break;
case "last":
navigation_html += last;
break;
case "next":
navigation_html += '<a class="next_link ' + jquery_ui_default_class + '" href="">' + options.nav_label_next + '</a>';
break;
case "prev":
navigation_html += '<a class="previous_link ' + jquery_ui_default_class + '" href="">' + options.nav_label_prev + '</a>';
break;
case "num":
navigation_html += less;
var current_link = 0;
while (number_of_pages > current_link) {
navigation_html += '<a class="page_link ' + jquery_ui_default_class + '" href="" longdesc="' + current_link + '">' + (current_link + 1) + '</a>';
current_link++;
}
navigation_html += more;
break;
default:
break;
}
}
// And add it to the appropriate area of the DOM
$nav_panels = $page_container.find(options.nav_panel_id);
$nav_panels.html(navigation_html).each(function() {
$(this).find('.page_link:first').addClass('first');
$(this).find('.page_link:last').addClass('last');
});
// Hide the more/less indicators
$nav_panels.children('.ellipse').hide();
// Set the active page link styling
$nav_panels.find('.previous_link').next().next().addClass('active_page ' + jquery_ui_active_class);
/* Setup Page Display */
// And hide all pages
$items.hide();
// Show the first page
$items.slice(0, meta.data(items_per_page)).show();
/* Setup Nav Menu Display */
// Page number slices
total_page_no_links = $page_container.find(options.nav_panel_id + ':first').children('.page_link').size();
options.num_page_links_to_display = Math.min(options.num_page_links_to_display, total_page_no_links);
$nav_panels.children('.page_link').hide(); // Hide all the page links
// And only show the number we should be seeing
$nav_panels.each(function() {
$(this).children('.page_link').slice(0, options.num_page_links_to_display).show();
});
/* Bind the actions to their respective links */
// Event handler for 'First' link
$page_container.find('.first_link').click(function(e) {
e.preventDefault();
movePageNumbersRight($(this), 0);
gotopage(0);
});
// Event handler for 'Last' link
$page_container.find('.last_link').click(function(e) {
e.preventDefault();
var lastPage = total_page_no_links - 1;
movePageNumbersLeft($(this), lastPage);
gotopage(lastPage);
});
// Event handler for 'Prev' link
$page_container.find('.previous_link').click(function(e) {
e.preventDefault();
showPrevPage($(this));
});
// Event handler for 'Next' link
$page_container.find('.next_link').click(function(e) {
e.preventDefault();
showNextPage($(this));
});
// Event handler for each 'Page' link
$page_container.find('.page_link').click(function(e) {
e.preventDefault();
gotopage($(this).attr('longdesc'));
});
// Goto the required page
gotopage(parseInt(options.start_page));
toggleMoreLess();
if (!options.wrap_around) tagNextPrev();
});
function showPrevPage(e) {
new_page = parseInt(meta.data(current_page)) - 1;
// Check that we aren't on a boundary link
if ($(e).siblings('.active_page').prev('.page_link').length == true) {
movePageNumbersRight(e, new_page);
gotopage(new_page);
}
else if (options.wrap_around) {
gotopage(total_page_no_links - 1);
}
};
function showNextPage(e) {
new_page = parseInt(meta.data(current_page)) + 1;
// Check that we aren't on a boundary link
if ($(e).siblings('.active_page').next('.page_link').length == true) {
movePageNumbersLeft(e, new_page);
gotopage(new_page);
}
else if (options.wrap_around) {
gotopage(0);
}
};
function gotopage(page_num) {
page_num = parseInt(page_num, 10)
var ipp = parseInt(meta.data(items_per_page));
// Find the start of the next slice
start_from = page_num * ipp;
// Find the end of the next slice
end_on = start_from + ipp;
// Hide the current page
var items = $items.hide().slice(start_from, end_on);
items.show();
if(typeof options.on_show == 'function')
options.on_show(items,ipp,page_num,start_from,end_on);
// Reassign the active class
$page_container.find(options.nav_panel_id).children('.page_link[longdesc=' + page_num + ']').addClass('active_page ' + jquery_ui_active_class).siblings('.active_page').removeClass('active_page ' + jquery_ui_active_class);
// Set the current page meta data
meta.data(current_page, page_num);
/*########## Ajout de l'option page courante + nombre de pages*/
var $current_page = parseInt(meta.data(current_page)+1);
// Get the total number of items
var total_items = $item_container.children().size();
// Calculate the number of pages needed
var $number_of_pages = Math.ceil(total_items / options.items_per_page);
/*##################################################################*/
$page_container.find(options.nav_info_id).html(options.nav_label_info.replace("{0}", start_from + 1).
replace("{1}", start_from + items.length).replace("{2}", $items.length).replace("{3}", $current_page).replace("{4}", $number_of_pages));
// Hide the more and/or less indicators
toggleMoreLess();
// Add a class to the next or prev links if there are no more pages next or previous to the active page
tagNextPrev();
// check if the onPage callback is available and call it
if (typeof(options.onPageDisplayed) !== "undefined" ) {
options.onPageDisplayed.call(this, page_num + 1)
}
}
// Methods to shift the diplayed index of page numbers to the left or right
function movePageNumbersLeft(e, new_p) {
var new_page = new_p;
var $current_active_link = $(e).siblings('.active_page');
if ($current_active_link.siblings('.page_link[longdesc=' + new_page + ']').css('display') == 'none') {
$nav_panels.each(function() {
$(this).children('.page_link').hide() // Hide all the page links
.slice(parseInt(new_page - options.num_page_links_to_display + 1), new_page + 1).show();
});
}
}
function movePageNumbersRight(e, new_p) {
var new_page = new_p;
var $current_active_link = $(e).siblings('.active_page');
if ($current_active_link.siblings('.page_link[longdesc=' + new_page + ']').css('display') == 'none') {
$nav_panels.each(function() {
$(this).children('.page_link').hide() // Hide all the page links
.slice(new_page, new_page + parseInt(options.num_page_links_to_display)).show();
});
}
}
// Show or remove the ellipses that indicate that more page numbers exist in the page index than are currently shown
function toggleMoreLess() {
if (!$nav_panels.children('.page_link:visible').hasClass('last')) {
$nav_panels.children('.more').show();
}
else {
$nav_panels.children('.more').hide();
}
if (!$nav_panels.children('.page_link:visible').hasClass('first')) {
$nav_panels.children('.less').show();
}
else {
$nav_panels.children('.less').hide();
}
}
/* Add the style class ".no_more" to the first/prev and last/next links to allow custom styling */
function tagNextPrev() {
if ($nav_panels.children('.last').hasClass('active_page')) {
$nav_panels.children('.next_link').add('.last_link').addClass('no_more ' + jquery_ui_disabled_class);
}
else {
$nav_panels.children('.next_link').add('.last_link').removeClass('no_more ' + jquery_ui_disabled_class);
}
if ($nav_panels.children('.first').hasClass('active_page')) {
$nav_panels.children('.previous_link').add('.first_link').addClass('no_more ' + jquery_ui_disabled_class);
}
else {
$nav_panels.children('.previous_link').add('.first_link').removeClass('no_more ' + jquery_ui_disabled_class);
}
}
};
})(jQuery);
| JavaScript |
(function($) {
var has_VML, has_canvas, create_canvas_for, add_shape_to, clear_canvas, shape_from_area,
canvas_style, hex_to_decimal, css3color, is_image_loaded, options_from_area;
has_canvas = !!document.createElement('canvas').getContext;
// VML: more complex
has_VML = (function() {
var a = document.createElement('div');
a.innerHTML = '<v:shape id="vml_flag1" adj="1" />';
var b = a.firstChild;
b.style.behavior = "url(#default#VML)";
return b ? typeof b.adj == "object": true;
})();
if(!(has_canvas || has_VML)) {
$.fn.maphilight = function() { return this; };
return;
}
if(has_canvas) {
hex_to_decimal = function(hex) {
return Math.max(0, Math.min(parseInt(hex, 16), 255));
};
css3color = function(color, opacity) {
return 'rgba('+hex_to_decimal(color.substr(0,2))+','+hex_to_decimal(color.substr(2,2))+','+hex_to_decimal(color.substr(4,2))+','+opacity+')';
};
create_canvas_for = function(img) {
var c = $('<canvas style="width:'+img.width+'px;height:'+img.height+'px;"></canvas>').get(0);
c.getContext("2d").clearRect(0, 0, c.width, c.height);
return c;
};
var draw_shape = function(context, shape, coords, x_shift, y_shift) {
x_shift = x_shift || 0;
y_shift = y_shift || 0;
context.beginPath();
if(shape == 'rect') {
// x, y, width, height
context.rect(coords[0] + x_shift, coords[1] + y_shift, coords[2] - coords[0], coords[3] - coords[1]);
} else if(shape == 'poly') {
context.moveTo(coords[0] + x_shift, coords[1] + y_shift);
for(i=2; i < coords.length; i+=2) {
context.lineTo(coords[i] + x_shift, coords[i+1] + y_shift);
}
} else if(shape == 'circ') {
// x, y, radius, startAngle, endAngle, anticlockwise
context.arc(coords[0] + x_shift, coords[1] + y_shift, coords[2], 0, Math.PI * 2, false);
}
context.closePath();
}
add_shape_to = function(canvas, shape, coords, options, name) {
var i, context = canvas.getContext('2d');
// Because I don't want to worry about setting things back to a base state
// Shadow has to happen first, since it's on the bottom, and it does some clip /
// fill operations which would interfere with what comes next.
if(options.shadow) {
context.save();
if(options.shadowPosition == "inside") {
// Cause the following stroke to only apply to the inside of the path
draw_shape(context, shape, coords);
context.clip();
}
// Redraw the shape shifted off the canvas massively so we can cast a shadow
// onto the canvas without having to worry about the stroke or fill (which
// cannot have 0 opacity or width, since they're what cast the shadow).
var x_shift = canvas.width * 100;
var y_shift = canvas.height * 100;
draw_shape(context, shape, coords, x_shift, y_shift);
context.shadowOffsetX = options.shadowX - x_shift;
context.shadowOffsetY = options.shadowY - y_shift;
context.shadowBlur = options.shadowRadius;
context.shadowColor = css3color(options.shadowColor, options.shadowOpacity);
// Now, work out where to cast the shadow from! It looks better if it's cast
// from a fill when it's an outside shadow or a stroke when it's an interior
// shadow. Allow the user to override this if they need to.
var shadowFrom = options.shadowFrom;
if (!shadowFrom) {
if (options.shadowPosition == 'outside') {
shadowFrom = 'fill';
} else {
shadowFrom = 'stroke';
}
}
if (shadowFrom == 'stroke') {
context.strokeStyle = "rgba(0,0,0,1)";
context.stroke();
} else if (shadowFrom == 'fill') {
context.fillStyle = "rgba(0,0,0,1)";
context.fill();
}
context.restore();
// and now we clean up
if(options.shadowPosition == "outside") {
context.save();
// Clear out the center
draw_shape(context, shape, coords);
context.globalCompositeOperation = "destination-out";
context.fillStyle = "rgba(0,0,0,1);";
context.fill();
context.restore();
}
}
context.save();
draw_shape(context, shape, coords);
// fill has to come after shadow, otherwise the shadow will be drawn over the fill,
// which mostly looks weird when the shadow has a high opacity
if(options.fill) {
context.fillStyle = css3color(options.fillColor, options.fillOpacity);
context.fill();
}
// Likewise, stroke has to come at the very end, or it'll wind up under bits of the
// shadow or the shadow-background if it's present.
if(options.stroke) {
context.strokeStyle = css3color(options.strokeColor, options.strokeOpacity);
context.lineWidth = options.strokeWidth;
context.stroke();
}
context.restore();
if(options.fade) {
$(canvas).css('opacity', 0).animate({opacity: 1}, 100);
}
};
clear_canvas = function(canvas) {
canvas.getContext('2d').clearRect(0, 0, canvas.width,canvas.height);
};
} else { // ie executes this code
create_canvas_for = function(img) {
return $('<var style="zoom:1;overflow:hidden;display:block;width:'+img.width+'px;height:'+img.height+'px;"></var>').get(0);
};
add_shape_to = function(canvas, shape, coords, options, name) {
var fill, stroke, opacity, e;
for (var i in coords) { coords[i] = parseInt(coords[i], 10); }
fill = '<v:fill color="#'+options.fillColor+'" opacity="'+(options.fill ? options.fillOpacity : 0)+'" />';
stroke = (options.stroke ? 'strokeweight="'+options.strokeWidth+'" stroked="t" strokecolor="#'+options.strokeColor+'"' : 'stroked="f"');
opacity = '<v:stroke opacity="'+options.strokeOpacity+'"/>';
if(shape == 'rect') {
e = $('<v:rect name="'+name+'" filled="t" '+stroke+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+coords[0]+'px;top:'+coords[1]+'px;width:'+(coords[2] - coords[0])+'px;height:'+(coords[3] - coords[1])+'px;"></v:rect>');
} else if(shape == 'poly') {
e = $('<v:shape name="'+name+'" filled="t" '+stroke+' coordorigin="0,0" coordsize="'+canvas.width+','+canvas.height+'" path="m '+coords[0]+','+coords[1]+' l '+coords.join(',')+' x e" style="zoom:1;margin:0;padding:0;display:block;position:absolute;top:0px;left:0px;width:'+canvas.width+'px;height:'+canvas.height+'px;"></v:shape>');
} else if(shape == 'circ') {
e = $('<v:oval name="'+name+'" filled="t" '+stroke+' style="zoom:1;margin:0;padding:0;display:block;position:absolute;left:'+(coords[0] - coords[2])+'px;top:'+(coords[1] - coords[2])+'px;width:'+(coords[2]*2)+'px;height:'+(coords[2]*2)+'px;"></v:oval>');
}
e.get(0).innerHTML = fill+opacity;
$(canvas).append(e);
};
clear_canvas = function(canvas) {
// jquery1.8 + ie7
var $html = $("<div>" + canvas.innerHTML + "</div>");
$html.children('[name=highlighted]').remove();
canvas.innerHTML = $html.html();
};
}
shape_from_area = function(area) {
var i, coords = area.getAttribute('coords').split(',');
for (i=0; i < coords.length; i++) { coords[i] = parseFloat(coords[i]); }
return [area.getAttribute('shape').toLowerCase().substr(0,4), coords];
};
options_from_area = function(area, options) {
var $area = $(area);
return $.extend({}, options, $.metadata ? $area.metadata() : false, $area.data('maphilight'));
};
is_image_loaded = function(img) {
if(!img.complete) { return false; } // IE
if(typeof img.naturalWidth != "undefined" && img.naturalWidth === 0) { return false; } // Others
return true;
};
canvas_style = {
position: 'absolute',
left: 0,
top: 0,
padding: 0,
border: 0
};
var ie_hax_done = false;
$.fn.maphilight = function(opts) {
opts = $.extend({}, $.fn.maphilight.defaults, opts);
if(!has_canvas && !ie_hax_done) {
$(window).ready(function() {
document.namespaces.add("v", "urn:schemas-microsoft-com:vml");
var style = document.createStyleSheet();
var shapes = ['shape','rect', 'oval', 'circ', 'fill', 'stroke', 'imagedata', 'group','textbox'];
$.each(shapes,
function() {
style.addRule('v\\:' + this, "behavior: url(#default#VML); antialias:true");
}
);
});
ie_hax_done = true;
}
return this.each(function() {
var img, wrap, options, map, canvas, canvas_always, mouseover, highlighted_shape, usemap;
img = $(this);
if(!is_image_loaded(this)) {
// If the image isn't fully loaded, this won't work right. Try again later.
return window.setTimeout(function() {
img.maphilight(opts);
}, 200);
}
options = $.extend({}, opts, $.metadata ? img.metadata() : false, img.data('maphilight'));
// jQuery bug with Opera, results in full-url#usemap being returned from jQuery's attr.
// So use raw getAttribute instead.
usemap = img.get(0).getAttribute('usemap');
if (!usemap) {
return
}
map = $('map[name="'+usemap.substr(1)+'"]');
if(!(img.is('img,input[type="image"]') && usemap && map.size() > 0)) {
return;
}
if(img.hasClass('maphilighted')) {
// We're redrawing an old map, probably to pick up changes to the options.
// Just clear out all the old stuff.
var wrapper = img.parent();
img.insertBefore(wrapper);
wrapper.remove();
$(map).unbind('.maphilight').find('area[coords]').unbind('.maphilight');
}
wrap = $('<div></div>').css({
display:'block',
background:'url("'+this.src+'")',
position:'relative',
padding:0,
width:this.width,
height:this.height
});
if(options.wrapClass) {
if(options.wrapClass === true) {
wrap.addClass($(this).attr('class'));
} else {
wrap.addClass(options.wrapClass);
}
}
img.before(wrap).css('opacity', 0).css(canvas_style).remove();
if(has_VML) { img.css('filter', 'Alpha(opacity=0)'); }
wrap.append(img);
canvas = create_canvas_for(this);
$(canvas).css(canvas_style);
canvas.height = this.height;
canvas.width = this.width;
mouseover = function(e) {
var shape, area_options;
area_options = options_from_area(this, options);
if(
!area_options.neverOn
&&
!area_options.alwaysOn
) {
shape = shape_from_area(this);
add_shape_to(canvas, shape[0], shape[1], area_options, "highlighted");
if(area_options.groupBy) {
var areas;
// two ways groupBy might work; attribute and selector
if(/^[a-zA-Z][\-a-zA-Z]+$/.test(area_options.groupBy)) {
areas = map.find('area['+area_options.groupBy+'="'+$(this).attr(area_options.groupBy)+'"]');
} else {
areas = map.find(area_options.groupBy);
}
var first = this;
areas.each(function() {
if(this != first) {
var subarea_options = options_from_area(this, options);
if(!subarea_options.neverOn && !subarea_options.alwaysOn) {
var shape = shape_from_area(this);
add_shape_to(canvas, shape[0], shape[1], subarea_options, "highlighted");
}
}
});
}
// workaround for IE7, IE8 not rendering the final rectangle in a group
if(!has_canvas) {
$(canvas).append('<v:rect></v:rect>');
}
}
}
$(map).bind('alwaysOn.maphilight', function() {
// Check for areas with alwaysOn set. These are added to a *second* canvas,
// which will get around flickering during fading.
if(canvas_always) {
clear_canvas(canvas_always);
}
if(!has_canvas) {
$(canvas).empty();
}
$(map).find('area[coords]').each(function() {
var shape, area_options;
area_options = options_from_area(this, options);
if(area_options.alwaysOn) {
if(!canvas_always && has_canvas) {
canvas_always = create_canvas_for(img[0]);
$(canvas_always).css(canvas_style);
canvas_always.width = img[0].width;
canvas_always.height = img[0].height;
img.before(canvas_always);
}
area_options.fade = area_options.alwaysOnFade; // alwaysOn shouldn't fade in initially
shape = shape_from_area(this);
if (has_canvas) {
add_shape_to(canvas_always, shape[0], shape[1], area_options, "");
} else {
add_shape_to(canvas, shape[0], shape[1], area_options, "");
}
}
});
});
$(map).trigger('alwaysOn.maphilight').find('area[coords]')
.bind('mouseover.maphilight', mouseover)
.bind('mouseout.maphilight', function(e) { clear_canvas(canvas); });
img.before(canvas); // if we put this after, the mouseover events wouldn't fire.
img.addClass('maphilighted');
});
};
$.fn.maphilight.defaults = {
fill: true,
fillColor: '000000',
fillOpacity: 0.2,
stroke: true,
strokeColor: 'ff0000',
strokeOpacity: 1,
strokeWidth: 1,
fade: true,
alwaysOn: false,
neverOn: false,
groupBy: false,
wrapClass: true,
// plenty of shadow:
shadow: false,
shadowX: 0,
shadowY: 0,
shadowRadius: 6,
shadowColor: '000000',
shadowOpacity: 0.8,
shadowPosition: 'outside',
shadowFrom: false
};
})(jQuery);
| JavaScript |
$(document).ready(function(){
window.parent.jQuery('ul.menu-bar > li > a').removeClass('active_menu');
setTimeout(function(){
var hClone = $('h3.modul-title').clone(true).css('display','block');
$('h3.modul-title').slideUp(function(){$(this).remove()});
var moduleInfo = window.parent.jQuery('div.modul-info');
var activeMenu = window.parent.jQuery('ul.menu-bar > li > a.' + gcConf.subject_cls);
if( !activeMenu.length )
activeMenu = window.parent.jQuery('ul.user-menu > li > a.' + gcConf.subject_cls);
activeMenu.addClass('active_menu');
var tt = activeMenu.find('>i').attr('mt');
moduleInfo.empty().hide().append(hClone.html(tt));
moduleInfo.fadeIn();
},200)
}); | JavaScript |
function show_upload_button(unique_id, uploader_element)
{
$('#upload-state-message-'+unique_id).html('');
$("#loading-"+unique_id).hide();
$('#upload-button-'+unique_id).slideDown('fast');
$("input[rel="+uploader_element.attr('name')+"]").val('');
$('#success_'+unique_id).slideUp('fast');
}
function load_fancybox(elem)
{
elem.fancybox({
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'speedIn' : 600,
'speedOut' : 200,
'overlayShow' : false
});
}
W = window;
$(document).ready(function(){
///////////////
$('.gc-file-upload').each(function(){
var unique_id = $(this).attr('id');
var uploader_url = $(this).attr('rel');
var uploader_element = $(this);
var delete_url = $('#delete_url_'+unique_id).attr('href');
eval("var file_upload_info = upload_info_"+unique_id+"");
$(this).fileupload({
dataType: 'json',
url: uploader_url,
cache: false,
acceptFileTypes: file_upload_info.accepted_file_types,
beforeSend: function(){
$('#upload-state-message-'+unique_id).html(string_upload_file);
$("#loading-"+unique_id).show();
$("#upload-button-"+unique_id).slideUp("fast");
},
limitMultiFileUploads: 1,
maxFileSize: file_upload_info.max_file_size,
send: function (e, data) {
var errors = '';
if (data.files.length > 1) {
errors += error_max_number_of_files + "\n" ;
}
$.each(data.files,function(index, file){
if (!(data.acceptFileTypes.test(file.type) || data.acceptFileTypes.test(file.name))) {
errors += error_accept_file_types + "\n";
}
if (data.maxFileSize && file.size > data.maxFileSize) {
errors += error_max_file_size + "\n";
}
if (typeof file.size === 'number' && file.size < data.minFileSize) {
errors += error_min_file_size + "\n";
}
});
if(errors != '')
{
error_alert('Error',errors);
return false;
}
return true;
},
done: function (e, data) {
// console.log(data.result)
if(typeof data.result.success != 'undefined' && data.result.success)
{
$("#loading-"+unique_id).hide();
$("#progress-"+unique_id).html('');
//////
$.each(data.result.files, function (index, file) {
$('#upload-state-message-'+unique_id).html('');
$("input[rel="+uploader_element.attr('name')+"]").val(file.name)
$('#importFromCSV').data('file',file);
var file_name = file.name;
file_name = file_name.split('-');
file_name.splice(0,1);
file_name = file_name.join('');
var file_name_base64 = file.base64;
var is_image = (file_name.substr(-4) == '.jpg'
|| file_name.substr(-4) == '.png'
|| file_name.substr(-5) == '.jpeg'
|| file_name.substr(-4) == '.gif'
|| file_name.substr(-5) == '.tiff') && !gcConf.unset_image_preview
? true : false;
if(is_image)
{
$('#file_'+unique_id).addClass('image-thumbnail');
load_fancybox($('#file_'+unique_id));
$('#file_'+unique_id).html('<img src="'+file.url+'" height="50" />');
}
else
{
//$('#file_'+unique_id).removeClass('image-thumbnail');
$('#file_'+unique_id).addClass('image-thumbnail');
load_fancybox($('#file_'+unique_id));
//$('#file_'+unique_id).unbind("click");
$('#file_'+unique_id).html(file_name);
}
$('#file_'+unique_id).attr('href',file.url);
$('#hidden_'+unique_id).val(file_name);
$('#success_'+unique_id).fadeIn('slow');
$('#delete_url_'+unique_id).attr('rel',file_name_base64);
$('#upload-button-'+unique_id).slideUp('fast');
//console.log(window)
});
}
else if(typeof data.result.message != 'undefined')
{
error_alert('Error',data.result.message);
show_upload_button(unique_id, uploader_element);
}
else
{
if(data.result == 'invalid_csv_data')
{
var message = 'Template yang anda upload tidak sesuai, jumlah kolom harus 5 sesuai dengan template yang disediakan, untuk melihat template klik download';
error_alert('Notifikasi',message);
show_upload_button(unique_id, uploader_element);
}
else
{
//console.log(arguments);
error_alert('Error',error_on_uploading);
show_upload_button(unique_id, uploader_element);
}
}
},
autoUpload: true,
error: function()
{
error_alert('Upload Error','err'+error_on_uploading);
show_upload_button(unique_id, uploader_element);
},
fail: function(e, data)
{
// data.errorThrown
// data.textStatus;
// data.jqXHR;
error_alert('Upload Failed',error_on_uploading);
show_upload_button(unique_id, uploader_element);
},
progress: function (e, data) {
$("#progress-"+unique_id).html(string_progress + parseInt(data.loaded / data.total * 100, 10) + '%');
}
});
$('#delete_'+unique_id).click(function(){
var no_delete = $(this).data('no_delete')?'?no_delete=true':'';
if($(this).data('no_confirm'))
{
var file_name = $('#delete_url_'+unique_id).attr('rel');
$.ajax({
url: delete_url+"/"+file_name + no_delete,
cache: false,
success:function(){
show_upload_button(unique_id, uploader_element);
},
beforeSend: function(){
$('#upload-state-message-'+unique_id).html(string_delete_file);
$('#success_'+unique_id).hide();
$("#loading-"+unique_id).show();
$("#upload-button-"+unique_id).slideUp("fast");
}
});
return false;
}
confirm_alert('Konfirmasi',message_prompt_delete_file,function(){
var file_name = $('#delete_url_'+unique_id).attr('rel');
$.ajax({
url: delete_url+"/"+file_name + no_delete,
cache: false,
success:function(){
show_upload_button(unique_id, uploader_element);
},
beforeSend: function(){
$('#upload-state-message-'+unique_id).html(string_delete_file);
$('#success_'+unique_id).hide();
$("#loading-"+unique_id).show();
$("#upload-button-"+unique_id).slideUp("fast");
}
});
},function(){
});
return false;
});
});
}); | JavaScript |
function setContent (sec,com,el,callback) {
var url = base_url() + sec + '/' + com;
if(url.match(/\?/g))
url+='&uuids='+uniqid();
else
url+='?uuids='+uniqid();
var convertedToSingleView = [
'welcome_greeting',
//'content_management_group_model'
];
var k_com = com.split('?');
var key_converted_to_single_view = sec + '_' + k_com[0];
//
var is_page_already_in_cache = false;
var page_cache_data = false;
window.current_key_converted_to_single_view = key_converted_to_single_view;
try
{
if(typeof gcConf.ktb_data != 'undefined')
{
gcConf.ktb_data={};
if(typeof gcConf.ktb_data[key_converted_to_single_view] != 'undefined')
{
is_page_already_in_cache = true;
page_cache_data = true;//real_data[key_converted_to_single_view];
}
}
}
catch(e)
{
page_cache_data = false;
}
if(is_page_already_in_cache)
{
// var iframeContent = $('<iframe style="border:none" frameBorder="0" allowTransparency="true" width="100%" height="100%" src="" id="iframeContent"></iframe>');
//
if(page_cache_data != false)
{
// var iframe = $('#iframeContent').get(0).contentWindow;
// console.log($('#iframeContent'))
// if(typeof iframe.$ != 'undefined')
// {
// console.log('here')
// var iframe_html = iframe.$('html');
// if(iframe_html.length)
// {
// iframe_html.html(page_cache_data);
// iframe.$(document).trigger('ready');
// }
// else
// {
// iframe.document.write('<!doctype HTML><html></html>');
// var iframe_html = iframe.$('html');
// if(iframe_html.length)
// {
// iframe_html.html(page_cache_data);
// }
// }
//}
$('#iframeContent').replaceWith(gcConf.ktb_data[key_converted_to_single_view]);
$('#iframeContent').data('dont_bubble',false);
//.html(page_cache_data);
//return;
}
}
if($.inArray(key_converted_to_single_view,convertedToSingleView) >= 0)
{
$('#singleViewContainer').load(url);
$('#singleViewContainer').fadeIn();
$('#iframeContent').hide();
}
else
{
$('#singleViewContainer').hide();
$('#iframeContent').fadeIn();
if(page_cache_data == false)
$('#iframeContent').prop('src',url);
if(typeof callback == 'function')
{
callback(url);
}
}
}
function checkHash(){}
$(document).ready(function () {
$('#iframeContent').load(function(){
if($(this).data('dont_bubble'))
{
$(this).data('dont_bubble',false);
return;
}
var continue_script = false;
// try
// {
if(typeof gcConf.ktb_data == 'undefined')
{
gcConf.ktb_data = {};
}
var key_converted_to_single_view = typeof window.current_key_converted_to_single_view != 'undefined' ? window.current_key_converted_to_single_view : -1;
if(key_converted_to_single_view != -1)
{
continue_script = true;
}
// }
// catch(e)
// {
// console.log(e)
// }
if(continue_script)
{
// var real_data = 'tmp_data';
// console.log('Here')
// real_data = gcConf.ktb_data;
var page_cache_data = this.contentWindow.$('html').html();
gcConf.ktb_data[key_converted_to_single_view] = $(this).clone(true);
//localStorage.ktb_data = JSON.stringify(real_data);
}
try
{
var win = $('#iframeContent').get(0).contentWindow;
win.SetGridMainIcon($(el).find('>i').prop('class'));
}
catch(e){}
});
var loggedIn = !($('#AppLoad').text().replace(/\s/,'') == 'Welcome');
// INIT LAYOUT
var west_not_loggedIn = {initClosed:true,togglerLength_closed:0,size:250};
var west_loggedIn = {size:313};
if(loggedIn){
$('.userMenu').show().css({
display: 'block',
padding: '21px 9px 0 51px',
position: 'absolute',
right: '0',
top: '0'
});
$('.userMenu button').css({padding:'4px',cursor:'pointer'}).addClass('ui-state-default ui-corner-all')
}
var westConfig = loggedIn ? west_loggedIn : west_not_loggedIn;
$('body').layout({
applyDemoStyles: false,
east:{initClosed:true,togglerLength_closed:0},
north:{size:124,initClosed:0,togglerLength_open:0},
south:{size:0,initClosed:1,togglerLength_open:0},
west:westConfig,
east__initHidden: true ,
west__resizable: false,
east__resizable: false,
north__resizable: false,
south__resizable: false
});
$('.user-menu .ui-accordion-header-icon.ui-icon.ui-icon-triangle-1-e').remove();
$(window).resize(function(){
var lc = $('.ui-layout-center.ui-layout-pane.ui-layout-pane-center');
setTimeout(function(){
lc.height($(this).height()-122)
},500);
});
setTimeout(function(){
$(window).trigger('resize');
$('.acc-wrap,.cmp-cap,.modul-info').fadeIn();
},100);
}); | JavaScript |
/*!
* jquery.qtip. The jQuery tooltip plugin
*
* Copyright (c) 2009 Craig Thompson
* http://craigsworks.com
*
* Licensed under MIT
* http://www.opensource.org/licenses/mit-license.php
*
* Launch : February 2009
* Version : 1.0.0-rc3
* Released: Tuesday 12th May, 2009 - 00:00
* Debug: jquery.qtip.debug.js
*/
(function($)
{
// Implementation
$.fn.qtip = function(options, blanket)
{
var i, id, interfaces, opts, obj, command, config, api;
// Return API / Interfaces if requested
if(typeof options == 'string')
{
// Make sure API data exists if requested
if(typeof $(this).data('qtip') !== 'object')
$.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.NO_TOOLTIP_PRESENT, false);
// Return requested object
if(options == 'api')
return $(this).data('qtip').interfaces[ $(this).data('qtip').current ];
else if(options == 'interfaces')
return $(this).data('qtip').interfaces;
}
// Validate provided options
else
{
// Set null options object if no options are provided
if(!options) options = {};
// Sanitize option data
if(typeof options.content !== 'object' || (options.content.jquery && options.content.length > 0)) options.content = { text: options.content };
if(typeof options.content.title !== 'object') options.content.title = { text: options.content.title };
if(typeof options.position !== 'object') options.position = { corner: options.position };
if(typeof options.position.corner !== 'object') options.position.corner = { target: options.position.corner, tooltip: options.position.corner };
if(typeof options.show !== 'object') options.show = { when: options.show };
if(typeof options.show.when !== 'object') options.show.when = { event: options.show.when };
if(typeof options.show.effect !== 'object') options.show.effect = { type: options.show.effect };
if(typeof options.hide !== 'object') options.hide = { when: options.hide };
if(typeof options.hide.when !== 'object') options.hide.when = { event: options.hide.when };
if(typeof options.hide.effect !== 'object') options.hide.effect = { type: options.hide.effect };
if(typeof options.style !== 'object') options.style = { name: options.style };
options.style = sanitizeStyle(options.style);
// Build main options object
opts = $.extend(true, {}, $.fn.qtip.defaults, options);
// Inherit all style properties into one syle object and include original options
opts.style = buildStyle.call({ options: opts }, opts.style);
opts.user = $.extend(true, {}, options);
};
// Iterate each matched element
return $(this).each(function() // Return original elements as per jQuery guidelines
{
// Check for API commands
if(typeof options == 'string')
{
command = options.toLowerCase();
interfaces = $(this).qtip('interfaces');
// Make sure API data exists$('.qtip').qtip('destroy')
if(typeof interfaces == 'object')
{
// Check if API call is a BLANKET DESTROY command
if(blanket === true && command == 'destroy')
while(interfaces.length > 0) interfaces[interfaces.length-1].destroy();
// API call is not a BLANKET DESTROY command
else
{
// Check if supplied command effects this tooltip only (NOT BLANKET)
if(blanket !== true) interfaces = [ $(this).qtip('api') ];
// Execute command on chosen qTips
for(i = 0; i < interfaces.length; i++)
{
// Destroy command doesn't require tooltip to be rendered
if(command == 'destroy') interfaces[i].destroy();
// Only call API if tooltip is rendered and it wasn't a destroy call
else if(interfaces[i].status.rendered === true)
{
if(command == 'show') interfaces[i].show();
else if(command == 'hide') interfaces[i].hide();
else if(command == 'focus') interfaces[i].focus();
else if(command == 'disable') interfaces[i].disable(true);
else if(command == 'enable') interfaces[i].disable(false);
};
};
};
};
}
// No API commands, continue with qTip creation
else
{
// Create unique configuration object
config = $.extend(true, {}, opts);
config.hide.effect.length = opts.hide.effect.length;
config.show.effect.length = opts.show.effect.length;
// Sanitize target options
if(config.position.container === false) config.position.container = $(document.body);
if(config.position.target === false) config.position.target = $(this);
if(config.show.when.target === false) config.show.when.target = $(this);
if(config.hide.when.target === false) config.hide.when.target = $(this);
// Determine tooltip ID (Reuse array slots if possible)
id = $.fn.qtip.interfaces.length;
for(i = 0; i < id; i++)
{
if(typeof $.fn.qtip.interfaces[i] == 'undefined'){ id = i; break; };
};
// Instantiate the tooltip
obj = new qTip($(this), config, id);
// Add API references
$.fn.qtip.interfaces[id] = obj;
// Check if element already has qTip data assigned
if(typeof $(this).data('qtip') == 'object')
{
// Set new current interface id
if(typeof $(this).attr('qtip') === 'undefined')
$(this).data('qtip').current = $(this).data('qtip').interfaces.length;
// Push new API interface onto interfaces array
$(this).data('qtip').interfaces.push(obj);
}
// No qTip data is present, create now
else $(this).data('qtip', { current: 0, interfaces: [obj] });
// If prerendering is disabled, create tooltip on showEvent
if(config.content.prerender === false && config.show.when.event !== false && config.show.ready !== true)
{
config.show.when.target.bind(config.show.when.event+'.qtip-'+id+'-create', { qtip: id }, function(event)
{
// Retrieve API interface via passed qTip Id
api = $.fn.qtip.interfaces[ event.data.qtip ];
// Unbind show event and cache mouse coords
api.options.show.when.target.unbind(api.options.show.when.event+'.qtip-'+event.data.qtip+'-create');
api.cache.mouse = { x: event.pageX, y: event.pageY };
// Render tooltip and start the event sequence
construct.call( api );
api.options.show.when.target.trigger(api.options.show.when.event);
});
}
// Prerendering is enabled, create tooltip now
else
{
// Set mouse position cache to top left of the element
obj.cache.mouse = {
x: config.show.when.target.offset().left,
y: config.show.when.target.offset().top
};
// Construct the tooltip
construct.call(obj);
}
};
});
};
// Instantiator
function qTip(target, options, id)
{
// Declare this reference
var self = this;
// Setup class attributes
self.id = id;
self.options = options;
self.status = {
animated: false,
rendered: false,
disabled: false,
focused: false
};
self.elements = {
target: target.addClass(self.options.style.classes.target),
tooltip: null,
wrapper: null,
content: null,
contentWrapper: null,
title: null,
button: null,
tip: null,
bgiframe: null
};
self.cache = {
mouse: {},
position: {},
toggle: 0
};
self.timers = {};
// Define exposed API methods
$.extend(self, self.options.api,
{
show: function(event)
{
var returned, solo;
// Make sure tooltip is rendered and if not, return
if(!self.status.rendered)
return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'show');
// Only continue if element is visible
if(self.elements.tooltip.css('display') !== 'none') return self;
// Clear animation queue
self.elements.tooltip.stop(true, false);
// Call API method and if return value is false, halt
returned = self.beforeShow.call(self, event);
if(returned === false) return self;
// Define afterShow callback method
function afterShow()
{
// Call API method and focus if it isn't static
if(self.options.position.type !== 'static') self.focus();
self.onShow.call(self, event);
try{
// Prevent antialias from disappearing in IE7 by removing filter attribute
if($.browser.msie) self.elements.tooltip.get(0).style.removeAttribute('filter');
}
catch(e){}
};
// Maintain toggle functionality if enabled
self.cache.toggle = 1;
// Update tooltip position if it isn't static
if(self.options.position.type !== 'static')
self.updatePosition(event, (self.options.show.effect.length > 0));
// Hide other tooltips if tooltip is solo
if(typeof self.options.show.solo == 'object') solo = $(self.options.show.solo);
else if(self.options.show.solo === true) solo = $('div.qtip').not(self.elements.tooltip);
if(solo) solo.each(function(){ if($(this).qtip('api').status.rendered === true) $(this).qtip('api').hide(); });
// Show tooltip
if(typeof self.options.show.effect.type == 'function')
{
self.options.show.effect.type.call(self.elements.tooltip, self.options.show.effect.length);
self.elements.tooltip.queue(function(){ afterShow(); $(this).dequeue(); });
}
else
{
switch(self.options.show.effect.type.toLowerCase())
{
case 'fade':
self.elements.tooltip.fadeIn(self.options.show.effect.length, afterShow);
break;
case 'slide':
self.elements.tooltip.slideDown(self.options.show.effect.length, function()
{
afterShow();
if(self.options.position.type !== 'static') self.updatePosition(event, true);
});
break;
case 'grow':
self.elements.tooltip.show(self.options.show.effect.length, afterShow);
break;
default:
self.elements.tooltip.show(null, afterShow);
break;
};
// Add active class to tooltip
self.elements.tooltip.addClass(self.options.style.classes.active);
};
// Log event and return
return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_SHOWN, 'show');
},
hide: function(event)
{
var returned;
// Make sure tooltip is rendered and if not, return
if(!self.status.rendered)
return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'hide');
// Only continue if element is visible
else if(self.elements.tooltip.css('display') === 'none') return self;
// Stop show timer and animation queue
clearTimeout(self.timers.show);
self.elements.tooltip.stop(true, false);
// Call API method and if return value is false, halt
returned = self.beforeHide.call(self, event);
if(returned === false) return self;
// Define afterHide callback method
function afterHide(){ self.onHide.call(self, event); };
// Maintain toggle functionality if enabled
self.cache.toggle = 0;
// Hide tooltip
if(typeof self.options.hide.effect.type == 'function')
{
self.options.hide.effect.type.call(self.elements.tooltip, self.options.hide.effect.length);
self.elements.tooltip.queue(function(){ afterHide(); $(this).dequeue(); });
}
else
{
switch(self.options.hide.effect.type.toLowerCase())
{
case 'fade':
self.elements.tooltip.fadeOut(self.options.hide.effect.length, afterHide);
break;
case 'slide':
self.elements.tooltip.slideUp(self.options.hide.effect.length, afterHide);
break;
case 'grow':
self.elements.tooltip.hide(self.options.hide.effect.length, afterHide);
break;
default:
self.elements.tooltip.hide(null, afterHide);
break;
};
// Remove active class to tooltip
self.elements.tooltip.removeClass(self.options.style.classes.active);
};
// Log event and return
return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_HIDDEN, 'hide');
},
updatePosition: function(event, animate)
{
var i, target, tooltip, coords, mapName, imagePos, newPosition, ieAdjust, ie6Adjust, borderAdjust, mouseAdjust, offset, curPosition, returned
// Make sure tooltip is rendered and if not, return
if(!self.status.rendered)
return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updatePosition');
// If tooltip is static, return
else if(self.options.position.type == 'static')
return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.CANNOT_POSITION_STATIC, 'updatePosition');
// Define property objects
target = {
position: { left: 0, top: 0 },
dimensions: { height: 0, width: 0 },
corner: self.options.position.corner.target
};
tooltip = {
position: self.getPosition(),
dimensions: self.getDimensions(),
corner: self.options.position.corner.tooltip
};
// Target is an HTML element
if(self.options.position.target !== 'mouse')
{
// If the HTML element is AREA, calculate position manually
if(self.options.position.target.get(0).nodeName.toLowerCase() == 'area')
{
// Retrieve coordinates from coords attribute and parse into integers
coords = self.options.position.target.attr('coords').split(',');
for(i = 0; i < coords.length; i++) coords[i] = parseInt(coords[i]);
// Setup target position object
mapName = self.options.position.target.parent('map').attr('name');
try{
imagePos = $('img[usemap="#'+mapName+'"]:first').offset();
target.position = {
left: Math.floor(imagePos.left + coords[0]),
top: Math.floor(imagePos.top + coords[1])
};
}catch(e){}
// Determine width and height of the area
switch(self.options.position.target.attr('shape').toLowerCase())
{
case 'rect':
target.dimensions = {
width: Math.ceil(Math.abs(coords[2] - coords[0])),
height: Math.ceil(Math.abs(coords[3] - coords[1]))
};
break;
case 'circle':
target.dimensions = {
width: coords[2] + 1,
height: coords[2] + 1
};
break;
case 'poly':
target.dimensions = {
width: coords[0],
height: coords[1]
};
for(i = 0; i < coords.length; i++)
{
if(i % 2 == 0)
{
if(coords[i] > target.dimensions.width)
target.dimensions.width = coords[i];
if(coords[i] < coords[0])
target.position.left = Math.floor(imagePos.left + coords[i]);
}
else
{
if(coords[i] > target.dimensions.height)
target.dimensions.height = coords[i];
if(coords[i] < coords[1])
target.position.top = Math.floor(imagePos.top + coords[i]);
};
};
target.dimensions.width = target.dimensions.width - (target.position.left - imagePos.left);
target.dimensions.height = target.dimensions.height - (target.position.top - imagePos.top);
break;
default:
return $.fn.qtip.log.error.call(self, 4, $.fn.qtip.constants.INVALID_AREA_SHAPE, 'updatePosition');
break;
};
// Adjust position by 2 pixels (Positioning bug?)
target.dimensions.width -= 2; target.dimensions.height -= 2;
}
// Target is the document
else if(self.options.position.target.add(document.body).length === 1)
{
target.position = { left: $(document).scrollLeft(), top: $(document).scrollTop() };
target.dimensions = { height: $(window).height(), width: $(window).width() };
}
// Target is a regular HTML element, find position normally
else
{
// Check if the target is another tooltip. If its animated, retrieve position from newPosition data
if(typeof self.options.position.target.attr('qtip') !== 'undefined')
target.position = self.options.position.target.qtip('api').cache.position;
else
target.position = self.options.position.target.offset();
// Setup dimensions objects
target.dimensions = {
height: self.options.position.target.outerHeight(),
width: self.options.position.target.outerWidth()
};
};
// Calculate correct target corner position
newPosition = $.extend({}, target.position);
if(target.corner.search(/right/i) !== -1)
newPosition.left += target.dimensions.width;
if(target.corner.search(/bottom/i) !== -1)
newPosition.top += target.dimensions.height;
if(target.corner.search(/((top|bottom)Middle)|center/) !== -1)
newPosition.left += (target.dimensions.width / 2);
if(target.corner.search(/((left|right)Middle)|center/) !== -1)
newPosition.top += (target.dimensions.height / 2);
}
// Mouse is the target, set position to current mouse coordinates
else
{
// Setup target position and dimensions objects
target.position = newPosition = { left: self.cache.mouse.x, top: self.cache.mouse.y };
target.dimensions = { height: 1, width: 1 };
};
// Calculate correct target corner position
if(tooltip.corner.search(/right/i) !== -1)
newPosition.left -= tooltip.dimensions.width;
if(tooltip.corner.search(/bottom/i) !== -1)
newPosition.top -= tooltip.dimensions.height;
if(tooltip.corner.search(/((top|bottom)Middle)|center/) !== -1)
newPosition.left -= (tooltip.dimensions.width / 2);
if(tooltip.corner.search(/((left|right)Middle)|center/) !== -1)
newPosition.top -= (tooltip.dimensions.height / 2);
// Setup IE adjustment variables (Pixel gap bugs)
ieAdjust = ($.browser.msie) ? 1 : 0; // And this is why I hate IE...
ie6Adjust = ($.browser.msie && parseInt($.browser.version.charAt(0)) === 6) ? 1 : 0; // ...and even more so IE6!
// Adjust for border radius
if(self.options.style.border.radius > 0)
{
if(tooltip.corner.search(/Left/) !== -1)
newPosition.left -= self.options.style.border.radius;
else if(tooltip.corner.search(/Right/) !== -1)
newPosition.left += self.options.style.border.radius;
if(tooltip.corner.search(/Top/) !== -1)
newPosition.top -= self.options.style.border.radius;
else if(tooltip.corner.search(/Bottom/) !== -1)
newPosition.top += self.options.style.border.radius;
};
// IE only adjustments (Pixel perfect!)
if(ieAdjust)
{
if(tooltip.corner.search(/top/) !== -1)
newPosition.top -= ieAdjust
else if(tooltip.corner.search(/bottom/) !== -1)
newPosition.top += ieAdjust
if(tooltip.corner.search(/left/) !== -1)
newPosition.left -= ieAdjust
else if(tooltip.corner.search(/right/) !== -1)
newPosition.left += ieAdjust
if(tooltip.corner.search(/leftMiddle|rightMiddle/) !== -1)
newPosition.top -= 1
};
// If screen adjustment is enabled, apply adjustments
if(self.options.position.adjust.screen === true)
newPosition = screenAdjust.call(self, newPosition, target, tooltip);
// If mouse is the target, prevent tooltip appearing directly under the mouse
if(self.options.position.target === 'mouse' && self.options.position.adjust.mouse === true)
{
if(self.options.position.adjust.screen === true && self.elements.tip)
mouseAdjust = self.elements.tip.attr('rel');
else
mouseAdjust = self.options.position.corner.tooltip;
newPosition.left += (mouseAdjust.search(/right/i) !== -1) ? -6 : 6;
newPosition.top += (mouseAdjust.search(/bottom/i) !== -1) ? -6 : 6;
}
// Initiate bgiframe plugin in IE6 if tooltip overlaps a select box or object element
if(!self.elements.bgiframe && $.browser.msie && parseInt($.browser.version.charAt(0)) == 6)
{
$('select, object').each(function()
{
offset = $(this).offset();
offset.bottom = offset.top + $(this).height();
offset.right = offset.left + $(this).width();
if(newPosition.top + tooltip.dimensions.height >= offset.top
&& newPosition.left + tooltip.dimensions.width >= offset.left)
bgiframe.call(self);
});
};
// Add user xy adjustments
newPosition.left += self.options.position.adjust.x;
newPosition.top += self.options.position.adjust.y;
// Set new tooltip position if its moved, animate if enabled
curPosition = self.getPosition();
if(newPosition.left != curPosition.left || newPosition.top != curPosition.top)
{
// Call API method and if return value is false, halt
returned = self.beforePositionUpdate.call(self, event);
if(returned === false) return self;
// Cache new position
self.cache.position = newPosition;
// Check if animation is enabled
if(animate === true)
{
// Set animated status
self.status.animated = true;
// Animate and reset animated status on animation end
self.elements.tooltip.animate(newPosition, 200, 'swing', function(){ self.status.animated = false });
}
// Set new position via CSS
else self.elements.tooltip.css(newPosition);
// Call API method and log event if its not a mouse move
self.onPositionUpdate.call(self, event);
if(typeof event !== 'undefined' && event.type && event.type !== 'mousemove')
$.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_POSITION_UPDATED, 'updatePosition');
};
return self;
},
updateWidth: function(newWidth)
{
var hidden;
// Make sure tooltip is rendered and if not, return
if(!self.status.rendered)
return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updateWidth');
// Make sure supplied width is a number and if not, return
else if(newWidth && typeof newWidth !== 'number')
return $.fn.qtip.log.error.call(self, 2, 'newWidth must be of type number', 'updateWidth');
// Setup elements which must be hidden during width update
hidden = self.elements.contentWrapper.siblings().add(self.elements.tip).add(self.elements.button);
// Calculate the new width if one is not supplied
if(!newWidth)
{
// Explicit width is set
if(typeof self.options.style.width.value == 'number')
newWidth = self.options.style.width.value;
// No width is set, proceed with auto detection
else
{
// Set width to auto initally to determine new width and hide other elements
self.elements.tooltip.css({ width: 'auto' });
hidden.hide();
// Set position and zoom to defaults to prevent IE hasLayout bug
if($.browser.msie)
self.elements.wrapper.add(self.elements.contentWrapper.children()).css({ zoom: 'normal' });
// Set the new width
newWidth = self.getDimensions().width + 1;
// Make sure its within the maximum and minimum width boundries
if(!self.options.style.width.value)
{
if(newWidth > self.options.style.width.max) newWidth = self.options.style.width.max
if(newWidth < self.options.style.width.min) newWidth = self.options.style.width.min
};
};
};
// Adjust newWidth by 1px if width is odd (IE6 rounding bug fix)
if(newWidth % 2 !== 0) newWidth -= 1;
// Set the new calculated width and unhide other elements
self.elements.tooltip.width(newWidth);
hidden.show();
// Set the border width, if enabled
if(self.options.style.border.radius)
{
self.elements.tooltip.find('.qtip-betweenCorners').each(function(i)
{
$(this).width(newWidth - (self.options.style.border.radius * 2));
})
};
// IE only adjustments
if($.browser.msie)
{
// Reset position and zoom to give the wrapper layout (IE hasLayout bug)
self.elements.wrapper.add(self.elements.contentWrapper.children()).css({ zoom: '1' });
// Set the new width
self.elements.wrapper.width(newWidth);
// Adjust BGIframe height and width if enabled
if(self.elements.bgiframe) self.elements.bgiframe.width(newWidth).height(self.getDimensions.height);
};
// Log event and return
return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_WIDTH_UPDATED, 'updateWidth');
},
updateStyle: function(name)
{
var tip, borders, context, corner, coordinates;
// Make sure tooltip is rendered and if not, return
if(!self.status.rendered)
return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updateStyle');
// Return if style is not defined or name is not a string
else if(typeof name !== 'string' || !$.fn.qtip.styles[name])
return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.STYLE_NOT_DEFINED, 'updateStyle');
// Set the new style object
self.options.style = buildStyle.call(self, $.fn.qtip.styles[name], self.options.user.style);
// Update initial styles of content and title elements
self.elements.content.css( jQueryStyle(self.options.style) );
if(self.options.content.title.text !== false)
self.elements.title.css( jQueryStyle(self.options.style.title, true) );
// Update CSS border colour
self.elements.contentWrapper.css({ borderColor: self.options.style.border.color });
// Update tip color if enabled
if(self.options.style.tip.corner !== false)
{
if($('<canvas>').get(0).getContext)
{
// Retrieve canvas context and clear
tip = self.elements.tooltip.find('.qtip-tip canvas:first');
context = tip.get(0).getContext('2d');
context.clearRect(0,0,300,300);
// Draw new tip
corner = tip.parent('div[rel]:first').attr('rel');
coordinates = calculateTip(corner, self.options.style.tip.size.width, self.options.style.tip.size.height);
drawTip.call(self, tip, coordinates, self.options.style.tip.color || self.options.style.border.color);
}
else if($.browser.msie)
{
// Set new fillcolor attribute
tip = self.elements.tooltip.find('.qtip-tip [nodeName="shape"]');
tip.attr('fillcolor', self.options.style.tip.color || self.options.style.border.color);
};
};
// Update border colors if enabled
if(self.options.style.border.radius > 0)
{
self.elements.tooltip.find('.qtip-betweenCorners').css({ backgroundColor: self.options.style.border.color });
if($('<canvas>').get(0).getContext)
{
borders = calculateBorders(self.options.style.border.radius)
self.elements.tooltip.find('.qtip-wrapper canvas').each(function()
{
// Retrieve canvas context and clear
context = $(this).get(0).getContext('2d');
context.clearRect(0,0,300,300);
// Draw new border
corner = $(this).parent('div[rel]:first').attr('rel')
drawBorder.call(self, $(this), borders[corner],
self.options.style.border.radius, self.options.style.border.color);
});
}
else if($.browser.msie)
{
// Set new fillcolor attribute on each border corner
self.elements.tooltip.find('.qtip-wrapper [nodeName="arc"]').each(function()
{
$(this).attr('fillcolor', self.options.style.border.color)
});
};
};
// Log event and return
return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_STYLE_UPDATED, 'updateStyle');
},
updateContent: function(content, reposition)
{
var parsedContent, images, loadedImages;
// Make sure tooltip is rendered and if not, return
if(!self.status.rendered)
return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updateContent');
// Make sure content is defined before update
else if(!content)
return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.NO_CONTENT_PROVIDED, 'updateContent');
// Call API method and set new content if a string is returned
parsedContent = self.beforeContentUpdate.call(self, content);
if(typeof parsedContent == 'string') content = parsedContent;
else if(parsedContent === false) return;
// Set position and zoom to defaults to prevent IE hasLayout bug
if($.browser.msie) self.elements.contentWrapper.children().css({ zoom: 'normal' });
// Append new content if its a DOM array and show it if hidden
if(content.jquery && content.length > 0)
content.clone(true).appendTo(self.elements.content).show();
// Content is a regular string, insert the new content
else self.elements.content.html(content);
// Check if images need to be loaded before position is updated to prevent mis-positioning
images = self.elements.content.find('img[complete=false]');
if(images.length > 0)
{
loadedImages = 0;
images.each(function(i)
{
$('<img src="'+ $(this).attr('src') +'" />')
.load(function(){ if(++loadedImages == images.length) afterLoad(); });
});
}
else afterLoad();
function afterLoad()
{
// Update the tooltip width
self.updateWidth();
// If repositioning is enabled, update positions
if(reposition !== false)
{
// Update position if tooltip isn't static
if(self.options.position.type !== 'static')
self.updatePosition(self.elements.tooltip.is(':visible'), true);
// Reposition the tip if enabled
if(self.options.style.tip.corner !== false)
positionTip.call(self);
};
};
// Call API method and log event
self.onContentUpdate.call(self);
return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_CONTENT_UPDATED, 'loadContent');
},
loadContent: function(url, data, method)
{
var returned;
// Make sure tooltip is rendered and if not, return
if(!self.status.rendered)
return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'loadContent');
// Call API method and if return value is false, halt
returned = self.beforeContentLoad.call(self);
if(returned === false) return self;
// Load content using specified request type
if(method == 'post')
$.post(url, data, setupContent);
else
$.get(url, data, setupContent);
function setupContent(content)
{
// Call API method and log event
self.onContentLoad.call(self);
$.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_CONTENT_LOADED, 'loadContent');
// Update the content
self.updateContent(content);
};
return self;
},
updateTitle: function(content)
{
// Make sure tooltip is rendered and if not, return
if(!self.status.rendered)
return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'updateTitle');
// Make sure content is defined before update
else if(!content)
return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.NO_CONTENT_PROVIDED, 'updateTitle');
// Call API method and if return value is false, halt
returned = self.beforeTitleUpdate.call(self);
if(returned === false) return self;
// Set the new content and reappend the button if enabled
if(self.elements.button) self.elements.button = self.elements.button.clone(true);
self.elements.title.html(content)
if(self.elements.button) self.elements.title.prepend(self.elements.button);
// Call API method and log event
self.onTitleUpdate.call(self);
return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_TITLE_UPDATED, 'updateTitle');
},
focus: function(event)
{
var curIndex, newIndex, elemIndex, returned;
// Make sure tooltip is rendered and if not, return
if(!self.status.rendered)
return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'focus');
else if(self.options.position.type == 'static')
return $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.CANNOT_FOCUS_STATIC, 'focus');
// Set z-index variables
curIndex = parseInt( self.elements.tooltip.css('z-index') );
newIndex = 6000 + $('div.qtip[qtip]').length - 1;
// Only update the z-index if it has changed and tooltip is not already focused
if(!self.status.focused && curIndex !== newIndex)
{
// Call API method and if return value is false, halt
returned = self.beforeFocus.call(self, event);
if(returned === false) return self;
// Loop through all other tooltips
$('div.qtip[qtip]').not(self.elements.tooltip).each(function()
{
if($(this).qtip('api').status.rendered === true)
{
elemIndex = parseInt($(this).css('z-index'));
// Reduce all other tooltip z-index by 1
if(typeof elemIndex == 'number' && elemIndex > -1)
$(this).css({ zIndex: parseInt( $(this).css('z-index') ) - 1 });
// Set focused status to false
$(this).qtip('api').status.focused = false;
}
})
// Set the new z-index and set focus status to true
self.elements.tooltip.css({ zIndex: newIndex });
self.status.focused = true;
// Call API method and log event
self.onFocus.call(self, event);
$.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_FOCUSED, 'focus');
};
return self;
},
disable: function(state)
{
// Make sure tooltip is rendered and if not, return
if(!self.status.rendered)
return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'disable');
if(state)
{
// Tooltip is not already disabled, proceed
if(!self.status.disabled)
{
// Set the disabled flag and log event
self.status.disabled = true;
$.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_DISABLED, 'disable');
}
// Tooltip is already disabled, inform user via log
else $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.TOOLTIP_ALREADY_DISABLED, 'disable');
}
else
{
// Tooltip is not already enabled, proceed
if(self.status.disabled)
{
// Reassign events, set disable status and log
self.status.disabled = false;
$.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_ENABLED, 'disable');
}
// Tooltip is already enabled, inform the user via log
else $.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.TOOLTIP_ALREADY_ENABLED, 'disable');
};
return self;
},
destroy: function()
{
var i, returned, interfaces;
// Call API method and if return value is false, halt
returned = self.beforeDestroy.call(self);
if(returned === false) return self;
// Check if tooltip is rendered
if(self.status.rendered)
{
// Remove event handlers and remove element
self.options.show.when.target.unbind('mousemove.qtip', self.updatePosition);
self.options.show.when.target.unbind('mouseout.qtip', self.hide);
self.options.show.when.target.unbind(self.options.show.when.event + '.qtip');
self.options.hide.when.target.unbind(self.options.hide.when.event + '.qtip');
self.elements.tooltip.unbind(self.options.hide.when.event + '.qtip');
self.elements.tooltip.unbind('mouseover.qtip', self.focus);
self.elements.tooltip.remove();
}
// Tooltip isn't yet rendered, remove render event
else self.options.show.when.target.unbind(self.options.show.when.event+'.qtip-create');
// Check to make sure qTip data is present on target element
if(typeof self.elements.target.data('qtip') == 'object')
{
// Remove API references from interfaces object
interfaces = self.elements.target.data('qtip').interfaces;
if(typeof interfaces == 'object' && interfaces.length > 0)
{
// Remove API from interfaces array
for(i = 0; i < interfaces.length - 1; i++)
if(interfaces[i].id == self.id) interfaces.splice(i, 1)
}
}
delete $.fn.qtip.interfaces[self.id];
// Set qTip current id to previous tooltips API if available
if(typeof interfaces == 'object' && interfaces.length > 0)
self.elements.target.data('qtip').current = interfaces.length -1;
else
self.elements.target.removeData('qtip');
// Call API method and log destroy
self.onDestroy.call(self);
$.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_DESTROYED, 'destroy');
return self.elements.target
},
getPosition: function()
{
var show, offset;
// Make sure tooltip is rendered and if not, return
if(!self.status.rendered)
return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'getPosition');
show = (self.elements.tooltip.css('display') !== 'none') ? false : true;
// Show and hide tooltip to make sure coordinates are returned
if(show) self.elements.tooltip.css({ visiblity: 'hidden' }).show();
offset = self.elements.tooltip.offset();
if(show) self.elements.tooltip.css({ visiblity: 'visible' }).hide();
return offset;
},
getDimensions: function()
{
var show, dimensions;
// Make sure tooltip is rendered and if not, return
if(!self.status.rendered)
return $.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.TOOLTIP_NOT_RENDERED, 'getDimensions');
show = (!self.elements.tooltip.is(':visible')) ? true : false;
// Show and hide tooltip to make sure dimensions are returned
if(show) self.elements.tooltip.css({ visiblity: 'hidden' }).show();
dimensions = {
height: self.elements.tooltip.outerHeight(),
width: self.elements.tooltip.outerWidth()
};
if(show) self.elements.tooltip.css({ visiblity: 'visible' }).hide();
return dimensions;
}
});
};
// Define priamry construct function
function construct()
{
var self, adjust, content, url, data, method, tempLength;
self = this;
// Call API method
self.beforeRender.call(self);
// Set rendered status to true
self.status.rendered = true;
// Create initial tooltip elements
self.elements.tooltip = '<div qtip="'+self.id+'" ' +
'class="qtip '+(self.options.style.classes.tooltip || self.options.style)+'"' +
'style="display:none; -moz-border-radius:0; -webkit-border-radius:0; border-radius:0;' +
'position:'+self.options.position.type+';">' +
' <div class="qtip-wrapper" style="position:relative; overflow:hidden; text-align:left;">' +
' <div class="qtip-contentWrapper" style="overflow:hidden;">' +
' <div class="qtip-content '+self.options.style.classes.content+'"></div>' +
'</div></div></div>';
// Append to container element
self.elements.tooltip = $(self.elements.tooltip);
self.elements.tooltip.appendTo(self.options.position.container)
// Setup tooltip qTip data
self.elements.tooltip.data('qtip', { current: 0, interfaces: [self] });
// Setup element references
self.elements.wrapper = self.elements.tooltip.children('div:first');
self.elements.contentWrapper = self.elements.wrapper.children('div:first').css({ background: self.options.style.background });
self.elements.content = self.elements.contentWrapper.children('div:first').css( jQueryStyle(self.options.style) );
// Apply IE hasLayout fix to wrapper and content elements
if($.browser.msie) self.elements.wrapper.add(self.elements.content).css({ zoom: 1 });
// Setup tooltip attributes
if(self.options.hide.when.event == 'unfocus') self.elements.tooltip.attr('unfocus', true);
// If an explicit width is set, updateWidth prior to setting content to prevent dirty rendering
if(typeof self.options.style.width.value == 'number') self.updateWidth();
// Create borders and tips if supported by the browser
if($('<canvas>').get(0).getContext || $.browser.msie)
{
// Create border
if(self.options.style.border.radius > 0)
createBorder.call(self);
else
self.elements.contentWrapper.css({ border: self.options.style.border.width+'px solid '+self.options.style.border.color });
// Create tip if enabled
if(self.options.style.tip.corner !== false)
createTip.call(self);
}
// Neither canvas or VML is supported, tips and borders cannot be drawn!
else
{
// Set defined border width
self.elements.contentWrapper.css({ border: self.options.style.border.width+'px solid '+self.options.style.border.color });
// Reset border radius and tip
self.options.style.border.radius = 0;
self.options.style.tip.corner = false;
// Inform via log
$.fn.qtip.log.error.call(self, 2, $.fn.qtip.constants.CANVAS_VML_NOT_SUPPORTED, 'render');
};
// Use the provided content string or DOM array
if((typeof self.options.content.text == 'string' && self.options.content.text.length > 0)
|| (self.options.content.text.jquery && self.options.content.text.length > 0))
content = self.options.content.text;
// Use title string for content if present
else if(typeof self.elements.target.attr('title') == 'string' && self.elements.target.attr('title').length > 0)
{
content = self.elements.target.attr('title').replace("\\n", '<br />');
self.elements.target.attr('title', ''); // Remove title attribute to prevent default tooltip showing
}
// No title is present, use alt attribute instead
else if(typeof self.elements.target.attr('alt') == 'string' && self.elements.target.attr('alt').length > 0)
{
content = self.elements.target.attr('alt').replace("\\n", '<br />');
self.elements.target.attr('alt', ''); // Remove alt attribute to prevent default tooltip showing
}
// No valid content was provided, inform via log
else
{
content = ' ';
$.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.NO_VALID_CONTENT, 'render');
};
// Set the tooltips content and create title if enabled
if(self.options.content.title.text !== false) createTitle.call(self);
self.updateContent(content);
// Assign events and toggle tooltip with focus
assignEvents.call(self);
if(self.options.show.ready === true) self.show();
// Retrieve ajax content if provided
if(self.options.content.url !== false)
{
url = self.options.content.url;
data = self.options.content.data;
method = self.options.content.method || 'get';
self.loadContent(url, data, method);
};
// Call API method and log event
self.onRender.call(self);
$.fn.qtip.log.error.call(self, 1, $.fn.qtip.constants.EVENT_RENDERED, 'render');
};
// Create borders using canvas and VML
function createBorder()
{
var self, i, width, radius, color, coordinates, containers, size, betweenWidth, betweenCorners, borderTop, borderBottom, borderCoord, sideWidth, vertWidth;
self = this;
// Destroy previous border elements, if present
self.elements.wrapper.find('.qtip-borderBottom, .qtip-borderTop').remove();
// Setup local variables
width = self.options.style.border.width;
radius = self.options.style.border.radius;
color = self.options.style.border.color || self.options.style.tip.color;
// Calculate border coordinates
coordinates = calculateBorders(radius);
// Create containers for the border shapes
containers = {};
for(i in coordinates)
{
// Create shape container
containers[i] = '<div rel="'+i+'" style="'+((i.search(/Left/) !== -1) ? 'left' : 'right') + ':0; ' +
'position:absolute; height:'+radius+'px; width:'+radius+'px; overflow:hidden; line-height:0.1px; font-size:1px">';
// Canvas is supported
if($('<canvas>').get(0).getContext)
containers[i] += '<canvas height="'+radius+'" width="'+radius+'" style="vertical-align: top"></canvas>';
// No canvas, but if it's IE use VML
else if($.browser.msie)
{
size = radius * 2 + 3;
containers[i] += '<v:arc stroked="false" fillcolor="'+color+'" startangle="'+coordinates[i][0]+'" endangle="'+coordinates[i][1]+'" ' +
'style="width:'+size+'px; height:'+size+'px; margin-top:'+((i.search(/bottom/) !== -1) ? -2 : -1)+'px; ' +
'margin-left:'+((i.search(/Right/) !== -1) ? coordinates[i][2] - 3.5 : -1)+'px; ' +
'vertical-align:top; display:inline-block; behavior:url(#default#VML)"></v:arc>';
};
containers[i] += '</div>';
};
// Create between corners elements
betweenWidth = self.getDimensions().width - (Math.max(width, radius) * 2);
betweenCorners = '<div class="qtip-betweenCorners" style="height:'+radius+'px; width:'+betweenWidth+'px; ' +
'overflow:hidden; background-color:'+color+'; line-height:0.1px; font-size:1px;">';
// Create top border container
borderTop = '<div class="qtip-borderTop" dir="ltr" style="height:'+radius+'px; ' +
'margin-left:'+radius+'px; line-height:0.1px; font-size:1px; padding:0;">' +
containers['topLeft'] + containers['topRight'] + betweenCorners;
self.elements.wrapper.prepend(borderTop);
// Create bottom border container
borderBottom = '<div class="qtip-borderBottom" dir="ltr" style="height:'+radius+'px; ' +
'margin-left:'+radius+'px; line-height:0.1px; font-size:1px; padding:0;">' +
containers['bottomLeft'] + containers['bottomRight'] + betweenCorners;
self.elements.wrapper.append(borderBottom);
// Draw the borders if canvas were used (Delayed til after DOM creation)
if($('<canvas>').get(0).getContext)
{
self.elements.wrapper.find('canvas').each(function()
{
borderCoord = coordinates[ $(this).parent('[rel]:first').attr('rel') ];
drawBorder.call(self, $(this), borderCoord, radius, color);
})
}
// Create a phantom VML element (IE won't show the last created VML element otherwise)
else if($.browser.msie) self.elements.tooltip.append('<v:image style="behavior:url(#default#VML);"></v:image>');
// Setup contentWrapper border
sideWidth = Math.max(radius, (radius + (width - radius)) )
vertWidth = Math.max(width - radius, 0);
self.elements.contentWrapper.css({
border: '0px solid ' + color,
borderWidth: vertWidth + 'px ' + sideWidth + 'px'
})
};
// Border canvas draw method
function drawBorder(canvas, coordinates, radius, color)
{
// Create corner
var context = canvas.get(0).getContext('2d');
context.fillStyle = color;
context.beginPath();
context.arc(coordinates[0], coordinates[1], radius, 0, Math.PI * 2, false);
context.fill();
};
// Create tip using canvas and VML
function createTip(corner)
{
var self, color, coordinates, coordsize, path;
self = this;
// Destroy previous tip, if there is one
if(self.elements.tip !== null) self.elements.tip.remove();
// Setup color and corner values
color = self.options.style.tip.color || self.options.style.border.color;
if(self.options.style.tip.corner === false) return;
else if(!corner) corner = self.options.style.tip.corner;
// Calculate tip coordinates
coordinates = calculateTip(corner, self.options.style.tip.size.width, self.options.style.tip.size.height);
// Create tip element
self.elements.tip = '<div class="'+self.options.style.classes.tip+'" dir="ltr" rel="'+corner+'" style="position:absolute; ' +
'height:'+self.options.style.tip.size.height+'px; width:'+self.options.style.tip.size.width+'px; ' +
'margin:0 auto; line-height:0.1px; font-size:1px;">';
// Use canvas element if supported
if($('<canvas>').get(0).getContext)
self.elements.tip += '<canvas height="'+self.options.style.tip.size.height+'" width="'+self.options.style.tip.size.width+'"></canvas>';
// Canvas not supported - Use VML (IE)
else if($.browser.msie)
{
// Create coordize and tip path using tip coordinates
coordsize = self.options.style.tip.size.width + ',' + self.options.style.tip.size.height;
path = 'm' + coordinates[0][0] + ',' + coordinates[0][1];
path += ' l' + coordinates[1][0] + ',' + coordinates[1][1];
path += ' ' + coordinates[2][0] + ',' + coordinates[2][1];
path += ' xe';
// Create VML element
self.elements.tip += '<v:shape fillcolor="'+color+'" stroked="false" filled="true" path="'+path+'" coordsize="'+coordsize+'" ' +
'style="width:'+self.options.style.tip.size.width+'px; height:'+self.options.style.tip.size.height+'px; ' +
'line-height:0.1px; display:inline-block; behavior:url(#default#VML); ' +
'vertical-align:'+((corner.search(/top/) !== -1) ? 'bottom' : 'top')+'"></v:shape>';
// Create a phantom VML element (IE won't show the last created VML element otherwise)
self.elements.tip += '<v:image style="behavior:url(#default#VML);"></v:image>';
// Prevent tooltip appearing above the content (IE z-index bug)
self.elements.contentWrapper.css('position', 'relative');
};
// Attach new tip to tooltip element
self.elements.tooltip.prepend(self.elements.tip + '</div>');
// Create element reference and draw the canvas tip (Delayed til after DOM creation)
self.elements.tip = self.elements.tooltip.find('.'+self.options.style.classes.tip).eq(0);
if($('<canvas>').get(0).getContext)
drawTip.call(self, self.elements.tip.find('canvas:first'), coordinates, color);
// Fix IE small tip bug
if(corner.search(/top/) !== -1 && $.browser.msie && parseInt($.browser.version.charAt(0)) === 6)
self.elements.tip.css({ marginTop: -4 });
// Set the tip position
positionTip.call(self, corner);
};
// Canvas tip drawing method
function drawTip(canvas, coordinates, color)
{
// Setup properties
var context = canvas.get(0).getContext('2d');
context.fillStyle = color;
// Create tip
context.beginPath();
context.moveTo(coordinates[0][0], coordinates[0][1]);
context.lineTo(coordinates[1][0], coordinates[1][1]);
context.lineTo(coordinates[2][0], coordinates[2][1]);
context.fill();
};
function positionTip(corner)
{
var self, ieAdjust, paddingCorner, paddingSize, newMargin;
self = this;
// Return if tips are disabled or tip is not yet rendered
if(self.options.style.tip.corner === false || !self.elements.tip) return;
if(!corner) corner = self.elements.tip.attr('rel');
// Setup adjustment variables
ieAdjust = positionAdjust = ($.browser.msie) ? 1 : 0;
// Set initial position
self.elements.tip.css(corner.match(/left|right|top|bottom/)[0], 0);
// Set position of tip to correct side
if(corner.search(/top|bottom/) !== -1)
{
// Adjustments for IE6 - 0.5px border gap bug
if($.browser.msie)
{
if(parseInt($.browser.version.charAt(0)) === 6)
positionAdjust = (corner.search(/top/) !== -1) ? -3 : 1;
else
positionAdjust = (corner.search(/top/) !== -1) ? 1 : 2;
};
if(corner.search(/Middle/) !== -1)
self.elements.tip.css({ left: '50%', marginLeft: -(self.options.style.tip.size.width / 2) });
else if(corner.search(/Left/) !== -1)
self.elements.tip.css({ left: self.options.style.border.radius - ieAdjust });
else if(corner.search(/Right/) !== -1)
self.elements.tip.css({ right: self.options.style.border.radius + ieAdjust });
if(corner.search(/top/) !== -1)
self.elements.tip.css({ top: -positionAdjust });
else
self.elements.tip.css({ bottom: positionAdjust });
}
else if(corner.search(/left|right/) !== -1)
{
// Adjustments for IE6 - 0.5px border gap bug
if($.browser.msie)
positionAdjust = (parseInt($.browser.version.charAt(0)) === 6) ? 1 : ((corner.search(/left/) !== -1) ? 1 : 2);
if(corner.search(/Middle/) !== -1)
self.elements.tip.css({ top: '50%', marginTop: -(self.options.style.tip.size.height / 2) });
else if(corner.search(/Top/) !== -1)
self.elements.tip.css({ top: self.options.style.border.radius - ieAdjust });
else if(corner.search(/Bottom/) !== -1)
self.elements.tip.css({ bottom: self.options.style.border.radius + ieAdjust });
if(corner.search(/left/) !== -1)
self.elements.tip.css({ left: -positionAdjust });
else
self.elements.tip.css({ right: positionAdjust });
};
// Adjust tooltip padding to compensate for tip
paddingCorner = 'padding-' + corner.match(/left|right|top|bottom/)[0];
paddingSize = self.options.style.tip.size[ (paddingCorner.search(/left|right/) !== -1) ? 'width' : 'height' ];
self.elements.tooltip.css('padding', 0);
self.elements.tooltip.css(paddingCorner, paddingSize);
// Match content margin to prevent gap bug in IE6 ONLY
if($.browser.msie && parseInt($.browser.version.charAt(0)) == 6)
{
newMargin = parseInt(self.elements.tip.css('margin-top')) || 0;
newMargin += parseInt(self.elements.content.css('margin-top')) || 0;
self.elements.tip.css({ marginTop: newMargin });
};
};
// Create title bar for content
function createTitle()
{
var self = this;
// Destroy previous title element, if present
if(self.elements.title !== null) self.elements.title.remove();
// Create title element
self.elements.title = $('<div class="'+self.options.style.classes.title+'">')
.css( jQueryStyle(self.options.style.title, true) )
.css({ zoom: ($.browser.msie) ? 1 : 0 })
.prependTo(self.elements.contentWrapper);
// Update title with contents if enabled
if(self.options.content.title.text) self.updateTitle.call(self, self.options.content.title.text);
// Create title close buttons if enabled
if(self.options.content.title.button !== false
&& typeof self.options.content.title.button == 'string')
{
self.elements.button = $('<a class="'+self.options.style.classes.button+'" style="float:right; position: relative"></a>')
.css( jQueryStyle(self.options.style.button, true) )
.html(self.options.content.title.button)
.prependTo(self.elements.title)
.click(function(event){ if(!self.status.disabled) self.hide(event) });
};
};
// Assign hide and show events
function assignEvents()
{
var self, showTarget, hideTarget, inactiveEvents;
self = this;
// Setup event target variables
showTarget = self.options.show.when.target;
hideTarget = self.options.hide.when.target;
// Add tooltip as a hideTarget is its fixed
if(self.options.hide.fixed) hideTarget = hideTarget.add(self.elements.tooltip);
// Check if the hide event is special 'inactive' type
if(self.options.hide.when.event == 'inactive')
{
// Define events which reset the 'inactive' event handler
inactiveEvents = ['click', 'dblclick', 'mousedown', 'mouseup', 'mousemove',
'mouseout', 'mouseenter', 'mouseleave', 'mouseover' ];
// Define 'inactive' event timer method
function inactiveMethod(event)
{
if(self.status.disabled === true) return;
//Clear and reset the timer
clearTimeout(self.timers.inactive);
self.timers.inactive = setTimeout(function()
{
// Unassign 'inactive' events
$(inactiveEvents).each(function()
{
hideTarget.unbind(this+'.qtip-inactive');
self.elements.content.unbind(this+'.qtip-inactive');
});
// Hide the tooltip
self.hide(event);
}
, self.options.hide.delay);
};
}
// Check if the tooltip is 'fixed'
else if(self.options.hide.fixed === true)
{
self.elements.tooltip.bind('mouseover.qtip', function()
{
if(self.status.disabled === true) return;
// Reset the hide timer
clearTimeout(self.timers.hide);
});
};
// Define show event method
function showMethod(event)
{
if(self.status.disabled === true) return;
// If set, hide tooltip when inactive for delay period
if(self.options.hide.when.event == 'inactive')
{
// Assign each reset event
$(inactiveEvents).each(function()
{
hideTarget.bind(this+'.qtip-inactive', inactiveMethod);
self.elements.content.bind(this+'.qtip-inactive', inactiveMethod);
});
// Start the inactive timer
inactiveMethod();
};
// Clear hide timers
clearTimeout(self.timers.show);
clearTimeout(self.timers.hide);
// Start show timer
self.timers.show = setTimeout(function(){ self.show(event); }, self.options.show.delay);
};
// Define hide event method
function hideMethod(event)
{
if(self.status.disabled === true) return;
// Prevent hiding if tooltip is fixed and event target is the tooltip
if(self.options.hide.fixed === true
&& self.options.hide.when.event.search(/mouse(out|leave)/i) !== -1
&& $(event.relatedTarget).parents('div.qtip[qtip]').length > 0)
{
// Prevent default and popagation
event.stopPropagation();
event.preventDefault();
// Reset the hide timer
clearTimeout(self.timers.hide);
return false;
};
// Clear timers and stop animation queue
clearTimeout(self.timers.show);
clearTimeout(self.timers.hide);
self.elements.tooltip.stop(true, true);
// If tooltip has displayed, start hide timer
self.timers.hide = setTimeout(function(){ self.hide(event); }, self.options.hide.delay);
};
// Both events and targets are identical, apply events using a toggle
if((self.options.show.when.target.add(self.options.hide.when.target).length === 1
&& self.options.show.when.event == self.options.hide.when.event
&& self.options.hide.when.event !== 'inactive')
|| self.options.hide.when.event == 'unfocus')
{
self.cache.toggle = 0;
// Use a toggle to prevent hide/show conflicts
showTarget.bind(self.options.show.when.event + '.qtip', function(event)
{
if(self.cache.toggle == 0) showMethod(event);
else hideMethod(event);
});
}
// Events are not identical, bind normally
else
{
showTarget.bind(self.options.show.when.event + '.qtip', showMethod);
// If the hide event is not 'inactive', bind the hide method
if(self.options.hide.when.event !== 'inactive')
hideTarget.bind(self.options.hide.when.event + '.qtip', hideMethod);
};
// Focus the tooltip on mouseover
if(self.options.position.type.search(/(fixed|absolute)/) !== -1)
self.elements.tooltip.bind('mouseover.qtip', self.focus);
// If mouse is the target, update tooltip position on mousemove
if(self.options.position.target === 'mouse' && self.options.position.type !== 'static')
{
showTarget.bind('mousemove.qtip', function(event)
{
// Set the new mouse positions if adjustment is enabled
self.cache.mouse = { x: event.pageX, y: event.pageY };
// Update the tooltip position only if the tooltip is visible and adjustment is enabled
if(self.status.disabled === false
&& self.options.position.adjust.mouse === true
&& self.options.position.type !== 'static'
&& self.elements.tooltip.css('display') !== 'none')
self.updatePosition(event);
});
};
};
// Screen position adjustment
function screenAdjust(position, target, tooltip)
{
var self, adjustedPosition, adjust, newCorner, overflow, corner;
self = this;
// Setup corner and adjustment variable
if(tooltip.corner == 'center') return target.position // TODO: 'center' corner adjustment
adjustedPosition = $.extend({}, position);
newCorner = { x: false, y: false };
// Define overflow properties
overflow = {
left: (adjustedPosition.left < $.fn.qtip.cache.screen.scroll.left),
right: (adjustedPosition.left + tooltip.dimensions.width + 2 >= $.fn.qtip.cache.screen.width + $.fn.qtip.cache.screen.scroll.left),
top: (adjustedPosition.top < $.fn.qtip.cache.screen.scroll.top),
bottom: (adjustedPosition.top + tooltip.dimensions.height + 2 >= $.fn.qtip.cache.screen.height + $.fn.qtip.cache.screen.scroll.top)
};
// Determine new positioning properties
adjust = {
left: (overflow.left && (tooltip.corner.search(/right/i) != -1 || (tooltip.corner.search(/right/i) == -1 && !overflow.right))),
right: (overflow.right && (tooltip.corner.search(/left/i) != -1 || (tooltip.corner.search(/left/i) == -1 && !overflow.left))),
top: (overflow.top && tooltip.corner.search(/top/i) == -1),
bottom: (overflow.bottom && tooltip.corner.search(/bottom/i) == -1)
};
// Tooltip overflows off the left side of the screen
if(adjust.left)
{
if(self.options.position.target !== 'mouse')
adjustedPosition.left = target.position.left + target.dimensions.width;
else
adjustedPosition.left = self.cache.mouse.x
newCorner.x = 'Left';
}
// Tooltip overflows off the right side of the screen
else if(adjust.right)
{
if(self.options.position.target !== 'mouse')
adjustedPosition.left = target.position.left - tooltip.dimensions.width;
else
adjustedPosition.left = self.cache.mouse.x - tooltip.dimensions.width;
newCorner.x = 'Right';
};
// Tooltip overflows off the top of the screen
if(adjust.top)
{
if(self.options.position.target !== 'mouse')
adjustedPosition.top = target.position.top + target.dimensions.height;
else
adjustedPosition.top = self.cache.mouse.y
newCorner.y = 'top';
}
// Tooltip overflows off the bottom of the screen
else if(adjust.bottom)
{
if(self.options.position.target !== 'mouse')
adjustedPosition.top = target.position.top - tooltip.dimensions.height;
else
adjustedPosition.top = self.cache.mouse.y - tooltip.dimensions.height;
newCorner.y = 'bottom';
};
// Don't adjust if resulting position is negative
if(adjustedPosition.left < 0)
{
adjustedPosition.left = position.left;
newCorner.x = false;
};
if(adjustedPosition.top < 0)
{
adjustedPosition.top = position.top;
newCorner.y = false;
};
// Change tip corner if positioning has changed and tips are enabled
if(self.options.style.tip.corner !== false)
{
// Determine new corner properties
adjustedPosition.corner = new String(tooltip.corner);
if(newCorner.x !== false) adjustedPosition.corner = adjustedPosition.corner.replace(/Left|Right|Middle/, newCorner.x);
if(newCorner.y !== false) adjustedPosition.corner = adjustedPosition.corner.replace(/top|bottom/, newCorner.y);
// Adjust tip if position has changed and tips are enabled
if(adjustedPosition.corner !== self.elements.tip.attr('rel'))
createTip.call(self, adjustedPosition.corner);
};
return adjustedPosition;
};
// Build a jQuery style object from supplied style object
function jQueryStyle(style, sub)
{
var styleObj, i;
styleObj = $.extend(true, {}, style);
for(i in styleObj)
{
if(sub === true && i.search(/(tip|classes)/i) !== -1)
delete styleObj[i];
else if(!sub && i.search(/(width|border|tip|title|classes|user)/i) !== -1)
delete styleObj[i];
};
return styleObj;
};
// Sanitize styles
function sanitizeStyle(style)
{
if(typeof style.tip !== 'object') style.tip = { corner: style.tip };
if(typeof style.tip.size !== 'object') style.tip.size = { width: style.tip.size, height: style.tip.size };
if(typeof style.border !== 'object') style.border = { width: style.border };
if(typeof style.width !== 'object') style.width = { value: style.width };
if(typeof style.width.max == 'string') style.width.max = parseInt(style.width.max.replace(/([0-9]+)/i, "$1"));
if(typeof style.width.min == 'string') style.width.min = parseInt(style.width.min.replace(/([0-9]+)/i, "$1"));
// Convert deprecated x and y tip values to width/height
if(typeof style.tip.size.x == 'number')
{
style.tip.size.width = style.tip.size.x;
delete style.tip.size.x;
};
if(typeof style.tip.size.y == 'number')
{
style.tip.size.height = style.tip.size.y;
delete style.tip.size.y;
};
return style;
};
// Build styles recursively with inheritance
function buildStyle()
{
var self, i, styleArray, styleExtend, finalStyle, ieAdjust;
self = this;
// Build style options from supplied arguments
styleArray = [true, {}];
for(i = 0; i < arguments.length; i++)
styleArray.push(arguments[i]);
styleExtend = [ $.extend.apply($, styleArray) ];
// Loop through each named style inheritance
while(typeof styleExtend[0].name == 'string')
{
// Sanitize style data and append to extend array
styleExtend.unshift( sanitizeStyle($.fn.qtip.styles[ styleExtend[0].name ]) );
};
// Make sure resulting tooltip className represents final style
styleExtend.unshift(true, {classes:{ tooltip: 'qtip-' + (arguments[0].name || 'defaults') }}, $.fn.qtip.styles.defaults);
// Extend into a single style object
finalStyle = $.extend.apply($, styleExtend);
// Adjust tip size if needed (IE 1px adjustment bug fix)
ieAdjust = ($.browser.msie) ? 1 : 0;
finalStyle.tip.size.width += ieAdjust;
finalStyle.tip.size.height += ieAdjust;
// Force even numbers for pixel precision
if(finalStyle.tip.size.width % 2 > 0) finalStyle.tip.size.width += 1;
if(finalStyle.tip.size.height % 2 > 0) finalStyle.tip.size.height += 1;
// Sanitize final styles tip corner value
if(finalStyle.tip.corner === true)
finalStyle.tip.corner = (self.options.position.corner.tooltip === 'center') ? false : self.options.position.corner.tooltip;
return finalStyle;
};
// Tip coordinates calculator
function calculateTip(corner, width, height)
{
// Define tip coordinates in terms of height and width values
var tips = {
bottomRight: [[0,0], [width,height], [width,0]],
bottomLeft: [[0,0], [width,0], [0,height]],
topRight: [[0,height], [width,0], [width,height]],
topLeft: [[0,0], [0,height], [width,height]],
topMiddle: [[0,height], [width / 2,0], [width,height]],
bottomMiddle: [[0,0], [width,0], [width / 2,height]],
rightMiddle: [[0,0], [width,height / 2], [0,height]],
leftMiddle: [[width,0], [width,height], [0,height / 2]]
};
tips.leftTop = tips.bottomRight;
tips.rightTop = tips.bottomLeft;
tips.leftBottom = tips.topRight;
tips.rightBottom = tips.topLeft;
return tips[corner];
};
// Border coordinates calculator
function calculateBorders(radius)
{
var borders;
// Use canvas element if supported
if($('<canvas>').get(0).getContext)
{
borders = {
topLeft: [radius,radius], topRight: [0,radius],
bottomLeft: [radius,0], bottomRight: [0,0]
};
}
// Canvas not supported - Use VML (IE)
else if($.browser.msie)
{
borders = {
topLeft: [-90,90,0], topRight: [-90,90,-radius],
bottomLeft: [90,270,0], bottomRight: [90, 270,-radius]
};
};
return borders;
};
// BGIFRAME JQUERY PLUGIN ADAPTION
// Special thanks to Brandon Aaron for this plugin
// http://plugins.jquery.com/project/bgiframe
function bgiframe()
{
var self, html, dimensions;
self = this;
dimensions = self.getDimensions();
// Setup iframe HTML string
html = '<iframe class="qtip-bgiframe" frameborder="0" tabindex="-1" src="javascript:false" '+
'style="display:block; position:absolute; z-index:-1; filter:alpha(opacity=\'0\'); border: 1px solid red; ' +
'height:'+dimensions.height+'px; width:'+dimensions.width+'px" />';
// Append the new HTML and setup element reference
self.elements.bgiframe = self.elements.wrapper.prepend(html).children('.qtip-bgiframe:first');
};
// Assign cache and event initialisation on document load
$(document).ready(function()
{
// Setup library cache with window scroll and dimensions of document
$.fn.qtip.cache = {
screen: {
scroll: { left: $(window).scrollLeft(), top: $(window).scrollTop() },
width: $(window).width(),
height: $(window).height()
}
};
// Adjust positions of the tooltips on window resize or scroll if enabled
var adjustTimer;
$(window).bind('resize scroll', function(event)
{
clearTimeout(adjustTimer);
adjustTimer = setTimeout(function()
{
// Readjust cached screen values
if(event.type === 'scroll')
$.fn.qtip.cache.screen.scroll = { left: $(window).scrollLeft(), top: $(window).scrollTop() };
else
{
$.fn.qtip.cache.screen.width = $(window).width();
$.fn.qtip.cache.screen.height = $(window).height();
};
for(i = 0; i < $.fn.qtip.interfaces.length; i++)
{
// Access current elements API
var api = $.fn.qtip.interfaces[i];
// Update position if resize or scroll adjustments are enabled
if(api.status.rendered === true
&& (api.options.position.type !== 'static'
|| api.options.position.adjust.scroll && event.type === 'scroll'
|| api.options.position.adjust.resize && event.type === 'resize'))
{
// Queue the animation so positions are updated correctly
api.updatePosition(event, true);
}
};
}
, 100);
})
// Hide unfocus toolipts on document mousedown
$(document).bind('mousedown.qtip', function(event)
{
if($(event.target).parents('div.qtip').length === 0)
{
$('.qtip[unfocus]').each(function()
{
var api = $(this).qtip("api");
// Only hide if its visible and not the tooltips target
if($(this).is(':visible') && !api.status.disabled
&& $(event.target).add(api.elements.target).length > 1)
api.hide(event);
})
};
})
});
// Define qTip API interfaces array
$.fn.qtip.interfaces = []
// Define log and constant place holders
$.fn.qtip.log = { error: function(){ return this; } };
$.fn.qtip.constants = {};
// Define configuration defaults
$.fn.qtip.defaults = {
// Content
content: {
prerender: false,
text: false,
url: false,
data: null,
title: {
text: false,
button: false
}
},
// Position
position: {
target: false,
corner: {
target: 'bottomRight',
tooltip: 'topLeft'
},
adjust: {
x: 0, y: 0,
mouse: true,
screen: false,
scroll: true,
resize: true
},
type: 'absolute',
container: false
},
// Effects
show: {
when: {
target: false,
event: 'mouseover'
},
effect: {
type: 'fade',
length: 100
},
delay: 140,
solo: false,
ready: false
},
hide: {
when: {
target: false,
event: 'mouseout'
},
effect: {
type: 'fade',
length: 100
},
delay: 0,
fixed: false
},
// Callbacks
api: {
beforeRender: function(){},
onRender: function(){},
beforePositionUpdate: function(){},
onPositionUpdate: function(){},
beforeShow: function(){},
onShow: function(){},
beforeHide: function(){},
onHide: function(){},
beforeContentUpdate: function(){},
onContentUpdate: function(){},
beforeContentLoad: function(){},
onContentLoad: function(){},
beforeTitleUpdate: function(){},
onTitleUpdate: function(){},
beforeDestroy: function(){},
onDestroy: function(){},
beforeFocus: function(){},
onFocus: function(){}
}
};
$.fn.qtip.styles = {
defaults: {
background: 'white',
color: '#111',
overflow: 'hidden',
textAlign: 'left',
width: {
min: 0,
max: 250
},
padding: '5px 9px',
border: {
width: 1,
radius: 0,
color: '#d3d3d3'
},
tip: {
corner: false,
color: false,
size: { width: 13, height: 13 },
opacity: 1
},
title: {
background: '#e1e1e1',
fontWeight: 'bold',
padding: '7px 12px'
},
button: {
cursor: 'pointer'
},
classes: {
target: '',
tip: 'qtip-tip',
title: 'qtip-title',
button: 'qtip-button',
content: 'qtip-content',
active: 'qtip-active'
}
},
cream: {
border: {
width: 3,
radius: 0,
color: '#F9E98E'
},
title: {
background: '#F0DE7D',
color: '#A27D35'
},
background: '#FBF7AA',
color: '#A27D35',
classes: { tooltip: 'qtip-cream' }
},
light: {
border: {
width: 3,
radius: 0,
color: '#E2E2E2'
},
title: {
background: '#f1f1f1',
color: '#454545'
},
background: 'white',
color: '#454545',
classes: { tooltip: 'qtip-light' }
},
dark: {
border: {
width: 3,
radius: 0,
color: '#303030'
},
title: {
background: '#404040',
color: '#f3f3f3'
},
background: '#505050',
color: '#f3f3f3',
classes: { tooltip: 'qtip-dark' }
},
red: {
border: {
width: 3,
radius: 0,
color: '#CE6F6F'
},
title: {
background: '#f28279',
color: '#9C2F2F'
},
background: '#F79992',
color: '#9C2F2F',
classes: { tooltip: 'qtip-red' }
},
green: {
border: {
width: 3,
radius: 0,
color: '#A9DB66'
},
title: {
background: '#b9db8c',
color: '#58792E'
},
background: '#CDE6AC',
color: '#58792E',
classes: { tooltip: 'qtip-green' }
},
blue: {
border: {
width: 3,
radius: 0,
color: '#ADD9ED'
},
title: {
background: '#D0E9F5',
color: '#5E99BD'
},
background: '#E5F6FE',
color: '#4D9FBF',
classes: { tooltip: 'qtip-blue' }
}
};
})(jQuery); | JavaScript |
window.error_alert=function(title,content,callback)
{
var dlg = $('<div id="ualertdlg"></div>');
var content = $('<div class="content"></div>').append(content);
var closeBtn = $('<button class="btn btn-large"><i class="fa fa-times"></i> Close</button>');
dlg.append(content);
dlg.append(closeBtn);
dlg.dialog({
modal:true,
title:title,
width:300,
height:160,
close:function(){
if(typeof callback == 'function')
{
callback(dlg);
}
dlg.remove();
}
});
closeBtn.click(function(){
dlg.dialog('close')});
$('div[aria-describedby=ualertdlg]').addClass('err-dlg')
};
window.confirm_alert=function(title,content,onConfirm,onCancel,onLoad){
var dlg = $('<div id="ualertdlg"></div>');
dlg.append(content);
dlg.dialog({
modal:true,
title:title,
width:400,
height:160,
close:function(){
dlg.remove();
},
open : function(){
if(typeof onLoad == 'function')
{
onLoad(dlg);
}
}
});
dlg.dialog('option', 'title', title);
dlg.dialog('option', 'buttons', {
"Yes" : function(){
$(this).dialog("close");
onConfirm(dlg);
},
"No" : function() {
$(this).dialog("close");
onCancel(dlg);
}});
var yesBtn = dlg.parent().find('.ui-dialog-buttonset button:first');
var noBtn = yesBtn.next();
yesBtn.attr('class','btn btn-large');
noBtn.attr('class','btn btn-large');
yesBtn.html('<i class="fa fa-check"></i> Ok');
noBtn.html('<i class="fa fa-times"></i> Cancel');
yesBtn.unbind('mouseover');
noBtn.unbind('mouseover');
dlg.dialog("open");
$('div[aria-describedby=ualertdlg]').addClass('err-dlg');
}; | JavaScript |
window.ImageMapEditorCallback = {
currentImage : '',
onDrawStop : function(obj,app,type) {
////console.log(arguments)
},
onSaveItem : function(id,data){
//console.log(id)
//console.log(data)
},
onLoad : function(areas,img){
//console.log(areas);
//return;
window.ImageMapEditorCallback.currentImage = img;
// //console.log(areas)
// //console.log(img)
window.shmc.app.loadFromJSON(areas,img);
},
load : function(areas){
window.shmc.app.loadFromJSON(areas,window.ImageMapEditorCallback.currentImage);
},
onAfterSaveAll : function(newAreas){
window.ImageMapEditorCallback.load(newAreas);
},
onRemove : function(obj){
var row_id = 0;
if(typeof obj.row_id != 'undefined')
row_id = obj.row_id;
if(obj.row_id)
{
var id = window.sub_group_part_id();
var url = base_url() + 'content_management/part_position_code_delete/'+row_id+'/'+id;
$.post(url,{},function(newAreas){
window.ImageMapEditorCallback.onAfterSaveAll(newAreas);
},'json');
}
},
onSaveAll : function(obj){
////console.log(obj);
var areas = obj.areas;
if(areas.length)
{
var data = JSON.stringify(areas);
var id = window.sub_group_part_id();
var url = base_url() + 'content_management/part_position_code_update/'+id;
////console.log(data);
$.post(url,{data:data},function(newAreas){
window.ImageMapEditorCallback.onAfterSaveAll(newAreas);
},'json');
}
}
}
| JavaScript |
/*
* Summer html image map creator
* http://github.com/summerstyle/summer
*
* Copyright 2013 Vera Lobacheva (summerstyle.ru)
* Released under the GPL3 (GPL3.txt)
*
* Thu May 15 2013 15:15:27 GMT+0400
*/
/**
* Fire an event handler to the specified node. Event handlers can detect that the event was fired programatically
* by testing for a 'synthetic=true' property on the event object
* @param {HTMLNode} node The node to fire the event handler on.
* @param {String} eventName The name of the event without the "on" (e.g., "focus")
*/
function fireEvent(node, eventName) {
// Make sure we use the ownerDocument from the provided node to avoid cross-window problems
var doc;
if (node.ownerDocument) {
doc = node.ownerDocument;
} else if (node.nodeType == 9){
// the node may be the document itself, nodeType 9 = DOCUMENT_NODE
doc = node;
} else {
throw new Error("Invalid node passed to fireEvent: " + node.id);
}
if (node.dispatchEvent) {
// Gecko-style approach (now the standard) takes more work
var eventClass = "";
// Different events have different event classes.
// If this switch statement can't map an eventName to an eventClass,
// the event firing is going to fail.
switch (eventName) {
case "click": // Dispatching of 'click' appears to not work correctly in Safari. Use 'mousedown' or 'mouseup' instead.
case "mousedown":
case "mouseup":
eventClass = "MouseEvents";
break;
case "focus":
case "change":
case "blur":
case "select":
eventClass = "HTMLEvents";
break;
default:
throw "fireEvent: Couldn't find an event class for event '" + eventName + "'.";
break;
}
var event = doc.createEvent(eventClass);
var bubbles = eventName == "change" ? false : true;
event.initEvent(eventName, bubbles, true); // All events created as bubbling and cancelable.
event.synthetic = true; // allow detection of synthetic events
// The second parameter says go ahead with the default action
node.dispatchEvent(event, true);
} else if (node.fireEvent) {
// IE-old school style
var event = doc.createEventObject();
event.synthetic = true; // allow detection of synthetic events
node.fireEvent("on" + eventName, event);
}
};
"use strict";
function SummerHtmlImageMapCreator() {
/* Utilities */
var utils = {
offsetX : function(node) {
var box = node.getBoundingClientRect(),
scroll = window.pageXOffset;
return Math.round(box.left + scroll);
},
offsetY : function(node) {
var box = node.getBoundingClientRect(),
scroll = window.pageYOffset;
return Math.round(box.top + scroll);
},
rightX : function(x) {
return x-app.getOffset('x');
},
rightY : function(y) {
return y-app.getOffset('y');
},
trim : function(str) {
return str.replace(/^\s+|\s+$/g, '');
},
id : function (str) {
return document.getElementById(str);
},
hide : function(node) {
node.style.display = 'none';
return this;
},
show : function(node) {
node.style.display = 'block';
return this;
},
encode : function(str) {
return str.replace(/</g, '<').replace(/>/g, '>');
},
foreach : function(arr, func) {
for(var i = 0, count = arr.length; i < count; i++) {
func(arr[i], i);
}
},
foreachReverse : function(arr, func) {
for(var i = arr.length - 1; i >= 0; i--) {
func(arr[i], i);
}
},
debug : (function() {
var output = document.getElementById('debug');
return function() {
output.innerHTML = [].join.call(arguments, ' ');
}
})(),
stopEvent : function(e) {
e.stopPropagation();
e.preventDefault();
return this;
},
addClass : function(node, str) {
// node.className.baseVal for SVG-elements
// or
// node.className for HTML-elements
var is_svg = node.className.baseVal !== undefined ? true : false,
arr = is_svg ? node.className.baseVal.split(' ') : node.className.split(' '),
isset = false;
utils.foreach(arr, function(x) {
if(x === str) {
isset = true;
}
});
if (!isset) {
arr.push(str);
is_svg ? node.className.baseVal = arr.join(' ') : node.className = arr.join(' ');
}
return this;
},
removeClass : function(node, str) {
var is_svg = node.className.baseVal !== undefined ? true : false,
arr = is_svg ? node.className.baseVal.split(' ') : node.className.split(' '),
isset = false;
utils.foreach(arr, function(x, i) {
if(x === str) {
isset = true;
arr.splice(i--, 1);
}
});
if (isset) {
is_svg ? node.className.baseVal = arr.join(' ') : node.className = arr.join(' ');
}
return this;
},
hasClass : function(node, str) {
var is_svg = node.className.baseVal !== undefined ? true : false,
arr = is_svg ? node.className.baseVal.split(' ') : node.className.split(' '),
isset = false;
utils.foreach(arr, function(x) {
if(x === str) {
isset = true;
}
});
return isset;
},
extend : function(obj, options) {
var target = {};
for (name in obj) {
if(obj.hasOwnProperty(name)) {
target[name] = options[name] ? options[name] : obj[name];
}
}
return target;
},
supportFileReader : (function() {
//console.log('iam called.');
return (typeof FileReader !== 'undefined');
})()
};
SummerHtmlImageMapCreator.utils = utils;
/* Main object */
var app = (function() {
//console.log('iam called 204');
var body = document.getElementsByTagName('body')[0],
wrapper = utils.id('wrapper'),
svg = utils.id('svg'),
img = utils.id('img'),
img_src = null,
container = utils.id('image'),
about = utils.id('about'),
coords_info = utils.id('coords'),
offset = {x: 0, y: 0},
shape = null,
is_draw = false,
mode = null, // drawing || editing || preview
objects = [],
new_area = null,
selected_area = null,
edit_type,
events = [],
map,
filename,
KEYS = {
F1 : 112,
ESC : 27,
TOP : 38,
BOTTOM : 40,
LEFT : 37,
RIGHT : 39,
DELETE : 46,
I : 73,
S : 83,
C : 67
};
function recalcOffsetValues() {
offset.x = utils.offsetX(container);
offset.y = utils.offsetY(container);
};
/* Get offset value */
window.addEventListener('resize', recalcOffsetValues, false);
/* Disable selection */
container.addEventListener('mousedown', function(e) { e.preventDefault(); }, false);
/* Disable image dragging */
img.addEventListener('dragstart', function(e){
e.preventDefault();
}, false);
/* Display cursor coordinates info */
container.addEventListener('mousemove', function(e){
coords_info.innerHTML = 'x: ' + utils.rightX(e.pageX) + ', ' + 'y: ' + utils.rightY(e.pageY);
}, false);
container.addEventListener('mouseleave', function(){
coords_info.innerHTML = '';
}, false);
/* Add mousedown event for svg */
function onSvgMousedown(e) {
if (mode === 'editing') {
if (e.target.parentNode.tagName === 'g') {
info.unload();
selected_area = e.target.parentNode.obj;
app.deselectAll();
selected_area.select();
selected_area.delta = {
'x' : e.pageX,
'y' : e.pageY
};
if (utils.hasClass(e.target, 'helper')) {
var helper = e.target;
edit_type = helper.action;
if (helper.n >= 0) { // if typeof selected_area == polygon
selected_area.selected_point = helper.n;
}
app.addEvent(container, 'mousemove', selected_area.onEdit)
.addEvent(container, 'mouseup', selected_area.onEditStop);
} else if (e.target.tagName === 'rect' || e.target.tagName === 'circle' || e.target.tagName === 'polygon') {
edit_type = 'move';
app.addEvent(container, 'mousemove', selected_area.onEdit)
.addEvent(container, 'mouseup', selected_area.onEditStop);
};
} else {
app.deselectAll();
info.unload();
};
};
}
container.addEventListener('mousedown', onSvgMousedown, false);
/* Add click event for svg */
function onSvgClick(e) {
//console.log('Hello iam clicked');
if (mode === 'drawing' && !is_draw && shape) {
code.hide();
switch (shape) {
case 'rect':
new_area = new Rect(utils.rightX(e.pageX), utils.rightY(e.pageY));
app.addEvent(container, 'mousemove', new_area.onDraw)
.addEvent(container, 'click', new_area.onDrawStop);
break;
case 'circle':
new_area = new Circle(utils.rightX(e.pageX), utils.rightY(e.pageY));
app.addEvent(container, 'mousemove', new_area.onDraw)
.addEvent(container, 'click', new_area.onDrawStop);
break;
case 'polygon':
new_area = new Polygon(utils.rightX(e.pageX), utils.rightY(e.pageY));
app.addEvent(container, 'mousemove', new_area.onDraw)
.addEvent(container, 'click', new_area.onDrawAddPoint)
.addEvent(document, 'keydown', new_area.onDrawStop)
.addEvent(new_area.helpers[0].helper, 'click', new_area.onDrawStop);
break;
};
};
};
function onSvgRightClick (e) {
//console.log('Iam right click on line 336');
e.preventDefault();
}
container.addEventListener('contextmenu', onSvgRightClick, false);
container.addEventListener('click', onSvgClick, false);
/* Bug with keydown event for SVG in Opera browser
(when hot keys don't work after focusing on svg element) */
function operaSvgKeydownBugFix() {
window.focus();
}
if (window.navigator.appName === 'Opera') {
container.addEventListener('mousedown', operaSvgKeydownBugFix, false);
container.addEventListener('mouseup', operaSvgKeydownBugFix, false);
container.addEventListener('click', operaSvgKeydownBugFix, false);
container.addEventListener('dblclick', operaSvgKeydownBugFix, false);
};
/* Add dblclick event for svg */
function onAreaDblClick(e) {
if (mode === 'editing') {
if (e.target.tagName === 'rect' || e.target.tagName === 'circle' || e.target.tagName === 'polygon') {
selected_area = e.target.parentNode.obj;
////console.log(selected_area);
info.load(selected_area, e.pageX, e.pageY);
};
};
};
container.addEventListener('dblclick', onAreaDblClick, false);
/* Add keydown event for document */
function onDocumentKeyDown(e) {
return true;
var ctrlDown = e.ctrlKey || e.metaKey // PC || Mac
switch (e.keyCode) {
// case KEYS.F1: /* F1 key */
// help.show();
// e.preventDefault();
// break;
case KEYS.ESC: /* ESC key */
help.hide();
if (is_draw) {
is_draw = false;
new_area.remove();
objects.pop();
app.removeAllEvents();
} else if (mode === 'editing') {
selected_area.redraw();
app.removeAllEvents();
};
break;
case KEYS.TOP: /* Top arrow key */
if (mode === 'editing' && selected_area) {
selected_area.setParams(selected_area.dynamicEdit(selected_area['move'](0, -1)));
e.preventDefault();
}
break;
case KEYS.BOTTOM: /* Bottom arrow key */
if (mode === 'editing' && selected_area) {
selected_area.setParams(selected_area.dynamicEdit(selected_area['move'](0, 1)));
e.preventDefault();
}
break;
case KEYS.LEFT: /* Left arrow key */
if (mode === 'editing' && selected_area) {
selected_area.setParams(selected_area.dynamicEdit(selected_area['move'](-1, 0)));
e.preventDefault();
}
break;
case KEYS.RIGHT: /* Right arrow key */
if (mode === 'editing' && selected_area) {
selected_area.setParams(selected_area.dynamicEdit(selected_area['move'](1, 0)));
e.preventDefault();
}
break;
case KEYS.DELETE: /* DELETE key */
if (mode === 'editing' && selected_area) {
app.removeObject(selected_area);
selected_area = null;
info.unload();
}
break;
case KEYS.I: /* i (edit info) key */
if (mode === 'editing' && selected_area) {
var params = selected_area.params,
x = params.x || params.cx || params[0],
y = params.y || params.cy || params[1];
info.load(selected_area, x + app.getOffset('x'), y + app.getOffset('y'));
}
break;
// case KEYS.S: /* s (save) key */
// app.saveInLocalStorage();
// break;
case KEYS.C: /* CTRL+C copy */
if (mode === 'editing' && selected_area && ctrlDown) {
var Constructor = null,
area_params = selected_area.toJSON(),
area;
switch (area_params.type) {
case 'rect':
Constructor = Rect;
break;
case 'circle':
Constructor = Circle;
break;
case 'polygon':
Constructor = Polygon;
break;
}
if (Constructor) {
Constructor.createFromSaved(area_params);
selected_area.setParams(selected_area.move(10, 10));
selected_area.redraw();
}
}
break;
}
}
document.addEventListener('keydown', onDocumentKeyDown, false);
/* Returned object */
return {
saveInLocalStorage : function() {
var obj = {
areas : [],
img : img_src
};
utils.foreach(objects, function(x) {
obj.areas.push(x.toJSON());
});
//window.localStorage.setItem('SummerHTMLImageMapCreator', JSON.stringify(obj));
//alert('Saved');
window.ImageMapEditorCallback.onSaveAll(obj);
return this;
},
loadFromJSON : function(areas,img) {
app.clear();
//var str = window.localStorage.getItem('SummerHTMLImageMapCreator'),
// obj = JSON.parse(str),
//var areas = obj.areas;
var obj = {
areas : areas,
img : img
};
this.loadImage(img);
var i = 0;
utils.foreach(obj.areas, function(x) {
x.coords = x.coords.replace(/\s+/g,'');
x.coords = x.coords.split(',');
//console.log(x.coords);
var coords = [];
$.each(x.coords,function(i,v){
coords.push(parseInt(v));
});
obj.areas[i].coords = coords;
i+=1;
//console.log(coords);
switch (x.type) {
case 'rect':
////console.log(x);
if (x.coords.length === 4) {
Rect.createFromSaved({
coords : coords,
href : '#',
alt : x.position_code_name,
title : '',
row_id : x.row_id,
model_code : x.model_code,
group_code_part : x.group_code_part,
sub_group_code : x.sub_group_code,
position_code_link : x.position_code_link,
position_code_part : x.position_code_part,
position_code_name : x.position_code_name
});
}
break;
case 'circle':
if (x.coords.length === 3) {
Circle.createFromSaved({
coords : x.coords,
href : x.href,
alt : x.alt,
title : x.title,
row_id : x.row_id,
model_code : x.model_code,
group_code_part : x.group_code_part,
sub_group_code : x.sub_group_code,
position_code_link : x.position_code_link,position_code_part : x.position_code_part,
position_code_name : x.position_code_name
});
}
break;
case 'polygon':
if (x.coords.length >= 6 && x.coords.length % 2 === 0) {
Polygon.createFromSaved({
coords : x.coords,
href : x.href,
alt : x.alt,
title : x.title,
row_id : x.row_id,
model_code : x.model_code,
group_code_part : x.group_code_part,
sub_group_code : x.sub_group_code,
position_code_link : x.position_code_link,position_code_part : x.position_code_part,
position_code_name : x.position_code_name
});
}
break;
}
});
return this;
},
loadFromLocalStorage : function() {
var str = window.localStorage.getItem('SummerHTMLImageMapCreator'),
obj = JSON.parse(str),
areas = obj.areas;
this.loadImage(obj.img);
utils.foreach(areas, function(x) {
switch (x.type) {
case 'rect':
if (x.coords.length === 4) {
Rect.createFromSaved({
coords : x.coords,
href : x.href,
alt : x.alt,
title : x.title,
row_id : x.row_id,
model_code : x.model_code,
group_code_part : x.group_code_part,
sub_group_code : x.sub_group_code,
position_code_link : x.position_code_link,position_code_part : x.position_code_part,
position_code_name : x.position_code_name
});
}
break;
case 'circle':
if (x.coords.length === 3) {
Circle.createFromSaved({
coords : x.coords,
href : x.href,
alt : x.alt,
title : x.title,
row_id : x.row_id,
model_code : x.model_code,
group_code_part : x.group_code_part,
sub_group_code : x.sub_group_code,
position_code_link : x.position_code_link,position_code_part : x.position_code_part,
position_code_name : x.position_code_name
});
}
break;
case 'polygon':
if (x.coords.length >= 6 && x.coords.length % 2 === 0) {
Polygon.createFromSaved({
coords : x.coords,
href : x.href,
alt : x.alt,
title : x.title,
row_id : x.row_id,
model_code : x.model_code,
group_code_part : x.group_code_part,
sub_group_code : x.sub_group_code,
position_code_link : x.position_code_link,position_code_part : x.position_code_part,
position_code_name : x.position_code_name
});
}
break;
}
});
return this;
},
hide : function() {
utils.hide(wrapper);
return this;
},
show : function() {
utils.show(wrapper);
return this;
},
recalcOffsetValues: function() {
recalcOffsetValues();
return this;
},
setDimensions : function(width, height) {
svg.setAttribute('width', width);
svg.setAttribute('height', height);
container.style.width = width + 'px';
container.style.height = height + 'px';
return this;
},
loadImage : function(url) {
get_image.showLoadIndicator();
img.src = url;
img_src = url;
img.onload = function() {
get_image.hideLoadIndicator().hide();
app.show()
.setDimensions(img.width, img.height)
.recalcOffsetValues();
};
return this;
},
preview : (function() {
img.setAttribute('usemap', '#map');
map = document.createElement('map');
map.setAttribute('name', 'map');
container.appendChild(map);
return function() {
info.unload();
app.setShape(null);
utils.hide(svg);
map.innerHTML = app.getHTMLCode();
//setTimeout(function(){
$('.map').maphilight({
alwaysOn :true,
// fillColor : '#dedede',
// fillOpacity : .2
});
$('area').each(function()
{
$(this).qtip(
{
content: $(this).attr('alt'), // Use the ALT attribute of the area map
style: {
name: 'dark', // Give it the preset dark style
border: {
width: 0,
radius: 2
},
position: {
corner: {
target: 'topLeft',
tooltip: 'middleRight'
}
},
tip: true // Apply a tip at the default tooltip corner
}
});
});
// /},200);
//code.print();
return this;
}
})(),
hidePreview : function() {
utils.show(svg);
map.innerHTML = '';
$('.map canvas').remove();
return this;
},
addNodeToSvg : function(node) {
svg.appendChild(node);
return this;
},
removeNodeFromSvg : function(node) {
svg.removeChild(node);
return this;
},
getOffset : function(arg) {
switch(arg) {
case 'x':
return offset.x;
break;
case 'y':
return offset.y;
break;
}
return undefined;
},
clear : function(){
//remove all areas
objects.length = 0;
while(svg.childNodes[0]) {
svg.removeChild(svg.childNodes[0]);
}
code.hide();
info.unload();
return this;
},
removeObject : function(obj) {
var b_confirm = false;
utils.foreach(objects, function(x, i) {
if(x === obj) {
if(confirm('Apakah anda yakin ingin menghapus objek ini ?')){
b_confirm = true;
window.ImageMapEditorCallback.onRemove(x);
objects.splice(i, 1);
}
}
});
if(b_confirm)
{
obj.remove();
}
return this;
},
deselectAll : function() {
utils.foreach(objects, function(x) {
x.deselect();
});
return this;
},
getIsDraw : function() {
return is_draw;
},
setIsDraw : function(arg) {
is_draw = arg;
return this;
},
setMode : function(arg) {
mode = arg;
return this;
},
getMode : function() {
return mode;
},
setShape : function(arg) {
shape = arg;
return this;
},
getShape : function() {
return shape;
},
addObject : function(object) {
objects.push(object);
return this;
},
getNewArea : function() {
return new_area;
},
resetNewArea : function() {
new_area = null;
return this;
},
getSelectedArea : function() {
return selected_area;
},
setSelectedArea : function(obj) {
selected_area = obj;
return this;
},
getEditType : function() {
return edit_type;
},
setFilename : function(str) {
filename = str;
return this;
},
setEditClass : function() {
utils.removeClass(container, 'draw')
.addClass(container, 'edit');
return this;
},
setDrawClass : function() {
utils.removeClass(container, 'edit')
.addClass(container, 'draw');
return this;
},
setDefaultClass : function() {
utils.removeClass(container, 'edit')
.removeClass(container, 'draw');
return this;
},
addEvent : function(target, eventType, func) {
events.push(new AppEvent(target, eventType, func));
return this;
},
removeAllEvents : function() {
utils.foreach(events, function(x) {
x.remove();
});
events.length = 0;
return this;
},
getHTMLCode : function(arg) {
var html_code = '';
if (arg) {
if (!objects.length) {
return '0 objects';
}
html_code += utils.encode('<img src="' + filename + '" alt="" usemap="#map" />') +
'<br />' + utils.encode('<map name="map">') + '<br />';
utils.foreachReverse(objects, function(x) {
html_code += ' ' + utils.encode(x.toString()) + '<br />';
});
html_code += utils.encode('</map>');
} else {
utils.foreachReverse(objects, function(x) {
html_code += x.toString();
});
}
return html_code;
}
};
})();
SummerHtmlImageMapCreator.app = app;
/* Help block */
var help = (function() {
var block = utils.id('help'),
overlay = utils.id('overlay'),
close_button = block.querySelector('.close_button');
function hide() {
// utils.hide(block);
// utils.hide(overlay);
}
function show() {
// utils.show(block);
// utils.show(overlay);
}
overlay.addEventListener('click', hide, false);
close_button.addEventListener('click', hide, false);
return {
show : show,
hide : hide
};
})();
/* For html code of created map */
var code = (function(){
var block = utils.id('code'),
content = utils.id('code_content'),
close_button = block.querySelector('.close_button');
close_button.addEventListener('click', function(e) {
utils.hide(block);
e.preventDefault();
}, false);
return {
print: function() {
content.innerHTML = app.getHTMLCode(true);
utils.show(block);
},
hide: function() {
utils.hide(block);
}
};
})();
/* Edit selected area info */
var info = (function() {
var form = utils.id('edit_details'),
header = form.querySelector('h5'),
href_attr = utils.id('href_attr'),
alt_attr = utils.id('alt_attr'),
title_attr = utils.id('title_attr'),
save_button = utils.id('save_details'),
row_id = utils.id('row_id'),
model_code = utils.id('model_code'),
group_code_part = utils.id('group_code_part'),
sub_group_code = utils.id('sub_group_code'),
position_code_part = utils.id('position_code_part'),
position_code_link = utils.id('position_code_link'),
position_code_name = utils.id('position_code_name'),
close_button = form.querySelector('.close_button'),
sections = form.querySelectorAll('p'),
obj,
x,
y,
temp_x,
temp_y;
function changedReset() {
utils.removeClass(form, 'changed');
utils.foreach(sections, function(x) {
utils.removeClass(x, 'changed');
});
}
function save(e) {
// obj.href = href_attr.value;
// obj.alt = alt_attr.value;
// obj.title = title_attr.value;
//obj.row_id = row_id.value;
obj.model_code = model_code.value;
obj.group_code_part = group_code_part.value;
obj.sub_group_code = sub_group_code.value;
obj.position_code_part= position_code_part.value;
obj.position_code_name = position_code_name.value;
var validation_errors = [];
var validation_keys = ['model_code','group_code_part','sub_group_code','position_code_part','position_code_name'];
$.each(validation_keys,function(i,k){
if(obj[k].length <= 0)
{
var field_name = k.replace(/_/g,' ').toUpperCase();
validation_errors.push('<b><u>'+field_name+'</u></b>.');
}
});
// obj.href ? obj.with_href() : obj.without_href();
if(validation_errors.length > 0)
{
parent.error_alert('Peringatan','Anda harus melengkapi field berikut ini sebelum menyimpan :<br/>'+validation_errors.join('<br/>'))
}
else if($('#position_code_part').val().length < 6)
{
parent.error_alert('Peringatan','Position Code Part minimal 6 karakter !');
$('#position_code_part').focus();
return false;
}
else
{
app.saveInLocalStorage();
info.unload();
}
// console.log(obj.toJSON());
changedReset();
e.preventDefault();
};
function unload() {
//
obj = null;
changedReset();
utils.hide(form);
}
function setCoords(x, y) {
form.style.left = (x + 5) + 'px';
form.style.top = (y + 5) + 'px';
}
function moveEditBlock(e) {
setCoords(x + e.pageX - temp_x, y + e.pageY - temp_y);
}
function stopMoveEditBlock(e) {
x = x + e.pageX - temp_x;
y = y + e.pageY - temp_y;
setCoords(x, y);
app.removeAllEvents();
}
function change() {
utils.addClass(form, 'changed');
utils.addClass(this.parentNode, 'changed');
}
save_button.addEventListener('click', save, false);
// href_attr.addEventListener('keydown', function(e) { e.stopPropagation(); }, false);
// alt_attr.addEventListener('keydown', function(e) { e.stopPropagation(); }, false);
// title_attr.addEventListener('keydown', function(e) { e.stopPropagation(); }, false);
// href_attr.addEventListener('change', change, false);
// alt_attr.addEventListener('change', change, false);
// title_attr.addEventListener('change', change, false);
function close_info()
{
var validation_errors = [];
var validation_keys = ['model_code','group_code_part','sub_group_code','position_code_part','position_code_name'];
$.each(validation_keys,function(i,k){
var value = $('#'+k).val()
if(value.length <= 0)
{
var field_name = k.replace(/_/g,' ').toUpperCase();
validation_errors.push('<b><u>'+field_name+'</u></b>.');
}
});
// obj.href ? obj.with_href() : obj.without_href();
if(validation_errors.length > 0)
{
parent.error_alert('Peringatan','Anda harus melengkapi field berikut ini sebelum menyimpan :<br/>'+validation_errors.join('<br/>'))
return false;
}
if($('#position_code_part').val().length < 6)
{
parent.error_alert('Peringatan','Position Code Part minimal 6 karakter !');
$('#position_code_part').focus();
return false;
}
unload();
}
close_button.addEventListener('click', close_info, false);
header.addEventListener('mousedown', function(e) {
temp_x = e.pageX,
temp_y = e.pageY;
app.addEvent(document, 'mousemove', moveEditBlock);
app.addEvent(header, 'mouseup', stopMoveEditBlock);
e.preventDefault();
}, false);
return {
load : function(object, new_x, new_y) {
obj = object;
// href_attr.value = object.href ? object.href : '';
// alt_attr.value = object.alt ? object.alt : '';
// title_attr.value = object.title ? object.title : '';
utils.show(form);
if (new_x && new_y) {
x = new_x;
y = new_y;
setCoords(x, y);
}
window.ImageMapEditorCallback.onLoadInfo(object,new_x,new_y);
},
unload : unload
};
})();
/* Load areas from html code */
var from_html_form = (function() {
var form = utils.id('from_html_wrapper'),
code_input = utils.id('code_input'),
load_button = utils.id('load_code_button'),
close_button = form.querySelector('.close_button'),
regexp_area = /<area(?=.*? shape="(rect|circle|poly)")(?=.*? coords="([\d ,]+?)")[\s\S]*?>/gmi,
regexp_href = / href="([\S\s]+?)"/,
regexp_alt = / alt="([\S\s]+?)"/,
regexp_title = / title="([\S\s]+?)"/;
function test(str) {
var result_area,
result_href,
result_alt,
result_title,
type,
coords,
area,
href,
alt,
title,
success = false;
if (str) {
result_area = regexp_area.exec(str);
while (result_area) {
success = true;
area = result_area[0];
type = result_area[1];
coords = result_area[2].split(/ ?, ?/);
result_href = regexp_href.exec(area);
if (result_href) {
href = result_href[1];
} else {
href = '';
}
result_alt = regexp_alt.exec(area);
if (result_alt) {
alt = result_alt[1];
} else {
alt = '';
}
result_title = regexp_title.exec(area);
if (result_title) {
title = result_title[1];
} else {
title = '';
}
for (var i = 0, len = coords.length; i < len; i++) {
coords[i] = Number(coords[i]);
}
switch (type) {
case 'rect':
if (coords.length === 4) {
Rect.createFromSaved({
coords : coords,
href : href,
alt : alt,
title : title
});
}
break;
case 'circle':
if (coords.length === 3) {
Circle.createFromSaved({
coords : coords,
href : href,
alt : alt,
title : title
});
}
break;
case 'poly':
if (coords.length >= 6 && coords.length % 2 === 0) {
Polygon.createFromSaved({
coords : coords,
href : href,
alt : alt,
title : title
});
}
break;
}
result_area = regexp_area.exec(str);
}
if (success) {
hide();
}
}
}
function load(e) {
test(code_input.value);
e.preventDefault();
};
function hide() {
utils.hide(form);
}
load_button.addEventListener('click', load, false);
close_button.addEventListener('click', hide, false);
return {
show : function() {
code_input.value = '';
utils.show(form);
},
hide : hide
};
})();
/* Get image form */
var get_image = (function() {
//console.log('iam called 1011');
var block = utils.id('get_image_wrapper'),
loading_indicator = utils.id('loading'),
button = utils.id('button'),
filename = null,
last_changed = null;
// Drag'n'drop - the first way to loading an image
var drag_n_drop = (function() {
var dropzone = utils.id('dropzone'),
dropzone_clear_button = dropzone.querySelector('.clear_button'),
sm_img = utils.id('sm_img');
if (!utils.supportFileReader) { // For IE9
utils.hide(utils.id('file_reader_support'));
};
function testFile(type) {
switch (type) {
case 'image/jpeg':
case 'image/gif':
case 'image/png':
return true;
break;
}
return false;
}
dropzone.addEventListener('dragover', function(e){
utils.stopEvent(e);
}, false);
dropzone.addEventListener('dragleave', function(e){
utils.stopEvent(e);
}, false);
dropzone.addEventListener('drop', function(e){
utils.stopEvent(e);
var reader = new FileReader(),
file = e.dataTransfer.files[0];
if (testFile(file.type)) {
utils.removeClass(dropzone, 'error');
reader.readAsDataURL(file);
reader.onload = function(e) {
sm_img.src = e.target.result;
sm_img.style.display = 'inline-block';
filename = file.name;
utils.show(dropzone_clear_button);
last_changed = drag_n_drop;
};
} else {
clearDropzone();
utils.addClass(dropzone, 'error');
}
}, false);
function clearDropzone() {
sm_img.src = '';
utils.hide(sm_img)
.hide(dropzone_clear_button)
.removeClass(dropzone, 'error');
last_changed = url_input;
};
dropzone_clear_button.addEventListener('click', clearDropzone, false);
return {
clear : clearDropzone,
init : function() {
dropzone.draggable = true;
this.clear();
utils.hide(sm_img)
.hide(dropzone_clear_button);
},
test : function() {
return sm_img.src ? true : false;
},
getImage : function() {
return sm_img.src;
}
};
})();
/* Set a url - the second way to loading an image */
var url_input = (function() {
var url = utils.id('url'),
url_clear_button = url.parentNode.querySelector('.clear_button');
function testUrl(str) {
var url_str = utils.trim(str),
temp_array = url_str.split('.'),
ext;
if(temp_array.length > 1) {
ext = temp_array[temp_array.length-1].toLowerCase();
switch (ext) {
case 'jpg':
case 'jpeg':
case 'gif':
case 'png':
return true;
break;
};
};
return false;
}
function onUrlChange() {
setTimeout(function(){
if(url.value.length) {
utils.show(url_clear_button);
last_changed = url_input;
} else {
utils.hide(url_clear_button);
last_changed = drag_n_drop;
}
}, 0);
}
url.addEventListener('keypress', onUrlChange, false);
url.addEventListener('change', onUrlChange, false);
url.addEventListener('paste', onUrlChange, false);
function clearUrl() {
url.value = '';
utils.hide(url_clear_button);
utils.removeClass(url, 'error');
last_changed = url_input;
};
url_clear_button.addEventListener('click', clearUrl, false);
return {
clear : clearUrl,
init : function() {
//this.clear();
utils.hide(url_clear_button);
},
test : function() {
if(testUrl(url.value)) {
utils.removeClass(url, 'error');
return true;
} else {
utils.addClass(url, 'error');
};
return false;
},
getImage : function() {
var tmp_arr = url.value.split('/');
filename = tmp_arr[tmp_arr.length - 1];
return utils.trim(url.value)
}
};
})();
/* Block init */
function init() {
utils.hide(loading_indicator);
drag_n_drop.init();
url_input.init();
}
init();
/* Block clear */
function clear() {
drag_n_drop.clear();
url_input.clear();
last_changed = null;
};
/* Selected image loading */
function onButtonClick(e) {
if (last_changed === url_input && url_input.test()) {
app.loadImage(url_input.getImage()).setFilename(filename);
} else if (last_changed === drag_n_drop && drag_n_drop.test()) {
app.loadImage(drag_n_drop.getImage()).setFilename(filename);
}
e.preventDefault();
};
button.addEventListener('click', onButtonClick, false);
/* Returned object */
return {
show : function() {
clear();
utils.show(block);
return this;
},
hide : function() {
utils.hide(block);
return this;
},
showLoadIndicator : function() {
utils.show(loading_indicator);
return this;
},
hideLoadIndicator : function() {
utils.hide(loading_indicator);
return this;
}
};
})();
/* Buttons and actions */
var buttons = (function() {
var all = utils.id('nav').getElementsByTagName('li'),
save = utils.id('save'),
load = utils.id('load'),
rectangle = utils.id('rect'),
circle = utils.id('circle'),
polygon = utils.id('polygon'),
edit = utils.id('edit'),
clear = utils.id('clear'),
from_html = utils.id('from_html'),
to_html = utils.id('to_html'),
preview = utils.id('preview'),
new_image = utils.id('new_image'),
show_help = utils.id('show_help');
function deselectAll() {
utils.foreach(all, function(x) {
utils.removeClass(x, 'selected');
});
}
function selectOne(button) {
deselectAll();
utils.addClass(button, 'selected');
}
function onSaveButtonClick(e) {
// Save in localStorage
app.saveInLocalStorage();
e.preventDefault();
}
function onLoadButtonClick(e) {
// Load from localStorage
app.clear()
.loadFromLocalStorage();
e.preventDefault();
}
function onShapeButtonClick(e) {
// shape = rect || circle || polygon
app.setMode('drawing')
.setDrawClass()
.setShape(this.id)
.deselectAll()
.hidePreview();
info.unload();
selectOne(this);
e.preventDefault();
}
function onClearButtonClick(e) {
////console.log(app.getNewArea());
var selected_area = app.getSelectedArea();
if (app.getMode() === 'editing' && selected_area) {
app.removeObject(selected_area);
selected_area = null;
info.unload();
}else if(!selected_area){
window.parent.error_alert('Peringatan','Silahkan pilih objek lebih dahulu dengan cara mengklik !')
}
// Clear all
// if (confirm('Clear all?')) {
// app.setMode(null)
// .setDefaultClass()
// .setShape(null)
// .clear()
// .hidePreview();
// deselectAll();
// }
e.preventDefault();
}
function onFromHtmlButtonClick(e) {
// Load areas from html
from_html_form.show();
e.preventDefault();
}
function onToHtmlButtonClick(e) {
// Generate html code only
info.unload();
code.print();
e.preventDefault();
}
function onPreviewButtonClick(e) {
if (app.getMode() === 'preview') {
app.setMode(null)
.hidePreview();
deselectAll();
} else {
app.deselectAll()
.setMode('preview')
.setDefaultClass()
.preview();
selectOne(this);
}
e.preventDefault();
}
function onEditButtonClick(e) {
if (app.getMode() === 'editing') {
app.setMode(null)
.setDefaultClass()
.deselectAll();
deselectAll();
utils.show(svg);
} else {
app.setShape(null)
.setMode('editing')
.setEditClass();
selectOne(this);
}
app.hidePreview();
e.preventDefault();
}
function onNewImageButtonClick(e) {
// New image - clear all and back to loading image screen
if(confirm('Discard all changes?')) {
app.setMode(null)
.setDefaultClass()
.setShape(null)
.setIsDraw(false)
.clear()
.hide()
.hidePreview();
deselectAll();
get_image.show();
}
e.preventDefault();
}
function onShowHelpButtonClick(e) {
help.show();
e.preventDefault();
}
save.addEventListener('click', onSaveButtonClick, false);
load.addEventListener('click', onLoadButtonClick, false);
rectangle.addEventListener('click', onShapeButtonClick, false);
circle.addEventListener('click', onShapeButtonClick, false);
polygon.addEventListener('click', onShapeButtonClick, false);
clear.addEventListener('click', onClearButtonClick, false);
from_html.addEventListener('click', onFromHtmlButtonClick, false);
to_html.addEventListener('click', onToHtmlButtonClick, false);
preview.addEventListener('click', onPreviewButtonClick, false);
edit.addEventListener('click', onEditButtonClick, false);
new_image.addEventListener('click', onNewImageButtonClick, false);
show_help.addEventListener('click', onShowHelpButtonClick, false);
})();
/* AppEvent constructor */
function AppEvent(target, eventType, func) {
this.target = target;
this.eventType = eventType;
this.func = func;
target.addEventListener(eventType, func, false);
};
AppEvent.prototype.remove = function() {
this.target.removeEventListener(this.eventType, this.func, false);
};
/* Helper constructor */
function Helper(node, x, y) {
this.helper = document.createElementNS('http://www.w3.org/2000/svg', 'rect');
this.helper.setAttribute('class', 'helper');
this.helper.setAttribute('height', 5);
this.helper.setAttribute('width', 5);
this.helper.setAttribute('x', x-3);
this.helper.setAttribute('y', y-3);
node.appendChild(this.helper);
};
Helper.prototype.setCoords = function(x, y) {
this.helper.setAttribute('x', x-3);
this.helper.setAttribute('y', y-3);
return this;
};
Helper.prototype.setAction = function(action) {
this.helper.action = action;
return this;
};
Helper.prototype.setCursor = function(cursor) {
utils.addClass(this.helper, cursor);
return this;
};
Helper.prototype.setId = function(id) {
this.helper.n = id;
return this;
};
/* Rectangle constructor */
var Rect = function (x, y){
app.setIsDraw(true);
this.params = {
x : x, //distance from the left edge of the image to the left side of the rectangle
y : y, //distance from the top edge of the image to the top side of the rectangle
width : 0, //width of rectangle
height : 0 //height of rectangle
};
this.href = ''; //href attribute - not required
this.alt = ''; //alt attribute - not required
this.title = ''; //title attribute - not required
this.row_id='';
this.model_code ='';
this.group_code_part ='';
this.sub_group_code = '';
this.position_code_part = '';
this.position_code_link = '';
this.position_code_name = '';
this.g = document.createElementNS('http://www.w3.org/2000/svg', 'g'); //container
this.rect = document.createElementNS('http://www.w3.org/2000/svg', 'rect'); //rectangle
app.addNodeToSvg(this.g);
this.g.appendChild(this.rect);
this.g.obj = this; /* Link to parent object */
this.helpers = { //object with all helpers-rectangles
center : new Helper(this.g, x-this.params.width/2, y-this.params.height/2),
top : new Helper(this.g, x-this.params.width/2, y-this.params.height/2),
bottom : new Helper(this.g, x-this.params.width/2, y-this.params.height/2),
left : new Helper(this.g, x-this.params.width/2, y-this.params.height/2),
right : new Helper(this.g, x-this.params.width/2, y-this.params.height/2),
top_left : new Helper(this.g, x-this.params.width/2, y-this.params.height/2),
top_right : new Helper(this.g, x-this.params.width/2, y-this.params.height/2),
bottom_left : new Helper(this.g, x-this.params.width/2, y-this.params.height/2),
bottom_right : new Helper(this.g, x-this.params.width/2, y-this.params.height/2)
};
this.helpers.center.setAction('move').setCursor('move');
this.helpers.left.setAction('editLeft').setCursor('e-resize');
this.helpers.right.setAction('editRight').setCursor('w-resize');
this.helpers.top.setAction('editTop').setCursor('n-resize');
this.helpers.bottom.setAction('editBottom').setCursor('s-resize');
this.helpers.top_left.setAction('editTopLeft').setCursor('nw-resize');
this.helpers.top_right.setAction('editTopRight').setCursor('ne-resize');
this.helpers.bottom_left.setAction('editBottomLeft').setCursor('sw-resize');
this.helpers.bottom_right.setAction('editBottomRight').setCursor('se-resize');
this.select().redraw();
/* Add this object to array of all objects */
app.addObject(this);
};
Rect.prototype.setCoords = function(params){
this.rect.setAttribute('x', params.x);
this.rect.setAttribute('y', params.y);
this.rect.setAttribute('width', params.width);
this.rect.setAttribute('height', params.height);
this.helpers.center.setCoords(params.x + params.width/2, params.y + params.height/2);
this.helpers.top.setCoords(params.x + params.width/2, params.y);
this.helpers.bottom.setCoords(params.x + params.width/2, params.y + params.height);
this.helpers.left.setCoords(params.x, params.y + params.height/2);
this.helpers.right.setCoords(params.x + params.width, params.y + params.height/2);
this.helpers.top_left.setCoords(params.x, params.y);
this.helpers.top_right.setCoords(params.x + params.width, params.y);
this.helpers.bottom_left.setCoords(params.x, params.y + params.height);
this.helpers.bottom_right.setCoords(params.x + params.width, params.y + params.height);
return this;
};
Rect.prototype.setParams = function(params){
this.params.x = params.x;
this.params.y = params.y;
this.params.width = params.width;
this.params.height = params.height;
return this;
};
Rect.prototype.redraw = function() {
this.setCoords(this.params);
return this;
};
Rect.prototype.dynamicDraw = function(x1,y1,square){
var x0 = this.params.x,
y0 = this.params.y,
new_x,
new_y,
new_width,
new_height,
delta,
temp_params;
new_width = Math.abs(x1-x0);
new_height = Math.abs(y1-y0);
if (square) {
delta = new_width-new_height;
if (delta > 0) {
new_width = new_height;
} else {
new_height = new_width;
}
}
if (x0>x1) {
new_x = x1;
if (square && delta > 0) {
new_x = x1 + Math.abs(delta);
}
} else {
new_x = x0;
}
if (y0>y1) {
new_y = y1;
if (square && delta < 0) {
new_y = y1 + Math.abs(delta);
}
} else {
new_y = y0;
}
temp_params = { /* params */
x : new_x,
y : new_y,
width : new_width,
height: new_height
};
this.setCoords(temp_params);
return temp_params;
};
Rect.prototype.onDraw = function(e) {
var _n_f = app.getNewArea(),
square = e.shiftKey ? true : false;
_n_f.dynamicDraw(utils.rightX(e.pageX), utils.rightY(e.pageY), square);
};
Rect.prototype.onDrawStop = function(e) {
var _n_f = app.getNewArea(),
square = e.shiftKey ? true : false;
_n_f.setParams(_n_f.dynamicDraw(utils.rightX(e.pageX), utils.rightY(e.pageY), square)).deselect();
app.removeAllEvents()
.setIsDraw(false)
.resetNewArea();
fireEvent(utils.id('edit'),'click');
//app.setSelectedArea(this);
window.ImageMapEditorCallback.onDrawStop(_n_f,app,'rect');
};
Rect.prototype.move = function(dx, dy) { //offset x and y
var temp_params = Object.create(this.params);
temp_params.x += dx;
temp_params.y += dy;
return temp_params;
};
Rect.prototype.editLeft = function(dx, dy) { //offset x and y
var temp_params = Object.create(this.params);
temp_params.x += dx;
temp_params.width -= dx;
return temp_params;
};
Rect.prototype.editRight = function(dx, dy) { //offset x and y
var temp_params = Object.create(this.params);
temp_params.width += dx;
return temp_params;
};
Rect.prototype.editTop = function(dx, dy) { //offset x and y
var temp_params = Object.create(this.params);
temp_params.y += dy;
temp_params.height -= dy;
return temp_params;
};
Rect.prototype.editBottom = function(dx, dy) { //offset x and y
var temp_params = Object.create(this.params);
temp_params.height += dy;
return temp_params;
};
Rect.prototype.editTopLeft = function(dx, dy) { //offset x and y
var temp_params = Object.create(this.params);
temp_params.x += dx;
temp_params.y += dy;
temp_params.width -= dx;
temp_params.height -= dy;
return temp_params;
};
Rect.prototype.editTopRight = function(dx, dy) { //offset x and y
var temp_params = Object.create(this.params);
temp_params.y += dy;
temp_params.width += dx;
temp_params.height -= dy;
return temp_params;
};
Rect.prototype.editBottomLeft = function(dx, dy) { //offset x and y
var temp_params = Object.create(this.params);
temp_params.x += dx;
temp_params.width -= dx;
temp_params.height += dy;
return temp_params;
};
Rect.prototype.editBottomRight = function(dx, dy) { //offset x and y
var temp_params = Object.create(this.params);
temp_params.width += dx;
temp_params.height += dy;
return temp_params;
};
Rect.prototype.dynamicEdit = function(temp_params, save_proportions) {
if (temp_params.width < 0) {
temp_params.width = Math.abs(temp_params.width);
temp_params.x -= temp_params.width;
}
if (temp_params.height < 0) {
temp_params.height = Math.abs(temp_params.height);
temp_params.y -= temp_params.height;
}
if (save_proportions) {
var proportions = this.params.width / this.params.height,
new_proportions = temp_params.width / temp_params.height,
delta = new_proportions - proportions,
x0 = this.params.x,
y0 = this.params.y,
x1 = temp_params.x,
y1 = temp_params.y;
if (delta > 0) {
temp_params.width = Math.round(temp_params.height * proportions);
} else {
temp_params.height = Math.round(temp_params.width / proportions);
}
}
this.setCoords(temp_params);
return temp_params;
};
Rect.prototype.onEdit = function(e) {
var _s_f = app.getSelectedArea(),
edit_type = app.getEditType(),
save_proportions = e.shiftKey ? true : false;
_s_f.dynamicEdit(_s_f[edit_type](e.pageX - _s_f.delta.x, e.pageY - _s_f.delta.y), save_proportions);
};
Rect.prototype.onEditStop = function(e) {
var _s_f = app.getSelectedArea(),
edit_type = app.getEditType(),
save_proportions = e.shiftKey ? true : false;
_s_f.setParams(_s_f.dynamicEdit(_s_f[edit_type](e.pageX - _s_f.delta.x, e.pageY - _s_f.delta.y), save_proportions));
app.removeAllEvents();
};
Rect.prototype.remove = function() {
app.removeNodeFromSvg(this.g);
};
Rect.prototype.select = function() {
utils.addClass(this.rect, 'selected');
return this;
};
Rect.prototype.deselect = function() {
utils.removeClass(this.rect, 'selected');
return this;
};
Rect.prototype.with_href = function() {
utils.addClass(this.rect, 'with_href');
return this;
}
Rect.prototype.without_href = function() {
utils.removeClass(this.rect, 'with_href');
return this;
}
Rect.prototype.toString = function() { //to html map area code
var x2 = this.params.x + this.params.width,
y2 = this.params.y + this.params.height;
return '<area shape="rect" coords="'
+ this.params.x + ', '
+ this.params.y + ', '
+ x2 + ', '
+ y2
+ '"'
+ (this.href ? ' href="' + this.href + '"' : ' href="#"')
+ (this.position_code_name ? ' alt="' + this.position_code_name + '"' : '')
+ (this.position_code_name ? ' title="' + '"' : '')
+ (this.row_id ? ' row_id="' + this.row_id + '"' : '')
+ (this.model_code ? ' model_code="' + this.model_code + '"' : '')
+ (this.group_code_part ? ' group_code_part="' + this.group_code_part + '"' : '')
+ (this.sub_group_code ? ' sub_group_code="' + this.sub_group_code + '"' : '')
+ (this.position_code_part ? ' position_code_part="' + this.position_code_part + '"' : '') + (this.position_code_link ? ' position_code_link="' + this.position_code_link + '"' : '')
+ (this.position_code_name ? ' position_code_name="' + this.position_code_name + '"' : '')
+ ' />';
};
Rect.createFromSaved = function(params) {
var coords = params.coords,
href = params.href,
alt = params.alt,
title = params.title,
row_id = params.row_id,
model_code = params.model_code,
group_code_part = params.group_code_part,
sub_group_code = params.sub_group_code,
position_code_part = params.position_code_part,
position_code_name = params.position_code_name,
area = new Rect(coords[0], coords[1]);
area.setParams(area.dynamicDraw(coords[2], coords[3])).deselect();
app.setIsDraw(false)
.resetNewArea();
if (href) {
area.href = href;
}
if (alt) {
area.alt = alt;
}
if (title) {
area.title = title;
}
if (row_id) {
area.row_id = row_id;
//console.log(row_id);
}
if (model_code) {
area.model_code = model_code;
}
if (group_code_part) {
area.group_code_part = group_code_part;
}
if (sub_group_code) {
area.sub_group_code = sub_group_code;
}
if (position_code_name) {
area.position_code_name = position_code_name;
}
if (position_code_part) {
area.position_code_part = position_code_part;
}
if (position_code_part) {
area.position_code_link = position_code_link;
}
//console.log(area);
};
Rect.prototype.toJSON = function() {
return {
type : 'rect',
coords : [
this.params.x,
this.params.y,
this.params.x + this.params.width,
this.params.y + this.params.height
],
href : this.href,
alt : this.alt,
title : this.title,
row_id : this.row_id,
model_code : this.model_code,
group_code_part : this.group_code_part,
sub_group_code : this.sub_group_code,
position_code_part : this.position_code_part,
position_code_link : this.position_code_link,
position_code_name : this.position_code_name
}
};
/* Circle constructor */
var Circle = function (x, y){
app.setIsDraw(true);
this.params = {
cx : x, //distance from the left edge of the image to the center of the circle
cy : y, //distance from the top edge of the image to the center of the circle
radius : 0 //radius of the circle
};
this.href = ''; //href attribute - not required
this.alt = ''; //alt attribute - not required
this.title = ''; //title attribute - not required
this.row_id='';
this.model_code ='';
this.group_code_part ='';
this.sub_group_code = '';
this.position_code_part = '';
this.position_code_name = '';
this.g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
this.circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
app.addNodeToSvg(this.g);
this.g.appendChild(this.circle);
this.g.obj = this; /* Link to parent object */
this.helpers = { //array of all helpers-rectangles
center : new Helper(this.g, x, y),
top : new Helper(this.g, x, y),
bottom : new Helper(this.g, x, y),
left : new Helper(this.g, x, y),
right : new Helper(this.g, x, y)
};
this.helpers.center.setAction('move');
this.helpers.top.setAction('editTop').setCursor('n-resize');
this.helpers.bottom.setAction('editBottom').setCursor('s-resize');
this.helpers.left.setAction('editLeft').setCursor('w-resize');
this.helpers.right.setAction('editRight').setCursor('e-resize');
this.select().redraw();
app.addObject(this); //add this object to array of all objects
};
Circle.prototype.setCoords = function(params){
this.circle.setAttribute('cx', params.cx);
this.circle.setAttribute('cy', params.cy);
this.circle.setAttribute('r', params.radius);
this.helpers.center.setCoords(params.cx, params.cy);
this.helpers.top.setCoords(params.cx, params.cy - params.radius);
this.helpers.right.setCoords(params.cx + params.radius, params.cy);
this.helpers.bottom.setCoords(params.cx, params.cy + params.radius);
this.helpers.left.setCoords(params.cx - params.radius, params.cy);
return this;
};
Circle.prototype.setParams = function(params){
this.params.cx = params.cx;
this.params.cy = params.cy;
this.params.radius = params.radius;
return this;
};
Circle.prototype.redraw = function() {
this.setCoords(this.params);
return this;
};
Circle.prototype.dynamicDraw = function(x1,y1){
var x0 = this.params.cx,
y0 = this.params.cy,
dx,
dy,
radius,
temp_params;
x1 = x1 ? x1 : x0;
y1 = y1 ? y1 : y0;
dx = Math.abs(x0-x1);
dy = Math.abs(y0-y1);
radius = Math.round(Math.sqrt(dx*dx + dy*dy));
temp_params = { /* params */
cx : x0,
cy : y0,
radius : radius
};
this.setCoords(temp_params);
return temp_params;
};
Circle.prototype.onDraw = function(e) {
var _n_f = app.getNewArea();
_n_f.dynamicDraw(utils.rightX(e.pageX), utils.rightY(e.pageY));
};
Circle.prototype.onDrawStop = function(e) {
var _n_f = app.getNewArea();
_n_f.setParams(_n_f.dynamicDraw(utils.rightX(e.pageX), utils.rightY(e.pageY))).deselect();
app.removeAllEvents()
.setIsDraw(false)
.resetNewArea();
fireEvent(utils.id('edit'),'click');
window.ImageMapEditorCallback.onDrawStop(_n_f,app,'circle');
};
Circle.prototype.move = function(dx, dy){ //offset x and y
var temp_params = Object.create(this.params);
temp_params.cx += dx;
temp_params.cy += dy;
return temp_params;
};
Circle.prototype.editTop = function(dx, dy){ //offset x and y
var temp_params = Object.create(this.params);
temp_params.radius -= dy;
return temp_params;
};
Circle.prototype.editBottom = function(dx, dy){ //offset x and y
var temp_params = Object.create(this.params);
temp_params.radius += dy;
return temp_params;
};
Circle.prototype.editLeft = function(dx, dy){ //offset x and y
var temp_params = Object.create(this.params);
temp_params.radius -= dx;
return temp_params;
};
Circle.prototype.editRight = function(dx, dy){ //offset x and y
var temp_params = Object.create(this.params);
temp_params.radius += dx;
return temp_params;
};
Circle.prototype.dynamicEdit = function(temp_params) {
if (temp_params.radius < 0) {
temp_params.radius = Math.abs(temp_params.radius);
}
this.setCoords(temp_params);
return temp_params;
};
Circle.prototype.onEdit = function(e) {
var _s_f = app.getSelectedArea(),
edit_type = app.getEditType();
_s_f.dynamicEdit(_s_f[edit_type](e.pageX - _s_f.delta.x, e.pageY - _s_f.delta.y));
};
Circle.prototype.onEditStop = function(e) {
var _s_f = app.getSelectedArea(),
edit_type = app.getEditType();
_s_f.setParams(_s_f.dynamicEdit(_s_f[edit_type](e.pageX - _s_f.delta.x, e.pageY - _s_f.delta.y)));
app.removeAllEvents();
};
Circle.prototype.remove = function(){
app.removeNodeFromSvg(this.g);
};
Circle.prototype.select = function() {
utils.addClass(this.circle, 'selected');
return this;
};
Circle.prototype.deselect = function() {
utils.removeClass(this.circle, 'selected');
return this;
};
Circle.prototype.with_href = function() {
utils.addClass(this.circle, 'with_href');
return this;
}
Circle.prototype.without_href = function() {
utils.removeClass(this.circle, 'with_href');
return this;
}
Circle.prototype.toString = function() { //to html map area code
return '<area shape="circle" coords="'
+ this.params.cx + ', '
+ this.params.cy + ', '
+ this.params.radius
+ '"'
+ (this.href ? ' href="' + this.href + '"' : '')
+ (this.alt ? ' alt="' + this.alt + '"' : '')
+ (this.title ? ' title="' + this.title + '"' : '')
+ (this.row_id ? ' row_id="' + this.row_id + '"' : '')
+ (this.model_code ? ' model_code="' + this.model_code + '"' : '')
+ (this.group_code_part ? ' group_code_part="' + this.group_code_part + '"' : '')
+ (this.sub_group_code ? ' sub_group_code="' + this.sub_group_code + '"' : '')
+ (this.position_code_part ? ' position_code_part="' + this.position_code_part + '"' : '') + (this.position_code_link ? ' position_code_link="' + this.position_code_link + '"' : '')
+ (this.position_code_name ? ' position_code_name="' + this.position_code_name + '"' : '')
+ ' />';
};
Circle.createFromSaved = function(params) {
var coords = params.coords,
href = params.href,
alt = params.alt,
title = params.title,
row_id = params.row_id,
model_code = params.model_code,
group_code_part = params.group_code_part,
sub_group_code = params.sub_group_code,
position_code_part = params.position_code_part,
position_code_name = params.position_code_name,
area = new Circle(coords[0], coords[1]);
area.setParams(area.dynamicDraw(coords[0], coords[1] + coords[2])).deselect();
app.setIsDraw(false)
.resetNewArea();
if (href) {
area.href = href;
}
if (alt) {
area.alt = alt;
}
if (title) {
area.title = title;
}
if (row_id) {
area.row_id = row_id;
}
if (model_code) {
area.model_code = model_code;
}
if (group_code_part) {
area.group_code_part = group_code_part;
}
if (sub_group_code) {
area.sub_group_code = sub_group_code;
}
if (position_code_name) {
area.position_code_name = position_code_name;
}
if (position_code_part) {
area.position_code_part = position_code_part;
}
};
Circle.prototype.toJSON = function() {
return {
type : 'circle',
coords : [
this.params.cx,
this.params.cy,
this.params.radius
],
href : this.href,
alt : this.alt,
title : this.title,
row_id : this.row_id,
model_code : this.model_code,
group_code_part : this.group_code_part,
group_code_part : this.sub_group_code,
group_code_part : this.position_code_part,
group_code_part : this.position_code_name
}
};
/* Polygon constructor */
var Polygon = function(x, y){
app.setIsDraw(true);
this.params = [x, y]; //array of coordinates of polygon points
this.href = ''; //href attribute - not required
this.alt = ''; //alt attribute - not required
this.title = ''; //title attribute - not required
this.row_id='';
this.model_code ='';
this.group_code_part ='';
this.sub_group_code = '';
this.position_code_part = '';
this.position_code_name = '';
this.g = document.createElementNS('http://www.w3.org/2000/svg', 'g');
this.polygon = document.createElementNS('http://www.w3.org/2000/svg', 'polyline');
app.addNodeToSvg(this.g);
this.g.appendChild(this.polygon);
this.g.obj = this; /* Link to parent object */
this.helpers = [ //array of all helpers-rectangles
new Helper(this.g, this.params[0], this.params[1])
];
this.helpers[0].setAction('pointMove').setCursor('pointer').setId(0);
this.selected_point = -1;
this.select().redraw();
app.addObject(this); //add this object to array of all objects
};
Polygon.prototype.setCoords = function(params){
var coords_values = params.join(' ');
this.polygon.setAttribute('points', coords_values);
utils.foreach(this.helpers, function(x, i) {
x.setCoords(params[2*i], params[2*i+1]);
});
return this;
};
Polygon.prototype.setParams = function(arr) {
this.params = Array.prototype.slice.call(arr);
return this;
};
Polygon.prototype.addPoint = function(x, y){
var helper = new Helper(this.g, x, y);
helper.setAction('pointMove').setCursor('pointer').setId(this.helpers.length);
this.helpers.push(helper);
this.params.push(x, y);
this.redraw();
return this;
};
Polygon.prototype.redraw = function() {
this.setCoords(this.params);
return this;
};
Polygon.prototype.right_angle = function(x, y){
var old_x = this.params[this.params.length-2],
old_y = this.params[this.params.length-1],
dx = x - old_x,
dy = - (y - old_y),
tan = dy/dx; //tangens
if (dx > 0 && dy > 0) {
if (tan > 2.414) {
x = old_x;
} else if (tan < 0.414) {
y = old_y;
} else {
Math.abs(dx) > Math.abs(dy) ? x = old_x + dy : y = old_y - dx;
}
} else if (dx < 0 && dy > 0) {
if (tan < -2.414) {
x = old_x;
} else if (tan > -0.414) {
y = old_y;
} else {
Math.abs(dx) > Math.abs(dy) ? x = old_x - dy : y = old_y + dx;
}
} else if (dx < 0 && dy < 0) {
if (tan > 2.414) {
x = old_x;
} else if (tan < 0.414) {
y = old_y;
} else {
Math.abs(dx) > Math.abs(dy) ? x = old_x + dy : y = old_y - dx;
}
} else if (dx > 0 && dy < 0) {
if (tan < -2.414) {
x = old_x;
} else if (tan > -0.414) {
y = old_y;
} else {
Math.abs(dx) > Math.abs(dy) ? x = old_x - dy : y = old_y + dx;
}
}
return {
x : x,
y : y
};
};
Polygon.prototype.dynamicDraw = function(x, y, right_angle){
var temp_params = [].concat(this.params);
if (right_angle) {
var right_coords = this.right_angle(x, y);
x = right_coords.x;
y = right_coords.y;
}
temp_params.push(x, y);
this.setCoords(temp_params);
return temp_params;
};
Polygon.prototype.onDraw = function(e) {
var _n_f = app.getNewArea();
var right_angle = e.shiftKey ? true : false;
_n_f.dynamicDraw(utils.rightX(e.pageX), utils.rightY(e.pageY), right_angle);
};
Polygon.prototype.onDrawAddPoint = function(e) {
var x = utils.rightX(e.pageX),
y = utils.rightY(e.pageY),
_n_f = app.getNewArea();
if (e.shiftKey) {
var right_coords = _n_f.right_angle(x, y);
x = right_coords.x;
y = right_coords.y;
}
_n_f.addPoint(x, y);
};
Polygon.prototype.onDrawStop = function(e) {
var _n_f = app.getNewArea();
if (e.type == 'click' || (e.type == 'keydown' && e.keyCode == 13)) { // key Enter
if (_n_f.params.length >= 6) { //>= 3 points for polygon
_n_f.polyline = _n_f.polygon;
_n_f.polygon = document.createElementNS('http://www.w3.org/2000/svg', 'polygon');
_n_f.g.replaceChild(_n_f.polygon, _n_f.polyline);
_n_f.setCoords(_n_f.params).deselect();
delete(_n_f.polyline);
app.removeAllEvents()
.setIsDraw(false)
.resetNewArea();
fireEvent(utils.id('edit'),'click');
window.ImageMapEditorCallback.onDrawStop(_n_f,app,'polygon');
}
};
e.stopPropagation();
};
Polygon.prototype.move = function(x, y){ //offset x and y
var temp_params = Object.create(this.params);
for (var i = 0, count = this.params.length; i < count; i++) {
i % 2 ? this.params[i] += y : this.params[i] += x;
}
return temp_params;
};
Polygon.prototype.pointMove = function(x, y){ //offset x and y
this.params[2 * this.selected_point] += x;
this.params[2 * this.selected_point + 1] += y;
return this.params;
};
Polygon.prototype.dynamicEdit = function(temp_params) {
this.setCoords(temp_params);
return temp_params;
};
Polygon.prototype.onEdit = function(e) {
var _s_f = app.getSelectedArea(),
edit_type = app.getEditType();
_s_f.dynamicEdit(_s_f[edit_type](e.pageX - _s_f.delta.x, e.pageY - _s_f.delta.y));
_s_f.delta.x = e.pageX;
_s_f.delta.y = e.pageY;
};
Polygon.prototype.onEditStop = function(e) {
var _s_f = app.getSelectedArea(),
edit_type = app.getEditType();
_s_f.setParams(_s_f.dynamicEdit(_s_f[edit_type](e.pageX - _s_f.delta.x, e.pageY - _s_f.delta.y)));
app.removeAllEvents();
};
Polygon.prototype.remove = function(){
app.removeNodeFromSvg(this.g);
};
Polygon.prototype.select = function() {
utils.addClass(this.polygon, 'selected');
return this;
};
Polygon.prototype.deselect = function() {
utils.removeClass(this.polygon, 'selected');
return this;
};
Polygon.prototype.with_href = function() {
utils.addClass(this.polygon, 'with_href');
return this;
}
Polygon.prototype.without_href = function() {
utils.removeClass(this.polygon, 'with_href');
return this;
}
Polygon.prototype.toString = function() { //to html map area code
for (var i = 0, count = this.params.length, str = ''; i < count; i++) {
str += this.params[i];
if (i != count - 1) {
str += ', ';
}
}
return '<area shape="poly" coords="'
+ str
+ '"'
+ (this.href ? ' href="' + this.href + '"' : '')
+ (this.alt ? ' alt="' + this.alt + '"' : '')
+ (this.title ? ' title="' + this.title + '"' : '')
+ (this.row_id ? ' row_id="' + this.row_id + '"' : '')
+ (this.model_code ? ' model_code="' + this.model_code + '"' : '')
+ (this.group_code_part ? ' group_code_part="' + this.group_code_part + '"' : '')
+ (this.sub_group_code ? ' sub_group_code="' + this.sub_group_code + '"' : '')
+ (this.position_code_part ? ' position_code_part="' + this.position_code_part + '"' : '') + (this.position_code_link ? ' position_code_link="' + this.position_code_link + '"' : '')
+ (this.position_code_name ? ' position_code_name="' + this.position_code_name + '"' : '')
+ ' />';
};
Polygon.createFromSaved = function(params) {
var coords = params.coords,
href = params.href,
alt = params.alt,
title = params.title,
row_id = params.row_id,
model_code = params.model_code,
group_code_part = params.group_code_part,
sub_group_code = params.sub_group_code,
position_code_part = params.position_code_part,
position_code_name = params.position_code_name,
area = new Polygon(coords[0], coords[1]);
for (var i = 2, c = coords.length; i < c; i+=2) {
area.addPoint(coords[i], coords[i+1]);
}
area.polyline = area.polygon;
area.polygon = document.createElementNS('http://www.w3.org/2000/svg', 'polygon');
area.g.replaceChild(area.polygon, area.polyline);
area.setCoords(area.params).deselect();
delete(area.polyline);
app.setIsDraw(false)
.resetNewArea();
if (href) {
area.href = href;
}
if (alt) {
area.alt = alt;
}
if (title) {
area.title = title;
}
if (row_id) {
area.row_id = row_id;
}
if (model_code) {
area.model_code = model_code;
}
if (group_code_part) {
area.group_code_part = group_code_part;
}
if (sub_group_code) {
area.sub_group_code = sub_group_code;
}
if (position_code_name) {
area.position_code_name = position_code_name;
}
if (position_code_part) {
area.position_code_part = position_code_part;
}
};
Polygon.prototype.toJSON = function() {
return {
type : 'polygon',
coords : this.params,
href : this.href,
alt : this.alt,
title : this.title,
row_id : this.row_id,
model_code : this.model_code,
group_code_part : this.group_code_part,
group_code_part : this.sub_group_code,
group_code_part : this.position_code_part,
group_code_part : this.position_code_name
}
};
window.shmc=SummerHtmlImageMapCreator;
};
document.addEventListener("DOMContentLoaded", SummerHtmlImageMapCreator, false); | JavaScript |
/*
<script type="text/javascript" src=""></script>
<script type="text/javascript" src="<?php echo base_url()?>assets/grocery_crud/js/jquery_plugins/jquery.layout-latest.js"></script>
<!--script type="text/javascript" src="<?php echo base_url()?>assets/grocery_crud/js/jquery_plugins/jquery.ba-hashchange-1.3.min.js"></script-->
*/
head.load( "assets/grocery_crud/js/jquery_plugins/ui/jquery.ui.core.js",
"assets/grocery_crud/js/jquery_plugins/ui/jquery.ui.widget.js",
"assets/grocery_crud/js/jquery_plugins/ui/jquery.ui.accordion.js"); | JavaScript |
$(function(){
$( 'textarea.texteditor' ).ckeditor({toolbar:'Full'});
$( 'textarea.mini-texteditor' ).ckeditor({toolbar:'Basic',width:700});
}); | JavaScript |
$(function(){
// $(".chosen-select,.chosen-multiple-select").chosen({width:120,allow_single_deselect:true});
}); | JavaScript |
$(function(){
$('.datetime-input').datetime({
userLang : 'en',
americanMode: true,
});
$('.datetime-input-clear').button();
$('.datetime-input-clear').click(function(){
$(this).parent().find('.datetime-input').val("");
return false;
});
}); | JavaScript |
$(function(){
$('.datetime-input').datetimepicker({
timeFormat: 'hh:mm:ss',
dateFormat: js_date_format,
showButtonPanel: true,
changeMonth: true,
changeYear: true
});
$('.datetime-input-clear').button();
$('.datetime-input-clear').click(function(){
$(this).parent().find('.datetime-input').val("");
return false;
});
}); | JavaScript |
$(function(){
$(".radio-uniform").uniform();
}); | JavaScript |
$(function() {
var tinymce_path = default_texteditor_path+'/tiny_mce/';
var tinymce_options = {
// Location of TinyMCE script
script_url : tinymce_path +"tiny_mce.js",
// General options
theme : "advanced",
plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",
//plugins : "advimage,paste",
// Theme options
theme_advanced_buttons1 : "bold,italic,underline,|,justifyleft,justifycenter,justifyright,justifyfull,image,fullscreen",//,tablecontrols,fullscreen",
//theme_advanced_buttons4 : "attribs,|,visualchars,nonbreaking,template,pagebreak",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "center",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
entity_encoding : "raw",
/*
// Example content CSS (should be your site CSS)
content_css : "css/content.css",
*/
// Drop lists for link/image/media/template dialogs
template_external_list_url : tinymce_path +"lists/template_list.js",
external_link_list_url : tinymce_path +"lists/link_list.js",
external_image_list_url : tinymce_path +"lists/image_list.js",
media_external_list_url : tinymce_path +"lists/media_list.js",
// Replace values for the template plugin
template_replace_values : {
username : "Some User",
staffid : "991234"
}
};
$('textarea.texteditor').tinymce(tinymce_options);
var minimal_tinymce_options = $.extend({}, tinymce_options);
minimal_tinymce_options.theme = "simple";
$('textarea.mini-texteditor').tinymce(minimal_tinymce_options);
}); | JavaScript |
$(function(){
$(".multiselect").multiselect();
}); | JavaScript |
$(function(){
$('.datepicker-input').datepicker({
dateFormat: js_date_format,
showButtonPanel: true,
changeMonth: true,
changeYear: true
});
$('.datepicker-input-clear').button();
$('.datepicker-input-clear').click(function(){
$(this).parent().find('.datepicker-input').val("");
return false;
});
}); | JavaScript |
function success_message(success_message)
{
noty({
text: success_message,
type: 'success',
dismissQueue: true,
layout: 'top',
callback: {
afterShow: function() {
setTimeout(function(){
$.noty.closeAll();
},7000);
try{
/********************************************************************/
if(typeof window.gcConf.afterSubmit == 'function')
{
window.gcConf.afterSubmit();
}
/*********************************************************************/
}catch(e){
}
}
}
});
}
function error_message(error_message)
{
noty({
text: error_message,
type: 'error',
layout: 'top',
dismissQueue: true
});
}
function form_success_message(success_message,oper,data_unique_hash,cb)
{
//console.log(arguments)
if(oper == 'add')
{
// data_unique_hash
if(typeof cb == 'function')
{
cb(data_unique_hash);
}
}
$('#report-success').slideUp('fast');
$('#report-success').html(success_message);
if ($('#report-success').closest('.ui-dialog').length !== 0) {
$('.go-to-edit-form').click(function(){
fnOpenEditForm($(this));
return false;
});
}
$('#report-success').slideDown('normal');
$('#report-error').slideUp('fast').html('');
}
function form_error_message(error_message)
{
$('#report-error').slideUp('fast');
$('#report-error').html(error_message);
$('#report-error').slideDown('normal');
$('#report-success').slideUp('fast').html('');
} | JavaScript |
$(function(){
$('.image-thumbnail').fancybox({
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'speedIn' : 600,
'speedOut' : 200,
'overlayShow' : false
});
}); | JavaScript |
// ----------------------------------------------------------------------------
// markItUp!
// ----------------------------------------------------------------------------
// Copyright (C) 2011 Jay Salvat
// http://markitup.jaysalvat.com/
// ----------------------------------------------------------------------------
// Html tags
// http://en.wikipedia.org/wiki/html
// ----------------------------------------------------------------------------
// Basic set. Feel free to add more tags
// ----------------------------------------------------------------------------
var mySettings = {
onShiftEnter: {keepDefault:false, replaceWith:'<br />\n'},
onCtrlEnter: {keepDefault:false, openWith:'\n<p>', closeWith:'</p>'},
onTab: {keepDefault:false, replaceWith:' '},
markupSet: [
{name:'Bold', key:'B', openWith:'(!(<strong>|!|<b>)!)', closeWith:'(!(</strong>|!|</b>)!)' },
{name:'Italic', key:'I', openWith:'(!(<em>|!|<i>)!)', closeWith:'(!(</em>|!|</i>)!)' },
{name:'Stroke through', key:'S', openWith:'<del>', closeWith:'</del>' },
{separator:'---------------' },
{name:'Bulleted List', openWith:' <li>', closeWith:'</li>', multiline:true, openBlockWith:'<ul>\n', closeBlockWith:'\n</ul>'},
{name:'Numeric List', openWith:' <li>', closeWith:'</li>', multiline:true, openBlockWith:'<ol>\n', closeBlockWith:'\n</ol>'},
{separator:'---------------' },
{name:'Picture', key:'P', replaceWith:'<img src="[![Source:!:http://]!]" alt="[![Alternative text]!]" />' },
{name:'Link', key:'L', openWith:'<a href="[![Link:!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:'Your text to link...' },
{separator:'---------------' },
{name:'Clean', className:'clean', replaceWith:function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } },
{name:'Preview', className:'preview', call:'preview'}
]
};
$(document).ready(function() {
$('.texteditor').markItUp(mySettings);
$( 'textarea.mini-texteditor' ).markItUp(mySettings);
}); | JavaScript |
function show_upload_button(unique_id, uploader_element)
{
$('#upload-state-message-'+unique_id).html('');
$("#loading-"+unique_id).hide();
$('#upload-button-'+unique_id).slideDown('fast');
if( uploader_element.hasClass('virtualized') )
{
$("input[uniqid="+uploader_element.attr('id')+"]").val('');
}
else
{
$("input[rel="+uploader_element.attr('name')+"]").val('');
}
$('#success_'+unique_id).slideUp('fast');
}
function load_fancybox(elem)
{
elem.fancybox({
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'speedIn' : 600,
'speedOut' : 200,
'overlayShow' : false
});
}
$(document).ready(function(){
// alert('kkkk');
///////////////
$('.gc-file-upload').each(function(){
var unique_id = $(this).attr('id');
var uploader_url = $(this).attr('rel');
var uploader_element = $(this);
var delete_url = $('#delete_url_'+unique_id).attr('href');
eval("var file_upload_info = upload_info_"+unique_id+"");
$(this).fileupload({
dataType: 'json',
url: uploader_url,
cache: false,
acceptFileTypes: file_upload_info.accepted_file_types,
beforeSend: function(){
$('#upload-state-message-'+unique_id).html(string_upload_file);
$("#loading-"+unique_id).show();
$("#upload-button-"+unique_id).slideUp("fast");
},
limitMultiFileUploads: 1,
maxFileSize: file_upload_info.max_file_size,
send: function (e, data) {
var errors = '';
if (data.files.length > 1) {
errors += error_max_number_of_files + "\n" ;
}
$.each(data.files,function(index, file){
if (!(data.acceptFileTypes.test(file.type) || data.acceptFileTypes.test(file.name))) {
errors += error_accept_file_types + "\n";
}
if (data.maxFileSize && file.size > data.maxFileSize) {
errors += error_max_file_size + "\n";
}
if (typeof file.size === 'number' && file.size < data.minFileSize) {
errors += error_min_file_size + "\n";
}
});
if(errors != '')
{
error_alert('Error',errors);
return false;
}
return true;
},
done: function (e, data) {
if(typeof data.result.success != 'undefined' && data.result.success)
{
$("#loading-"+unique_id).hide();
$("#progress-"+unique_id).html('');
$.each(data.result.files, function (index, file) {
$('#upload-state-message-'+unique_id).html('');
$("input[rel="+uploader_element.attr('name')+"]").val(file.name);
var file_name = file.name;
file_name = file_name.split('-');
file_name.splice(0,1);
file_name = file_name.join('');
var file_name_base64 = file.base64;
var is_image = (file_name.substr(-4) == '.jpg'
|| file_name.substr(-4) == '.png'
|| file_name.substr(-5) == '.jpeg'
|| file_name.substr(-4) == '.gif'
|| file_name.substr(-5) == '.tiff') && !gcConf.unset_image_preview
? true : false;
if(is_image)
{
$('#file_'+unique_id).addClass('image-thumbnail');
load_fancybox($('#file_'+unique_id));
$('#file_'+unique_id).html('<img src="'+file.url+'" height="50" />');
}
else
{
//$('#file_'+unique_id).removeClass('image-thumbnail');
$('#file_'+unique_id).addClass('image-thumbnail');
load_fancybox($('#file_'+unique_id));
//$('#file_'+unique_id).unbind("click");
$('#file_'+unique_id).html(file_name);
}
$('#file_'+unique_id).attr('href',file.url);
$('#hidden_'+unique_id).val(file_name);
$('#success_'+unique_id).fadeIn('slow');
$('#delete_url_'+unique_id).attr('rel',file_name_base64);
$('#delete_'+unique_id).data('no_delete',true);
console.log('#delete_'+unique_id);
$('#upload-button-'+unique_id).slideUp('fast');
});
}
else if(typeof data.result.message != 'undefined')
{
error_alert('Error',data.result.message);
show_upload_button(unique_id, uploader_element);
}
else
{
error_alert('Error',error_on_uploading);
show_upload_button(unique_id, uploader_element);
}
},
autoUpload: true,
error: function()
{
error_alert('Error',error_on_uploading);
show_upload_button(unique_id, uploader_element);
},
fail: function(e, data)
{
// data.errorThrown
// data.textStatus;
// data.jqXHR;
error_alert('Error',error_on_uploading);
show_upload_button(unique_id, uploader_element);
},
progress: function (e, data) {
$("#progress-"+unique_id).html(string_progress + parseInt(data.loaded / data.total * 100, 10) + '%');
}
});
$('#delete_'+unique_id).click(function(){
var this_el = this;
var no_delete = $(this).data('no_delete')?'?no_delete=true':'';
// console.log(no_delete);
if($(this).data('no_confirm'))
{
var file_name = $('#delete_url_'+unique_id).attr('rel');
$.ajax({
url: delete_url+"/"+file_name + no_delete,
cache: false,
success:function(){
if(typeof gcConf.cb_delete_image_fn == 'function')
{
gcConf.cb_delete_image_fn(this_el);
}
show_upload_button(unique_id, uploader_element);
},
beforeSend: function(){
$('#upload-state-message-'+unique_id).html(string_delete_file);
$('#success_'+unique_id).hide();
$("#loading-"+unique_id).show();
$("#upload-button-"+unique_id).slideUp("fast");
}
});
return false;
}
confirm_alert('Konfirmasi',message_prompt_delete_file,function(){
var file_name = $('#delete_url_'+unique_id).attr('rel');
$.ajax({
url: delete_url+"/"+file_name + no_delete,
cache: false,
success:function(){
if(typeof gcConf.cb_delete_image_fn == 'function')
{
gcConf.cb_delete_image_fn(this_el);
}
show_upload_button(unique_id, uploader_element);
},
beforeSend: function(){
$('#upload-state-message-'+unique_id).html(string_delete_file);
$('#success_'+unique_id).hide();
$("#loading-"+unique_id).show();
$("#upload-button-"+unique_id).slideUp("fast");
}
});
},function(){
});
return false;
});
});
}); | JavaScript |
$(function(){
$('.numeric').numeric();
$('.numeric').keydown(function(e){
if(e.keyCode == 38)
{
if(IsNumeric($(this).val()))
{
var new_number = parseInt($(this).val()) + 1;
$(this).val(new_number);
}else if($(this).val().length == 0)
{
var new_number = 1;
$(this).val(new_number);
}
}
else if(e.keyCode == 40)
{
if(IsNumeric($(this).val()))
{
var new_number = parseInt($(this).val()) - 1;
$(this).val(new_number);
}else if($(this).val().length == 0)
{
var new_number = -1;
$(this).val(new_number);
}
}
});
});
function IsNumeric(input)
{
return (input - 0) == input && input.length > 0;
}
| JavaScript |
/*
* jQuery Iframe Transport Plugin 1.3
* https://github.com/blueimp/jQuery-File-Upload
*
* Copyright 2011, Sebastian Tschan
* https://blueimp.net
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
/*jslint unparam: true, nomen: true */
/*global define, window, document */
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
// Register as an anonymous AMD module:
define(['jquery'], factory);
} else {
// Browser globals:
factory(window.jQuery);
}
}(function ($) {
'use strict';
// Helper variable to create unique names for the transport iframes:
var counter = 0;
// The iframe transport accepts three additional options:
// options.fileInput: a jQuery collection of file input fields
// options.paramName: the parameter name for the file form data,
// overrides the name property of the file input field(s)
// options.formData: an array of objects with name and value properties,
// equivalent to the return data of .serializeArray(), e.g.:
// [{name: 'a', value: 1}, {name: 'b', value: 2}]
$.ajaxTransport('iframe', function (options) {
if (options.async && (options.type === 'POST' || options.type === 'GET')) {
var form,
iframe;
return {
send: function (_, completeCallback) {
form = $('<form style="display:none;"></form>');
// javascript:false as initial iframe src
// prevents warning popups on HTTPS in IE6.
// IE versions below IE8 cannot set the name property of
// elements that have already been added to the DOM,
// so we set the name along with the iframe HTML markup:
iframe = $(
'<iframe src="javascript:false;" name="iframe-transport-' +
(counter += 1) + '"></iframe>'
).bind('load', function () {
var fileInputClones;
iframe
.unbind('load')
.bind('load', function () {
var response;
// Wrap in a try/catch block to catch exceptions thrown
// when trying to access cross-domain iframe contents:
try {
response = iframe.contents();
// Google Chrome and Firefox do not throw an
// exception when calling iframe.contents() on
// cross-domain requests, so we unify the response:
if (!response.length || !response[0].firstChild) {
throw new Error();
}
} catch (e) {
response = undefined;
}
// The complete callback returns the
// iframe content document as response object:
completeCallback(
200,
'success',
{'iframe': response}
);
// Fix for IE endless progress bar activity bug
// (happens on form submits to iframe targets):
$('<iframe src="javascript:false;"></iframe>')
.appendTo(form);
form.remove();
});
form
.prop('target', iframe.prop('name'))
.prop('action', options.url)
.prop('method', options.type);
if (options.formData) {
$.each(options.formData, function (index, field) {
$('<input type="hidden"/>')
.prop('name', field.name)
.val(field.value)
.appendTo(form);
});
}
if (options.fileInput && options.fileInput.length &&
options.type === 'POST') {
fileInputClones = options.fileInput.clone();
// Insert a clone for each file input field:
options.fileInput.after(function (index) {
return fileInputClones[index];
});
if (options.paramName) {
options.fileInput.each(function () {
$(this).prop('name', options.paramName);
});
}
// Appending the file input fields to the hidden form
// removes them from their original location:
form
.append(options.fileInput)
.prop('enctype', 'multipart/form-data')
// enctype must be set as encoding for IE:
.prop('encoding', 'multipart/form-data');
}
form.submit();
// Insert the file input fields at their original location
// by replacing the clones with the originals:
if (fileInputClones && fileInputClones.length) {
options.fileInput.each(function (index, input) {
var clone = $(fileInputClones[index]);
$(input).prop('name', clone.prop('name'));
clone.replaceWith(input);
});
}
});
form.append(iframe).appendTo(document.body);
},
abort: function () {
if (iframe) {
// javascript:false as iframe src aborts the request
// and prevents warning popups on HTTPS in IE6.
// concat is used to avoid the "Script URL" JSLint error:
iframe
.unbind('load')
.prop('src', 'javascript'.concat(':false;'));
}
if (form) {
form.remove();
}
}
};
}
});
// The iframe transport returns the iframe content document as response.
// The following adds converters from iframe to text, json, html, and script:
$.ajaxSetup({
converters: {
'iframe text': function (iframe) {
return $(iframe[0].body).text();
},
'iframe json': function (iframe) {
return $.parseJSON($(iframe[0].body).text());
},
'iframe html': function (iframe) {
return $(iframe[0].body).html();
},
'iframe script': function (iframe) {
return $.globalEval($(iframe[0].body).text());
}
}
});
}));
| JavaScript |
/*
* jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
*
* Uses the built in easing capabilities added In jQuery 1.1
* to offer multiple easing options
*
* TERMS OF USE - jQuery Easing
*
* Open source under the BSD License.
*
* Copyright © 2008 George McGinley Smith
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* Neither the name of the author nor the names of contributors may be used to endorse
* or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
// t: current time, b: begInnIng value, c: change In value, d: duration
eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('h.i[\'1a\']=h.i[\'z\'];h.O(h.i,{y:\'D\',z:9(x,t,b,c,d){6 h.i[h.i.y](x,t,b,c,d)},17:9(x,t,b,c,d){6 c*(t/=d)*t+b},D:9(x,t,b,c,d){6-c*(t/=d)*(t-2)+b},13:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t+b;6-c/2*((--t)*(t-2)-1)+b},X:9(x,t,b,c,d){6 c*(t/=d)*t*t+b},U:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t+1)+b},R:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t+b;6 c/2*((t-=2)*t*t+2)+b},N:9(x,t,b,c,d){6 c*(t/=d)*t*t*t+b},M:9(x,t,b,c,d){6-c*((t=t/d-1)*t*t*t-1)+b},L:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t+b;6-c/2*((t-=2)*t*t*t-2)+b},K:9(x,t,b,c,d){6 c*(t/=d)*t*t*t*t+b},J:9(x,t,b,c,d){6 c*((t=t/d-1)*t*t*t*t+1)+b},I:9(x,t,b,c,d){e((t/=d/2)<1)6 c/2*t*t*t*t*t+b;6 c/2*((t-=2)*t*t*t*t+2)+b},G:9(x,t,b,c,d){6-c*8.C(t/d*(8.g/2))+c+b},15:9(x,t,b,c,d){6 c*8.n(t/d*(8.g/2))+b},12:9(x,t,b,c,d){6-c/2*(8.C(8.g*t/d)-1)+b},Z:9(x,t,b,c,d){6(t==0)?b:c*8.j(2,10*(t/d-1))+b},Y:9(x,t,b,c,d){6(t==d)?b+c:c*(-8.j(2,-10*t/d)+1)+b},W:9(x,t,b,c,d){e(t==0)6 b;e(t==d)6 b+c;e((t/=d/2)<1)6 c/2*8.j(2,10*(t-1))+b;6 c/2*(-8.j(2,-10*--t)+2)+b},V:9(x,t,b,c,d){6-c*(8.o(1-(t/=d)*t)-1)+b},S:9(x,t,b,c,d){6 c*8.o(1-(t=t/d-1)*t)+b},Q:9(x,t,b,c,d){e((t/=d/2)<1)6-c/2*(8.o(1-t*t)-1)+b;6 c/2*(8.o(1-(t-=2)*t)+1)+b},P:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);6-(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b},H:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d)==1)6 b+c;e(!p)p=d*.3;e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);6 a*8.j(2,-10*t)*8.n((t*d-s)*(2*8.g)/p)+c+b},T:9(x,t,b,c,d){f s=1.l;f p=0;f a=c;e(t==0)6 b;e((t/=d/2)==2)6 b+c;e(!p)p=d*(.3*1.5);e(a<8.w(c)){a=c;f s=p/4}m f s=p/(2*8.g)*8.r(c/a);e(t<1)6-.5*(a*8.j(2,10*(t-=1))*8.n((t*d-s)*(2*8.g)/p))+b;6 a*8.j(2,-10*(t-=1))*8.n((t*d-s)*(2*8.g)/p)*.5+c+b},F:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*(t/=d)*t*((s+1)*t-s)+b},E:9(x,t,b,c,d,s){e(s==u)s=1.l;6 c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},16:9(x,t,b,c,d,s){e(s==u)s=1.l;e((t/=d/2)<1)6 c/2*(t*t*(((s*=(1.B))+1)*t-s))+b;6 c/2*((t-=2)*t*(((s*=(1.B))+1)*t+s)+2)+b},A:9(x,t,b,c,d){6 c-h.i.v(x,d-t,0,c,d)+b},v:9(x,t,b,c,d){e((t/=d)<(1/2.k)){6 c*(7.q*t*t)+b}m e(t<(2/2.k)){6 c*(7.q*(t-=(1.5/2.k))*t+.k)+b}m e(t<(2.5/2.k)){6 c*(7.q*(t-=(2.14/2.k))*t+.11)+b}m{6 c*(7.q*(t-=(2.18/2.k))*t+.19)+b}},1b:9(x,t,b,c,d){e(t<d/2)6 h.i.A(x,t*2,0,c,d)*.5+b;6 h.i.v(x,t*2-d,0,c,d)*.5+c*.5+b}});',62,74,'||||||return||Math|function|||||if|var|PI|jQuery|easing|pow|75|70158|else|sin|sqrt||5625|asin|||undefined|easeOutBounce|abs||def|swing|easeInBounce|525|cos|easeOutQuad|easeOutBack|easeInBack|easeInSine|easeOutElastic|easeInOutQuint|easeOutQuint|easeInQuint|easeInOutQuart|easeOutQuart|easeInQuart|extend|easeInElastic|easeInOutCirc|easeInOutCubic|easeOutCirc|easeInOutElastic|easeOutCubic|easeInCirc|easeInOutExpo|easeInCubic|easeOutExpo|easeInExpo||9375|easeInOutSine|easeInOutQuad|25|easeOutSine|easeInOutBack|easeInQuad|625|984375|jswing|easeInOutBounce'.split('|'),0,{}))
/*
*
* TERMS OF USE - EASING EQUATIONS
*
* Open source under the BSD License.
*
* Copyright © 2001 Robert Penner
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* Neither the name of the author nor the names of contributors may be used to endorse
* or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
| JavaScript |
/*
Uniform v2.0.0
Copyright © 2009 Josh Pyles / Pixelmatrix Design LLC
http://pixelmatrixdesign.com
Requires jQuery 1.3 or newer
Much thanks to Thomas Reynolds and Buck Wilson for their help and advice on
this.
Disabling text selection is made possible by Mathias Bynens
<http://mathiasbynens.be/> and his noSelect plugin.
<https://github.com/mathiasbynens/jquery-noselect>, which is embedded.
Also, thanks to David Kaneda and Eugene Bond for their contributions to the
plugin.
Tyler Akins has also rewritten chunks of the plugin, helped close many issues,
and ensured version 2 got out the door.
License:
MIT License - http://www.opensource.org/licenses/mit-license.php
Enjoy!
*/
/*global jQuery, window, document*/
(function ($, undef) {
"use strict";
/**
* Use .prop() if jQuery supports it, otherwise fall back to .attr()
*
* @param jQuery $el jQuery'd element on which we're calling attr/prop
* @param ... All other parameters are passed to jQuery's function
* @return The result from jQuery
*/
function attrOrProp($el) {
var args = Array.prototype.slice.call(arguments, 1);
if ($el.prop) {
// jQuery 1.6+
return $el.prop.apply($el, args);
}
// jQuery 1.5 and below
return $el.attr.apply($el, args);
}
/**
* For backwards compatibility with older jQuery libraries, only bind
* one thing at a time. Also, this function adds our namespace to
* events in one consistent location, shrinking the minified code.
*
* The properties on the events object are the names of the events
* that we are supposed to add to. It can be a space separated list.
* The namespace will be added automatically.
*
* @param jQuery $el
* @param Object options Uniform options for this element
* @param Object events Events to bind, properties are event names
*/
function bindMany($el, options, events) {
var name, namespaced;
for (name in events) {
if (events.hasOwnProperty(name)) {
namespaced = name.replace(/ |$/g, options.eventNamespace);
$el.bind(name, events[name]);
}
}
}
/**
* Bind the hover, active, focus, and blur UI updates
*
* @param jQuery $el Original element
* @param jQuery $target Target for the events (our div/span)
* @param Object options Uniform options for the element $target
*/
function bindUi($el, $target, options) {
bindMany($el, options, {
focus: function () {
$target.addClass(options.focusClass);
},
blur: function () {
$target.removeClass(options.focusClass);
$target.removeClass(options.activeClass);
},
mouseenter: function () {
$target.addClass(options.hoverClass);
},
mouseleave: function () {
$target.removeClass(options.hoverClass);
$target.removeClass(options.activeClass);
},
"mousedown touchbegin": function () {
if (!$el.is(":disabled")) {
$target.addClass(options.activeClass);
}
},
"mouseup touchend": function () {
$target.removeClass(options.activeClass);
}
});
}
/**
* Remove the hover, focus, active classes.
*
* @param jQuery $el Element with classes
* @param Object options Uniform options for the element
*/
function classClearStandard($el, options) {
$el.removeClass(options.hoverClass + " " + options.focusClass + " " + options.activeClass);
}
/**
* Add or remove a class, depending on if it's "enabled"
*
* @param jQuery $el Element that has the class added/removed
* @param String className Class or classes to add/remove
* @param Boolean enabled True to add the class, false to remove
*/
function classUpdate($el, className, enabled) {
if (enabled) {
$el.addClass(className);
} else {
$el.removeClass(className);
}
}
/**
* Updating the "checked" property can be a little tricky. This
* changed in jQuery 1.6 and now we can pass booleans to .prop().
* Prior to that, one either adds an attribute ("checked=checked") or
* removes the attribute.
*
* @param jQuery $tag Our Uniform span/div
* @param jQuery $el Original form element
* @param Object options Uniform options for this element
*/
function classUpdateChecked($tag, $el, options) {
var c = "checked",
isChecked = $el.is(":" + c);
if ($el.prop) {
// jQuery 1.6+
$el.prop(c, isChecked);
} else {
// jQuery 1.5 and below
if (isChecked) {
$el.attr(c, c);
} else {
$el.removeAttr(c);
}
}
classUpdate($tag, options.checkedClass, isChecked);
}
/**
* Set or remove the "disabled" class for disabled elements, based on
* if the
*
* @param jQuery $tag Our Uniform span/div
* @param jQuery $el Original form element
* @param Object options Uniform options for this element
*/
function classUpdateDisabled($tag, $el, options) {
classUpdate($tag, options.disabledClass, $el.is(":disabled"));
}
/**
* Wrap an element inside of a container or put the container next
* to the element. See the code for examples of the different methods.
*
* Returns the container that was added to the HTML.
*
* @param jQuery $el Element to wrap
* @param jQuery $container Add this new container around/near $el
* @param String method One of "after", "before" or "wrap"
* @return $container after it has been cloned for adding to $el
*/
function divSpanWrap($el, $container, method) {
switch (method) {
case "after":
// Result: <element /> <container />
$el.after($container);
return $el.next();
case "before":
// Result: <container /> <element />
$el.before($container);
return $el.prev();
case "wrap":
// Result: <container> <element /> </container>
$el.wrap($container);
return $el.parent();
}
return null;
}
/**
* Create a div/span combo for uniforming an element
*
* @param jQuery $el Element to wrap
* @param Object options Options for the element, set by the user
* @param Object divSpanConfig Options for how we wrap the div/span
* @return Object Contains the div and span as properties
*/
function divSpan($el, options, divSpanConfig) {
var $div, $span, id;
if (!divSpanConfig) {
divSpanConfig = {};
}
divSpanConfig = $.extend({
bind: {},
divClass: null,
divWrap: "wrap",
spanClass: null,
spanHtml: null,
spanWrap: "wrap"
}, divSpanConfig);
$div = $('<div />');
$span = $('<span />');
// Automatically hide this div/span if the element is hidden.
// Do not hide if the element is hidden because a parent is hidden.
if (options.autoHide && $el.is(':hidden') && $el.css('display') === 'none') {
$div.hide();
}
if (divSpanConfig.divClass) {
$div.addClass(divSpanConfig.divClass);
}
if (divSpanConfig.spanClass) {
$span.addClass(divSpanConfig.spanClass);
}
id = attrOrProp($el, 'id');
if (options.useID && id) {
attrOrProp($div, 'id', options.idPrefix + '-' + id);
}
if (divSpanConfig.spanHtml) {
$span.html(divSpanConfig.spanHtml);
}
$div = divSpanWrap($el, $div, divSpanConfig.divWrap);
$span = divSpanWrap($el, $span, divSpanConfig.spanWrap);
classUpdateDisabled($div, $el, options);
return {
div: $div,
span: $span
};
}
/**
* Test if high contrast mode is enabled.
*
* In high contrast mode, background images can not be set and
* they are always returned as 'none'.
*
* @return boolean True if in high contrast mode
*/
function highContrast() {
var c, $div, el, rgb;
// High contrast mode deals with white and black
rgb = 'rgb(120,2,153)';
$div = $('<div style="width:0;height:0;color:' + rgb + '">');
$('body').append($div);
el = $div.get(0);
// $div.css() will get the style definition, not
// the actually displaying style
if (window.getComputedStyle) {
c = window.getComputedStyle(el, '').color;
} else {
c = (el.currentStyle || el.style || {}).color;
}
$div.remove();
return c.replace(/ /g, '') !== rgb;
}
/**
* Change text into safe HTML
*
* @param String text
* @return String HTML version
*/
function htmlify(text) {
if (!text) {
return "";
}
return $('<span />').text(text).html();
}
/**
* Test if the element is a multiselect
*
* @param jQuery $el Element
* @return boolean true/false
*/
function isMultiselect($el) {
var elSize;
if ($el[0].multiple) {
return true;
}
elSize = attrOrProp($el, "size");
if (!elSize || elSize <= 1) {
return false;
}
return true;
}
/**
* Meaningless utility function. Used mostly for improving minification.
*
* @return false
*/
function returnFalse() {
return false;
}
/**
* noSelect plugin, very slightly modified
* http://mths.be/noselect v1.0.3
*
* @param jQuery $elem Element that we don't want to select
* @param Object options Uniform options for the element
*/
function noSelect($elem, options) {
var none = 'none';
bindMany($elem, options, {
'selectstart dragstart mousedown': returnFalse
});
$elem.css({
MozUserSelect: none,
msUserSelect: none,
webkitUserSelect: none,
userSelect: none
});
}
/**
* Updates the filename tag based on the value of the real input
* element.
*
* @param jQuery $el Actual form element
* @param jQuery $filenameTag Span/div to update
* @param Object options Uniform options for this element
*/
function setFilename($el, $filenameTag, options) {
var filename = $el.val();
if (filename === "") {
filename = options.fileDefaultHtml;
} else {
filename = filename.split(/[\/\\]+/);
filename = filename[(filename.length - 1)];
}
$filenameTag.text(filename);
}
/**
* Function from jQuery to swap some CSS values, run a callback,
* then restore the CSS. Modified to pass JSLint and handle undefined
* values with 'use strict'.
*
* @param jQuery $el Element
* @param object newCss CSS values to swap out
* @param Function callback Function to run
*/
function swap($el, newCss, callback) {
var restore, item;
restore = [];
$el.each(function () {
var name;
for (name in newCss) {
if (Object.prototype.hasOwnProperty.call(newCss, name)) {
restore.push({
el: this,
name: name,
old: this.style[name]
});
this.style[name] = newCss[name];
}
}
});
callback();
while (restore.length) {
item = restore.pop();
item.el.style[item.name] = item.old;
}
}
/**
* The browser doesn't provide sizes of elements that are not visible.
* This will clone an element and add it to the DOM for calculations.
*
* @param jQuery $el
* @param String method
*/
function sizingInvisible($el, callback) {
swap($el.parents().andSelf().not(':visible'), {
visibility: "hidden",
display: "block",
position: "absolute"
}, callback);
}
/**
* Standard way to unwrap the div/span combination from an element
*
* @param jQuery $el Element that we wish to preserve
* @param Object options Uniform options for the element
* @return Function This generated function will perform the given work
*/
function unwrapUnwrapUnbindFunction($el, options) {
return function () {
$el.unwrap().unwrap().unbind(options.eventNamespace);
};
}
var allowStyling = true, // False if IE6 or other unsupported browsers
highContrastTest = false, // Was the high contrast test ran?
uniformHandlers = [ // Objects that take care of "unification"
{
// Buttons
match: function ($el) {
return $el.is("a, button, :submit, :reset, input[type='button']");
},
apply: function ($el, options) {
var $div, defaultSpanHtml, ds, getHtml, doingClickEvent;
defaultSpanHtml = options.submitDefaultHtml;
if ($el.is(":reset")) {
defaultSpanHtml = options.resetDefaultHtml;
}
if ($el.is("a, button")) {
// Use the HTML inside the tag
getHtml = function () {
return $el.html() || defaultSpanHtml;
};
} else {
// Use the value property of the element
getHtml = function () {
return htmlify(attrOrProp($el, "value")) || defaultSpanHtml;
};
}
ds = divSpan($el, options, {
divClass: options.buttonClass,
spanHtml: getHtml()
});
$div = ds.div;
bindUi($el, $div, options);
doingClickEvent = false;
bindMany($div, options, {
"click touchend": function () {
var ev, res, target, href;
if (doingClickEvent) {
return;
}
doingClickEvent = true;
if ($el[0].dispatchEvent) {
ev = document.createEvent("MouseEvents");
ev.initEvent("click", true, true);
res = $el[0].dispatchEvent(ev);
// What about Chrome and Opera?
// Should the browser check be removed?
if ((jQuery.browser.msie || jQuery.browser.mozilla) && $el.is('a') && res) {
target = attrOrProp($el, 'target');
href = attrOrProp($el, 'href');
if (!target || target === '_self') {
document.location.href = href;
} else {
window.open(href, target);
}
}
} else {
$el.click();
}
doingClickEvent = false;
}
});
noSelect($div, options);
return {
remove: function () {
// Move $el out
$div.after($el);
// Remove div and span
$div.remove();
// Unbind events
$el.unbind(options.eventNamespace);
return $el;
},
update: function () {
classClearStandard($div, options);
classUpdateDisabled($div, $el, options);
ds.span.html(getHtml());
}
};
}
},
{
// Checkboxes
match: function ($el) {
return $el.is(":checkbox");
},
apply: function ($el, options) {
var ds, $div, $span;
ds = divSpan($el, options, {
divClass: options.checkboxClass
});
$div = ds.div;
$span = ds.span;
// Add focus classes, toggling, active, etc.
bindUi($el, $div, options);
bindMany($el, options, {
"click touchend": function () {
classUpdateChecked($span, $el, options);
}
});
classUpdateChecked($span, $el, options);
return {
remove: unwrapUnwrapUnbindFunction($el, options),
update: function () {
classClearStandard($div, options);
$span.removeClass(options.checkedClass);
classUpdateChecked($span, $el, options);
classUpdateDisabled($div, $el, options);
}
};
}
},
{
// File selection / uploads
match: function ($el) {
return $el.is(":file");
},
apply: function ($el, options) {
var ds, $div, $filename, $button;
// The "span" is the button
ds = divSpan($el, options, {
divClass: options.fileClass,
spanClass: options.fileButtonClass,
spanHtml: options.fileButtonHtml,
spanWrap: "after"
});
$div = ds.div;
$button = ds.span;
$filename = $("<span />").html(options.fileDefaultHtml);
$filename.addClass(options.filenameClass);
$filename = divSpanWrap($el, $filename, "after");
// Set the size
if (!attrOrProp($el, "size")) {
attrOrProp($el, "size", $div.width() / 10);
}
// Actions
function filenameUpdate() {
setFilename($el, $filename, options);
}
bindUi($el, $div, options);
// Account for input saved across refreshes
filenameUpdate();
// IE7 doesn't fire onChange until blur or second fire.
if ($.browser.msie) {
// IE considers browser chrome blocking I/O, so it
// suspends tiemouts until after the file has
// been selected.
bindMany($el, options, {
click: function () {
$el.trigger("change");
setTimeout(filenameUpdate, 0);
}
});
} else {
// All other browsers behave properly
bindMany($el, options, {
change: filenameUpdate
});
}
noSelect($filename, options);
noSelect($button, options);
return {
remove: function () {
// Remove filename and button
$filename.remove();
$button.remove();
// Unwrap parent div, remove events
return $el.unwrap().unbind(options.eventNamespace);
},
update: function () {
classClearStandard($div, options);
setFilename($el, $filename, options);
classUpdateDisabled($div, $el, options);
}
};
}
},
{
// Input fields (text)
match: function ($el) {
if ($el.is("input")) {
var t = (" " + attrOrProp($el, "type") + " ").toLowerCase(),
allowed = " color date datetime datetime-local email month number password search tel text time url week ";
return allowed.indexOf(t) >= 0;
}
return false;
},
apply: function ($el) {
var elType = attrOrProp($el, "type");
$el.addClass(elType);
return {
remove: function () {
$el.removeClass(elType);
},
update: returnFalse
};
}
},
{
// Radio buttons
match: function ($el) {
return $el.is(":radio");
},
apply: function ($el, options) {
var ds, $div, $span;
ds = divSpan($el, options, {
divClass: options.radioClass
});
$div = ds.div;
$span = ds.span;
// Add classes for focus, handle active, checked
bindUi($el, $div, options);
bindMany($el, options, {
"click touchend": function () {
// Find all radios with the same name, then update
// them with $.uniform.update() so the right
// per-element options are used
$.uniform.update($(':radio[name="' + attrOrProp($el, "name") + '"]'));
}
});
classUpdateChecked($span, $el, options);
return {
remove: unwrapUnwrapUnbindFunction($el, options),
update: function () {
classClearStandard($div, options);
classUpdateChecked($span, $el, options);
classUpdateDisabled($div, $el, options);
}
};
}
},
{
// Select lists, but do not style multiselects here
match: function ($el) {
if ($el.is("select") && !isMultiselect($el)) {
return true;
}
return false;
},
apply: function ($el, options) {
var ds, $div, $span, origElemWidth;
if (options.selectAutoWidth) {
sizingInvisible($el, function () {
origElemWidth = $el.width();
});
}
ds = divSpan($el, options, {
divClass: options.selectClass,
spanHtml: ($el.find(":selected:first") || $el.find("option:first")).html(),
spanWrap: "before"
});
$div = ds.div;
$span = ds.span;
if (options.selectAutoWidth) {
// Use the width of the select and adjust the
// span and div accordingly
sizingInvisible($el, function () {
var spanPad;
spanPad = $span.outerWidth() - $span.width();
$div.width(origElemWidth + spanPad);
$span.width(origElemWidth);
});
} else {
// Force the select to fill the size of the div
$div.addClass('fixedWidth');
}
// Take care of events
bindUi($el, $div, options);
bindMany($el, options, {
change: function () {
$span.html($el.find(":selected").html());
$div.removeClass(options.activeClass);
},
"click touchend": function () {
// IE7 and IE8 may not update the value right
// until after click event - issue #238
var selHtml = $el.find(":selected").html();
if ($span.html() !== selHtml) {
// Change was detected
// Fire the change event on the select tag
$el.trigger('change');
}
},
keyup: function () {
$span.html($el.find(":selected").html());
}
});
noSelect($span, options);
return {
remove: function () {
// Remove sibling span
$span.remove();
// Unwrap parent div
$el.unwrap().unbind(options.eventNamespace);
return $el;
},
update: function () {
if (options.selectAutoWidth) {
// Easier to remove and reapply formatting
$.uniform.restore($el);
$el.uniform(options);
} else {
classClearStandard($div, options);
// Reset current selected text
$span.html($el.find(":selected").html());
classUpdateDisabled($div, $el, options);
}
}
};
}
},
{
// Select lists - multiselect lists only
match: function ($el) {
if ($el.is("select") && isMultiselect($el)) {
return true;
}
return false;
},
apply: function ($el, options) {
$el.addClass(options.selectMultiClass);
return {
remove: function () {
$el.removeClass(options.selectMultiClass);
},
update: returnFalse
};
}
},
{
// Textareas
match: function ($el) {
return $el.is("textarea");
},
apply: function ($el, options) {
$el.addClass(options.textareaClass);
return {
remove: function () {
$el.removeClass(options.textareaClass);
},
update: returnFalse
};
}
}
];
// IE6 can't be styled - can't set opacity on select
if ($.browser.msie && $.browser.version < 7) {
allowStyling = false;
}
$.uniform = {
// Default options that can be overridden globally or when uniformed
// globally: $.uniform.defaults.fileButtonHtml = "Pick A File";
// on uniform: $('input').uniform({fileButtonHtml: "Pick a File"});
defaults: {
activeClass: "active",
autoHide: true,
buttonClass: "button",
checkboxClass: "checker",
checkedClass: "checked",
disabledClass: "disabled",
eventNamespace: ".uniform",
fileButtonClass: "action",
fileButtonHtml: "Choose File",
fileClass: "uploader",
fileDefaultHtml: "No file selected",
filenameClass: "filename",
focusClass: "focus",
hoverClass: "hover",
idPrefix: "uniform",
radioClass: "radio",
resetDefaultHtml: "Reset",
resetSelector: false, // We'll use our own function when you don't specify one
selectAutoWidth: true,
selectClass: "selector",
selectMultiClass: "uniform-multiselect",
submitDefaultHtml: "Submit", // Only text allowed
textareaClass: "uniform",
useID: true
},
// All uniformed elements - DOM objects
elements: []
};
$.fn.uniform = function (options) {
var el = this;
options = $.extend({}, $.uniform.defaults, options);
// If we are in high contrast mode, do not allow styling
if (!highContrastTest) {
highContrastTest = true;
if (highContrast()) {
allowStyling = false;
}
}
// Only uniform on browsers that work
if (!allowStyling) {
return this;
}
// Code for specifying a reset button
if (options.resetSelector) {
$(options.resetSelector).mouseup(function () {
window.setTimeout(function () {
$.uniform.update(el);
}, 10);
});
}
return this.each(function () {
var $el = $(this), i, handler, callbacks;
// Avoid uniforming elements already uniformed - just update
if ($el.data("uniformed")) {
$.uniform.update($el);
return;
}
// See if we have any handler for this type of element
for (i = 0; i < uniformHandlers.length; i = i + 1) {
handler = uniformHandlers[i];
if (handler.match($el, options)) {
callbacks = handler.apply($el, options);
$el.data("uniformed", callbacks);
// Store element in our global array
$.uniform.elements.push($el.get(0));
return;
}
}
// Could not style this element
});
};
$.uniform.restore = $.fn.uniform.restore = function (elem) {
if (elem === undef) {
elem = $.uniform.elements;
}
$(elem).each(function () {
var $el = $(this), index, elementData;
elementData = $el.data("uniformed");
// Skip elements that are not uniformed
if (!elementData) {
return;
}
// Unbind events, remove additional markup that was added
elementData.remove();
// Remove item from list of uniformed elements
index = $.inArray(this, $.uniform.elements);
if (index >= 0) {
$.uniform.elements.splice(index, 1);
}
$el.removeData("uniformed");
});
};
$.uniform.update = $.fn.uniform.update = function (elem) {
if (elem === undef) {
elem = $.uniform.elements;
}
$(elem).each(function () {
var $el = $(this), elementData;
elementData = $el.data("uniformed");
// Skip elements that are not uniformed
if (!elementData) {
return;
}
elementData.update($el, elementData.options);
});
};
}(jQuery));
| JavaScript |
// Utility for creating objects in older browsers
if ( typeof Object.create !== 'function' ) {
Object.create = function( obj ) {
function F() {}
F.prototype = obj;
return new F();
};
}
/*!
* jQuery panelSnap
* Version 0.12.0
*
* Requires:
* - jQuery 1.7 or higher (no jQuery.migrate needed)
*
* https://github.com/guidobouman/jquery-panelsnap
*
* Copyright 2013, Guido Bouman
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Date: Wed Feb 13 16:05:00 2013 +0100
*/
(function($, window, document, undefined) {
var pluginName = 'panelSnap';
var storageName = 'plugin_' + pluginName;
var pluginObject = {
isMouseDown: false,
isSnapping: false,
enabled: true,
scrollInterval: 0,
scrollOffset: 0,
init: function(options, container) {
var self = this;
self.container = container;
self.$container = $(container);
self.$eventContainer = self.$container;
self.$snapContainer = self.$container;
if(self.$container.is('body')) {
self.$eventContainer = $(document);
self.$snapContainer = $(document.documentElement);
var ua = navigator.userAgent;
if(~ua.indexOf('WebKit')) {
self.$snapContainer = $('body');
}
}
self.scrollInterval = self.$container.height();
self.options = $.extend(true, {}, $.fn.panelSnap.options, options);
self.bind();
if(self.options.$menu !== false && $('.active', self.options.$menu).length > 0) {
$('.active', self.options.$menu).click();
} else {
var $target = self.getPanel(':first');
self.activatePanel($target);
}
return self;
},
bind: function() {
var self = this;
self.bindProxied(self.$eventContainer, 'scrollstop', self.scrollStop);
self.bindProxied(self.$eventContainer, 'mousewheel', self.mouseWheel);
self.bindProxied(self.$eventContainer, 'mousedown', self.mouseDown);
self.bindProxied(self.$eventContainer, 'mouseup', self.mouseUp);
self.bindProxied($(window), 'resizestop', self.resize);
if(self.options.keyboardNavigation.enabled) {
self.bindProxied($(window), 'keydown', self.keyDown, self.$eventContainer);
}
if(self.options.$menu !== false) {
self.bindProxied($(self.options.$menu), 'click', self.captureMenuClick, self.options.menuSelector);
}
},
bindProxied: function($element, event, method, selector) {
var self = this;
selector = typeof selector === 'string' ? selector : null;
$element.on(event + self.options.namespace, selector, $.proxy(function(e) {
return method.call(self, e);
}, self));
},
destroy: function() {
var self = this;
// Gotta love namespaced events!
self.$eventContainer.off(self.options.namespace);
$(window).off(self.options.namespace);
if(self.options.$menu !== false) {
$(self.options.menuSelector, self.options.$menu).off(self.options.namespace);
}
self.$container.removeData(storageName);
},
scrollStop: function(e) {
var self = this;
e.stopPropagation();
if(!self.enabled) {
return;
}
if(self.isMouseDown) {
self.$eventContainer.one('mouseup' + self.options.namespace, self.processScroll);
return;
}
if(self.isSnapping) {
return;
}
var offset = self.$snapContainer.scrollTop();
var scrollDifference = offset - self.scrollOffset;
var maxOffset = self.$container[0].scrollHeight - self.scrollInterval;
var panelCount = self.getPanel().length;
var childNumber;
if(
scrollDifference < -self.options.directionThreshold &&
scrollDifference > -self.scrollInterval
) {
childNumber = Math.floor(offset / self.scrollInterval);
} else if(
scrollDifference > self.options.directionThreshold &&
scrollDifference < self.scrollInterval
) {
childNumber = Math.ceil(offset / self.scrollInterval);
} else {
childNumber = Math.round(offset / self.scrollInterval);
}
childNumber = Math.max(0, Math.min(childNumber, panelCount));
var $target = self.getPanel(':eq(' + childNumber + ')');
if(scrollDifference === 0) {
// Do nothing
} else if (offset <= 0 || offset >= maxOffset) {
// Only activate, prevent stuttering
self.activatePanel($target);
// Set scrollOffset to a sane number for next scroll
self.scrollOffset = offset < 0 ? 0 : maxOffset;
} else {
self.snapToPanel($target);
}
},
mouseWheel: function(e) {
var self = this;
// This event only fires when the user actually scrolls with their input device.
// Be it a trackpad, legacy mouse or anything else.
self.$container.stop(true);
self.isSnapping = false;
},
mouseDown: function(e) {
var self = this;
self.isMouseDown = true;
},
mouseUp: function(e) {
var self = this;
self.isMouseDown = false;
if(self.scrollOffset !== self.$snapContainer.scrollTop()) {
self.scrollStop(e);
}
},
keyDown: function(e) {
var self = this;
var nav = self.options.keyboardNavigation;
if (self.isSnapping) {
if(e.which == nav.previousPanelKey || e.which == nav.nextPanelKey) {
e.preventDefault();
return false;
}
return;
}
switch(e.which) {
case nav.previousPanelKey:
e.preventDefault();
self.snapTo('prev', nav.wrapAround);
break;
case nav.nextPanelKey:
e.preventDefault();
self.snapTo('next', nav.wrapAround);
break;
}
},
resize: function(e) {
var self = this;
self.scrollInterval = self.$container.height();
if(!self.enabled) {
return;
}
var $target = self.getPanel('.active');
self.snapToPanel($target);
},
captureMenuClick: function(e) {
var self = this;
var panel = $(e.currentTarget).data('panel');
var $target = self.getPanel('[data-panel="' + panel + '"]');
self.snapToPanel($target);
return false;
},
snapToPanel: function($target) {
var self = this;
if (!($target instanceof jQuery)) {
return;
}
self.isSnapping = true;
self.options.onSnapStart.call(self, $target);
self.$container.trigger('panelsnap:start', [$target]);
var scrollTarget = 0;
if(self.$container.is('body')) {
scrollTarget = $target.offset().top;
} else {
scrollTarget = self.$snapContainer.scrollTop() + $target.position().top;
}
self.$snapContainer.stop(true).animate({
scrollTop: scrollTarget
}, self.options.slideSpeed, function() {
self.scrollOffset = scrollTarget;
self.isSnapping = false;
// Call callback
self.options.onSnapFinish.call(self, $target);
self.$container.trigger('panelsnap:finish', [$target]);
});
self.activatePanel($target);
},
activatePanel: function($target) {
var self = this;
self.getPanel('.active').removeClass('active');
$target.addClass('active');
if(self.options.$menu !== false) {
var activeItemSelector = '> ' + self.options.menuSelector + '.active';
$(activeItemSelector, self.options.$menu).removeClass('active');
var attribute = '[data-panel="' + $target.data('panel') + '"]';
var itemSelector = '> ' + self.options.menuSelector + attribute;
var $itemToActivate = $(itemSelector, self.options.$menu);
$itemToActivate.addClass('active');
}
self.options.onActivate.call(self, $target);
self.$container.trigger('panelsnap:activate', [$target]);
},
getPanel: function(selector) {
var self = this;
if(typeof selector === 'undefined') {
selector = '';
}
var panelSelector = '> ' + self.options.panelSelector + selector;
return $(panelSelector, self.$container);
},
snapTo: function(target, wrap) {
var self = this;
if(typeof wrap !== 'boolean') {
wrap = true;
}
var $target;
switch(target) {
case 'prev':
$target = self.getPanel('.active').prev(self.options.panelSelector);
if($target.length < 1 && wrap)
{
$target = self.getPanel(':last');
}
break;
case 'next':
$target = self.getPanel('.active').next(self.options.panelSelector);
if($target.length < 1 && wrap)
{
$target = self.getPanel(':first');
}
break;
case 'first':
$target = self.getPanel(':first');
break;
case 'last':
$target = self.getPanel(':last');
break;
}
if($target.length > 0) {
self.snapToPanel($target);
}
},
enable: function() {
var self = this;
// Gather scrollOffset for next scroll
self.scrollOffset = self.$container[0].scrollHeight;
self.enabled = true;
},
disable: function() {
var self = this;
self.enabled = false;
},
toggle: function() {
var self = this;
if(self.enabled) {
self.disable();
} else {
self.enable();
}
}
};
$.fn[pluginName] = function(options) {
var args = Array.prototype.slice.call(arguments);
return this.each(function() {
var pluginInstance = $.data(this, storageName);
if(typeof options === 'object' || options === 'init' || ! options) {
if(!pluginInstance) {
if(options === 'init') {
options = args[1] || {};
}
pluginInstance = Object.create(pluginObject).init(options, this);
$.data(this, storageName, pluginInstance);
} else {
$.error('Plugin is already initialized for this object.');
return;
}
} else if(!pluginInstance) {
$.error('Plugin is not initialized for this object yet.');
return;
} else if(pluginInstance[options]) {
var method = options;
options = args.slice(1);
pluginInstance[method].apply(pluginInstance, options);
} else {
$.error('Method ' + options + ' does not exist on jQuery.panelSnap.');
return;
}
});
};
$.fn[pluginName].options = {
$menu: false,
menuSelector: 'a',
panelSelector: 'section',
namespace: '.panelSnap',
onSnapStart: function(){},
onSnapFinish: function(){},
onActivate: function(){},
directionThreshold: 50,
slideSpeed: 200,
keyboardNavigation: {
enabled: false,
nextPanelKey: 40,
previousPanelKey: 38,
wrapAround: true
}
};
})(jQuery, window, document);
/*!
* Special flavoured jQuery Mobile scrollstart & scrollstop events.
* Version 0.1.3
*
* Requires:
* - jQuery 1.7.1 or higher (no jQuery.migrate needed)
*
* Copyright 2013, Guido Bouman
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Date: Wed Feb 13 16:05:00 2013 +0100
*/
(function($) {
// Also handles the scrollstop event
$.event.special.scrollstart = {
enabled: true,
setup: function() {
var thisObject = this;
var $this = $(thisObject);
var scrolling;
var timer;
$this.data('scrollwatch', true);
function trigger(event, scrolling) {
event.type = scrolling ? "scrollstart" : "scrollstop";
$this.trigger(event);
}
$this.on("touchmove scroll", function(event) {
if(!$.event.special.scrollstart.enabled) {
return;
}
if(!$.event.special.scrollstart.scrolling) {
$.event.special.scrollstart.scrolling = true;
trigger(event, true);
}
clearTimeout(timer);
timer = setTimeout(function() {
$.event.special.scrollstart.scrolling = false;
trigger(event, false);
}, 50);
});
}
};
// Proxies scrollstart when needed
$.event.special.scrollstop = {
setup: function() {
var thisObject = this;
var $this = $(thisObject);
if(!$this.data('scrollwatch')) {
$(this).on('scrollstart', function(){});
}
}
};
})(jQuery);
/*!
* Resizestart and resizestop events.
* Version 0.0.1
*
* Requires:
* - jQuery 1.7.1 or higher (no jQuery.migrate needed)
*
* Copyright 2013, Guido Bouman
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
* Date: Fri Oct 25 15:05:00 2013 +0100
*/
(function($) {
// Also handles the resizestop event
$.event.special.resizestart = {
enabled: true,
setup: function() {
var thisObject = this;
var $this = $(thisObject);
var resizing;
var timer;
$this.data('resizewatch', true);
function trigger(event, resizing) {
event.type = resizing ? "resizestart" : "resizestop";
$this.trigger(event);
}
$this.on("resize", function(event) {
if(!$.event.special.resizestart.enabled) {
return;
}
if(!$.event.special.resizestart.resizing) {
$.event.special.resizestart.resizing = true;
trigger(event, true);
}
clearTimeout(timer);
timer = setTimeout(function() {
$.event.special.resizestart.resizing = false;
trigger(event, false);
}, 200);
});
}
};
// Proxies resizestart when needed
$.event.special.resizestop = {
setup: function() {
var thisObject = this;
var $this = $(thisObject);
if(!$this.data('resizewatch')) {
$(this).on('resizestart', function(){});
}
}
};
})(jQuery);
/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
* Licensed under the MIT License (LICENSE.txt).
*
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
* Thanks to: Seamus Leahy for adding deltaX and deltaY
*
* Version: 3.0.6
*
* Requires: 1.2.2+
*/
(function($) {
var types = ['DOMMouseScroll', 'mousewheel'];
if ($.event.fixHooks) {
for ( var i=types.length; i; ) {
$.event.fixHooks[ types[--i] ] = $.event.mouseHooks;
}
}
$.event.special.mousewheel = {
setup: function() {
if ( this.addEventListener ) {
for ( var i=types.length; i; ) {
this.addEventListener( types[--i], handler, false );
}
} else {
this.onmousewheel = handler;
}
},
teardown: function() {
if ( this.removeEventListener ) {
for ( var i=types.length; i; ) {
this.removeEventListener( types[--i], handler, false );
}
} else {
this.onmousewheel = null;
}
}
};
$.fn.extend({
mousewheel: function(fn) {
return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
},
unmousewheel: function(fn) {
return this.unbind("mousewheel", fn);
}
});
function handler(event) {
var orgEvent = event || window.event,
args = [].slice.call( arguments, 1 ),
delta = 0,
returnValue = true,
deltaX = 0,
deltaY = 0;
event = $.event.fix(orgEvent);
event.type = "mousewheel";
// Old school scrollwheel delta
if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta/120; }
if ( orgEvent.detail ) { delta = -orgEvent.detail/3; }
// New school multidimensional scroll (touchpads) deltas
deltaY = delta;
// Gecko
if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
deltaY = 0;
deltaX = -1*delta;
}
// Webkit
if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
// Add event and delta to the front of the arguments
args.unshift(event, delta, deltaX, deltaY);
return ($.event.dispatch || $.event.handle).apply(this, args);
}
})(jQuery);
| JavaScript |
/*
* FancyBox - jQuery Plugin
* Simple and fancy lightbox alternative
*
* Examples and documentation at: http://fancybox.net
*
* Copyright (c) 2008 - 2010 Janis Skarnelis
* That said, it is hardly a one-person project. Many people have submitted bugs, code, and offered their advice freely. Their support is greatly appreciated.
*
* Version: 1.3.4 (11/11/2010)
* Requires: jQuery v1.3+
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
;(function($) {
var tmp, loading, overlay, wrap, outer, content, close, title, nav_left, nav_right,
selectedIndex = 0, selectedOpts = {}, selectedArray = [], currentIndex = 0, currentOpts = {}, currentArray = [],
ajaxLoader = null, imgPreloader = new Image(), imgRegExp = /\.(jpg|gif|png|bmp|jpeg)(.*)?$/i, swfRegExp = /[^\.]\.(swf)\s*$/i,
loadingTimer, loadingFrame = 1,
titleHeight = 0, titleStr = '', start_pos, final_pos, busy = false, fx = $.extend($('<div/>')[0], { prop: 0 }),
isIE6 = navigator.userAgent.match(/msie/i) && navigator.userAgent.match(/6/) && !window.XMLHttpRequest,
/*
* Private methods
*/
_abort = function() {
loading.hide();
imgPreloader.onerror = imgPreloader.onload = null;
if (ajaxLoader) {
ajaxLoader.abort();
}
tmp.empty();
},
_error = function() {
if (false === selectedOpts.onError(selectedArray, selectedIndex, selectedOpts)) {
loading.hide();
busy = false;
return;
}
selectedOpts.titleShow = false;
selectedOpts.width = 'auto';
selectedOpts.height = 'auto';
tmp.html( '<p id="fancybox-error">The requested content cannot be loaded.<br />Please try again later.</p>' );
_process_inline();
},
_start = function() {
var obj = selectedArray[ selectedIndex ],
href,
type,
title,
str,
emb,
ret;
_abort();
selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));
ret = selectedOpts.onStart(selectedArray, selectedIndex, selectedOpts);
if (ret === false) {
busy = false;
return;
} else if (typeof ret == 'object') {
selectedOpts = $.extend(selectedOpts, ret);
}
title = selectedOpts.title || (obj.nodeName ? $(obj).attr('title') : obj.title) || '';
if (obj.nodeName && !selectedOpts.orig) {
selectedOpts.orig = $(obj).children("img:first").length ? $(obj).children("img:first") : $(obj);
}
if (title === '' && selectedOpts.orig && selectedOpts.titleFromAlt) {
title = selectedOpts.orig.attr('alt');
}
href = selectedOpts.href || (obj.nodeName ? $(obj).attr('href') : obj.href) || null;
if ((/^(?:javascript)/i).test(href) || href == '#') {
href = null;
}
if (selectedOpts.type) {
type = selectedOpts.type;
if (!href) {
href = selectedOpts.content;
}
} else if (selectedOpts.content) {
type = 'html';
} else if (href) {
if (href.match(imgRegExp)) {
type = 'image';
} else if (href.match(swfRegExp)) {
type = 'swf';
} else if ($(obj).hasClass("iframe")) {
type = 'iframe';
} else if (href.indexOf("#") === 0) {
type = 'inline';
} else {
type = 'ajax';
}
}
if (!type) {
_error();
return;
}
if (type == 'inline') {
obj = href.substr(href.indexOf("#"));
type = $(obj).length > 0 ? 'inline' : 'ajax';
}
selectedOpts.type = type;
selectedOpts.href = href;
selectedOpts.title = title;
if (selectedOpts.autoDimensions) {
if (selectedOpts.type == 'html' || selectedOpts.type == 'inline' || selectedOpts.type == 'ajax') {
selectedOpts.width = 'auto';
selectedOpts.height = 'auto';
} else {
selectedOpts.autoDimensions = false;
}
}
if (selectedOpts.modal) {
selectedOpts.overlayShow = true;
selectedOpts.hideOnOverlayClick = false;
selectedOpts.hideOnContentClick = false;
selectedOpts.enableEscapeButton = false;
selectedOpts.showCloseButton = false;
}
selectedOpts.padding = parseInt(selectedOpts.padding, 10);
selectedOpts.margin = parseInt(selectedOpts.margin, 10);
tmp.css('padding', (selectedOpts.padding + selectedOpts.margin));
$('.fancybox-inline-tmp').unbind('fancybox-cancel').bind('fancybox-change', function() {
$(this).replaceWith(content.children());
});
switch (type) {
case 'html' :
tmp.html( selectedOpts.content );
_process_inline();
break;
case 'inline' :
if ( $(obj).parent().is('#fancybox-content') === true) {
busy = false;
return;
}
$('<div class="fancybox-inline-tmp" />')
.hide()
.insertBefore( $(obj) )
.bind('fancybox-cleanup', function() {
$(this).replaceWith(content.children());
}).bind('fancybox-cancel', function() {
$(this).replaceWith(tmp.children());
});
$(obj).appendTo(tmp);
_process_inline();
break;
case 'image':
busy = false;
$.fancybox.showActivity();
imgPreloader = new Image();
imgPreloader.onerror = function() {
_error();
};
imgPreloader.onload = function() {
busy = true;
imgPreloader.onerror = imgPreloader.onload = null;
_process_image();
};
imgPreloader.src = href;
break;
case 'swf':
selectedOpts.scrolling = 'no';
str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"><param name="movie" value="' + href + '"></param>';
emb = '';
$.each(selectedOpts.swf, function(name, val) {
str += '<param name="' + name + '" value="' + val + '"></param>';
emb += ' ' + name + '="' + val + '"';
});
str += '<embed src="' + href + '" type="application/x-shockwave-flash" width="' + selectedOpts.width + '" height="' + selectedOpts.height + '"' + emb + '></embed></object>';
tmp.html(str);
_process_inline();
break;
case 'ajax':
busy = false;
$.fancybox.showActivity();
selectedOpts.ajax.win = selectedOpts.ajax.success;
ajaxLoader = $.ajax($.extend({}, selectedOpts.ajax, {
url : href,
data : selectedOpts.ajax.data || {},
error : function(XMLHttpRequest, textStatus, errorThrown) {
if ( XMLHttpRequest.status > 0 ) {
_error();
}
},
success : function(data, textStatus, XMLHttpRequest) {
var o = typeof XMLHttpRequest == 'object' ? XMLHttpRequest : ajaxLoader;
if (o.status == 200) {
if ( typeof selectedOpts.ajax.win == 'function' ) {
ret = selectedOpts.ajax.win(href, data, textStatus, XMLHttpRequest);
if (ret === false) {
loading.hide();
return;
} else if (typeof ret == 'string' || typeof ret == 'object') {
data = ret;
}
}
tmp.html( data );
_process_inline();
}
}
}));
break;
case 'iframe':
_show();
break;
}
},
_process_inline = function() {
var
w = selectedOpts.width,
h = selectedOpts.height;
if (w.toString().indexOf('%') > -1) {
w = parseInt( ($(window).width() - (selectedOpts.margin * 2)) * parseFloat(w) / 100, 10) + 'px';
} else {
w = w == 'auto' ? 'auto' : w + 'px';
}
if (h.toString().indexOf('%') > -1) {
h = parseInt( ($(window).height() - (selectedOpts.margin * 2)) * parseFloat(h) / 100, 10) + 'px';
} else {
h = h == 'auto' ? 'auto' : h + 'px';
}
tmp.wrapInner('<div style="width:' + w + ';height:' + h + ';overflow: ' + (selectedOpts.scrolling == 'auto' ? 'auto' : (selectedOpts.scrolling == 'yes' ? 'scroll' : 'hidden')) + ';position:relative;"></div>');
selectedOpts.width = tmp.width();
selectedOpts.height = tmp.height();
_show();
},
_process_image = function() {
selectedOpts.width = imgPreloader.width;
selectedOpts.height = imgPreloader.height;
$("<img />").attr({
'id' : 'fancybox-img',
'src' : imgPreloader.src,
'alt' : selectedOpts.title
}).appendTo( tmp );
_show();
},
_show = function() {
var pos, equal;
loading.hide();
if (wrap.is(":visible") && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
$.event.trigger('fancybox-cancel');
busy = false;
return;
}
busy = true;
$(content.add( overlay )).unbind();
$(window).unbind("resize.fb scroll.fb");
$(document).unbind('keydown.fb');
if (wrap.is(":visible") && currentOpts.titlePosition !== 'outside') {
wrap.css('height', wrap.height());
}
currentArray = selectedArray;
currentIndex = selectedIndex;
currentOpts = selectedOpts;
if (currentOpts.overlayShow) {
overlay.css({
'background-color' : currentOpts.overlayColor,
'opacity' : currentOpts.overlayOpacity,
'cursor' : currentOpts.hideOnOverlayClick ? 'pointer' : 'auto',
'height' : $(document).height()
});
if (!overlay.is(':visible')) {
if (isIE6) {
$('select:not(#fancybox-tmp select)').filter(function() {
return this.style.visibility !== 'hidden';
}).css({'visibility' : 'hidden'}).one('fancybox-cleanup', function() {
this.style.visibility = 'inherit';
});
}
overlay.show();
}
} else {
overlay.hide();
}
final_pos = _get_zoom_to();
_process_title();
if (wrap.is(":visible")) {
$( close.add( nav_left ).add( nav_right ) ).hide();
pos = wrap.position(),
start_pos = {
top : pos.top,
left : pos.left,
width : wrap.width(),
height : wrap.height()
};
equal = (start_pos.width == final_pos.width && start_pos.height == final_pos.height);
content.fadeTo(currentOpts.changeFade, 0.3, function() {
var finish_resizing = function() {
content.html( tmp.contents() ).fadeTo(currentOpts.changeFade, 1, _finish);
};
$.event.trigger('fancybox-change');
content
.empty()
.removeAttr('filter')
.css({
'border-width' : currentOpts.padding,
'width' : final_pos.width - currentOpts.padding * 2,
'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
});
if (equal) {
finish_resizing();
} else {
fx.prop = 0;
$(fx).animate({prop: 1}, {
duration : currentOpts.changeSpeed,
easing : currentOpts.easingChange,
step : _draw,
complete : finish_resizing
});
}
});
return;
}
wrap.removeAttr("style");
content.css('border-width', currentOpts.padding);
if (currentOpts.transitionIn == 'elastic') {
start_pos = _get_zoom_from();
content.html( tmp.contents() );
wrap.show();
if (currentOpts.opacity) {
final_pos.opacity = 0;
}
fx.prop = 0;
$(fx).animate({prop: 1}, {
duration : currentOpts.speedIn,
easing : currentOpts.easingIn,
step : _draw,
complete : _finish
});
return;
}
if (currentOpts.titlePosition == 'inside' && titleHeight > 0) {
title.show();
}
content
.css({
'width' : final_pos.width - currentOpts.padding * 2,
'height' : selectedOpts.autoDimensions ? 'auto' : final_pos.height - titleHeight - currentOpts.padding * 2
})
.html( tmp.contents() );
wrap
.css(final_pos)
.fadeIn( currentOpts.transitionIn == 'none' ? 0 : currentOpts.speedIn, _finish );
},
_format_title = function(title) {
if (title && title.length) {
if (currentOpts.titlePosition == 'float') {
return '<table id="fancybox-title-float-wrap" cellpadding="0" cellspacing="0"><tr><td id="fancybox-title-float-left"></td><td id="fancybox-title-float-main">' + title + '</td><td id="fancybox-title-float-right"></td></tr></table>';
}
return '<div id="fancybox-title-' + currentOpts.titlePosition + '">' + title + '</div>';
}
return false;
},
_process_title = function() {
titleStr = currentOpts.title || '';
titleHeight = 0;
title
.empty()
.removeAttr('style')
.removeClass();
if (currentOpts.titleShow === false) {
title.hide();
return;
}
titleStr = $.isFunction(currentOpts.titleFormat) ? currentOpts.titleFormat(titleStr, currentArray, currentIndex, currentOpts) : _format_title(titleStr);
if (!titleStr || titleStr === '') {
title.hide();
return;
}
title
.addClass('fancybox-title-' + currentOpts.titlePosition)
.html( titleStr )
.appendTo( 'body' )
.show();
switch (currentOpts.titlePosition) {
case 'inside':
title
.css({
'width' : final_pos.width - (currentOpts.padding * 2),
'marginLeft' : currentOpts.padding,
'marginRight' : currentOpts.padding
});
titleHeight = title.outerHeight(true);
title.appendTo( outer );
final_pos.height += titleHeight;
break;
case 'over':
title
.css({
'marginLeft' : currentOpts.padding,
'width' : final_pos.width - (currentOpts.padding * 2),
'bottom' : currentOpts.padding
})
.appendTo( outer );
break;
case 'float':
title
.css('left', parseInt((title.width() - final_pos.width - 40)/ 2, 10) * -1)
.appendTo( wrap );
break;
default:
title
.css({
'width' : final_pos.width - (currentOpts.padding * 2),
'paddingLeft' : currentOpts.padding,
'paddingRight' : currentOpts.padding
})
.appendTo( wrap );
break;
}
title.hide();
},
_set_navigation = function() {
if (currentOpts.enableEscapeButton || currentOpts.enableKeyboardNav) {
$(document).bind('keydown.fb', function(e) {
if (e.keyCode == 27 && currentOpts.enableEscapeButton) {
e.preventDefault();
$.fancybox.close();
} else if ((e.keyCode == 37 || e.keyCode == 39) && currentOpts.enableKeyboardNav && e.target.tagName !== 'INPUT' && e.target.tagName !== 'TEXTAREA' && e.target.tagName !== 'SELECT') {
e.preventDefault();
$.fancybox[ e.keyCode == 37 ? 'prev' : 'next']();
}
});
}
if (!currentOpts.showNavArrows) {
nav_left.hide();
nav_right.hide();
return;
}
if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex !== 0) {
nav_left.show();
}
if ((currentOpts.cyclic && currentArray.length > 1) || currentIndex != (currentArray.length -1)) {
nav_right.show();
}
},
_finish = function () {
if (!$.support.opacity) {
content.get(0).style.removeAttribute('filter');
wrap.get(0).style.removeAttribute('filter');
}
if (selectedOpts.autoDimensions) {
content.css('height', 'auto');
}
wrap.css('height', 'auto');
if (titleStr && titleStr.length) {
title.show();
}
if (currentOpts.showCloseButton) {
close.show();
}
_set_navigation();
if (currentOpts.hideOnContentClick) {
content.bind('click', $.fancybox.close);
}
if (currentOpts.hideOnOverlayClick) {
overlay.bind('click', $.fancybox.close);
}
$(window).bind("resize.fb", $.fancybox.resize);
if (currentOpts.centerOnScroll) {
$(window).bind("scroll.fb", $.fancybox.center);
}
if (currentOpts.type == 'iframe') {
$('<iframe id="fancybox-frame" name="fancybox-frame' + new Date().getTime() + '" frameborder="0" hspace="0" ' + ($.browser.msie ? 'allowtransparency="true""' : '') + ' scrolling="' + selectedOpts.scrolling + '" src="' + currentOpts.href + '"></iframe>').appendTo(content);
}
wrap.show();
busy = false;
$.fancybox.center();
currentOpts.onComplete(currentArray, currentIndex, currentOpts);
_preload_images();
},
_preload_images = function() {
var href,
objNext;
if ((currentArray.length -1) > currentIndex) {
href = currentArray[ currentIndex + 1 ].href;
if (typeof href !== 'undefined' && href.match(imgRegExp)) {
objNext = new Image();
objNext.src = href;
}
}
if (currentIndex > 0) {
href = currentArray[ currentIndex - 1 ].href;
if (typeof href !== 'undefined' && href.match(imgRegExp)) {
objNext = new Image();
objNext.src = href;
}
}
},
_draw = function(pos) {
var dim = {
width : parseInt(start_pos.width + (final_pos.width - start_pos.width) * pos, 10),
height : parseInt(start_pos.height + (final_pos.height - start_pos.height) * pos, 10),
top : parseInt(start_pos.top + (final_pos.top - start_pos.top) * pos, 10),
left : parseInt(start_pos.left + (final_pos.left - start_pos.left) * pos, 10)
};
if (typeof final_pos.opacity !== 'undefined') {
dim.opacity = pos < 0.5 ? 0.5 : pos;
}
wrap.css(dim);
content.css({
'width' : dim.width - currentOpts.padding * 2,
'height' : dim.height - (titleHeight * pos) - currentOpts.padding * 2
});
},
_get_viewport = function() {
return [
$(window).width() - (currentOpts.margin * 2),
$(window).height() - (currentOpts.margin * 2),
$(document).scrollLeft() + currentOpts.margin,
$(document).scrollTop() + currentOpts.margin
];
},
_get_zoom_to = function () {
var view = _get_viewport(),
to = {},
resize = currentOpts.autoScale,
double_padding = currentOpts.padding * 2,
ratio;
if (currentOpts.width.toString().indexOf('%') > -1) {
to.width = parseInt((view[0] * parseFloat(currentOpts.width)) / 100, 10);
} else {
to.width = currentOpts.width + double_padding;
}
if (currentOpts.height.toString().indexOf('%') > -1) {
to.height = parseInt((view[1] * parseFloat(currentOpts.height)) / 100, 10);
} else {
to.height = currentOpts.height + double_padding;
}
if (resize && (to.width > view[0] || to.height > view[1])) {
if (selectedOpts.type == 'image' || selectedOpts.type == 'swf') {
ratio = (currentOpts.width ) / (currentOpts.height );
if ((to.width ) > view[0]) {
to.width = view[0];
to.height = parseInt(((to.width - double_padding) / ratio) + double_padding, 10);
}
if ((to.height) > view[1]) {
to.height = view[1];
to.width = parseInt(((to.height - double_padding) * ratio) + double_padding, 10);
}
} else {
to.width = Math.min(to.width, view[0]);
to.height = Math.min(to.height, view[1]);
}
}
to.top = parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - to.height - 40) * 0.5)), 10);
to.left = parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - to.width - 40) * 0.5)), 10);
return to;
},
_get_obj_pos = function(obj) {
var pos = obj.offset();
pos.top += parseInt( obj.css('paddingTop'), 10 ) || 0;
pos.left += parseInt( obj.css('paddingLeft'), 10 ) || 0;
pos.top += parseInt( obj.css('border-top-width'), 10 ) || 0;
pos.left += parseInt( obj.css('border-left-width'), 10 ) || 0;
pos.width = obj.width();
pos.height = obj.height();
return pos;
},
_get_zoom_from = function() {
var orig = selectedOpts.orig ? $(selectedOpts.orig) : false,
from = {},
pos,
view;
if (orig && orig.length) {
pos = _get_obj_pos(orig);
from = {
width : pos.width + (currentOpts.padding * 2),
height : pos.height + (currentOpts.padding * 2),
top : pos.top - currentOpts.padding - 20,
left : pos.left - currentOpts.padding - 20
};
} else {
view = _get_viewport();
from = {
width : currentOpts.padding * 2,
height : currentOpts.padding * 2,
top : parseInt(view[3] + view[1] * 0.5, 10),
left : parseInt(view[2] + view[0] * 0.5, 10)
};
}
return from;
},
_animate_loading = function() {
if (!loading.is(':visible')){
clearInterval(loadingTimer);
return;
}
$('div', loading).css('top', (loadingFrame * -40) + 'px');
loadingFrame = (loadingFrame + 1) % 12;
};
/*
* Public methods
*/
$.fn.fancybox = function(options) {
if (!$(this).length) {
return this;
}
$(this)
.data('fancybox', $.extend({}, options, ($.metadata ? $(this).metadata() : {})))
.unbind('click.fb')
.bind('click.fb', function(e) {
e.preventDefault();
if (busy) {
return;
}
busy = true;
$(this).blur();
selectedArray = [];
selectedIndex = 0;
var rel = $(this).attr('rel') || '';
if (!rel || rel == '' || rel === 'nofollow') {
selectedArray.push(this);
} else {
selectedArray = $("a[rel=" + rel + "], area[rel=" + rel + "]");
selectedIndex = selectedArray.index( this );
}
_start();
return;
});
return this;
};
$.fancybox = function(obj) {
var opts;
if (busy) {
return;
}
busy = true;
opts = typeof arguments[1] !== 'undefined' ? arguments[1] : {};
selectedArray = [];
selectedIndex = parseInt(opts.index, 10) || 0;
if ($.isArray(obj)) {
for (var i = 0, j = obj.length; i < j; i++) {
if (typeof obj[i] == 'object') {
$(obj[i]).data('fancybox', $.extend({}, opts, obj[i]));
} else {
obj[i] = $({}).data('fancybox', $.extend({content : obj[i]}, opts));
}
}
selectedArray = jQuery.merge(selectedArray, obj);
} else {
if (typeof obj == 'object') {
$(obj).data('fancybox', $.extend({}, opts, obj));
} else {
obj = $({}).data('fancybox', $.extend({content : obj}, opts));
}
selectedArray.push(obj);
}
if (selectedIndex > selectedArray.length || selectedIndex < 0) {
selectedIndex = 0;
}
_start();
};
$.fancybox.showActivity = function() {
clearInterval(loadingTimer);
loading.show();
loadingTimer = setInterval(_animate_loading, 66);
};
$.fancybox.hideActivity = function() {
loading.hide();
};
$.fancybox.next = function() {
return $.fancybox.pos( currentIndex + 1);
};
$.fancybox.prev = function() {
return $.fancybox.pos( currentIndex - 1);
};
$.fancybox.pos = function(pos) {
if (busy) {
return;
}
pos = parseInt(pos);
selectedArray = currentArray;
if (pos > -1 && pos < currentArray.length) {
selectedIndex = pos;
_start();
} else if (currentOpts.cyclic && currentArray.length > 1) {
selectedIndex = pos >= currentArray.length ? 0 : currentArray.length - 1;
_start();
}
return;
};
$.fancybox.cancel = function() {
if (busy) {
return;
}
busy = true;
$.event.trigger('fancybox-cancel');
_abort();
selectedOpts.onCancel(selectedArray, selectedIndex, selectedOpts);
busy = false;
};
// Note: within an iframe use - parent.$.fancybox.close();
$.fancybox.close = function() {
if (busy || wrap.is(':hidden')) {
return;
}
busy = true;
if (currentOpts && false === currentOpts.onCleanup(currentArray, currentIndex, currentOpts)) {
busy = false;
return;
}
_abort();
$(close.add( nav_left ).add( nav_right )).hide();
$(content.add( overlay )).unbind();
$(window).unbind("resize.fb scroll.fb");
$(document).unbind('keydown.fb');
content.find('iframe').attr('src', isIE6 && /^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank');
if (currentOpts.titlePosition !== 'inside') {
title.empty();
}
wrap.stop();
function _cleanup() {
overlay.fadeOut('fast');
title.empty().hide();
wrap.hide();
$.event.trigger('fancybox-cleanup');
content.empty();
currentOpts.onClosed(currentArray, currentIndex, currentOpts);
currentArray = selectedOpts = [];
currentIndex = selectedIndex = 0;
currentOpts = selectedOpts = {};
busy = false;
}
if (currentOpts.transitionOut == 'elastic') {
start_pos = _get_zoom_from();
var pos = wrap.position();
final_pos = {
top : pos.top ,
left : pos.left,
width : wrap.width(),
height : wrap.height()
};
if (currentOpts.opacity) {
final_pos.opacity = 1;
}
title.empty().hide();
fx.prop = 1;
$(fx).animate({ prop: 0 }, {
duration : currentOpts.speedOut,
easing : currentOpts.easingOut,
step : _draw,
complete : _cleanup
});
} else {
wrap.fadeOut( currentOpts.transitionOut == 'none' ? 0 : currentOpts.speedOut, _cleanup);
}
};
$.fancybox.resize = function() {
if (overlay.is(':visible')) {
overlay.css('height', $(document).height());
}
$.fancybox.center(true);
};
$.fancybox.center = function() {
var view, align;
if (busy) {
return;
}
align = arguments[0] === true ? 1 : 0;
view = _get_viewport();
if (!align && (wrap.width() > view[0] || wrap.height() > view[1])) {
return;
}
wrap
.stop()
.animate({
'top' : parseInt(Math.max(view[3] - 20, view[3] + ((view[1] - content.height() - 40) * 0.5) - currentOpts.padding)),
'left' : parseInt(Math.max(view[2] - 20, view[2] + ((view[0] - content.width() - 40) * 0.5) - currentOpts.padding))
}, typeof arguments[0] == 'number' ? arguments[0] : 200);
};
$.fancybox.init = function() {
if ($("#fancybox-wrap").length) {
return;
}
$('body').append(
tmp = $('<div id="fancybox-tmp"></div>'),
loading = $('<div id="fancybox-loading"><div></div></div>'),
overlay = $('<div id="fancybox-overlay"></div>'),
wrap = $('<div id="fancybox-wrap"></div>')
);
outer = $('<div id="fancybox-outer"></div>')
.append('<div class="fancybox-bg" id="fancybox-bg-n"></div><div class="fancybox-bg" id="fancybox-bg-ne"></div><div class="fancybox-bg" id="fancybox-bg-e"></div><div class="fancybox-bg" id="fancybox-bg-se"></div><div class="fancybox-bg" id="fancybox-bg-s"></div><div class="fancybox-bg" id="fancybox-bg-sw"></div><div class="fancybox-bg" id="fancybox-bg-w"></div><div class="fancybox-bg" id="fancybox-bg-nw"></div>')
.appendTo( wrap );
outer.append(
content = $('<div id="fancybox-content"></div>'),
close = $('<a id="fancybox-close"></a>'),
title = $('<div id="fancybox-title"></div>'),
nav_left = $('<a href="javascript:;" id="fancybox-left"><span class="fancy-ico" id="fancybox-left-ico"></span></a>'),
nav_right = $('<a href="javascript:;" id="fancybox-right"><span class="fancy-ico" id="fancybox-right-ico"></span></a>')
);
close.click($.fancybox.close);
loading.click($.fancybox.cancel);
nav_left.click(function(e) {
e.preventDefault();
$.fancybox.prev();
});
nav_right.click(function(e) {
e.preventDefault();
$.fancybox.next();
});
if ($.fn.mousewheel) {
wrap.bind('mousewheel.fb', function(e, delta) {
if (busy) {
e.preventDefault();
} else if ($(e.target).get(0).clientHeight == 0 || $(e.target).get(0).scrollHeight === $(e.target).get(0).clientHeight) {
e.preventDefault();
$.fancybox[ delta > 0 ? 'prev' : 'next']();
}
});
}
if (!$.support.opacity) {
wrap.addClass('fancybox-ie');
}
if (isIE6) {
loading.addClass('fancybox-ie6');
wrap.addClass('fancybox-ie6');
$('<iframe id="fancybox-hide-sel-frame" src="' + (/^https/i.test(window.location.href || '') ? 'javascript:void(false)' : 'about:blank' ) + '" scrolling="no" border="0" frameborder="0" tabindex="-1"></iframe>').prependTo(outer);
}
};
$.fn.fancybox.defaults = {
padding : 10,
margin : 40,
opacity : false,
modal : false,
cyclic : false,
scrolling : 'auto', // 'auto', 'yes' or 'no'
width : 560,
height : 340,
autoScale : true,
autoDimensions : true,
centerOnScroll : false,
ajax : {},
swf : { wmode: 'transparent' },
hideOnOverlayClick : true,
hideOnContentClick : false,
overlayShow : true,
overlayOpacity : 0.7,
overlayColor : '#777',
titleShow : true,
titlePosition : 'float', // 'float', 'outside', 'inside' or 'over'
titleFormat : null,
titleFromAlt : false,
transitionIn : 'fade', // 'elastic', 'fade' or 'none'
transitionOut : 'fade', // 'elastic', 'fade' or 'none'
speedIn : 300,
speedOut : 300,
changeSpeed : 300,
changeFade : 'fast',
easingIn : 'swing',
easingOut : 'swing',
showCloseButton : true,
showNavArrows : true,
enableEscapeButton : true,
enableKeyboardNav : true,
onStart : function(){},
onCancel : function(){},
onComplete : function(){},
onCleanup : function(){},
onClosed : function(){},
onError : function(){}
};
$(document).ready(function() {
$.fancybox.init();
});
})(jQuery); | JavaScript |
/**
* noty - jQuery Notification Plugin v2.0.3
* Contributors: https://github.com/needim/noty/graphs/contributors
*
* Examples and Documentation - http://needim.github.com/noty/
*
* Licensed under the MIT licenses:
* http://www.opensource.org/licenses/mit-license.php
*
**/
if (typeof Object.create !== 'function') {
Object.create = function (o) {
function F() {};
F.prototype = o;
return new F();
};
};
;(function($) {
var NotyObject = {
init: function(options) {
// Mix in the passed in options with the default options
this.options = $.extend({}, $.noty.defaults, options);
this.options.layout = (this.options.custom) ? $.noty.layouts['inline'] : $.noty.layouts[this.options.layout];
this.options.theme = $.noty.themes[this.options.theme];
delete options.layout, delete options.theme;
this.options = $.extend({}, this.options, this.options.layout.options);
this.options.id = 'noty_' + (new Date().getTime() * Math.floor(Math.random()* 1000000));
this.options = $.extend({}, this.options, options);
// Build the noty dom initial structure
this._build();
// return this so we can chain/use the bridge with less code.
return this;
}, // end init
_build: function() {
// Generating noty bar
var $bar = $('<div class="noty_bar"/>').attr('id', this.options.id);
$bar.append(this.options.template).find('.noty_text').html(this.options.text);
this.$bar = (this.options.layout.parent.object !== null) ? $(this.options.layout.parent.object).css(this.options.layout.parent.css).append($bar) : $bar;
// Set buttons if available
if (this.options.buttons) {
// If we have button disable closeWith & timeout options
this.options.closeWith = [], this.options.timeout = false;
var $buttons = $('<div/>').addClass('noty_buttons');
(this.options.layout.parent.object !== null) ? this.$bar.find('.noty_bar').append($buttons) : this.$bar.append($buttons);
var self = this;
$.each(this.options.buttons, function(i, button) {
var $button = $('<button/>').addClass((button.addClass) ? button.addClass : 'gray').html(button.text)
.appendTo(self.$bar.find('.noty_buttons'))
.bind('click', function(e) { if ($.isFunction(button.onClick)) { button.onClick.call($button, self); } });
});
}
// For easy access
this.$message = this.$bar.find('.noty_message');
this.$closeButton = this.$bar.find('.noty_close');
this.$buttons = this.$bar.find('.noty_buttons');
$.noty.store[this.options.id] = this; // store noty for api
}, // end _build
show: function() {
var self = this;
$(self.options.layout.container.selector).append(self.$bar);
self.options.theme.style.apply(self);
($.type(self.options.layout.css) === 'function') ? this.options.layout.css.apply(self.$bar) : self.$bar.css(this.options.layout.css || {});
self.$bar.addClass(self.options.layout.addClass);
self.options.layout.container.style.apply($(self.options.layout.container.selector));
self.options.theme.callback.onShow.apply(this);
if ($.inArray('click', self.options.closeWith) > -1)
self.$bar.css('cursor', 'pointer').one('click', function() { self.close(); });
if ($.inArray('hover', self.options.closeWith) > -1)
self.$bar.one('mouseenter', function() { self.close(); });
if ($.inArray('button', self.options.closeWith) > -1)
self.$closeButton.one('click', function() { self.close(); });
if ($.inArray('button', self.options.closeWith) == -1)
self.$closeButton.remove();
if (self.options.callback.onShow)
self.options.callback.onShow.apply(self);
self.$bar.animate(
self.options.animation.open,
self.options.animation.speed,
self.options.animation.easing,
function() {
if (self.options.callback.afterShow) self.options.callback.afterShow.apply(self);
self.shown = true;
});
// If noty is have a timeout option
if (self.options.timeout)
self.$bar.delay(self.options.timeout).promise().done(function() { self.close(); });
return this;
}, // end show
close: function() {
if (this.closed) return;
var self = this;
if (!this.shown) { // If we are still waiting in the queue just delete from queue
$.each($.noty.queue, function(i, n) {
if (n.options.id == self.options.id) {
$.noty.queue.splice(i, 1);
}
});
return;
}
self.$bar.addClass('i-am-closing-now');
if (self.options.callback.onClose) { self.options.callback.onClose.apply(self); }
self.$bar.clearQueue().stop().animate(
self.options.animation.close,
self.options.animation.speed,
self.options.animation.easing,
function() { if (self.options.callback.afterClose) self.options.callback.afterClose.apply(self); })
.promise().done(function() {
// Modal Cleaning
if (self.options.modal) {
$.notyRenderer.setModalCount(-1);
if ($.notyRenderer.getModalCount() == 0) $('.noty_modal').fadeOut('fast', function() { $(this).remove(); });
}
// Layout Cleaning
$.notyRenderer.setLayoutCountFor(self, -1);
if ($.notyRenderer.getLayoutCountFor(self) == 0) $(self.options.layout.container.selector).remove();
if(self.$bar == null)
return;
self.$bar.remove();
self.$bar = null;
self.closed = true;
delete $.noty.store[self.options.id]; // deleting noty from store
if (!self.options.dismissQueue) {
// Queue render
$.noty.ontap = true;
$.notyRenderer.render();
}
});
}, // end close
setText: function(text) {
if (!this.closed) {
this.options.text = text;
this.$bar.find('.noty_text').html(text);
}
return this;
},
setType: function(type) {
if (!this.closed) {
this.options.type = type;
this.options.theme.style.apply(this);
this.options.theme.callback.onShow.apply(this);
}
return this;
},
closed: false,
shown: false
}; // end NotyObject
$.notyRenderer = {};
$.notyRenderer.init = function(options) {
// Renderer creates a new noty
var notification = Object.create(NotyObject).init(options);
(notification.options.force) ? $.noty.queue.unshift(notification) : $.noty.queue.push(notification);
$.notyRenderer.render();
return ($.noty.returns == 'object') ? notification : notification.options.id;
};
$.notyRenderer.render = function() {
var instance = $.noty.queue[0];
if ($.type(instance) === 'object') {
if (instance.options.dismissQueue) {
$.notyRenderer.show($.noty.queue.shift());
} else {
if ($.noty.ontap) {
$.notyRenderer.show($.noty.queue.shift());
$.noty.ontap = false;
}
}
} else {
$.noty.ontap = true; // Queue is over
}
};
$.notyRenderer.show = function(notification) {
if (notification.options.modal) {
$.notyRenderer.createModalFor(notification);
$.notyRenderer.setModalCount(+1);
}
// Where is the container?
if ($(notification.options.layout.container.selector).length == 0) {
if (notification.options.custom) {
notification.options.custom.append($(notification.options.layout.container.object).addClass('i-am-new'));
} else {
$('body').append($(notification.options.layout.container.object).addClass('i-am-new'));
}
} else {
$(notification.options.layout.container.selector).removeClass('i-am-new');
}
$.notyRenderer.setLayoutCountFor(notification, +1);
notification.show();
};
$.notyRenderer.createModalFor = function(notification) {
if ($('.noty_modal').length == 0)
$('<div/>').addClass('noty_modal').data('noty_modal_count', 0).css(notification.options.theme.modal.css).prependTo($('body')).fadeIn('fast');
};
$.notyRenderer.getLayoutCountFor = function(notification) {
return $(notification.options.layout.container.selector).data('noty_layout_count') || 0;
};
$.notyRenderer.setLayoutCountFor = function(notification, arg) {
return $(notification.options.layout.container.selector).data('noty_layout_count', $.notyRenderer.getLayoutCountFor(notification) + arg);
};
$.notyRenderer.getModalCount = function() {
return $('.noty_modal').data('noty_modal_count') || 0;
};
$.notyRenderer.setModalCount = function(arg) {
return $('.noty_modal').data('noty_modal_count', $.notyRenderer.getModalCount() + arg);
};
// This is for custom container
$.fn.noty = function(options) {
options.custom = $(this);
return $.notyRenderer.init(options);
};
$.noty = {};
$.noty.queue = [];
$.noty.ontap = true;
$.noty.layouts = {};
$.noty.themes = {};
$.noty.returns = 'object';
$.noty.store = {};
$.noty.get = function(id) {
return $.noty.store.hasOwnProperty(id) ? $.noty.store[id] : false;
};
$.noty.close = function(id) {
return $.noty.get(id) ? $.noty.get(id).close() : false;
};
$.noty.setText = function(id, text) {
return $.noty.get(id) ? $.noty.get(id).setText(text) : false;
};
$.noty.setType = function(id, type) {
return $.noty.get(id) ? $.noty.get(id).setType(type) : false;
};
$.noty.clearQueue = function() {
$.noty.queue = [];
};
$.noty.closeAll = function() {
$.noty.clearQueue();
$.each($.noty.store, function(id, noty) {
noty.close();
});
};
var windowAlert = window.alert;
$.noty.consumeAlert = function(options) {
window.alert = function(text) {
if (options)
options.text = text;
else
options = {text:text};
$.notyRenderer.init(options);
};
};
$.noty.stopConsumeAlert = function(){
window.alert = windowAlert;
};
$.noty.defaults = {
layout: 'top',
theme: 'default',
type: 'alert',
text: '',
dismissQueue: true,
template: '<div class="noty_message" style="padding:0 !important"><span class="noty_text" style="background:#dedede !important"></span><div class="noty_close"></div></div>',
animation: {
open: {height: 'toggle'},
close: {height: 'toggle'},
easing: 'swing',
speed: 500
},
timeout: 2200,
force: false,
modal: false,
closeWith: ['click'],
callback: {
onShow: function() {},
afterShow: function() {},
onClose: function() {},
afterClose: function() {}
},
buttons: false
};
$(window).resize(function() {
$.each($.noty.layouts, function(index, layout) {
layout.container.style.apply($(layout.container.selector));
});
});
})(jQuery);
// Helpers
function noty(options) {
// This is for BC - Will be deleted on v2.2.0
var using_old = 0
, old_to_new = {
'animateOpen': 'animation.open',
'animateClose': 'animation.close',
'easing': 'animation.easing',
'speed': 'animation.speed',
'onShow': 'callback.onShow',
'onShown': 'callback.afterShow',
'onClose': 'callback.onClose',
'onClosed': 'callback.afterClose'
}
jQuery.each(options, function(key, value) {
if (old_to_new[key]) {
using_old++;
var _new = old_to_new[key].split('.');
if (!options[_new[0]]) options[_new[0]] = {};
options[_new[0]][_new[1]] = (value) ? value : function() {};
delete options[key];
}
});
if (!options.closeWith) {
options.closeWith = jQuery.noty.defaults.closeWith;
}
if (options.hasOwnProperty('closeButton')) {
using_old++;
if (options.closeButton) options.closeWith.push('button');
delete options.closeButton;
}
if (options.hasOwnProperty('closeOnSelfClick')) {
using_old++;
if (options.closeOnSelfClick) options.closeWith.push('click');
delete options.closeOnSelfClick;
}
if (options.hasOwnProperty('closeOnSelfOver')) {
using_old++;
if (options.closeOnSelfOver) options.closeWith.push('hover');
delete options.closeOnSelfOver;
}
if (options.hasOwnProperty('custom')) {
using_old++;
if (options.custom.container != 'null') options.custom = options.custom.container;
}
if (options.hasOwnProperty('cssPrefix')) {
using_old++;
delete options.cssPrefix;
}
if (options.theme == 'noty_theme_default') {
using_old++;
options.theme = 'default';
}
if (!options.hasOwnProperty('dismissQueue')) {
if (options.layout == 'topLeft'
|| options.layout == 'topRight'
|| options.layout == 'bottomLeft'
|| options.layout == 'bottomRight') {
options.dismissQueue = true;
} else {
options.dismissQueue = false;
}
}
if (options.buttons) {
jQuery.each(options.buttons, function(i, button) {
if (button.click) {
using_old++;
button.onClick = button.click;
delete button.click;
}
if (button.type) {
using_old++;
button.addClass = button.type;
delete button.type;
}
});
}
if (using_old) console.warn('You are using noty v2 with v1.x.x options. @deprecated until v2.2.0 - Please update your options.');
// console.log(options);
// End of the BC
return jQuery.notyRenderer.init(options);
}
/** Jquery noty top */
;(function($) {
$.noty.layouts.top = {
name: 'top',
options: {},
container: {
object: '<ul id="noty_top_layout_container" />',
selector: 'ul#noty_top_layout_container',
style: function() {
$(this).css({
top: 0,
left: '5%',
position: 'fixed',
width: '90%',
height: 'auto',
margin: 0,
padding: 0,
listStyleType: 'none',
zIndex: 9999999
});
}
},
parent: {
object: '<li />',
selector: 'li',
css: {}
},
css: {
display: 'none'
},
addClass: ''
};
})(jQuery);
/** Jquery noty default theme */
;(function($) {
$.noty.themes['default'] = {
name: 'default',
helpers: {
borderFix: function() {
if (this.options.dismissQueue) {
var selector = this.options.layout.container.selector + ' ' + this.options.layout.parent.selector;
switch (this.options.layout.name) {
case 'top':
$(selector).css({borderRadius: '0px 0px 0px 0px'});
$(selector).last().css({borderRadius: '0px 0px 5px 5px'}); break;
case 'topCenter': case 'topLeft': case 'topRight':
case 'bottomCenter': case 'bottomLeft': case 'bottomRight':
case 'center': case 'centerLeft': case 'centerRight': case 'inline':
$(selector).css({borderRadius: '0px 0px 0px 0px'});
$(selector).first().css({'border-top-left-radius': '5px', 'border-top-right-radius': '5px'});
$(selector).last().css({'border-bottom-left-radius': '5px', 'border-bottom-right-radius': '5px'}); break;
case 'bottom':
$(selector).css({borderRadius: '0px 0px 0px 0px'});
$(selector).first().css({borderRadius: '5px 5px 0px 0px'}); break;
default: break;
}
}
}
},
modal: {
css: {
position: 'fixed',
width: '100%',
height: '100%',
backgroundColor: '#000',
zIndex: 10000,
opacity: 0.6,
display: 'none',
left: 0,
top: 0,
}
},
style: function() {
this.$bar.css({
overflow: 'hidden',
background: "#dedede"
});
this.$message.css({
fontSize: '13px',
lineHeight: '16px',
textAlign: 'center',
padding: '8px 10px 9px',
width: 'auto',
position: 'relative',
opacity:'.8'
});
this.$closeButton.css({
position: 'absolute',
top: 4, right: 4,
width: 10, height: 10,
background: "#dedede",
display: 'none',
cursor: 'pointer',
opacity:'.8'
});
this.$buttons.css({
padding: 5,
textAlign: 'right',
borderTop: '1px solid #ccc',
backgroundColor: '#fff',
});
this.$buttons.find('button').css({
marginLeft: 5
});
this.$buttons.find('button:first').css({
marginLeft: 0
});
this.$bar.bind({
mouseenter: function() { $(this).find('.noty_close').fadeIn(); },
mouseleave: function() { $(this).find('.noty_close').fadeOut(); }
});
switch (this.options.layout.name) {
case 'top':
this.$bar.css({
borderRadius: '0px 0px 5px 5px',
borderBottom: '2px solid #eee',
borderLeft: '2px solid #eee',
borderRight: '2px solid #eee',
boxShadow: "0 2px 4px rgba(0, 0, 0, 0.1)"
});
break;
case 'topCenter': case 'center': case 'bottomCenter': case 'inline':
this.$bar.css({
borderRadius: '5px',
border: '1px solid #eee',
boxShadow: "0 2px 4px rgba(0, 0, 0, 0.1)"
});
this.$message.css({fontSize: '13px', textAlign: 'center'});
break;
case 'topLeft': case 'topRight':
case 'bottomLeft': case 'bottomRight':
case 'centerLeft': case 'centerRight':
this.$bar.css({
borderRadius: '5px',
border: '1px solid #eee',
boxShadow: "0 2px 4px rgba(0, 0, 0, 0.1)"
});
this.$message.css({fontSize: '13px', textAlign: 'left'});
break;
case 'bottom':
this.$bar.css({
borderRadius: '5px 5px 0px 0px',
borderTop: '2px solid #eee',
borderLeft: '2px solid #eee',
borderRight: '2px solid #eee',
boxShadow: "0 -2px 4px rgba(0, 0, 0, 0.1)"
});
break;
default:
this.$bar.css({
border: '2px solid #eee',
boxShadow: "0 2px 4px rgba(0, 0, 0, 0.1)"
});
break;
}
switch (this.options.type) {
case 'alert': case 'notification':
this.$bar.css({backgroundColor: '#FFF', borderColor: '#CCC', color: '#444'}); break;
case 'warning':
this.$bar.css({backgroundColor: '#FFEAA8', borderColor: '#FFC237', color: '#826200'});
this.$buttons.css({borderTop: '1px solid #FFC237'}); break;
case 'error':
this.$bar.css({backgroundColor: 'red', borderColor: 'darkred', color: '#FFF'});
this.$message.css({fontWeight: 'bold'});
this.$buttons.css({borderTop: '1px solid darkred'}); break;
case 'information':
this.$bar.css({backgroundColor: '#57B7E2', borderColor: '#0B90C4', color: '#FFF'});
this.$buttons.css({borderTop: '1px solid #0B90C4'}); break;
case 'success':
this.$bar.css({backgroundColor: '#dedede', borderColor: '#dedede', color: 'darkgreen'});
this.$buttons.css({borderTop: '1px solid #50C24E'});break;
default:
this.$bar.css({backgroundColor: '#FFF', borderColor: '#CCC', color: '#444'}); break;
}
},
callback: {
onShow: function() { $.noty.themes['default'].helpers.borderFix.apply(this); },
onClose: function() { $.noty.themes['default'].helpers.borderFix.apply(this); }
}
};
})(jQuery);
| JavaScript |
/**
* @author trixta
* @version 1.2
*/
(function($){
var mwheelI = {
pos: [-260, -260]
},
minDif = 3,
doc = document,
root = doc.documentElement,
body = doc.body,
longDelay, shortDelay
;
function unsetPos(){
if(this === mwheelI.elem){
mwheelI.pos = [-260, -260];
mwheelI.elem = false;
minDif = 3;
}
}
$.event.special.mwheelIntent = {
setup: function(){
var jElm = $(this).bind('mousewheel', $.event.special.mwheelIntent.handler);
if( this !== doc && this !== root && this !== body ){
jElm.bind('mouseleave', unsetPos);
}
jElm = null;
return true;
},
teardown: function(){
$(this)
.unbind('mousewheel', $.event.special.mwheelIntent.handler)
.unbind('mouseleave', unsetPos)
;
return true;
},
handler: function(e, d){
var pos = [e.clientX, e.clientY];
if( this === mwheelI.elem || Math.abs(mwheelI.pos[0] - pos[0]) > minDif || Math.abs(mwheelI.pos[1] - pos[1]) > minDif ){
mwheelI.elem = this;
mwheelI.pos = pos;
minDif = 250;
clearTimeout(shortDelay);
shortDelay = setTimeout(function(){
minDif = 10;
}, 200);
clearTimeout(longDelay);
longDelay = setTimeout(function(){
minDif = 3;
}, 1500);
e = $.extend({}, e, {type: 'mwheelIntent'});
return ($.event.dispatch || $.event.handle).apply(this, arguments);
}
}
};
$.fn.extend({
mwheelIntent: function(fn) {
return fn ? this.bind("mwheelIntent", fn) : this.trigger("mwheelIntent");
},
unmwheelIntent: function(fn) {
return this.unbind("mwheelIntent", fn);
}
});
$(function(){
body = doc.body;
//assume that document is always scrollable, doesn't hurt if not
$(doc).bind('mwheelIntent.mwheelIntentDefault', $.noop);
});
})(jQuery);
| JavaScript |
/*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
* Licensed under the MIT License (LICENSE.txt).
*
* Version: 3.1.9
*
* Requires: jQuery 1.2.2+
*/
(function (factory) {
if ( typeof define === 'function' && define.amd ) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS style for Browserify
module.exports = factory;
} else {
// Browser globals
factory(jQuery);
}
}(function ($) {
var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
slice = Array.prototype.slice,
nullLowestDeltaTimeout, lowestDelta;
if ( $.event.fixHooks ) {
for ( var i = toFix.length; i; ) {
$.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
}
}
var special = $.event.special.mousewheel = {
version: '3.1.9',
setup: function() {
if ( this.addEventListener ) {
for ( var i = toBind.length; i; ) {
this.addEventListener( toBind[--i], handler, false );
}
} else {
this.onmousewheel = handler;
}
// Store the line height and page height for this particular element
$.data(this, 'mousewheel-line-height', special.getLineHeight(this));
$.data(this, 'mousewheel-page-height', special.getPageHeight(this));
},
teardown: function() {
if ( this.removeEventListener ) {
for ( var i = toBind.length; i; ) {
this.removeEventListener( toBind[--i], handler, false );
}
} else {
this.onmousewheel = null;
}
},
getLineHeight: function(elem) {
return parseInt($(elem)['offsetParent' in $.fn ? 'offsetParent' : 'parent']().css('fontSize'), 10);
},
getPageHeight: function(elem) {
return $(elem).height();
},
settings: {
adjustOldDeltas: true
}
};
$.fn.extend({
mousewheel: function(fn) {
return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');
},
unmousewheel: function(fn) {
return this.unbind('mousewheel', fn);
}
});
function handler(event) {
var orgEvent = event || window.event,
args = slice.call(arguments, 1),
delta = 0,
deltaX = 0,
deltaY = 0,
absDelta = 0;
event = $.event.fix(orgEvent);
event.type = 'mousewheel';
// Old school scrollwheel delta
if ( 'detail' in orgEvent ) { deltaY = orgEvent.detail * -1; }
if ( 'wheelDelta' in orgEvent ) { deltaY = orgEvent.wheelDelta; }
if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY; }
if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
// Firefox < 17 horizontal scrolling related to DOMMouseScroll event
if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
deltaX = deltaY * -1;
deltaY = 0;
}
// Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
delta = deltaY === 0 ? deltaX : deltaY;
// New school wheel delta (wheel event)
if ( 'deltaY' in orgEvent ) {
deltaY = orgEvent.deltaY * -1;
delta = deltaY;
}
if ( 'deltaX' in orgEvent ) {
deltaX = orgEvent.deltaX;
if ( deltaY === 0 ) { delta = deltaX * -1; }
}
// No change actually happened, no reason to go any further
if ( deltaY === 0 && deltaX === 0 ) { return; }
// Need to convert lines and pages to pixels if we aren't already in pixels
// There are three delta modes:
// * deltaMode 0 is by pixels, nothing to do
// * deltaMode 1 is by lines
// * deltaMode 2 is by pages
if ( orgEvent.deltaMode === 1 ) {
var lineHeight = $.data(this, 'mousewheel-line-height');
delta *= lineHeight;
deltaY *= lineHeight;
deltaX *= lineHeight;
} else if ( orgEvent.deltaMode === 2 ) {
var pageHeight = $.data(this, 'mousewheel-page-height');
delta *= pageHeight;
deltaY *= pageHeight;
deltaX *= pageHeight;
}
// Store lowest absolute delta to normalize the delta values
absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
if ( !lowestDelta || absDelta < lowestDelta ) {
lowestDelta = absDelta;
// Adjust older deltas if necessary
if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
lowestDelta /= 40;
}
}
// Adjust older deltas if necessary
if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
// Divide all the things by 40!
delta /= 40;
deltaX /= 40;
deltaY /= 40;
}
// Get a whole, normalized value for the deltas
delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta);
deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
// Add information to the event object
event.deltaX = deltaX;
event.deltaY = deltaY;
event.deltaFactor = lowestDelta;
// Go ahead and set deltaMode to 0 since we converted to pixels
// Although this is a little odd since we overwrite the deltaX/Y
// properties with normalized deltas.
event.deltaMode = 0;
// Add event and delta to the front of the arguments
args.unshift(event, delta, deltaX, deltaY);
// Clearout lowestDelta after sometime to better
// handle multiple device types that give different
// a different lowestDelta
// Ex: trackpad = 3 and mouse wheel = 120
if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
return ($.event.dispatch || $.event.handle).apply(this, args);
}
function nullLowestDelta() {
lowestDelta = null;
}
function shouldAdjustOldDeltas(orgEvent, absDelta) {
// If this is an older event and the delta is divisable by 120,
// then we are assuming that the browser is treating this as an
// older mouse wheel event and that we should divide the deltas
// by 40 to try and get a more usable deltaFactor.
// Side note, this actually impacts the reported scroll distance
// in older browsers and can cause scrolling to be slower than native.
// Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
}
}));
| JavaScript |
var js_libraries = [];
var fnOpenEditForm = function(this_element){
var href_url = this_element.attr("href");
var dialog_height = $(window).height() - 80;
//Close all
$(".ui-dialog-content").dialog("close");
$.ajax({
url: href_url,
data: {
is_ajax: 'true'
},
type: 'post',
dataType: 'json',
beforeSend: function() {
this_element.closest('.flexigrid').addClass('loading-opacity');
},
complete: function(){
this_element.closest('.flexigrid').removeClass('loading-opacity');
},
success: function (data) {
if (typeof CKEDITOR !== 'undefined' && typeof CKEDITOR.instances !== 'undefined') {
$.each(CKEDITOR.instances,function(index){
delete CKEDITOR.instances[index];
});
}
//LazyLoad.loadOnce(data.js_lib_files);
LazyLoad.load(data.js_config_files);
// $.each(data.css_files,function(index,css_file){
// load_css_file(css_file);
// });
//console.log(data);
var cdlg = $("<div/>").html(data.output).addClass('flexigrid-dlg-form '+window.gcConf.subject_cls).dialog({
width: 'auto',
modal: true,
title: gcConf.state + (gcConf.state == 'Add' ? ' New ' : ' ') + gcConf.subject,
height: 'auto',
close: function(){
if($(this_element).attr('invoke_after'))
{
var fn_invoke_after = $(this_element).attr('invoke_after');
if(typeof window[fn_invoke_after] == 'function')
{
window[fn_invoke_after](this_element);
}
}
$(this).remove();
},
open: function(){
var this_dialog = $(this);
//console.log(gcConf);
// console.log(gcConf);
if(typeof window.gcConf.onDialogOpen!='undefined')
{
if( typeof window.gcConf.onDialogOpen == 'function')
{
var frmContainer = $(cdlg).find('.flexigrid.crud-form');
var frmObj = $(cdlg).find('#crudForm');
window.gcConf.onDialogOpen(this,cdlg,frmContainer,frmObj);
}
}
$('#cancel-button').click(function(){
this_dialog.dialog("close");
});
// setTimeout(function(){
// // $(cdlg.find('textarea,input').get(0)).focus();
// // console.log('autofocus');
// var title = cdlg.find('.ftitle').text();
// cdlg.dialog('option','title',title);
// },50);
}
});
}
});
};
var add_edit_button_listener = function () {
//If dialog AJAX forms is turned on from grocery CRUD config
if (dialog_forms) {
//$('.add_button').attr('onclick','');
$('.edit_button,.add_button').unbind('click');
$('.edit_button,.add_button').click(function(){
if($(this).hasClass('add_button'))
window.gcConf.state = 'Add';
else
window.gcConf.state = 'Edit';
fnOpenEditForm($(this));
//console.log(window.gcConf);
return false;
});
}
}
var load_css_file = function(css_file) {
if ($('head').find('link[href="'+css_file+'"]').length == 0) {
$('head').append($('<link/>').attr("type","text/css")
.attr("rel","stylesheet").attr("href",css_file));
}
};
| JavaScript |
function text(){}
function error_alert(title,content)
{
var dlg = $('<div id="ualertdlg"></div>');
var content = $('<div class="content"></div>').append(content);
var closeBtn = $('<button class="btn"><i class="fa fa-times"></i> Close</button>');
dlg.append(content);
dlg.append(closeBtn);
dlg.dialog({
modal:true,
title:title,
width:300,
height:130,
close:function(){
dlg.remove();
}
});
closeBtn.click(function(){dlg.dialog('close')});
$('div[aria-describedby=ualertdlg]').addClass('err-dlg');
};
window.confirm_alert=function(title,content,onConfirm,onCancel){
// console.log('hello')
// var dlg = $('<div id="ualertdlg"></div>');
// dlg.append(content);
// dlg.dialog({
// modal:true,
// title:title,
// width:300,
// height:130,
// close:function(){
// dlg.remove();
// }
// });
// dlg.dialog('option', 'buttons', {
// "Confirm" : function(){
// $(this).dialog("close");
// onConfirm(dlg);
// },
// "Cancel" : function() {
// $(this).dialog("close");
// onCancel(dlg);
// }
// });
// dlg.dialog("open");
// $('div[aria-describedby=ualertdlg]').addClass('err-dlg');
}; | JavaScript |
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* @fileOverview Defines the {@link CKEDITOR.lang} object for the
* Persian language.
*/
/**#@+
@type String
@example
*/
/**
* Contains the dictionary of language entries.
* @namespace
*/
CKEDITOR.lang['fa'] =
{
/**
* The language reading direction. Possible values are "rtl" for
* Right-To-Left languages (like Arabic) and "ltr" for Left-To-Right
* languages (like English).
* @default 'ltr'
*/
dir : 'rtl',
/*
* Screenreader titles. Please note that screenreaders are not always capable
* of reading non-English words. So be careful while translating it.
*/
editorTitle : 'ویرایشگر متن غنی, %1',
editorHelp : 'کلید Alt+0 را برای راهنمایی بفشارید',
// ARIA descriptions.
toolbars : 'نوار ابزار',
editor : 'ویرایشگر متن غنی',
// Toolbar buttons without dialogs.
source : 'منبع',
newPage : 'برگهٴ تازه',
save : 'ذخیره',
preview : 'پیشنمایش',
cut : 'برش',
copy : 'کپی',
paste : 'چسباندن',
print : 'چاپ',
underline : 'زیرخطدار',
bold : 'درشت',
italic : 'خمیده',
selectAll : 'گزینش همه',
removeFormat : 'برداشتن فرمت',
strike : 'میانخط',
subscript : 'زیرنویس',
superscript : 'بالانویس',
horizontalrule : 'گنجاندن خط افقی',
pagebreak : 'گنجاندن شکستگی پایان برگه',
pagebreakAlt : 'شکستن صفحه',
unlink : 'برداشتن پیوند',
undo : 'واچیدن',
redo : 'بازچیدن',
// Common messages and labels.
common :
{
browseServer : 'فهرستنمایی سرور',
url : 'URL',
protocol : 'پروتکل',
upload : 'انتقال به سرور',
uploadSubmit : 'به سرور بفرست',
image : 'تصویر',
flash : 'فلش',
form : 'فرم',
checkbox : 'خانهٴ گزینهای',
radio : 'دکمهٴ رادیویی',
textField : 'فیلد متنی',
textarea : 'ناحیهٴ متنی',
hiddenField : 'فیلد پنهان',
button : 'دکمه',
select : 'فیلد چندگزینهای',
imageButton : 'دکمهٴ تصویری',
notSet : '<تعین نشده>',
id : 'شناسه',
name : 'نام',
langDir : 'جهتنمای زبان',
langDirLtr : 'چپ به راست (LTR)',
langDirRtl : 'راست به چپ (RTL)',
langCode : 'کد زبان',
longDescr : 'URL توصیف طولانی',
cssClass : 'کلاسهای شیوهنامه(Stylesheet)',
advisoryTitle : 'عنوان کمکی',
cssStyle : 'شیوه(style)',
ok : 'پذیرش',
cancel : 'انصراف',
close : 'بستن',
preview : 'پیشنمایش',
generalTab : 'عمومی',
advancedTab : 'پیشرفته',
validateNumberFailed : 'این مقدار یک عدد نیست.',
confirmNewPage : 'هر تغییر ایجاد شدهی ذخیره نشده از بین خواهد رفت. آیا اطمینان دارید که قصد بارگیری صفحه جدیدی را دارید؟',
confirmCancel : 'برخی از گزینهها تغییر کردهاند. آیا واقعا قصد بستن این پنجره را دارید؟',
options : 'گزینهها',
target : 'مسیر',
targetNew : 'پنجره جدید (_blank)',
targetTop : 'بالاترین پنجره (_top)',
targetSelf : 'همان پنجره (_self)',
targetParent : 'پنجره والد (_parent)',
langDirLTR : 'چپ به راست (LTR)',
langDirRTL : 'راست به چپ (RTL)',
styles : 'سبک',
cssClasses : 'کلاسهای شیوهنامه',
width : 'پهنا',
height : 'درازا',
align : 'چینش',
alignLeft : 'چپ',
alignRight : 'راست',
alignCenter : 'وسط',
alignTop : 'بالا',
alignMiddle : 'وسط',
alignBottom : 'پائین',
invalidValue : 'Invalid value.', // MISSING
invalidHeight : 'ارتفاع باید یک عدد باشد.',
invalidWidth : 'پهنا باید یک عدد باشد.',
invalidCssLength : 'عدد تعیین شده برای فیلد "%1" باید یک عدد مثبت با یا بدون یک واحد اندازه گیری CSS معتبر باشد (px, %, in, cm, mm, em, ex, pt, or pc).',
invalidHtmlLength : 'عدد تعیین شده برای فیلد "%1" باید یک عدد مثبت با یا بدون یک واحد اندازه گیری HTML معتبر باشد (px or %).',
invalidInlineStyle : 'عدد تعیین شده برای سبک درونخطی(Inline Style) باید دارای یک یا چند چندتایی با شکلی شبیه "name : value" که باید با یک ","(semi-colons) از هم جدا شوند.',
cssLengthTooltip : 'یک عدد برای یک مقدار بر حسب پیکسل و یا یک عدد با یک واحد CSS معتبر وارد کنید (px, %, in, cm, mm, em, ex, pt, or pc).',
// Put the voice-only part of the label in the span.
unavailable : '%1<span class="cke_accessibility">، غیر قابل دسترس</span>'
},
contextmenu :
{
options : 'گزینههای منوی زمینه'
},
// Special char dialog.
specialChar :
{
toolbar : 'گنجاندن نویسهٴ ویژه',
title : 'گزینش نویسهٴ ویژه',
options : 'گزینههای نویسههای ویژه'
},
// Link dialog.
link :
{
toolbar : 'گنجاندن/ویرایش پیوند',
other : '<سایر>',
menu : 'ویرایش پیوند',
title : 'پیوند',
info : 'اطلاعات پیوند',
target : 'مقصد',
upload : 'انتقال به سرور',
advanced : 'پیشرفته',
type : 'نوع پیوند',
toUrl : 'URL',
toAnchor : 'لنگر در همین صفحه',
toEmail : 'پست الکترونیکی',
targetFrame : '<فریم>',
targetPopup : '<پنجرهٴ پاپاپ>',
targetFrameName : 'نام فریم مقصد',
targetPopupName : 'نام پنجرهٴ پاپاپ',
popupFeatures : 'ویژگیهای پنجرهٴ پاپاپ',
popupResizable : 'قابل تغییر اندازه',
popupStatusBar : 'نوار وضعیت',
popupLocationBar: 'نوار موقعیت',
popupToolbar : 'نوارابزار',
popupMenuBar : 'نوار منو',
popupFullScreen : 'تمامصفحه (IE)',
popupScrollBars : 'میلههای پیمایش',
popupDependent : 'وابسته (Netscape)',
popupLeft : 'موقعیت چپ',
popupTop : 'موقعیت بالا',
id : 'شناسه',
langDir : 'جهتنمای زبان',
langDirLTR : 'چپ به راست (LTR)',
langDirRTL : 'راست به چپ (RTL)',
acccessKey : 'کلید دستیابی',
name : 'نام',
langCode : 'جهتنمای زبان',
tabIndex : 'نمایهٴ دسترسی با برگه',
advisoryTitle : 'عنوان کمکی',
advisoryContentType : 'نوع محتوای کمکی',
cssClasses : 'کلاسهای شیوهنامه(Stylesheet)',
charset : 'نویسهگان منبع پیوند شده',
styles : 'شیوه(style)',
rel : 'وابستگی',
selectAnchor : 'یک لنگر برگزینید',
anchorName : 'با نام لنگر',
anchorId : 'با شناسهٴ المان',
emailAddress : 'نشانی پست الکترونیکی',
emailSubject : 'موضوع پیام',
emailBody : 'متن پیام',
noAnchors : '(در این سند لنگری دردسترس نیست)',
noUrl : 'لطفا URL پیوند را بنویسید',
noEmail : 'لطفا نشانی پست الکترونیکی را بنویسید'
},
// Anchor dialog
anchor :
{
toolbar : 'گنجاندن/ویرایش لنگر',
menu : 'ویژگیهای لنگر',
title : 'ویژگیهای لنگر',
name : 'نام لنگر',
errorName : 'لطفا نام لنگر را بنویسید',
remove : 'حذف لنگر'
},
// List style dialog
list:
{
numberedTitle : 'ویژگیهای فهرست شمارهدار',
bulletedTitle : 'ویژگیهای فهرست گلولهدار',
type : 'نوع',
start : 'شروع',
validateStartNumber :'فهرست شماره شروع باید یک عدد صحیح باشد.',
circle : 'دایره',
disc : 'صفحه گرد',
square : 'چهارگوش',
none : 'هیچ',
notset : '<تنظیم نشده>',
armenian : 'شمارهگذاری ارمنی',
georgian : 'شمارهگذاری گریگورین (an, ban, gan, etc.)',
lowerRoman : 'پانویس رومی (i, ii, iii, iv, v, etc.)',
upperRoman : 'بالانویس رومی (I, II, III, IV, V, etc.)',
lowerAlpha : 'پانویس الفبایی (a, b, c, d, e, etc.)',
upperAlpha : 'بالانویس الفبایی (A, B, C, D, E, etc.)',
lowerGreek : 'پانویس یونانی (alpha, beta, gamma, etc.)',
decimal : 'دهدهی (1, 2, 3, etc.)',
decimalLeadingZero : 'دهدهی همراه با صفر (01, 02, 03, etc.)'
},
// Find And Replace Dialog
findAndReplace :
{
title : 'جستجو و جایگزینی',
find : 'جستجو',
replace : 'جایگزینی',
findWhat : 'چه چیز را مییابید:',
replaceWith : 'جایگزینی با:',
notFoundMsg : 'متن موردنظر یافت نشد.',
findOptions : 'گزینههای جستجو',
matchCase : 'همسانی در بزرگی و کوچکی نویسهها',
matchWord : 'همسانی با واژهٴ کامل',
matchCyclic : 'همسانی با چرخه',
replaceAll : 'جایگزینی همهٴ یافتهها',
replaceSuccessMsg : '%1 رخداد جایگزین شد.'
},
// Table Dialog
table :
{
toolbar : 'جدول',
title : 'ویژگیهای جدول',
menu : 'ویژگیهای جدول',
deleteTable : 'پاک کردن جدول',
rows : 'سطرها',
columns : 'ستونها',
border : 'اندازهٴ لبه',
widthPx : 'پیکسل',
widthPc : 'درصد',
widthUnit : 'واحد پهنا',
cellSpace : 'فاصلهٴ میان سلولها',
cellPad : 'فاصلهٴ پرشده در سلول',
caption : 'عنوان',
summary : 'خلاصه',
headers : 'سرنویسها',
headersNone : 'هیچ',
headersColumn : 'اولین ستون',
headersRow : 'اولین ردیف',
headersBoth : 'هردو',
invalidRows : 'تعداد ردیفها باید یک عدد بزرگتر از 0 باشد.',
invalidCols : 'تعداد ستونها باید یک عدد بزرگتر از 0 باشد.',
invalidBorder : 'مقدار اندازه خطوط باید یک عدد باشد.',
invalidWidth : 'مقدار پهنای جدول باید یک عدد باشد.',
invalidHeight : 'مقدار ارتفاع جدول باید یک عدد باشد.',
invalidCellSpacing : 'مقدار فاصلهگذاری سلول باید یک عدد باشد.',
invalidCellPadding : 'بالشتک سلول باید یک عدد باشد.',
cell :
{
menu : 'سلول',
insertBefore : 'افزودن سلول قبل از',
insertAfter : 'افزودن سلول بعد از',
deleteCell : 'حذف سلولها',
merge : 'ادغام سلولها',
mergeRight : 'ادغام به راست',
mergeDown : 'ادغام به پایین',
splitHorizontal : 'جدا کردن افقی سلول',
splitVertical : 'جدا کردن عمودی سلول',
title : 'ویژگیهای سلول',
cellType : 'نوع سلول',
rowSpan : 'محدوده ردیفها',
colSpan : 'محدوده ستونها',
wordWrap : 'شکستن کلمه',
hAlign : 'چینش افقی',
vAlign : 'چینش عمودی',
alignBaseline : 'خط مبنا',
bgColor : 'رنگ زمینه',
borderColor : 'رنگ خطوط',
data : 'اطلاعات',
header : 'سرنویس',
yes : 'بله',
no : 'خیر',
invalidWidth : 'عرض سلول باید یک عدد باشد.',
invalidHeight : 'ارتفاع سلول باید عدد باشد.',
invalidRowSpan : 'مقدار محدوده ردیفها باید یک عدد باشد.',
invalidColSpan : 'مقدار محدوده ستونها باید یک عدد باشد.',
chooseColor : 'انتخاب'
},
row :
{
menu : 'سطر',
insertBefore : 'افزودن سطر قبل از',
insertAfter : 'افزودن سطر بعد از',
deleteRow : 'حذف سطرها'
},
column :
{
menu : 'ستون',
insertBefore : 'افزودن ستون قبل از',
insertAfter : 'افزودن ستون بعد از',
deleteColumn : 'حذف ستونها'
}
},
// Button Dialog.
button :
{
title : 'ویژگیهای دکمه',
text : 'متن (مقدار)',
type : 'نوع',
typeBtn : 'دکمه',
typeSbm : 'ثبت',
typeRst : 'بازنشانی (Reset)'
},
// Checkbox and Radio Button Dialogs.
checkboxAndRadio :
{
checkboxTitle : 'ویژگیهای خانهٴ گزینهای',
radioTitle : 'ویژگیهای دکمهٴ رادیویی',
value : 'مقدار',
selected : 'برگزیده'
},
// Form Dialog.
form :
{
title : 'ویژگیهای فرم',
menu : 'ویژگیهای فرم',
action : 'رویداد',
method : 'متد',
encoding : 'رمزنگاری'
},
// Select Field Dialog.
select :
{
title : 'ویژگیهای فیلد چندگزینهای',
selectInfo : 'اطلاعات',
opAvail : 'گزینههای دردسترس',
value : 'مقدار',
size : 'اندازه',
lines : 'خطوط',
chkMulti : 'گزینش چندگانه فراهم باشد',
opText : 'متن',
opValue : 'مقدار',
btnAdd : 'افزودن',
btnModify : 'ویرایش',
btnUp : 'بالا',
btnDown : 'پائین',
btnSetValue : 'تنظیم به عنوان مقدار برگزیده',
btnDelete : 'پاککردن'
},
// Textarea Dialog.
textarea :
{
title : 'ویژگیهای ناحیهٴ متنی',
cols : 'ستونها',
rows : 'سطرها'
},
// Text Field Dialog.
textfield :
{
title : 'ویژگیهای فیلد متنی',
name : 'نام',
value : 'مقدار',
charWidth : 'پهنای نویسه',
maxChars : 'بیشینهٴ نویسهها',
type : 'نوع',
typeText : 'متن',
typePass : 'گذرواژه'
},
// Hidden Field Dialog.
hidden :
{
title : 'ویژگیهای فیلد پنهان',
name : 'نام',
value : 'مقدار'
},
// Image Dialog.
image :
{
title : 'ویژگیهای تصویر',
titleButton : 'ویژگیهای دکمهٴ تصویری',
menu : 'ویژگیهای تصویر',
infoTab : 'اطلاعات تصویر',
btnUpload : 'به سرور بفرست',
upload : 'انتقال به سرور',
alt : 'متن جایگزین',
lockRatio : 'قفل کردن نسبت',
resetSize : 'بازنشانی اندازه',
border : 'لبه',
hSpace : 'فاصلهٴ افقی',
vSpace : 'فاصلهٴ عمودی',
alertUrl : 'لطفا URL تصویر را بنویسید',
linkTab : 'پیوند',
button2Img : 'آیا مایلید از یک تصویر ساده روی دکمه تصویری انتخاب شده استفاده کنید؟',
img2Button : 'آیا مایلید از یک دکمه تصویری روی تصویر انتخاب شده استفاده کنید؟',
urlMissing : 'آدرس URL اصلی تصویر یافت نشد.',
validateBorder : 'مقدار خطوط باید یک عدد باشد.',
validateHSpace : 'مقدار فاصلهگذاری افقی باید یک عدد باشد.',
validateVSpace : 'مقدار فاصلهگذاری عمودی باید یک عدد باشد.'
},
// Flash Dialog
flash :
{
properties : 'ویژگیهای فلش',
propertiesTab : 'ویژگیها',
title : 'ویژگیهای فلش',
chkPlay : 'آغاز خودکار',
chkLoop : 'اجرای پیاپی',
chkMenu : 'در دسترس بودن منوی فلش',
chkFull : 'اجازه تمام صفحه',
scale : 'مقیاس',
scaleAll : 'نمایش همه',
scaleNoBorder : 'بدون کران',
scaleFit : 'جایگیری کامل',
access : 'دسترسی به اسکریپت',
accessAlways : 'همیشه',
accessSameDomain: 'همان دامنه',
accessNever : 'هرگز',
alignAbsBottom : 'پائین مطلق',
alignAbsMiddle : 'وسط مطلق',
alignBaseline : 'خط پایه',
alignTextTop : 'متن بالا',
quality : 'کیفیت',
qualityBest : 'بهترین',
qualityHigh : 'بالا',
qualityAutoHigh : 'بالا - خودکار',
qualityMedium : 'متوسط',
qualityAutoLow : 'پایین - خودکار',
qualityLow : 'پایین',
windowModeWindow: 'پنجره',
windowModeOpaque: 'مات',
windowModeTransparent : 'شفاف',
windowMode : 'حالت پنجره',
flashvars : 'مقادیر برای فلش',
bgcolor : 'رنگ پسزمینه',
hSpace : 'فاصلهٴ افقی',
vSpace : 'فاصلهٴ عمودی',
validateSrc : 'لطفا URL پیوند را بنویسید',
validateHSpace : 'مقدار فاصلهگذاری افقی باید یک عدد باشد.',
validateVSpace : 'مقدار فاصلهگذاری عمودی باید یک عدد باشد.'
},
// Speller Pages Dialog
spellCheck :
{
toolbar : 'بررسی املا',
title : 'بررسی املا',
notAvailable : 'با عرض پوزش خدمات الان در دسترس نیستند.',
errorLoading : 'خطا در بارگیری برنامه خدمات میزبان: %s.',
notInDic : 'در واژه~نامه یافت نشد',
changeTo : 'تغییر به',
btnIgnore : 'چشمپوشی',
btnIgnoreAll : 'چشمپوشی همه',
btnReplace : 'جایگزینی',
btnReplaceAll : 'جایگزینی همه',
btnUndo : 'واچینش',
noSuggestions : '- پیشنهادی نیست -',
progress : 'بررسی املا در حال انجام...',
noMispell : 'بررسی املا انجام شد. هیچ غلط املائی یافت نشد',
noChanges : 'بررسی املا انجام شد. هیچ واژهای تغییر نیافت',
oneChange : 'بررسی املا انجام شد. یک واژه تغییر یافت',
manyChanges : 'بررسی املا انجام شد. %1 واژه تغییر یافت',
ieSpellDownload : 'بررسی کنندهٴ املا نصب نشده است. آیا میخواهید آن را هماکنون دریافت کنید؟'
},
smiley :
{
toolbar : 'خندانک',
title : 'گنجاندن خندانک',
options : 'گزینههای خندانک'
},
elementsPath :
{
eleLabel : 'مسیر عناصر',
eleTitle : '%1 عنصر'
},
numberedlist : 'فهرست شمارهدار',
bulletedlist : 'فهرست نقطهای',
indent : 'افزایش تورفتگی',
outdent : 'کاهش تورفتگی',
justify :
{
left : 'چپچین',
center : 'میانچین',
right : 'راستچین',
block : 'بلوکچین'
},
blockquote : 'بلوک نقل قول',
clipboard :
{
title : 'چسباندن',
cutError : 'تنظیمات امنیتی مرورگر شما اجازه نمیدهد که ویرایشگر به طور خودکار عملکردهای برش را انجام دهد. لطفا با دکمههای صفحه کلید این کار را انجام دهید (Ctrl/Cmd+X).',
copyError : 'تنظیمات امنیتی مرورگر شما اجازه نمیدهد که ویرایشگر به طور خودکار عملکردهای کپی کردن را انجام دهد. لطفا با دکمههای صفحه کلید این کار را انجام دهید (Ctrl/Cmd+C).',
pasteMsg : 'لطفا متن را با کلیدهای (<STRONG>Ctrl/Cmd+V</STRONG>) در این جعبهٴ متنی بچسبانید و <STRONG>پذیرش</STRONG> را بزنید.',
securityMsg : 'به خاطر تنظیمات امنیتی مرورگر شما، ویرایشگر نمیتواند دسترسی مستقیم به دادههای clipboard داشته باشد. شما باید دوباره آنرا در این پنجره بچسبانید.',
pasteArea : 'محل چسباندن'
},
pastefromword :
{
confirmCleanup : 'متنی که میخواهید بچسبانید به نظر میرسد که از Word کپی شده است. آیا میخواهید قبل از چسباندن آن را پاکسازی کنید؟',
toolbar : 'چسباندن از Word',
title : 'چسباندن از Word',
error : 'به دلیل بروز خطای داخلی امکان پاکسازی اطلاعات بازنشانی شده وجود ندارد.'
},
pasteText :
{
button : 'چسباندن به عنوان متن ِساده',
title : 'چسباندن به عنوان متن ِساده'
},
templates :
{
button : 'الگوها',
title : 'الگوهای محتویات',
options : 'گزینههای الگو',
insertOption : 'محتویات کنونی جایگزین شوند',
selectPromptMsg : 'لطفا الگوی موردنظر را برای بازکردن در ویرایشگر برگزینید<br>(محتویات کنونی از دست خواهند رفت):',
emptyListMsg : '(الگوئی تعریف نشده است)'
},
showBlocks : 'نمایش بلوکها',
stylesCombo :
{
label : 'سبک',
panelTitle : 'سبکهای قالببندی',
panelTitle1 : 'سبکهای بلوک',
panelTitle2 : 'سبکهای درونخطی',
panelTitle3 : 'سبکهای شیء'
},
format :
{
label : 'فرمت',
panelTitle : 'فرمت',
tag_p : 'نرمال',
tag_pre : 'فرمت شده',
tag_address : 'آدرس',
tag_h1 : 'سرنویس 1',
tag_h2 : 'سرنویس 2',
tag_h3 : 'سرنویس 3',
tag_h4 : 'سرنویس 4',
tag_h5 : 'سرنویس 5',
tag_h6 : 'سرنویس 6',
tag_div : 'بند'
},
div :
{
title : 'ایجاد یک محل DIV',
toolbar : 'ایجاد یک محل DIV',
cssClassInputLabel : 'کلاسهای شیوهنامه',
styleSelectLabel : 'سبک',
IdInputLabel : 'شناسه',
languageCodeInputLabel : ' کد زبان',
inlineStyleInputLabel : 'سبک درونخطی(Inline Style)',
advisoryTitleInputLabel : 'عنوان مشاوره',
langDirLabel : 'جهت نوشتاری زبان',
langDirLTRLabel : 'چپ به راست (LTR)',
langDirRTLLabel : 'راست به چپ (RTL)',
edit : 'ویرایش Div',
remove : 'حذف Div'
},
iframe :
{
title : 'ویژگیهای IFrame',
toolbar : 'IFrame',
noUrl : 'لطفا مسیر URL iframe را درج کنید',
scrolling : 'نمایش خطکشها',
border : 'نمایش خطوط frame'
},
font :
{
label : 'قلم',
voiceLabel : 'قلم',
panelTitle : 'قلم'
},
fontSize :
{
label : 'اندازه',
voiceLabel : 'اندازه قلم',
panelTitle : 'اندازه'
},
colorButton :
{
textColorTitle : 'رنگ متن',
bgColorTitle : 'رنگ پسزمینه',
panelTitle : 'رنگها',
auto : 'خودکار',
more : 'رنگهای بیشتر...'
},
colors :
{
'000' : 'سیاه',
'800000' : 'خرمایی',
'8B4513' : 'قهوهای شکلاتی',
'2F4F4F' : 'ارغوانی مایل به خاکستری',
'008080' : 'آبی مایل به خاکستری',
'000080' : 'آبی سیر',
'4B0082' : 'نیلی',
'696969' : 'خاکستری تیره',
'B22222' : 'آتش آجری',
'A52A2A' : 'قهوهای',
'DAA520' : 'میلهی طلایی',
'006400' : 'سبز تیره',
'40E0D0' : 'فیروزهای',
'0000CD' : 'آبی روشن',
'800080' : 'ارغوانی',
'808080' : 'خاکستری',
'F00' : 'قرمز',
'FF8C00' : 'نارنجی پررنگ',
'FFD700' : 'طلایی',
'008000' : 'سبز',
'0FF' : 'آبی مایل به سبز',
'00F' : 'آبی',
'EE82EE' : 'بنفش',
'A9A9A9' : 'خاکستری مات',
'FFA07A' : 'صورتی کدر روشن',
'FFA500' : 'نارنجی',
'FFFF00' : 'زرد',
'00FF00' : 'فسفری',
'AFEEEE' : 'فیروزهای رنگ پریده',
'ADD8E6' : 'آبی کمرنگ',
'DDA0DD' : 'آلویی',
'D3D3D3' : 'خاکستری روشن',
'FFF0F5' : 'بنفش کمرنگ',
'FAEBD7' : 'عتیقه سفید',
'FFFFE0' : 'زرد روشن',
'F0FFF0' : 'عسلی',
'F0FFFF' : 'لاجوردی',
'F0F8FF' : 'آبی براق',
'E6E6FA' : 'بنفش کمرنگ',
'FFF' : 'سفید'
},
scayt :
{
title : 'بررسی املای تایپ شما',
opera_title : 'توسط اپرا پشتیبانی نمیشود',
enable : 'فعالسازی SCAYT',
disable : 'غیرفعالسازی SCAYT',
about : 'درباره SCAYT',
toggle : 'ضامن SCAYT',
options : 'گزینهها',
langs : 'زبانها',
moreSuggestions : 'پیشنهادهای بیشتر',
ignore : 'عبور کردن',
ignoreAll : 'عبور کردن از همه',
addWord : 'افزودن Word',
emptyDic : 'نام دیکشنری نباید خالی باشد.',
optionsTab : 'گزینهها',
allCaps : 'نادیده گرفتن همه کلاه-واژهها',
ignoreDomainNames : 'عبور از نامهای دامنه',
mixedCase : 'عبور از کلماتی مرکب از حروف بزرگ و کوچک',
mixedWithDigits : 'عبور از کلمات به همراه عدد',
languagesTab : 'زبانها',
dictionariesTab : 'دیکشنریها',
dic_field_name : 'نام دیکشنری',
dic_create : 'ایجاد',
dic_restore : 'بازیافت',
dic_delete : 'حذف',
dic_rename : 'تغییر نام',
dic_info : 'در ابتدا دیکشنری کاربر در کوکی ذخیره میشود. با این حال، کوکیها در اندازه محدود شدهاند. وقتی که دیکشنری کاربری بزرگ میشود و به نقطهای که نمیتواند در کوکی ذخیره شود، پس از آن دیکشنری ممکن است بر روی سرور ما ذخیره شود. برای ذخیره دیکشنری شخصی شما بر روی سرور ما، باید یک نام برای دیکشنری خود مشخص نمایید. اگر شما قبلا یک دیکشنری روی سرور ما ذخیره کردهاید، لطفا نام آنرا درج و روی دکمه بازیافت کلیک نمایید.',
aboutTab : 'درباره'
},
about :
{
title : 'درباره CKEditor',
dlgTitle : 'درباره CKEditor',
help : 'بررسی $1 برای راهنمایی.',
userGuide : 'راهنمای کاربران CKEditor',
moreInfo : 'برای کسب اطلاعات مجوز لطفا به وب سایت ما مراجعه کنید:',
copy : 'حق نشر © $1. کلیه حقوق محفوظ است.'
},
maximize : 'حداکثر کردن',
minimize : 'حداقل کردن',
fakeobjects :
{
anchor : 'لنگر',
flash : 'انیمشن فلش',
iframe : 'IFrame',
hiddenfield : 'فیلد پنهان',
unknown : 'شیء ناشناخته'
},
resize : 'کشیدن برای تغییر اندازه',
colordialog :
{
title : 'انتخاب رنگ',
options : 'گزینههای رنگ',
highlight : 'متمایز',
selected : 'رنگ انتخاب شده',
clear : 'پاک کردن'
},
toolbarCollapse : 'بستن نوار ابزار',
toolbarExpand : 'بازکردن نوار ابزار',
toolbarGroups :
{
document : 'سند',
clipboard : 'حافظه موقت/برگشت',
editing : 'در حال ویرایش',
forms : 'فرمها',
basicstyles : 'شیوههای پایه',
paragraph : 'بند',
links : 'پیوندها',
insert : 'ورود',
styles : 'شیوهها',
colors : 'رنگها',
tools : 'ابزارها'
},
bidi :
{
ltr : 'نوشتار متن از چپ به راست',
rtl : 'نوشتار متن از راست به چپ'
},
docprops :
{
label : 'ویژگیهای سند',
title : 'ویژگیهای سند',
design : 'طراحی',
meta : 'فراداده',
chooseColor : 'انتخاب',
other : '<سایر>',
docTitle : 'عنوان صفحه',
charset : 'رمزگذاری نویسهگان',
charsetOther : 'رمزگذاری نویسهگان دیگر',
charsetASCII : 'ASCII',
charsetCE : 'اروپای مرکزی',
charsetCT : 'چینی رسمی (Big5)',
charsetCR : 'سیریلیک',
charsetGR : 'یونانی',
charsetJP : 'ژاپنی',
charsetKR : 'کرهای',
charsetTR : 'ترکی',
charsetUN : 'یونیکُد (UTF-8)',
charsetWE : 'اروپای غربی',
docType : 'عنوان نوع سند',
docTypeOther : 'عنوان نوع سند دیگر',
xhtmlDec : 'شامل تعاریف XHTML',
bgColor : 'رنگ پسزمینه',
bgImage : 'URL تصویر پسزمینه',
bgFixed : 'پسزمینهٴ پیمایش ناپذیر',
txtColor : 'رنگ متن',
margin : 'حاشیههای صفحه',
marginTop : 'بالا',
marginLeft : 'چپ',
marginRight : 'راست',
marginBottom : 'پایین',
metaKeywords : 'کلیدواژگان نمایهگذاری سند (با کاما جدا شوند)',
metaDescription : 'توصیف سند',
metaAuthor : 'نویسنده',
metaCopyright : 'حق انتشار',
previewHtml : '<p>این یک <strong>متن نمونه</strong> است. شما در حال استفاده از <a href="javascript:void(0)">CKEditor</a> هستید.</p>'
}
};
| JavaScript |
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
* @fileOverview
*/
/**#@+
@type String
@example
*/
/**
* Contains the dictionary of language entries.
* @namespace
*/
CKEDITOR.lang['ku'] =
{
/**
* The language reading direction. Possible values are "rtl" for
* Right-To-Left languages (like Arabic) and "ltr" for Left-To-Right
* languages (like English).
* @default 'ltr'
*/
dir : 'rtl',
/*
* Screenreader titles. Please note that screenreaders are not always capable
* of reading non-English words. So be careful while translating it.
*/
editorTitle : 'دهسکاریکهری ناونیشان',
editorHelp : 'کلیکی ALT لهگهڵ 0 بکه بۆ یارمهتی',
// ARIA descriptions.
toolbars : 'تووڵاەرازی دەسکاریکەر',
editor : 'سەرنووسەی دەقی بەپیت',
// Toolbar buttons without dialogs.
source : 'سەرچاوە',
newPage : 'پەڕەیەکی نوێ',
save : 'پاشکەوتکردن',
preview : 'پێشبینین',
cut : 'بڕین',
copy : 'لەبەرگرنتەوه',
paste : 'لکاندن',
print : 'چاپکردن',
underline : 'ژێرهێڵ',
bold : 'قەڵەو',
italic : 'لار',
selectAll : 'نیشانکردنی هەمووی',
removeFormat : 'لابردنی داڕشتەکە',
strike : 'لێدان',
subscript : 'ژێرنووس',
superscript : 'سەرنووس',
horizontalrule : 'دانانی هێلی ئاسۆیی',
pagebreak : 'دانانی پشووی پەڕە بۆ چاپکردن',
pagebreakAlt : 'پشووی پەڕە',
unlink : 'لابردنی بەستەر',
undo : 'پووچکردنەوه',
redo : 'هەڵگەڕاندنەوه',
// Common messages and labels.
common :
{
browseServer : 'هێنانی ڕاژە',
url : 'ناونیشانی بەستەر',
protocol : 'پڕۆتۆکۆڵ',
upload : 'بارکردن',
uploadSubmit : 'ناردنی بۆ ڕاژە',
image : 'وێنە',
flash : 'فلاش',
form : 'داڕشتە',
checkbox : 'خانەی نیشانکردن',
radio : 'جێگرەوەی دوگمە',
textField : 'خانەی دەق',
textarea : 'ڕووبەری دەق',
hiddenField : 'شاردنەوی خانە',
button : 'دوگمە',
select : 'هەڵبژاردەی خانە',
imageButton : 'دوگمەی وێنە',
notSet : '<هیچ دانەدراوە>',
id : 'ناسنامە',
name : 'ناو',
langDir : 'ئاراستەی زمان',
langDirLtr : 'چەپ بۆ ڕاست (LTR)',
langDirRtl : 'ڕاست بۆ چەپ (RTL)',
langCode : 'هێمای زمان',
longDescr : 'پێناسەی درێژی بەستەر',
cssClass : 'شێوازی چینی پهڕە',
advisoryTitle : 'ڕاوێژکاری سەردێڕ',
cssStyle : 'شێواز',
ok : 'باشە',
cancel : 'هەڵوەشاندن',
close : 'داخستن',
preview : 'پێشبینین',
generalTab : 'گشتی',
advancedTab : 'پهرهسهندوو',
validateNumberFailed : 'ئەم نرخە ژمارە نیه، تکایە نرخێکی ژمارە بنووسە.',
confirmNewPage : 'سەرجەم گۆڕانکاریەکان و پێکهاتەکانی ناوەووە لەدەست دەدەی گەر بێتوو پاشکەوتی نەکەی یەکەم جار، تۆ هەر دڵنیایی لەکردنەوەی پەنجەرەکی نوێ؟',
confirmCancel : 'هەندێك هەڵبژاردە گۆڕدراوە. تۆ دڵنیایی لهداخستنی ئەم دیالۆگە؟',
options : 'هەڵبژاردە',
target : 'ئامانج',
targetNew : 'پەنجەرەیهکی نوێ (_blank)',
targetTop : 'لووتکەی پەنجەرە (_top)',
targetSelf : 'لەهەمان پەنجەرە (_self)',
targetParent : 'پەنجەرەی باوان (_parent)',
langDirLTR : 'چەپ بۆ ڕاست (LTR)',
langDirRTL : 'ڕاست بۆ چەپ (RTL)',
styles : 'شێواز',
cssClasses : 'شێوازی چینی پەڕە',
width : 'پانی',
height : 'درێژی',
align : 'ڕێککەرەوە',
alignLeft : 'چەپ',
alignRight : 'ڕاست',
alignCenter : 'ناوەڕاست',
alignTop : 'سەرەوە',
alignMiddle : 'ناوەند',
alignBottom : 'ژێرەوە',
invalidValue : 'نرخێکی نادرووست.',
invalidHeight : 'درێژی دەبێت ژمارە بێت.',
invalidWidth : 'پانی دەبێت ژمارە بێت.',
invalidCssLength : 'ئەم نرخەی دراوە بۆ خانەی "%1" دەبێت ژمارەکی درووست بێت یان بێ ناونیشانی ئامرازی (px, %, in, cm, mm, em, ex, pt, یان pc).',
invalidHtmlLength : 'ئەم نرخەی دراوە بۆ خانەی "%1" دەبێت ژمارەکی درووست بێت یان بێ ناونیشانی ئامرازی HTML (px یان %).',
invalidInlineStyle : 'دانهی نرخی شێوازی ناوهێڵ دهبێت پێکهاتبێت لهیهك یان زیاتری داڕشته "ناو : نرخ", جیاکردنهوهی بهفاریزهوخاڵ',
cssLengthTooltip : 'ژمارهیهك بنووسه بۆ نرخی piksel یان ئامرازێکی درووستی CSS (px, %, in, cm, mm, em, ex, pt, یان pc).',
// Put the voice-only part of the label in the span.
unavailable : '%1<span class="cke_accessibility">, ئامادە نیە</span>'
},
contextmenu :
{
options : 'هەڵبژاردەی لیستەی کلیکی دەستی ڕاست'
},
// Special char dialog.
specialChar :
{
toolbar : 'دانانەی نووسەی تایبەتی',
title : 'هەڵبژاردنی نووسەی تایبەتی',
options : 'هەڵبژاردەی نووسەی تایبەتی'
},
// Link dialog.
link :
{
toolbar : 'دانان/ڕێکخستنی بەستەر',
other : '<هیتر>',
menu : 'چاکسازی بەستەر',
title : 'بەستەر',
info : 'زانیاری بەستەر',
target : 'ئامانج',
upload : 'بارکردن',
advanced : 'پێشکهوتوو',
type : 'جۆری بهستهر',
toUrl : 'ناونیشانی بهستهر',
toAnchor : 'بهستهر بۆ لهنگهر له دهق',
toEmail : 'ئیمهیل',
targetFrame : '<چووارچێوه>',
targetPopup : '<پهنجهرهی سهرههڵدهر>',
targetFrameName : 'ناوی ئامانجی چووارچێوه',
targetPopupName : 'ناوی پهنجهرهی سهرههڵدهر',
popupFeatures : 'خاسیهتی پهنجهرهی سهرههڵدهر',
popupResizable : 'توانای گۆڕینی قهباره',
popupStatusBar : 'هێڵی دۆخ',
popupLocationBar: 'هێڵی ناونیشانی بهستهر',
popupToolbar : 'هێڵی تووڵامراز',
popupMenuBar : 'هێڵی لیسته',
popupFullScreen : 'پڕ بهپڕی شاشه (IE)',
popupScrollBars : 'هێڵی هاتووچۆپێکردن',
popupDependent : 'پێوهبهستراو (Netscape)',
popupLeft : 'جێگای چهپ',
popupTop : 'جێگای سهرهوه',
id : 'ناسنامه',
langDir : 'ئاراستهی زمان',
langDirLTR : 'چهپ بۆ ڕاست (LTR)',
langDirRTL : 'ڕاست بۆ چهپ (RTL)',
acccessKey : 'کلیلی دهستپێگهیشتن',
name : 'ناو',
langCode : 'هێمای زمان',
tabIndex : 'بازدهری تابی ئیندێکس',
advisoryTitle : 'ڕاوێژکاری سهردێڕ',
advisoryContentType : 'جۆری ناوهڕۆکی ڕاویژکار',
cssClasses : 'شێوازی چینی پهڕه',
charset : 'بەستەری سەرچاوەی نووسه',
styles : 'شێواز',
rel : 'پهیوهندی (rel)',
selectAnchor : 'ههڵبژاردنی لهنگهرێك',
anchorName : 'بهپێی ناوی لهنگهر',
anchorId : 'بهپێی ناسنامهی توخم',
emailAddress : 'ناونیشانی ئیمهیل',
emailSubject : 'بابهتی نامه',
emailBody : 'ناوهڕۆکی نامه',
noAnchors : '(هیچ جۆرێکی لهنگهر ئاماده نیه لهم پهڕهیه)',
noUrl : 'تکایه ناونیشانی بهستهر بنووسه',
noEmail : 'تکایه ناونیشانی ئیمهیل بنووسه'
},
// Anchor dialog
anchor :
{
toolbar : 'دانان/چاکسازی لهنگهر',
menu : 'چاکسازی لهنگهر',
title : 'خاسیهتی لهنگهر',
name : 'ناوی لهنگهر',
errorName : 'تکایه ناوی لهنگهر بنووسه',
remove : 'لابردنی لهنگهر'
},
// List style dialog
list:
{
numberedTitle : 'خاسیهتی لیستی ژمارهیی',
bulletedTitle : 'خاسیهتی لیستی خاڵی',
type : 'جۆر',
start : 'دهستپێکردن',
validateStartNumber :'دهستپێکهری لیستی ژمارهیی دهبێت تهنها ژماره بێت.',
circle : 'بازنه',
disc : 'پهپکه',
square : 'چووراگۆشه',
none : 'هیچ',
notset : '<دانهندراوه>',
armenian : 'ئاراستهی ژمارهی ئهرمهنی',
georgian : 'ئاراستهی ژمارهی جۆڕجی (an, ban, gan, وههیتر.)',
lowerRoman : 'ژمارهی ڕۆمی بچووك (i, ii, iii, iv, v, وههیتر.)',
upperRoman : 'ژمارهی ڕۆمی گهوره (I, II, III, IV, V, وههیتر.)',
lowerAlpha : 'ئهلفابێی بچووك (a, b, c, d, e, وههیتر.)',
upperAlpha : 'ئهلفابێی گهوره (A, B, C, D, E, وههیتر.)',
lowerGreek : 'یۆنانی بچووك (alpha, beta, gamma, وههیتر.)',
decimal : 'ژماره (1, 2, 3, وههیتر.)',
decimalLeadingZero : 'ژماره سفڕی لهپێشهوه (01, 02, 03, وههیتر.)'
},
// Find And Replace Dialog
findAndReplace :
{
title : 'گهڕان وه لهبریدانان',
find : 'گهڕان',
replace : 'لهبریدانان',
findWhat : 'گهڕان بهدووای:',
replaceWith : 'لهبریدانان به:',
notFoundMsg : 'هیچ دهقه گهڕانێك نهدۆزراوه.',
findOptions : 'ههڵبژاردهکانی گهڕان',
matchCase : 'جیاکردنهوه لهنێوان پیتی گهورهو بچووك',
matchWord : 'تهنها ههموو وشهکه',
matchCyclic : 'گهڕان لهههموو پهڕهکه',
replaceAll : 'لهبریدانانی ههمووی',
replaceSuccessMsg : ' پێشهاته(ی) لهبری دانرا. %1'
},
// Table Dialog
table :
{
toolbar : 'خشته',
title : 'خاسیهتی خشته',
menu : 'خاسیهتی خشته',
deleteTable : 'سڕینهوهی خشته',
rows : 'ڕیز',
columns : 'ستوونهکان',
border : 'گهورهیی پهراوێز',
widthPx : 'وێنهخاڵ - پیکسل',
widthPc : 'لهسهدا',
widthUnit : 'پانی یهکه',
cellSpace : 'بۆشایی خانه',
cellPad : 'بۆشایی ناوپۆش',
caption : 'سهردێڕ',
summary : 'کورته',
headers : 'سهرپهڕه',
headersNone : 'هیچ',
headersColumn : 'یهکهم ئهستوون',
headersRow : 'یهکهم ڕیز',
headersBoth : 'ههردووك',
invalidRows : 'ژمارهی ڕیز دهبێت گهورهتر بێت لهژمارهی 0.',
invalidCols : 'ژمارهی ئهستوونی دهبێت گهورهتر بێت لهژمارهی 0.',
invalidBorder : 'ژمارهی پهراوێز دهبێت تهنها ژماره بێت.',
invalidWidth : 'پانی خشته دهبێت تهنها ژماره بێت.',
invalidHeight : 'درێژی خشته دهبێت تهنها ژماره بێت.',
invalidCellSpacing : 'بۆشایی خانه دهبێت ژمارهکی درووست بێت.',
invalidCellPadding : 'ناوپۆشی خانه دهبێت ژمارهکی درووست بێت.',
cell :
{
menu : 'خانه',
insertBefore : 'دانانی خانه لهپێش',
insertAfter : 'دانانی خانه لهپاش',
deleteCell : 'سڕینهوهی خانه',
merge : 'تێکهڵکردنی خانه',
mergeRight : 'تێکهڵکردنی لهگهڵ ڕاست',
mergeDown : 'تێکهڵکردنی لهگهڵ خوارهوه',
splitHorizontal : 'دابهشکردنی خانهی ئاسۆیی',
splitVertical : 'دابهشکردنی خانهی ئهستونی',
title : 'خاسیهتی خانه',
cellType : 'جۆری خانه',
rowSpan : 'ماوهی نێوان ڕیز',
colSpan : 'بستی ئهستونی',
wordWrap : 'پێچانهوهی وشه',
hAlign : 'ڕیزکردنی ئاسۆیی',
vAlign : 'ڕیزکردنی ئهستونی',
alignBaseline : 'هێڵهبنهڕهت',
bgColor : 'ڕهنگی پاشبنهما',
borderColor : 'ڕهنگی پهراوێز',
data : 'داتا',
header : 'سهرپهڕه',
yes : 'بهڵێ',
no : 'نهخێر',
invalidWidth : 'پانی خانه دهبێت بهتهواوی ژماره بێت.',
invalidHeight : 'درێژی خانه بهتهواوی دهبێت ژماره بێت.',
invalidRowSpan : 'ماوهی نێوان ڕیز بهتهواوی دهبێت ژماره بێت.',
invalidColSpan : 'ماوهی نێوان ئهستونی بهتهواوی دهبێت ژماره بێت.',
chooseColor : 'ههڵبژاردن'
},
row :
{
menu : 'ڕیز',
insertBefore : 'دانانی ڕیز لهپێش',
insertAfter : 'دانانی ڕیز لهپاش',
deleteRow : 'سڕینهوهی ڕیز'
},
column :
{
menu : 'ئهستون',
insertBefore : 'دانانی ئهستون لهپێش',
insertAfter : 'دانانی ئهستوون لهپاش',
deleteColumn : 'سڕینهوهی ئهستوون'
}
},
// Button Dialog.
button :
{
title : 'خاسیهتی دوگمه',
text : '(نرخی) دهق',
type : 'جۆر',
typeBtn : 'دوگمه',
typeSbm : 'ناردن',
typeRst : 'ڕێکخستنهوه'
},
// Checkbox and Radio Button Dialogs.
checkboxAndRadio :
{
checkboxTitle : 'خاسیهتی چووارگۆشی پشکنین',
radioTitle : 'خاسیهتی جێگرهوهی دوگمه',
value : 'نرخ',
selected : 'ههڵبژاردرا'
},
// Form Dialog.
form :
{
title : 'خاسیهتی داڕشته',
menu : 'خاسیهتی داڕشته',
action : 'کردار',
method : 'ڕێگه',
encoding : 'بهکۆدکهر'
},
// Select Field Dialog.
select :
{
title : 'ههڵبژاردهی خاسیهتی خانه',
selectInfo : 'زانیاری',
opAvail : 'ههڵبژاردهی ههبوو',
value : 'نرخ',
size : 'گهورهیی',
lines : 'هێڵهکان',
chkMulti : 'ڕێدان بهفره ههڵبژارده',
opText : 'دهق',
opValue : 'نرخ',
btnAdd : 'زیادکردن',
btnModify : 'گۆڕانکاری',
btnUp : 'سهرهوه',
btnDown : 'خوارهوه',
btnSetValue : 'دابنێ وهك نرخێکی ههڵبژێردراو',
btnDelete : 'سڕینهوه'
},
// Textarea Dialog.
textarea :
{
title : 'خاسیهتی ڕووبهری دهق',
cols : 'ئهستونیهکان',
rows : 'ڕیزهکان'
},
// Text Field Dialog.
textfield :
{
title : 'خاسیهتی خانهی دهق',
name : 'ناو',
value : 'نرخ',
charWidth : 'پانی نووسه',
maxChars : 'ئهوپهڕی نووسه',
type : 'جۆر',
typeText : 'دهق',
typePass : 'پێپهڕهوشه'
},
// Hidden Field Dialog.
hidden :
{
title : 'خاسیهتی خانهی شاردراوه',
name : 'ناو',
value : 'نرخ'
},
// Image Dialog.
image :
{
title : 'خاسیهتی وێنه',
titleButton : 'خاسیهتی دوگمهی وێنه',
menu : 'خاسیهتی وێنه',
infoTab : 'زانیاری وێنه',
btnUpload : 'ناردنی بۆ ڕاژه',
upload : 'بارکردن',
alt : 'جێگرهوهی دهق',
lockRatio : 'داخستنی ڕێژه',
resetSize : 'ڕێکخستنهوهی قهباره',
border : 'پهراوێز',
hSpace : 'بۆشایی ئاسۆیی',
vSpace : 'بۆشایی ئهستونی',
alertUrl : 'تکایه ناونیشانی بهستهری وێنه بنووسه',
linkTab : 'بهستهر',
button2Img : 'تۆ دهتهوێت دوگمهی وێنهی دیاریکراو بگۆڕیت بۆ وێنهکی ئاسایی؟',
img2Button : 'تۆ دهتهوێت وێنهی دیاریکراو بگۆڕیت بۆ دوگمهی وێنه؟',
urlMissing : 'سهرچاوهی بهستهری وێنه بزره',
validateBorder : 'پهراوێز دهبێت بهتهواوی تهنها ژماره بێت.',
validateHSpace : 'بۆشایی ئاسۆیی دهبێت بهتهواوی تهنها ژماره بێت.',
validateVSpace : 'بۆشایی ئهستونی دهبێت بهتهواوی تهنها ژماره بێت.'
},
// Flash Dialog
flash :
{
properties : 'خاسیهتی فلاش',
propertiesTab : 'خاسیهت',
title : 'خاسیهتی فلاش',
chkPlay : 'پێکردنی یان لێدانی خۆکار',
chkLoop : 'گرێ',
chkMenu : 'چالاککردنی لیستهی فلاش',
chkFull : 'ڕێپێدان به پڕ بهپڕی شاشه',
scale : 'پێوانه',
scaleAll : 'نیشاندانی ههموو',
scaleNoBorder : 'بێ پهراوێز',
scaleFit : 'بهوردی بگونجێت',
access : 'دهستپێگهیشتنی نووسراو',
accessAlways : 'ههمیشه',
accessSameDomain: 'ههمان دۆمهین',
accessNever : 'ههرگیز',
alignAbsBottom : 'له ژێرهوه',
alignAbsMiddle : 'لهناوهند',
alignBaseline : 'هێڵەبنەڕەت',
alignTextTop : 'دهق لهسهرهوه',
quality : 'جۆرایهتی',
qualityBest : 'باشترین',
qualityHigh : 'بهرزی',
qualityAutoHigh : 'بهرزی خۆکار',
qualityMedium : 'مامناوهند',
qualityAutoLow : 'نزمی خۆکار',
qualityLow : 'نزم',
windowModeWindow: 'پهنجهره',
windowModeOpaque: 'ناڕوون',
windowModeTransparent : 'ڕۆشن',
windowMode : 'شێوازی پهنجهره',
flashvars : 'گۆڕاوهکان بۆ فلاش',
bgcolor : 'ڕهنگی پاشبنهما',
hSpace : 'بۆشایی ئاسۆیی',
vSpace : 'بۆشایی ئهستونی',
validateSrc : 'ناونیشانی بهستهر نابێت خاڵی بێت',
validateHSpace : 'بۆشایی ئاسۆیی دهبێت ژماره بێت.',
validateVSpace : 'بۆشایی ئهستونی دهبێت ژماره بێت.'
},
// Speller Pages Dialog
spellCheck :
{
toolbar : 'پشکنینی ڕێنووس',
title : 'پشکنینی ڕێنووس',
notAvailable : 'ببووره، لهمکاتهدا ڕاژهکه لهبهردهستا نیه.',
errorLoading : 'ههڵه لههێنانی داخوازینامهی خانهخۆێی ڕاژه: %s.',
notInDic : 'لهفهرههنگ دانیه',
changeTo : 'گۆڕینی بۆ',
btnIgnore : 'پشتگوێ کردن',
btnIgnoreAll : 'پشتگوێکردنی ههمووی',
btnReplace : 'لهبریدانن',
btnReplaceAll : 'لهبریدانانی ههمووی',
btnUndo : 'پووچکردنهوه',
noSuggestions : '- هیچ پێشنیارێك -',
progress : 'پشکنینی ڕێنووس لهبهردهوامبوون دایه...',
noMispell : 'پشکنینی ڕێنووس کۆتای هات: هیچ ههڵهیهکی ڕێنووس نهدۆزراوه',
noChanges : 'پشکنینی ڕێنووس کۆتای هات: هیچ وشهیهك نۆگۆڕدرا',
oneChange : 'پشکنینی ڕێنووس کۆتای هات: یهك وشه گۆڕدرا',
manyChanges : 'پشکنینی ڕێنووس کۆتای هات: لهسهدا %1 ی وشهکان گۆڕدرا',
ieSpellDownload : 'پشکنینی ڕێنووس دانهمزراوه. دهتهوێت ئێستا دایبگریت?'
},
smiley :
{
toolbar : 'زهردهخهنه',
title : 'دانانی زهردهخهنهیهك',
options : 'ههڵبژاردهی زهردهخهنه'
},
elementsPath :
{
eleLabel : 'ڕێڕهوی توخمهکان',
eleTitle : '%1 توخم'
},
numberedlist : 'دانان/لابردنی ژمارەی لیست',
bulletedlist : 'دانان/لابردنی خاڵی لیست',
indent : 'زیادکردنی بۆشایی',
outdent : 'کەمکردنەوەی بۆشایی',
justify :
{
left : 'بههێڵ کردنی چهپ',
center : 'ناوهڕاست',
right : 'بههێڵ کردنی ڕاست',
block : 'هاوستوونی'
},
blockquote : 'بەربەستکردنی وتەی وەرگیراو',
clipboard :
{
title : 'لکاندن',
cutError : 'پارێزی وێبگەڕەکەت ڕێگهنادات بە سەرنووسەکە لهبڕینی خۆکار. تکایە لەبری ئەمە ئەم فەرمانە بەکاربهێنە بەداگرتنی کلیلی (Ctrl/Cmd+X).',
copyError : 'پارێزی وێبگەڕەکەت ڕێگهنادات بەسەرنووسەکە لە لکاندنی دەقی خۆکار. تکایە لەبری ئەمە ئەم فەرمانە بەکاربهێنە بەداگرتنی کلیلی (Ctrl/Cmd+C).',
pasteMsg : 'تکایه بیلکێنه لهناوهوهی ئهم سنوقه لهڕێی تهختهکلیلهکهت بهباکارهێنانی کلیلی (<STRONG>Ctrl/Cmd+V</STRONG>) دووای کلیکی باشه بکه.',
securityMsg : 'بههۆی شێوهپێدانی پارێزی وێبگهڕهکهت، سهرنووسهکه ناتوانێت دهستبگهیهنێت بهههڵگیراوهکه ڕاستهوخۆ. بۆیه پێویسته دووباره بیلکێنیت لهم پهنجهرهیه.',
pasteArea : 'ناوچهی لکاندن'
},
pastefromword :
{
confirmCleanup : 'ئهم دهقهی بهتهمای بیلکێنی پێدهچێت له word هێنرابێت. دهتهوێت پاکی بکهیوه پێش ئهوهی بیلکێنی؟',
toolbar : 'لکاندنی لهڕێی Word',
title : 'لکاندنی لهلایهن Word',
error : 'هیچ ڕێگهیهك نهبوو لهلکاندنی دهقهکه بههۆی ههڵهکی ناوهخۆیی'
},
pasteText :
{
button : 'لکاندنی وهك دهقی ڕوون',
title : 'لکاندنی وهك دهقی ڕوون'
},
templates :
{
button : 'ڕووکار',
title : 'پێکهاتهی ڕووکار',
options : 'ههڵبژاردهکانی ڕووکار',
insertOption : 'لهشوێن دانانی ئهم پێکهاتانهی ئێستا',
selectPromptMsg : 'ڕووکارێك ههڵبژێره بۆ کردنهوهی له سهرنووسهر:',
emptyListMsg : '(هیچ ڕووکارێك دیارینهکراوه)'
},
showBlocks : 'نیشاندانی بەربەستەکان',
stylesCombo :
{
label : 'شێواز',
panelTitle : 'شێوازی ڕازاندنهوه',
panelTitle1 : 'شێوازی خشت',
panelTitle2 : 'شێوازی ناوهێڵ',
panelTitle3 : 'شێوازی بهرکار'
},
format :
{
label : 'ڕازاندنهوه',
panelTitle : 'بهشی ڕازاندنهوه',
tag_p : 'ئاسایی',
tag_pre : 'شێوازکراو',
tag_address : 'ناونیشان',
tag_h1 : 'سهرنووسهی ١',
tag_h2 : 'سهرنووسهی ٢',
tag_h3 : 'سهرنووسهی ٣',
tag_h4 : 'سهرنووسهی ٤',
tag_h5 : 'سهرنووسهی ٥',
tag_h6 : 'سهرنووسهی ٦',
tag_div : '(DIV)-ی ئاسایی'
},
div :
{
title : 'دانانی لهخۆگری Div',
toolbar : 'دانانی لهخۆگری Div',
cssClassInputLabel : 'شێوازی چینی پهڕه',
styleSelectLabel : 'شێواز',
IdInputLabel : 'ناسنامه',
languageCodeInputLabel : 'هێمای زمان',
inlineStyleInputLabel : 'شێوازی ناوهێڵ',
advisoryTitleInputLabel : 'سهردێڕ',
langDirLabel : 'ئاراستهی زمان',
langDirLTRLabel : 'چهپ بۆ ڕاست (LTR)',
langDirRTLLabel : 'ڕاست بۆ چهپ (RTL)',
edit : 'چاکسازی Div',
remove : 'لابردنی Div'
},
iframe :
{
title : 'دیالۆگی چووارچێوه',
toolbar : 'چووارچێوه',
noUrl : 'تکایه ناونیشانی بهستهر بنووسه بۆ چووارچێوه',
scrolling : 'چالاککردنی هاتووچۆپێکردن',
border : 'نیشاندانی لاکێشه بهچوواردهوری چووارچێوه'
},
font :
{
label : 'فۆنت',
voiceLabel : 'فۆنت',
panelTitle : 'ناوی فۆنت'
},
fontSize :
{
label : 'گهورهیی',
voiceLabel : 'گهورهیی فۆنت',
panelTitle : 'گهورهیی فۆنت'
},
colorButton :
{
textColorTitle : 'ڕهنگی دهق',
bgColorTitle : 'ڕهنگی پاشبنهما',
panelTitle : 'ڕهنگهکان',
auto : 'خۆکار',
more : 'ڕهنگی زیاتر...'
},
colors :
{
'000' : 'ڕهش',
'800000' : 'سۆرو ماڕوونی',
'8B4513' : 'ماڕوونی',
'2F4F4F' : 'سهوزی تاریك',
'008080' : 'سهوزو شین',
'000080' : 'شینی تۆخ',
'4B0082' : 'مۆری تۆخ',
'696969' : 'ڕهساسی تۆخ',
'B22222' : 'سۆری تۆخ',
'A52A2A' : 'قاوهیی',
'DAA520' : 'قاوهیی بریسکهدار',
'006400' : 'سهوزی تۆخ',
'40E0D0' : 'شینی ناتۆخی بریسکهدار',
'0000CD' : 'شینی مامناوهند',
'800080' : 'پهمبهیی',
'808080' : 'ڕهساسی',
'F00' : 'سۆر',
'FF8C00' : 'نارهنجی تۆخ',
'FFD700' : 'زهرد',
'008000' : 'سهوز',
'0FF' : 'شینی ئاسمانی',
'00F' : 'شین',
'EE82EE' : 'پهمهیی',
'A9A9A9' : 'ڕهساسی ناتۆخ',
'FFA07A' : 'نارهنجی ناتۆخ',
'FFA500' : 'نارهنجی',
'FFFF00' : 'زهرد',
'00FF00' : 'سهوز',
'AFEEEE' : 'شینی ناتۆخ',
'ADD8E6' : 'شینی زۆر ناتۆخ',
'DDA0DD' : 'پهمهیی ناتۆخ',
'D3D3D3' : 'ڕهساسی بریسکهدار',
'FFF0F5' : 'جهرگی زۆر ناتۆخ',
'FAEBD7' : 'جهرگی ناتۆخ',
'FFFFE0' : 'سپی ناتۆخ',
'F0FFF0' : 'ههنگوینی ناتۆخ',
'F0FFFF' : 'شینێکی زۆر ناتۆخ',
'F0F8FF' : 'شینێکی ئاسمانی زۆر ناتۆخ',
'E6E6FA' : 'شیری',
'FFF' : 'سپی'
},
scayt :
{
title : 'پشکنینی نووسه لهکاتی نووسین',
opera_title : 'پشتیوانی نهکراوه لهلایهن Opera',
enable : 'چالاککردنی SCAYT',
disable : 'ناچالاککردنی SCAYT',
about : 'دهربارهی SCAYT',
toggle : 'گۆڕینی SCAYT',
options : 'ههڵبژارده',
langs : 'زمانهکان',
moreSuggestions : 'پێشنیاری زیاتر',
ignore : 'پشتگوێخستن',
ignoreAll : 'پشتگوێخستنی ههمووی',
addWord : 'زیادکردنی ووشه',
emptyDic : 'ناوی فهرههنگ نابێت خاڵی بێت.',
optionsTab : 'ههڵبژارده',
allCaps : 'پشتگوێخستنی وشانهی پێکهاتووه لهپیتی گهوره',
ignoreDomainNames : 'پشتگوێخستنی دۆمهین',
mixedCase : 'پشتگوێخستنی وشانهی پێکهاتووه لهپیتی گهورهو بچووك',
mixedWithDigits : 'پشتگوێخستنی وشانهی پێکهاتووه لهژماره',
languagesTab : 'زمانهکان',
dictionariesTab : 'فهرههنگهکان',
dic_field_name : 'ناوی فهرههنگ',
dic_create : 'درووستکردن',
dic_restore : 'گهڕاندنهوه',
dic_delete : 'سڕینهوه',
dic_rename : 'گۆڕینی ناو',
dic_info : 'لهبنچینهدا فهرههنگی بهکارهێنهر کۆگاکردن کراوه له شهکرۆکه Cookie, ههرچۆنێك بێت شهکۆرکه سنووردار کراوه له قهباره کۆگاکردن.کاتێك فهرههنگی بهکارهێنهر گهیشته ئهم خاڵهی کهناتوانرێت زیاتر کۆگاکردن بکرێت له شهکرۆکه، ئهوسا فهرههنگهکه پێویسته کۆگابکرێت له ڕاژهکهی ئێمه. بۆ کۆگاکردنی زانیاری تایبهتی فهرههنگهکه له ڕاژهکهی ئێمه, پێویسته ناوێك ههڵبژێریت بۆ فهرههنگهکه. گهر تۆ فهرههنگێکی کۆگاکراوت ههیه, تکایه ناوی فهرههنگهکه بنووسه وه کلیکی دوگمهی گهڕاندنهوه بکه.',
aboutTab : 'دهربارهی'
},
about :
{
title : 'دهربارهی CKEditor',
dlgTitle : 'دهربارهی CKEditor',
help : 'سهیری $1 بکه بۆ یارمهتی.',
userGuide : 'ڕێپیشاندهری CKEditors',
moreInfo : 'بۆ زانیاری زیاتری مۆڵهت, تکایه سهردانی ماڵپهڕهکهمان بکه:',
copy : 'مافی لهبهرگرتنهوهی © $1. گشتی پارێزراوه.'
},
maximize : 'ئەوپهڕی گەورەیی',
minimize : 'ئەوپەڕی بچووکی',
fakeobjects :
{
anchor : 'لهنگهر',
flash : 'فلاش',
iframe : 'لهچوارچێوه',
hiddenfield : 'شاردنهوهی خانه',
unknown : 'بهرکارێکی نهناسراو'
},
resize : 'ڕابکێشە بۆ گۆڕینی قەبارەکەی',
colordialog :
{
title : 'ههڵبژاردنی ڕهنگ',
options : 'ههڵبژاردهی ڕهنگهکان',
highlight : 'نیشانکردن',
selected : 'ههڵبژاردرا',
clear : 'پاککردنهوه'
},
toolbarCollapse : 'شاردنەوی هێڵی تووڵامراز',
toolbarExpand : 'نیشاندانی هێڵی تووڵامراز',
toolbarGroups :
{
document : 'پهڕه',
clipboard : 'بڕین/پووچکردنهوه',
editing : 'چاکسازی',
forms : 'داڕشته',
basicstyles : 'شێوازی بنچینهیی',
paragraph : 'بڕگه',
links : 'بهستهر',
insert : 'خستنه ناو',
styles : 'شێواز',
colors : 'ڕهنگهکان',
tools : 'ئامرازهکان'
},
bidi :
{
ltr : 'ئاراستهی نووسه لهچهپ بۆ ڕاست',
rtl : 'ئاراستهی نووسه لهڕاست بۆ چهپ'
},
docprops :
{
label : 'خاسییهتی پهڕه',
title : 'خاسییهتی پهڕه',
design : 'شێوهکار',
meta : 'زانیاری مێتا',
chooseColor : 'ههڵبژێره',
other : 'هیتر...',
docTitle : 'سهردێڕی پهڕه',
charset : 'دهستهی نووسهی بهکۆدهکهر',
charsetOther : 'دهستهی نووسهی بهکۆدهکهری تر',
charsetASCII : 'ASCII',
charsetCE : 'ناوهڕاست ئهوروپا',
charsetCT : 'چینی(Big5)',
charsetCR : 'سیریلیك',
charsetGR : 'یۆنانی',
charsetJP : 'ژاپۆن',
charsetKR : 'کۆریا',
charsetTR : 'تورکیا',
charsetUN : 'Unicode (UTF-8)',
charsetWE : 'ڕۆژئاوای ئهوروپا',
docType : 'سهرپهڕهی جۆری پهڕه',
docTypeOther : 'سهرپهڕهی جۆری پهڕهی تر',
xhtmlDec : 'بهیاننامهکانی XHTML لهگهڵدابێت',
bgColor : 'ڕهنگی پاشبنهما',
bgImage : 'ناونیشانی بهستهری وێنهی پاشبنهما',
bgFixed : 'بێ هاتووچوپێکردنی (چهسپاو) پاشبنهمای وێنه',
txtColor : 'ڕهنگی دهق',
margin : 'تهنیشت پهڕه',
marginTop : 'سهرهوه',
marginLeft : 'چهپ',
marginRight : 'ڕاست',
marginBottom : 'ژێرهوه',
metaKeywords : 'بهڵگهنامهی وشهی کاریگهر(به کۆما لێکیان جیابکهوه)',
metaDescription : 'پێناسهی لاپهڕه',
metaAuthor : 'نووسهر',
metaCopyright : 'مافی بڵاوکردنهوهی',
previewHtml : '<p>ئهمه وهك نموونهی <strong>دهقه</strong>. تۆ بهکاردههێنیت <a href="javascript:void(0)">CKEditor</a>.</p>'
}
};
| JavaScript |
/*
Copyright (c) 2003-2012, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.editorConfig = function( config )
{
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
};
| JavaScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.