Real-Time Find and Replace - Version 2.0

Version Description

  • Interface revamped.
  • New feature: Can re-order your rules via drag-and-drop.
Download this release

Release Info

Developer Marios Alexandrou
Plugin Icon 128x128 Real-Time Find and Replace
Version 2.0
Comparing to
See all releases

Code changes from version 1.6 to 2.0

css/draggable.png ADDED
Binary file
css/far.css ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .postbox .hndle {
2
+ border-top-left-radius: 3px;
3
+ border-top-right-radius: 3px;
4
+ margin-bottom: 20px;
5
+ }
6
+
7
+ h3 {
8
+ font-size: 15px;
9
+ font-weight: normal;
10
+ padding-top: 7px;
11
+ padding-right: 10px;
12
+ padding-bottom: 7px;
13
+ padding-left: 10px;
14
+ margin-top: 0px;
15
+ margin-right: 0px;
16
+ margin-bottom: 0px;
17
+ margin-left: 0px;
18
+ line-height: 1;
19
+ }
20
+
21
+ #far_sb {
22
+ padding-top: 70px;
23
+ width: 300px;
24
+ float: left;
25
+ }
26
+
27
+ .left {
28
+ display: block;
29
+ float: left;
30
+ }
31
+
32
+ #far_items {
33
+ width: 600px;
34
+ float: left;
35
+ }
36
+
37
+ #far_items ul {
38
+ padding: 10px 0;
39
+ clear: both;
40
+ width: 600px;
41
+ display: block;
42
+
43
+ }
44
+
45
+ #far_items li {
46
+ width: 550px;
47
+ display: block;
48
+ float: left;
49
+ margin: 0px;
50
+ padding: 10px;
51
+
52
+ border-top-color: #dfdfdf;
53
+ border-right-color-value: #dfdfdf;
54
+ border-bottom-color: #dfdfdf;
55
+ border-left-color-value: #dfdfdf;
56
+ box-shadow: #ffffff;
57
+ border-top-left-radius: 3px;
58
+ border-top-right-radius: 3px;
59
+ border-bottom-right-radius: 3px;
60
+ border-bottom-left-radius: 3px;
61
+ background-color: #f5f5f5;
62
+ background-repeat: repeat;
63
+ background-attachment: scroll;
64
+ background-position: 0% 0%;
65
+ background-clip: border-box;
66
+ background-origin: padding-box;
67
+ background-size: auto auto;
68
+ background-image: #f5f5f5;
69
+ }
70
+
71
+ #far_items li {
72
+ background-image: url(draggable.png);
73
+ background-repeat: no-repeat;
74
+ background-position: 5px 45px;
75
+ padding-left: 30px;
76
+ overflow: auto;
77
+ border: 1px solid #d5d5d5;
78
+ }
79
+
80
+ #far_items textarea {
81
+ width: 225px;
82
+ min-height: 75px;
83
+ margin-right: 5px;
84
+ resize: vertical;
85
+ }
86
+
87
+ #far_items input {
88
+ margin-right: 5px;
89
+ }
90
+
91
+ .findh {
92
+ display: inline-block;
93
+ float: left;
94
+ padding: 0px;
95
+ font-size: 12pt;
96
+ font-weight: bold;
97
+ padding-top: 10px;
98
+ padding: 20px 0 0 30px;
99
+ }
100
+
101
+ .replaceh {
102
+ display: inline-block;
103
+ float: left;
104
+ padding: 0px;
105
+ font-size: 12pt;
106
+ font-weight: bold;
107
+ padding-top: 10px;
108
+ padding: 20px 0 0 200px;
109
+ }
110
+
111
+
112
+ .clearpad {
113
+ clear: both;
114
+ padding: 10px;
115
+ }
js/jquery-ui-1.10.3.custom.min.js ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ /*! jQuery UI - v1.10.3 - 2013-10-07
2
+ * http://jqueryui.com
3
+ * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.sortable.js
4
+ * Copyright 2013 jQuery Foundation and other contributors; Licensed MIT */
5
+
6
+ (function(t,e){function n(e,n){var r,s,o,a=e.nodeName.toLowerCase();return"area"===a?(r=e.parentNode,s=r.name,e.href&&s&&"map"===r.nodeName.toLowerCase()?(o=t("img[usemap=#"+s+"]")[0],!!o&&i(o)):!1):(/input|select|textarea|button|object/.test(a)?!e.disabled:"a"===a?e.href||n:n)&&i(e)}function i(e){return t.expr.filters.visible(e)&&!t(e).parents().addBack().filter(function(){return"hidden"===t.css(this,"visibility")}).length}var r=0,s=/^ui-id-\d+$/;t.ui=t.ui||{},t.extend(t.ui,{version:"1.10.3",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),t.fn.extend({focus:function(e){return function(n,i){return"number"==typeof n?this.each(function(){var e=this;setTimeout(function(){t(e).focus(),i&&i.call(e)},n)}):e.apply(this,arguments)}}(t.fn.focus),scrollParent:function(){var e;return e=t.ui.ie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(t.css(this,"position"))&&/(auto|scroll)/.test(t.css(this,"overflow")+t.css(this,"overflow-y")+t.css(this,"overflow-x"))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(t.css(this,"overflow")+t.css(this,"overflow-y")+t.css(this,"overflow-x"))}).eq(0),/fixed/.test(this.css("position"))||!e.length?t(document):e},zIndex:function(n){if(n!==e)return this.css("zIndex",n);if(this.length)for(var i,r,s=t(this[0]);s.length&&s[0]!==document;){if(i=s.css("position"),("absolute"===i||"relative"===i||"fixed"===i)&&(r=parseInt(s.css("zIndex"),10),!isNaN(r)&&0!==r))return r;s=s.parent()}return 0},uniqueId:function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++r)})},removeUniqueId:function(){return this.each(function(){s.test(this.id)&&t(this).removeAttr("id")})}}),t.extend(t.expr[":"],{data:t.expr.createPseudo?t.expr.createPseudo(function(e){return function(n){return!!t.data(n,e)}}):function(e,n,i){return!!t.data(e,i[3])},focusable:function(e){return n(e,!isNaN(t.attr(e,"tabindex")))},tabbable:function(e){var i=t.attr(e,"tabindex"),r=isNaN(i);return(r||i>=0)&&n(e,!r)}}),t("<a>").outerWidth(1).jquery||t.each(["Width","Height"],function(n,i){function r(e,n,i,r){return t.each(s,function(){n-=parseFloat(t.css(e,"padding"+this))||0,i&&(n-=parseFloat(t.css(e,"border"+this+"Width"))||0),r&&(n-=parseFloat(t.css(e,"margin"+this))||0)}),n}var s="Width"===i?["Left","Right"]:["Top","Bottom"],o=i.toLowerCase(),a={innerWidth:t.fn.innerWidth,innerHeight:t.fn.innerHeight,outerWidth:t.fn.outerWidth,outerHeight:t.fn.outerHeight};t.fn["inner"+i]=function(n){return n===e?a["inner"+i].call(this):this.each(function(){t(this).css(o,r(this,n)+"px")})},t.fn["outer"+i]=function(e,n){return"number"!=typeof e?a["outer"+i].call(this,e):this.each(function(){t(this).css(o,r(this,e,!0,n)+"px")})}}),t.fn.addBack||(t.fn.addBack=function(t){return this.add(null==t?this.prevObject:this.prevObject.filter(t))}),t("<a>").data("a-b","a").removeData("a-b").data("a-b")&&(t.fn.removeData=function(e){return function(n){return arguments.length?e.call(this,t.camelCase(n)):e.call(this)}}(t.fn.removeData)),t.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),t.support.selectstart="onselectstart"in document.createElement("div"),t.fn.extend({disableSelection:function(){return this.bind((t.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(t){t.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),t.extend(t.ui,{plugin:{add:function(e,n,i){var r,s=t.ui[e].prototype;for(r in i)s.plugins[r]=s.plugins[r]||[],s.plugins[r].push([n,i[r]])},call:function(t,e,n){var i,r=t.plugins[e];if(r&&t.element[0].parentNode&&11!==t.element[0].parentNode.nodeType)for(i=0;r.length>i;i++)t.options[r[i][0]]&&r[i][1].apply(t.element,n)}},hasScroll:function(e,n){if("hidden"===t(e).css("overflow"))return!1;var i=n&&"left"===n?"scrollLeft":"scrollTop",r=!1;return e[i]>0?!0:(e[i]=1,r=e[i]>0,e[i]=0,r)}})})(jQuery);(function(t,e){var i=0,s=Array.prototype.slice,o=t.cleanData;t.cleanData=function(e){for(var i,s=0;null!=(i=e[s]);s++)try{t(i).triggerHandler("remove")}catch(n){}o(e)},t.widget=function(i,s,o){var n,r,a,h,l={},c=i.split(".")[0];i=i.split(".")[1],n=c+"-"+i,o||(o=s,s=t.Widget),t.expr[":"][n.toLowerCase()]=function(e){return!!t.data(e,n)},t[c]=t[c]||{},r=t[c][i],a=t[c][i]=function(t,i){return this._createWidget?(arguments.length&&this._createWidget(t,i),e):new a(t,i)},t.extend(a,r,{version:o.version,_proto:t.extend({},o),_childConstructors:[]}),h=new s,h.options=t.widget.extend({},h.options),t.each(o,function(i,o){return t.isFunction(o)?(l[i]=function(){var t=function(){return s.prototype[i].apply(this,arguments)},e=function(t){return s.prototype[i].apply(this,t)};return function(){var i,s=this._super,n=this._superApply;return this._super=t,this._superApply=e,i=o.apply(this,arguments),this._super=s,this._superApply=n,i}}(),e):(l[i]=o,e)}),a.prototype=t.widget.extend(h,{widgetEventPrefix:r?h.widgetEventPrefix:i},l,{constructor:a,namespace:c,widgetName:i,widgetFullName:n}),r?(t.each(r._childConstructors,function(e,i){var s=i.prototype;t.widget(s.namespace+"."+s.widgetName,a,i._proto)}),delete r._childConstructors):s._childConstructors.push(a),t.widget.bridge(i,a)},t.widget.extend=function(i){for(var o,n,r=s.call(arguments,1),a=0,h=r.length;h>a;a++)for(o in r[a])n=r[a][o],r[a].hasOwnProperty(o)&&n!==e&&(i[o]=t.isPlainObject(n)?t.isPlainObject(i[o])?t.widget.extend({},i[o],n):t.widget.extend({},n):n);return i},t.widget.bridge=function(i,o){var n=o.prototype.widgetFullName||i;t.fn[i]=function(r){var a="string"==typeof r,h=s.call(arguments,1),l=this;return r=!a&&h.length?t.widget.extend.apply(null,[r].concat(h)):r,a?this.each(function(){var s,o=t.data(this,n);return o?t.isFunction(o[r])&&"_"!==r.charAt(0)?(s=o[r].apply(o,h),s!==o&&s!==e?(l=s&&s.jquery?l.pushStack(s.get()):s,!1):e):t.error("no such method '"+r+"' for "+i+" widget instance"):t.error("cannot call methods on "+i+" prior to initialization; "+"attempted to call method '"+r+"'")}):this.each(function(){var e=t.data(this,n);e?e.option(r||{})._init():t.data(this,n,new o(r,this))}),l}},t.Widget=function(){},t.Widget._childConstructors=[],t.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(e,s){s=t(s||this.defaultElement||this)[0],this.element=t(s),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=t.widget.extend({},this.options,this._getCreateOptions(),e),this.bindings=t(),this.hoverable=t(),this.focusable=t(),s!==this&&(t.data(s,this.widgetFullName,this),this._on(!0,this.element,{remove:function(t){t.target===s&&this.destroy()}}),this.document=t(s.style?s.ownerDocument:s.document||s),this.window=t(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:t.noop,_getCreateEventData:t.noop,_create:t.noop,_init:t.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(t.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:t.noop,widget:function(){return this.element},option:function(i,s){var o,n,r,a=i;if(0===arguments.length)return t.widget.extend({},this.options);if("string"==typeof i)if(a={},o=i.split("."),i=o.shift(),o.length){for(n=a[i]=t.widget.extend({},this.options[i]),r=0;o.length-1>r;r++)n[o[r]]=n[o[r]]||{},n=n[o[r]];if(i=o.pop(),s===e)return n[i]===e?null:n[i];n[i]=s}else{if(s===e)return this.options[i]===e?null:this.options[i];a[i]=s}return this._setOptions(a),this},_setOptions:function(t){var e;for(e in t)this._setOption(e,t[e]);return this},_setOption:function(t,e){return this.options[t]=e,"disabled"===t&&(this.widget().toggleClass(this.widgetFullName+"-disabled ui-state-disabled",!!e).attr("aria-disabled",e),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")),this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_on:function(i,s,o){var n,r=this;"boolean"!=typeof i&&(o=s,s=i,i=!1),o?(s=n=t(s),this.bindings=this.bindings.add(s)):(o=s,s=this.element,n=this.widget()),t.each(o,function(o,a){function h(){return i||r.options.disabled!==!0&&!t(this).hasClass("ui-state-disabled")?("string"==typeof a?r[a]:a).apply(r,arguments):e}"string"!=typeof a&&(h.guid=a.guid=a.guid||h.guid||t.guid++);var l=o.match(/^(\w+)\s*(.*)$/),c=l[1]+r.eventNamespace,p=l[2];p?n.delegate(p,c,h):s.bind(c,h)})},_off:function(t,e){e=(e||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,t.unbind(e).undelegate(e)},_delay:function(t,e){function i(){return("string"==typeof t?s[t]:t).apply(s,arguments)}var s=this;return setTimeout(i,e||0)},_hoverable:function(e){this.hoverable=this.hoverable.add(e),this._on(e,{mouseenter:function(e){t(e.currentTarget).addClass("ui-state-hover")},mouseleave:function(e){t(e.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(e){this.focusable=this.focusable.add(e),this._on(e,{focusin:function(e){t(e.currentTarget).addClass("ui-state-focus")},focusout:function(e){t(e.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(e,i,s){var o,n,r=this.options[e];if(s=s||{},i=t.Event(i),i.type=(e===this.widgetEventPrefix?e:this.widgetEventPrefix+e).toLowerCase(),i.target=this.element[0],n=i.originalEvent)for(o in n)o in i||(i[o]=n[o]);return this.element.trigger(i,s),!(t.isFunction(r)&&r.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},t.each({show:"fadeIn",hide:"fadeOut"},function(e,i){t.Widget.prototype["_"+e]=function(s,o,n){"string"==typeof o&&(o={effect:o});var r,a=o?o===!0||"number"==typeof o?i:o.effect||i:e;o=o||{},"number"==typeof o&&(o={duration:o}),r=!t.isEmptyObject(o),o.complete=n,o.delay&&s.delay(o.delay),r&&t.effects&&t.effects.effect[a]?s[e](o):a!==e&&s[a]?s[a](o.duration,o.easing,n):s.queue(function(i){t(this)[e](),n&&n.call(s[0]),i()})}})})(jQuery);(function(t){var e=!1;t(document).mouseup(function(){e=!1}),t.widget("ui.mouse",{version:"1.10.3",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var e=this;this.element.bind("mousedown."+this.widgetName,function(t){return e._mouseDown(t)}).bind("click."+this.widgetName,function(s){return!0===t.data(s.target,e.widgetName+".preventClickEvent")?(t.removeData(s.target,e.widgetName+".preventClickEvent"),s.stopImmediatePropagation(),!1):undefined}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&t(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(s){if(!e){this._mouseStarted&&this._mouseUp(s),this._mouseDownEvent=s;var i=this,o=1===s.which,n="string"==typeof this.options.cancel&&s.target.nodeName?t(s.target).closest(this.options.cancel).length:!1;return o&&!n&&this._mouseCapture(s)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){i.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(s)&&this._mouseDelayMet(s)&&(this._mouseStarted=this._mouseStart(s)!==!1,!this._mouseStarted)?(s.preventDefault(),!0):(!0===t.data(s.target,this.widgetName+".preventClickEvent")&&t.removeData(s.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(t){return i._mouseMove(t)},this._mouseUpDelegate=function(t){return i._mouseUp(t)},t(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),s.preventDefault(),e=!0,!0)):!0}},_mouseMove:function(e){return t.ui.ie&&(!document.documentMode||9>document.documentMode)&&!e.button?this._mouseUp(e):this._mouseStarted?(this._mouseDrag(e),e.preventDefault()):(this._mouseDistanceMet(e)&&this._mouseDelayMet(e)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,e)!==!1,this._mouseStarted?this._mouseDrag(e):this._mouseUp(e)),!this._mouseStarted)},_mouseUp:function(e){return t(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,e.target===this._mouseDownEvent.target&&t.data(e.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(e)),!1},_mouseDistanceMet:function(t){return Math.max(Math.abs(this._mouseDownEvent.pageX-t.pageX),Math.abs(this._mouseDownEvent.pageY-t.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}})})(jQuery);(function(t){function e(t,e,i){return t>e&&e+i>t}function i(t){return/left|right/.test(t.css("float"))||/inline|table-cell/.test(t.css("display"))}t.widget("ui.sortable",t.ui.mouse,{version:"1.10.3",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_create:function(){var t=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?"x"===t.axis||i(this.items[0].item):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var t=this.items.length-1;t>=0;t--)this.items[t].item.removeData(this.widgetName+"-item");return this},_setOption:function(e,i){"disabled"===e?(this.options[e]=i,this.widget().toggleClass("ui-sortable-disabled",!!i)):t.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(e,i){var s=null,o=!1,n=this;return this.reverting?!1:this.options.disabled||"static"===this.options.type?!1:(this._refreshItems(e),t(e.target).parents().each(function(){return t.data(this,n.widgetName+"-item")===n?(s=t(this),!1):undefined}),t.data(e.target,n.widgetName+"-item")===n&&(s=t(e.target)),s?!this.options.handle||i||(t(this.options.handle,s).find("*").addBack().each(function(){this===e.target&&(o=!0)}),o)?(this.currentItem=s,this._removeCurrentsFromItems(),!0):!1:!1)},_mouseStart:function(e,i,s){var o,n,r=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(e),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},t.extend(this.offset,{click:{left:e.pageX-this.offset.left,top:e.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(e),this.originalPageX=e.pageX,this.originalPageY=e.pageY,r.cursorAt&&this._adjustOffsetFromHelper(r.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),r.containment&&this._setContainment(),r.cursor&&"auto"!==r.cursor&&(n=this.document.find("body"),this.storedCursor=n.css("cursor"),n.css("cursor",r.cursor),this.storedStylesheet=t("<style>*{ cursor: "+r.cursor+" !important; }</style>").appendTo(n)),r.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",r.opacity)),r.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",r.zIndex)),this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",e,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!s)for(o=this.containers.length-1;o>=0;o--)this.containers[o]._trigger("activate",e,this._uiHash(this));return t.ui.ddmanager&&(t.ui.ddmanager.current=this),t.ui.ddmanager&&!r.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(e),!0},_mouseDrag:function(e){var i,s,o,n,r=this.options,a=!1;for(this.position=this._generatePosition(e),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-e.pageY<r.scrollSensitivity?this.scrollParent[0].scrollTop=a=this.scrollParent[0].scrollTop+r.scrollSpeed:e.pageY-this.overflowOffset.top<r.scrollSensitivity&&(this.scrollParent[0].scrollTop=a=this.scrollParent[0].scrollTop-r.scrollSpeed),this.overflowOffset.left+this.scrollParent[0].offsetWidth-e.pageX<r.scrollSensitivity?this.scrollParent[0].scrollLeft=a=this.scrollParent[0].scrollLeft+r.scrollSpeed:e.pageX-this.overflowOffset.left<r.scrollSensitivity&&(this.scrollParent[0].scrollLeft=a=this.scrollParent[0].scrollLeft-r.scrollSpeed)):(e.pageY-t(document).scrollTop()<r.scrollSensitivity?a=t(document).scrollTop(t(document).scrollTop()-r.scrollSpeed):t(window).height()-(e.pageY-t(document).scrollTop())<r.scrollSensitivity&&(a=t(document).scrollTop(t(document).scrollTop()+r.scrollSpeed)),e.pageX-t(document).scrollLeft()<r.scrollSensitivity?a=t(document).scrollLeft(t(document).scrollLeft()-r.scrollSpeed):t(window).width()-(e.pageX-t(document).scrollLeft())<r.scrollSensitivity&&(a=t(document).scrollLeft(t(document).scrollLeft()+r.scrollSpeed))),a!==!1&&t.ui.ddmanager&&!r.dropBehaviour&&t.ui.ddmanager.prepareOffsets(this,e)),this.positionAbs=this._convertPositionTo("absolute"),this.options.axis&&"y"===this.options.axis||(this.helper[0].style.left=this.position.left+"px"),this.options.axis&&"x"===this.options.axis||(this.helper[0].style.top=this.position.top+"px"),i=this.items.length-1;i>=0;i--)if(s=this.items[i],o=s.item[0],n=this._intersectsWithPointer(s),n&&s.instance===this.currentContainer&&o!==this.currentItem[0]&&this.placeholder[1===n?"next":"prev"]()[0]!==o&&!t.contains(this.placeholder[0],o)&&("semi-dynamic"===this.options.type?!t.contains(this.element[0],o):!0)){if(this.direction=1===n?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(s))break;this._rearrange(e,s),this._trigger("change",e,this._uiHash());break}return this._contactContainers(e),t.ui.ddmanager&&t.ui.ddmanager.drag(this,e),this._trigger("sort",e,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(e,i){if(e){if(t.ui.ddmanager&&!this.options.dropBehaviour&&t.ui.ddmanager.drop(this,e),this.options.revert){var s=this,o=this.placeholder.offset(),n=this.options.axis,r={};n&&"x"!==n||(r.left=o.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollLeft)),n&&"y"!==n||(r.top=o.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,t(this.helper).animate(r,parseInt(this.options.revert,10)||500,function(){s._clear(e)})}else this._clear(e,i);return!1}},cancel:function(){if(this.dragging){this._mouseUp({target:null}),"original"===this.options.helper?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var e=this.containers.length-1;e>=0;e--)this.containers[e]._trigger("deactivate",null,this._uiHash(this)),this.containers[e].containerCache.over&&(this.containers[e]._trigger("out",null,this._uiHash(this)),this.containers[e].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),t.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?t(this.domPosition.prev).after(this.currentItem):t(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},t(i).each(function(){var i=(t(e.item||this).attr(e.attribute||"id")||"").match(e.expression||/(.+)[\-=_](.+)/);i&&s.push((e.key||i[1]+"[]")+"="+(e.key&&e.expression?i[1]:i[2]))}),!s.length&&e.key&&s.push(e.key+"="),s.join("&")},toArray:function(e){var i=this._getItemsAsjQuery(e&&e.connected),s=[];return e=e||{},i.each(function(){s.push(t(e.item||this).attr(e.attribute||"id")||"")}),s},_intersectsWith:function(t){var e=this.positionAbs.left,i=e+this.helperProportions.width,s=this.positionAbs.top,o=s+this.helperProportions.height,n=t.left,r=n+t.width,a=t.top,h=a+t.height,l=this.offset.click.top,c=this.offset.click.left,p="x"===this.options.axis||s+l>a&&h>s+l,f="y"===this.options.axis||e+c>n&&r>e+c,u=p&&f;return"pointer"===this.options.tolerance||this.options.forcePointerForContainers||"pointer"!==this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>t[this.floating?"width":"height"]?u:e+this.helperProportions.width/2>n&&r>i-this.helperProportions.width/2&&s+this.helperProportions.height/2>a&&h>o-this.helperProportions.height/2},_intersectsWithPointer:function(t){var i="x"===this.options.axis||e(this.positionAbs.top+this.offset.click.top,t.top,t.height),s="y"===this.options.axis||e(this.positionAbs.left+this.offset.click.left,t.left,t.width),o=i&&s,n=this._getDragVerticalDirection(),r=this._getDragHorizontalDirection();return o?this.floating?r&&"right"===r||"down"===n?2:1:n&&("down"===n?2:1):!1},_intersectsWithSides:function(t){var i=e(this.positionAbs.top+this.offset.click.top,t.top+t.height/2,t.height),s=e(this.positionAbs.left+this.offset.click.left,t.left+t.width/2,t.width),o=this._getDragVerticalDirection(),n=this._getDragHorizontalDirection();return this.floating&&n?"right"===n&&s||"left"===n&&!s:o&&("down"===o&&i||"up"===o&&!i)},_getDragVerticalDirection:function(){var t=this.positionAbs.top-this.lastPositionAbs.top;return 0!==t&&(t>0?"down":"up")},_getDragHorizontalDirection:function(){var t=this.positionAbs.left-this.lastPositionAbs.left;return 0!==t&&(t>0?"right":"left")},refresh:function(t){return this._refreshItems(t),this.refreshPositions(),this},_connectWith:function(){var t=this.options;return t.connectWith.constructor===String?[t.connectWith]:t.connectWith},_getItemsAsjQuery:function(e){var i,s,o,n,r=[],a=[],h=this._connectWith();if(h&&e)for(i=h.length-1;i>=0;i--)for(o=t(h[i]),s=o.length-1;s>=0;s--)n=t.data(o[s],this.widgetFullName),n&&n!==this&&!n.options.disabled&&a.push([t.isFunction(n.options.items)?n.options.items.call(n.element):t(n.options.items,n.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),n]);for(a.push([t.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):t(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),i=a.length-1;i>=0;i--)a[i][0].each(function(){r.push(this)});return t(r)},_removeCurrentsFromItems:function(){var e=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=t.grep(this.items,function(t){for(var i=0;e.length>i;i++)if(e[i]===t.item[0])return!1;return!0})},_refreshItems:function(e){this.items=[],this.containers=[this];var i,s,o,n,r,a,h,l,c=this.items,p=[[t.isFunction(this.options.items)?this.options.items.call(this.element[0],e,{item:this.currentItem}):t(this.options.items,this.element),this]],f=this._connectWith();if(f&&this.ready)for(i=f.length-1;i>=0;i--)for(o=t(f[i]),s=o.length-1;s>=0;s--)n=t.data(o[s],this.widgetFullName),n&&n!==this&&!n.options.disabled&&(p.push([t.isFunction(n.options.items)?n.options.items.call(n.element[0],e,{item:this.currentItem}):t(n.options.items,n.element),n]),this.containers.push(n));for(i=p.length-1;i>=0;i--)for(r=p[i][1],a=p[i][0],s=0,l=a.length;l>s;s++)h=t(a[s]),h.data(this.widgetName+"-item",r),c.push({item:h,instance:r,width:0,height:0,left:0,top:0})},refreshPositions:function(e){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());var i,s,o,n;for(i=this.items.length-1;i>=0;i--)s=this.items[i],s.instance!==this.currentContainer&&this.currentContainer&&s.item[0]!==this.currentItem[0]||(o=this.options.toleranceElement?t(this.options.toleranceElement,s.item):s.item,e||(s.width=o.outerWidth(),s.height=o.outerHeight()),n=o.offset(),s.left=n.left,s.top=n.top);if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(i=this.containers.length-1;i>=0;i--)n=this.containers[i].element.offset(),this.containers[i].containerCache.left=n.left,this.containers[i].containerCache.top=n.top,this.containers[i].containerCache.width=this.containers[i].element.outerWidth(),this.containers[i].containerCache.height=this.containers[i].element.outerHeight();return this},_createPlaceholder:function(e){e=e||this;var i,s=e.options;s.placeholder&&s.placeholder.constructor!==String||(i=s.placeholder,s.placeholder={element:function(){var s=e.currentItem[0].nodeName.toLowerCase(),o=t("<"+s+">",e.document[0]).addClass(i||e.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper");return"tr"===s?e.currentItem.children().each(function(){t("<td>&#160;</td>",e.document[0]).attr("colspan",t(this).attr("colspan")||1).appendTo(o)}):"img"===s&&o.attr("src",e.currentItem.attr("src")),i||o.css("visibility","hidden"),o},update:function(t,o){(!i||s.forcePlaceholderSize)&&(o.height()||o.height(e.currentItem.innerHeight()-parseInt(e.currentItem.css("paddingTop")||0,10)-parseInt(e.currentItem.css("paddingBottom")||0,10)),o.width()||o.width(e.currentItem.innerWidth()-parseInt(e.currentItem.css("paddingLeft")||0,10)-parseInt(e.currentItem.css("paddingRight")||0,10)))}}),e.placeholder=t(s.placeholder.element.call(e.element,e.currentItem)),e.currentItem.after(e.placeholder),s.placeholder.update(e,e.placeholder)},_contactContainers:function(s){var o,n,r,a,h,l,c,p,f,u,d=null,m=null;for(o=this.containers.length-1;o>=0;o--)if(!t.contains(this.currentItem[0],this.containers[o].element[0]))if(this._intersectsWith(this.containers[o].containerCache)){if(d&&t.contains(this.containers[o].element[0],d.element[0]))continue;d=this.containers[o],m=o}else this.containers[o].containerCache.over&&(this.containers[o]._trigger("out",s,this._uiHash(this)),this.containers[o].containerCache.over=0);if(d)if(1===this.containers.length)this.containers[m].containerCache.over||(this.containers[m]._trigger("over",s,this._uiHash(this)),this.containers[m].containerCache.over=1);else{for(r=1e4,a=null,u=d.floating||i(this.currentItem),h=u?"left":"top",l=u?"width":"height",c=this.positionAbs[h]+this.offset.click[h],n=this.items.length-1;n>=0;n--)t.contains(this.containers[m].element[0],this.items[n].item[0])&&this.items[n].item[0]!==this.currentItem[0]&&(!u||e(this.positionAbs.top+this.offset.click.top,this.items[n].top,this.items[n].height))&&(p=this.items[n].item.offset()[h],f=!1,Math.abs(p-c)>Math.abs(p+this.items[n][l]-c)&&(f=!0,p+=this.items[n][l]),r>Math.abs(p-c)&&(r=Math.abs(p-c),a=this.items[n],this.direction=f?"up":"down"));if(!a&&!this.options.dropOnEmpty)return;if(this.currentContainer===this.containers[m])return;a?this._rearrange(s,a,null,!0):this._rearrange(s,null,this.containers[m].element,!0),this._trigger("change",s,this._uiHash()),this.containers[m]._trigger("change",s,this._uiHash(this)),this.currentContainer=this.containers[m],this.options.placeholder.update(this.currentContainer,this.placeholder),this.containers[m]._trigger("over",s,this._uiHash(this)),this.containers[m].containerCache.over=1}},_createHelper:function(e){var i=this.options,s=t.isFunction(i.helper)?t(i.helper.apply(this.element[0],[e,this.currentItem])):"clone"===i.helper?this.currentItem.clone():this.currentItem;return s.parents("body").length||t("parent"!==i.appendTo?i.appendTo:this.currentItem[0].parentNode)[0].appendChild(s[0]),s[0]===this.currentItem[0]&&(this._storedCSS={width:this.currentItem[0].style.width,height:this.currentItem[0].style.height,position:this.currentItem.css("position"),top:this.currentItem.css("top"),left:this.currentItem.css("left")}),(!s[0].style.width||i.forceHelperSize)&&s.width(this.currentItem.width()),(!s[0].style.height||i.forceHelperSize)&&s.height(this.currentItem.height()),s},_adjustOffsetFromHelper:function(e){"string"==typeof e&&(e=e.split(" ")),t.isArray(e)&&(e={left:+e[0],top:+e[1]||0}),"left"in e&&(this.offset.click.left=e.left+this.margins.left),"right"in e&&(this.offset.click.left=this.helperProportions.width-e.right+this.margins.left),"top"in e&&(this.offset.click.top=e.top+this.margins.top),"bottom"in e&&(this.offset.click.top=this.helperProportions.height-e.bottom+this.margins.top)},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var e=this.offsetParent.offset();return"absolute"===this.cssPosition&&this.scrollParent[0]!==document&&t.contains(this.scrollParent[0],this.offsetParent[0])&&(e.left+=this.scrollParent.scrollLeft(),e.top+=this.scrollParent.scrollTop()),(this.offsetParent[0]===document.body||this.offsetParent[0].tagName&&"html"===this.offsetParent[0].tagName.toLowerCase()&&t.ui.ie)&&(e={top:0,left:0}),{top:e.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:e.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if("relative"===this.cssPosition){var t=this.currentItem.position();return{top:t.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:t.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.currentItem.css("marginLeft"),10)||0,top:parseInt(this.currentItem.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var e,i,s,o=this.options;"parent"===o.containment&&(o.containment=this.helper[0].parentNode),("document"===o.containment||"window"===o.containment)&&(this.containment=[0-this.offset.relative.left-this.offset.parent.left,0-this.offset.relative.top-this.offset.parent.top,t("document"===o.containment?document:window).width()-this.helperProportions.width-this.margins.left,(t("document"===o.containment?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top]),/^(document|window|parent)$/.test(o.containment)||(e=t(o.containment)[0],i=t(o.containment).offset(),s="hidden"!==t(e).css("overflow"),this.containment=[i.left+(parseInt(t(e).css("borderLeftWidth"),10)||0)+(parseInt(t(e).css("paddingLeft"),10)||0)-this.margins.left,i.top+(parseInt(t(e).css("borderTopWidth"),10)||0)+(parseInt(t(e).css("paddingTop"),10)||0)-this.margins.top,i.left+(s?Math.max(e.scrollWidth,e.offsetWidth):e.offsetWidth)-(parseInt(t(e).css("borderLeftWidth"),10)||0)-(parseInt(t(e).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,i.top+(s?Math.max(e.scrollHeight,e.offsetHeight):e.offsetHeight)-(parseInt(t(e).css("borderTopWidth"),10)||0)-(parseInt(t(e).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top])},_convertPositionTo:function(e,i){i||(i=this.position);var s="absolute"===e?1:-1,o="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,n=/(html|body)/i.test(o[0].tagName);return{top:i.top+this.offset.relative.top*s+this.offset.parent.top*s-("fixed"===this.cssPosition?-this.scrollParent.scrollTop():n?0:o.scrollTop())*s,left:i.left+this.offset.relative.left*s+this.offset.parent.left*s-("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():n?0:o.scrollLeft())*s}},_generatePosition:function(e){var i,s,o=this.options,n=e.pageX,r=e.pageY,a="absolute"!==this.cssPosition||this.scrollParent[0]!==document&&t.contains(this.scrollParent[0],this.offsetParent[0])?this.scrollParent:this.offsetParent,h=/(html|body)/i.test(a[0].tagName);return"relative"!==this.cssPosition||this.scrollParent[0]!==document&&this.scrollParent[0]!==this.offsetParent[0]||(this.offset.relative=this._getRelativeOffset()),this.originalPosition&&(this.containment&&(e.pageX-this.offset.click.left<this.containment[0]&&(n=this.containment[0]+this.offset.click.left),e.pageY-this.offset.click.top<this.containment[1]&&(r=this.containment[1]+this.offset.click.top),e.pageX-this.offset.click.left>this.containment[2]&&(n=this.containment[2]+this.offset.click.left),e.pageY-this.offset.click.top>this.containment[3]&&(r=this.containment[3]+this.offset.click.top)),o.grid&&(i=this.originalPageY+Math.round((r-this.originalPageY)/o.grid[1])*o.grid[1],r=this.containment?i-this.offset.click.top>=this.containment[1]&&i-this.offset.click.top<=this.containment[3]?i:i-this.offset.click.top>=this.containment[1]?i-o.grid[1]:i+o.grid[1]:i,s=this.originalPageX+Math.round((n-this.originalPageX)/o.grid[0])*o.grid[0],n=this.containment?s-this.offset.click.left>=this.containment[0]&&s-this.offset.click.left<=this.containment[2]?s:s-this.offset.click.left>=this.containment[0]?s-o.grid[0]:s+o.grid[0]:s)),{top:r-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():h?0:a.scrollTop()),left:n-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():h?0:a.scrollLeft())}},_rearrange:function(t,e,i,s){i?i[0].appendChild(this.placeholder[0]):e.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?e.item[0]:e.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var o=this.counter;this._delay(function(){o===this.counter&&this.refreshPositions(!s)})},_clear:function(t,e){this.reverting=!1;var i,s=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(i in this._storedCSS)("auto"===this._storedCSS[i]||"static"===this._storedCSS[i])&&(this._storedCSS[i]="");this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!e&&s.push(function(t){this._trigger("receive",t,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||e||s.push(function(t){this._trigger("update",t,this._uiHash())}),this!==this.currentContainer&&(e||(s.push(function(t){this._trigger("remove",t,this._uiHash())}),s.push(function(t){return function(e){t._trigger("receive",e,this._uiHash(this))}}.call(this,this.currentContainer)),s.push(function(t){return function(e){t._trigger("update",e,this._uiHash(this))}}.call(this,this.currentContainer)))),i=this.containers.length-1;i>=0;i--)e||s.push(function(t){return function(e){t._trigger("deactivate",e,this._uiHash(this))}}.call(this,this.containers[i])),this.containers[i].containerCache.over&&(s.push(function(t){return function(e){t._trigger("out",e,this._uiHash(this))}}.call(this,this.containers[i])),this.containers[i].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,this.cancelHelperRemoval){if(!e){for(this._trigger("beforeStop",t,this._uiHash()),i=0;s.length>i;i++)s[i].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!1}if(e||this._trigger("beforeStop",t,this._uiHash()),this.placeholder[0].parentNode.removeChild(this.placeholder[0]),this.helper[0]!==this.currentItem[0]&&this.helper.remove(),this.helper=null,!e){for(i=0;s.length>i;i++)s[i].call(this,t);this._trigger("stop",t,this._uiHash())}return this.fromOutside=!1,!0},_trigger:function(){t.Widget.prototype._trigger.apply(this,arguments)===!1&&this.cancel()},_uiHash:function(e){var i=e||this;return{helper:i.helper,placeholder:i.placeholder||t([]),position:i.position,originalPosition:i.originalPosition,offset:i.positionAbs,item:i.currentItem,sender:e?e.element:null}}})})(jQuery);
js/jquery.dynamicfields.js CHANGED
@@ -1,9 +1,23 @@
1
  function addFormField() {
2
- var id = document.getElementById("id").value;
3
- jQuery("#divTxt").append("<p id='row" + id + "'><label for='farfind" + id + "'>Find:&nbsp;</label><textarea rows='2' cols='30' name='farfind[" + id + "]' id='farfind" + id + "' /></textarea>&nbsp;&nbsp;<label for='farregex" + id + "'>RegEx?:&nbsp;</label><input type='checkbox' name='farregex[" + id + "]' id='farregex" + id + "' />&nbsp;&nbsp;<label for='farreplace" + id + "'>Replace:&nbsp;</label><textarea rows='2' cols='30' name='farreplace[" + id + "]' id='farreplace" + id + "' /></textarea>&nbsp;&nbsp&nbsp;<a href='#' onClick='removeFormField(\"#row" + id + "\"); return false;'>Remove</a></p>");
 
 
 
4
  id = (id - 1) + 2;
5
  document.getElementById("id").value = id;
 
 
 
 
 
6
  }
7
  function removeFormField(id) {
8
  jQuery(id).remove();
9
  }
 
 
 
 
 
 
1
  function addFormField() {
2
+ var id = jQuery('#id').val();
3
+ jQuery("#far_itemlist").append("<li id ='row" + id + "'><textarea class='left' name='farfind["+ id +"]' id='farfind" + id + "'></textarea>"
4
+ + "<textarea class='left' name='farreplace["+ id +"]' id='farreplace" + id + "'></textarea>"
5
+ + "<label class='left' for='farregex" + id + "'>RegEx?:&nbsp;</label><input class='left' type='checkbox' name='farregex[" + id + "]' id='farregex" + id +"'/><br />"
6
+ + "<br /><input type='button' class='button left remove' value='Remove' onClick='removeFormField(\"#row"+ id +"\"); return false;' />\n</li>");
7
  id = (id - 1) + 2;
8
  document.getElementById("id").value = id;
9
+
10
+ jQuery('html, body').animate({
11
+ scrollTop: jQuery("#row"+(id-1)).offset().top
12
+ }, 1000);
13
+
14
  }
15
  function removeFormField(id) {
16
  jQuery(id).remove();
17
  }
18
+
19
+
20
+ jQuery(function() {
21
+ jQuery( "#far_itemlist" ).sortable();
22
+
23
+ });
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: http://infolific.com/technology/software-worth-using/real-time-find
4
  Tags: find, replace
5
  Requires at least: 2.7
6
  Tested up to: 3.6.1
7
- Stable tag: 1.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -24,7 +24,7 @@ Here are some real-world examples:
24
 
25
  Here are some more examples:
26
 
27
- http://infolific.com/technology/blogging-and-web-publishing/handiest-wordpress-plugin-youve-never-heard-of/
28
 
29
  And remember, all of the above can be done WITHOUT modifying themes or plugin files so you'll always be able to upgrade them without having to worry about losing custom edits.
30
 
@@ -85,4 +85,8 @@ http://wordpress.org/extend/plugins/rss-includes-pages/
85
  * Fixed some jQuery bugs affecting the adding and removing of boxes.
86
 
87
  = 1.6 =
88
- * Fixed problem with HTML character handling. Thanks to acub (http://profiles.wordpress.org/acub) for the code.
 
 
 
 
4
  Tags: find, replace
5
  Requires at least: 2.7
6
  Tested up to: 3.6.1
7
+ Stable tag: 2.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
24
 
25
  Here are some more examples:
26
 
27
+ http://infolific.com/technology/internet/handiest-wordpress-plugin-youve-never-heard-of/
28
 
29
  And remember, all of the above can be done WITHOUT modifying themes or plugin files so you'll always be able to upgrade them without having to worry about losing custom edits.
30
 
85
  * Fixed some jQuery bugs affecting the adding and removing of boxes.
86
 
87
  = 1.6 =
88
+ * Fixed problem with HTML character handling. Thanks to acub (http://profiles.wordpress.org/acub) for the code.
89
+
90
+ = 2.0 =
91
+ * Interface revamped.
92
+ * New feature: Can re-order your rules via drag-and-drop.
real-time-find-and-replace.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: Real-Time Find and Replace
4
- Version: 1.6
5
  Plugin URI: http://infolific.com/technology/software-worth-using/real-time-find-and-replace-for-wordpress/
6
  Description: Set up find and replace rules that are executed AFTER a page is generated by WordPress, but BEFORE it is sent to a user's browser.
7
  Author: Marios Alexandrou
@@ -45,35 +45,105 @@ function far_options_page(){
45
  } ?>
46
  <div class="wrap" style="padding-bottom:5em">
47
  <h2>Real-Time Find and Replace</h2>
48
- <p>Enter your find and replace cases below.</p>
 
 
49
  <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
 
 
 
 
 
 
 
 
50
  <?php
51
  $farsettings = get_option('far_plugin_settings');
52
  if (is_array($farsettings['farfind'])){ //if there are any finds already set
53
  $i=1;
54
  foreach ($farsettings['farfind'] as $key => $find){
55
  if(isset($farsettings['farregex'][$key]))
56
- $regex = 'CHECKED';
57
  $replace = $farsettings['farreplace'][$key];
58
- echo "<p id='row$i'><label for='farfind$i'>Find:&nbsp;</label><textarea rows='3' cols='30' name='farfind[$i]' id='farfind$i'>".esc_textarea( $find )."</textarea>&nbsp;&nbsp;<label for='farregex$i'>RegEx?:&nbsp;</label><input type='checkbox' name='farregex[$i]' id='farregex$i' $regex />&nbsp;&nbsp;<label for='farreplace$i'>Replace:&nbsp;</label><textarea rows='3' cols='30' name='farreplace[$i]' id='farreplace$i'>".esc_textarea( $replace )."</textarea>&nbsp;&nbsp&nbsp;<a href='#' onClick='removeFormField(\"#row$i\"); return false;'>Remove</a></p>\n";
 
 
 
 
59
  unset($regex);
60
  $i++;
61
  }
62
  } else {
63
- echo 'Click "Add" below to begin.';
64
  }
65
  ?>
 
66
  <div id="divTxt"></div>
67
- <p><a href="#" onClick="addFormField(); return false;">Add</a></p>
68
- <input type="hidden" id="id" value="<?php echo $i; /*used so javascript returns unique ids*/ ?>" />
69
- <input type="hidden" name="setup-update" />
70
- <p><input type="submit" class="button" value="Update Settings" /></p>
71
  </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  </div>
73
  <?php
74
  }
75
  function far_admin_scripts(){ // these scripts print on the admin page
76
  wp_enqueue_script('far_dynamicfields', plugins_url() . '/real-time-find-and-replace/js/jquery.dynamicfields.js', array('jquery'));
 
 
 
 
77
  }
78
 
79
  /*
@@ -97,5 +167,4 @@ function far_template_redirect(){
97
  ob_start('far_ob_call');
98
  }
99
  add_action('template_redirect', 'far_template_redirect');
100
-
101
  ?>
1
  <?php
2
  /*
3
  Plugin Name: Real-Time Find and Replace
4
+ Version: 2.0
5
  Plugin URI: http://infolific.com/technology/software-worth-using/real-time-find-and-replace-for-wordpress/
6
  Description: Set up find and replace rules that are executed AFTER a page is generated by WordPress, but BEFORE it is sent to a user's browser.
7
  Author: Marios Alexandrou
45
  } ?>
46
  <div class="wrap" style="padding-bottom:5em">
47
  <h2>Real-Time Find and Replace</h2>
48
+ <p> Enter your find and replace cases below. Click and drag to change the order. </p>
49
+ <div id="far_items">
50
+
51
  <form method="post" action="<?php echo $_SERVER["REQUEST_URI"]; ?>">
52
+ <input type="button" class="button left" value="Add" onClick="addFormField(); return false;" />
53
+ <input type="submit" class="button left" value="Update Settings" />
54
+ <input type="hidden" name="setup-update" />
55
+ <br style="clear:both;"/>
56
+ <h3 class="findh">Find</h3>
57
+ <h3 class="replaceh">Replace</h3>
58
+
59
+ <ul id="far_itemlist">
60
  <?php
61
  $farsettings = get_option('far_plugin_settings');
62
  if (is_array($farsettings['farfind'])){ //if there are any finds already set
63
  $i=1;
64
  foreach ($farsettings['farfind'] as $key => $find){
65
  if(isset($farsettings['farregex'][$key]))
66
+ $regex = 'CHECKED';
67
  $replace = $farsettings['farreplace'][$key];
68
+ echo "<li id='row$i'>";
69
+ echo "<textarea class='left' name='farfind[$i]' id='farfind$i'>".esc_textarea( $find )."</textarea>";
70
+ echo "<textarea class='left' name='farreplace[$i]' id='farreplace$i'>".esc_textarea( $replace )."</textarea>";
71
+ echo "<label class='left' for='farregex$i'>RegEx?:&nbsp;</label><input class='left' type='checkbox' name='farregex[$i]' id='farregex$i' $regex /><br />";
72
+ echo "<br /><input type='button' class='button left remove' value='Remove' onClick='removeFormField(\"#row$i\"); return false;' />\n</p>";
73
  unset($regex);
74
  $i++;
75
  }
76
  } else {
77
+ echo 'Click "Add" to begin.';
78
  }
79
  ?>
80
+ </ul>
81
  <div id="divTxt"></div>
82
+ <div class="clearpad"></div>
83
+ <input type="button" class="button left" value="Add" onClick="addFormField(); return false;" />
84
+ <input type="submit" class="button left" value="Update Settings" />
85
+ <input type="hidden" id="id" value="<?php echo $i; /*used so javascript returns unique ids*/ ?>" />
86
  </form>
87
+ </div>
88
+
89
+ <div id="far_sb">
90
+
91
+ <div class="postbox" id="far_sbone">
92
+ <h3 class='hndle'><span>Documentation</span></h3>
93
+ <div class="inside">
94
+ <strong>Instructions</strong>
95
+ <p>This plugin will replace HTML code AFTER it is rendered. None of these changes affect your files. To undo changes, just delete the find/replace pair.</p>
96
+ <ol>
97
+ <li>Type in text/code to find on the left. This can be a plain text match or a regular expression (use / at the start and end).</li>
98
+ <li>Type in the text/code you want to replace the find with on the right.</li>
99
+ <li>If using a regular expression for the find, check the regex box.</li>
100
+ </ol>
101
+ <strong>Tips</strong>
102
+ <ol>
103
+ <li>Want to remove text/code from a page? Leave the replace box blank.</li>
104
+ <li>Want to disable a rule, but not delete it? Put something random in the match box that will not actually be matched.</li>
105
+ <li>Not seeing your changes? Turn off your cache!</li>
106
+ <li>Seeing a blank page on your site? A bad regex is the most common cause.</li>
107
+ <li>Need some ideas? <a href="http://infolific.com/technology/internet/handiest-wordpress-plugin-youve-never-heard-of/">Check out this post.</a></li>
108
+ </ol>
109
+ </div>
110
+ </div>
111
+
112
+
113
+ <div class="postbox" id="far_sbtwo">
114
+ <h3 class='hndle'><span>Support</span></h3>
115
+ <div class="inside">
116
+ <p>You best bet is to post on the <a href="http://wordpress.org/support/plugin/real-time-find-and-replace">plugin support page</a>.</p>
117
+ <p>Please consider supporting me too! Follow me on <a href="https://twitter.com/malexandrou">Twitter</a> or <a href="http://wordpress.org/plugins/real-time-find-and-replace/">rate the plugin</a>. Thanks!</p>
118
+ </div>
119
+ </div>
120
+
121
+
122
+ <div class="postbox" id="far_sbthree">
123
+ <h3 class='hndle'><span>Other Plugins</span></h3>
124
+ <div class="inside">
125
+ <ul>
126
+ <li><a href="http://wordpress.org/extend/plugins/rss-includes-pages/">RSS Includes Pages</a>: Modifies RSS feeds so that they include pages and not just posts. My most popular plugin!
127
+ <li><a href="http://wordpress.org/extend/plugins/social-media-email-alerts/">Social Media E-Mail Alerts</a>: Receive e-mail alerts when your site gets traffic from social media sites of your choosing. You can also set up alerts for when certain parameters app.</li>
128
+ </ul>
129
+ </div>
130
+ </div>
131
+
132
+
133
+
134
+ </div>
135
+
136
+
137
+
138
  </div>
139
  <?php
140
  }
141
  function far_admin_scripts(){ // these scripts print on the admin page
142
  wp_enqueue_script('far_dynamicfields', plugins_url() . '/real-time-find-and-replace/js/jquery.dynamicfields.js', array('jquery'));
143
+ wp_enqueue_script('jquery-ui-1', plugins_url() . '/real-time-find-and-replace/js/jquery-ui-1.10.3.custom.min.js', array('jquery'));
144
+ wp_enqueue_style('far_styles', plugins_url() . '/real-time-find-and-replace/css/far.css');
145
+
146
+
147
  }
148
 
149
  /*
167
  ob_start('far_ob_call');
168
  }
169
  add_action('template_redirect', 'far_template_redirect');
 
170
  ?>