move giant notes inline script into its own file
This commit is contained in:
parent
b8ac8b7710
commit
1303a5aa7b
72
contrib/notes/script.js
Normal file
72
contrib/notes/script.js
Normal file
@ -0,0 +1,72 @@
|
||||
$(function() {
|
||||
$('#main_image').imgNotes(); //If your notes data is is not named notes pass it
|
||||
|
||||
$('#cancelnote').click(function(){
|
||||
$('#main_image').imgAreaSelect({ hide: true });
|
||||
$('#noteform').hide();
|
||||
});
|
||||
|
||||
$('#EditCancelNote').click(function() {
|
||||
$('#main_image').imgAreaSelect({ hide: true });
|
||||
$('#noteEditForm').hide();
|
||||
});
|
||||
|
||||
$('#addnote').click(function(){
|
||||
$('#noteEditForm').hide();
|
||||
$('#main_image').imgAreaSelect({ onSelectChange: showaddnote, x1: 120, y1: 90, x2: 280, y2: 210 });
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.note').click(function() {
|
||||
$('#noteform').hide();
|
||||
var imgOffset = $('#main_image').offset();
|
||||
|
||||
var x1 = parseInt(this.style.left) - imgOffset.left;
|
||||
var y1 = parseInt(this.style.top) - imgOffset.top;
|
||||
var width = parseInt(this.style.width);
|
||||
var height = parseInt(this.style.height);
|
||||
var text = $(this).next('.notep').text().replace(/([^>]?)\\n{2}/g, '$1\\n');
|
||||
var id = $(this).next('.notep').next('.noteID').text();
|
||||
|
||||
$('#main_image').imgAreaSelect({ onSelectChange: showeditnote, x1: x1, y1: y1, x2: x1 + width, y2: y1 + height });
|
||||
setEditNoteData(x1, y1, width, height, text, id);
|
||||
});
|
||||
});
|
||||
|
||||
function showaddnote (img, area) {
|
||||
imgOffset = $(img).offset();
|
||||
form_left = parseInt(imgOffset.left) + parseInt(area.x1);
|
||||
form_top = parseInt(imgOffset.top) + parseInt(area.y1) + parseInt(area.height)+5;
|
||||
|
||||
$('#noteform').css({ left: form_left + 'px', top: form_top + 'px'});
|
||||
$('#noteform').show();
|
||||
$('#noteform').css('z-index', 10000);
|
||||
$('#NoteX1').val(area.x1);
|
||||
$('#NoteY1').val(area.y1);
|
||||
$('#NoteHeight').val(area.height);
|
||||
$('#NoteWidth').val(area.width);
|
||||
}
|
||||
|
||||
function showeditnote (img, area) {
|
||||
imgOffset = $(img).offset();
|
||||
form_left = parseInt(imgOffset.left) + area.x1;
|
||||
form_top = parseInt(imgOffset.top) + area.y2;
|
||||
|
||||
$('#noteEditForm').css({ left: form_left + 'px', top: form_top + 'px'});
|
||||
$('#noteEditForm').show();
|
||||
$('#noteEditForm').css('z-index', 10000);
|
||||
$('#EditNoteX1').val(area.x1);
|
||||
$('#EditNoteY1').val(area.y1);
|
||||
$('#EditNoteHeight').val(area.height);
|
||||
$('#EditNoteWidth').val(area.width);
|
||||
}
|
||||
|
||||
function setEditNoteData(x1, y1, width, height, text, id) {
|
||||
$('#EditNoteX1').val(x1);
|
||||
$('#EditNoteY1').val(y1);
|
||||
$('#EditNoteHeight').val(height);
|
||||
$('#EditNoteWidth').val(width);
|
||||
$('#EditNoteNote').text(text);
|
||||
$('#EditNoteID').val(id);
|
||||
$('#DeleteNoteNoteID').val(id);
|
||||
}
|
@ -2,25 +2,12 @@
|
||||
class NotesTheme extends Themelet {
|
||||
public function note_button($image_id) {
|
||||
return '
|
||||
<script type="text/javascript">
|
||||
function confirm_action() {
|
||||
var r=confirm("Are You Sure?");
|
||||
if (r==true) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- <a href="#" id="addnotelink" >Add a note</a> -->
|
||||
|
||||
<form action="" method="">
|
||||
<input type="button" id="addnote" value="Add Note">
|
||||
<input type="hidden" name="image_id" value="'.$image_id.'">
|
||||
</form>
|
||||
';
|
||||
<!-- <a href="#" id="addnotelink" >Add a note</a> -->
|
||||
<form action="" method="">
|
||||
<input type="button" id="addnote" value="Add Note">
|
||||
<input type="hidden" name="image_id" value="'.$image_id.'">
|
||||
</form>
|
||||
';
|
||||
}
|
||||
public function request_button($image_id) {
|
||||
return make_form(make_link("note/add_request")) . '
|
||||
@ -31,7 +18,7 @@ class NotesTheme extends Themelet {
|
||||
}
|
||||
public function nuke_notes_button($image_id) {
|
||||
return make_form(make_link("note/nuke_notes")) . '
|
||||
<input id="noterequest" type="submit" value="Nuke Notes" onclick="return confirm_action()">
|
||||
<input id="noterequest" type="submit" value="Nuke Notes" onclick="return confirm_action(\'Are you sure?\')">
|
||||
<input type="hidden" name="image_id" value="'.$image_id.'">
|
||||
</form>
|
||||
';
|
||||
@ -45,8 +32,8 @@ class NotesTheme extends Themelet {
|
||||
}
|
||||
|
||||
public function search_notes_page(Page $page) { //IN DEVELOPMENT, NOT FULLY WORKING
|
||||
$html = '<form method="GET" action="/furpiledbeta/post/list/note=">
|
||||
<input id="search_input" type="text" name="search"/>
|
||||
$html = '<form method="GET" action="'.make_link("post/list/note=").'">
|
||||
<input placeholder="Search Notes" type="text" name="search"/>
|
||||
<input type="submit" style="display: none;" value="Find"/>
|
||||
</form>';
|
||||
|
||||
@ -62,109 +49,26 @@ class NotesTheme extends Themelet {
|
||||
$page->add_html_header("<script src='$data_href/contrib/notes/jquery.qimgareaselect-0.4.js' type='text/javascript'></script>", 100);
|
||||
$page->add_html_header("<script src='$data_href/contrib/notes/jquery.rimgnotes-0.2.js' type='text/javascript'></script>", 101);
|
||||
|
||||
$html = "<script type='text/javascript'>
|
||||
|
||||
notes = [";
|
||||
|
||||
$to_json = array();
|
||||
foreach($recovered_notes as $note)
|
||||
{
|
||||
$parsedNote = $note["note"];
|
||||
$parsedNote = str_replace("\n", "\\n", $parsedNote);
|
||||
$parsedNote = str_replace("\r", "\\r", $parsedNote);
|
||||
|
||||
$html .= "{'x1':'".$note["x1"]."', ".
|
||||
"'y1':'".$note["y1"]."',".
|
||||
"'height':'".$note["height"]."',".
|
||||
"'width':'".$note["width"]."',".
|
||||
"'note':'".$parsedNote."',".
|
||||
"'note_id':'".$note["id"].
|
||||
"'},";
|
||||
}
|
||||
if (count($recovered_notes) > 0)
|
||||
{
|
||||
substr($html, 0, strlen($html) - 1); // remove final comma
|
||||
$to_json[] = array(
|
||||
'x1': $note["x1"],
|
||||
'y1': $note["y1"],
|
||||
'height': $note["height"],
|
||||
'width': $note["width"],
|
||||
'note': $parsedNote,
|
||||
'note_id': $note["id"],
|
||||
);
|
||||
}
|
||||
|
||||
$html .= "];
|
||||
";
|
||||
|
||||
$html .= "$(document).ready(function() {
|
||||
$('#main_image').imgNotes(); //If your notes data is is not named notes pass it
|
||||
|
||||
$('#cancelnote').click(function(){
|
||||
$('#main_image').imgAreaSelect({ hide: true });
|
||||
$('#noteform').hide();
|
||||
});
|
||||
|
||||
$('#EditCancelNote').click(function() {
|
||||
$('#main_image').imgAreaSelect({ hide: true });
|
||||
$('#noteEditForm').hide();
|
||||
});
|
||||
|
||||
$('#addnote').click(function(){
|
||||
$('#noteEditForm').hide();
|
||||
$('#main_image').imgAreaSelect({ onSelectChange: showaddnote, x1: 120, y1: 90, x2: 280, y2: 210 });
|
||||
return false;
|
||||
});
|
||||
|
||||
$('.note').click(function() {
|
||||
$('#noteform').hide();
|
||||
var imgOffset = $('#main_image').offset();
|
||||
|
||||
var x1 = parseInt(this.style.left) - imgOffset.left;
|
||||
var y1 = parseInt(this.style.top) - imgOffset.top;
|
||||
var width = parseInt(this.style.width);
|
||||
var height = parseInt(this.style.height);
|
||||
var text = $(this).next('.notep').text().replace(/([^>]?)\\n{2}/g, '$1\\n');
|
||||
var id = $(this).next('.notep').next('.noteID').text();
|
||||
|
||||
$('#main_image').imgAreaSelect({ onSelectChange: showeditnote, x1: x1, y1: y1, x2: x1 + width, y2: y1 + height });
|
||||
setEditNoteData(x1, y1, width, height, text, id);
|
||||
});
|
||||
});
|
||||
|
||||
function showaddnote (img, area) {
|
||||
imgOffset = $(img).offset();
|
||||
form_left = parseInt(imgOffset.left) + parseInt(area.x1);
|
||||
form_top = parseInt(imgOffset.top) + parseInt(area.y1) + parseInt(area.height)+5;
|
||||
|
||||
$('#noteform').css({ left: form_left + 'px', top: form_top + 'px'});
|
||||
|
||||
$('#noteform').show();
|
||||
|
||||
$('#noteform').css('z-index', 10000);
|
||||
$('#NoteX1').val(area.x1);
|
||||
$('#NoteY1').val(area.y1);
|
||||
$('#NoteHeight').val(area.height);
|
||||
$('#NoteWidth').val(area.width);
|
||||
}
|
||||
function showeditnote (img, area) {
|
||||
imgOffset = $(img).offset();
|
||||
form_left = parseInt(imgOffset.left) + area.x1;
|
||||
form_top = parseInt(imgOffset.top) + area.y2;
|
||||
|
||||
$('#noteEditForm').css({ left: form_left + 'px', top: form_top + 'px'});
|
||||
|
||||
$('#noteEditForm').show();
|
||||
|
||||
$('#noteEditForm').css('z-index', 10000);
|
||||
$('#EditNoteX1').val(area.x1);
|
||||
$('#EditNoteY1').val(area.y1);
|
||||
$('#EditNoteHeight').val(area.height);
|
||||
$('#EditNoteWidth').val(area.width);
|
||||
}
|
||||
function setEditNoteData(x1, y1, width, height, text, id)
|
||||
{
|
||||
$('#EditNoteX1').val(x1);
|
||||
$('#EditNoteY1').val(y1);
|
||||
$('#EditNoteHeight').val(height);
|
||||
$('#EditNoteWidth').val(width);
|
||||
$('#EditNoteNote').text(text);
|
||||
$('#EditNoteID').val(id);
|
||||
$('#DeleteNoteNoteID').val(id);
|
||||
}
|
||||
|
||||
</script>
|
||||
$html = "<script type='text/javascript'>";
|
||||
$html .= "notes = " . json_encode($to_json);
|
||||
$html .= "</script>
|
||||
|
||||
<div id='noteform'>
|
||||
".make_form(make_link("note/add_note"))."
|
||||
@ -224,7 +128,7 @@ class NotesTheme extends Themelet {
|
||||
|
||||
$html .= "</div>";
|
||||
|
||||
$page->add_block(new Block(null, $html, "main", 1));
|
||||
$page->add_block(new Block(null, $html, "main", 1));
|
||||
}
|
||||
|
||||
|
||||
@ -369,6 +273,5 @@ class NotesTheme extends Themelet {
|
||||
|
||||
$this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
}
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user