PageSourceSearch

https://emedialibrary.org/openedit/components/javascript/openedit.js

js emedialibrary.org collected 2026-10-09 17:44:25 UTC 8,467 bytes, 306 lines download raw bytes

1jQuery(document).ready(function () {
2	//insert a chunk of html
3	var body = jQuery("body");
4	var hide = body.data("hidetoolbar");
5	var isBlockfind = $("#application").hasClass("blockfind");
6	//console.log(hide);
7
8	if (hide != true && !isBlockfind) {
9		var path = window.location.pathname;
10		if (window.location.search) {
11			path = path + window.location.search;
12		}
13
14		jQuery.get(
15			"/openedit/components/toolbar/admintoolbarselector.html",
16			{ path: path },
17			function (data) {
18				body.prepend(data);
19
20				loadToolbar();
21			},
22		);
23
24		$(document).on("click", ".oe-enableedit", function () {
25			var apphome = jQuery("#application").data("apphome");
26			//<li><a href="$home/openedit/views/workflow/mode/viewdebug.html?origURL=$origURL" ><img src="$home/openedit/theme/images/toolbar/modepreview.gif" border="0" title="Debug Mode" />Debug Mode</a></li>
27
28			var args = $(this).data();
29			//Enable dashes on
30			$.get(href, args, function (data) {
31				//reload page
32			});
33		});
34
35		$(document).on("click", ".oeDialog", function () {
36			var target = $(this).data("target");
37			if (target == null) {
38				target = $(this).attr("href");
39			}
40			var title = $(this).data("title");
41			if (title != null) {
42				$("#modal-title").text(title);
43			}
44			$("#edit-modal-body").load(target, function (result) {
45				var textareas = jQuery(".htmleditor");
46				if (textareas.length > 0) {
47					loadEditors();
48				}
49				$("#editmodal").modal("show");
50			});
51			return false;
52		});
53
54		$(document).on("click", ".oemodechange", function (e) {
55			e.preventDefault();
56			var target = $(this).attr("href");
57			var title = $(this).attr("title");
58			jQuery.get(target, function () {
59				if (title != "DebugMode") {
60					window.location.reload();
61				}
62			});
63		});
64
65		jQuery("a.openeditdialog").each(function () {
66			var height = jQuery(window).height();
67			var width = jQuery(window).width();
68			height = height * 0.9;
69			width = width * 0.9;
70			if (width < 900) {
71				width = 1050;
72			}
73
74			var newfancy = jQuery(this).fancybox({
75				zoomSpeedIn: 300,
76				zoomSpeedOut: 300,
77				overlayShow: true,
78				enableEscapeButton: true,
79				type: "iframe",
80				height: height,
81				width: width,
82			});
83		});
84
85		//OLD Approach
86		jQuery("a.oeinlineedit").on("click", function (e) {
87			e.preventDefault();
88			e.stopPropagation();
89
90			var parent = $(this).closest(".openeditinline");
91			var container = parent.find(".openediteditcontent");
92
93			var editpath = parent.data("editpath");
94
95			// var catalogid = app.data("catalogid");
96			//alert("using " + catalogid);
97			var home = $("#openedit").data("home");
98			if (!home) {
99				home = "";
100			}
101			var savepath = home + "/openedit/components/html/save.html";
102
103			container.data("savepath", savepath);
104			container.data("editpath", editpath);
105
106			$(window).trigger("inlinehtmlstart", [container]);
107
108			/*
109			CKEDITOR.config.saveSubmitURL = savepath + "?editPath=" + editpath; //TODO: Save this URL specific to this editor
110			CKEDITOR.config.filebrowserBrowseUrl =
111				home + "/openedit/components/html/browse/index.html?editPath=$editPath";
112			CKEDITOR.config.filebrowserUploadUrl =
113				home + "/openedit/components/html/edit/actions/imageupload-finish.html";
114			CKEDITOR.config.filebrowserImageBrowseUrl =
115				home + "/openedit/components/html/browse/index.html?editPath=$editPath";
116			CKEDITOR.config.filebrowserImageUploadUrl =
117				home + "/openedit/components/html/edit/actions/imageupload-finish.html";
118			CKEDITOR.config.entities = false;
119			CKEDITOR.config.basicEntities = true;
120			var content = container.find(".openediteditcontent").get(0);
121			//var content = jQuery(".openediteditcontent" ).get(0);
122			content.setAttribute("contenteditable", "true");
123			var editor = CKEDITOR.inline(content, {
124				extraConfig: { oldcontent: "null" },
125				startupFocus: true,
126				on: {
127					dataReady: function (event) {
128						event.editor.config.extraConfig.oldcontent = event.editor.getData();
129					},
130					blur: function (event) {
131						var enCollator = new Intl.Collator("en");
132						var data = event.editor.getData();
133
134						if (
135							enCollator.compare(data, editor.config.extraConfig.oldcontent) !=
136							0
137						) {
138							$(window).on("beforeunload", function () {
139								return "You have unsaved changes.  Reloading will loose these changes.";
140							});
141						}
142						return false;
143					},
144					savecontentdone: function (event) {
145						location.reload();
146					},
147				},
148			});
149			*/
150		});
151	}
152
153	var content = $("textarea.oeeditorhtml");
154	if (content.length) {
155		$(window).trigger("edithtmlstart", [content]);
156	}
157
158	loadHtmlEditor = function (field, viewtype, container) {
159		var apphome = jQuery("#application").data("apphome");
160
161		var home = $("#openedit").data("home");
162		if (!home) {
163			home = "";
164		}
165
166		if (viewtype == "html") {
167			var savepath = home + apphome + "/components/data/save.html";
168			container.data("savepath", savepath);
169			var dataid = container.data("dataid");
170			if (dataid) {
171				container.data("id", dataid);
172			}
173			$(window).trigger("edithtmlstart", [container]);
174		} else if (viewtype == "input") {
175			var savepath = home + apphome + "/components/data/save.html";
176			var oldborder = container.css("border");
177			container.css("border", "1px dashed black");
178			content.setAttribute("contenteditable", "true");
179			container.focus();
180			var options = container.data();
181			options.save = true;
182			options.oemaxlevel = 1;
183			options.id = options.dataid;
184			var field = options.field;
185			container.keyup(function (evt) {
186				//save as we go?
187				// enter pressed
188				var contents = compoent.innerHTML;
189				options[field + ".value"] = contents;
190
191				//TODO: use "post" method for larger inputs not "get"
192				$.get(savepath, options, function () {
193					//reset border
194					//content.setAttribute('contenteditable', 'false');
195					container.css("border", oldborder);
196				});
197			});
198			//Capture the enter key
199		}
200	};
201
202	//onload
203
204	var editmode = jQuery("#application").data("editmode");
205
206	if (editmode == "postedit") {
207		var container = $(".oe-editable");
208		$(window).trigger("edithtmlstart", [container]);
209	}
210
211	//THis is a click that enabled something else to edit. Like a pencil icon
212	jQuery(document).on("click", ".oe-dataedit", function (e) {
213		console.log("Opening editor");
214		var container = $(this).data("target");
215		container = $(container);
216		// var content = container.get(0);
217		// var searchtype = container.data("searchtype");
218		// var id = container.data("dataid");
219		var field = container.data("field");
220		var viewtype = container.data("viewtype");
221		if (!viewtype) {
222			viewtype = "html";
223		}
224		var home = $("#openedit").data("home");
225		if (!home) {
226			home = "";
227		}
228		e.preventDefault();
229
230		loadHtmlEditor(field, viewtype, container);
231
232		return false;
233	});
234
235	var htminp = jQuery(".oehtmlinput");
236	if (htminp.length > 0) {
237		var field = htminp.data("field");
238		var viewtype = "html";
239		loadHtmlEditor(field, viewtype, htminp);
240	}
241
242	jQuery("form.oeajaxform").on("submit", function () {
243		var targetdiv = jQuery(this).attr("targetdiv");
244		targetdiv = targetdiv.replace(/\//g, "\\/");
245		//allows for posting to a div in the parent from a fancybox.
246		if (targetdiv.indexOf("parent.") == 0) {
247			targetdiv = targetdiv.substr(7);
248			parent.jQuery(this).ajaxSubmit({
249				target: "#" + targetdiv,
250				success: function () {
251					$(document).trigger("domchanged", "#" + targetdiv);
252				},
253			});
254
255			//closes the fancybox after submitting
256			parent.jQuery.fn.fancybox.close();
257		} else {
258			jQuery(this).ajaxSubmit({
259				target: "#" + targetdiv,
260				success: function () {
261					$(document).trigger("domchanged", "#" + targetdiv);
262				},
263			});
264		}
265		return false;
266	});
267});
268
269loadToolbar = function () {
270	jQuery("#oeselector").on("mouseenter", function () {
271		if (jQuery("#oeadmintoolbarlocation").is(":visible")) {
272			return;
273		}
274		var me = jQuery(this);
275		jQuery.get(me.attr("href"), {}, function (data) {
276			me.html(data);
277			jQuery("#oeadmintoolbarlocation").on("mouseleave", function () {
278				jQuery(this).hide();
279			});
280		});
281	});
282};
283
284showHover = function (inAssetId) {
285	var el = document.getElementById("oehover");
286	el = jQuery(el);
287	if (el.attr("status") == "show") {
288		if (inAssetId == el.attr("assetid")) {
289			el.show();
290		}
291	}
292};
293
294refreshFileMenu = function () {
295	var editpath = $("#fileoptionsmenu").data("editpath");
296
297	var home = $("#openedit").data("home");
298	if (!home) {
299		home = "";
300	}
301	$("#fileoptionsmenu").load(
302		home +
303			"/openedit/components/html/edit/menu.html?oemaxlevel=1&editPath=" +
304			editpath,
305	);
306};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.